From a1f59ee4061f2f8a585fff46feebb0da35654f9b Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Tue, 16 Sep 2014 10:40:13 +0400 Subject: [PATCH 1/6] EA-59230 (NPEs around getMirror() fixed) --- .../intellij/psi/impl/compiled/ClsElementImpl.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsElementImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsElementImpl.java index a2ce5b36c589..6e60a2d20401 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsElementImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsElementImpl.java @@ -30,6 +30,7 @@ import com.intellij.psi.impl.source.tree.TreeElement; import com.intellij.psi.tree.IElementType; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtilCore; +import com.intellij.util.ArrayUtil; import com.intellij.util.IncorrectOperationException; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NonNls; @@ -177,7 +178,9 @@ public abstract class ClsElementImpl extends PsiElementBase implements PsiCompil @Override public PsiElement findElementAt(int offset) { - PsiElement mirrorAt = getMirror().findElementAt(offset); + PsiElement mirror = getMirror(); + if (mirror == null) return null; + PsiElement mirrorAt = mirror.findElementAt(offset); while (true) { if (mirrorAt == null) return null; PsiElement elementAt = mirrorToElement(mirrorAt); @@ -188,7 +191,9 @@ public abstract class ClsElementImpl extends PsiElementBase implements PsiCompil @Override public PsiReference findReferenceAt(int offset) { - PsiReference mirrorRef = getMirror().findReferenceAt(offset); + PsiElement mirror = getMirror(); + if (mirror == null) return null; + PsiReference mirrorRef = mirror.findReferenceAt(offset); if (mirrorRef == null) return null; PsiElement mirrorElement = mirrorRef.getElement(); PsiElement element = mirrorToElement(mirrorElement); @@ -235,7 +240,8 @@ public abstract class ClsElementImpl extends PsiElementBase implements PsiCompil @Override @NotNull public char[] textToCharArray() { - return getMirror().textToCharArray(); + PsiElement mirror = getMirror(); + return mirror != null ? mirror.textToCharArray() : ArrayUtil.EMPTY_CHAR_ARRAY; } @Override From 11adb6fe14c6d913f8fcc10ffeff36c2fb6038c9 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Tue, 16 Sep 2014 10:40:37 +0400 Subject: [PATCH 2/6] Cleanup (over-specified type) --- .../src/org/jetbrains/java/decompiler/IdeaDecompiler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/java-decompiler/src/org/jetbrains/java/decompiler/IdeaDecompiler.java b/plugins/java-decompiler/src/org/jetbrains/java/decompiler/IdeaDecompiler.java index 4c68eb5ba775..784160f349f9 100644 --- a/plugins/java-decompiler/src/org/jetbrains/java/decompiler/IdeaDecompiler.java +++ b/plugins/java-decompiler/src/org/jetbrains/java/decompiler/IdeaDecompiler.java @@ -56,7 +56,7 @@ public class IdeaDecompiler extends ClassFileDecompilers.Light { "//\n\n"; private final IFernflowerLogger myLogger = new IdeaLogger(); - private final HashMap myOptions = new HashMap(); + private final Map myOptions = new HashMap(); public IdeaDecompiler() { myOptions.put(IFernflowerPreferences.HIDE_DEFAULT_CONSTRUCTOR, "0"); From fc4d3ec42aef4edc9b93235245bbdbea2188ac27 Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Tue, 16 Sep 2014 10:52:27 +0400 Subject: [PATCH 3/6] EA-60474 - IAE: XsltSupport.isXsltFile --- .../lang/xpath/xslt/impl/XsltSymbolIndex.java | 75 ++++++++++--------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/impl/XsltSymbolIndex.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/impl/XsltSymbolIndex.java index dd1d9869db05..f3a41b856cdd 100644 --- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/impl/XsltSymbolIndex.java +++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/impl/XsltSymbolIndex.java @@ -49,32 +49,16 @@ public class XsltSymbolIndex extends FileBasedIndexExtension NAME = ID.create("XsltSymbolIndex"); - enum Kind { - PARAM(XsltParameter.class), VARIABLE(XsltVariable.class), TEMPLATE(XsltTemplate.class), ANYTHING(null); + @SuppressWarnings({ "UnusedDeclaration" }) + public static Collection getSymbolNames(Project project) { + return FileBasedIndex.getInstance().getAllKeys(NAME, project); + } - final Class myClazz; - - Kind(Class clazz) { - myClazz = clazz; - } - - @Nullable - public XsltElement wrap(XmlTag tag) { - final Class clazz; - if (myClazz != null) { - if (!name().toLowerCase().equals(tag.getLocalName())) { - return null; - } - clazz = myClazz; - } else { - try { - clazz = valueOf(tag.getLocalName().toUpperCase()).myClazz; - } catch (IllegalArgumentException e) { - return null; - } - } - return XsltElementFactory.getInstance().wrapElement(tag, clazz); - } + public static NavigationItem[] getSymbolsByName(final String name, Project project, boolean includeNonProjectItems) { + final GlobalSearchScope scope = includeNonProjectItems ? GlobalSearchScope.allScope(project) : GlobalSearchScope.projectScope(project); + final SymbolCollector collector = new SymbolCollector(name, project, scope); + FileBasedIndex.getInstance().processValues(NAME, name, null, collector, scope); + return collector.getResult(); } @Override @@ -165,16 +149,32 @@ public class XsltSymbolIndex extends FileBasedIndexExtension getSymbolNames(Project project) { - return FileBasedIndex.getInstance().getAllKeys(NAME, project); - } + enum Kind { + PARAM(XsltParameter.class), VARIABLE(XsltVariable.class), TEMPLATE(XsltTemplate.class), ANYTHING(null); - public static NavigationItem[] getSymbolsByName(final String name, Project project, boolean includeNonProjectItems) { - final GlobalSearchScope scope = includeNonProjectItems ? GlobalSearchScope.allScope(project) : GlobalSearchScope.projectScope(project); - final SymbolCollector collector = new SymbolCollector(name, project, scope); - FileBasedIndex.getInstance().processValues(NAME, name, null, collector, scope); - return collector.getResult(); + final Class myClazz; + + Kind(Class clazz) { + myClazz = clazz; + } + + @Nullable + public XsltElement wrap(XmlTag tag) { + final Class clazz; + if (myClazz != null) { + if (!name().toLowerCase().equals(tag.getLocalName())) { + return null; + } + clazz = myClazz; + } else { + try { + clazz = valueOf(tag.getLocalName().toUpperCase()).myClazz; + } catch (IllegalArgumentException e) { + return null; + } + } + return XsltElementFactory.getInstance().wrapElement(tag, clazz); + } } private static class MyAttributeHandler extends NanoXmlUtil.IXMLBuilderAdapter { @@ -213,12 +213,13 @@ public class XsltSymbolIndex extends FileBasedIndexExtension Date: Tue, 16 Sep 2014 11:29:40 +0400 Subject: [PATCH 4/6] Fixed resolve to all registered Python file types (not only *.py) --- .../python/psi/resolve/ResolveImportUtil.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/python/src/com/jetbrains/python/psi/resolve/ResolveImportUtil.java b/python/src/com/jetbrains/python/psi/resolve/ResolveImportUtil.java index 2f866a24d8af..c98dcf7ee056 100644 --- a/python/src/com/jetbrains/python/psi/resolve/ResolveImportUtil.java +++ b/python/src/com/jetbrains/python/psi/resolve/ResolveImportUtil.java @@ -16,6 +16,9 @@ package com.jetbrains.python.psi.resolve; import com.intellij.openapi.extensions.Extensions; +import com.intellij.openapi.fileTypes.ExtensionFileNameMatcher; +import com.intellij.openapi.fileTypes.FileNameMatcher; +import com.intellij.openapi.fileTypes.FileTypeManager; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleUtilCore; import com.intellij.openapi.projectRoots.Sdk; @@ -30,6 +33,7 @@ import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.QualifiedName; import com.intellij.util.containers.HashSet; import com.jetbrains.python.PyNames; +import com.jetbrains.python.PythonFileType; import com.jetbrains.python.psi.*; import com.jetbrains.python.psi.impl.*; import com.jetbrains.python.psi.types.PyModuleType; @@ -346,8 +350,16 @@ public class ResolveImportUtil { @Nullable private static PsiFile findPyFileInDir(PsiDirectory dir, String referencedName) { - final PsiFile file = dir.findFile(referencedName + PyNames.DOT_PY); - // findFile() does case-insensitive search, and we need exactly matching case (see PY-381) + PsiFile file = dir.findFile(referencedName + PyNames.DOT_PY); + if (file == null) { + final List associations = FileTypeManager.getInstance().getAssociations(PythonFileType.INSTANCE); + for (FileNameMatcher association : associations) { + if (association instanceof ExtensionFileNameMatcher) { + file = dir.findFile(referencedName + "." + ((ExtensionFileNameMatcher)association).getExtension()); + if (file != null) break; + } + } + } if (file != null && FileUtil.getNameWithoutExtension(file.getName()).equals(referencedName)) { return file; } From 4e6de6fab99343b124c47e46e12ee7284a1d3d42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yann=20C=C3=A9bron?= Date: Tue, 16 Sep 2014 09:37:07 +0200 Subject: [PATCH 5/6] IDEA-116923 Fix, kill or rewrite FinderRecursivePanelSelectionUpdateTest --- ...nderRecursivePanelSelectionUpdateTest.java | 33 +++++-------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/platform/platform-tests/testSrc/com/intellij/ui/FinderRecursivePanelSelectionUpdateTest.java b/platform/platform-tests/testSrc/com/intellij/ui/FinderRecursivePanelSelectionUpdateTest.java index 60141b765fbc..24e36fba5029 100644 --- a/platform/platform-tests/testSrc/com/intellij/ui/FinderRecursivePanelSelectionUpdateTest.java +++ b/platform/platform-tests/testSrc/com/intellij/ui/FinderRecursivePanelSelectionUpdateTest.java @@ -15,7 +15,6 @@ */ package com.intellij.ui; -import com.intellij.idea.Bombed; import com.intellij.openapi.project.Project; import com.intellij.testFramework.PlatformTestCase; import com.intellij.testFramework.SkipInHeadlessEnvironment; @@ -25,44 +24,28 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.util.Arrays; -import java.util.Calendar; import java.util.List; @SkipInHeadlessEnvironment public class FinderRecursivePanelSelectionUpdateTest extends PlatformTestCase { - @Bombed(year = 2015, month = Calendar.APRIL, day = 1, user = "Yann Cebron") public void testUpdate() throws InterruptedException { - StringFinderRecursivePanel panel_0 = new StringFinderRecursivePanel(getProject()) { - @NotNull - @Override - protected JComponent createRightComponent(String s) { - return new StringFinderRecursivePanel(this) { - @Override - @NotNull - protected JComponent createRightComponent(String s) { - return new StringFinderRecursivePanel(this) { - @Override - @NotNull - protected JComponent createRightComponent(String s) { - return new StringFinderRecursivePanel(this); - } - }; - } - }; - } - }; + StringFinderRecursivePanel panel_0 = new StringFinderRecursivePanel(getProject()); disposeOnTearDown(panel_0); + final StringFinderRecursivePanel panel_1 = new StringFinderRecursivePanel(panel_0); + panel_1.setSecondComponent(panel_0); panel_0.setTestSelectedIndex(0); - StringFinderRecursivePanel panel_1 = (StringFinderRecursivePanel)panel_0.getSecondComponent(); + final StringFinderRecursivePanel panel_2 = new StringFinderRecursivePanel(panel_1); + panel_1.setSecondComponent(panel_2); panel_1.setTestSelectedIndex(1); - StringFinderRecursivePanel panel_2 = (StringFinderRecursivePanel)panel_1.getSecondComponent(); + final StringFinderRecursivePanel panel_3 = new StringFinderRecursivePanel(panel_2); + panel_2.setSecondComponent(panel_3); panel_2.setTestSelectedIndex(2); - StringFinderRecursivePanel panel_3 = (StringFinderRecursivePanel)panel_2.getSecondComponent(); + panel_3.setSecondComponent(new StringFinderRecursivePanel(panel_3)); panel_3.setTestSelectedIndex(3); panel_0.updatePanel(); From 5e99101dcb6858922b88ebebb0d69dfb6e538c58 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Tue, 16 Sep 2014 10:12:38 +0200 Subject: [PATCH 6/6] IDEA-COMMUNITY-CR-599 --- .../intellij/execution/console/ConsoleExecuteAction.java | 8 ++++---- .../execution/console/LanguageConsoleBuilder.java | 2 +- .../intellij/execution/console/UseConsoleInputAction.java | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/execution/console/ConsoleExecuteAction.java b/platform/lang-impl/src/com/intellij/execution/console/ConsoleExecuteAction.java index f5bec9ac6be4..fe260df74038 100644 --- a/platform/lang-impl/src/com/intellij/execution/console/ConsoleExecuteAction.java +++ b/platform/lang-impl/src/com/intellij/execution/console/ConsoleExecuteAction.java @@ -140,7 +140,7 @@ public class ConsoleExecuteAction extends DumbAwareAction { private boolean myAddToHistory = true; final boolean myPreserveMarkup; - boolean useProcessStdIn; + boolean myUseProcessStdIn; public ConsoleExecuteActionHandler(boolean preserveMarkup) { myCommandHistoryModel = new ConsoleHistoryModel(); @@ -163,14 +163,14 @@ public class ConsoleExecuteAction extends DumbAwareAction { } protected void runExecuteAction(@NotNull LanguageConsoleImpl console, @Nullable LanguageConsoleView consoleView) { - if (!useProcessStdIn) { + if (!myUseProcessStdIn) { beforeExecution(console); } - String text = console.prepareExecuteAction(myAddToHistory && !useProcessStdIn, myPreserveMarkup, true); + String text = console.prepareExecuteAction(myAddToHistory && !myUseProcessStdIn, myPreserveMarkup, true); ((UndoManagerImpl)UndoManager.getInstance(console.getProject())).invalidateActionsFor(DocumentReferenceManager.getInstance().create(console.getCurrentEditor().getDocument())); - if (useProcessStdIn) { + if (myUseProcessStdIn) { assert consoleView != null; consoleView.print(text, ConsoleViewContentType.USER_INPUT); consoleView.print("\n", ConsoleViewContentType.USER_INPUT); diff --git a/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleBuilder.java b/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleBuilder.java index 12db013acdd8..a763d934b30e 100644 --- a/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleBuilder.java +++ b/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleBuilder.java @@ -175,7 +175,7 @@ public final class LanguageConsoleBuilder { if (processInputStateKey != null) { assert executeActionHandler != null; if (PropertiesComponent.getInstance().getBoolean(processInputStateKey, false)) { - executeActionHandler.useProcessStdIn = true; + executeActionHandler.myUseProcessStdIn = true; DaemonCodeAnalyzer daemonCodeAnalyzer = DaemonCodeAnalyzer.getInstance(consoleView.getProject()); daemonCodeAnalyzer.setHighlightingEnabled(consoleView.getConsole().getFile(), false); } diff --git a/platform/lang-impl/src/com/intellij/execution/console/UseConsoleInputAction.java b/platform/lang-impl/src/com/intellij/execution/console/UseConsoleInputAction.java index 5b450e3bd154..5dc58ac1875c 100644 --- a/platform/lang-impl/src/com/intellij/execution/console/UseConsoleInputAction.java +++ b/platform/lang-impl/src/com/intellij/execution/console/UseConsoleInputAction.java @@ -51,6 +51,6 @@ final class UseConsoleInputAction extends ToggleAction implements DumbAware { List actions = ActionUtil.getActions(consoleView.getConsole().getConsoleEditor().getComponent()); ConsoleExecuteAction action = ContainerUtil.findInstance(actions, ConsoleExecuteAction.class); - action.myExecuteActionHandler.useProcessStdIn = !state; + action.myExecuteActionHandler.myUseProcessStdIn = !state; } } \ No newline at end of file