diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaClassNameCompletionContributor.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaClassNameCompletionContributor.java index d36c35ca6e73..90e550a75b30 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaClassNameCompletionContributor.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaClassNameCompletionContributor.java @@ -37,9 +37,11 @@ import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtil; import com.intellij.util.Consumer; import com.intellij.util.SmartList; +import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import java.util.List; +import java.util.Set; import static com.intellij.patterns.PsiJavaPatterns.psiClass; import static com.intellij.patterns.PsiJavaPatterns.psiElement; @@ -117,26 +119,52 @@ public class JavaClassNameCompletionContributor extends CompletionContributor { final boolean pkgContext = JavaCompletionUtil.inSomePackage(insertedElement); AllClassesGetter.processJavaClasses(parameters, matcher, filterByScope, new Consumer() { - @Override - public void consume(PsiClass psiClass) { - if (filter.isAcceptable(psiClass, insertedElement)) { - if (!inJavaContext) { - consumer.consume(AllClassesGetter.createLookupItem(psiClass, AllClassesGetter.TRY_SHORTENING)); - } else { - for (JavaPsiClassReferenceElement element : createClassLookupItems(psiClass, afterNew, - JavaClassNameInsertHandler.JAVA_CLASS_INSERT_HANDLER, new Condition() { + @Override + public void consume(PsiClass psiClass) { + processClass(psiClass, ContainerUtil.newHashSet(), ""); + } + + private void processClass(PsiClass psiClass, Set visited, String prefix) { + if (!visited.add(psiClass)) return; + + boolean isInnerClass = StringUtil.isNotEmpty(prefix); + if (isInnerClass && isProcessedIndependently(psiClass)) { + return; + } + + if (filter.isAcceptable(psiClass, insertedElement)) { + if (!inJavaContext) { + JavaPsiClassReferenceElement element = AllClassesGetter.createLookupItem(psiClass, AllClassesGetter.TRY_SHORTENING); + element.setLookupString(prefix + element.getLookupString()); + consumer.consume(element); + } else { + for (JavaPsiClassReferenceElement element : createClassLookupItems(psiClass, afterNew, + JavaClassNameInsertHandler.JAVA_CLASS_INSERT_HANDLER, new Condition() { @Override public boolean value(PsiClass psiClass) { return filter.isAcceptable(psiClass, insertedElement) && AllClassesGetter.isAcceptableInContext(insertedElement, psiClass, filterByScope, pkgContext); } })) { - consumer.consume(element); - } + element.setLookupString(prefix + element.getLookupString()); + consumer.consume(element); + } + } + } else { + String name = psiClass.getName(); + if (name != null) { + for (PsiClass innerClass : psiClass.getInnerClasses()) { + processClass(innerClass, visited, prefix + name + "."); } } } - }); + } + + private boolean isProcessedIndependently(PsiClass psiClass) { + String innerName = psiClass.getName(); + return innerName != null && matcher.prefixMatches(innerName); + } + }); } static LookupElement highlightIfNeeded(JavaPsiClassReferenceElement element, CompletionParameters parameters) { diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java index 67143a7b73a5..2a03a31bb3ea 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java @@ -20,6 +20,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProgressIndicatorProvider; import com.intellij.openapi.roots.FileIndexFacade; import com.intellij.openapi.util.*; +import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.*; @@ -711,6 +712,10 @@ public class PsiClassImplUtil { @Nullable public static PsiClassType correctType(PsiClassType originalType, final GlobalSearchScope resolveScope) { + if (!Registry.is("java.correct.class.type.by.place.resolve.scope")) { + return originalType; + } + final PsiClassType.ClassResolveResult originalResolveResult = originalType.resolveGenerics(); PsiClass superClass = originalResolveResult.getElement(); if (superClass == null) { @@ -746,7 +751,7 @@ public class PsiClassImplUtil { } }); if (substitute == null) return null; - + substitutor = substitutor.put(typeParameters[i], substitute); } } diff --git a/java/java-tests/testData/codeInsight/completion/normal/InnerAnnotation.java b/java/java-tests/testData/codeInsight/completion/normal/InnerAnnotation.java new file mode 100644 index 000000000000..4fd5cc0138d4 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/normal/InnerAnnotation.java @@ -0,0 +1,11 @@ +final class MyModule { + @Target({FIELD,PARAMETER,METHOD}) + @Retention(RUNTIME) + public static @interface Dependency { } +} + +final class SomeService { + + SomeService(@My) { + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/normal/InnerAnnotation_after.java b/java/java-tests/testData/codeInsight/completion/normal/InnerAnnotation_after.java new file mode 100644 index 000000000000..9ad5271d6b8d --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/normal/InnerAnnotation_after.java @@ -0,0 +1,11 @@ +final class MyModule { + @Target({FIELD,PARAMETER,METHOD}) + @Retention(RUNTIME) + public static @interface Dependency { } +} + +final class SomeService { + + SomeService(@MyModule.Dependency) { + } +} \ 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 05a14ef267f0..b02d90b6d596 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/MultipleModuleHighlightingTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/MultipleModuleHighlightingTest.groovy @@ -25,7 +25,7 @@ import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase */ class MultipleModuleHighlightingTest extends JavaCodeInsightFixtureTestCase { - @Bombed(day = 1, month = Calendar.MARCH) + @Bombed(day = 1, month = Calendar.APRIL) public void "test use original place classpath for reference type resolving"() { addTwoModules() @@ -60,7 +60,7 @@ class Class3 { myFixture.checkHighlighting() } - @Bombed(day = 1, month = Calendar.MARCH) + @Bombed(day = 1, month = Calendar.APRIL) public void "test use original place classpath for new expression type resolving"() { addTwoModules() diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy index d8abdbd5a9e8..0852028413bf 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy @@ -932,6 +932,7 @@ public class ListUtils { public void testTabReplacesMethodNameWithLocalVariableName() throws Throwable { doTest('\t'); } public void testMethodParameterAnnotationClass() throws Throwable { doTest(); } + public void testInnerAnnotation() { doTest('\n'); } public void testPrimitiveCastOverwrite() throws Throwable { doTest '\t' } public void testClassReferenceInFor() throws Throwable { doTest ' ' } public void testClassReferenceInFor2() throws Throwable { doTest ' ' } diff --git a/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java b/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java index 8bf2fb1d4284..384fdc3eb339 100644 --- a/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java +++ b/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java @@ -365,6 +365,19 @@ public class FindManagerTest extends DaemonAnalyzerTestCase { assertSize(1, findUsages(findModel)); } + public void testNonSourceContent() throws Exception { + VirtualFile root = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(createTempDirectory()); + PsiTestUtil.addContentRoot(myModule, root); + + createFile(myModule, root, "A.txt", "goo doo"); + + FindModel findModel = FindManagerTestUtils.configureFindModel("goo"); + findModel.setProjectScope(false); + findModel.setModuleName(myModule.getName()); + + assertSize(1, findUsages(findModel)); + } + public void testReplaceRegexp() { FindModel findModel = new FindModel(); findModel.setStringToFind("bug_(?=here)"); @@ -537,6 +550,7 @@ public class FindManagerTest extends DaemonAnalyzerTestCase { findModel.setFromCursor(false); findModel.setGlobal(true); findModel.setMultipleFiles(true); + findModel.setCustomScope(true); ThrowableRunnable test = new ThrowableRunnable() { @Override @@ -573,6 +587,7 @@ public class FindManagerTest extends DaemonAnalyzerTestCase { VirtualFile file = tempDirFixture.createFile("a.txt", "foo bar foo"); FindModel findModel = FindManagerTestUtils.configureFindModel("foo"); findModel.setWholeWordsOnly(true); + findModel.setCustomScope(true); findModel.setCustomScope(new LocalSearchScope(PsiManager.getInstance(myProject).findFile(file))); assertSize(2, findUsages(findModel)); } diff --git a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/DaemonCodeAnalyzerSettings.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/DaemonCodeAnalyzerSettings.java index 00fa3f0f4cff..9fc611d6dbbc 100644 --- a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/DaemonCodeAnalyzerSettings.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/DaemonCodeAnalyzerSettings.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. @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package com.intellij.codeInsight.daemon; import com.intellij.openapi.components.ServiceManager; +import com.intellij.util.xmlb.annotations.OptionTag; import com.intellij.util.xmlb.annotations.Transient; public class DaemonCodeAnalyzerSettings { @@ -26,9 +26,9 @@ public class DaemonCodeAnalyzerSettings { public boolean NEXT_ERROR_ACTION_GOES_TO_ERRORS_FIRST = true; public int AUTOREPARSE_DELAY = 300; - public boolean SHOW_ADD_IMPORT_HINTS = true; + protected boolean myShowAddImportHints = true; public String NO_AUTO_IMPORT_PATTERN = "[a-z].?"; - public boolean SUPPRESS_WARNINGS = true; + protected boolean mySuppressWarnings = true; public boolean SHOW_METHOD_SEPARATORS = false; public int ERROR_STRIPE_MARK_MIN_HEIGHT = 2; public boolean SHOW_SMALL_ICONS_IN_GUTTER = true; @@ -38,21 +38,21 @@ public class DaemonCodeAnalyzerSettings { return false; } - @Transient + @OptionTag(value = "SHOW_ADD_IMPORT_HINTS") public boolean isImportHintEnabled() { - return SHOW_ADD_IMPORT_HINTS; + return myShowAddImportHints; } public void setImportHintEnabled(boolean isImportHintEnabled) { - SHOW_ADD_IMPORT_HINTS = isImportHintEnabled; + myShowAddImportHints = isImportHintEnabled; } - @Transient + @OptionTag(value = "SUPPRESS_WARNINGS") public boolean isSuppressWarnings() { - return SUPPRESS_WARNINGS; + return mySuppressWarnings; } public void setSuppressWarnings(boolean suppressWarnings) { - SUPPRESS_WARNINGS = suppressWarnings; + mySuppressWarnings = suppressWarnings; } } diff --git a/platform/core-api/src/com/intellij/openapi/project/DumbService.java b/platform/core-api/src/com/intellij/openapi/project/DumbService.java index 68ca99133e46..efd18fbf8805 100644 --- a/platform/core-api/src/com/intellij/openapi/project/DumbService.java +++ b/platform/core-api/src/com/intellij/openapi/project/DumbService.java @@ -21,6 +21,7 @@ import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.Computable; +import com.intellij.openapi.util.ModificationTracker; import com.intellij.openapi.util.NotNullLazyKey; import com.intellij.openapi.util.Ref; import com.intellij.util.messages.Topic; @@ -37,9 +38,6 @@ import java.util.List; * A service managing IDEA's 'dumb' mode: when indices are updated in background and the functionality is very much limited. * Only the explicitly allowed functionality is available. Usually it's allowed by implementing {@link DumbAware} interface. * - * If you want to register a toolwindow, which will be enabled during the dumb mode, please use {@link com.intellij.openapi.wm.ToolWindowManager}'s - * registration methods which have 'canWorkInDumMode' parameter. - * * @author peter */ public abstract class DumbService { @@ -50,6 +48,11 @@ public abstract class DumbService { */ public static final Topic DUMB_MODE = new Topic("dumb mode", DumbModeListener.class); + /** + * The tracker is advanced each time we enter/exit from dumb mode. + */ + public abstract ModificationTracker getModificationTracker(); + /** * @return whether IntelliJ IDEA is in dumb mode, which means that right now indices are updated in background. * IDEA offers only limited functionality at such times, e.g. plain text file editing and version control operations. diff --git a/platform/diff-impl/src/com/intellij/diff/actions/CompareFilesAction.java b/platform/diff-impl/src/com/intellij/diff/actions/CompareFilesAction.java index 2e321952643a..4e00df7f1e41 100644 --- a/platform/diff-impl/src/com/intellij/diff/actions/CompareFilesAction.java +++ b/platform/diff-impl/src/com/intellij/diff/actions/CompareFilesAction.java @@ -42,8 +42,31 @@ public class CompareFilesAction extends BaseShowDiffAction { VirtualFile[] files = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY); - String text = getTemplatePresentation().getText(); - if (files != null && files.length == 1) text += "..."; + String text = "Compare Files"; + if (files != null && files.length == 1) { + text = "Compare With..."; + } + else if (files != null && files.length == 2) { + Type type1 = getType(files[0]); + Type type2 = getType(files[1]); + + if (type1 != type2) { + text = "Compare"; + } + else { + switch (type1) { + case FILE: + text = "Compare Files"; + break; + case DIRECTORY: + text = "Compare Directories"; + break; + case ARCHIEVE: + text = "Compare Archieves"; + break; + } + } + } e.getPresentation().setText(text); } @@ -93,7 +116,9 @@ public class CompareFilesAction extends BaseShowDiffAction { private static VirtualFile getOtherFile(@Nullable Project project, @NotNull VirtualFile file) { FileChooserDescriptor descriptor; String key; - if (file.isDirectory() || file.getFileType() instanceof ArchiveFileType) { + + Type type = getType(file); + if (type == Type.DIRECTORY || type == Type.ARCHIEVE) { descriptor = new FileChooserDescriptor(false, true, true, false, false, false); key = LAST_USED_FOLDER_KEY; } @@ -121,4 +146,14 @@ public class CompareFilesAction extends BaseShowDiffAction { if (project == null) return; PropertiesComponent.getInstance(project).setValue(key, file.getPath()); } + + @NotNull + private static Type getType(@Nullable VirtualFile file) { + if (file == null) return Type.FILE; + if (file.isDirectory()) return Type.DIRECTORY; + if (file.getFileType() instanceof ArchiveFileType) return Type.ARCHIEVE; + return Type.FILE; + } + + private enum Type {FILE, DIRECTORY, ARCHIEVE} } diff --git a/platform/diff-impl/src/com/intellij/diff/tools/dir/DifDiffViewer.java b/platform/diff-impl/src/com/intellij/diff/tools/dir/DifDiffViewer.java index 98786884cb1d..b362604c5f96 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/dir/DifDiffViewer.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/dir/DifDiffViewer.java @@ -23,17 +23,21 @@ import com.intellij.diff.contents.EmptyContent; import com.intellij.diff.contents.FileContent; import com.intellij.diff.requests.ContentDiffRequest; import com.intellij.diff.requests.DiffRequest; +import com.intellij.ide.DataManager; import com.intellij.ide.diff.DiffElement; import com.intellij.ide.diff.DirDiffSettings; import com.intellij.ide.diff.JarFileDiffElement; import com.intellij.ide.diff.VirtualFileDiffElement; import com.intellij.ide.highlighter.ArchiveFileType; import com.intellij.openapi.Disposable; +import com.intellij.openapi.actionSystem.DataProvider; +import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.diff.impl.dir.DirDiffFrame; import com.intellij.openapi.diff.impl.dir.DirDiffPanel; import com.intellij.openapi.diff.impl.dir.DirDiffTableModel; import com.intellij.openapi.diff.impl.dir.DirDiffWindow; import com.intellij.openapi.util.Disposer; +import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -46,7 +50,8 @@ class DifDiffViewer implements FrameDiffTool.DiffViewer { @NotNull private final DiffContext myContext; @NotNull private final ContentDiffRequest myRequest; - @NotNull private final DirDiffPanel myPanel; + @NotNull private final DirDiffPanel myDirDiffPanel; + @NotNull private final JPanel myPanel; public DifDiffViewer(@NotNull DiffContext context, @NotNull ContentDiffRequest request) { myContext = context; @@ -57,7 +62,7 @@ class DifDiffViewer implements FrameDiffTool.DiffViewer { DiffElement element2 = createDiffElement(contents.get(1)); DirDiffTableModel model = new DirDiffTableModel(context.getProject(), element1, element2, new DirDiffSettings()); - myPanel = new DirDiffPanel(model, new DirDiffWindow((DirDiffFrame)null) { + myDirDiffPanel = new DirDiffPanel(model, new DirDiffWindow((DirDiffFrame)null) { @Override public Window getWindow() { return null; @@ -72,31 +77,43 @@ class DifDiffViewer implements FrameDiffTool.DiffViewer { public void setTitle(String title) { } }); + + myPanel = new JPanel(new BorderLayout()); + myPanel.add(myDirDiffPanel.getPanel(), BorderLayout.CENTER); + DataManager.registerDataProvider(myPanel, new DataProvider() { + @Override + public Object getData(@NonNls String dataId) { + if (PlatformDataKeys.HELP_ID.is(dataId)) { + return "reference.dialogs.diff.folder"; + } + return null; + } + }); } @NotNull @Override public FrameDiffTool.ToolbarComponents init() { - myPanel.setupSplitter(); + myDirDiffPanel.setupSplitter(); return new FrameDiffTool.ToolbarComponents(); } @Override public void dispose() { - Disposer.dispose(myPanel); + Disposer.dispose(myDirDiffPanel); } @NotNull @Override public JComponent getComponent() { - return myPanel.getPanel(); + return myPanel; } @Nullable @Override public JComponent getPreferredFocusedComponent() { - return myPanel.getTable(); + return myDirDiffPanel.getTable(); } // diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/DaemonCodeAnalyzerSettingsImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/DaemonCodeAnalyzerSettingsImpl.java index d4889a97f802..0334f18b0931 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/DaemonCodeAnalyzerSettingsImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/DaemonCodeAnalyzerSettingsImpl.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. @@ -24,13 +24,13 @@ import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.profile.codeInspection.InspectionProfileManager; import com.intellij.profile.codeInspection.InspectionProfileManagerImpl; -import com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters; +import com.intellij.util.xmlb.SkipDefaultsSerializationFilter; import com.intellij.util.xmlb.XmlSerializer; import org.jdom.Element; @State( name = "DaemonCodeAnalyzerSettings", - storages = {@Storage(file = StoragePathMacros.APP_CONFIG + "/editor.codeinsight.xml")} + storages = @Storage(file = StoragePathMacros.APP_CONFIG + "/editor.codeinsight.xml") ) public class DaemonCodeAnalyzerSettingsImpl extends DaemonCodeAnalyzerSettings implements PersistentStateComponent, Cloneable { @Override @@ -42,7 +42,7 @@ public class DaemonCodeAnalyzerSettingsImpl extends DaemonCodeAnalyzerSettings i public DaemonCodeAnalyzerSettingsImpl clone() { DaemonCodeAnalyzerSettingsImpl settings = new DaemonCodeAnalyzerSettingsImpl(); settings.AUTOREPARSE_DELAY = AUTOREPARSE_DELAY; - settings.SHOW_ADD_IMPORT_HINTS = SHOW_ADD_IMPORT_HINTS; + settings.myShowAddImportHints = myShowAddImportHints; settings.SHOW_METHOD_SEPARATORS = SHOW_METHOD_SEPARATORS; settings.NO_AUTO_IMPORT_PATTERN = NO_AUTO_IMPORT_PATTERN; settings.SHOW_SMALL_ICONS_IN_GUTTER = SHOW_SMALL_ICONS_IN_GUTTER; @@ -51,7 +51,7 @@ public class DaemonCodeAnalyzerSettingsImpl extends DaemonCodeAnalyzerSettings i @Override public Element getState() { - Element element = XmlSerializer.serialize(this, new SkipDefaultValuesSerializationFilters()); + Element element = XmlSerializer.serialize(this, new SkipDefaultsSerializationFilter()); String profile = InspectionProfileManager.getInstance().getRootProfile().getName(); if (!"Default".equals(profile)) { element.setAttribute("profile", profile); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/EnterHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/EnterHandler.java index b6f951efb865..449f0865f793 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/EnterHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/EnterHandler.java @@ -356,7 +356,7 @@ public class EnterHandler extends BaseEnterHandler { commentContext.docStart = false; } else { - commentContext.docAsterisk = true; + commentContext.docAsterisk = CodeStyleSettingsManager.getSettings(getProject()).JD_LEADING_ASTERISKS_ARE_ENABLED; commentContext.docStart = false; } } diff --git a/platform/lang-impl/src/com/intellij/find/impl/FindInProjectTask.java b/platform/lang-impl/src/com/intellij/find/impl/FindInProjectTask.java index 93e88a25e0fa..973be2bc7416 100644 --- a/platform/lang-impl/src/com/intellij/find/impl/FindInProjectTask.java +++ b/platform/lang-impl/src/com/intellij/find/impl/FindInProjectTask.java @@ -267,7 +267,7 @@ class FindInProjectTask { @NotNull private Collection collectFilesInScope(@NotNull final Set alreadySearched, final boolean skipIndexed) { - SearchScope customScope = myFindModel.getCustomScope(); + SearchScope customScope = myFindModel.isCustomScope() ? myFindModel.getCustomScope() : null; final GlobalSearchScope globalCustomScope = toGlobal(customScope); final ProjectFileIndex fileIndex = ProjectFileIndex.SERVICE.getInstance(myProject); @@ -432,17 +432,7 @@ class FindInProjectTask { return Collections.emptySet(); } - SearchScope customScope = myFindModel.getCustomScope(); - GlobalSearchScope scope = myPsiDirectory != null - ? GlobalSearchScopesCore.directoryScope(myPsiDirectory, myFindModel.isWithSubdirectories()) - : myModule != null - ? myModule.getModuleContentScope() - : customScope instanceof GlobalSearchScope - ? (GlobalSearchScope)customScope - : toGlobal(customScope); - if (scope == null) { - scope = ProjectScope.getContentScope(myProject); - } + GlobalSearchScope scope = toGlobal(FindInProjectUtil.getScopeFromModel(myProject, myFindModel)); final Set resultFiles = new LinkedHashSet(); diff --git a/platform/lang-impl/src/com/intellij/find/impl/FindInProjectUtil.java b/platform/lang-impl/src/com/intellij/find/impl/FindInProjectUtil.java index 17ca7e4436bf..d22071e66b8e 100644 --- a/platform/lang-impl/src/com/intellij/find/impl/FindInProjectUtil.java +++ b/platform/lang-impl/src/com/intellij/find/impl/FindInProjectUtil.java @@ -49,10 +49,7 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileManager; import com.intellij.openapi.vfs.ex.VirtualFileManagerEx; import com.intellij.psi.*; -import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.psi.search.GlobalSearchScopesCore; -import com.intellij.psi.search.LocalSearchScope; -import com.intellij.psi.search.SearchScope; +import com.intellij.psi.search.*; import com.intellij.ui.content.Content; import com.intellij.usageView.UsageInfo; import com.intellij.usageView.UsageViewManager; @@ -443,7 +440,7 @@ public class FindInProjectUtil { } @NotNull - private static SearchScope getScopeFromModel(@NotNull Project project, @NotNull FindModel findModel) { + static SearchScope getScopeFromModel(@NotNull Project project, @NotNull FindModel findModel) { SearchScope customScope = findModel.getCustomScope(); PsiDirectory psiDir = getPsiDirectory(findModel, project); VirtualFile directory = psiDir == null ? null : psiDir.getVirtualFile(); @@ -452,8 +449,8 @@ public class FindInProjectUtil { // we don't have to check for myProjectFileIndex.isExcluded(file) here like FindInProjectTask.collectFilesInScope() does // because all found usages are guaranteed to be not in excluded dir directory != null ? GlobalSearchScopesCore.directoryScope(project, directory, findModel.isWithSubdirectories()) : - module != null ? GlobalSearchScope.moduleScope(module) : - findModel.isProjectScope() ? GlobalSearchScope.projectScope(project) : + module != null ? module.getModuleContentScope() : + findModel.isProjectScope() ? ProjectScope.getContentScope(project) : GlobalSearchScope.allScope(project); } } diff --git a/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowManager.java b/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowManager.java index 654f43e0c2ec..d0a875598203 100644 --- a/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowManager.java +++ b/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowManager.java @@ -25,6 +25,10 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import javax.swing.event.HyperlinkListener; +/** + * If you want to register a toolwindow, which will be enabled during the dumb mode, please use {@link ToolWindowManager}'s + * registration methods which have 'canWorkInDumMode' parameter. + */ public abstract class ToolWindowManager { public abstract boolean canShowNotification(@NotNull String toolWindowId); @@ -37,22 +41,22 @@ public abstract class ToolWindowManager { * Register specified tool window into IDE window system. * @param id id of tool window to be registered. * @param component component which represents tool window content. - * May be null. Content can be further added via content manager for this tool window (See {@link com.intellij.openapi.wm.ToolWindow#getContentManager()}) + * May be null. Content can be further added via content manager for this tool window (See {@link ToolWindow#getContentManager()}) * @param anchor the default anchor for first registration. It uses only first time the * tool window with the specified id is being registered into the window system. * After the first registration window's anchor is stored in project file * and anchor is ignored. - * @exception java.lang.IllegalArgumentException if the same window is already installed or one + * @exception IllegalArgumentException if the same window is already installed or one * of the parameters is null. * @return tool window - * @deprecated {@link com.intellij.openapi.wm.ToolWindowManager#registerToolWindow(String, boolean, ToolWindowAnchor)} + * @deprecated {@link ToolWindowManager#registerToolWindow(String, boolean, ToolWindowAnchor)} */ @Deprecated @NotNull public abstract ToolWindow registerToolWindow(@NotNull String id, @NotNull JComponent component, @NotNull ToolWindowAnchor anchor); /** - * @deprecated {@link com.intellij.openapi.wm.ToolWindowManager#registerToolWindow(String, boolean, ToolWindowAnchor)} + * @deprecated {@link ToolWindowManager#registerToolWindow(String, boolean, ToolWindowAnchor)} */ @Deprecated @NotNull @@ -62,7 +66,7 @@ public abstract class ToolWindowManager { @NotNull Disposable parentDisposable); /** - * @deprecated {@link com.intellij.openapi.wm.ToolWindowManager#registerToolWindow(String, boolean, ToolWindowAnchor)} + * @deprecated {@link ToolWindowManager#registerToolWindow(String, boolean, ToolWindowAnchor)} */ @Deprecated @NotNull @@ -72,7 +76,7 @@ public abstract class ToolWindowManager { Disposable parentDisposable, boolean canWorkInDumbMode); /** - * @deprecated {@link com.intellij.openapi.wm.ToolWindowManager#registerToolWindow(String, boolean, ToolWindowAnchor)} + * @deprecated {@link ToolWindowManager#registerToolWindow(String, boolean, ToolWindowAnchor)} */ @Deprecated @NotNull diff --git a/platform/platform-impl/src/com/intellij/ide/startup/impl/StartupManagerImpl.java b/platform/platform-impl/src/com/intellij/ide/startup/impl/StartupManagerImpl.java index b1839c87ac10..ad6a9567885c 100644 --- a/platform/platform-impl/src/com/intellij/ide/startup/impl/StartupManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/ide/startup/impl/StartupManagerImpl.java @@ -215,7 +215,10 @@ public class StartupManagerImpl extends StartupManagerEx { } }); - Registry.get("ide.firstStartup").setValue(false); + // otherwise will be stored - we must not create config files in tests + if (!app.isUnitTestMode()) { + Registry.get("ide.firstStartup").setValue(false); + } } public void scheduleInitialVfsRefresh() { diff --git a/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java b/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java index 4932c584a1e5..6b9b702ad443 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java @@ -49,10 +49,11 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Map; -public class DumbServiceImpl extends DumbService implements Disposable { +public class DumbServiceImpl extends DumbService implements Disposable, ModificationTracker { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.project.DumbServiceImpl"); private volatile boolean myDumb = false; private final DumbModeListener myPublisher; + private long myModificationCount; private final Queue myUpdatesQueue = new Queue(5); /** @@ -116,6 +117,11 @@ public class DumbServiceImpl extends DumbService implements Disposable { myAlternativeResolution.set(enabled); } + @Override + public ModificationTracker getModificationTracker() { + return null; + } + @Override public boolean isDumb() { return myDumb; @@ -209,6 +215,7 @@ public class DumbServiceImpl extends DumbService implements Disposable { @Override public Boolean compute() { myDumb = true; + myModificationCount++; try { myPublisher.enteredDumbMode(); } @@ -236,6 +243,7 @@ public class DumbServiceImpl extends DumbService implements Disposable { private void updateFinished() { myDumb = false; + myModificationCount++; if (myProject.isDisposed()) return; if (ApplicationManager.getApplication().isInternal()) LOG.info("updateFinished"); @@ -440,6 +448,11 @@ public class DumbServiceImpl extends DumbService implements Disposable { return result.get(); } + @Override + public long getModificationCount() { + return myModificationCount; + } + private class AppIconProgress extends ProgressIndicatorBase { private double lastFraction; diff --git a/platform/platform-resources-en/src/messages/ActionsBundle.properties b/platform/platform-resources-en/src/messages/ActionsBundle.properties index 727d96663ff5..89f48f1340cc 100644 --- a/platform/platform-resources-en/src/messages/ActionsBundle.properties +++ b/platform/platform-resources-en/src/messages/ActionsBundle.properties @@ -228,8 +228,8 @@ action.NewClass.text=Java Class action.NewFile.text=File action.NewDir.text=Directory/Package action.NewFromTemplate.text=From Template -action.CompareTwoFiles.text=Compare Two _Files -action.CompareTwoFiles.description=Compare two selected files +action.CompareTwoFiles.text=Compare _Files +action.CompareTwoFiles.description=Compare two selected files or folders action.CompareFileWithEditor.text=Co_mpare File with Editor action.CompareFileWithEditor.description=Compare selected file with editor action.ShowQuickDocAtPinnedWindowFromTooltip.text=Full documentation in a pinned window diff --git a/platform/platform-resources/src/brokenPlugins.txt b/platform/platform-resources/src/brokenPlugins.txt index f0219611dcb5..d9fe7ef3fa2b 100644 --- a/platform/platform-resources/src/brokenPlugins.txt +++ b/platform/platform-resources/src/brokenPlugins.txt @@ -7,7 +7,7 @@ com.jetbrains.lang.ejs 131.17 131.12 com.jetbrains.twig 133.51 130.1639 org.jetbrains.plugins.ruby 7.0.0.20150216 7.0.0.20150204 7.0.0.20141010 7.0.0.20140915 7.0.0.20140901 7.0.0.20140807 6.0.0.20140207 6.5.2.20140512 7.0.0.20140704 7.0.0.20140707 7.0.0.20140724 Pythonid 3.1 4.0.25 4.0.26 -Karma 138.1684 138.1879 138.317 138.21 134.1163 134.1039 134.686 134.31 +Karma 140.2109 138.1684 138.1879 138.317 138.21 134.1163 134.1039 134.686 134.31 org.intellij.scala 1.2.67.3.EAP 1.3.2-14.1 1.3.3-14.1 1.0.93.10.EAP 1.0.93.4.EAP 1.0.93.9.EAP 1.0.58 1.0.16 1.0.14 1.0.13 0.42.28 0.42.23 0.40.20 0.40.18 0.40.16 0.32.593 0.32.562 0.32.558 0.32.550 0.32.520 0.32.512 org.jetbrains.kannotator 0.2.420 org.jetbrains.kotlin 0.10.555 0.10.4 0.8.1615 0.7.1360 0.7.1376 0.8.7 diff --git a/platform/platform-tests/testSrc/com/intellij/usages/impl/UsageViewManagerTest.java b/platform/platform-tests/testSrc/com/intellij/usages/impl/UsageViewManagerTest.java index 3e38bd2bbb4a..a4fd1b4c881b 100644 --- a/platform/platform-tests/testSrc/com/intellij/usages/impl/UsageViewManagerTest.java +++ b/platform/platform-tests/testSrc/com/intellij/usages/impl/UsageViewManagerTest.java @@ -25,6 +25,11 @@ import com.intellij.usages.UsageTarget; import com.intellij.usages.UsageViewManager; public class UsageViewManagerTest extends PlatformTestCase { + + static { + initPlatformLangPrefix(); + } + public void testScopeCreatedForFindInDirectory() { VirtualFile dir = getProject().getBaseDir(); FindModel findModel = new FindModel(); @@ -36,4 +41,14 @@ public class UsageViewManagerTest extends PlatformTestCase { SearchScope scope = manager.getMaxSearchScopeToWarnOfFallingOutOf(new UsageTarget[]{target}); assertEquals(scope, GlobalSearchScopesCore.directoryScope(getProject(), dir, true)); } + + public void testScopeCreatedForFindInModuleContent() { + FindModel findModel = new FindModel(); + findModel.setModuleName(getModule().getName()); + findModel.setProjectScope(false); + UsageTarget target = new FindInProjectUtil.StringUsageTarget(getProject(), findModel); + UsageViewManagerImpl manager = (UsageViewManagerImpl)UsageViewManager.getInstance(getProject()); + SearchScope scope = manager.getMaxSearchScopeToWarnOfFallingOutOf(new UsageTarget[]{target}); + assertEquals(scope, getModule().getModuleContentScope()); + } } diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index c324e0870738..1613d3e292e3 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -257,6 +257,9 @@ java.annotations.inference.nullable.method.description=Restart is required; infe java.annotations.inference.nullable.method.transitivity=true java.annotations.inference.nullable.method.transitivity.description=Restart is required; if a method result is a call to a @Nullable method, reports the caller as @Nullable as well +java.correct.class.type.by.place.resolve.scope=true +java.correct.class.type.by.place.resolve.scope.description=When resolving Java references, use the resolve scope of the currently processed source file + documentation.component.editor.font=false ide.completion.show.better.matching.classes=true diff --git a/platform/vcs-api/src/com/intellij/openapi/diff/impl/patch/PatchReader.java b/platform/vcs-api/src/com/intellij/openapi/diff/impl/patch/PatchReader.java index 0e51740f4c48..f17109fe4353 100644 --- a/platform/vcs-api/src/com/intellij/openapi/diff/impl/patch/PatchReader.java +++ b/platform/vcs-api/src/com/intellij/openapi/diff/impl/patch/PatchReader.java @@ -55,10 +55,10 @@ public class PatchReader { this(patchContent, true); } - public PatchReader(CharSequence patchContent, boolean parseHunks) { + public PatchReader(CharSequence patchContent, boolean saveHunks) { myLines = LineTokenizer.tokenizeIntoList(patchContent, false); - myAdditionalInfoParser = new AdditionalInfoParser(!parseHunks); - myPatchContentParser = new PatchContentParser(parseHunks); + myAdditionalInfoParser = new AdditionalInfoParser(!saveHunks); + myPatchContentParser = new PatchContentParser(saveHunks); } public List readAllPatches() throws PatchSyntaxException { @@ -254,15 +254,15 @@ public class PatchReader { private static class PatchContentParser implements Parser { - private final boolean myParseHunks; + private final boolean mySaveHunks; private DiffFormat myDiffFormat = null; private final List myPatches; private boolean myDiffCommandLike; private boolean myIndexLike; - private PatchContentParser(boolean parseHunks) { - myParseHunks = parseHunks; + private PatchContentParser(boolean saveHunks) { + mySaveHunks = saveHunks; myPatches = new SmartList(); } @@ -303,7 +303,7 @@ public class PatchReader { } private TextFilePatch readPatch(String curLine, ListIterator iterator) throws PatchSyntaxException { - final TextFilePatch curPatch = new TextFilePatch(null); + final TextFilePatch curPatch = mySaveHunks ? new TextFilePatch(null) : new EmptyTextFilePatch(); extractFileName(curLine, curPatch, true, myDiffCommandLike && myIndexLike); if (! iterator.hasNext()) throw new PatchSyntaxException(iterator.previousIndex(), "Second file name expected"); @@ -314,7 +314,7 @@ public class PatchReader { } extractFileName(curLine, curPatch, false, myDiffCommandLike && myIndexLike); - while (myParseHunks && iterator.hasNext()) { + while (iterator.hasNext()) { PatchHunk hunk; if (myDiffFormat == DiffFormat.UNIFIED) { hunk = readNextHunkUnified(iterator); @@ -595,4 +595,37 @@ public class PatchReader { boolean testIsStart(final String start); void parse(final String start, final ListIterator iterator) throws PatchSyntaxException; } + + private static class EmptyTextFilePatch extends TextFilePatch { + private int myHunkCount = 0; + private boolean myNew; + private boolean myDeleted; + + EmptyTextFilePatch() { + super(null); + } + + @Override + public void addHunk(PatchHunk hunk) { + if (myHunkCount == 0) { + if (hunk.isNewContent()) { + myNew = true; + } + else if (hunk.isDeletedContent()) { + myDeleted = true; + } + } + myHunkCount++; + } + + @Override + public boolean isNewFile() { + return myHunkCount == 1 && myNew; + } + + @Override + public boolean isDeletedFile() { + return myHunkCount == 1 && myDeleted; + } + } } diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java index ab79d9af9be1..5f5aa460d640 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java @@ -399,23 +399,25 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C @NotNull public Selection getSelection() { - return new Selection(); + return new Selection(this); } - public class Selection { + public static class Selection { private final TIntHashSet myCommits; + private final VcsLogGraphTable myTable; - public Selection() { - myCommits = getCommitsAtRows(myDataPack.getVisibleGraph(), getSelectedRows()); + public Selection(@NotNull VcsLogGraphTable table) { + myTable = table; + myCommits = getCommitsAtRows(myTable.myDataPack.getVisibleGraph(), myTable.getSelectedRows()); } public void restore(@NotNull VisibleGraph newVisibleGraph) { - TIntHashSet rowsToSelect = findNewRowsToSelect(getGraphTableModel(), newVisibleGraph, myCommits); + TIntHashSet rowsToSelect = findNewRowsToSelect(myTable.getGraphTableModel(), newVisibleGraph, myCommits); if (!rowsToSelect.isEmpty()) { rowsToSelect.forEach(new TIntProcedure() { @Override public boolean execute(int row) { - addRowSelectionInterval(row, row); + myTable.addRowSelectionInterval(row, row); return true; } }); diff --git a/python/educational/interactive-learning/src/com/jetbrains/edu/learning/run/StudySmartChecker.java b/python/educational/interactive-learning/src/com/jetbrains/edu/learning/run/StudySmartChecker.java index 43928034db0f..bf2b59999b11 100644 --- a/python/educational/interactive-learning/src/com/jetbrains/edu/learning/run/StudySmartChecker.java +++ b/python/educational/interactive-learning/src/com/jetbrains/edu/learning/run/StudySmartChecker.java @@ -27,25 +27,28 @@ public class StudySmartChecker { private StudySmartChecker() { } + private static final Logger LOG = Logger.getInstance(StudySmartChecker.class); public static void smartCheck(@NotNull final AnswerPlaceholder placeholder, - @NotNull final Project project, - @NotNull final VirtualFile answerFile, - @NotNull final TaskFile answerTaskFile, - @NotNull final TaskFile usersTaskFile, - @NotNull final StudyTestRunner testRunner, - @NotNull final VirtualFile virtualFile, - @NotNull final Document usersDocument) { + @NotNull final Project project, + @NotNull final VirtualFile answerFile, + @NotNull final TaskFile answerTaskFile, + @NotNull final TaskFile usersTaskFile, + @NotNull final StudyTestRunner testRunner, + @NotNull final VirtualFile virtualFile, + @NotNull final Document usersDocument) { try { final int index = placeholder.getIndex(); + String windowCopyName = answerFile.getNameWithoutExtension() + index + EduNames.WINDOW_POSTFIX + answerFile.getExtension(); final VirtualFile windowCopy = - answerFile.copy(project, answerFile.getParent(), answerFile.getNameWithoutExtension() + index + EduNames.WINDOW_POSTFIX); + answerFile.copy(project, answerFile.getParent(), windowCopyName); final FileDocumentManager documentManager = FileDocumentManager.getInstance(); final Document windowDocument = documentManager.getDocument(windowCopy); if (windowDocument != null) { - final File resourceFile = StudyUtils.copyResourceFile(virtualFile.getName(), windowCopy.getName(), project, usersTaskFile.getTask()); + final File resourceFile = + StudyUtils.copyResourceFile(virtualFile.getName(), windowCopy.getName(), project, usersTaskFile.getTask()); final TaskFile windowTaskFile = new TaskFile(); TaskFile.copy(answerTaskFile, windowTaskFile); EduDocumentListener listener = new EduDocumentListener(windowTaskFile); @@ -85,5 +88,4 @@ public class StudySmartChecker { LOG.error(e); } } - } diff --git a/python/educational/src/com/jetbrains/edu/EduNames.java b/python/educational/src/com/jetbrains/edu/EduNames.java index 8295735ca9d0..882a2ef9e7ef 100644 --- a/python/educational/src/com/jetbrains/edu/EduNames.java +++ b/python/educational/src/com/jetbrains/edu/EduNames.java @@ -25,7 +25,7 @@ public class EduNames { public static final String TEST_TAB_NAME = "test"; public static final String USER_TEST_INPUT = "input"; public static final String USER_TEST_OUTPUT = "output"; - public static final String WINDOW_POSTFIX = "_window.py"; + public static final String WINDOW_POSTFIX = "_window."; public static final String TASK = "task"; public static final String USER_TESTS = "userTests"; public static final String SANDBOX_DIR = "Sandbox"; diff --git a/python/educational/src/com/jetbrains/edu/stepic/CourseInfo.java b/python/educational/src/com/jetbrains/edu/stepic/CourseInfo.java index 161dc10b059b..38815badc45b 100644 --- a/python/educational/src/com/jetbrains/edu/stepic/CourseInfo.java +++ b/python/educational/src/com/jetbrains/edu/stepic/CourseInfo.java @@ -15,14 +15,18 @@ public class CourseInfo { private String myName; @SerializedName("summary") private String myDescription; + @SerializedName("course_format") + //course type in format "pycharm " + private String myType; private String myAuthor; - public static CourseInfo INVALID_COURSE = new CourseInfo("", "", ""); + public static CourseInfo INVALID_COURSE = new CourseInfo("", "", "", ""); - public CourseInfo(String name, String author, String description) { + public CourseInfo(String name, String author, String description, String type) { myName = name; myAuthor = author; myDescription = description; + myType = type; } public String getName() { @@ -37,6 +41,10 @@ public class CourseInfo { return myDescription; } + public String getType() { + return myType; + } + @Override public String toString() { return myName; diff --git a/python/educational/src/com/jetbrains/edu/stepic/EduStepicConnector.java b/python/educational/src/com/jetbrains/edu/stepic/EduStepicConnector.java index a6e45bbd7c03..56bd969aa9f8 100644 --- a/python/educational/src/com/jetbrains/edu/stepic/EduStepicConnector.java +++ b/python/educational/src/com/jetbrains/edu/stepic/EduStepicConnector.java @@ -41,6 +41,8 @@ public class EduStepicConnector { private static final String ourDomain = "stepic.org"; private static String ourSessionId = "524iethiwju2tjywaqmf7tbwx0p0jk1b"; private static String ourCSRFToken = "LJ9n6OyLVA7hxU94dlYWUu65MF51Nx37"; + //this prefix indicates that course can be opened by educational plugin + public static final String PYCHARM_PREFIX = "pycharm "; private EduStepicConnector() { } @@ -84,7 +86,8 @@ public class EduStepicConnector { course.setAuthor(info.getAuthor()); course.setDescription(info.getDescription()); course.setName(info.getName()); - course.setLanguage("Python"); // TODO: get from stepic + String courseType = info.getType(); + course.setLanguage(courseType.substring(PYCHARM_PREFIX.length())); course.setUpToDate(true); // TODO: get from stepic try { for (Integer section : info.sections) { diff --git a/xml/tests/src/com/intellij/codeInsight/daemon/XmlHighlightingTest.java b/xml/tests/src/com/intellij/codeInsight/daemon/XmlHighlightingTest.java index d88422df2127..d30c87b7bfd3 100644 --- a/xml/tests/src/com/intellij/codeInsight/daemon/XmlHighlightingTest.java +++ b/xml/tests/src/com/intellij/codeInsight/daemon/XmlHighlightingTest.java @@ -49,6 +49,7 @@ import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.highlighter.EditorHighlighter; import com.intellij.openapi.editor.highlighter.HighlighterIterator; import com.intellij.openapi.fileTypes.StdFileTypes; +import com.intellij.openapi.project.DumbServiceImpl; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VfsUtilCore; @@ -64,6 +65,7 @@ import com.intellij.util.Processor; import com.intellij.util.containers.ContainerUtil; import com.intellij.xml.XmlAttributeDescriptor; import com.intellij.xml.XmlBundle; +import com.intellij.xml.XmlElementDescriptor; import com.intellij.xml.impl.schema.XmlElementDescriptorImpl; import com.intellij.xml.util.*; import gnu.trove.THashSet; @@ -1422,7 +1424,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { Editor[] allEditors = EditorFactory.getInstance().getAllEditors(); final Editor schemaEditor = allEditors[0] == myEditor ? allEditors[1]:allEditors[0]; final String text = schemaEditor.getDocument().getText(); - final String newText = text.replaceAll("xsd","xs"); + final String newText = text.replaceAll("xsd", "xs"); WriteCommandAction.runWriteCommandAction(null, new Runnable(){ @Override public void run() { @@ -1767,7 +1769,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { final String testName = getTestName(false); String[][] urls = { {"urn:jboss:bean-deployer:2.0", testName + ".xsd"}, - {null, testName + "_2.xsd"} + {"", testName + "_2.xsd"} }; doTestWithLocations(urls,"xml"); } @@ -2082,6 +2084,26 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { assertTrue(resolve instanceof XmlTag); } + public void testDropAnyAttributeCacheOnExitFromDumbMode() throws Exception { + try { + DumbServiceImpl.getInstance(myProject).setDumb(true); + configureByFiles(null, getVirtualFile(BASE_PATH + "AnyAttributeNavigation/test.xml"), + getVirtualFile(BASE_PATH + "AnyAttributeNavigation/test.xsd"), + getVirtualFile(BASE_PATH + "AnyAttributeNavigation/library.xsd")); + PsiReference at = getFile().findReferenceAt(getEditor().getCaretModel().getOffset()); + + XmlTag tag = PsiTreeUtil.getParentOfType(at.getElement(), XmlTag.class); + XmlElementDescriptor descriptor = tag.getDescriptor(); + XmlAttributeDescriptor[] descriptors = descriptor.getAttributesDescriptors(tag); + System.out.println(Arrays.asList(descriptors)); + } + finally { + DumbServiceImpl.getInstance(myProject).setDumb(false); + } + + doDoTest(true, false); + } + public void testQualifiedAttributeReference() throws Exception { configureByFiles(null, BASE_PATH + "qualified.xml", BASE_PATH + "qualified.xsd"); doDoTest(true, false); diff --git a/xml/xml-psi-api/src/com/intellij/javaee/ExternalResourceManager.java b/xml/xml-psi-api/src/com/intellij/javaee/ExternalResourceManager.java index 05f7d7c037ca..0c5a63e57b5a 100644 --- a/xml/xml-psi-api/src/com/intellij/javaee/ExternalResourceManager.java +++ b/xml/xml-psi-api/src/com/intellij/javaee/ExternalResourceManager.java @@ -38,7 +38,7 @@ public abstract class ExternalResourceManager extends SimpleModificationTracker public abstract void removeResource(@NotNull String url, @Nullable String version); /** - * @see #getResourceLocation(String, com.intellij.openapi.project.Project) + * @see #getResourceLocation(String, Project) */ @Deprecated public abstract String getResourceLocation(@NotNull @NonNls String url); diff --git a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/ComplexTypeDescriptor.java b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/ComplexTypeDescriptor.java index e86f655bc6d1..c18db0fec59d 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/ComplexTypeDescriptor.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/ComplexTypeDescriptor.java @@ -15,10 +15,10 @@ */ package com.intellij.xml.impl.schema; +import com.intellij.openapi.project.DumbService; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.FieldCache; import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiFile; import com.intellij.psi.impl.source.resolve.reference.impl.providers.SchemaReferencesProvider; import com.intellij.psi.meta.PsiMetaData; import com.intellij.psi.util.CachedValue; @@ -85,17 +85,21 @@ public class ComplexTypeDescriptor extends TypeDescriptor { } }; + @SuppressWarnings("MismatchedQueryAndUpdateOfCollection") private final FactoryMap> myAnyAttributeCache = new ConcurrentFactoryMap>() { @Override protected CachedValue create(final String key) { return CachedValuesManager.getManager(myTag.getProject()).createCachedValue(new CachedValueProvider() { @Override public Result compute() { - THashSet dependencies = new THashSet(); + THashSet dependencies = new THashSet(); CanContainAttributeType type = _canContainAttribute(key, myTag, null, new THashSet(), dependencies); if (dependencies.isEmpty()) { dependencies.add(myTag.getContainingFile()); } + if (DumbService.isDumb(myTag.getProject())) { + dependencies.add(DumbService.getInstance(myTag.getProject()).getModificationTracker()); + } return Result.create(type, ArrayUtil.toObjectArray(dependencies)); } }, false); @@ -398,7 +402,7 @@ public class ComplexTypeDescriptor extends TypeDescriptor { XmlTag tag, @Nullable String qName, Set visited, - @Nullable Set dependencies) { + @Nullable Set dependencies) { if (XmlNSDescriptorImpl.equalsToSchemaName(tag, "anyAttribute")) { if (dependencies != null) { dependencies.add(tag.getContainingFile());