diff --git a/.idea/runConfigurations/Dart_tests.xml b/.idea/runConfigurations/Dart_tests.xml new file mode 100644 index 000000000000..d77a8f622588 --- /dev/null +++ b/.idea/runConfigurations/Dart_tests.xml @@ -0,0 +1,23 @@ + + + + + + + + + + \ No newline at end of file diff --git a/build/scripts/unpackJdks.gant b/build/scripts/unpackJdks.gant index 0ec562e5fe2d..8bb53c134348 100644 --- a/build/scripts/unpackJdks.gant +++ b/build/scripts/unpackJdks.gant @@ -49,7 +49,7 @@ def unpackJdks() { private void unpackJdk(File osDir, File jdkDir, String majorVersion) { def jdkFiles = osDir.listFiles().findAll { it.name.startsWith("jdk$majorVersion") } if (SystemInfo.isWindows) { - def arch = SystemInfo.is64Bit ? "x64" : "x32" + def arch = "x64" jdkFiles = jdkFiles.findAll { it.name.endsWith("_${arch}.zip") } } if (jdkFiles.empty) { diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/JavaDebugProcess.java b/java/debugger/impl/src/com/intellij/debugger/engine/JavaDebugProcess.java index 36aff625f280..b65f977ede75 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/JavaDebugProcess.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/JavaDebugProcess.java @@ -321,8 +321,9 @@ public class JavaDebugProcess extends XDebugProcess { leftToolbar.add(ActionManager.getInstance().getAction(DebuggerActions.DUMP_THREADS), beforeRunner); leftToolbar.add(Separator.getInstance(), beforeRunner); - settings.addAction(new AutoVarsSwitchAction(), Constraints.FIRST); - settings.addAction(new WatchLastMethodReturnValueAction(), Constraints.FIRST); + Constraints beforeSort = new Constraints(Anchor.BEFORE, "XDebugger.ToggleSortValues"); + settings.addAction(new WatchLastMethodReturnValueAction(), beforeSort); + settings.addAction(new AutoVarsSwitchAction(), beforeSort); } private static class AutoVarsSwitchAction extends ToggleAction { diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ModulesConfigurator.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ModulesConfigurator.java index fe55b1645084..b91059865e8c 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ModulesConfigurator.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ModulesConfigurator.java @@ -69,18 +69,20 @@ public class ModulesConfigurator implements ModulesProvider, ModuleEditor.Change private static final Logger LOG = Logger.getInstance("#" + ModulesConfigurator.class.getName()); private final Project myProject; - private final List myModuleEditors = new ArrayList(); - private final Comparator myModuleEditorComparator = new Comparator() { - @Override - public int compare(ModuleEditor editor1, ModuleEditor editor2) { - return ModulesAlphaComparator.INSTANCE.compare(editor1.getModule(), editor2.getModule()); - } - @SuppressWarnings({"EqualsWhichDoesntCheckParameterClass"}) - public boolean equals(Object o) { - return false; + private final Map myModuleEditors = new TreeMap(new Comparator() { + @Override + public int compare(Module o1, Module o2) { + String n1 = o1.getName(); + String n2 = o2.getName(); + int result = n1.compareToIgnoreCase(n2); + if (result != 0) { + return result; + } + return n1.compareTo(n2); } - }; + }); + private boolean myModified = false; private ModifiableModuleModel myModuleModel; private boolean myModuleModelCommitted = false; @@ -107,7 +109,7 @@ public class ModulesConfigurator implements ModulesProvider, ModuleEditor.Change ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { - for (final ModuleEditor moduleEditor : myModuleEditors) { + for (final ModuleEditor moduleEditor : myModuleEditors.values()) { Disposer.dispose(moduleEditor); } myModuleEditors.clear(); @@ -119,7 +121,6 @@ public class ModulesConfigurator implements ModulesProvider, ModuleEditor.Change } } }); - } @Override @@ -140,12 +141,7 @@ public class ModulesConfigurator implements ModulesProvider, ModuleEditor.Change @Nullable public ModuleEditor getModuleEditor(Module module) { - for (final ModuleEditor moduleEditor : myModuleEditors) { - if (module.equals(moduleEditor.getModule())) { - return moduleEditor; - } - } - return null; + return myModuleEditors.get(module); } @Override @@ -170,7 +166,7 @@ public class ModulesConfigurator implements ModulesProvider, ModuleEditor.Change } }; - myModuleEditors.add(moduleEditor); + myModuleEditors.put(moduleEditor.getModule(), moduleEditor); moduleEditor.addChangeListener(this); Disposer.register(moduleEditor, new Disposable() { @@ -202,7 +198,6 @@ public class ModulesConfigurator implements ModulesProvider, ModuleEditor.Change for (Module module : modules) { getOrCreateModuleEditor(module); } - Collections.sort(myModuleEditors, myModuleEditorComparator); } } }); @@ -226,7 +221,7 @@ public class ModulesConfigurator implements ModulesProvider, ModuleEditor.Change // validate content and source roots final Map contentRootToModuleNameMap = new HashMap(); final Map srcRootsToContentRootMap = new HashMap(); - for (final ModuleEditor moduleEditor : myModuleEditors) { + for (final ModuleEditor moduleEditor : myModuleEditors.values()) { final ModifiableRootModel rootModel = moduleEditor.getModifiableRootModel(); final ContentEntry[] contents = rootModel.getContentEntries(); for (ContentEntry contentEntry : contents) { @@ -278,7 +273,7 @@ public class ModulesConfigurator implements ModulesProvider, ModuleEditor.Change } final List models = new ArrayList(myModuleEditors.size()); - for (ModuleEditor moduleEditor : myModuleEditors) { + for (ModuleEditor moduleEditor : myModuleEditors.values()) { moduleEditor.canApply(); } @@ -287,8 +282,8 @@ public class ModulesConfigurator implements ModulesProvider, ModuleEditor.Change for (Map.Entry entry : projectJdksModel.getProjectSdks().entrySet()) { modifiedToOriginalMap.put(entry.getValue(), entry.getKey()); } - - for (final ModuleEditor moduleEditor : myModuleEditors) { + + for (final ModuleEditor moduleEditor : myModuleEditors.values()) { final ModifiableRootModel model = moduleEditor.apply(); if (model != null) { if (!model.isSdkInherited()) { @@ -407,7 +402,6 @@ public class ModulesConfigurator implements ModulesProvider, ModuleEditor.Change @Override public void run() { getOrCreateModuleEditor(module); - Collections.sort(myModuleEditors, myModuleEditorComparator); } }); processModuleCountChanged(); @@ -466,13 +460,13 @@ public class ModulesConfigurator implements ModulesProvider, ModuleEditor.Change return false; } // do remove - myModuleEditors.remove(selectedEditor); + myModuleEditors.remove(selectedEditor.getModule()); // destroyProcess removed module final Module moduleToRemove = selectedEditor.getModule(); // remove all dependencies on the module that is about to be removed List modifiableRootModels = new ArrayList(); - for (final ModuleEditor moduleEditor : myModuleEditors) { + for (final ModuleEditor moduleEditor : myModuleEditors.values()) { final ModifiableRootModel modifiableRootModel = moduleEditor.getModifiableRootModelProxy(); modifiableRootModels.add(modifiableRootModel); } @@ -487,13 +481,13 @@ public class ModulesConfigurator implements ModulesProvider, ModuleEditor.Change private void processModuleCountChanged() { - for (ModuleEditor moduleEditor : myModuleEditors) { + for (ModuleEditor moduleEditor : myModuleEditors.values()) { moduleEditor.moduleCountChanged(); } } public void processModuleCompilerOutputChanged(String baseUrl) { - for (ModuleEditor moduleEditor : myModuleEditors) { + for (ModuleEditor moduleEditor : myModuleEditors.values()) { moduleEditor.updateCompilerOutputPathChanged(baseUrl, moduleEditor.getName()); } } @@ -502,7 +496,7 @@ public class ModulesConfigurator implements ModulesProvider, ModuleEditor.Change if (myModuleModel.isChanged()) { return true; } - for (ModuleEditor moduleEditor : myModuleEditors) { + for (ModuleEditor moduleEditor : myModuleEditors.values()) { if (moduleEditor.isModified()) { return true; } @@ -552,13 +546,12 @@ public class ModulesConfigurator implements ModulesProvider, ModuleEditor.Change } public void moduleRenamed(Module module, final String oldName, final String name) { - for (ModuleEditor moduleEditor : myModuleEditors) { - if (module == moduleEditor.getModule() && Comparing.strEqual(moduleEditor.getName(), oldName)) { - moduleEditor.setModuleName(name); - moduleEditor.updateCompilerOutputPathChanged(ProjectStructureConfigurable.getInstance(myProject).getProjectConfig().getCompilerOutputUrl(), name); - myContext.getDaemonAnalyzer().queueUpdate(new ModuleProjectStructureElement(myContext, module)); - return; - } + ModuleEditor moduleEditor = myModuleEditors.get(module); + if (moduleEditor != null && Comparing.strEqual(moduleEditor.getName(), oldName)) { + moduleEditor.setModuleName(name); + moduleEditor.updateCompilerOutputPathChanged( + ProjectStructureConfigurable.getInstance(myProject).getProjectConfig().getCompilerOutputUrl(), name); + myContext.getDaemonAnalyzer().queueUpdate(new ModuleProjectStructureElement(myContext, module)); } } diff --git a/java/java-impl/src/com/intellij/psi/impl/AllowedApiFilterExtension.java b/java/java-analysis-impl/src/com/intellij/psi/impl/AllowedApiFilterExtension.java similarity index 100% rename from java/java-impl/src/com/intellij/psi/impl/AllowedApiFilterExtension.java rename to java/java-analysis-impl/src/com/intellij/psi/impl/AllowedApiFilterExtension.java diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/GenerateMembersUtil.java b/java/java-impl/src/com/intellij/codeInsight/generation/GenerateMembersUtil.java index 3dca018ab61a..e41b55b61655 100644 --- a/java/java-impl/src/com/intellij/codeInsight/generation/GenerateMembersUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/generation/GenerateMembersUtil.java @@ -276,13 +276,15 @@ public class GenerateMembersUtil { substituteReturnType(PsiManager.getInstance(project), resultMethod, sourceMethod.getReturnType(), collisionResolvedSubstitutor); substituteParameters(factory, codeStyleManager, sourceMethod.getParameterList(), resultMethod.getParameterList(), collisionResolvedSubstitutor, target); copyDocComment(sourceMethod, resultMethod, factory); - final List thrownTypes = ExceptionUtil.collectSubstituted(collisionResolvedSubstitutor, sourceMethod.getThrowsList().getReferencedTypes()); + GlobalSearchScope scope = sourceMethod.getResolveScope(); + final List thrownTypes = ExceptionUtil.collectSubstituted(collisionResolvedSubstitutor, sourceMethod.getThrowsList().getReferencedTypes(), + scope); if (target instanceof PsiClass) { final PsiClass[] supers = ((PsiClass)target).getSupers(); for (PsiClass aSuper : supers) { final PsiMethod psiMethod = aSuper.findMethodBySignature(sourceMethod, true); if (psiMethod != null && psiMethod != sourceMethod) { - ExceptionUtil.retainExceptions(thrownTypes, ExceptionUtil.collectSubstituted(TypeConversionUtil.getSuperClassSubstitutor(aSuper, (PsiClass)target, PsiSubstitutor.EMPTY), psiMethod.getThrowsList().getReferencedTypes())); + ExceptionUtil.retainExceptions(thrownTypes, ExceptionUtil.collectSubstituted(TypeConversionUtil.getSuperClassSubstitutor(aSuper, (PsiClass)target, PsiSubstitutor.EMPTY), psiMethod.getThrowsList().getReferencedTypes(), scope)); } } } diff --git a/java/java-psi-impl/gen/com/intellij/lang/java/lexer/_JavaDocLexer.java b/java/java-psi-impl/gen/com/intellij/lang/java/lexer/_JavaDocLexer.java index fd5431b88722..c02f43449f5a 100644 --- a/java/java-psi-impl/gen/com/intellij/lang/java/lexer/_JavaDocLexer.java +++ b/java/java-psi-impl/gen/com/intellij/lang/java/lexer/_JavaDocLexer.java @@ -1,20 +1,4 @@ -/* - * 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. - */ - -/* The following code was generated by JFlex 1.4.3 on 1/21/15 7:24 PM */ +/* The following code was generated by JFlex 1.4.3 on 5/15/15 11:22 AM */ /* It's an automatically generated code. Do not modify it. */ package com.intellij.lang.java.lexer; @@ -28,8 +12,8 @@ import com.intellij.psi.tree.IElementType; /** * This class is a scanner generated by * JFlex 1.4.3 - * on 1/21/15 7:24 PM from the specification file - * /Users/yole/jetbrains/IDEA/tools/lexer/../../community/java/java-psi-impl/src/com/intellij/lang/java/lexer/_JavaDocLexer.flex + * on 5/15/15 11:22 AM from the specification file + * C:/ws/IDEA/tools/lexer/../../community/java/java-psi-impl/src/com/intellij/lang/java/lexer/_JavaDocLexer.flex */ class _JavaDocLexer implements FlexLexer { /** initial size of the lookahead buffer */ @@ -63,70 +47,90 @@ class _JavaDocLexer implements FlexLexer { * Translates characters to character classes */ private static final String ZZ_CMAP_PACKED = - "\11\0\1\2\1\35\1\0\1\2\1\1\22\0\1\2\2\0\1\13"+ - "\1\4\3\0\1\11\1\12\1\7\1\0\1\14\1\5\1\3\1\6"+ - "\12\3\1\5\1\0\1\22\1\0\1\23\1\0\1\15\32\4\1\10"+ - "\1\0\1\10\1\0\1\4\1\0\1\17\1\4\1\25\1\27\1\30"+ - "\3\4\1\32\2\4\1\31\1\21\1\4\1\26\1\16\1\4\1\20"+ - "\1\4\1\33\6\4\1\24\1\0\1\34\44\0\4\4\4\0\1\4"+ - "\12\0\1\4\4\0\1\4\5\0\27\4\1\0\37\4\1\0\u013f\4"+ - "\31\0\162\4\4\0\14\4\16\0\5\4\11\0\1\4\213\0\1\4"+ - "\13\0\1\4\1\0\3\4\1\0\1\4\1\0\24\4\1\0\54\4"+ - "\1\0\46\4\1\0\5\4\4\0\202\4\10\0\105\4\1\0\46\4"+ - "\2\0\2\4\6\0\20\4\41\0\46\4\2\0\1\4\7\0\47\4"+ - "\110\0\33\4\5\0\3\4\56\0\32\4\5\0\13\4\43\0\2\4"+ - "\1\0\143\4\1\0\1\4\17\0\2\4\7\0\2\4\12\0\3\4"+ - "\2\0\1\4\20\0\1\4\1\0\36\4\35\0\3\4\60\0\46\4"+ - "\13\0\1\4\u0152\0\66\4\3\0\1\4\22\0\1\4\7\0\12\4"+ - "\43\0\10\4\2\0\2\4\2\0\26\4\1\0\7\4\1\0\1\4"+ - "\3\0\4\4\3\0\1\4\36\0\2\4\1\0\3\4\16\0\4\4"+ - "\21\0\6\4\4\0\2\4\2\0\26\4\1\0\7\4\1\0\2\4"+ - "\1\0\2\4\1\0\2\4\37\0\4\4\1\0\1\4\23\0\3\4"+ - "\20\0\11\4\1\0\3\4\1\0\26\4\1\0\7\4\1\0\2\4"+ - "\1\0\5\4\3\0\1\4\22\0\1\4\17\0\2\4\17\0\1\4"+ - "\23\0\10\4\2\0\2\4\2\0\26\4\1\0\7\4\1\0\2\4"+ - "\1\0\5\4\3\0\1\4\36\0\2\4\1\0\3\4\17\0\1\4"+ - "\21\0\1\4\1\0\6\4\3\0\3\4\1\0\4\4\3\0\2\4"+ - "\1\0\1\4\1\0\2\4\3\0\2\4\3\0\3\4\3\0\10\4"+ - "\1\0\3\4\77\0\1\4\13\0\10\4\1\0\3\4\1\0\27\4"+ - "\1\0\12\4\1\0\5\4\46\0\2\4\43\0\10\4\1\0\3\4"+ - "\1\0\27\4\1\0\12\4\1\0\5\4\3\0\1\4\40\0\1\4"+ - "\1\0\2\4\43\0\10\4\1\0\3\4\1\0\27\4\1\0\20\4"+ - "\46\0\2\4\43\0\22\4\3\0\30\4\1\0\11\4\1\0\1\4"+ - "\2\0\7\4\72\0\60\4\1\0\2\4\13\0\10\4\72\0\2\4"+ - "\1\0\1\4\2\0\2\4\1\0\1\4\2\0\1\4\6\0\4\4"+ - "\1\0\7\4\1\0\3\4\1\0\1\4\1\0\1\4\2\0\2\4"+ - "\1\0\4\4\1\0\2\4\11\0\1\4\2\0\5\4\1\0\1\4"+ - "\25\0\2\4\42\0\1\4\77\0\10\4\1\0\42\4\35\0\4\4"+ - "\164\0\42\4\1\0\5\4\1\0\2\4\45\0\6\4\112\0\46\4"+ - "\12\0\51\4\7\0\132\4\5\0\104\4\5\0\122\4\6\0\7\4"+ - "\1\0\77\4\1\0\1\4\1\0\4\4\2\0\7\4\1\0\1\4"+ - "\1\0\4\4\2\0\47\4\1\0\1\4\1\0\4\4\2\0\37\4"+ - "\1\0\1\4\1\0\4\4\2\0\7\4\1\0\1\4\1\0\4\4"+ - "\2\0\7\4\1\0\7\4\1\0\27\4\1\0\37\4\1\0\1\4"+ - "\1\0\4\4\2\0\7\4\1\0\47\4\1\0\23\4\105\0\125\4"+ - "\14\0\u026c\4\2\0\10\4\12\0\32\4\5\0\113\4\3\0\3\4"+ - "\17\0\15\4\1\0\4\4\16\0\22\4\16\0\22\4\16\0\15\4"+ - "\1\0\3\4\17\0\64\4\43\0\1\4\3\0\2\4\103\0\130\4"+ - "\10\0\51\4\127\0\35\4\63\0\36\4\2\0\5\4\u038b\0\154\4"+ - "\224\0\234\4\4\0\132\4\6\0\26\4\2\0\6\4\2\0\46\4"+ - "\2\0\6\4\2\0\10\4\1\0\1\4\1\0\1\4\1\0\1\4"+ - "\1\0\37\4\2\0\65\4\1\0\7\4\1\0\1\4\3\0\3\4"+ - "\1\0\7\4\3\0\4\4\2\0\6\4\4\0\15\4\5\0\3\4"+ - "\1\0\7\4\102\0\2\4\23\0\1\4\34\0\1\4\15\0\1\4"+ - "\40\0\22\4\120\0\1\4\4\0\1\4\2\0\12\4\1\0\1\4"+ - "\3\0\5\4\6\0\1\4\1\0\1\4\1\0\1\4\1\0\4\4"+ - "\1\0\3\4\1\0\7\4\3\0\3\4\5\0\5\4\26\0\44\4"+ - "\u0e81\0\3\4\31\0\11\4\7\0\5\4\2\0\5\4\4\0\126\4"+ - "\6\0\3\4\1\0\137\4\5\0\50\4\4\0\136\4\21\0\30\4"+ - "\70\0\20\4\u0200\0\u19b6\4\112\0\u51a6\4\132\0\u048d\4\u0773\0\u2ba4\4"+ - "\u215c\0\u012e\4\2\0\73\4\225\0\7\4\14\0\5\4\5\0\1\4"+ - "\1\0\12\4\1\0\15\4\1\0\5\4\1\0\1\4\1\0\2\4"+ - "\1\0\2\4\1\0\154\4\41\0\u016b\4\22\0\100\4\2\0\66\4"+ - "\50\0\15\4\66\0\2\4\30\0\3\4\31\0\1\4\6\0\5\4"+ - "\1\0\207\4\7\0\1\4\34\0\32\4\4\0\1\4\1\0\32\4"+ - "\12\0\132\4\3\0\6\4\2\0\6\4\2\0\6\4\2\0\3\4"+ - "\3\0\2\4\3\0\2\4\31\0"; + "\11\0\1\2\1\35\1\0\1\2\1\1\22\0\1\2\2\0\1\14"+ + "\1\4\3\0\1\12\1\13\1\10\1\0\1\15\1\5\1\3\1\7"+ + "\12\3\1\5\1\0\1\23\1\0\1\24\1\0\1\16\32\4\1\11"+ + "\1\0\1\11\1\0\1\4\1\0\1\20\1\4\1\26\1\30\1\31"+ + "\3\4\1\33\2\4\1\32\1\22\1\4\1\27\1\17\1\4\1\21"+ + "\1\4\1\34\6\4\1\25\1\0\1\6\44\0\4\4\4\0\1\4"+ + "\12\0\1\4\4\0\1\4\5\0\27\4\1\0\37\4\1\0\u01ca\4"+ + "\4\0\14\4\16\0\5\4\7\0\1\4\1\0\1\4\201\0\5\4"+ + "\1\0\2\4\2\0\4\4\10\0\1\4\1\0\3\4\1\0\1\4"+ + "\1\0\24\4\1\0\123\4\1\0\213\4\10\0\236\4\11\0\46\4"+ + "\2\0\1\4\7\0\47\4\7\0\1\4\100\0\33\4\5\0\3\4"+ + "\30\0\1\4\24\0\53\4\43\0\2\4\1\0\143\4\1\0\1\4"+ + "\17\0\2\4\7\0\2\4\12\0\3\4\2\0\1\4\20\0\1\4"+ + "\1\0\36\4\35\0\131\4\13\0\1\4\30\0\41\4\11\0\2\4"+ + "\4\0\1\4\5\0\26\4\4\0\1\4\11\0\1\4\3\0\1\4"+ + "\27\0\31\4\107\0\1\4\1\0\13\4\127\0\66\4\3\0\1\4"+ + "\22\0\1\4\7\0\12\4\17\0\7\4\1\0\7\4\5\0\10\4"+ + "\2\0\2\4\2\0\26\4\1\0\7\4\1\0\1\4\3\0\4\4"+ + "\3\0\1\4\20\0\1\4\15\0\2\4\1\0\3\4\16\0\4\4"+ + "\7\0\1\4\11\0\6\4\4\0\2\4\2\0\26\4\1\0\7\4"+ + "\1\0\2\4\1\0\2\4\1\0\2\4\37\0\4\4\1\0\1\4"+ + "\23\0\3\4\20\0\11\4\1\0\3\4\1\0\26\4\1\0\7\4"+ + "\1\0\2\4\1\0\5\4\3\0\1\4\22\0\1\4\17\0\2\4"+ + "\17\0\1\4\23\0\10\4\2\0\2\4\2\0\26\4\1\0\7\4"+ + "\1\0\2\4\1\0\5\4\3\0\1\4\36\0\2\4\1\0\3\4"+ + "\17\0\1\4\21\0\1\4\1\0\6\4\3\0\3\4\1\0\4\4"+ + "\3\0\2\4\1\0\1\4\1\0\2\4\3\0\2\4\3\0\3\4"+ + "\3\0\14\4\26\0\1\4\50\0\1\4\13\0\10\4\1\0\3\4"+ + "\1\0\27\4\1\0\12\4\1\0\5\4\3\0\1\4\32\0\2\4"+ + "\6\0\2\4\43\0\10\4\1\0\3\4\1\0\27\4\1\0\12\4"+ + "\1\0\5\4\3\0\1\4\40\0\1\4\1\0\2\4\17\0\2\4"+ + "\22\0\10\4\1\0\3\4\1\0\51\4\2\0\1\4\20\0\1\4"+ + "\21\0\2\4\30\0\6\4\5\0\22\4\3\0\30\4\1\0\11\4"+ + "\1\0\1\4\2\0\7\4\72\0\60\4\1\0\2\4\13\0\10\4"+ + "\72\0\2\4\1\0\1\4\2\0\2\4\1\0\1\4\2\0\1\4"+ + "\6\0\4\4\1\0\7\4\1\0\3\4\1\0\1\4\1\0\1\4"+ + "\2\0\2\4\1\0\4\4\1\0\2\4\11\0\1\4\2\0\5\4"+ + "\1\0\1\4\25\0\4\4\40\0\1\4\77\0\10\4\1\0\44\4"+ + "\33\0\5\4\163\0\53\4\24\0\1\4\20\0\6\4\4\0\4\4"+ + "\3\0\1\4\3\0\2\4\7\0\3\4\4\0\15\4\14\0\1\4"+ + "\21\0\46\4\1\0\1\4\5\0\1\4\2\0\53\4\1\0\u014d\4"+ + "\1\0\4\4\2\0\7\4\1\0\1\4\1\0\4\4\2\0\51\4"+ + "\1\0\4\4\2\0\41\4\1\0\4\4\2\0\7\4\1\0\1\4"+ + "\1\0\4\4\2\0\17\4\1\0\71\4\1\0\4\4\2\0\103\4"+ + "\45\0\20\4\20\0\125\4\14\0\u026c\4\2\0\21\4\1\0\32\4"+ + "\5\0\113\4\3\0\3\4\17\0\15\4\1\0\4\4\16\0\22\4"+ + "\16\0\22\4\16\0\15\4\1\0\3\4\17\0\64\4\43\0\1\4"+ + "\3\0\2\4\103\0\130\4\10\0\51\4\1\0\1\4\5\0\106\4"+ + "\12\0\35\4\63\0\36\4\2\0\5\4\13\0\54\4\25\0\7\4"+ + "\70\0\27\4\11\0\65\4\122\0\1\4\135\0\57\4\21\0\7\4"+ + "\67\0\36\4\15\0\2\4\12\0\54\4\32\0\44\4\51\0\3\4"+ + "\12\0\44\4\153\0\4\4\1\0\4\4\3\0\2\4\11\0\300\4"+ + "\100\0\u0116\4\2\0\6\4\2\0\46\4\2\0\6\4\2\0\10\4"+ + "\1\0\1\4\1\0\1\4\1\0\1\4\1\0\37\4\2\0\65\4"+ + "\1\0\7\4\1\0\1\4\3\0\3\4\1\0\7\4\3\0\4\4"+ + "\2\0\6\4\4\0\15\4\5\0\3\4\1\0\7\4\102\0\2\4"+ + "\23\0\1\4\34\0\1\4\15\0\1\4\20\0\15\4\3\0\33\4"+ + "\107\0\1\4\4\0\1\4\2\0\12\4\1\0\1\4\3\0\5\4"+ + "\6\0\1\4\1\0\1\4\1\0\1\4\1\0\4\4\1\0\13\4"+ + "\2\0\4\4\5\0\5\4\4\0\1\4\21\0\51\4\u0a77\0\57\4"+ + "\1\0\57\4\1\0\205\4\6\0\4\4\3\0\2\4\14\0\46\4"+ + "\1\0\1\4\5\0\1\4\2\0\70\4\7\0\1\4\20\0\27\4"+ + "\11\0\7\4\1\0\7\4\1\0\7\4\1\0\7\4\1\0\7\4"+ + "\1\0\7\4\1\0\7\4\1\0\7\4\120\0\1\4\u01d5\0\3\4"+ + "\31\0\11\4\7\0\5\4\2\0\5\4\4\0\126\4\6\0\3\4"+ + "\1\0\132\4\1\0\4\4\5\0\51\4\3\0\136\4\21\0\33\4"+ + "\65\0\20\4\u0200\0\u19b6\4\112\0\u51cd\4\63\0\u048d\4\103\0\56\4"+ + "\2\0\u010d\4\3\0\20\4\12\0\2\4\24\0\57\4\20\0\31\4"+ + "\10\0\120\4\47\0\11\4\2\0\147\4\2\0\4\4\1\0\4\4"+ + "\14\0\13\4\115\0\12\4\1\0\3\4\1\0\4\4\1\0\27\4"+ + "\25\0\1\4\7\0\64\4\16\0\62\4\76\0\6\4\3\0\1\4"+ + "\16\0\34\4\12\0\27\4\31\0\35\4\7\0\57\4\34\0\1\4"+ + "\60\0\51\4\27\0\3\4\1\0\10\4\24\0\27\4\3\0\1\4"+ + "\5\0\60\4\1\0\1\4\3\0\2\4\2\0\5\4\2\0\1\4"+ + "\1\0\1\4\30\0\3\4\2\0\13\4\7\0\3\4\14\0\6\4"+ + "\2\0\6\4\2\0\6\4\11\0\7\4\1\0\7\4\221\0\43\4"+ + "\35\0\u2ba4\4\14\0\27\4\4\0\61\4\u2104\0\u016e\4\2\0\152\4"+ + "\46\0\7\4\14\0\5\4\5\0\1\4\1\0\12\4\1\0\15\4"+ + "\1\0\5\4\1\0\1\4\1\0\2\4\1\0\2\4\1\0\154\4"+ + "\41\0\u016b\4\22\0\100\4\2\0\66\4\50\0\15\4\66\0\2\4"+ + "\30\0\3\4\31\0\1\4\6\0\5\4\1\0\207\4\7\0\1\4"+ + "\34\0\32\4\4\0\1\4\1\0\32\4\13\0\131\4\3\0\6\4"+ + "\2\0\6\4\2\0\6\4\2\0\3\4\3\0\2\4\3\0\2\4"+ + "\31\0"; /** * Translates characters to character classes @@ -139,13 +143,13 @@ class _JavaDocLexer implements FlexLexer { private static final int [] ZZ_ACTION = zzUnpackAction(); private static final String ZZ_ACTION_PACKED_0 = - "\13\0\3\1\1\2\1\3\2\2\1\4\1\5\1\6"+ + "\13\0\3\1\1\2\1\3\1\4\2\2\1\5\1\6"+ "\1\7\1\10\1\11\1\12\1\13\1\14\1\15\1\16"+ "\1\17\1\12\1\20\1\1\3\21\1\22\1\0\1\23"+ - "\1\0\4\24\1\25\7\24\1\26\1\24\1\27\2\24"; + "\1\0\6\24\1\25\12\24\1\26\1\24\2\27\2\24"; private static int [] zzUnpackAction() { - int [] result = new int[57]; + int [] result = new int[63]; int offset = 0; offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); return result; @@ -172,15 +176,15 @@ class _JavaDocLexer implements FlexLexer { private static final String ZZ_ROWMAP_PACKED_0 = "\0\0\0\36\0\74\0\132\0\170\0\226\0\264\0\322"+ "\0\360\0\u010e\0\u012c\0\u014a\0\u0168\0\u0186\0\u014a\0\u01a4"+ - "\0\u0186\0\u01c2\0\u014a\0\u014a\0\u01e0\0\u01fe\0\u021c\0\u023a"+ + "\0\u014a\0\u0186\0\u01c2\0\u014a\0\u01e0\0\u01fe\0\u021c\0\u023a"+ "\0\u0258\0\u014a\0\u014a\0\u014a\0\u014a\0\u014a\0\u0276\0\u014a"+ "\0\u0294\0\u014a\0\u02b2\0\u0186\0\u02b2\0\u02d0\0\u014a\0\u0186"+ - "\0\u02ee\0\u030c\0\u032a\0\u0348\0\u014a\0\u0366\0\u0384\0\u03a2"+ - "\0\u03c0\0\u03de\0\u03fc\0\u041a\0\u02ee\0\u0438\0\u02ee\0\u0456"+ - "\0\u0474"; + "\0\u02ee\0\u030c\0\u032a\0\u0348\0\u0366\0\u0384\0\u014a\0\u03a2"+ + "\0\u03c0\0\u03de\0\u03fc\0\u041a\0\u0438\0\u0456\0\u0474\0\u0492"+ + "\0\u04b0\0\u032a\0\u04ce\0\u02ee\0\u032a\0\u04ec\0\u050a"; private static int [] zzUnpackRowMap() { - int [] result = new int[57]; + int [] result = new int[63]; int offset = 0; offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); return result; @@ -203,43 +207,48 @@ class _JavaDocLexer implements FlexLexer { private static final int [] ZZ_TRANS = zzUnpackTrans(); private static final String ZZ_TRANS_PACKED_0 = - "\6\14\1\15\1\16\26\14\1\17\2\20\4\17\1\21"+ - "\5\17\1\22\6\17\1\23\7\17\1\24\1\20\1\17"+ - "\1\20\1\25\4\17\1\21\14\17\1\23\7\17\1\24"+ - "\1\20\1\14\2\26\4\14\1\16\24\14\1\24\1\26"+ - "\1\14\2\27\4\14\1\16\25\14\1\27\1\17\2\30"+ - "\2\31\2\17\1\21\1\31\1\32\1\17\1\33\1\34"+ - "\1\17\4\31\1\35\2\17\7\31\1\24\1\30\1\14"+ - "\2\20\2\31\2\14\1\16\1\31\1\14\1\36\1\14"+ - "\1\34\1\14\4\31\3\14\7\31\1\14\1\20\4\14"+ - "\1\37\2\14\1\16\6\14\4\37\1\14\1\40\1\14"+ - "\7\37\11\14\1\16\5\14\1\41\20\14\1\42\2\43"+ - "\4\42\1\44\14\42\1\23\7\42\1\24\1\45\1\42"+ - "\2\43\4\42\1\44\24\42\1\24\1\45\45\0\1\46"+ - "\34\0\1\47\1\50\27\0\2\20\32\0\1\20\4\0"+ - "\1\51\11\0\1\52\3\51\3\0\7\51\4\0\1\25"+ - "\34\0\2\26\32\0\1\26\1\0\2\27\32\0\1\27"+ - "\1\0\2\30\32\0\1\30\3\0\2\31\3\0\1\31"+ - "\5\0\4\31\3\0\7\31\5\0\3\37\10\0\4\37"+ - "\3\0\7\37\6\0\1\51\11\0\1\52\3\51\3\0"+ - "\1\53\3\51\1\54\2\51\3\0\2\45\32\0\1\45"+ - "\7\0\1\55\31\0\3\51\10\0\4\51\3\0\7\51"+ - "\5\0\3\51\10\0\1\51\1\56\2\51\3\0\7\51"+ - "\5\0\3\51\10\0\4\51\3\0\1\51\1\57\5\51"+ - "\5\0\3\51\10\0\4\51\3\0\5\51\1\60\1\51"+ - "\5\0\3\51\10\0\2\51\1\61\1\51\3\0\7\51"+ - "\5\0\3\51\10\0\4\51\3\0\2\51\1\62\4\51"+ - "\5\0\3\51\10\0\4\51\3\0\6\51\1\63\5\0"+ - "\3\51\10\0\1\51\1\64\2\51\3\0\7\51\5\0"+ - "\3\51\10\0\4\51\3\0\3\51\1\65\3\51\5\0"+ - "\3\51\10\0\4\51\3\0\3\51\1\66\3\51\5\0"+ - "\3\51\10\0\3\51\1\67\3\0\7\51\5\0\3\51"+ - "\10\0\2\51\1\70\1\51\3\0\7\51\5\0\3\51"+ - "\10\0\1\51\1\71\2\51\3\0\7\51\5\0\3\51"+ - "\10\0\4\51\3\0\4\51\1\65\2\51\2\0"; + "\7\14\1\15\1\16\25\14\1\17\2\20\3\17\1\21"+ + "\1\17\1\22\5\17\1\23\6\17\1\24\7\17\1\20"+ + "\1\17\1\20\1\25\3\17\1\21\1\17\1\22\14\17"+ + "\1\24\7\17\1\20\1\14\2\26\3\14\1\21\1\14"+ + "\1\16\24\14\1\26\1\14\2\27\5\14\1\16\24\14"+ + "\1\27\1\17\2\30\2\31\1\17\1\21\1\17\1\22"+ + "\1\31\1\32\1\17\1\33\1\34\1\17\4\31\1\35"+ + "\2\17\7\31\1\30\1\14\2\20\2\31\3\14\1\16"+ + "\1\31\1\14\1\36\1\14\1\34\1\14\4\31\3\14"+ + "\7\31\1\20\4\14\1\37\3\14\1\16\6\14\4\37"+ + "\1\14\1\40\1\14\7\37\11\14\1\16\5\14\1\41"+ + "\17\14\1\42\2\43\3\42\1\21\1\42\1\44\14\42"+ + "\1\24\7\42\1\45\1\42\2\43\3\42\1\21\1\42"+ + "\1\44\24\42\1\45\46\0\1\46\34\0\1\47\1\50"+ + "\26\0\2\20\32\0\1\20\1\51\2\0\14\51\1\52"+ + "\15\51\3\0\1\25\34\0\2\26\32\0\1\26\1\0"+ + "\2\27\32\0\1\27\1\0\2\30\32\0\1\30\3\0"+ + "\2\31\4\0\1\31\5\0\4\31\3\0\7\31\4\0"+ + "\3\37\11\0\4\37\3\0\7\37\1\0\1\53\2\0"+ + "\3\53\1\0\10\53\1\54\6\53\1\55\3\53\1\56"+ + "\2\53\2\0\2\45\32\0\1\45\10\0\1\57\25\0"+ + "\1\51\2\0\32\51\1\0\1\51\2\0\15\51\1\60"+ + "\14\51\1\0\1\53\2\0\3\53\1\0\26\53\1\0"+ + "\1\53\2\0\3\53\1\0\11\53\1\61\14\53\1\0"+ + "\1\53\2\0\3\53\1\0\20\53\1\62\5\53\1\0"+ + "\1\53\2\0\3\53\1\0\24\53\1\63\1\53\1\0"+ + "\1\51\2\0\16\51\1\64\13\51\1\0\1\53\2\0"+ + "\3\53\1\0\12\53\1\65\13\53\1\0\1\53\2\0"+ + "\3\53\1\0\21\53\1\66\4\53\1\0\1\53\2\0"+ + "\3\53\1\0\25\53\1\67\1\0\1\51\2\0\15\51"+ + "\1\70\14\51\1\0\1\53\2\0\3\53\1\0\11\53"+ + "\1\71\14\53\1\0\1\53\2\0\3\53\1\0\22\53"+ + "\1\72\3\53\1\0\1\53\2\0\3\53\1\0\22\53"+ + "\1\73\3\53\1\0\1\51\2\0\17\51\1\74\12\51"+ + "\1\0\1\53\2\0\3\53\1\0\13\53\1\75\12\53"+ + "\1\0\1\53\2\0\3\53\1\0\12\53\1\76\13\53"+ + "\1\0\1\53\2\0\3\53\1\0\11\53\1\77\14\53"+ + "\1\0\1\53\2\0\3\53\1\0\23\53\1\72\2\53"+ + "\1\0"; private static int [] zzUnpackTrans() { - int [] result = new int[1170]; + int [] result = new int[1320]; int offset = 0; offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); return result; @@ -280,12 +289,12 @@ class _JavaDocLexer implements FlexLexer { private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); private static final String ZZ_ATTRIBUTE_PACKED_0 = - "\13\0\1\11\2\1\1\11\3\1\2\11\5\1\5\11"+ - "\1\1\1\11\1\1\1\11\3\1\1\0\1\11\1\0"+ - "\4\1\1\11\14\1"; + "\13\0\1\11\2\1\1\11\1\1\1\11\2\1\1\11"+ + "\5\1\5\11\1\1\1\11\1\1\1\11\3\1\1\0"+ + "\1\11\1\0\6\1\1\11\20\1"; private static int [] zzUnpackAttribute() { - int [] result = new int[57]; + int [] result = new int[63]; int offset = 0; offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); return result; @@ -365,19 +374,15 @@ class _JavaDocLexer implements FlexLexer { } + /** + * Creates a new scanner + * + * @param in the java.io.Reader to read input from. + */ _JavaDocLexer(java.io.Reader in) { this.zzReader = in; } - /** - * Creates a new scanner. - * There is also java.io.Reader version of this constructor. - * - * @param in the java.io.Inputstream to read input from. - */ - _JavaDocLexer(java.io.InputStream in) { - this(new java.io.InputStreamReader(in)); - } /** * Unpacks the compressed character translation table. @@ -389,7 +394,7 @@ class _JavaDocLexer implements FlexLexer { char [] map = new char[0x10000]; int i = 0; /* index in packed string */ int j = 0; /* index in unpacked array */ - while (i < 1270) { + while (i < 1662) { int count = packed.charAt(i++); char value = packed.charAt(i++); do map[j++] = value; while (--count > 0); @@ -631,25 +636,66 @@ class _JavaDocLexer implements FlexLexer { { return myTokenTypes.commentData(); } case 28: break; - case 5: + case 4: { yybegin(COMMENT_DATA); return myTokenTypes.inlineTagEnd(); } case 29: break; - case 4: - { if (checkAhead('@')) { - yybegin(INLINE_TAG_NAME); - return myTokenTypes.inlineTagStart(); - } - else{ - yybegin(COMMENT_DATA); - return myTokenTypes.inlineTagStart(); - } - } - case 30: break; case 21: { yybegin(COMMENT_DATA_START); return myTokenTypes.commentStart(); } + case 30: break; + case 7: + { if (checkAhead('<') || checkAhead('\"')) yybegin(COMMENT_DATA); + else if (checkAhead('\u007b') ) yybegin(COMMENT_DATA); // lbrace - there's a error in JLex when typing lbrace directly + else yybegin(DOC_TAG_VALUE); + return myTokenTypes.space(); + } case 31: break; + case 8: + { yybegin(DOC_TAG_VALUE); return myTokenTypes.space(); + } + case 32: break; + case 10: + { return myTokenTypes.tagValueToken(); + } + case 33: break; + case 20: + { yybegin(TAG_DOC_SPACE); return myTokenTypes.tagName(); + } + case 34: break; + case 18: + { yybegin(CODE_TAG); + return myTokenTypes.space(); + } + case 35: break; + case 9: + { yybegin(COMMENT_DATA); return myTokenTypes.space(); + } + case 36: break; + case 23: + { yybegin(PARAM_TAG_SPACE); return myTokenTypes.tagName(); + } + case 37: break; + case 22: + { yybegin(CODE_TAG_SPACE); return myTokenTypes.tagName(); + } + case 38: break; + case 1: + { return myTokenTypes.badCharacter(); + } + case 39: break; + case 15: + { yybegin(DOC_TAG_VALUE); return myTokenTypes.tagValueRParen(); + } + case 40: break; + case 11: + { yybegin(DOC_TAG_VALUE_IN_PAREN); return myTokenTypes.tagValueLParen(); + } + case 41: break; + case 13: + { return myTokenTypes.tagValueComma(); + } + case 42: break; case 14: { if (myJdk15Enabled) { yybegin(DOC_TAG_VALUE_IN_LTGT); @@ -660,57 +706,16 @@ class _JavaDocLexer implements FlexLexer { return myTokenTypes.commentData(); } } - case 32: break; - case 18: - { yybegin(CODE_TAG); - return myTokenTypes.space(); - } - case 33: break; - case 8: - { yybegin(DOC_TAG_VALUE); return myTokenTypes.space(); - } - case 34: break; - case 10: - { return myTokenTypes.tagValueToken(); - } - case 35: break; - case 20: - { yybegin(TAG_DOC_SPACE); return myTokenTypes.tagName(); - } - case 36: break; - case 9: - { yybegin(COMMENT_DATA); return myTokenTypes.space(); - } - case 37: break; - case 23: - { yybegin(PARAM_TAG_SPACE); return myTokenTypes.tagName(); - } - case 38: break; - case 22: - { yybegin(CODE_TAG_SPACE); return myTokenTypes.tagName(); - } - case 39: break; - case 7: - { if (checkAhead('<') || checkAhead('\"')) yybegin(COMMENT_DATA); - else if (checkAhead('\u007b') ) yybegin(COMMENT_DATA); // lbrace - there's a error in JLex when typing lbrace directly - else yybegin(DOC_TAG_VALUE); - return myTokenTypes.space(); - } - case 40: break; - case 1: - { return myTokenTypes.badCharacter(); - } - case 41: break; - case 15: - { yybegin(DOC_TAG_VALUE); return myTokenTypes.tagValueRParen(); - } - case 42: break; - case 11: - { yybegin(DOC_TAG_VALUE_IN_PAREN); return myTokenTypes.tagValueLParen(); - } case 43: break; - case 13: - { return myTokenTypes.tagValueComma(); + case 5: + { if (checkAhead('@')) { + yybegin(INLINE_TAG_NAME); + return myTokenTypes.inlineTagStart(); + } + else{ + yybegin(COMMENT_DATA); + return myTokenTypes.inlineTagStart(); + } } case 44: break; case 2: diff --git a/java/java-psi-impl/src/com/intellij/codeInsight/ExceptionUtil.java b/java/java-psi-impl/src/com/intellij/codeInsight/ExceptionUtil.java index cb6b93dd226d..e268bbdcd526 100644 --- a/java/java-psi-impl/src/com/intellij/codeInsight/ExceptionUtil.java +++ b/java/java-psi-impl/src/com/intellij/codeInsight/ExceptionUtil.java @@ -22,12 +22,14 @@ import com.intellij.openapi.util.RecursionGuard; import com.intellij.openapi.util.RecursionManager; import com.intellij.psi.*; import com.intellij.psi.controlFlow.*; +import com.intellij.psi.impl.PsiClassImplUtil; import com.intellij.psi.impl.PsiImplUtil; import com.intellij.psi.infos.CandidateInfo; import com.intellij.psi.infos.MethodCandidateInfo; import com.intellij.psi.scope.MethodProcessorSetupFailedException; import com.intellij.psi.scope.processor.MethodResolverProcessor; import com.intellij.psi.scope.util.PsiScopesUtil; +import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.util.*; import com.intellij.util.ArrayUtil; import com.intellij.util.Function; @@ -187,7 +189,7 @@ public class ExceptionUtil { PsiMethod method = (PsiMethod)resolveResult.getElement(); if (method != null) { - addExceptions(result, getExceptionsByMethod(method, resolveResult.getSubstitutor())); + addExceptions(result, getExceptionsByMethod(method, resolveResult.getSubstitutor(), element)); } addExceptions(result, getThrownExceptions(element.getChildren())); @@ -196,12 +198,16 @@ public class ExceptionUtil { } @NotNull - private static List getExceptionsByMethod(@NotNull PsiMethod method, @NotNull PsiSubstitutor substitutor) { - List result = ContainerUtil.newArrayList(); - + private static List getExceptionsByMethod(@NotNull PsiMethod method, @NotNull PsiSubstitutor substitutor, + @NotNull PsiElement place) { PsiClassType[] referenceTypes = method.getThrowsList().getReferencedTypes(); + if (referenceTypes.length == 0) return Collections.emptyList(); + + GlobalSearchScope scope = place.getResolveScope(); + + List result = ContainerUtil.newArrayList(); for (PsiType type : referenceTypes) { - type = substitutor.substitute(type); + type = PsiClassImplUtil.correctType(substitutor.substitute(type), scope); if (type instanceof PsiClassType) { result.add((PsiClassType)type); } @@ -449,13 +455,14 @@ public class ExceptionUtil { } }); if (candidates.size() > 1) { - final List ex = collectSubstituted(substitutor, thrownExceptions); + GlobalSearchScope scope = methodCall.getResolveScope(); + final List ex = collectSubstituted(substitutor, thrownExceptions, scope); for (Pair pair : candidates) { final PsiClassType[] exceptions = pair.first.getThrowsList().getReferencedTypes(); if (exceptions.length == 0) { return getUnhandledExceptions(methodCall, topElement, PsiSubstitutor.EMPTY, PsiClassType.EMPTY_ARRAY); } - retainExceptions(ex, collectSubstituted(pair.second, exceptions)); + retainExceptions(ex, collectSubstituted(pair.second, exceptions, scope)); } return getUnhandledExceptions(methodCall, topElement, PsiSubstitutor.EMPTY, ex.toArray(new PsiClassType[ex.size()])); } @@ -512,10 +519,10 @@ public class ExceptionUtil { ex.addAll(replacement); } - public static List collectSubstituted(PsiSubstitutor substitutor, PsiClassType[] thrownExceptions) { + public static List collectSubstituted(PsiSubstitutor substitutor, PsiClassType[] thrownExceptions, GlobalSearchScope scope) { final List ex = new ArrayList(); for (PsiClassType thrownException : thrownExceptions) { - final PsiType psiType = substitutor.substitute(thrownException); + final PsiType psiType = PsiClassImplUtil.correctType(substitutor.substitute(thrownException), scope); if (psiType instanceof PsiClassType) { ex.add((PsiClassType)psiType); } @@ -527,7 +534,7 @@ public class ExceptionUtil { public static List getCloserExceptions(@NotNull PsiResourceVariable resource) { PsiMethod method = PsiUtil.getResourceCloserMethod(resource); PsiSubstitutor substitutor = PsiUtil.resolveGenericsClassInType(resource.getType()).getSubstitutor(); - return method != null ? getExceptionsByMethod(method, substitutor) : Collections.emptyList(); + return method != null ? getExceptionsByMethod(method, substitutor, resource) : Collections.emptyList(); } @NotNull @@ -593,7 +600,7 @@ public class ExceptionUtil { List result = ContainerUtil.newArrayList(); for (PsiClassType referencedType : referencedTypes) { - final PsiType type = GenericsUtil.eliminateWildcards(substitutor.substitute(referencedType), false); + final PsiType type = PsiClassImplUtil.correctType(GenericsUtil.eliminateWildcards(substitutor.substitute(referencedType), false), element.getResolveScope()); if (!(type instanceof PsiClassType)) continue; PsiClassType classType = (PsiClassType)type; PsiClass exceptionClass = ((PsiClassType)type).resolve(); diff --git a/java/java-psi-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java b/java/java-psi-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java index b60d77311761..3de148091b4f 100644 --- a/java/java-psi-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java +++ b/java/java-psi-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java @@ -1264,9 +1264,6 @@ public class JavaDocInfoGenerator { else if (tagName.equals(VALUE_TAG)) { generateValueValue(tag, buffer, element); } - else { - buffer.append(element.getText()); - } } else { buffer.append(StringUtil.replaceUnicodeEscapeSequences(element.getText())); diff --git a/java/java-psi-impl/src/com/intellij/lang/java/lexer/_JavaDocLexer.flex b/java/java-psi-impl/src/com/intellij/lang/java/lexer/_JavaDocLexer.flex index c0869d84958a..437cb8e506e3 100644 --- a/java/java-psi-impl/src/com/intellij/lang/java/lexer/_JavaDocLexer.flex +++ b/java/java-psi-impl/src/com/intellij/lang/java/lexer/_JavaDocLexer.flex @@ -54,6 +54,8 @@ WHITE_DOC_SPACE_NO_LR=[\ \t\f] DIGIT=[0-9] ALPHA=[:jletter:] IDENTIFIER={ALPHA}({ALPHA}|{DIGIT}|[":.-"])* +TAG_IDENTIFIER=[^\ \t\f\n\r]+ +INLINE_TAG_IDENTIFIER=[^\ \t\f\n\r\}]+ %% @@ -98,12 +100,12 @@ IDENTIFIER={ALPHA}({ALPHA}|{DIGIT}|[":.-"])* } "@code" { yybegin(CODE_TAG_SPACE); return myTokenTypes.tagName(); } "@literal" { yybegin(CODE_TAG_SPACE); return myTokenTypes.tagName(); } - "@"{IDENTIFIER} { yybegin(TAG_DOC_SPACE); return myTokenTypes.tagName(); } + "@"{INLINE_TAG_IDENTIFIER} { yybegin(TAG_DOC_SPACE); return myTokenTypes.tagName(); } "}" { yybegin(COMMENT_DATA); return myTokenTypes.inlineTagEnd(); } . { yybegin(COMMENT_DATA); return myTokenTypes.commentData(); } . { yybegin(CODE_TAG); return myTokenTypes.commentData(); } - "@"{IDENTIFIER} { yybegin(TAG_DOC_SPACE); return myTokenTypes.tagName(); } + "@"{TAG_IDENTIFIER} { yybegin(TAG_DOC_SPACE); return myTokenTypes.tagName(); } {WHITE_DOC_SPACE_CHAR}+ { if (checkAhead('<') || checkAhead('\"')) yybegin(COMMENT_DATA); diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/JavaClassSupersImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/JavaClassSupersImpl.java index dc83c8ba72a2..9fa0cb29c03c 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/JavaClassSupersImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/JavaClassSupersImpl.java @@ -52,7 +52,7 @@ public class JavaClassSupersImpl extends JavaClassSupers { if (substitutor == null) return null; if (PsiUtil.isRawSubstitutor(derivedClass, derivedSubstitutor)) return createRawSubstitutor(superClass); - return composeSubstitutors(derivedSubstitutor, substitutor); + return composeSubstitutors(derivedSubstitutor, substitutor, superClass); } @NotNull @@ -61,10 +61,14 @@ public class JavaClassSupersImpl extends JavaClassSupers { } @NotNull - private static PsiSubstitutor composeSubstitutors(PsiSubstitutor outer, PsiSubstitutor inner) { + private static PsiSubstitutor composeSubstitutors(PsiSubstitutor outer, PsiSubstitutor inner, PsiClass onClass) { PsiSubstitutor answer = PsiSubstitutor.EMPTY; - for (Map.Entry entry : inner.getSubstitutionMap().entrySet()) { - answer = answer.put(entry.getKey(), outer.substitute(entry.getValue())); + Map outerMap = outer.getSubstitutionMap(); + Map innerMap = inner.getSubstitutionMap(); + for (PsiTypeParameter parameter : PsiUtil.typeParametersIterable(onClass)) { + if (outerMap.containsKey(parameter) || innerMap.containsKey(parameter)) { + answer = answer.put(parameter, outer.substitute(inner.substitute(parameter))); + } } return answer; } @@ -97,7 +101,7 @@ public class JavaClassSupersImpl extends JavaClassSupers { else { answer = getSuperSubstitutorWithCaching(superClass, psiClass, scope, result.getSubstitutor()); if (answer != null) { - return composeSubstitutors(derivedSubstitutor, answer); + return composeSubstitutors(derivedSubstitutor, answer, superClass); } } } diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiSuperMethodImplUtil.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiSuperMethodImplUtil.java index e853e12ef577..85d22f0077d4 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiSuperMethodImplUtil.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiSuperMethodImplUtil.java @@ -308,7 +308,7 @@ public class PsiSuperMethodImplUtil { if (superClass.isInterface() || CommonClassNames.JAVA_LANG_OBJECT.equals(superClass.getQualifiedName())) { if (superMethod.hasModifierProperty(PsiModifier.STATIC) || - superMethod.hasModifierProperty(PsiModifier.DEFAULT) && hierarchicalMethodSignature.getMethod().hasModifierProperty(PsiModifier.STATIC)) { + superMethod.hasModifierProperty(PsiModifier.DEFAULT) && hierarchicalMethodSignature.getMethod().hasModifierProperty(PsiModifier.STATIC) && !InheritanceUtil.isInheritorOrSelf(containingClass, superClass, true)) { return false; } diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/ScopedClassHierarchy.java b/java/java-psi-impl/src/com/intellij/psi/impl/ScopedClassHierarchy.java index 54a3ceddbd5c..ba7f3f149f98 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/ScopedClassHierarchy.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/ScopedClassHierarchy.java @@ -18,14 +18,19 @@ package com.intellij.psi.impl; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.psi.util.*; +import com.intellij.psi.util.CachedValueProvider; +import com.intellij.psi.util.CachedValuesManager; +import com.intellij.psi.util.PsiModificationTracker; +import com.intellij.psi.util.PsiUtil; import com.intellij.util.containers.ConcurrentFactoryMap; import com.intellij.util.containers.ContainerUtil; import gnu.trove.TObjectHashingStrategy; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.Collections; import java.util.Iterator; +import java.util.List; import java.util.Map; import static com.intellij.util.ObjectUtils.assertNotNull; @@ -48,27 +53,36 @@ class ScopedClassHierarchy { private final Map mySupersWithSubstitutors = ContainerUtil.newTroveMap(CLASS_HASHING_STRATEGY); private ScopedClassHierarchy(PsiClass psiClass, GlobalSearchScope resolveScope) { - PsiClassType type = JavaPsiFacade.getElementFactory(psiClass.getProject()).createType(psiClass, PsiSubstitutor.EMPTY); - visitTypes(resolveScope, PsiSubstitutor.EMPTY, type); + visitType(resolveScope, JavaPsiFacade.getElementFactory(psiClass.getProject()).createType(psiClass, PsiSubstitutor.EMPTY)); } - private void visitTypes(GlobalSearchScope resolveScope, PsiSubstitutor substitutor, PsiType... types) { - for (PsiType type : types) { - type = PsiClassImplUtil.correctType(substitutor.substitute(type), resolveScope); - if (!(type instanceof PsiClassType)) continue; - - PsiClassType.ClassResolveResult resolveResult = ((PsiClassType)type).resolveGenerics(); - PsiClass psiClass = resolveResult.getElement(); - if (psiClass == null || InheritanceImplUtil.hasObjectQualifiedName(psiClass) || mySupersWithSubstitutors.containsKey(psiClass)) continue; - - mySupersWithSubstitutors.put(psiClass, resolveResult); - - if (psiClass instanceof PsiAnonymousClass) { - visitTypes(resolveScope, resolveResult.getSubstitutor(), ((PsiAnonymousClass)psiClass).getBaseClassType()); - } - visitTypes(resolveScope, resolveResult.getSubstitutor(), psiClass.getExtendsListTypes()); - visitTypes(resolveScope, resolveResult.getSubstitutor(), psiClass.getImplementsListTypes()); + private void visitType(GlobalSearchScope resolveScope, @NotNull PsiClassType type) { + PsiClassType.ClassResolveResult resolveResult = type.resolveGenerics(); + PsiClass psiClass = resolveResult.getElement(); + if (psiClass == null || InheritanceImplUtil.hasObjectQualifiedName(psiClass) || mySupersWithSubstitutors.containsKey(psiClass)) { + return; } + + mySupersWithSubstitutors.put(psiClass, resolveResult); + + for (PsiType superType : getSuperTypes(psiClass)) { + superType = type.isRaw() && superType instanceof PsiClassType ? ((PsiClassType)superType).rawType() : resolveResult.getSubstitutor().substitute(superType); + superType = PsiClassImplUtil.correctType(superType, resolveScope); + if (superType instanceof PsiClassType) { + visitType(resolveScope, (PsiClassType)superType); + } + } + } + + @NotNull + private static List getSuperTypes(PsiClass psiClass) { + List superTypes = ContainerUtil.newArrayList(); + if (psiClass instanceof PsiAnonymousClass) { + ContainerUtil.addIfNotNull(superTypes, ((PsiAnonymousClass)psiClass).getBaseClassType()); + } + Collections.addAll(superTypes, psiClass.getExtendsListTypes()); + Collections.addAll(superTypes, psiClass.getImplementsListTypes()); + return superTypes; } @NotNull diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/TypeCorrector.java b/java/java-psi-impl/src/com/intellij/psi/impl/TypeCorrector.java index bedb42cecc2e..d44993ebb701 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/TypeCorrector.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/TypeCorrector.java @@ -108,8 +108,12 @@ class TypeCorrector extends PsiTypeMapper { PsiTypeParameter[] originalTypeParameters = originalClass.getTypeParameters(); if (typeParameters.length != originalTypeParameters.length) return substitutor; + Map substitutionMap = substitutor.getSubstitutionMap(); + PsiSubstitutor mappedSubstitutor = PsiSubstitutor.EMPTY; for (int i = 0; i < originalTypeParameters.length; i++) { + if (!substitutionMap.containsKey(originalTypeParameters[i])) continue; + PsiType originalSubstitute = substitutor.substitute(originalTypeParameters[i]); if (originalSubstitute != null) { PsiType substitute = mapType(originalSubstitute); diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/StubBuildingVisitor.java b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/StubBuildingVisitor.java index bc4a0ac7030d..ca9491f59727 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/StubBuildingVisitor.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/StubBuildingVisitor.java @@ -256,7 +256,7 @@ public class StubBuildingVisitor extends ClassVisitor { if ((access & Opcodes.ACC_ABSTRACT) != 0) { flags |= ModifierFlags.ABSTRACT_MASK; } - else if (isInterface) { + else if (isInterface && (access & Opcodes.ACC_STATIC) == 0) { flags |= ModifierFlags.DEFENDER_MASK; } if ((access & Opcodes.ACC_STRICT) != 0) { diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java index a27dfe5adb83..f78a5165345b 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java @@ -25,7 +25,6 @@ import com.intellij.psi.scope.processor.MethodCandidatesProcessor; import com.intellij.psi.scope.processor.MethodResolverProcessor; import com.intellij.psi.scope.util.PsiScopesUtil; import com.intellij.psi.util.PsiUtil; -import com.intellij.psi.util.TypeConversionUtil; import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -60,7 +59,6 @@ public class PsiResolveHelperImpl implements PsiResolveHelper { processor = new MethodResolverProcessor(anonymous, argumentList, place, place.getContainingFile()); aClass = anonymous.getBaseClassType().resolve(); if (aClass == null) return JavaResolveResult.EMPTY_ARRAY; - substitutor = substitutor.putAll(TypeConversionUtil.getSuperClassSubstitutor(aClass, anonymous, substitutor)); } else { processor = new MethodResolverProcessor(aClass, argumentList, place, place.getContainingFile()); diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/InheritanceOfStaticMethodFromDefault.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/InheritanceOfStaticMethodFromDefault.java new file mode 100644 index 000000000000..918c88ff50c7 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/InheritanceOfStaticMethodFromDefault.java @@ -0,0 +1,7 @@ +interface A { + default void foo(){} +} + +interface B extends A { + static void foo(){} +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/javadocIG/noSpaceAfterTagName.html b/java/java-tests/testData/codeInsight/javadocIG/noSpaceAfterTagName.html new file mode 100644 index 000000000000..44d2a12be7af --- /dev/null +++ b/java/java-tests/testData/codeInsight/javadocIG/noSpaceAfterTagName.html @@ -0,0 +1,2 @@ +
class Foo
+extends Object
foobar \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/javadocIG/noSpaceAfterTagName.java b/java/java-tests/testData/codeInsight/javadocIG/noSpaceAfterTagName.java new file mode 100644 index 000000000000..a3c0fcacca6d --- /dev/null +++ b/java/java-tests/testData/codeInsight/javadocIG/noSpaceAfterTagName.java @@ -0,0 +1,2 @@ +/** foo{@literal@tag}bar */ +class Foo {} \ No newline at end of file diff --git a/java/java-tests/testData/psi/cls/mirror/Function.txt b/java/java-tests/testData/psi/cls/mirror/Function.txt new file mode 100644 index 000000000000..24bb6e9ff0ac --- /dev/null +++ b/java/java-tests/testData/psi/cls/mirror/Function.txt @@ -0,0 +1,16 @@ + + // IntelliJ API Decompiler stub source generated from a class file + // Implementation of methods is not available + +package java.util.function; + +@java.lang.FunctionalInterface +public interface Function { + R apply(T t); + + default java.util.function.Function compose(java.util.function.Function function) { /* compiled code */ } + + default java.util.function.Function andThen(java.util.function.Function function) { /* compiled code */ } + + static java.util.function.Function identity() { /* compiled code */ } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/MultipleModuleHighlightingTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/MultipleModuleHighlightingTest.groovy index 379068e37eeb..a5b84c0c1559 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/MultipleModuleHighlightingTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/MultipleModuleHighlightingTest.groovy @@ -14,11 +14,16 @@ * limitations under the License. */ package com.intellij.codeInsight - import com.intellij.openapi.module.JavaModuleType +import com.intellij.openapi.roots.ModuleRootManager import com.intellij.openapi.roots.ModuleRootModificationUtil +import com.intellij.openapi.roots.ModuleSourceOrderEntry +import com.intellij.openapi.roots.OrderEntry import com.intellij.testFramework.PsiTestUtil import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase +import com.intellij.util.Consumer +import com.intellij.util.containers.ContainerUtil + /** * @author peter */ @@ -95,4 +100,51 @@ class Class3 { ModuleRootModificationUtil.addDependency(myModule, mod1) ModuleRootModificationUtil.addDependency(myModule, mod2) } + + public void testOverridingJdkExceptions() { + def dep = PsiTestUtil.addModule(project, JavaModuleType.moduleType, "dep", myFixture.tempDirFixture.findOrCreateDir("dep")) + ModuleRootModificationUtil.setModuleSdk(dep, ModuleRootManager.getInstance(myModule).sdk) + ModuleRootModificationUtil.updateModel(myModule, { model -> + model.addModuleOrderEntry(dep) + + List entries = model.orderEntries as List + def srcEntry = ContainerUtil.findInstance(entries, ModuleSourceOrderEntry) + assert srcEntry + + model.rearrangeOrderEntries(([srcEntry] + (entries - srcEntry)) as OrderEntry[]) + } as Consumer) + + myFixture.addFileToProject "java/lang/IllegalArgumentException.java", ''' +package java.lang; + +public class IllegalArgumentException extends Exception { } +''' + + myFixture.addFileToProject 'dep/foo/Foo.java', ''' +package foo; + +public class Foo { + public static void libraryMethod() throws IllegalArgumentException {} +} +''' + + myFixture.configureFromExistingVirtualFile(myFixture.addFileToProject('Bar.java', ''' +class Bar { + +void caught() { + try { + foo.Foo.libraryMethod(); + } catch (IllegalArgumentException e) {} +} + +void uncaught() { + foo.Foo.libraryMethod(); +} + +} + +''').virtualFile) + myFixture.checkHighlighting() + } + } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Interface8MethodsHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Interface8MethodsHighlightingTest.java index e6cceffbab96..f308271a953a 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Interface8MethodsHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Interface8MethodsHighlightingTest.java @@ -52,6 +52,10 @@ public class Interface8MethodsHighlightingTest extends LightCodeInsightFixtureTe doTest(true, false); } + public void testInheritanceOfStaticMethodFromDefault() throws Exception { + doTest(); + } + public void testStaticMethodAccessibleBothThroughStaticImportAndInheritance() throws Exception { myFixture.addClass("package p; public interface Foo {" + " static void foo() {}" + diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/JavaDocInfoGeneratorTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/JavaDocInfoGeneratorTest.java index 21160772691b..d93cd3005f0e 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/JavaDocInfoGeneratorTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/JavaDocInfoGeneratorTest.java @@ -159,6 +159,10 @@ public class JavaDocInfoGeneratorTest extends CodeInsightTestCase { assertNotNull(docInfo); assertEquals(exampleHtmlFileText(getTestName(true)), replaceEnvironmentDependentContent(docInfo)); } + + public void testNoSpaceAfterTagName() throws Exception { + verifyJavaDoc(getTestClass()); + } private static String exampleHtmlFileText(String name) throws IOException { final File htmlPath = new File(JavaTestUtil.getJavaTestDataPath() + "/codeInsight/javadocIG/" + name + ".html"); diff --git a/java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java b/java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java index df5cb1d2ff49..7d4c62b27d82 100644 --- a/java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java @@ -82,6 +82,13 @@ public class ClsMirrorBuildingTest extends LightIdeaTestCase { doTest(clsPath, txtPath); } + public void testStaticMethodInInterface() { + String testDir = JavaTestUtil.getJavaTestDataPath(); + String clsPath = testDir + "/../../mockJDK-1.8/jre/lib/rt.jar!/java/util/function/Function.class"; + String txtPath = testDir + "/psi/cls/mirror/Function.txt"; + doTest(clsPath, txtPath); + } + public void testStrayInnersFiltering() throws IOException { String path = JavaTestUtil.getJavaTestDataPath() + "/../../mockJDK-1.8/jre/lib/rt.jar!/java/lang/Class.class"; VirtualFile file = StandardFileSystems.jar().findFileByPath(path); diff --git a/platform/core-api/src/com/intellij/openapi/vfs/VirtualFileSystem.java b/platform/core-api/src/com/intellij/openapi/vfs/VirtualFileSystem.java index 1cd16c1f7fc0..862c44006476 100644 --- a/platform/core-api/src/com/intellij/openapi/vfs/VirtualFileSystem.java +++ b/platform/core-api/src/com/intellij/openapi/vfs/VirtualFileSystem.java @@ -89,8 +89,9 @@ public abstract class VirtualFileSystem { * This method is useful when the file was created externally and you need to find {@link VirtualFile} * corresponding to it.

