From 29e92773846b286f8a47664a6581e048416a90fb Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Sat, 17 Jan 2015 18:16:48 +0100 Subject: [PATCH 01/18] =?UTF-8?q?reduce=20usage=20of=20JSDebuggerSupportUt?= =?UTF-8?q?ils=20=E2=80=94=20move=20getContextElement=20to=20new=20Debugge?= =?UTF-8?q?rSupportUtils=20util=20class=20(available=20in=20community)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jetbrains/debugger/DebuggerSupportUtils.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/DebuggerSupportUtils.java diff --git a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/DebuggerSupportUtils.java b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/DebuggerSupportUtils.java new file mode 100644 index 000000000000..f5bb519c0e71 --- /dev/null +++ b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/DebuggerSupportUtils.java @@ -0,0 +1,15 @@ +package org.jetbrains.debugger; + +import com.intellij.openapi.project.Project; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.psi.PsiElement; +import com.intellij.xdebugger.XDebuggerUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public final class DebuggerSupportUtils { + @Nullable + public static PsiElement getContextElement(@NotNull VirtualFile virtualFile, int offset, @NotNull Project project) { + return XDebuggerUtil.getInstance().findContextElement(virtualFile, offset, project, true); + } +} From f84ec8d9f634f9ae91bab050613e73fa525141ba Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Sat, 17 Jan 2015 18:25:25 +0100 Subject: [PATCH 02/18] reduce usage of JSDebuggerSupportUtils --- .../jetbrains/debugger/DebuggerSupportUtils.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/DebuggerSupportUtils.java b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/DebuggerSupportUtils.java index f5bb519c0e71..3f25196b5b18 100644 --- a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/DebuggerSupportUtils.java +++ b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/DebuggerSupportUtils.java @@ -1,15 +1,21 @@ package org.jetbrains.debugger; -import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiElement; import com.intellij.xdebugger.XDebuggerUtil; -import org.jetbrains.annotations.NotNull; +import com.intellij.xdebugger.XSourcePosition; import org.jetbrains.annotations.Nullable; public final class DebuggerSupportUtils { @Nullable - public static PsiElement getContextElement(@NotNull VirtualFile virtualFile, int offset, @NotNull Project project) { - return XDebuggerUtil.getInstance().findContextElement(virtualFile, offset, project, true); + public static XSourcePosition calcSourcePosition(@Nullable PsiElement element) { + if (element != null) { + PsiElement navigationElement = element.getNavigationElement(); + VirtualFile file = navigationElement.getContainingFile().getVirtualFile(); + if (file != null) { + return XDebuggerUtil.getInstance().createPositionByOffset(file, navigationElement.getTextOffset()); + } + } + return null; } } From cf6bfd7ef2cd4c276b40661235397a579529f43a Mon Sep 17 00:00:00 2001 From: Dennis Ushakov Date: Mon, 19 Jan 2015 12:44:24 +0300 Subject: [PATCH 03/18] #WEB-14743 fixed --- .../jetbrains/python/module/PyProjectStructureDetector.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/python/pluginSrc/com/jetbrains/python/module/PyProjectStructureDetector.java b/python/pluginSrc/com/jetbrains/python/module/PyProjectStructureDetector.java index 585ce5c16680..4e805355e83a 100644 --- a/python/pluginSrc/com/jetbrains/python/module/PyProjectStructureDetector.java +++ b/python/pluginSrc/com/jetbrains/python/module/PyProjectStructureDetector.java @@ -49,11 +49,15 @@ public class PyProjectStructureDetector extends ProjectStructureDetector { @NotNull List result) { LOG.info("Detecting roots under " + dir); for (File child : children) { - if (FileUtilRt.extensionEquals(child.getName(), "py")) { + final String name = child.getName(); + if (FileUtilRt.extensionEquals(name, "py")) { LOG.info("Found Python file " + child.getPath()); result.add(new DetectedContentRoot(dir, "Python", PythonModuleTypeBase.getInstance(), WebModuleType.getInstance())); return DirectoryProcessingResult.SKIP_CHILDREN; } + if ("node_modules".equals(name)) { + return DirectoryProcessingResult.SKIP_CHILDREN; + } } return DirectoryProcessingResult.PROCESS_CHILDREN; } From 4ff4a347ac342a72e3b9254821095e875dfc7f9f Mon Sep 17 00:00:00 2001 From: "Vladimir.Orlov" Date: Mon, 19 Jan 2015 17:12:35 +0300 Subject: [PATCH 04/18] IDEA-133615 Automatic update breaks --- platform/util/src/com/intellij/util/Restarter.java | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/util/src/com/intellij/util/Restarter.java b/platform/util/src/com/intellij/util/Restarter.java index 8ee6f46b1093..fdcc4f876b3f 100644 --- a/platform/util/src/com/intellij/util/Restarter.java +++ b/platform/util/src/com/intellij/util/Restarter.java @@ -156,6 +156,7 @@ public class Restarter { public static File createTempExecutable(File executable) throws IOException { File executableDir = new File(System.getProperty("user.home") + "/." + System.getProperty("idea.paths.selector") + "/restart"); File copy = new File(executableDir.getPath() + "/" + executable.getName()); + if (!FileUtilRt.createDirectory(executableDir)) throw new IOException("Cannot create dir: " + executableDir); if (!FileUtilRt.ensureCanCreateFile(copy) || (copy.exists() && !copy.delete())) { String ext = FileUtilRt.getExtension(executable.getName()); copy = FileUtilRt.createTempFile(executableDir, FileUtilRt.getNameWithoutExtension(copy.getName()), From 9cf3ef745393cdf5c72da0ddc17c65abbaf9919b Mon Sep 17 00:00:00 2001 From: Daniil Ovchinnikov Date: Mon, 19 Jan 2015 17:12:52 +0300 Subject: [PATCH 05/18] IDEA-135033 Storage for activation status fixed & .gdsl files within library sources ignored --- .../groovy/dsl/DslActivationStatus.java | 20 +++++++++++++------ .../groovy/dsl/GroovyDslFileIndex.java | 7 +++++-- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/dsl/DslActivationStatus.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/dsl/DslActivationStatus.java index de1d162148bb..267707e08207 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/dsl/DslActivationStatus.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/dsl/DslActivationStatus.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package org.jetbrains.plugins.groovy.dsl; import com.intellij.openapi.components.*; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileManager; import gnu.trove.THashMap; @@ -49,11 +50,16 @@ public class DslActivationStatus implements PersistentStateComponent { @Nullable public synchronized String getInactivityReason(VirtualFile file) { String status = myStatus.get(file); - return status == null || status == ENABLED ? null : status; + return ENABLED.equals(status) ? null : status; } public synchronized boolean isActivated(VirtualFile file) { - return myStatus.get(file) == ENABLED; + final String status = myStatus.get(file); + if (status == null) { + myStatus.put(file, ENABLED); + return true; + } + return ENABLED.equals(status); } @Nullable @@ -66,7 +72,9 @@ public class DslActivationStatus implements PersistentStateComponent { Element element = new Element("file"); root.addContent(element); element.setAttribute("url", file.getUrl()); - element.setAttribute("status", (status == ENABLED ? "" : status)); + if (!ENABLED.equals(status)) { + element.setAttribute("status", status); + } } return root; } @@ -76,10 +84,10 @@ public class DslActivationStatus implements PersistentStateComponent { List children = state.getChildren("file"); for (Element element : children) { String url = element.getAttributeValue("url", ""); - String status = element.getAttributeValue("status", ENABLED); + String status = element.getAttributeValue("status"); VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(url); if (file != null) { - myStatus.put(file, status); + myStatus.put(file, StringUtil.isNotEmpty(status) ? status : ENABLED); } } } diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/dsl/GroovyDslFileIndex.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/dsl/GroovyDslFileIndex.java index e9692292588f..692aab0efc4c 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/dsl/GroovyDslFileIndex.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/dsl/GroovyDslFileIndex.java @@ -74,7 +74,7 @@ import java.util.regex.Pattern; */ public class GroovyDslFileIndex extends ScalarIndexExtension { private static final Key> CACHED_EXECUTOR = Key.create("CachedGdslExecutor"); - private static final Logger LOG = Logger.getInstance("#org.jetbrains.plugins.groovy.dsl.GroovyDslFileIndex"); + private static final Logger LOG = Logger.getInstance(GroovyDslFileIndex.class); @NonNls public static final ID NAME = ID.create("GroovyDslFileIndex"); @NonNls private static final String OUR_KEY = "ourKey"; @@ -412,7 +412,10 @@ public class GroovyDslFileIndex extends ScalarIndexExtension { if (!vfile.isValid()) { continue; } - if (!fileIndex.isInLibraryClasses(vfile) && !fileIndex.isInLibrarySource(vfile)) { + if (fileIndex.isInLibrarySource(vfile)) { + continue; + } + if (!fileIndex.isInLibraryClasses(vfile)) { if (!fileIndex.isInSourceContent(vfile) || !isActivated(vfile)) { continue; } From d261422680c7868d5d556c7eee653fcd5f4fdcc2 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Mon, 19 Jan 2015 15:02:19 +0100 Subject: [PATCH 06/18] deleting classpath index files for changed output roots --- .../jps/incremental/IncProjectBuilder.java | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/IncProjectBuilder.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/IncProjectBuilder.java index 2f82e8df8b21..f8f576dec0fa 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/IncProjectBuilder.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/IncProjectBuilder.java @@ -16,10 +16,7 @@ package org.jetbrains.jps.incremental; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.util.LowMemoryWatcher; -import com.intellij.openapi.util.SystemInfo; -import com.intellij.openapi.util.UserDataHolder; -import com.intellij.openapi.util.UserDataHolderBase; +import com.intellij.openapi.util.*; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.SmartList; @@ -84,7 +81,7 @@ import java.util.concurrent.atomic.AtomicReference; public class IncProjectBuilder { private static final Logger LOG = Logger.getInstance("#org.jetbrains.jps.incremental.IncProjectBuilder"); - private static final String CLASSPATH_INDEX_FINE_NAME = "classpath.index"; + private static final String CLASSPATH_INDEX_FILE_NAME = "classpath.index"; private static final boolean GENERATE_CLASSPATH_INDEX = Boolean.parseBoolean(System.getProperty(GlobalOptions.GENERATE_CLASSPATH_INDEX_OPTION, "false")); private static final boolean SYNC_DELETE = Boolean.parseBoolean(System.getProperty("jps.sync.delete", SystemInfo.isWindows ? "true" : "false")); private static final GlobalContextKey>> TARGET_WITH_CLEARED_OUTPUT = GlobalContextKey.create("_targets_with_cleared_output_"); @@ -334,7 +331,25 @@ public class IncProjectBuilder { BuildRunner.PARALLEL_BUILD_ENABLED); context.addBuildListener(new ChainedTargetsBuildListener(context)); + + //Deletes class loader classpath index files for changed output roots + context.addBuildListener(new BuildListener() { + @Override + public void filesGenerated(Collection> paths) { + final Set outputs = new THashSet(FileUtil.FILE_HASHING_STRATEGY); + for (Pair pair : paths) { + outputs.add(new File(pair.getFirst())); + } + for (File root : outputs) { + //noinspection ResultOfMethodCallIgnored + new File(root, CLASSPATH_INDEX_FILE_NAME).delete(); + } + } + @Override + public void filesDeleted(Collection paths) { + } + }); for (TargetBuilder builder : myBuilderRegistry.getTargetBuilders()) { builder.buildStarted(context); } @@ -965,7 +980,7 @@ public class IncProjectBuilder { File outputDir = ((ModuleBuildTarget)target).getOutputDir(); if (outputDir != null && outputDirs.add(outputDir)) { try { - BufferedWriter writer = new BufferedWriter(new FileWriter(new File(outputDir, CLASSPATH_INDEX_FINE_NAME))); + BufferedWriter writer = new BufferedWriter(new FileWriter(new File(outputDir, CLASSPATH_INDEX_FILE_NAME))); try { writeIndex(writer, outputDir, ""); } From 439d072906234171ff988c6bfb5393be551479cd Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Mon, 19 Jan 2015 15:02:11 +0100 Subject: [PATCH 07/18] scopes: include/exclude disable status (IDEA-135311) --- .../util/scopeChooser/ScopeEditorPanel.java | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeEditorPanel.java b/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeEditorPanel.java index f36f1e8f9bc7..d4802b60188c 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeEditorPanel.java +++ b/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeEditorPanel.java @@ -38,6 +38,7 @@ import com.intellij.ui.*; import com.intellij.ui.components.panels.VerticalLayout; import com.intellij.ui.treeStructure.Tree; import com.intellij.util.Alarm; +import com.intellij.util.ArrayUtil; import com.intellij.util.Consumer; import com.intellij.util.ui.ColorIcon; import com.intellij.util.ui.UIUtil; @@ -237,11 +238,11 @@ public class ScopeEditorPanel { myPackageTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { - final boolean recursiveEnabled = isButtonEnabled(true, e.getPaths(), e); + final boolean recursiveEnabled = isButtonEnabled(true); includeRec.setEnabled(recursiveEnabled); excludeRec.setEnabled(recursiveEnabled); - final boolean nonRecursiveEnabled = isButtonEnabled(false, e.getPaths(), e); + final boolean nonRecursiveEnabled = isButtonEnabled(false); include.setEnabled(nonRecursiveEnabled); exclude.setEnabled(nonRecursiveEnabled); } @@ -281,19 +282,6 @@ public class ScopeEditorPanel { return buttonsPanel; } - static boolean isButtonEnabled(boolean rec, TreePath[] paths, TreeSelectionEvent e) { - if (paths != null) { - for (TreePath path : paths) { - if (!e.isAddedPath(path)) continue; - final PackageDependenciesNode node = (PackageDependenciesNode)path.getLastPathComponent(); - if (PatternDialectProvider.getInstance(DependencyUISettings.getInstance().SCOPE_TYPE).createPackageSet(node, rec) != null) { - return true; - } - } - } - return false; - } - boolean isButtonEnabled(boolean rec) { final TreePath[] paths = myPackageTree.getSelectionPaths(); if (paths != null) { From 296d5e3182d130a4f10b8b56ab0143d50ca6ae7c Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Mon, 19 Jan 2015 15:15:10 +0100 Subject: [PATCH 08/18] NPE (IDEA-135369) --- .../src/org/jetbrains/java/generate/psi/PsiAdapter.java | 8 ++++++-- .../openapi/projectRoots/JavaVersionServiceImpl.java | 2 ++ .../intellij/openapi/projectRoots/JavaVersionService.java | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/java/java-analysis-impl/src/org/jetbrains/java/generate/psi/PsiAdapter.java b/java/java-analysis-impl/src/org/jetbrains/java/generate/psi/PsiAdapter.java index 75d620e1f3be..e19f7f578bf9 100644 --- a/java/java-analysis-impl/src/org/jetbrains/java/generate/psi/PsiAdapter.java +++ b/java/java-analysis-impl/src/org/jetbrains/java/generate/psi/PsiAdapter.java @@ -18,8 +18,8 @@ package org.jetbrains.java.generate.psi; import com.intellij.openapi.project.Project; import com.intellij.openapi.projectRoots.JavaSdkVersion; import com.intellij.openapi.projectRoots.JavaVersionService; +import com.intellij.openapi.projectRoots.JdkVersionUtil; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.*; import com.intellij.psi.codeStyle.CodeStyleManager; import com.intellij.psi.codeStyle.JavaCodeStyleManager; @@ -670,7 +670,11 @@ public class PsiAdapter { } public static int getJavaVersion(PsiElement element) { - final JavaSdkVersion sdkVersion = JavaVersionService.getInstance().getJavaSdkVersion(element); + JavaSdkVersion sdkVersion = JavaVersionService.getInstance().getJavaSdkVersion(element); + if (sdkVersion == null) { + sdkVersion = JavaSdkVersion.fromLanguageLevel(PsiUtil.getLanguageLevel(element)); + } + int version = 0; switch (sdkVersion) { case JDK_1_0: diff --git a/java/java-impl/src/com/intellij/openapi/projectRoots/JavaVersionServiceImpl.java b/java/java-impl/src/com/intellij/openapi/projectRoots/JavaVersionServiceImpl.java index 1a3ce4e0cea2..e473f5c67281 100644 --- a/java/java-impl/src/com/intellij/openapi/projectRoots/JavaVersionServiceImpl.java +++ b/java/java-impl/src/com/intellij/openapi/projectRoots/JavaVersionServiceImpl.java @@ -17,6 +17,7 @@ package com.intellij.openapi.projectRoots; import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * @author anna @@ -28,6 +29,7 @@ public class JavaVersionServiceImpl extends JavaVersionService { return JavaSdkVersionUtil.isAtLeast(element, version); } + @Nullable @Override public JavaSdkVersion getJavaSdkVersion(@NotNull PsiElement element) { return JavaSdkVersionUtil.getJavaSdkVersion(element); diff --git a/java/java-psi-api/src/com/intellij/openapi/projectRoots/JavaVersionService.java b/java/java-psi-api/src/com/intellij/openapi/projectRoots/JavaVersionService.java index 5108c592c6ac..fe1873fdfd8d 100644 --- a/java/java-psi-api/src/com/intellij/openapi/projectRoots/JavaVersionService.java +++ b/java/java-psi-api/src/com/intellij/openapi/projectRoots/JavaVersionService.java @@ -23,6 +23,7 @@ import com.intellij.openapi.components.ServiceManager; import com.intellij.psi.PsiElement; import com.intellij.psi.util.PsiUtil; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public class JavaVersionService { public static JavaVersionService getInstance() { @@ -33,6 +34,7 @@ public class JavaVersionService { return PsiUtil.getLanguageLevel(element).isAtLeast(version.getMaxLanguageLevel()); } + @Nullable public JavaSdkVersion getJavaSdkVersion(@NotNull PsiElement element) { return JavaSdkVersion.fromLanguageLevel(PsiUtil.getLanguageLevel(element)); } From 4d2a8450dacb8cecf0cc45fe1ee5581938b1dedf Mon Sep 17 00:00:00 2001 From: nik Date: Mon, 19 Jan 2015 17:23:03 +0300 Subject: [PATCH 09/18] nio2 implementation of 'clonePermissions' corrected --- .../src/com/intellij/openapi/util/io/FileSystemUtil.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/platform/util/src/com/intellij/openapi/util/io/FileSystemUtil.java b/platform/util/src/com/intellij/openapi/util/io/FileSystemUtil.java index d734d4b4faa7..cbcf77d90fe6 100644 --- a/platform/util/src/com/intellij/openapi/util/io/FileSystemUtil.java +++ b/platform/util/src/com/intellij/openapi/util/io/FileSystemUtil.java @@ -305,12 +305,13 @@ public class FileSystemUtil { @Override protected boolean clonePermissions(@NotNull String source, @NotNull String target) throws Exception { if (SystemInfo.isUnix) { - Object pathObj = myGetPath.invoke(myDefaultFileSystem, source, ArrayUtil.EMPTY_STRING_ARRAY); - Map attributes = (Map)myReadAttributes.invoke(null, pathObj, "posix:permissions", myLinkOptions); + Object sourcePath = myGetPath.invoke(myDefaultFileSystem, source, ArrayUtil.EMPTY_STRING_ARRAY); + Object targetPath = myGetPath.invoke(myDefaultFileSystem, target, ArrayUtil.EMPTY_STRING_ARRAY); + Map attributes = (Map)myReadAttributes.invoke(null, sourcePath, "posix:permissions", myLinkOptions); if (attributes != null) { Object permissions = attributes.get("permissions"); if (permissions instanceof Collection) { - mySetAttribute.invoke(null, pathObj, "posix:permissions", permissions, myLinkOptions); + mySetAttribute.invoke(null, targetPath, "posix:permissions", permissions, myLinkOptions); return true; } } From 90a236e3f367d98032823e41b0a7dd6bd2b42480 Mon Sep 17 00:00:00 2001 From: nik Date: Mon, 19 Jan 2015 18:03:59 +0300 Subject: [PATCH 10/18] clone only 'executable' permissions during copying to avoid read-only files in the output (IDEA-133984) --- .../openapi/util/io/FileSystemUtil.java | 97 ++++++++++++++----- .../intellij/openapi/util/io/FileUtil.java | 2 +- 2 files changed, 76 insertions(+), 23 deletions(-) diff --git a/platform/util/src/com/intellij/openapi/util/io/FileSystemUtil.java b/platform/util/src/com/intellij/openapi/util/io/FileSystemUtil.java index cbcf77d90fe6..20e41ed39aad 100644 --- a/platform/util/src/com/intellij/openapi/util/io/FileSystemUtil.java +++ b/platform/util/src/com/intellij/openapi/util/io/FileSystemUtil.java @@ -56,7 +56,7 @@ public class FileSystemUtil { @Nullable protected abstract String resolveSymLink(@NotNull String path) throws Exception; - protected boolean clonePermissions(@NotNull String source, @NotNull String target) throws Exception { return false; } + protected boolean clonePermissions(@NotNull String source, @NotNull String target, boolean onlyPermissionsToExecute) throws Exception { return false; } @NotNull private String getName() { return getClass().getSimpleName().replace("MediatorImpl", ""); } @@ -196,7 +196,21 @@ public class FileSystemUtil { */ public static boolean clonePermissions(@NotNull String source, @NotNull String target) { try { - return ourMediator.clonePermissions(source, target); + return ourMediator.clonePermissions(source, target, false); + } + catch (Exception e) { + LOG.warn(e); + return false; + } + } + + /** + * Gives the second file permissions to execute of the first one if possible; returns true if succeed. + * Will do nothing on Windows. + */ + public static boolean clonePermissionsToExecute(@NotNull String source, @NotNull String target) { + try { + return ourMediator.clonePermissions(source, target, true); } catch (Exception e) { LOG.warn(e); @@ -303,22 +317,44 @@ public class FileSystemUtil { } @Override - protected boolean clonePermissions(@NotNull String source, @NotNull String target) throws Exception { + protected boolean clonePermissions(@NotNull String source, @NotNull String target, boolean onlyPermissionsToExecute) throws Exception { if (SystemInfo.isUnix) { Object sourcePath = myGetPath.invoke(myDefaultFileSystem, source, ArrayUtil.EMPTY_STRING_ARRAY); Object targetPath = myGetPath.invoke(myDefaultFileSystem, target, ArrayUtil.EMPTY_STRING_ARRAY); - Map attributes = (Map)myReadAttributes.invoke(null, sourcePath, "posix:permissions", myLinkOptions); - if (attributes != null) { - Object permissions = attributes.get("permissions"); - if (permissions instanceof Collection) { - mySetAttribute.invoke(null, targetPath, "posix:permissions", permissions, myLinkOptions); - return true; + Collection sourcePermissions = getPermissions(sourcePath); + if (sourcePermissions != null) { + Collection permissionsToSet; + if (onlyPermissionsToExecute) { + Collection targetPermissions = getPermissions(targetPath); + permissionsToSet = new HashSet(); + for (Object permission : targetPermissions) { + if (!permission.toString().endsWith("_EXECUTE")) { + permissionsToSet.add(permission); + } + } + for (Object permission : sourcePermissions) { + if (permission.toString().endsWith("_EXECUTE")) { + permissionsToSet.add(permission); + } + } } + else { + permissionsToSet = sourcePermissions; + } + mySetAttribute.invoke(null, targetPath, "posix:permissions", permissionsToSet, myLinkOptions); + return true; } } return false; } + + private Collection getPermissions(Object sourcePath) throws IllegalAccessException, InvocationTargetException { + Map attributes = (Map)myReadAttributes.invoke(null, sourcePath, "posix:permissions", myLinkOptions); + if (attributes == null) return null; + Object permissions = attributes.get("permissions"); + return permissions instanceof Collection ? (Collection)permissions : null; + } } @@ -347,6 +383,7 @@ public class FileSystemUtil { int S_IFREG = 0100000; // regular file int S_IFDIR = 0040000; // directory int PERM_MASK = 0777; + int EXECUTE_MASK = 0111; int WRITE_MASK = 0222; int W_OK = 2; // write permission flag for access(2) @@ -397,14 +434,13 @@ public class FileSystemUtil { int res = SystemInfo.isLinux ? myLibC.__lxstat64(0, path, buffer) : myLibC.lstat(path, buffer); if (res != 0) return null; - int mode = (SystemInfo.isLinux ? buffer.getInt(myOffsets[OFF_MODE]) : buffer.getShort(myOffsets[OFF_MODE])) & LibC.S_MASK; + int mode = getModeFlags(buffer) & LibC.S_MASK; boolean isSymlink = (mode & LibC.S_IFLNK) == LibC.S_IFLNK; if (isSymlink) { - res = SystemInfo.isLinux ? myLibC.__xstat64(0, path, buffer) : myLibC.stat(path, buffer); - if (res != 0) { + if (!loadFileStatus(path, buffer)) { return FileAttributes.BROKEN_SYMLINK; } - mode = (SystemInfo.isLinux ? buffer.getInt(myOffsets[OFF_MODE]) : buffer.getShort(myOffsets[OFF_MODE])) & LibC.S_MASK; + mode = getModeFlags(buffer) & LibC.S_MASK; } boolean isDirectory = (mode & LibC.S_IFDIR) == LibC.S_IFDIR; @@ -419,6 +455,10 @@ public class FileSystemUtil { return new FileAttributes(isDirectory, isSpecial, isSymlink, false, size, mTime, writable); } + private boolean loadFileStatus(@NotNull String path, Memory buffer) { + return (SystemInfo.isLinux ? myLibC.__xstat64(0, path, buffer) : myLibC.stat(path, buffer)) == 0; + } + @Override protected String resolveSymLink(@NotNull final String path) throws Exception { try { @@ -435,15 +475,25 @@ public class FileSystemUtil { } @Override - protected boolean clonePermissions(@NotNull String source, @NotNull String target) throws Exception { + protected boolean clonePermissions(@NotNull String source, @NotNull String target, boolean onlyPermissionsToExecute) throws Exception { Memory buffer = new Memory(256); - int res = SystemInfo.isLinux ? myLibC.__xstat64(0, source, buffer) : myLibC.stat(source, buffer); - if (res == 0) { - int permissions = (SystemInfo.isLinux ? buffer.getInt(myOffsets[OFF_MODE]) : buffer.getShort(myOffsets[OFF_MODE])) & LibC.PERM_MASK; - return myLibC.chmod(target, permissions) == 0; - } + if (!loadFileStatus(source, buffer)) return false; - return false; + int permissions; + int sourcePermissions = getModeFlags(buffer) & LibC.PERM_MASK; + if (onlyPermissionsToExecute) { + if (!loadFileStatus(target, buffer)) return false; + int targetPermissions = getModeFlags(buffer) & LibC.PERM_MASK; + permissions = targetPermissions & ~LibC.EXECUTE_MASK | sourcePermissions & LibC.EXECUTE_MASK; + } + else { + permissions = sourcePermissions; + } + return myLibC.chmod(target, permissions) == 0; + } + + private int getModeFlags(Memory buffer) { + return SystemInfo.isLinux ? buffer.getInt(myOffsets[OFF_MODE]) : buffer.getShort(myOffsets[OFF_MODE]); } private boolean ownFile(Memory buffer) { @@ -510,11 +560,14 @@ public class FileSystemUtil { } @Override - protected boolean clonePermissions(@NotNull String source, @NotNull String target) throws Exception { + protected boolean clonePermissions(@NotNull String source, @NotNull String target, boolean onlyPermissionsToExecute) throws Exception { if (SystemInfo.isUnix) { File srcFile = new File(source); File dstFile = new File(target); - return dstFile.setWritable(srcFile.canWrite(), true) && dstFile.setExecutable(srcFile.canExecute(), true); + if (!onlyPermissionsToExecute) { + if (!dstFile.setWritable(srcFile.canWrite(), true)) return false; + } + return dstFile.setExecutable(srcFile.canExecute(), true); } return false; diff --git a/platform/util/src/com/intellij/openapi/util/io/FileUtil.java b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java index a747727cfbc3..419c1bbfe14c 100644 --- a/platform/util/src/com/intellij/openapi/util/io/FileUtil.java +++ b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java @@ -497,7 +497,7 @@ public class FileUtil extends FileUtilRt { } if (SystemInfo.isUnix && fromFile.canExecute()) { - FileSystemUtil.clonePermissions(fromFile.getPath(), toFile.getPath()); + FileSystemUtil.clonePermissionsToExecute(fromFile.getPath(), toFile.getPath()); } } From 58dca1b0ae782163cf8a087e2a8c3df10ef8fcf8 Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Mon, 19 Jan 2015 18:07:55 +0300 Subject: [PATCH 11/18] IDEA-133347 Can't set breakpoint and debug in decompiled code --- .../ui/breakpoints/JavaLineBreakpointTypeBase.java | 6 +----- .../src/com/intellij/xdebugger/impl/XDebuggerUtilImpl.java | 7 ++++++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaLineBreakpointTypeBase.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaLineBreakpointTypeBase.java index ebaee1e6d5ee..1be1fb56557d 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaLineBreakpointTypeBase.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaLineBreakpointTypeBase.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,6 @@ package com.intellij.debugger.ui.breakpoints; import com.intellij.debugger.engine.DebuggerUtils; -import com.intellij.execution.filters.LineNumbersMapping; import com.intellij.openapi.editor.Document; import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.fileTypes.StdFileTypes; @@ -129,9 +128,6 @@ public abstract class JavaLineBreakpointTypeBase

Date: Mon, 19 Jan 2015 19:07:24 +0300 Subject: [PATCH 12/18] IDEA-126120 Proper handling for intersection types --- .../statements/expressions/TypesUtil.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java index eaebe9c3be64..675b413ea83f 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java @@ -221,20 +221,31 @@ public class TypesUtil { @NotNull PsiElement context, @NotNull ApplicableTo position) { if (actualType instanceof PsiIntersectionType) { + ConversionResult min = ConversionResult.ERROR; for (PsiType child : ((PsiIntersectionType)actualType).getConjuncts()) { - if (canAssign(targetType, child, context, position) == ConversionResult.OK) { + final ConversionResult result = canAssign(targetType, child, context, position); + if (result.ordinal() < min.ordinal()) { + min = result; + } + if (min == ConversionResult.OK) { return ConversionResult.OK; } } - return ConversionResult.ERROR; + return min; } + if (targetType instanceof PsiIntersectionType) { + ConversionResult max = ConversionResult.OK; for (PsiType child : ((PsiIntersectionType)targetType).getConjuncts()) { - if (canAssign(child, actualType, context, position) != ConversionResult.OK) { + final ConversionResult result = canAssign(child, actualType, context, position); + if (result.ordinal() > max.ordinal()) { + max = result; + } + if (max == ConversionResult.ERROR) { return ConversionResult.ERROR; } } - return ConversionResult.OK; + return max; } final ConversionResult result = areTypesConvertible(targetType, actualType, context, position); From 0a61d3269b56df8f94bd750a02b23a8e21fc4b94 Mon Sep 17 00:00:00 2001 From: Andrey Vokin Date: Mon, 19 Jan 2015 19:08:38 +0300 Subject: [PATCH 13/18] statistics --- platform/remote-servers/impl/src/META-INF/RemoteServers.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/platform/remote-servers/impl/src/META-INF/RemoteServers.xml b/platform/remote-servers/impl/src/META-INF/RemoteServers.xml index 287c8c945af8..64a3749163cd 100644 --- a/platform/remote-servers/impl/src/META-INF/RemoteServers.xml +++ b/platform/remote-servers/impl/src/META-INF/RemoteServers.xml @@ -29,6 +29,8 @@ + + From ef4c357e0b03c20b7c88c549db47f8068f24e46d Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Mon, 19 Jan 2015 17:19:28 +0100 Subject: [PATCH 14/18] use JBUI --- .../com/intellij/compiler/options/ProcessedModulesTable.java | 2 +- .../tree/render/configurables/NamedChildrenConfigurable.java | 5 +++-- .../src/com/intellij/ui/content/impl/ContentManagerImpl.java | 5 +++-- .../src/com/intellij/ui/popup/AbstractPopup.java | 5 +++-- .../util/src/com/intellij/util/ui/AbstractLayoutManager.java | 4 ++-- platform/util/src/com/intellij/util/ui/Layers.java | 4 ++-- .../com/intellij/openapi/vcs/changes/ChangesViewManager.java | 5 +++-- .../vcs/configurable/VcsDirectoryConfigurationPanel.java | 4 ++-- .../src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java | 5 +++-- plugins/devkit/src/util/ChooseModulesDialog.java | 2 +- 10 files changed, 23 insertions(+), 18 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/options/ProcessedModulesTable.java b/java/compiler/impl/src/com/intellij/compiler/options/ProcessedModulesTable.java index 4b76c29ba56f..a9f9d6755f14 100644 --- a/java/compiler/impl/src/com/intellij/compiler/options/ProcessedModulesTable.java +++ b/java/compiler/impl/src/com/intellij/compiler/options/ProcessedModulesTable.java @@ -50,7 +50,7 @@ public class ProcessedModulesTable extends JPanel { myTable.getEmptyText().setText("No modules configured"); //myTable.setShowGrid(false); - myTable.setIntercellSpacing(new Dimension(0, 0)); + myTable.setIntercellSpacing(JBUI.emptySize()); myTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); myTable.setColumnSelectionAllowed(false); diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/configurables/NamedChildrenConfigurable.java b/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/configurables/NamedChildrenConfigurable.java index fe4861de14eb..f38f6ca4c94d 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/configurables/NamedChildrenConfigurable.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/configurables/NamedChildrenConfigurable.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ import com.intellij.psi.PsiClass; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.ui.TableUtil; import com.intellij.util.ui.AbstractTableCellEditor; +import com.intellij.util.ui.JBUI; import com.intellij.util.ui.Table; import javax.swing.*; @@ -64,7 +65,7 @@ public class NamedChildrenConfigurable implements UnnamedConfigurable{ myCompletionEditor = ((DebuggerUtilsEx)DebuggerUtils.getInstance()).createEditor(project, psiClass, "NamedChildrenConfigurable"); myTable.setDragEnabled(false); - myTable.setIntercellSpacing(new Dimension(0, 0)); + myTable.setIntercellSpacing(JBUI.emptySize()); myTable.getColumn(expressionColumnName).setCellEditor(new AbstractTableCellEditor() { public Object getCellEditorValue() { diff --git a/platform/platform-impl/src/com/intellij/ui/content/impl/ContentManagerImpl.java b/platform/platform-impl/src/com/intellij/ui/content/impl/ContentManagerImpl.java index 27c63d468cee..e4b7a13e25eb 100644 --- a/platform/platform-impl/src/com/intellij/ui/content/impl/ContentManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/ui/content/impl/ContentManagerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,6 +35,7 @@ import com.intellij.ui.switcher.SwitchProvider; import com.intellij.ui.switcher.SwitchTarget; import com.intellij.util.SmartList; import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -100,7 +101,7 @@ public class ContentManagerImpl implements ContentManager, PropertyChangeListene myFocusProxy = new Wrapper.FocusHolder(); myFocusProxy.setOpaque(false); - myFocusProxy.setPreferredSize(new Dimension(0, 0)); + myFocusProxy.setPreferredSize(JBUI.emptySize()); MyContentComponent contentComponent = new MyContentComponent(); contentComponent.setContent(myUI.getComponent()); diff --git a/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java b/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java index d95c5dc22b38..5a5680cffa7e 100644 --- a/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java +++ b/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,6 +49,7 @@ import com.intellij.util.IJSwingUtilities; import com.intellij.util.Processor; import com.intellij.util.ui.ChildFocusWatcher; import com.intellij.util.ui.EmptyIcon; +import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -292,7 +293,7 @@ public class AbstractPopup implements JBPopup { else { myCaption = new CaptionPanel(); myCaption.setBorder(null); - myCaption.setPreferredSize(new Dimension(0, 0)); + myCaption.setPreferredSize(JBUI.emptySize()); } setWindowActive(myHeaderAlwaysFocusable); diff --git a/platform/util/src/com/intellij/util/ui/AbstractLayoutManager.java b/platform/util/src/com/intellij/util/ui/AbstractLayoutManager.java index 89a649e13715..16371ceaaac2 100644 --- a/platform/util/src/com/intellij/util/ui/AbstractLayoutManager.java +++ b/platform/util/src/com/intellij/util/ui/AbstractLayoutManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ public abstract class AbstractLayoutManager implements LayoutManager2 { @Override public Dimension minimumLayoutSize(final Container parent) { - return new Dimension(0, 0); + return JBUI.emptySize(); } } diff --git a/platform/util/src/com/intellij/util/ui/Layers.java b/platform/util/src/com/intellij/util/ui/Layers.java index f546d83961eb..447c85f971e2 100644 --- a/platform/util/src/com/intellij/util/ui/Layers.java +++ b/platform/util/src/com/intellij/util/ui/Layers.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ public class Layers extends JLayeredPane { @Override public Dimension getMinimumSize() { if (!isMinimumSizeSet()) - return new Dimension(0, 0); + return JBUI.emptySize(); return super.getMinimumSize(); } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewManager.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewManager.java index afbe74aaff2f..b18b0a680c4b 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewManager.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,6 +56,7 @@ import com.intellij.ui.content.Content; import com.intellij.ui.content.ContentFactory; import com.intellij.util.Alarm; import com.intellij.util.messages.MessageBusConnection; +import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import com.intellij.util.ui.tree.TreeUtil; import org.intellij.lang.annotations.JdkConstants; @@ -361,7 +362,7 @@ public class ChangesViewManager implements ChangesViewI, JDOMExternalizable, Pro if (myProgressLabel != null) { myProgressLabel.removeAll(); myProgressLabel.add(progress.create()); - myProgressLabel.setMinimumSize(new Dimension(0, 0)); + myProgressLabel.setMinimumSize(JBUI.emptySize()); } } }); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsDirectoryConfigurationPanel.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsDirectoryConfigurationPanel.java index 81ecb76e7986..c324139587a2 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsDirectoryConfigurationPanel.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsDirectoryConfigurationPanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -300,7 +300,7 @@ public class VcsDirectoryConfigurationPanel extends JPanel implements Configurab } myDirectoryMappingTable = new TableView(); - myDirectoryMappingTable.setIntercellSpacing(new Dimension(0, 0)); + myDirectoryMappingTable.setIntercellSpacing(JBUI.emptySize()); myBaseRevisionTexts = new JCheckBox("Store on shelf base revision texts for files under DVCS"); myLimitHistory = new VcsLimitHistoryConfigurable(myProject); diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java index ceaf8707d6a3..f4448c9736d5 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,6 +32,7 @@ import com.intellij.util.Function; import com.intellij.util.NotNullProducer; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.text.DateFormatUtil; +import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import com.intellij.vcs.log.VcsFullCommitDetails; import com.intellij.vcs.log.VcsLogHighlighter; @@ -114,7 +115,7 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C setRowHeight(HEIGHT_CELL); setShowHorizontalLines(false); - setIntercellSpacing(new Dimension(0, 0)); + setIntercellSpacing(JBUI.emptySize()); MouseAdapter mouseAdapter = new MyMouseAdapter(); addMouseMotionListener(mouseAdapter); diff --git a/plugins/devkit/src/util/ChooseModulesDialog.java b/plugins/devkit/src/util/ChooseModulesDialog.java index 34b62d26ea10..e77a6292d73d 100644 --- a/plugins/devkit/src/util/ChooseModulesDialog.java +++ b/plugins/devkit/src/util/ChooseModulesDialog.java @@ -99,7 +99,7 @@ public class ChooseModulesDialog extends DialogWrapper { myView.setShowGrid(false); myView.setTableHeader(null); - myView.setIntercellSpacing(new Dimension(0, 0)); + myView.setIntercellSpacing(JBUI.emptySize()); TableUtil.setupCheckboxColumn(myView, 0); myView.getModel().addTableModelListener(new TableModelListener() { public void tableChanged(TableModelEvent e) { From 41989392ae7883a4d9fa728f94372fc7e846c347 Mon Sep 17 00:00:00 2001 From: Yaroslav Lepenkin Date: Mon, 19 Jan 2015 19:34:13 +0300 Subject: [PATCH 15/18] Show the same dialog when processing single selected file and multiple selected files --- .../codeInsight/actions/OptimizeImportsAction.java | 4 ++-- .../codeInsight/actions/ReformatCodeAction.java | 11 ++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/actions/OptimizeImportsAction.java b/platform/lang-impl/src/com/intellij/codeInsight/actions/OptimizeImportsAction.java index bc18a4241360..0295fee17973 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/actions/OptimizeImportsAction.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/actions/OptimizeImportsAction.java @@ -59,7 +59,7 @@ public class OptimizeImportsAction extends AnAction { if (file == null) return; dir = file.getContainingDirectory(); } - else if (files != null && ReformatCodeAction.areFiles(files)) { + else if (files != null && ReformatCodeAction.containsAtLeastOneFile(files)) { final ReadonlyStatusHandler.OperationStatus operationStatus = ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(files); if (!operationStatus.hasReadonlyFiles()) { new OptimizeImportsProcessor(project, ReformatCodeAction.convertToPsiFiles(files, project), null).run(); @@ -160,7 +160,7 @@ public class OptimizeImportsAction extends AnAction { return; } } - else if (files != null && ReformatCodeAction.areFiles(files)) { + else if (files != null && ReformatCodeAction.containsAtLeastOneFile(files)) { boolean anyHasOptimizeImports = false; for (VirtualFile virtualFile : files) { PsiFile file = PsiManager.getInstance(project).findFile(virtualFile); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatCodeAction.java b/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatCodeAction.java index 78c6b9a6cff6..ba3d2d961f00 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatCodeAction.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatCodeAction.java @@ -88,7 +88,7 @@ public class ReformatCodeAction extends AnAction implements DumbAware { dir = file.getContainingDirectory(); hasSelection = editor.getSelectionModel().hasSelection(); } - else if (areFiles(files)) { + else if (containsAtLeastOneFile(files)) { final ReadonlyStatusHandler.OperationStatus operationStatus = ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(files); if (!operationStatus.hasReadonlyFiles()) { ReformatFilesOptions selectedFlags = getReformatFilesOptions(project, files); @@ -118,9 +118,6 @@ public class ReformatCodeAction extends AnAction implements DumbAware { } return; } - else if (files != null && files.length == 1) { - file = PsiManager.getInstance(project).findFile(files[0]); - } else { PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(dataContext); if (element == null) return; @@ -385,7 +382,7 @@ public class ReformatCodeAction extends AnAction implements DumbAware { return; } } - else if (files!= null && areFiles(files)) { + else if (files!= null && containsAtLeastOneFile(files)) { boolean anyFormatters = false; for (VirtualFile virtualFile : files) { if (virtualFile.isDirectory()) { @@ -490,9 +487,9 @@ public class ReformatCodeAction extends AnAction implements DumbAware { myTestOptions = options; } - public static boolean areFiles(final VirtualFile[] files) { + public static boolean containsAtLeastOneFile(final VirtualFile[] files) { if (files == null) return false; - if (files.length < 2) return false; + if (files.length < 1) return false; for (VirtualFile virtualFile : files) { if (virtualFile.isDirectory()) return false; } From aa915b2f7d274c1d1aa37978f3051179550694ce Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 19 Jan 2015 17:43:24 +0100 Subject: [PATCH 16/18] javadoc for javadoc psi --- .../intellij/psi/javadoc/PsiDocComment.java | 22 +++++++++++++- .../com/intellij/psi/javadoc/PsiDocTag.java | 29 +++++++++++++++++-- .../com/intellij/psi/javadoc/PsiDocToken.java | 7 ++++- .../intellij/psi/javadoc/PsiInlineDocTag.java | 5 +++- 4 files changed, 58 insertions(+), 5 deletions(-) diff --git a/java/java-psi-api/src/com/intellij/psi/javadoc/PsiDocComment.java b/java/java-psi-api/src/com/intellij/psi/javadoc/PsiDocComment.java index 081d0ce90206..b727ec7f3806 100644 --- a/java/java-psi-api/src/com/intellij/psi/javadoc/PsiDocComment.java +++ b/java/java-psi-api/src/com/intellij/psi/javadoc/PsiDocComment.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,20 +23,40 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +/** + * Represents a JavaDoc comment. + */ public interface PsiDocComment extends PsiComment, PsiDocCommentBase { + /** + * Returns the class, method or field described by the comment. + */ @Override @Nullable PsiDocCommentOwner getOwner(); + /** + * Returns the PSI elements containing the description of the element being documented + * (all significant tokens up to the first doc comment tag). + */ @NotNull PsiElement[] getDescriptionElements(); + /** + * Returns the list of JavaDoc tags in the comment. + */ @NotNull PsiDocTag[] getTags(); + /** + * Finds the first JavaDoc tag with the specified name. + * @return the tag with the specified name, or null if not found. + */ @Nullable PsiDocTag findTagByName(@NonNls String name); + /** + * Finds all JavaDoc tags with the specified name. + */ @NotNull PsiDocTag[] findTagsByName(@NonNls String name); } \ No newline at end of file diff --git a/java/java-psi-api/src/com/intellij/psi/javadoc/PsiDocTag.java b/java/java-psi-api/src/com/intellij/psi/javadoc/PsiDocTag.java index f2dfe9165036..6ae7d1321ebb 100644 --- a/java/java-psi-api/src/com/intellij/psi/javadoc/PsiDocTag.java +++ b/java/java-psi-api/src/com/intellij/psi/javadoc/PsiDocTag.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,13 +22,38 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public interface PsiDocTag extends PsiElement, PsiNamedElement{ +/** + * Represents a JavaDoc tag (either an inline tag or a block tag). + */ +public interface PsiDocTag extends PsiElement, PsiNamedElement { PsiDocTag[] EMPTY_ARRAY = new PsiDocTag[0]; + /** + * Returns the doc comment in which the tag is conained. + */ PsiDocComment getContainingComment(); + + /** + * Returns the token representing the name of this JavaDoc tag. + */ PsiElement getNameElement(); + + /** + * Returns the name of this JavaDoc tag. + */ @Override @NonNls @NotNull String getName(); + + /** + * Returns the list of all elements representing the contents of a tag. + */ PsiElement[] getDataElements(); + + /** + * Returns the element specifying what exactly is being documented by this tag + * (for example, the parameter name for a param tag or the exception name for a throws tag). + * + * @return the element, or null if the tag structure does not include such an element. + */ @Nullable PsiDocTagValue getValueElement(); } \ No newline at end of file diff --git a/java/java-psi-api/src/com/intellij/psi/javadoc/PsiDocToken.java b/java/java-psi-api/src/com/intellij/psi/javadoc/PsiDocToken.java index c515bbd58d79..f44565286d81 100644 --- a/java/java-psi-api/src/com/intellij/psi/javadoc/PsiDocToken.java +++ b/java/java-psi-api/src/com/intellij/psi/javadoc/PsiDocToken.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,8 +19,13 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.tree.IElementType; /** + * Represents a token inside a JavaDoc comment. + * * @author Mike */ public interface PsiDocToken extends PsiElement { + /** + * Returns the element type of this token. + */ IElementType getTokenType(); } diff --git a/java/java-psi-api/src/com/intellij/psi/javadoc/PsiInlineDocTag.java b/java/java-psi-api/src/com/intellij/psi/javadoc/PsiInlineDocTag.java index 535868cc0b1c..b22b44bd4cf3 100644 --- a/java/java-psi-api/src/com/intellij/psi/javadoc/PsiInlineDocTag.java +++ b/java/java-psi-api/src/com/intellij/psi/javadoc/PsiInlineDocTag.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,5 +15,8 @@ */ package com.intellij.psi.javadoc; +/** + * Represents an inline JavaDoc tag. + */ public interface PsiInlineDocTag extends PsiDocTag { } \ No newline at end of file From a3fe80e2d1820dbc2294c90c0b2af01177a4b75d Mon Sep 17 00:00:00 2001 From: peter Date: Mon, 19 Jan 2015 17:11:51 +0100 Subject: [PATCH 17/18] API to select UI elements the same way as speed search would do --- .../template/impl/TemplateListPanel.java | 16 ++-------------- .../ui/speedSearch/SpeedSearchSupply.java | 6 ++++++ .../src/com/intellij/ui/SpeedSearchBase.java | 7 ++++++- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java index d310851b8965..24efa6e9dd93 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java @@ -33,6 +33,7 @@ import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.EmptyRunnable; import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.*; +import com.intellij.ui.speedSearch.SpeedSearchSupply; import com.intellij.util.Alarm; import com.intellij.util.NullableFunction; import com.intellij.util.ObjectUtils; @@ -947,20 +948,7 @@ public class TemplateListPanel extends JPanel implements Disposable { } void selectNode(@NotNull String searchQuery) { - for (TemplateGroup group : myTemplateGroups) { - for (TemplateImpl template : group.getElements()) { - if (StringUtil.startsWithIgnoreCase(template.getKey(), searchQuery)) { - selectTemplate(group.getName(), template.getKey()); - return; - } - } - } - for (TemplateGroup group : myTemplateGroups) { - if (StringUtil.startsWithIgnoreCase(group.getName(), searchQuery)) { - selectTemplate(group.getName(), null); - return; - } - } + ObjectUtils.assertNotNull(SpeedSearchSupply.getSupply(myTree, true)).findAndSelectElement(searchQuery); } private void selectTemplate(@Nullable final String groupName, @Nullable final String templateKey) { diff --git a/platform/platform-api/src/com/intellij/ui/speedSearch/SpeedSearchSupply.java b/platform/platform-api/src/com/intellij/ui/speedSearch/SpeedSearchSupply.java index 736c4db0b677..75ffa534737e 100644 --- a/platform/platform-api/src/com/intellij/ui/speedSearch/SpeedSearchSupply.java +++ b/platform/platform-api/src/com/intellij/ui/speedSearch/SpeedSearchSupply.java @@ -80,4 +80,10 @@ public abstract class SpeedSearchSupply { public abstract void addChangeListener(@NotNull PropertyChangeListener listener); public abstract void removeChangeListener(@NotNull PropertyChangeListener listener); + + /** + * Find an element matching the searching query in the underlying component and select it there. Speed-search popup is not affected. + * @param searchQuery text that the selected element should match + */ + public abstract void findAndSelectElement(@NotNull String searchQuery); } diff --git a/platform/platform-impl/src/com/intellij/ui/SpeedSearchBase.java b/platform/platform-impl/src/com/intellij/ui/SpeedSearchBase.java index 6ee1ded56642..7170e20b9d7f 100644 --- a/platform/platform-impl/src/com/intellij/ui/SpeedSearchBase.java +++ b/platform/platform-impl/src/com/intellij/ui/SpeedSearchBase.java @@ -338,6 +338,11 @@ public abstract class SpeedSearchBase extends SpeedSear if ( mySearchPopup != null ) mySearchPopup.refreshSelection(); } + @Override + public void findAndSelectElement(@NotNull String searchQuery) { + selectElement(findElement(searchQuery), searchQuery); + } + private class SearchPopup extends JPanel { private final SearchField mySearchField; @@ -425,7 +430,7 @@ public abstract class SpeedSearchBase extends SpeedSear } public void refreshSelection () { - updateSelection(findElement(mySearchField.getText())); + findAndSelectElement(mySearchField.getText()); } private void updateSelection(Object element) { From b8ab7e2bc79b742dd48bcca79abcc5745fc45944 Mon Sep 17 00:00:00 2001 From: peter Date: Mon, 19 Jan 2015 17:14:13 +0100 Subject: [PATCH 18/18] IDEA-117143 quick search in settings does not search in "Notifications" --- ...tificationSearchableOptionContributor.java | 32 +++++++++++++++++++ .../impl/NotificationsConfigurable.java | 10 ++++-- .../ui/NotificationsConfigurablePanel.java | 6 ++++ .../src/META-INF/PlatformExtensions.xml | 1 + 4 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 platform/platform-impl/src/com/intellij/notification/impl/NotificationSearchableOptionContributor.java diff --git a/platform/platform-impl/src/com/intellij/notification/impl/NotificationSearchableOptionContributor.java b/platform/platform-impl/src/com/intellij/notification/impl/NotificationSearchableOptionContributor.java new file mode 100644 index 000000000000..b08890a14d61 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/notification/impl/NotificationSearchableOptionContributor.java @@ -0,0 +1,32 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.notification.impl; + +import com.intellij.ide.ui.search.SearchableOptionContributor; +import com.intellij.ide.ui.search.SearchableOptionProcessor; +import org.jetbrains.annotations.NotNull; + +/** + * @author peter + */ +public class NotificationSearchableOptionContributor extends SearchableOptionContributor { + @Override + public void processOptions(@NotNull SearchableOptionProcessor processor) { + for (NotificationSettings settings : NotificationsConfigurationImpl.getInstanceImpl().getAllSettings()) { + processor.addOptions(settings.getGroupId(), null, settings.getGroupId() + " notifications", NotificationsConfigurable.ID, NotificationsConfigurable.DISPLAY_NAME, true); + } + } +} diff --git a/platform/platform-impl/src/com/intellij/notification/impl/NotificationsConfigurable.java b/platform/platform-impl/src/com/intellij/notification/impl/NotificationsConfigurable.java index 17f6f42cb4df..99871d163225 100644 --- a/platform/platform-impl/src/com/intellij/notification/impl/NotificationsConfigurable.java +++ b/platform/platform-impl/src/com/intellij/notification/impl/NotificationsConfigurable.java @@ -30,6 +30,7 @@ import javax.swing.*; */ public class NotificationsConfigurable implements Configurable, SearchableConfigurable, Configurable.NoScroll { public static final String DISPLAY_NAME = "Notifications"; + static final String ID = "reference.settings.ide.settings.notifications"; private NotificationsConfigurablePanel myComponent; @Override @@ -41,7 +42,7 @@ public class NotificationsConfigurable implements Configurable, SearchableConfig @Override @NotNull public String getHelpTopic() { - return "reference.settings.ide.settings.notifications"; + return ID; } @Override @@ -82,6 +83,11 @@ public class NotificationsConfigurable implements Configurable, SearchableConfig @Override public Runnable enableSearch(final String option) { - return null; + return new Runnable() { + @Override + public void run() { + myComponent.selectGroup(option); + } + }; } } diff --git a/platform/platform-impl/src/com/intellij/notification/impl/ui/NotificationsConfigurablePanel.java b/platform/platform-impl/src/com/intellij/notification/impl/ui/NotificationsConfigurablePanel.java index 7931606053e5..1706376cc8e0 100644 --- a/platform/platform-impl/src/com/intellij/notification/impl/ui/NotificationsConfigurablePanel.java +++ b/platform/platform-impl/src/com/intellij/notification/impl/ui/NotificationsConfigurablePanel.java @@ -23,6 +23,8 @@ import com.intellij.openapi.ui.ComboBoxTableRenderer; import com.intellij.openapi.ui.StripeTable; import com.intellij.openapi.util.SystemInfo; import com.intellij.ui.*; +import com.intellij.ui.speedSearch.SpeedSearchSupply; +import com.intellij.util.ObjectUtils; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; @@ -427,4 +429,8 @@ public class NotificationsConfigurablePanel extends JPanel implements Disposable return result; } } + + public void selectGroup(String searchQuery) { + ObjectUtils.assertNotNull(SpeedSearchSupply.getSupply(myTable, true)).findAndSelectElement(searchQuery); + } } diff --git a/platform/platform-resources/src/META-INF/PlatformExtensions.xml b/platform/platform-resources/src/META-INF/PlatformExtensions.xml index d383db2838f0..5bd41b391f08 100644 --- a/platform/platform-resources/src/META-INF/PlatformExtensions.xml +++ b/platform/platform-resources/src/META-INF/PlatformExtensions.xml @@ -241,6 +241,7 @@ displayName="Notifications" id="reference.settings.ide.settings.notifications" provider="com.intellij.notification.impl.NotificationsConfigurableProvider"/> +