diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/ArrayRenderer.java b/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/ArrayRenderer.java index e53824e8441d..28f3f381489b 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/ArrayRenderer.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/ArrayRenderer.java @@ -73,14 +73,6 @@ public class ArrayRenderer extends NodeRendererImpl{ return UNIQUE_ID; } - public boolean isEnabled() { - return myProperties.isEnabled(); - } - - public void setEnabled(boolean enabled) { - myProperties.setEnabled(enabled); - } - public @NonNls String getName() { return "Array"; } diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/ClassRenderer.java b/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/ClassRenderer.java index ed48bed02cb4..2cfe619026e0 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/ClassRenderer.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/ClassRenderer.java @@ -98,16 +98,6 @@ public class ClassRenderer extends NodeRendererImpl{ return UNIQUE_ID; } - @Override - public boolean isEnabled() { - return myProperties.isEnabled(); - } - - @Override - public void setEnabled(boolean enabled) { - myProperties.setEnabled(enabled); - } - @Override public ClassRenderer clone() { return (ClassRenderer) super.clone(); diff --git a/java/java-indexing-impl/src/com/intellij/psi/impl/search/JavaDirectInheritorsSearcher.java b/java/java-indexing-impl/src/com/intellij/psi/impl/search/JavaDirectInheritorsSearcher.java index db8db0265b7d..4820dfe0859b 100644 --- a/java/java-indexing-impl/src/com/intellij/psi/impl/search/JavaDirectInheritorsSearcher.java +++ b/java/java-indexing-impl/src/com/intellij/psi/impl/search/JavaDirectInheritorsSearcher.java @@ -28,6 +28,7 @@ import com.intellij.psi.*; import com.intellij.psi.impl.java.stubs.index.JavaAnonymousClassBaseRefOccurenceIndex; import com.intellij.psi.impl.java.stubs.index.JavaSuperClassNameOccurenceIndex; import com.intellij.psi.search.GlobalSearchScope; +import com.intellij.psi.search.LocalSearchScope; import com.intellij.psi.search.PsiSearchScopeUtil; import com.intellij.psi.search.SearchScope; import com.intellij.psi.search.searches.AllClassesSearch; @@ -41,11 +42,9 @@ import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.HashMap; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.ConcurrentMap; +import java.util.stream.Collectors; /** * @author max @@ -71,7 +70,7 @@ public class JavaDirectInheritorsSearcher implements QueryExecutor map = HighlightingCaches.getInstance(project).DIRECT_SUB_CLASSES; PsiClass[] cache = map.get(baseClass); if (cache != null) { @@ -143,7 +142,7 @@ public class JavaDirectInheritorsSearcher implements QueryExecutor)baseClass::isPhysical)) { cache = ConcurrencyUtil.cacheOrGet(map, baseClass, cache); @@ -163,10 +162,22 @@ public class JavaDirectInheritorsSearcher implements QueryExecutor files = Arrays.stream(((LocalSearchScope)scope).getScope()).map(PsiUtil::getVirtualFile).collect(Collectors.toSet()); + return GlobalSearchScope.filesScope(project, files); + } + + @NotNull + private static PsiClass[] calculateDirectSubClasses(@NotNull Project project, + @NotNull PsiClass baseClass, + @NotNull String baseClassName, + @NotNull SearchScope useScope) { + GlobalSearchScope globalUseScope = ApplicationManager.getApplication().runReadAction((Computable)()-> toGlobal(useScope, project)); Collection candidates = - MethodUsagesSearcher.resolveInReadAction(project, () -> JavaSuperClassNameOccurenceIndex.getInstance().get(baseClassName, project, allScope)); + MethodUsagesSearcher.resolveInReadAction(project, () -> JavaSuperClassNameOccurenceIndex.getInstance().get(baseClassName, project, globalUseScope)); // memory/speed optimisation: it really is a map(string -> PsiClass or List) final Map classes = new HashMap<>(); @@ -215,7 +226,7 @@ public class JavaDirectInheritorsSearcher implements QueryExecutor anonymousCandidates = - MethodUsagesSearcher.resolveInReadAction(project, () -> JavaAnonymousClassBaseRefOccurenceIndex.getInstance().get(baseClassName, project, allScope)); + MethodUsagesSearcher.resolveInReadAction(project, () -> JavaAnonymousClassBaseRefOccurenceIndex.getInstance().get(baseClassName, project, globalUseScope)); processConcurrentlyIfTooMany(anonymousCandidates, candidate-> { diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/InheritanceImplUtil.java b/java/java-psi-impl/src/com/intellij/psi/impl/InheritanceImplUtil.java index df07ea0c2c78..a575f6aa4a3d 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/InheritanceImplUtil.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/InheritanceImplUtil.java @@ -77,11 +77,11 @@ public class InheritanceImplUtil { String baseQName = baseClass.getQualifiedName(); if (baseQName == null) return false; - if (CommonClassNames.JAVA_LANG_ENUM.equals(baseQName)) { - return candidateClass.isEnum(); + if (CommonClassNames.JAVA_LANG_ENUM.equals(baseQName) && candidateClass.isEnum()) { + return facade.findClass(baseQName, candidateClass.getResolveScope()) != null; } - if (CommonClassNames.JAVA_LANG_ANNOTATION_ANNOTATION.equals(baseQName)) { - return candidateClass.isAnnotationType(); + if (CommonClassNames.JAVA_LANG_ANNOTATION_ANNOTATION.equals(baseQName) && candidateClass.isAnnotationType()) { + return facade.findClass(baseQName, candidateClass.getResolveScope()) != null; } boolean isCandidateInterface = candidateClass.isInterface(); @@ -119,7 +119,8 @@ public class InheritanceImplUtil { if (referenceElements.length != 0) { GlobalSearchScope scope = extList.getResolveScope(); for (PsiJavaCodeReferenceElement ref : referenceElements) { - if (Comparing.equal(PsiNameHelper.getQualifiedClassName(ref.getQualifiedName(), false), baseQName) && facade.findClass(baseQName, scope) != null) + if (Comparing.equal(PsiNameHelper.getQualifiedClassName(ref.getQualifiedName(), false), baseQName) + && facade.findClass(baseQName, scope) != null) return true; } } diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java index 8b39f54544c2..73e7b55aeaf9 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java @@ -405,8 +405,8 @@ public class PsiClassImplUtil { processDeclarationsInClassNotCached(myPsiClass, processor, ResolveState.initial(), null, null, myPsiClass, false, PsiUtil.getLanguageLevel(myPsiClass), myResolveScope); Map result = ContainerUtil.newTroveMap(); - for (Entry> entry : map.entrySet()) { - result.put(entry.getKey(), entry.getValue().toArray(PsiMember.EMPTY_ARRAY)); + for (String name : map.keySet()) { + result.put(name, map.get(name).toArray(PsiMember.EMPTY_ARRAY)); } return result; } diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/tree/LazyParseablePsiElement.java b/platform/core-impl/src/com/intellij/psi/impl/source/tree/LazyParseablePsiElement.java index a5516b9141f6..d340e770f7bd 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/source/tree/LazyParseablePsiElement.java +++ b/platform/core-impl/src/com/intellij/psi/impl/source/tree/LazyParseablePsiElement.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 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,7 +49,7 @@ import java.util.List; public class LazyParseablePsiElement extends LazyParseableElement implements PsiElement, NavigationItem { private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.tree.LazyParseablePsiElement"); - public LazyParseablePsiElement(@NotNull IElementType type, CharSequence buffer) { + public LazyParseablePsiElement(@NotNull IElementType type, @Nullable CharSequence buffer) { super(type, buffer); setPsi(this); } diff --git a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java index 7639666b0cdc..26971c5b242e 100644 --- a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java @@ -22,6 +22,7 @@ import com.intellij.concurrency.JobScheduler; import com.intellij.diagnostic.LogEventException; import com.intellij.diagnostic.PerformanceWatcher; import com.intellij.diagnostic.ThreadDumper; +import com.intellij.execution.CommandLineUtil; import com.intellij.ide.*; import com.intellij.ide.plugins.IdeaPluginDescriptor; import com.intellij.idea.IdeaApplication; @@ -171,6 +172,7 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App myCommandLineMode = isCommandLine; myDoNotSave = isUnitTestMode || isHeadless; + CommandLineUtil.VERBOSE_COMMAND_LINE_MODE = isUnitTestMode; if (!isUnitTestMode && !isHeadless) { Disposer.register(this, Disposer.newDisposable(), "ui"); diff --git a/platform/util/src/com/intellij/execution/CommandLineUtil.java b/platform/util/src/com/intellij/execution/CommandLineUtil.java index d2707c45ee44..c03f213a4bc8 100644 --- a/platform/util/src/com/intellij/execution/CommandLineUtil.java +++ b/platform/util/src/com/intellij/execution/CommandLineUtil.java @@ -21,7 +21,7 @@ import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import java.io.File; -import java.util.Iterator; +import java.util.Collections; import java.util.List; public class CommandLineUtil { @@ -95,25 +95,27 @@ public class CommandLineUtil { return s.length() >= 2 && s.charAt(0) == ch && s.charAt(s.length() - 1) == ch; } + public static boolean VERBOSE_COMMAND_LINE_MODE; @NotNull public static String extractPresentableName(@NotNull String commandLine) { String executable = commandLine.trim(); - if (StringUtil.startsWithChar(executable, '\"') || StringUtil.startsWithChar(executable, '\'')) { - char quote = executable.charAt(0); - for (int i = 1; i < executable.length(); i++) { - if (executable.charAt(i) == quote && - (executable.charAt(i - 1) != '\'' || StringUtil.isEscapedBackslash(executable, 0, i - 1))) { - executable = executable.substring(1, i); - break; - } - } + List words = StringUtil.splitHonorQuotes(executable, ' '); + String execName; + List args; + if (words.isEmpty()) { + execName = executable; + args = Collections.emptyList(); } else { - Iterator words = StringUtil.tokenize(commandLine, " \t\n\r\f").iterator(); - executable = words.hasNext() ? words.next() : executable; + execName = words.get(0); + args = words.subList(1, words.size()); } - return new File(executable.trim()).getName(); + if (VERBOSE_COMMAND_LINE_MODE) { + return StringUtil.firstLast(execName + " " + StringUtil.join(args, " "), 250); + } + + return new File(StringUtil.unquoteString(execName)).getName(); } } \ No newline at end of file diff --git a/platform/util/src/com/intellij/execution/process/BaseOSProcessHandler.java b/platform/util/src/com/intellij/execution/process/BaseOSProcessHandler.java index 364798b5004b..5db0db2476c6 100644 --- a/platform/util/src/com/intellij/execution/process/BaseOSProcessHandler.java +++ b/platform/util/src/com/intellij/execution/process/BaseOSProcessHandler.java @@ -274,7 +274,7 @@ public class BaseOSProcessHandler extends ProcessHandler implements TaskExecutor private class SimpleOutputReader extends BaseOutputReader { private final Key myProcessOutputType; - private SimpleOutputReader(Reader reader, Key outputType, Options options, String presentableName) { + private SimpleOutputReader(Reader reader, Key outputType, Options options, @NotNull String presentableName) { super(reader, options); myProcessOutputType = outputType; start(presentableName); diff --git a/platform/util/src/com/intellij/execution/process/ProcessWaitFor.java b/platform/util/src/com/intellij/execution/process/ProcessWaitFor.java index e5ccfab8cc39..1fcd50b640fb 100644 --- a/platform/util/src/com/intellij/execution/process/ProcessWaitFor.java +++ b/platform/util/src/com/intellij/execution/process/ProcessWaitFor.java @@ -41,7 +41,7 @@ public class ProcessWaitFor { public void run() { String oldThreadName = Thread.currentThread().getName(); if (!StringUtil.isEmptyOrSpaces(presentableName)) { - Thread.currentThread().setName(StringUtil.first("ProcessWaitFor: " + presentableName, 120, true)); + Thread.currentThread().setName("ProcessWaitFor: " + presentableName); } int exitCode = 0; try { diff --git a/platform/util/src/com/intellij/util/io/BaseDataReader.java b/platform/util/src/com/intellij/util/io/BaseDataReader.java index 677bf6479c08..b5d2cc58f630 100644 --- a/platform/util/src/com/intellij/util/io/BaseDataReader.java +++ b/platform/util/src/com/intellij/util/io/BaseDataReader.java @@ -55,7 +55,7 @@ public abstract class BaseDataReader { public void run() { String oldThreadName = Thread.currentThread().getName(); if (!StringUtil.isEmptyOrSpaces(presentableName)) { - Thread.currentThread().setName(StringUtil.first("BaseDataReader: " + presentableName, 120, true)); + Thread.currentThread().setName("BaseDataReader: " + presentableName); } try { doRun();