*

- * This method should be only called within write-action. - * See {@link Application#runWriteAction}. + * If this method is invoked not from Swing event dispatch thread, then it must not happen inside a read action. The reason is that + * then the method call won't return until proper VFS events are fired, which happens on Swing thread and in write action. So invoking + * this method in a read action would result in a deadlock. * * @param path the path * @return {@link VirtualFile} if the file was found, null otherwise diff --git a/platform/diff-api/src/com/intellij/diff/FrameDiffTool.java b/platform/diff-api/src/com/intellij/diff/FrameDiffTool.java index 446a33a25204..86f354889cc2 100644 --- a/platform/diff-api/src/com/intellij/diff/FrameDiffTool.java +++ b/platform/diff-api/src/com/intellij/diff/FrameDiffTool.java @@ -40,6 +40,10 @@ public interface FrameDiffTool extends DiffTool { @NotNull @CalledInAwt ToolbarComponents init(); + + @Override + @CalledInAwt + void dispose(); } class ToolbarComponents { diff --git a/platform/diff-api/src/com/intellij/diff/requests/MessageDiffRequest.java b/platform/diff-api/src/com/intellij/diff/requests/MessageDiffRequest.java index 8e4c9f1a10c7..0d3dde3a195e 100644 --- a/platform/diff-api/src/com/intellij/diff/requests/MessageDiffRequest.java +++ b/platform/diff-api/src/com/intellij/diff/requests/MessageDiffRequest.java @@ -49,4 +49,8 @@ public abstract class MessageDiffRequest extends DiffRequest { public void setMessage(@NotNull String message) { myMessage = message; } + + @Override + public final void onAssigned(boolean isAssigned) { + } } diff --git a/platform/diff-impl/src/com/intellij/diff/impl/CacheDiffRequestChainProcessor.java b/platform/diff-impl/src/com/intellij/diff/impl/CacheDiffRequestChainProcessor.java index 63aabc7bf446..1a9a42dbd0b4 100644 --- a/platform/diff-impl/src/com/intellij/diff/impl/CacheDiffRequestChainProcessor.java +++ b/platform/diff-impl/src/com/intellij/diff/impl/CacheDiffRequestChainProcessor.java @@ -138,7 +138,7 @@ public abstract class CacheDiffRequestChainProcessor extends DiffRequestProcesso @CalledInAwt protected void onDispose() { super.onDispose(); - Disposer.dispose(myQueue); + myQueue.abort(); myRequestCache.clear(); } diff --git a/platform/diff-impl/src/com/intellij/diff/impl/DiffRequestPanelImpl.java b/platform/diff-impl/src/com/intellij/diff/impl/DiffRequestPanelImpl.java index 964c09bcf399..8677e343d868 100644 --- a/platform/diff-impl/src/com/intellij/diff/impl/DiffRequestPanelImpl.java +++ b/platform/diff-impl/src/com/intellij/diff/impl/DiffRequestPanelImpl.java @@ -35,7 +35,6 @@ public class DiffRequestPanelImpl implements DiffRequestPanel { public DiffRequestPanelImpl(@Nullable Project project, @Nullable Window window) { myProcessor = new MyCacheDiffRequestChainProcessor(project, window); - myProcessor.init(); myPanel = new JPanel(new BorderLayout()) { @Override diff --git a/platform/diff-impl/src/com/intellij/diff/impl/DiffRequestProcessor.java b/platform/diff-impl/src/com/intellij/diff/impl/DiffRequestProcessor.java index 74674c4f83ab..f939641e63fb 100644 --- a/platform/diff-impl/src/com/intellij/diff/impl/DiffRequestProcessor.java +++ b/platform/diff-impl/src/com/intellij/diff/impl/DiffRequestProcessor.java @@ -93,7 +93,7 @@ public abstract class DiffRequestProcessor implements Disposable { @NotNull private DiffRequest myActiveRequest; - @NotNull private ViewerState myState; + @Nullable private ViewerState myState; public DiffRequestProcessor(@Nullable Project project) { this(project, new UserDataHolderBase()); @@ -106,14 +106,14 @@ public abstract class DiffRequestProcessor implements Disposable { public DiffRequestProcessor(@Nullable Project project, @NotNull UserDataHolder context) { myProject = project; - myAvailableTools = DiffManagerEx.getInstance().getDiffTools(); - myToolOrder = new LinkedList(); - myContext = new MyDiffContext(context); myActiveRequest = NoDiffRequest.INSTANCE; mySettings = DiffSettingsHolder.getInstance().getSettings(myContext.getUserData(DiffUserDataKeysEx.PLACE)); + myAvailableTools = DiffManagerEx.getInstance().getDiffTools(); + myToolOrder = new LinkedList(getToolOrderFromSettings(myAvailableTools)); + // UI myPanel = new JPanel(new BorderLayout()); @@ -139,6 +139,8 @@ public abstract class DiffRequestProcessor implements Disposable { if (bottomPanel != null) myMainPanel.add(bottomPanel, BorderLayout.SOUTH); if (bottomPanel instanceof Disposable) Disposer.register(this, (Disposable)bottomPanel); + myState = new EmptyState(); + myContentPanel.setContent(DiffUtil.createMessagePanel(NoDiffRequest.INSTANCE.getMessage())); myOpenInEditorAction = new OpenInEditorAction(new Runnable() { @Override @@ -148,14 +150,6 @@ public abstract class DiffRequestProcessor implements Disposable { }); } - public void init() { - myToolOrder.addAll(getToolOrderFromSettings(myAvailableTools)); - - myActiveRequest.onAssigned(true); - myState = new ErrorState((MessageDiffRequest)myActiveRequest); - myState.init(); - } - // // Update // @@ -966,8 +960,10 @@ public abstract class DiffRequestProcessor implements Disposable { // private interface ViewerState { + @CalledInAwt void init(); + @CalledInAwt void destroy(); @Nullable @@ -980,6 +976,34 @@ public abstract class DiffRequestProcessor implements Disposable { DiffTool getActiveTool(); } + private static class EmptyState implements ViewerState { + @Override + public void init() { + } + + @Override + public void destroy() { + } + + @Nullable + @Override + public JComponent getPreferredFocusedComponent() { + return null; + } + + @Nullable + @Override + public Object getData(@NonNls String dataId) { + return null; + } + + @NotNull + @Override + public DiffTool getActiveTool() { + return ErrorDiffTool.INSTANCE; + } + } + private class ErrorState implements ViewerState { @Nullable private final DiffTool myDiffTool; @NotNull private final MessageDiffRequest myRequest; @@ -998,6 +1022,7 @@ public abstract class DiffRequestProcessor implements Disposable { } @Override + @CalledInAwt public void init() { myContentPanel.setContent(myViewer.getComponent()); @@ -1008,6 +1033,7 @@ public abstract class DiffRequestProcessor implements Disposable { } @Override + @CalledInAwt public void destroy() { Disposer.dispose(myViewer); } @@ -1041,6 +1067,7 @@ public abstract class DiffRequestProcessor implements Disposable { } @Override + @CalledInAwt public void init() { myContentPanel.setContent(myViewer.getComponent()); setTitle(myActiveRequest.getTitle()); @@ -1058,6 +1085,7 @@ public abstract class DiffRequestProcessor implements Disposable { } @Override + @CalledInAwt public void destroy() { Disposer.dispose(myViewer); } @@ -1097,6 +1125,7 @@ public abstract class DiffRequestProcessor implements Disposable { } @Override + @CalledInAwt public void init() { myContentPanel.setContent(myWrapperViewer.getComponent()); setTitle(myActiveRequest.getTitle()); @@ -1130,6 +1159,7 @@ public abstract class DiffRequestProcessor implements Disposable { } @Override + @CalledInAwt public void destroy() { Disposer.dispose(myViewer); Disposer.dispose(myWrapperViewer); diff --git a/platform/diff-impl/src/com/intellij/diff/impl/DiffWindowBase.java b/platform/diff-impl/src/com/intellij/diff/impl/DiffWindowBase.java index 8d9cff475107..309385201233 100644 --- a/platform/diff-impl/src/com/intellij/diff/impl/DiffWindowBase.java +++ b/platform/diff-impl/src/com/intellij/diff/impl/DiffWindowBase.java @@ -64,7 +64,6 @@ public abstract class DiffWindowBase { } }) .build(); - myProcessor.init(); myWrapper.setImage(ImageLoader.loadFromResource("/diff/Diff.png")); Disposer.register(myWrapper, myProcessor); diff --git a/platform/diff-impl/src/com/intellij/diff/tools/binary/BinaryDiffViewer.java b/platform/diff-impl/src/com/intellij/diff/tools/binary/BinaryDiffViewer.java index 9079242200e0..5b6fec5aaec2 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/binary/BinaryDiffViewer.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/binary/BinaryDiffViewer.java @@ -55,6 +55,7 @@ import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Pair; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.ui.UIUtil; +import org.jetbrains.annotations.CalledInAwt; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -118,20 +119,17 @@ public class BinaryDiffViewer extends ListenerDiffViewerBase { } @Override - protected void onInit() { - super.onInit(); - processContextHints(); - } - - @Override + @CalledInAwt public void onDispose() { - updateContextHints(); destroyEditorListeners(); destroyEditors(); super.onDispose(); } - private void processContextHints() { + @Override + @CalledInAwt + protected void processContextHints() { + super.processContextHints(); if (myEditor1 == null) { myCurrentSide = Side.RIGHT; } @@ -144,7 +142,10 @@ public class BinaryDiffViewer extends ListenerDiffViewerBase { } } - private void updateContextHints() { + @Override + @CalledInAwt + protected void updateContextHints() { + super.updateContextHints(); if (myEditor1 != null && myEditor2 != null) { myContext.putUserData(DiffUserDataKeys.PREFERRED_FOCUS_SIDE, myCurrentSide); } diff --git a/platform/diff-impl/src/com/intellij/diff/tools/fragmented/OnesideDiffViewer.java b/platform/diff-impl/src/com/intellij/diff/tools/fragmented/OnesideDiffViewer.java index 652904780f43..b40ca61e9af3 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/fragmented/OnesideDiffViewer.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/fragmented/OnesideDiffViewer.java @@ -146,30 +146,34 @@ public class OnesideDiffViewer extends TextDiffViewerBase { } @Override + @CalledInAwt protected void onInit() { super.onInit(); - processContextHints(); installTypingSupport(); myPanel.setLoadingContent(); // We need loading panel only for initial rediff() } @Override + @CalledInAwt protected void onDispose() { - updateContextHints(); - EditorFactory.getInstance().releaseEditor(myEditor); super.onDispose(); + EditorFactory.getInstance().releaseEditor(myEditor); } + @Override @CalledInAwt protected void processContextHints() { + super.processContextHints(); Side side = DiffUtil.getUserData(myRequest, myContext, DiffUserDataKeys.MASTER_SIDE); if (side != null && side.select(myActualContent1, myActualContent2) != null) myMasterSide = side; myInitialScrollHelper.processContext(myRequest); } + @Override @CalledInAwt protected void updateContextHints() { + super.updateContextHints(); myInitialScrollHelper.updateContext(myRequest); myFoldingModel.updateContext(myRequest, getFoldingModelSettings()); } diff --git a/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleDiffViewer.java b/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleDiffViewer.java index 4f007437da89..4072c5bf5200 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleDiffViewer.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleDiffViewer.java @@ -92,6 +92,7 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer { } @Override + @CalledInAwt protected void onInit() { super.onInit(); myContentPanel.setPainter(new MyDividerPainter()); @@ -99,10 +100,11 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer { } @Override - protected void onDisposeAwt() { + @CalledInAwt + protected void onDispose() { myModifierProvider.destroy(); destroyChangedBlocks(); - super.onDisposeAwt(); + super.onDispose(); } @NotNull @@ -159,16 +161,18 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer { } @Override + @CalledInAwt protected void processContextHints() { super.processContextHints(); myInitialScrollHelper.processContext(myRequest); } @Override + @CalledInAwt protected void updateContextHints() { + super.updateContextHints(); if (myFoldingModel != null) myFoldingModel.updateContext(myRequest, getFoldingModelSettings()); myInitialScrollHelper.updateContext(myRequest); - super.updateContextHints(); } // diff --git a/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleThreesideDiffViewer.java b/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleThreesideDiffViewer.java index 8632c27973c0..2e23d720f70a 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleThreesideDiffViewer.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleThreesideDiffViewer.java @@ -86,6 +86,7 @@ public class SimpleThreesideDiffViewer extends ThreesideTextDiffViewer { } @Override + @CalledInAwt protected void onInit() { super.onInit(); myContentPanel.setPainter(new MyDividerPainter(Side.LEFT), Side.LEFT); @@ -94,9 +95,10 @@ public class SimpleThreesideDiffViewer extends ThreesideTextDiffViewer { } @Override - protected void onDisposeAwt() { + @CalledInAwt + protected void onDispose() { destroyChangedBlocks(); - super.onDisposeAwt(); + super.onDispose(); } @NotNull @@ -136,12 +138,14 @@ public class SimpleThreesideDiffViewer extends ThreesideTextDiffViewer { } @Override + @CalledInAwt protected void processContextHints() { super.processContextHints(); myInitialScrollHelper.processContext(myRequest); } @Override + @CalledInAwt protected void updateContextHints() { super.updateContextHints(); myFoldingModel.updateContext(myRequest, getFoldingModelSettings()); @@ -259,6 +263,8 @@ public class SimpleThreesideDiffViewer extends ThreesideTextDiffViewer { } myInvalidDiffChanges.clear(); + myFoldingModel.destroy(); + myContentPanel.repaintDividers(); myStatusPanel.update(); } diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/base/DiffViewerBase.java b/platform/diff-impl/src/com/intellij/diff/tools/util/base/DiffViewerBase.java index 5f41070aa91f..e519314f7079 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/util/base/DiffViewerBase.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/util/base/DiffViewerBase.java @@ -31,13 +31,13 @@ import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.util.ProgressWindow; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Disposer; +import com.intellij.util.Alarm; import com.intellij.util.Function; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.*; import javax.swing.*; import java.util.List; -import java.util.concurrent.atomic.AtomicBoolean; public abstract class DiffViewerBase implements DiffViewer, DataProvider { protected static final Logger LOG = Logger.getInstance(DiffViewerBase.class); @@ -47,7 +47,8 @@ public abstract class DiffViewerBase implements DiffViewer, DataProvider { @NotNull protected final ContentDiffRequest myRequest; @NotNull private final DiffTaskQueue myTaskExecutor = new DiffTaskQueue(); - @NotNull private final AtomicBoolean myDisposed = new AtomicBoolean(false); + @NotNull private final Alarm myTaskAlarm = new Alarm(); + private volatile boolean myDisposed; public DiffViewerBase(@NotNull DiffContext context, @NotNull ContentDiffRequest request) { myProject = context.getProject(); @@ -57,6 +58,7 @@ public abstract class DiffViewerBase implements DiffViewer, DataProvider { @NotNull public final FrameDiffTool.ToolbarComponents init() { + processContextHints(); onInit(); FrameDiffTool.ToolbarComponents components = new FrameDiffTool.ToolbarComponents(); @@ -69,24 +71,41 @@ public abstract class DiffViewerBase implements DiffViewer, DataProvider { } @Override + @CalledInAwt public final void dispose() { - if (!myDisposed.compareAndSet(false, true)) return; + if (myDisposed) return; - onDispose(); - - UIUtil.invokeLaterIfNeeded(new Runnable() { + Runnable doDispose = new Runnable() { @Override public void run() { - onDisposeAwt(); + if (myDisposed) return; + myDisposed = true; + + abortRediff(); + updateContextHints(); + + onDispose(); } - }); + }; + + if (!ApplicationManager.getApplication().isDispatchThread()) LOG.warn(new Throwable("dispose() not from EDT")); + UIUtil.invokeLaterIfNeeded(doDispose); + } + + @CalledInAwt + protected void processContextHints() { + } + + @CalledInAwt + protected void updateContextHints() { } @CalledInAwt public final void scheduleRediff() { - if (myDisposed.get()) return; + if (isDisposed()) return; - myTaskExecutor.abortAndSchedule(new Runnable() { + abortRediff(); + myTaskAlarm.addRequest(new Runnable() { @Override public void run() { rediff(); @@ -97,6 +116,7 @@ public abstract class DiffViewerBase implements DiffViewer, DataProvider { @CalledInAwt public final void abortRediff() { myTaskExecutor.abort(); + myTaskAlarm.cancelAllRequests(); } @CalledInAwt @@ -106,7 +126,7 @@ public abstract class DiffViewerBase implements DiffViewer, DataProvider { @CalledInAwt public final void rediff(boolean trySync) { - if (myDisposed.get()) return; + if (isDisposed()) return; onBeforeRediff(); @@ -148,7 +168,7 @@ public abstract class DiffViewerBase implements DiffViewer, DataProvider { } public boolean isDisposed() { - return myDisposed.get(); + return myDisposed; } // @@ -191,12 +211,9 @@ public abstract class DiffViewerBase implements DiffViewer, DataProvider { @NotNull protected abstract Runnable performRediff(@NotNull ProgressIndicator indicator); - protected void onDispose() { - Disposer.dispose(myTaskExecutor); - } - @CalledInAwt - protected void onDisposeAwt() { + protected void onDispose() { + Disposer.dispose(myTaskAlarm); } @Nullable diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/threeside/ThreesideTextDiffViewer.java b/platform/diff-impl/src/com/intellij/diff/tools/util/threeside/ThreesideTextDiffViewer.java index a1f81110d4d1..86eb56b42e7c 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/util/threeside/ThreesideTextDiffViewer.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/util/threeside/ThreesideTextDiffViewer.java @@ -111,29 +111,24 @@ public abstract class ThreesideTextDiffViewer extends TextDiffViewerBase { } @Override - protected void onInit() { - super.onInit(); - processContextHints(); - } - - @Override + @CalledInAwt protected void onDispose() { - updateContextHints(); super.onDispose(); + destroyEditors(); } @Override - protected void onDisposeAwt() { - destroyEditors(); - super.onDisposeAwt(); - } - + @CalledInAwt protected void processContextHints() { + super.processContextHints(); ThreeSide side = myContext.getUserData(DiffUserDataKeys.PREFERRED_FOCUS_THREESIDE); if (side != null) myCurrentSide = side; } + @Override + @CalledInAwt protected void updateContextHints() { + super.updateContextHints(); myContext.putUserData(DiffUserDataKeys.PREFERRED_FOCUS_THREESIDE, myCurrentSide); } diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/twoside/TwosideTextDiffViewer.java b/platform/diff-impl/src/com/intellij/diff/tools/util/twoside/TwosideTextDiffViewer.java index 0a767ff45e5e..c7109814f010 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/util/twoside/TwosideTextDiffViewer.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/util/twoside/TwosideTextDiffViewer.java @@ -114,24 +114,16 @@ public abstract class TwosideTextDiffViewer extends TextDiffViewerBase { } @Override - protected void onInit() { - super.onInit(); - processContextHints(); - } - - @Override + @CalledInAwt protected void onDispose() { - updateContextHints(); super.onDispose(); + destroyEditors(); } @Override - protected void onDisposeAwt() { - destroyEditors(); - super.onDisposeAwt(); - } - + @CalledInAwt protected void processContextHints() { + super.processContextHints(); if (myEditor1 == null) { myCurrentSide = Side.RIGHT; } @@ -144,7 +136,10 @@ public abstract class TwosideTextDiffViewer extends TextDiffViewerBase { } } + @Override + @CalledInAwt protected void updateContextHints() { + super.updateContextHints(); if (myEditor1 != null && myEditor2 != null) { myContext.putUserData(DiffUserDataKeys.PREFERRED_FOCUS_SIDE, myCurrentSide); } diff --git a/platform/diff-impl/src/com/intellij/diff/util/DiffTaskQueue.java b/platform/diff-impl/src/com/intellij/diff/util/DiffTaskQueue.java index 40b6b6733967..4c4283136d29 100644 --- a/platform/diff-impl/src/com/intellij/diff/util/DiffTaskQueue.java +++ b/platform/diff-impl/src/com/intellij/diff/util/DiffTaskQueue.java @@ -15,64 +15,19 @@ */ package com.intellij.diff.util; -import com.intellij.openapi.Disposable; import com.intellij.openapi.progress.ProgressIndicator; -import com.intellij.openapi.util.Disposer; -import com.intellij.util.Alarm; import com.intellij.util.Function; -import org.jetbrains.annotations.*; +import org.jetbrains.annotations.CalledInAwt; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; -import java.util.concurrent.atomic.AtomicReference; - -public class DiffTaskQueue implements Disposable { - @NotNull private final Object LOCK = new Object(); - @NotNull private final Alarm myAlarm = new Alarm(); - - private boolean myDisposed; - @NotNull private final AtomicReference myProgressIndicator = new AtomicReference(); - - @CalledInAny - public void dispose() { - // if EDT is awaiting for background progress in executeAndTryWait - it holds LOCK. - // so we want to try cancel indicator before getting the lock. - cancelProgress(); - synchronized (LOCK) { - if (myDisposed) return; - myDisposed = true; - cancelProgress(); - Disposer.dispose(myAlarm); - } - } +public class DiffTaskQueue { + @Nullable private ProgressIndicator myProgressIndicator; @CalledInAwt public void abort() { - synchronized (LOCK) { - cancelProgress(); - myAlarm.cancelAllRequests(); - } - } - - private void cancelProgress() { - ProgressIndicator indicator = myProgressIndicator.getAndSet(null); - if (indicator != null) indicator.cancel(); - } - - @CalledInAwt - public void abortAndSchedule(@NotNull final Runnable task, int millis) { - synchronized (LOCK) { - if (myDisposed) return; - abort(); - - myAlarm.addRequest(new Runnable() { - @Override - public void run() { - synchronized (LOCK) { - if (myDisposed) return; - } - task.run(); - } - }, millis); - } + if (myProgressIndicator != null) myProgressIndicator.cancel(); + myProgressIndicator = null; } @CalledInAwt @@ -87,11 +42,7 @@ public class DiffTaskQueue implements Disposable { @Nullable final Runnable onSlowAction, final int waitMillis, final boolean forceEDT) { - synchronized (LOCK) { - if (myDisposed) return; - abort(); - - myProgressIndicator.set(BackgroundTaskUtil.executeAndTryWait(backgroundTask, onSlowAction, waitMillis, forceEDT)); - } + abort(); + myProgressIndicator = BackgroundTaskUtil.executeAndTryWait(backgroundTask, onSlowAction, waitMillis, forceEDT); } } diff --git a/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java b/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java index 6f13af4fed19..2bd2f27fd53a 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java +++ b/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java @@ -16,6 +16,7 @@ package com.intellij.ide.util; import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; +import com.intellij.icons.AllIcons; import com.intellij.ide.DataManager; import com.intellij.ide.DefaultTreeExpander; import com.intellij.ide.IdeBundle; @@ -27,6 +28,8 @@ import com.intellij.ide.structureView.StructureViewTreeElement; import com.intellij.ide.structureView.impl.StructureViewComposite; import com.intellij.ide.structureView.impl.common.PsiTreeElementBase; import com.intellij.ide.structureView.newStructureView.StructureViewComponent; +import com.intellij.ide.structureView.newStructureView.TreeActionWrapper; +import com.intellij.ide.structureView.newStructureView.TreeActionsOwner; import com.intellij.ide.structureView.newStructureView.TreeModelWrapper; import com.intellij.ide.util.treeView.AbstractTreeNode; import com.intellij.ide.util.treeView.NodeRenderer; @@ -46,8 +49,7 @@ import com.intellij.openapi.fileEditor.ex.IdeDocumentHistory; import com.intellij.openapi.keymap.KeymapManager; import com.intellij.openapi.keymap.KeymapUtil; import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.popup.JBPopup; -import com.intellij.openapi.ui.popup.JBPopupFactory; +import com.intellij.openapi.ui.popup.*; import com.intellij.openapi.util.*; import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.text.StringUtil; @@ -77,8 +79,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; import javax.swing.tree.DefaultMutableTreeNode; @@ -91,7 +91,7 @@ import java.util.List; /** * @author Konstantin Bulenkov */ -public class FileStructurePopup implements Disposable { +public class FileStructurePopup implements Disposable, TreeActionsOwner { private static final Logger LOG = Logger.getInstance("#com.intellij.ide.util.FileStructurePopup"); private final Project myProject; private final StructureViewModel myTreeModel; @@ -101,7 +101,6 @@ public class FileStructurePopup implements Disposable { private JBPopup myPopup; @NonNls private static final String narrowDownPropertyKey = "FileStructurePopup.narrowDown"; - private boolean myShouldNarrowDown = true; private final FileStructureTree myTree; private final FilteringTreeBuilder myAbstractTreeBuilder; private String myTitle; @@ -119,6 +118,7 @@ public class FileStructurePopup implements Disposable { private final TreeExpander myTreeExpander; @NotNull private final FileEditor myFileEditor; private final StructureView myStructureViewDelegate; + private boolean myCanClose = true; public FileStructurePopup(@NotNull Project project, @@ -259,7 +259,7 @@ public class FileStructurePopup implements Disposable { @Override public Boolean compute() { DimensionService.getInstance().setLocation(getDimensionServiceKey(), myPopup.getLocationOnScreen(), myProject); - return true; + return myCanClose; } }) .createPopup(); @@ -498,6 +498,10 @@ public class FileStructurePopup implements Disposable { } + private static boolean isShouldNarrowDown() { + return PropertiesComponent.getInstance().getBoolean(narrowDownPropertyKey, true); + } + @NonNls protected static String getDimensionServiceKey() { return "StructurePopup"; @@ -584,12 +588,17 @@ public class FileStructurePopup implements Disposable { for (FileStructureNodeProvider provider : fileStructureNodeProviders) { addCheckbox(comboPanel, provider); } + final JPanel topPanel = new JPanel(new BorderLayout()); + topPanel.add(comboPanel); + + topPanel.add(createSettingsButton(), BorderLayout.EAST); + myPreferredWidth = Math.max(comboPanel.getPreferredSize().width, JBUI.scale(350)); - panel.add(comboPanel, BorderLayout.NORTH); + panel.add(topPanel, BorderLayout.NORTH); JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myAbstractTreeBuilder.getTree()); scrollPane.setBorder(IdeBorderFactory.createBorder(SideBorder.TOP | SideBorder.BOTTOM)); panel.add(scrollPane, BorderLayout.CENTER); - panel.add(createSouthPanel(), BorderLayout.SOUTH); + //panel.add(createSouthPanel(), BorderLayout.SOUTH); DataManager.registerDataProvider(panel, new DataProvider() { @Override public Object getData(@NonNls String dataId) { @@ -634,6 +643,84 @@ public class FileStructurePopup implements Disposable { return panel; } + @NotNull + protected JComponent createSettingsButton() { + final JLabel label = new JLabel(AllIcons.General.SecondaryGroup); + new ClickListener() { + @Override + public boolean onClick(@NotNull MouseEvent event, int clickCount) { + DefaultActionGroup group = new DefaultActionGroup(); + //addSorters(group); + //addGroupers(group); + //addFilters(group); + + group.add(new ToggleAction(IdeBundle.message("checkbox.narrow.down.on.typing")) { + @Override + public boolean isSelected(AnActionEvent e) { + return isShouldNarrowDown(); + } + + @Override + public void setSelected(AnActionEvent e, boolean state) { + PropertiesComponent.getInstance().setValue(narrowDownPropertyKey, Boolean.toString(state)); + if (mySpeedSearch.isPopupActive() && !StringUtil.isEmpty(mySpeedSearch.getEnteredPrefix())) { + myAbstractTreeBuilder.queueUpdate(); + } + } + }); + + final DataManager dataManager = DataManager.getInstance(); + assert dataManager != null; + final ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(null, group, + dataManager.getDataContext(label), + JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, + false); + popup.addListener( + new JBPopupListener() { + @Override + public void beforeShown(LightweightWindowEvent event) { + + } + + @Override + public void onClosed(LightweightWindowEvent event) { + myCanClose = true; + } + }); + myCanClose = false; + popup.showUnderneathOf(label); + return true; + } + }.installOn(label); + return label; + } + + protected void addFilters(DefaultActionGroup group) { + Filter[] filters = myTreeModel.getFilters(); + for (Filter filter : filters) { + group.add(new TreeActionWrapper(filter, this)); + } + } + + protected void addGroupers(DefaultActionGroup group) { + Grouper[] groupers = myTreeModel.getGroupers(); + for (Grouper grouper : groupers) { + group.add(new TreeActionWrapper(grouper, this)); + } + } + + protected void addSorters(DefaultActionGroup group) { + Sorter[] sorters = myTreeModel.getSorters(); + for (final Sorter sorter : sorters) { + if (sorter.isVisible()) { + group.add(new TreeActionWrapper(sorter, this)); + } + } + if (sorters.length > 0) { + group.addSeparator(); + } + } + @Nullable private AbstractTreeNode getSelectedNode() { final TreePath path = myTree.getSelectionPath(); @@ -687,28 +774,6 @@ public class FileStructurePopup implements Disposable { return succeeded.get(); } - private JComponent createSouthPanel() { - final JCheckBox checkBox = new JCheckBox(IdeBundle.message("checkbox.narrow.down.on.typing")); - checkBox.setSelected(PropertiesComponent.getInstance().getBoolean(narrowDownPropertyKey, true)); - checkBox.addChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - myShouldNarrowDown = checkBox.isSelected(); - PropertiesComponent.getInstance().setValue(narrowDownPropertyKey, Boolean.toString(myShouldNarrowDown)); - - if (mySpeedSearch.isPopupActive() && !StringUtil.isEmpty(mySpeedSearch.getEnteredPrefix())) { - myAbstractTreeBuilder.queueUpdate(); - } - } - }); - - checkBox.setFocusable(false); - UIUtil.applyStyle(UIUtil.ComponentStyle.MINI, checkBox); - final JPanel panel = new JPanel(new BorderLayout()); - panel.add(checkBox, BorderLayout.WEST); - return panel; - } - private void addCheckbox(final JPanel panel, final TreeAction action) { String text = action instanceof FileStructureFilter ? ((FileStructureFilter)action).getCheckBoxText() : action instanceof FileStructureNodeProvider ? ((FileStructureNodeProvider)action).getCheckBoxText() : null; @@ -881,6 +946,16 @@ public class FileStructurePopup implements Disposable { return null; } + @Override + public void setActionActive(String name, boolean state) { + + } + + @Override + public boolean isActionActive(String name) { + return false; + } + private class FileStructurePopupFilter implements ElementFilter { private String myLastFilter = null; private final Set myVisibleParents = new HashSet(); @@ -888,7 +963,7 @@ public class FileStructurePopup implements Disposable { @Override public boolean shouldBeShowing(Object value) { - if (!myShouldNarrowDown) return true; + if (!isShouldNarrowDown()) return true; String filter = getSearchPrefix(); if (!StringUtil.equals(myLastFilter, filter)) { diff --git a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexProjectHandler.java b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexProjectHandler.java index 544124e29700..1ce63a3bad56 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexProjectHandler.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexProjectHandler.java @@ -136,7 +136,11 @@ public class FileBasedIndexProjectHandler extends AbstractProjectComponent imple @Nullable public static DumbModeTask createChangedFilesIndexingTask(final Project project) { - final FileBasedIndexImpl index = (FileBasedIndexImpl)FileBasedIndex.getInstance(); + final FileBasedIndex i = FileBasedIndex.getInstance(); + if (!(i instanceof FileBasedIndexImpl)) { + return null; + } + final FileBasedIndexImpl index = (FileBasedIndexImpl)i; if (index.getChangedFileCount() + index.getNumberOfPendingInvalidations() < 20) { return null; diff --git a/platform/platform-api/src/com/intellij/openapi/keymap/KeyboardSettingsExternalizable.java b/platform/platform-api/src/com/intellij/openapi/keymap/KeyboardSettingsExternalizable.java index 473cf3c53c16..e96abb6fd18f 100644 --- a/platform/platform-api/src/com/intellij/openapi/keymap/KeyboardSettingsExternalizable.java +++ b/platform/platform-api/src/com/intellij/openapi/keymap/KeyboardSettingsExternalizable.java @@ -22,6 +22,8 @@ import com.sun.istack.internal.NotNull; import org.jetbrains.annotations.Nullable; import java.awt.*; +import java.awt.im.InputContext; +import java.util.Locale; /** * @author Denis Fokin @@ -33,7 +35,7 @@ import java.awt.*; ) public class KeyboardSettingsExternalizable implements PersistentStateComponent { - private static final String [] supportedNonEnglishLanguages = {"de", "fr", "it"}; + private static final String [] supportedNonEnglishLanguages = {"de", "fr", "it", "uk"}; public static boolean isSupportedKeyboardLayout(@NotNull Component component) { if (SystemInfo.isMac) return false; @@ -46,12 +48,22 @@ public class KeyboardSettingsExternalizable implements PersistentStateComponent< return false; } + @Nullable public static String getLanguageForComponent(@NotNull Component component) { - return component.getInputContext().getLocale().getLanguage(); + final Locale locale = getLocaleForComponent(component); + return locale == null ? null : locale.getLanguage(); } + @Nullable + protected static Locale getLocaleForComponent(@NotNull Component component) { + final InputContext context = component.getInputContext(); + return context == null ? null : context.getLocale(); + } + + @Nullable public static String getDisplayLanguageNameForComponent(@NotNull Component component) { - return component.getInputContext().getLocale().getDisplayLanguage(); + final Locale locale = getLocaleForComponent(component); + return locale == null ? null : locale.getDisplayLanguage(); } public static final class OptionSet { @@ -80,6 +92,10 @@ public class KeyboardSettingsExternalizable implements PersistentStateComponent< myOptions = state; } + public boolean isUkrainianKeyboard (Component c) { + return c!=null && "uk".equals(c.getInputContext().getLocale().getLanguage()); + } + public boolean isNonEnglishKeyboardSupportEnabled () { return myOptions.USE_NON_ENGLISH_KEYBOARD; } diff --git a/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java b/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java index f6a0b2d9e7fb..ad541c2675dc 100644 --- a/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java +++ b/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java @@ -416,20 +416,8 @@ public class IdeEventQueue extends EventQueue { if (e instanceof KeyEvent) { KeyEvent ke = (KeyEvent)e; - // Alt,keyChar=Undefined keyChar,modifiers=Ctrl+Alt,extModifiers=Ctrl+Alt+Button5,keyLocation=KEY_LOCATION_RIGHT - - //if (ke.getKeyCode() == KeyEvent.VK_ALT && ke.getID() == KeyEvent.KEY_PRESSED) { - // - // if (ke.getKeyLocation() == KeyEvent.KEY_LOCATION_RIGHT) { - // if ((ke.getModifiersEx() & (InputEvent.ALT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) != (InputEvent.ALT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) - // { - // altGrIsPressed = true; - // } - // } - // - //} else { - // altGrIsPressed = false; - //} + // Try to get it from editor + Component sourceComponent = WindowManagerEx.getInstanceEx().getMostRecentFocusedWindow(); if (ke.getID() == KeyEvent.KEY_PRESSED) { switch (ke.getKeyCode()) { @@ -459,8 +447,15 @@ public class IdeEventQueue extends EventQueue { } } - - + if (!leftAltIsPressed && KeyboardSettingsExternalizable.getInstance().isUkrainianKeyboard(sourceComponent) ) { + if ('ґ' == ke.getKeyChar() || ke.getKeyCode() == KeyEvent.VK_U) { + ke = new KeyEvent(ke.getComponent(), ke.getID(), ke.getWhen(), 0, + KeyEvent.VK_UNDEFINED, 'ґ', ke.getKeyLocation()); + ke.setKeyCode(KeyEvent.VK_U); + ke.setKeyChar('ґ'); + return ke; + } + } Integer keyCodeFromChar = CharToVKeyMap.get(ke.getKeyChar()); if (keyCodeFromChar != null) { @@ -469,15 +464,12 @@ public class IdeEventQueue extends EventQueue { ke.setKeyCode(keyCodeFromChar); } - // Try to get it from editor - Component sourceComponent = WindowManagerEx.getInstanceEx().getMostRecentFocusedWindow(); - //for (int i = 0; sourceComponent == null && i < WindowManagerEx.getInstanceEx().getAllProjectFrames().length; i++) { // sourceComponent = WindowManagerEx.getInstanceEx().getAllProjectFrames()[i].getComponent(); //} if (sourceComponent != null) { - if (sourceComponent.getInputContext().getLocale().getLanguage().equals("de")) { + if (KeyboardSettingsExternalizable.isSupportedKeyboardLayout(sourceComponent)) { if ((ke.getModifiersEx() & (InputEvent.ALT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) != 0 /*&& ke.getKeyLocation() == KeyEvent.KEY_LOCATION_RIGHT*/) { // On German keyboard layout on Windows we are getting on key press // ctrl + alt instead of AltGr diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/RefreshSessionImpl.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/RefreshSessionImpl.java index e760233798d1..e2143dd43eea 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/RefreshSessionImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/RefreshSessionImpl.java @@ -110,9 +110,16 @@ public class RefreshSessionImpl extends RefreshSession { boolean haveEventsToFire = myFinishRunnable != null || !myEvents.isEmpty(); if (!workQueue.isEmpty()) { - LocalFileSystemImpl fs = (LocalFileSystemImpl)LocalFileSystem.getInstance(); - fs.markSuspiciousFilesDirty(workQueue); - FileWatcher watcher = fs.getFileWatcher(); + final LocalFileSystem fileSystem = LocalFileSystem.getInstance(); + final FileWatcher watcher; + if (fileSystem instanceof LocalFileSystemImpl) { + LocalFileSystemImpl fs = (LocalFileSystemImpl)fileSystem; + fs.markSuspiciousFilesDirty(workQueue); + watcher = fs.getFileWatcher(); + } + else { + watcher = null; + } long t = 0; if (LOG.isDebugEnabled()) { @@ -124,7 +131,7 @@ public class RefreshSessionImpl extends RefreshSession { if (myCancelled) break; NewVirtualFile nvf = (NewVirtualFile)file; - if (!myIsRecursive && (!myIsAsync || !watcher.isWatched(nvf))) { + if (!myIsRecursive && (!myIsAsync || (watcher != null && !watcher.isWatched(nvf)))) { // we're unable to definitely refresh synchronously by means of file watcher. nvf.markDirty(); } diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/EditProjectGroupAction.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/EditProjectGroupAction.java index d62a8a28b89a..f2eea817d9ba 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/EditProjectGroupAction.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/EditProjectGroupAction.java @@ -18,6 +18,7 @@ package com.intellij.openapi.wm.impl.welcomeScreen; import com.intellij.ide.ProjectGroup; import com.intellij.ide.ProjectGroupActionGroup; import com.intellij.ide.RecentProjectsManager; +import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.ui.InputValidatorEx; import com.intellij.openapi.ui.Messages; @@ -25,6 +26,7 @@ import com.intellij.ui.ListScrollingUtil; import org.jetbrains.annotations.Nullable; import javax.swing.*; +import java.util.List; /** * @author Konstantin Bulenkov @@ -82,4 +84,11 @@ public class EditProjectGroupAction extends RecentProjectsWelcomeScreenActionBas } } } + + @Override + public void update(AnActionEvent e) { + final List selected = getSelectedElements(e); + boolean enabled = !selected.isEmpty() && selected.get(0) instanceof ProjectGroupActionGroup; + e.getPresentation().setEnabledAndVisible(enabled); + } } diff --git a/platform/platform-resources-en/src/messages/ActionsBundle.properties b/platform/platform-resources-en/src/messages/ActionsBundle.properties index 8afc312c8303..f453a681c7d1 100644 --- a/platform/platform-resources-en/src/messages/ActionsBundle.properties +++ b/platform/platform-resources-en/src/messages/ActionsBundle.properties @@ -982,11 +982,11 @@ action.XDebugger.NewWatch.text=New Watch... action.XDebugger.EditWatch.text=Edit... action.XDebugger.AutoTooltip.text=Value auto tooltip action.XDebugger.AutoTooltip.description=Toggles if value tooltip is shown automatically on mouse over -action.XDebugger.Inline.text=Show values in editor +action.XDebugger.Inline.text=Show Values Inline action.XDebugger.Inline.description=Show available debugger session values inside editor action.XDebugger.AutoTooltipOnSelection.text=Show value on selection change action.XDebugger.AutoTooltipOnSelection.description=Toggles if value tooltip is shown automatically on selection change in editor -action.XDebugger.ToggleSortValues.text=Sort values alphabetically +action.XDebugger.ToggleSortValues.text=Sort Values Alphabetically action.XDebugger.ToggleSortValues.description=Sort values alphabetically in debugger views group.XDebugger.settings.text=Settings @@ -1020,7 +1020,7 @@ action.Debugger.MarkObject.unmark.text=Unmark Object action.Debugger.MarkObject.description=Mark/unmark the object so that it can be visually distinguished in in debugger views action.Debugger.AddToWatch.text=Add to Watches action.Debugger.EvaluateInConsole.text=Evaluate in Console -action.Debugger.UnmuteOnStop.text=Unmute breakpoints on session finish +action.XDebugger.UnmuteOnStop.text=Unmute Breakpoints on Session Finish action.Debugger.AutoRenderer.text=Auto group.EditorPopupMenu.text=Editor Popup Menu group.EditorPopupMenu.description=Editor Popup Menu diff --git a/platform/platform-resources-en/src/messages/XDebuggerBundle.properties b/platform/platform-resources-en/src/messages/XDebuggerBundle.properties index 7a7d8c67f0d5..cfeb8209caa7 100644 --- a/platform/platform-resources-en/src/messages/XDebuggerBundle.properties +++ b/platform/platform-resources-en/src/messages/XDebuggerBundle.properties @@ -128,3 +128,6 @@ setting.focus.app.on.breakpoint.label=Focus application on breakpoint settings.show.window.label=Show &debug window on breakpoint showReferring.dialog.title=Referring Objects For {0} +settings.show.values.inline=Show values inline +settings.show.value.tooltip=Show value tooltip. +settings.show.tooltip.on.selection=Show value tooltip on code selection diff --git a/platform/platform-resources/src/brokenPlugins.txt b/platform/platform-resources/src/brokenPlugins.txt index 9106b5d0a8e3..d4b2797a6d9c 100644 --- a/platform/platform-resources/src/brokenPlugins.txt +++ b/platform/platform-resources/src/brokenPlugins.txt @@ -23,4 +23,5 @@ com.jetbrains.chronon 134.1221 134.1414 134.1618 135.1291 135.476 135.666 ArgoUML.Integration 0.1.1 0.1.2 IdeaServerPlugin 1.0 1.0.2 1.0.3 1.0.4 1.0.7 1.0.8 copy.on.steroids 3.1 -"AWS Elastic Beanstalk" 0.7.7 0.7.6 0.7.5 0.7.4 0.7.3 0.7.2 0.7.1 0.7.0 0.6.1 0.6.0 0.5.5 0.5.4 0.5.3 0.5.2 0.5.1 0.5.0 \ No newline at end of file +"AWS Elastic Beanstalk" 0.7.7 0.7.6 0.7.5 0.7.4 0.7.3 0.7.2 0.7.1 0.7.0 0.6.1 0.6.0 0.5.5 0.5.4 0.5.3 0.5.2 0.5.1 0.5.0 +com.jetbrains.typoscript 0.1.1 0.1.0 \ No newline at end of file diff --git a/platform/platform-resources/src/idea/LangActions.xml b/platform/platform-resources/src/idea/LangActions.xml index 3f8edd619620..36671e305f56 100644 --- a/platform/platform-resources/src/idea/LangActions.xml +++ b/platform/platform-resources/src/idea/LangActions.xml @@ -794,10 +794,13 @@ - - - + + + + + + diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java index 9796cdde9a35..374f672f279e 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java @@ -1040,9 +1040,9 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig public LookupElement[] complete(@NotNull final CompletionType type, final int invocationCount) { assertInitialized(); myEmptyLookup = false; - UIUtil.invokeAndWaitIfNeeded(new Runnable() { + return UIUtil.invokeAndWaitIfNeeded(new Computable() { @Override - public void run() { + public LookupElement[] compute() { CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() { @Override public void run() { @@ -1059,10 +1059,9 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); // to compare with file text } }, null, null); + return getLookupElements(); } }); - - return getLookupElements(); } @Nullable diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/CacheChangeProcessor.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/CacheChangeProcessor.java index fd0b781bd06a..20ef03570cae 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/CacheChangeProcessor.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/CacheChangeProcessor.java @@ -31,7 +31,6 @@ import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.util.ProgressWindow; import com.intellij.openapi.project.DumbAwareAction; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Pair; import com.intellij.openapi.vcs.changes.actions.diff.ChangeDiffRequestProducer; import com.intellij.util.Function; @@ -161,7 +160,7 @@ public abstract class CacheChangeProcessor extends DiffRequestProcessor { @CalledInAwt protected void onDispose() { super.onDispose(); - Disposer.dispose(myQueue); + myQueue.abort(); myRequestCache.clear(); } 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 a19ebeaf68e0..0eab66982017 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 @@ -121,7 +121,6 @@ public class ChangesViewManager implements ChangesViewI, JDOMExternalizable, Pro Disposer.register(project, myView); myRepaintAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD, project); myDiffDetails = new MyChangeProcessor(myProject); - myDiffDetails.init(); myTsl = new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java index 18d6150b335c..3125ab0d34e4 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java @@ -321,7 +321,6 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj }); } }); - myDiffDetails.init(); myBrowserExtender.addToolbarActions(this); diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/settings/DataViewsConfigurableUi.form b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/settings/DataViewsConfigurableUi.form index a6e3f94f3bec..005e5aed54e3 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/settings/DataViewsConfigurableUi.form +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/settings/DataViewsConfigurableUi.form @@ -13,25 +13,9 @@ - - - - - - - - - - - - - - - - - + @@ -39,12 +23,62 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/settings/DataViewsConfigurableUi.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/settings/DataViewsConfigurableUi.java index 76645db3a3d3..1b220e800a00 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/settings/DataViewsConfigurableUi.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/settings/DataViewsConfigurableUi.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. @@ -15,17 +15,28 @@ */ package com.intellij.xdebugger.impl.settings; +import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.text.StringUtilRt; +import com.intellij.ui.IdeBorderFactory; +import com.intellij.ui.border.IdeaTitledBorder; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import javax.swing.*; public class DataViewsConfigurableUi { + public static final String IDE_DEBUGGER_INLINE_KEY = "ide.debugger.inline"; + public static final String DEBUGGER_VALUE_TOOLTIP_AUTO_SHOW_KEY = "debugger.valueTooltipAutoShow"; + public static final String DEBUGGER_VALUE_TOOLTIP_AUTO_SHOW_ON_SELECTION_KEY = "debugger.valueTooltipAutoShowOnSelection"; + private JCheckBox enableAutoExpressionsCheckBox; private JFormattedTextField valueTooltipDelayTextField; private JPanel panel; private JCheckBox sortAlphabeticallyCheckBox; + private JPanel myEditorSettingsPanel; + private JCheckBox myShowValuesInlineCheckBox; + private JCheckBox myShowValueTooltipCheckBox; + private JCheckBox myShowValueTooltipOnCheckBox; public DataViewsConfigurableUi() { UIUtil.configureNumericFormattedTextField(valueTooltipDelayTextField); @@ -33,7 +44,8 @@ public class DataViewsConfigurableUi { private int getValueTooltipDelay() { Object value = valueTooltipDelayTextField.getValue(); - return value instanceof Number ? ((Number)value).intValue() : StringUtilRt.parseInt((String)value, XDebuggerDataViewSettings.DEFAULT_VALUE_TOOLTIP_DELAY); + return value instanceof Number ? ((Number)value).intValue() : + StringUtilRt.parseInt((String)value, XDebuggerDataViewSettings.DEFAULT_VALUE_TOOLTIP_DELAY); } @NotNull @@ -44,18 +56,34 @@ public class DataViewsConfigurableUi { public boolean isModified(@NotNull XDebuggerDataViewSettings settings) { return getValueTooltipDelay() != settings.getValueLookupDelay() || sortAlphabeticallyCheckBox.isSelected() != settings.isSortValues() || - enableAutoExpressionsCheckBox.isSelected() != settings.isAutoExpressions(); + enableAutoExpressionsCheckBox.isSelected() != settings.isAutoExpressions() || + myShowValuesInlineCheckBox.isSelected() != Registry.is(IDE_DEBUGGER_INLINE_KEY) || + myShowValuesInlineCheckBox.isSelected() != Registry.is(DEBUGGER_VALUE_TOOLTIP_AUTO_SHOW_KEY) || + myShowValueTooltipOnCheckBox.isSelected() != Registry.is(DEBUGGER_VALUE_TOOLTIP_AUTO_SHOW_ON_SELECTION_KEY); } public void reset(@NotNull XDebuggerDataViewSettings settings) { valueTooltipDelayTextField.setValue(settings.getValueLookupDelay()); sortAlphabeticallyCheckBox.setSelected(settings.isSortValues()); enableAutoExpressionsCheckBox.setSelected(settings.isAutoExpressions()); + myShowValuesInlineCheckBox.setSelected(Registry.is(IDE_DEBUGGER_INLINE_KEY)); + myShowValueTooltipCheckBox.setSelected(Registry.is(DEBUGGER_VALUE_TOOLTIP_AUTO_SHOW_KEY)); + myShowValueTooltipOnCheckBox.setSelected(Registry.is(DEBUGGER_VALUE_TOOLTIP_AUTO_SHOW_ON_SELECTION_KEY)); } public void apply(@NotNull XDebuggerDataViewSettings settings) { settings.setValueLookupDelay(getValueTooltipDelay()); settings.setSortValues(sortAlphabeticallyCheckBox.isSelected()); settings.setAutoExpressions(enableAutoExpressionsCheckBox.isSelected()); + Registry.get(IDE_DEBUGGER_INLINE_KEY).setValue(myShowValuesInlineCheckBox.isSelected()); + Registry.get(DEBUGGER_VALUE_TOOLTIP_AUTO_SHOW_KEY).setValue(myShowValueTooltipCheckBox.isSelected()); + Registry.get(DEBUGGER_VALUE_TOOLTIP_AUTO_SHOW_ON_SELECTION_KEY).setValue(myShowValueTooltipOnCheckBox.isSelected()); + } + + private void createUIComponents() { + myEditorSettingsPanel = new JPanel(); + IdeaTitledBorder titledBorder = IdeBorderFactory.createTitledBorder("Editor", false); + myEditorSettingsPanel.setBorder(titledBorder); + titledBorder.acceptMinimumSize(myEditorSettingsPanel); } } \ No newline at end of file diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionTab.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionTab.java index 349b64742446..b35b150c82f3 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionTab.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionTab.java @@ -267,16 +267,7 @@ public class XDebugSessionTab extends DebuggerSessionTabBase { final AnAction[] commonSettings = myUi.getOptions().getSettingsActionsList(); DefaultActionGroup settings = new DefaultActionGroup(ActionsBundle.message("group.XDebugger.settings.text"), true); settings.getTemplatePresentation().setIcon(myUi.getOptions().getSettingsActions().getTemplatePresentation().getIcon()); - if (commonSettings.length > 0) { - for (AnAction each : commonSettings) { - settings.add(each); - } - settings.addSeparator(); - } - if (!session.getDebugProcess().isValuesCustomSorted()) { - settings.add(new ToggleSortValuesAction(commonSettings.length == 0)); - } - + settings.addAll(commonSettings); leftToolbar.add(settings); leftToolbar.addSeparator(); @@ -316,7 +307,7 @@ public class XDebugSessionTab extends DebuggerSessionTabBase { } @Override - public void update(AnActionEvent e) { + public void update(@NotNull AnActionEvent e) { super.update(e); if (!myShowIcon) { e.getPresentation().setIcon(null); diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/actions/SortValuesToggleAction.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/actions/SortValuesToggleAction.java index e399dbd96eba..3adade0fedb2 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/actions/SortValuesToggleAction.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/actions/SortValuesToggleAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 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. @@ -18,13 +18,23 @@ package com.intellij.xdebugger.impl.ui.tree.actions; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.ToggleAction; import com.intellij.openapi.project.DumbAware; +import com.intellij.xdebugger.XDebugSession; import com.intellij.xdebugger.impl.XDebuggerUtilImpl; import com.intellij.xdebugger.impl.settings.XDebuggerSettingsManager; +import org.jetbrains.annotations.NotNull; /** * @author nik */ public class SortValuesToggleAction extends ToggleAction implements DumbAware { + + @Override + public void update(@NotNull AnActionEvent e) { + super.update(e); + XDebugSession session = XDebugSession.DATA_KEY.getData(e.getDataContext()); + e.getPresentation().setEnabledAndVisible(session != null && !session.getDebugProcess().isValuesCustomSorted()); + } + @Override public boolean isSelected(AnActionEvent e) { return XDebuggerSettingsManager.getInstanceImpl().getDataViewSettings().isSortValues(); diff --git a/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/ByteCodeViewerComponent.java b/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/ByteCodeViewerComponent.java index fbd2b1b72f05..4ee91cefc5a2 100644 --- a/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/ByteCodeViewerComponent.java +++ b/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/ByteCodeViewerComponent.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. @@ -15,14 +15,13 @@ */ package com.intellij.byteCodeViewer; -import com.intellij.codeInsight.hint.EditorFragmentComponent; +import com.intellij.execution.filters.LineNumbersMapping; import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.ActionManager; import com.intellij.openapi.actionSystem.ActionPlaces; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.DefaultActionGroup; import com.intellij.openapi.editor.*; -import com.intellij.openapi.editor.colors.EditorColors; import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.ex.EditorEx; import com.intellij.openapi.editor.highlighter.EditorHighlighterFactory; @@ -30,10 +29,10 @@ import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.fileTypes.SyntaxHighlighter; import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; import com.intellij.openapi.project.Project; +import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiElement; -import com.intellij.ui.Gray; -import com.intellij.ui.JBColor; +import com.intellij.psi.PsiFile; import com.intellij.util.DocumentUtil; import javax.swing.*; @@ -82,9 +81,23 @@ public class ByteCodeViewerComponent extends JPanel implements Disposable { public void setText(final String bytecode, PsiElement element) { int offset = 0; - final Document document = PsiDocumentManager.getInstance(element.getProject()).getDocument(element.getContainingFile()); + PsiFile psiFile = element.getContainingFile(); + final Document document = PsiDocumentManager.getInstance(element.getProject()).getDocument(psiFile); if (document != null) { int lineNumber = document.getLineNumber(element.getTextOffset()); + VirtualFile file = psiFile.getVirtualFile(); + if (file != null) { + LineNumbersMapping mapping = file.getUserData(LineNumbersMapping.LINE_NUMBERS_MAPPING_KEY); + if (mapping != null) { + int mappedLine = mapping.sourceToBytecode(lineNumber); + while (mappedLine == -1 && lineNumber < document.getLineCount()) { + mappedLine = mapping.sourceToBytecode(++lineNumber); + } + if (mappedLine > 0) { + lineNumber = mappedLine; + } + } + } offset = bytecode.indexOf("LINENUMBER " + lineNumber); while (offset == -1 && lineNumber < document.getLineCount()) { offset = bytecode.indexOf("LINENUMBER " + (lineNumber++)); diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ThrowableInstanceNeverThrownInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ThrowableInstanceNeverThrownInspection.java index f36392ad4095..c435e8a773a3 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ThrowableInstanceNeverThrownInspection.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ThrowableInstanceNeverThrownInspection.java @@ -84,8 +84,7 @@ public class ThrowableInstanceNeverThrownInspection extends BaseInspection { return; } final PsiElement parent = getParent(expression.getParent()); - if (parent instanceof PsiThrowStatement || - parent instanceof PsiReturnStatement) { + if (canBeThrown(parent)) { return; } if (PsiTreeUtil.getParentOfType(parent, PsiCallExpression.class) != null) { @@ -93,7 +92,7 @@ public class ThrowableInstanceNeverThrownInspection extends BaseInspection { } final PsiElement typedParent = PsiTreeUtil.getParentOfType(expression, PsiAssignmentExpression.class, PsiVariable.class); final PsiElement variable = ThrowableResultOfMethodCallIgnoredInspection.getVariable(typedParent, expression); - if (variable == null) { + if (typedParent != null && variable == null) { return; } if (variable instanceof PsiLocalVariable) { @@ -104,8 +103,7 @@ public class ThrowableInstanceNeverThrownInspection extends BaseInspection { while (usageParent instanceof PsiParenthesizedExpression) { usageParent = usageParent.getParent(); } - if (usageParent instanceof PsiThrowStatement || - usageParent instanceof PsiReturnStatement) { + if (canBeThrown(usageParent)) { return; } if (PsiTreeUtil.getParentOfType(usageParent, PsiCallExpression.class) != null) { @@ -116,6 +114,12 @@ public class ThrowableInstanceNeverThrownInspection extends BaseInspection { registerError(expression, expression); } + private static boolean canBeThrown(PsiElement parent) { + return parent instanceof PsiThrowStatement || + parent instanceof PsiReturnStatement || + parent instanceof PsiLambdaExpression; + } + public static PsiElement getParent(PsiElement element) { PsiElement parent = element; while (parent instanceof PsiParenthesizedExpression || diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ThrowableResultOfMethodCallIgnoredInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ThrowableResultOfMethodCallIgnoredInspection.java index cc5ee222d4db..b3984cfa2b43 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ThrowableResultOfMethodCallIgnoredInspection.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ThrowableResultOfMethodCallIgnoredInspection.java @@ -63,10 +63,7 @@ public class ThrowableResultOfMethodCallIgnoredInspection extends BaseInspection while (parent instanceof PsiParenthesizedExpression || parent instanceof PsiTypeCastExpression) { parent = parent.getParent(); } - if (parent instanceof PsiReturnStatement || - parent instanceof PsiThrowStatement || - parent instanceof PsiExpressionList || - parent instanceof PsiLambdaExpression) { + if (canBeThrown(parent)) { return; } if (!TypeUtils.expressionHasTypeOrSubtype(expression, CommonClassNames.JAVA_LANG_THROWABLE)) { @@ -102,15 +99,20 @@ public class ThrowableResultOfMethodCallIgnoredInspection extends BaseInspection while (usageParent instanceof PsiParenthesizedExpression) { usageParent = usageParent.getParent(); } - if (usageParent instanceof PsiThrowStatement || - usageParent instanceof PsiReturnStatement || - usageParent instanceof PsiExpressionList) { + if (canBeThrown(usageParent)) { return; } } } registerMethodCallError(expression); } + + private static boolean canBeThrown(PsiElement parent) { + return parent instanceof PsiReturnStatement || + parent instanceof PsiThrowStatement || + parent instanceof PsiExpressionList || + parent instanceof PsiLambdaExpression; + } } protected static PsiElement getVariable(PsiElement parent, PsiElement expression) { diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/DynamicRegexReplaceableByCompiledPatternInspectionBase.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/DynamicRegexReplaceableByCompiledPatternInspectionBase.java index feca10548dfc..d826a47a84c9 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/DynamicRegexReplaceableByCompiledPatternInspectionBase.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/DynamicRegexReplaceableByCompiledPatternInspectionBase.java @@ -16,8 +16,10 @@ package com.siyeh.ig.performance; import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel; +import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.util.WriteExternalException; import com.intellij.psi.*; +import com.intellij.psi.impl.AllowedApiFilterExtension; import com.siyeh.InspectionGadgetsBundle; import com.siyeh.ig.BaseInspection; import com.siyeh.ig.BaseInspectionVisitor; @@ -124,7 +126,14 @@ public class DynamicRegexReplaceableByCompiledPatternInspectionBase extends Base return false; } final String className = containingClass.getQualifiedName(); - return CommonClassNames.JAVA_LANG_STRING.equals(className); + if (!CommonClassNames.JAVA_LANG_STRING.equals(className)) { + return false; + } + if (Extensions.getRootArea().hasExtensionPoint(AllowedApiFilterExtension.EP_NAME.getName())) { + //todo[nik] remove this condition when the extension point will be registered in java-analysis-impl module + return AllowedApiFilterExtension.isClassAllowed("java.util.regex.Pattern", expression); + } + return true; } private boolean isOptimizedPattern(String regex) { diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/throwable_instance_never_thrown/ThrowableInstanceNeverThrown.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/throwable_instance_never_thrown/ThrowableInstanceNeverThrown.java index f87fa95e2cae..711776a7d91c 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/throwable_instance_never_thrown/ThrowableInstanceNeverThrown.java +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/throwable_instance_never_thrown/ThrowableInstanceNeverThrown.java @@ -44,3 +44,16 @@ public class ThrowableInstanceNeverThrown { void methodCall(IOException e){} } + +interface I { + Exception get(); +} + +class L { + { + I i = () -> new RuntimeException(); + + final RuntimeException exception = new RuntimeException(); + I i2 = () -> exception; + } +} \ No newline at end of file diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/wizard/GradleProjectImportBuilder.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/wizard/GradleProjectImportBuilder.java index 1dc0368d4775..608338346528 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/wizard/GradleProjectImportBuilder.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/wizard/GradleProjectImportBuilder.java @@ -73,7 +73,7 @@ public class GradleProjectImportBuilder extends AbstractExternalProjectImportBui final ImportFromGradleControl importFromGradleControl = getControl(context.getProject()); importFromGradleControl.setLinkedProjectPath(pathToUse); final Pair sdkPair = ExternalSystemJdkUtil.getAvailableJdk(context.getProject()); - if (sdkPair != null) { + if (sdkPair != null && !ExternalSystemJdkUtil.USE_INTERNAL_JAVA.equals(sdkPair.first)) { importFromGradleControl.getProjectSettings().setGradleJvm(sdkPair.first); } } diff --git a/python/helpers/pycharm/utrunner.py b/python/helpers/pycharm/utrunner.py index d0450c242825..bd04fedcff53 100644 --- a/python/helpers/pycharm/utrunner.py +++ b/python/helpers/pycharm/utrunner.py @@ -52,8 +52,9 @@ def walkModules(modulesAndPattern, dirname, names): if name.endswith(".py") and prog.match(name): modules.append(loadSource(os.path.join(dirname, name))) + # For default pattern see https://docs.python.org/2/library/unittest.html#test-discovery -def loadModulesFromFolderRec(folder, pattern = "test*.py"): +def loadModulesFromFolderRec(folder, pattern="test*.py"): modules = [] if PYTHON_VERSION_MAJOR == 3: # fnmatch converts glob to regexp @@ -105,7 +106,7 @@ if __name__ == "__main__": a = arg.split("::") if len(a) == 1: # From module or folder - a_splitted = a[0].split("_args_separator_") # ";" can't be used with bash, so we use "_args_separator_" + a_splitted = a[0].split("_args_separator_") # ";" can't be used with bash, so we use "_args_separator_" if len(a_splitted) != 1: # means we have pattern to match against if a_splitted[0].endswith(os.path.sep): diff --git a/resources-en/src/messages/DebuggerBundle.properties b/resources-en/src/messages/DebuggerBundle.properties index 929447158cd4..dfc2a108eaea 100644 --- a/resources-en/src/messages/DebuggerBundle.properties +++ b/resources-en/src/messages/DebuggerBundle.properties @@ -441,7 +441,7 @@ action.show.watches.description=Shows or hides 'watches' pane action.show.watches.text.hide=Hide Watches action.show.watches.text.show=Show Watches action.watch.method.return.value.description=Enables watching last executed method return value -action.watches.method.return.value.enable=Watch method return values +action.watches.method.return.value.enable=Show Method Return Values action.watches.method.return.value.disable=Stop watching method return values action.watches.method.return.value.unavailable.reason=Feature is not supported by the target VM action.auto.variables.mode=Auto-Variables Mode diff --git a/xml/xml-psi-impl/src/com/intellij/lang/html/HtmlParsing.java b/xml/xml-psi-impl/src/com/intellij/lang/html/HtmlParsing.java index 82c1dff7aabb..96719edfcd78 100644 --- a/xml/xml-psi-impl/src/com/intellij/lang/html/HtmlParsing.java +++ b/xml/xml-psi-impl/src/com/intellij/lang/html/HtmlParsing.java @@ -37,12 +37,12 @@ import org.jetbrains.annotations.Nullable; public class HtmlParsing { @NonNls private static final String TR_TAG = "tr"; @NonNls private static final String TD_TAG = "td"; - @NonNls private static final String DD_TAG = "dd"; - @NonNls private static final String DT_TAG = "dt"; + @NonNls private static final String TH_TAG = "th"; @NonNls private static final String TABLE_TAG = "table"; private final PsiBuilder myBuilder; private final Stack myTagNamesStack = new Stack(); + private final Stack myOriginalTagNamesStack = new Stack(); private final Stack myTagMarkersStack = new Stack(); @NonNls private static final String COMPLETION_NAME = CompletionUtilCore.DUMMY_IDENTIFIER_TRIMMED.toLowerCase(); @@ -64,7 +64,7 @@ public class HtmlParsing { final IElementType tt = token(); if (tt == XmlTokenType.XML_START_TAG_START) { error = flushError(error); - parseTag(""); + parseTag(); myTagMarkersStack.clear(); myTagNamesStack.clear(); } @@ -133,146 +133,72 @@ public class HtmlParsing { doctype.done(XmlElementType.XML_DOCTYPE); } - private static boolean ddordt(String name) { - return DT_TAG.equals(name) || DD_TAG.equals(name); - } - - private boolean parseTag(String parentName) { + private void parseTag() { assert token() == XmlTokenType.XML_START_TAG_START : "Tag start expected"; - final PsiBuilder.Marker tag = mark(); - myTagMarkersStack.push(tag); - - // Start tag header - advance(); - final String originalTagName; - if (token() != XmlTokenType.XML_NAME) { - error(XmlErrorMessages.message("xml.parsing.tag.name.expected")); - originalTagName = ""; - } - else { - originalTagName = myBuilder.getTokenText(); - advance(); - } - - String tagName = StringUtil.toLowerCase(originalTagName); - if (ddordt(tagName) && ddordt(parentName) || - tagName.equals(parentName) && HtmlUtil.isOptionalEndForHtmlTagL(tagName) || - myTagMarkersStack.size() > MAGIC_FRAME_COUNT // no chance for evil guys wanting us to have stack overflow - ) { - tag.rollbackTo(); - myTagMarkersStack.pop(); - return false; - } - - myTagNamesStack.push(tagName); - - boolean freeMakerTag = !tagName.isEmpty() && '#' == tagName.charAt(0); - - do { - final IElementType tt = token(); - if (freeMakerTag) { - if (tt == XmlTokenType.XML_EMPTY_ELEMENT_END || - tt == XmlTokenType.XML_TAG_END || - tt == XmlTokenType.XML_END_TAG_START || - tt == XmlTokenType.XML_START_TAG_START) break; - advance(); - } - else { - if (tt == XmlTokenType.XML_NAME) { - parseAttribute(); - } - else if (tt == XmlTokenType.XML_CHAR_ENTITY_REF || tt == XmlTokenType.XML_ENTITY_REF_TOKEN) { - parseReference(); - } - else { - break; - } - } - } - while (!eof()); - - if (token() == XmlTokenType.XML_EMPTY_ELEMENT_END) { - advance(); - tag.done(XmlElementType.HTML_TAG); - return true; - } - - if (token() == XmlTokenType.XML_TAG_END) { - advance(); - } - else { - error(XmlErrorMessages.message("tag.start.is.not.closed")); - tag.done(XmlElementType.HTML_TAG); - return true; - } - - if (HtmlUtil.isSingleHtmlTagL(tagName)) { - final PsiBuilder.Marker footer = mark(); - if (token() == XmlTokenType.XML_END_TAG_START) { - advance(); - if (token() == XmlTokenType.XML_NAME) { - if (tagName.equalsIgnoreCase(myBuilder.getTokenText())) { - advance(); - footer.drop(); - if (token() == XmlTokenType.XML_TAG_END) { - advance(); - } - tag.done(XmlElementType.HTML_TAG); - return true; - } - } - } - - footer.rollbackTo(); - tag.done(XmlElementType.HTML_TAG); - return true; - } - - // Done header, start content - - boolean isInlineTagContainer = HtmlUtil.isInlineTagContainerL(tagName); - boolean isOptionalTagEnd = HtmlUtil.isOptionalEndForHtmlTagL(tagName); - - PsiBuilder.Marker firstBlockChild = null; - + String originalTagName; PsiBuilder.Marker xmlText = null; while (!eof()) { final IElementType tt = token(); if (tt == XmlTokenType.XML_START_TAG_START) { xmlText = terminateText(xmlText); - if (!parseTag(tagName)) { - tag.done(XmlElementType.HTML_TAG); - return true; + final PsiBuilder.Marker tag = mark(); + + // Start tag header + advance(); + if (token() != XmlTokenType.XML_NAME) { + error(XmlErrorMessages.message("xml.parsing.tag.name.expected")); + originalTagName = ""; + } + else { + originalTagName = myBuilder.getTokenText(); + advance(); } - PsiBuilder.Marker childMarker = myTagMarkersStack.pop(); - String childName = myTagNamesStack.pop(); + String tagName = StringUtil.toLowerCase(originalTagName); + while (childTerminatesParentInStack(tagName)) { + PsiBuilder.Marker top = closeTag(); + top.doneBefore(XmlElementType.HTML_TAG, tag); + } - if (isOptionalTagEnd) { - boolean foundMatch = childTerminatesParentInStack(childName, true); - if (foundMatch) { - // allow only one promotion per tag, otherwise last row in table - // will make it up to the first one moving all tags in between under first node - if (!canTerminate(childName, tagName)) { - myTagMarkersStack.pop(); - myTagNamesStack.pop(); + myTagMarkersStack.push(tag); + myTagNamesStack.push(tagName); + myOriginalTagNamesStack.push(originalTagName); - myTagMarkersStack.push(childMarker); - myTagNamesStack.push(childName); + parseHeader(tagName); + + if (token() == XmlTokenType.XML_EMPTY_ELEMENT_END) { + advance(); + doneTag(tag); + continue; + } + + if (token() == XmlTokenType.XML_TAG_END) { + advance(); + } + else { + error(XmlErrorMessages.message("tag.start.is.not.closed")); + doneTag(tag); + continue; + } + + if (HtmlUtil.isSingleHtmlTagL(tagName)) { + final PsiBuilder.Marker footer = mark(); + if (token() == XmlTokenType.XML_END_TAG_START) { + advance(); + if (token() == XmlTokenType.XML_NAME) { + if (tagName.equalsIgnoreCase(myBuilder.getTokenText())) { + advance(); + footer.drop(); + if (token() == XmlTokenType.XML_TAG_END) { + advance(); + } + doneTag(tag); + continue; + } } - - tag.doneBefore(XmlElementType.HTML_TAG, childMarker); - return true; } - } - - - if (isInlineTagContainer && HtmlUtil.isHtmlBlockTagL(childName) && isOptionalTagEnd && !HtmlUtil.isPossiblyInlineTag(childName)) { - tag.doneBefore(XmlElementType.HTML_TAG, childMarker); - return true; - } - else if (isOptionalTagEnd && firstBlockChild == null && HtmlUtil.isHtmlBlockTagL(childName) && !HtmlUtil.isHtmlBlockTagL(tagName) && canTerminate(childName, tagName)) { - firstBlockChild = childMarker; + footer.rollbackTo(); + doneTag(tag); } } else if (tt == XmlTokenType.XML_PI_START) { @@ -312,23 +238,20 @@ public class HtmlParsing { if (token() == XmlTokenType.XML_NAME) { String endName = StringUtil.toLowerCase(myBuilder.getTokenText()); - if (!tagName.equals(endName) && !endName.endsWith(COMPLETION_NAME)) { - final boolean hasChancesToMatch = HtmlUtil.isOptionalEndForHtmlTagL(endName) ? childTerminatesParentInStack(endName, false) : myTagNamesStack.contains(endName); + final String parentTagName = !myTagNamesStack.isEmpty() ? myTagNamesStack.peek() : ""; + if (!parentTagName.equals(endName) && !endName.endsWith(COMPLETION_NAME)) { + final boolean isOptionalTagEnd = HtmlUtil.isOptionalEndForHtmlTagL(parentTagName); + final boolean hasChancesToMatch = HtmlUtil.isOptionalEndForHtmlTagL(endName) ? childTerminatesParentInStack(endName) : myTagNamesStack.contains(endName); if (hasChancesToMatch) { footer.rollbackTo(); if (isOptionalTagEnd) { - if (firstBlockChild != null) { - tag.doneBefore(XmlElementType.HTML_TAG, firstBlockChild); - } - else { - tag.done(XmlElementType.HTML_TAG); - } + doneTag(myTagMarkersStack.peek()); } else { - error(XmlErrorMessages.message("named.element.is.not.closed", originalTagName)); - tag.done(XmlElementType.HTML_TAG); + error(XmlErrorMessages.message("named.element.is.not.closed", myOriginalTagNamesStack.peek())); + doneTag(myTagMarkersStack.peek()); } - return true; + continue; } else { advance(); @@ -356,57 +279,105 @@ public class HtmlParsing { else { error(XmlErrorMessages.message("xml.parsing.closing.tag.is.not.done")); } - - tag.done(XmlElementType.HTML_TAG); - return true; - } - else { + if (hasTags()) doneTag(myTagMarkersStack.peek()); + } else if ((token() == XmlTokenType.XML_REAL_WHITE_SPACE || token() == XmlTokenType.XML_DATA_CHARACTERS) && !hasTags()) { + xmlText = terminateText(xmlText); + advance(); + } else { xmlText = startText(xmlText); advance(); } } - terminateText(xmlText); + while (hasTags()) { + final String tagName = myTagNamesStack.peek(); + if (!HtmlUtil.isOptionalEndForHtmlTagL(tagName) && !"html".equals(tagName) && !"body".equals(tagName)) { + error(XmlErrorMessages.message("named.element.is.not.closed", myOriginalTagNamesStack.peek())); + } + doneTag(myTagMarkersStack.peek()); + } + } - if (isOptionalTagEnd || "body".equalsIgnoreCase(tagName) || "html".equalsIgnoreCase(tagName)) { - if (firstBlockChild != null) { - tag.doneBefore(XmlElementType.HTML_TAG, firstBlockChild); + private boolean hasTags() { + return !myTagNamesStack.isEmpty(); + } + + private PsiBuilder.Marker closeTag() { + myTagNamesStack.pop(); + myOriginalTagNamesStack.pop(); + return myTagMarkersStack.pop(); + } + + private void doneTag(PsiBuilder.Marker tag) { + tag.done(XmlElementType.HTML_TAG); + final String tagName = myTagNamesStack.peek(); + closeTag(); + + final String parentTagName = hasTags() ? myTagNamesStack.peek() : ""; + boolean isInlineTagContainer = HtmlUtil.isInlineTagContainerL(parentTagName); + boolean isOptionalTagEnd = HtmlUtil.isOptionalEndForHtmlTagL(parentTagName); + if (isInlineTagContainer && HtmlUtil.isHtmlBlockTagL(tagName) && isOptionalTagEnd && !HtmlUtil.isPossiblyInlineTag(tagName)) { + PsiBuilder.Marker top = closeTag(); + top.doneBefore(XmlElementType.HTML_TAG, tag); + } + } + + private void parseHeader(String tagName) { + boolean freeMakerTag = !tagName.isEmpty() && '#' == tagName.charAt(0); + + do { + final IElementType tt = token(); + if (freeMakerTag) { + if (tt == XmlTokenType.XML_EMPTY_ELEMENT_END || + tt == XmlTokenType.XML_TAG_END || + tt == XmlTokenType.XML_END_TAG_START || + tt == XmlTokenType.XML_START_TAG_START) break; + advance(); } else { - tag.done(XmlElementType.HTML_TAG); + if (tt == XmlTokenType.XML_NAME) { + parseAttribute(); + } + else if (tt == XmlTokenType.XML_CHAR_ENTITY_REF || tt == XmlTokenType.XML_ENTITY_REF_TOKEN) { + parseReference(); + } + else { + break; + } } } - else { - error(XmlErrorMessages.message("named.element.is.not.closed", originalTagName)); - tag.done(XmlElementType.HTML_TAG); - } - - return true; + while (!eof()); } - private static boolean canTerminate(final String childTagName,final String tagName) { - return childTagName.equals(tagName) || HtmlUtil.canTerminate(childTagName, tagName); - } - - private boolean childTerminatesParentInStack(final String childName, final boolean terminateOnNonOptionalTag) { - boolean isCell = TD_TAG.equals(childName) || "th".equals(childName); + private boolean childTerminatesParentInStack(final String childName) { + boolean isCell = TD_TAG.equals(childName) || TH_TAG.equals(childName); boolean isRow = TR_TAG.equals(childName); + boolean isStructure = isStructure(childName); for (int i = myTagNamesStack.size() - 1; i >= 0; i--) { String parentName = myTagNamesStack.get(i); - if (terminateOnNonOptionalTag && !HtmlUtil.isOptionalEndForHtmlTagL(parentName)) return false; - if (isCell && (TR_TAG.equals(parentName) || TABLE_TAG.equals(parentName)) || - isRow && TABLE_TAG.equals(parentName)) { + final boolean isParentTable = TABLE_TAG.equals(parentName); + final boolean isParentStructure = isStructure(parentName); + if (isCell && (TR_TAG.equals(parentName) || isParentStructure || isParentTable) || + isRow && (isParentStructure || isParentTable) || + isStructure && isParentTable) { return false; } - if (canTerminate(childName, parentName)) { + if ("li".equals(childName) && ("ul".equals(parentName) || "ol".equals(parentName))) { + return false; + } + + if (HtmlUtil.canTerminate(childName, parentName)) { return true; } } return false; } + private static boolean isStructure(String childName) { + return "thead".equals(childName) || "tbody".equals(childName) || "tfoot".equals(childName); + } @NotNull private PsiBuilder.Marker startText(@Nullable PsiBuilder.Marker xmlText) { @@ -621,6 +592,4 @@ public class HtmlParsing { private void error(final String message) { myBuilder.error(message); } - - private static final int MAGIC_FRAME_COUNT = 450; } diff --git a/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlControls.xml b/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlControls.xml index 4dc51494808f..88edfb5bd1f3 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlControls.xml +++ b/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlControls.xml @@ -31,7 +31,7 @@ - +