diff --git a/RegExpSupport/test/test/BaseParseTestcase.java b/RegExpSupport/test/test/BaseParseTestcase.java index ccdf656619e3..e6cb0fc0d726 100644 --- a/RegExpSupport/test/test/BaseParseTestcase.java +++ b/RegExpSupport/test/test/BaseParseTestcase.java @@ -43,7 +43,7 @@ public abstract class BaseParseTestcase extends UsefulTestCase{ protected void setUp() throws Exception { super.setUp(); final IdeaTestFixtureFactory fixtureFactory = IdeaTestFixtureFactory.getFixtureFactory(); - final TestFixtureBuilder builder = fixtureFactory.createFixtureBuilder(); + final TestFixtureBuilder builder = fixtureFactory.createFixtureBuilder(getName()); myFixture = fixtureFactory.createCodeInsightFixture(builder.getFixture()); myFixture.setTestDataPath(getTestDataPath()); diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/api/CompAPIDriver.java b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/api/CompAPIDriver.java index 39d8996e296a..f4353c85a8e5 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/api/CompAPIDriver.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/api/CompAPIDriver.java @@ -27,6 +27,7 @@ import javax.tools.*; import java.io.File; import java.io.IOException; import java.io.PrintWriter; +import java.lang.reflect.Field; import java.net.URI; import java.util.List; import java.util.concurrent.BlockingQueue; @@ -145,6 +146,18 @@ class CompAPIDriver { assert !processing; //assert myCompilationResults.isEmpty() : myCompilationResults; myCompilationResults.clear(); + cleanupInternalFields(); + } + + private static void cleanupInternalFields() { + try { + Field freelist = Class.forName("com.sun.tools.javac.util.SharedNameTable").getDeclaredField("freelist"); + freelist.setAccessible(true); + freelist.set(null, com.sun.tools.javac.util.List.nil()); + } + catch (Exception ignored) { + + } } public void offerClassFile(URI uri, byte[] bytes) { diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/nodes/PackagingElementNode.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/nodes/PackagingElementNode.java index 74f8c0882532..e4e49aa18b0e 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/nodes/PackagingElementNode.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/nodes/PackagingElementNode.java @@ -80,6 +80,7 @@ public class PackagingElementNode> extends Artifac return myPackagingElements.size() == 1 ? myPackagingElements.get(0) : null; } + @NotNull @Override public Object[] getEqualityObjects() { return ArrayUtil.toObjectArray(myPackagingElements); diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/sourceItems/SourceItemNode.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/sourceItems/SourceItemNode.java index 35dcd13d1c2d..3abe7671318a 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/sourceItems/SourceItemNode.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/sourceItems/SourceItemNode.java @@ -20,6 +20,7 @@ import com.intellij.openapi.roots.ui.configuration.artifacts.ArtifactEditorEx; import com.intellij.packaging.ui.ArtifactEditorContext; import com.intellij.packaging.ui.PackagingSourceItem; import com.intellij.ui.treeStructure.SimpleTree; +import org.jetbrains.annotations.NotNull; import java.awt.event.InputEvent; import java.util.Collections; @@ -35,6 +36,7 @@ public class SourceItemNode extends SourceItemNodeBase { mySourceItem = sourceItem; } + @NotNull @Override public Object[] getEqualityObjects() { return new Object[]{mySourceItem}; diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/sourceItems/SourceItemsTreeRoot.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/sourceItems/SourceItemsTreeRoot.java index c094f3caa5bc..fa83689521e5 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/sourceItems/SourceItemsTreeRoot.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/sourceItems/SourceItemsTreeRoot.java @@ -35,6 +35,7 @@ public class SourceItemsTreeRoot extends SourceItemNodeBase { return null; } + @NotNull @Override public Object[] getEqualityObjects() { return new Object[]{"root"}; diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/ProjectStructureDaemonAnalyzer.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/ProjectStructureDaemonAnalyzer.java index 7d1e7c43b49f..b63cc1e5592e 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/ProjectStructureDaemonAnalyzer.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/ProjectStructureDaemonAnalyzer.java @@ -290,6 +290,7 @@ public class ProjectStructureDaemonAnalyzer implements Disposable { return myElement.equals(other.myElement) && (!other.myCheck || myCheck) && (!other.myCollectUsages || myCollectUsages); } + @NotNull @Override public Object[] getEqualityObjects() { return myEqualityObjects; diff --git a/java/idea-ui/src/com/intellij/util/ui/classpath/ChooseLibrariesDialogBase.java b/java/idea-ui/src/com/intellij/util/ui/classpath/ChooseLibrariesDialogBase.java index 2598cc730981..97649e847afb 100644 --- a/java/idea-ui/src/com/intellij/util/ui/classpath/ChooseLibrariesDialogBase.java +++ b/java/idea-ui/src/com/intellij/util/ui/classpath/ChooseLibrariesDialogBase.java @@ -269,6 +269,7 @@ public abstract class ChooseLibrariesDialogBase extends DialogWrapper { return 0; } + @NotNull @Override public Object[] getEqualityObjects() { return new Object[] {myElement}; diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressAllForClassFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressAllForClassFix.java index 3f43a51568b0..c06a82b1062f 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressAllForClassFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressAllForClassFix.java @@ -66,7 +66,7 @@ public class SuppressAllForClassFix extends SuppressFix { } @Override - public void invoke(final Project project, final Editor editor, final PsiElement element) throws IncorrectOperationException { + public void invoke(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) throws IncorrectOperationException { final PsiDocCommentOwner container = getContainer(element); LOG.assertTrue(container != null); if (!CodeInsightUtilBase.preparePsiElementForWrite(container)) return; diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressFix.java index 2c5cd77301aa..a8464dc6c9c8 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressFix.java @@ -105,7 +105,7 @@ public class SuppressFix extends SuppressIntentionAction { } @Override - public void invoke(final Project project, final Editor editor, final PsiElement element) throws IncorrectOperationException { + public void invoke(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) throws IncorrectOperationException { PsiDocCommentOwner container = getContainer(element); assert container != null; if (!CodeInsightUtilBase.preparePsiElementForWrite(container)) return; diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressParameterFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressParameterFix.java index dbd6e2f38cc0..49682f21e312 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressParameterFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressParameterFix.java @@ -66,7 +66,7 @@ public class SuppressParameterFix extends SuppressIntentionAction { } @Override - public void invoke(final Project project, final Editor editor, final PsiElement element) throws IncorrectOperationException { + public void invoke(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) throws IncorrectOperationException { PsiParameter container = PsiTreeUtil.getParentOfType(element, PsiParameter.class, false); assert container != null; if (!CodeInsightUtilBase.preparePsiElementForWrite(container)) return; diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java index 4a0ed7347583..4b7f8ce86cda 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java @@ -26,6 +26,7 @@ import com.intellij.codeInsight.intention.QuickFixFactory; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.IndexNotReadyException; import com.intellij.openapi.project.Project; +import com.intellij.openapi.projectRoots.JavaSdkVersion; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.TextRange; import com.intellij.pom.java.LanguageLevel; @@ -505,7 +506,17 @@ public class GenericsHighlightUtil { final PsiType retErasure1 = TypeConversionUtil.erasure(checkMethod.getReturnType()); final PsiType retErasure2 = TypeConversionUtil.erasure(superMethod.getReturnType()); - if (!Comparing.equal(retErasure1, retErasure2) && + + boolean differentReturnTypeErasure = !Comparing.equal(retErasure1, retErasure2); + if (checkEqualsSuper && JavaSdkVersion.isAtLeast(checkMethod, JavaSdkVersion.JDK_1_7)) { + if (retErasure1 != null && retErasure2 != null) { + differentReturnTypeErasure = !TypeConversionUtil.isAssignable(retErasure1, retErasure2); + } else { + differentReturnTypeErasure = !(retErasure1 == null && retErasure2 == null); + } + } + + if (differentReturnTypeErasure && !TypeConversionUtil.isVoidType(retErasure1) && !TypeConversionUtil.isVoidType(retErasure2) && !(checkEqualsSuper && Arrays.equals(superSignature.getParameterTypes(), signatureToCheck.getParameterTypes()))) { diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/DelegateWithDefaultParamValueIntentionAction.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/DelegateWithDefaultParamValueIntentionAction.java index dc09b28a11e4..4348764edd35 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/DelegateWithDefaultParamValueIntentionAction.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/DelegateWithDefaultParamValueIntentionAction.java @@ -83,7 +83,7 @@ public class DelegateWithDefaultParamValueIntentionAction extends PsiElementBase } @Override - public void invoke(Project project, Editor editor, PsiElement element) throws IncorrectOperationException { + public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException { final PsiParameter parameter = PsiTreeUtil.getParentOfType(element, PsiParameter.class); final PsiMethod method = (PsiMethod)parameter.getDeclarationScope(); final PsiMethod prototype = (PsiMethod)method.getContainingClass().addBefore(generateMethodPrototype(method, parameter), method); diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/IterateOverIterableIntention.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/IterateOverIterableIntention.java index 514d5f78efaf..74ab0409705a 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/IterateOverIterableIntention.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/IterateOverIterableIntention.java @@ -112,7 +112,9 @@ public class IterateOverIterableIntention implements IntentionAction { element = ((PsiExpressionStatement)element).getExpression().getLastChild(); } while ((element = PsiTreeUtil.getParentOfType(element, PsiExpression.class, true)) != null) { - if (element.getParent() instanceof PsiMethodCallExpression) continue; + final PsiElement parent = element.getParent(); + if (parent instanceof PsiMethodCallExpression) continue; + if (!(parent instanceof PsiExpressionStatement)) return null; final PsiType type = ((PsiExpression)element).getType(); if (type instanceof PsiArrayType || InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_LANG_ITERABLE)) return (PsiExpression)element; } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QualifyThisArgumentFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QualifyThisArgumentFix.java index ff23c5fcaa12..a5cfce5dd068 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QualifyThisArgumentFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QualifyThisArgumentFix.java @@ -66,7 +66,7 @@ public class QualifyThisArgumentFix extends PsiElementBaseIntentionAction { } @Override - public void invoke(Project project, Editor editor, PsiElement element) throws IncorrectOperationException { + public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException { myExpression.replace(RefactoringUtil.createThisExpression(PsiManager.getInstance(project), myPsiClass)); } diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/InsertLiteralUnderscoresAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/InsertLiteralUnderscoresAction.java index 281a18d78abc..0681808cea69 100644 --- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/InsertLiteralUnderscoresAction.java +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/InsertLiteralUnderscoresAction.java @@ -46,7 +46,7 @@ public class InsertLiteralUnderscoresAction extends PsiElementBaseIntentionActio } @Override - public void invoke(final Project project, final Editor editor, final PsiElement element) throws IncorrectOperationException { + public void invoke(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) throws IncorrectOperationException { final PsiLiteralExpression literalExpression = PsiTreeUtil.getParentOfType(element, PsiLiteralExpression.class, false); if (literalExpression == null) return; diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/RemoveLiteralUnderscoresAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/RemoveLiteralUnderscoresAction.java index 4207625a54ca..320104e934de 100644 --- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/RemoveLiteralUnderscoresAction.java +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/RemoveLiteralUnderscoresAction.java @@ -40,7 +40,7 @@ public class RemoveLiteralUnderscoresAction extends PsiElementBaseIntentionActio } @Override - public void invoke(final Project project, final Editor editor, final PsiElement element) throws IncorrectOperationException { + public void invoke(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) throws IncorrectOperationException { final PsiLiteralExpression literalExpression = PsiTreeUtil.getParentOfType(element, PsiLiteralExpression.class, false); if (literalExpression == null) return; diff --git a/java/java-impl/src/com/intellij/openapi/projectRoots/impl/JavaSdkImpl.java b/java/java-impl/src/com/intellij/openapi/projectRoots/impl/JavaSdkImpl.java index ace9c134e0a7..005be2d1bd4f 100644 --- a/java/java-impl/src/com/intellij/openapi/projectRoots/impl/JavaSdkImpl.java +++ b/java/java-impl/src/com/intellij/openapi/projectRoots/impl/JavaSdkImpl.java @@ -15,6 +15,7 @@ */ package com.intellij.openapi.projectRoots.impl; +import com.intellij.execution.util.ExecUtil; import com.intellij.openapi.application.PathManager; import com.intellij.openapi.project.ProjectBundle; import com.intellij.openapi.projectRoots.*; @@ -154,33 +155,27 @@ public class JavaSdkImpl extends JavaSdk { public String suggestHomePath() { if (SystemInfo.isMac) { if (new File("/usr/libexec/java_home").exists()) { - try { - final Process exec = Runtime.getRuntime().exec("/usr/libexec/java_home"); - final BufferedReader input = new BufferedReader(new InputStreamReader(exec.getInputStream())); - try { - final String path = input.readLine(); - if (new File(path).exists()) return path; - } - finally { - input.close(); - } + final String path = ExecUtil.execAndReadLine("/usr/libexec/java_home"); + if (path != null && new File(path).exists()) { + return path; } - catch (IOException ignore) { } } - - return "/System/Library/Frameworks/JavaVM.framework/Versions/"; + return "/System/Library/Frameworks/JavaVM.framework/Versions"; } + if (SystemInfo.isLinux) { - final String[] homes = {"/usr/java", "/opt/java", "/usr/lib/jvm/"}; + final String[] homes = {"/usr/java", "/opt/java", "/usr/lib/jvm"}; for (String home : homes) { if (new File(home).isDirectory()) { return home; } } } + if (SystemInfo.isSolaris) { - return "/usr/jdk/"; + return "/usr/jdk"; } + return null; } diff --git a/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpDialog.java b/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpDialog.java index 5d06e931eab2..d960ac43f833 100644 --- a/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpDialog.java +++ b/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpDialog.java @@ -192,10 +192,14 @@ public class PullUpDialog extends RefactoringDialog { protected void doAction() { if (!myCallback.checkConflicts(this)) return; JavaRefactoringSettings.getInstance().PULL_UP_MEMBERS_JAVADOC = myJavaDocPanel.getPolicy(); - StatisticsManager - .getInstance().incUseCount(new StatisticsInfo(PULL_UP_STATISTICS_KEY + myClass.getQualifiedName(), getSuperClass().getQualifiedName())); + final PsiClass superClass = getSuperClass(); + String name = superClass.getQualifiedName(); + if (name != null) { + StatisticsManager + .getInstance().incUseCount(new StatisticsInfo(PULL_UP_STATISTICS_KEY + myClass.getQualifiedName(), name)); + } - invokeRefactoring(new PullUpHelper(myClass, getSuperClass(), getSelectedMemberInfos(), + invokeRefactoring(new PullUpHelper(myClass, superClass, getSelectedMemberInfos(), new DocCommentPolicy(getJavaDocPolicy()))); close(OK_EXIT_CODE); } diff --git a/java/java-impl/src/com/intellij/refactoring/util/RefactoringHierarchyUtil.java b/java/java-impl/src/com/intellij/refactoring/util/RefactoringHierarchyUtil.java index fda1ea726c1e..c46864483270 100644 --- a/java/java-impl/src/com/intellij/refactoring/util/RefactoringHierarchyUtil.java +++ b/java/java-impl/src/com/intellij/refactoring/util/RefactoringHierarchyUtil.java @@ -25,6 +25,7 @@ package com.intellij.refactoring.util; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.util.Comparing; import com.intellij.psi.*; import com.intellij.psi.search.PsiElementProcessor; import com.intellij.psi.search.PsiElementProcessorAdapter; @@ -129,7 +130,13 @@ public class RefactoringHierarchyUtil { Collections.sort( basesList, new Comparator() { public int compare(PsiClass c1, PsiClass c2) { - return c1.getQualifiedName().compareTo(c2.getQualifiedName()); + final String fqn1 = c1.getQualifiedName(); + final String fqn2 = c2.getQualifiedName(); + if (fqn1 != null && fqn2 != null) return fqn1.compareTo(fqn2); + if (fqn1 == null && fqn2 == null) { + return Comparing.compare(c1.getName(), c2.getName()); + } + return fqn1 == null ? 1 : -1; } } ); diff --git a/java/java-impl/src/com/intellij/slicer/SliceNode.java b/java/java-impl/src/com/intellij/slicer/SliceNode.java index 7247b7f0e31b..df114e5f9751 100644 --- a/java/java-impl/src/com/intellij/slicer/SliceNode.java +++ b/java/java-impl/src/com/intellij/slicer/SliceNode.java @@ -144,6 +144,7 @@ public class SliceNode extends AbstractTreeNode implements Duplicate @Override protected PresentationData createPresentation() { return new PresentationData(){ + @NotNull @Override public Object[] getEqualityObjects() { return ArrayUtil.append(super.getEqualityObjects(), changed); diff --git a/java/java-psi-impl/src/com/intellij/psi/scope/processor/MethodCandidatesProcessor.java b/java/java-psi-impl/src/com/intellij/psi/scope/processor/MethodCandidatesProcessor.java index 79d526ac8ac7..b3dbf527fb1e 100644 --- a/java/java-psi-impl/src/com/intellij/psi/scope/processor/MethodCandidatesProcessor.java +++ b/java/java-psi-impl/src/com/intellij/psi/scope/processor/MethodCandidatesProcessor.java @@ -79,7 +79,7 @@ public class MethodCandidatesProcessor extends MethodsProcessor{ protected boolean isShadowed(final PsiMethod candidate) { if (myCurrentFileContext instanceof PsiImportStaticStatement) { - for (JavaResolveResult result : getResult()) { + for (JavaResolveResult result : getResults()) { if (result.getElement() != candidate && result.isAccessible() && !(result.getCurrentFileResolveScope() instanceof PsiImportStaticStatement)) return true; diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/SameErasureDifferentReturnTypes.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/SameErasureDifferentReturnTypes.java index f203f95c25de..8bbd7b65154a 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/SameErasureDifferentReturnTypes.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/SameErasureDifferentReturnTypes.java @@ -7,7 +7,7 @@ interface Matcher { } interface ArgumentConstraintPhrases { - T with(Matcher matcher); + T with(Matcher matcher); boolean with(Matcher matcher); byte with(Matcher matcher); short with(Matcher matcher); @@ -19,7 +19,7 @@ interface ArgumentConstraintPhrases { class ExpectationGroupBuilder implements ArgumentConstraintPhrases { - public T with(final Matcher matcher) { + public T with(final Matcher matcher) { return null; } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/SameErasureDifferentReturnTypesJdk14.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/SameErasureDifferentReturnTypesJdk14.java new file mode 100644 index 000000000000..b046069c784a --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/SameErasureDifferentReturnTypesJdk14.java @@ -0,0 +1,48 @@ +/** @noinspection UnusedDeclaration*/ +interface Matcher { + + boolean matches(Object object); + + void _dont_implement_Matcher___instead_extend_BaseMatcher_(); +} + +interface ArgumentConstraintPhrases { + T with(Matcher matcher); + boolean with(Matcher matcher); + byte with(Matcher matcher); + int with(Matcher matcher); + long with(Matcher matcher); + float with(Matcher matcher); + double with(Matcher matcher); +} + +class ExpectationGroupBuilder implements ArgumentConstraintPhrases { + + public T with(final Matcher matcher) { + return null; + } + + public boolean with(final Matcher matcher) { + return false; + } + + public byte with(final Matcher matcher) { + return 0; + } + + public int with(final Matcher matcher) { + return 0; + } + + public long with(final Matcher matcher) { + return 0; + } + + public float with(final Matcher matcher) { + return 0; + } + + public double with(final Matcher matcher) { + return 0; + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/iterateOver/before3.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/iterateOver/before3.java new file mode 100644 index 000000000000..b9ea90a0502e --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/iterateOver/before3.java @@ -0,0 +1,6 @@ +// "Iterate" "false" +class Test { + void foo() { + final Annotation[] annotations = getClass().getAnnotations(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/pullUp/after6.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/pullUp/after6.java new file mode 100644 index 000000000000..6934fb76215a --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/pullUp/after6.java @@ -0,0 +1,14 @@ +// "Pull method 'foo' to 'Foo' and make it abstract" "true" +public class Test { + void bar() { + abstract class Foo { + abstract void foo(); + } + class FooImpl extends Foo { + @Override + void foo(){} + } + } +} + + diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/pullUp/before6.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/pullUp/before6.java new file mode 100644 index 000000000000..6cefa7bc162a --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/pullUp/before6.java @@ -0,0 +1,12 @@ +// "Pull method 'foo' to 'Foo' and make it abstract" "true" +public class Test { + void bar() { + class Foo {} + class FooImpl extends Foo { + @Override + void foo(){} + } + } +} + + diff --git a/java/java-tests/testData/psi/resolve/class/ModuleSourceAsLibrarySource.java b/java/java-tests/testData/psi/resolve/class/ModuleSourceAsLibrarySource.java new file mode 100644 index 000000000000..ae7482c76f32 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/class/ModuleSourceAsLibrarySource.java @@ -0,0 +1,3 @@ +public class ModuleSourceAsLibrarySource { + ModuleSourceAsLibrarySourceDep field; +} diff --git a/java/java-tests/testData/psi/resolve/class/ModuleSourceAsLibrarySourceDep.java b/java/java-tests/testData/psi/resolve/class/ModuleSourceAsLibrarySourceDep.java new file mode 100644 index 000000000000..78a8b08ecc6f --- /dev/null +++ b/java/java-tests/testData/psi/resolve/class/ModuleSourceAsLibrarySourceDep.java @@ -0,0 +1 @@ +public class ModuleSourceAsLibrarySourceDep {} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/SuppressExternalTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/SuppressExternalTest.java index 02d1c996716b..a02a70ba3af8 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/SuppressExternalTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/SuppressExternalTest.java @@ -37,7 +37,7 @@ public class SuppressExternalTest extends UsefulTestCase { public void setUp() throws Exception { super.setUp(); final IdeaTestFixtureFactory fixtureFactory = IdeaTestFixtureFactory.getFixtureFactory(); - final TestFixtureBuilder testFixtureBuilder = fixtureFactory.createFixtureBuilder(); + final TestFixtureBuilder testFixtureBuilder = fixtureFactory.createFixtureBuilder(getName()); myFixture = JavaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(testFixtureBuilder.getFixture()); myFixture.setTestDataPath(PathManagerEx.getTestDataPath() + "/codeInsight/externalAnnotations"); final JavaModuleFixtureBuilder builder = testFixtureBuilder.addModule(JavaModuleFixtureBuilder.class); diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java index d33381ec1e2e..c8ed0105e79a 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java @@ -4,6 +4,8 @@ import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection; import com.intellij.codeInspection.unusedImport.UnusedImportLocalInspection; import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection; +import com.intellij.openapi.projectRoots.Sdk; +import com.intellij.openapi.projectRoots.impl.JavaSdkImpl; import com.intellij.openapi.roots.LanguageLevelProjectExtension; import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.PsiClass; @@ -34,6 +36,11 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase { LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(level); } + @Override + protected Sdk getProjectJDK() { + return getTestName(false).contains("Jdk14") ? JavaSdkImpl.getMockJdk14() : super.getProjectJDK(); + } + public void testReferenceTypeParams() throws Exception { doTest(false); } public void testOverridingMethods() throws Exception { doTest(false); } public void testTypeParameterBoundsList() throws Exception { doTest(false); } @@ -85,6 +92,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase { public void testGenericExtendException() throws Exception { doTest(false); } public void testSameErasureDifferentReturnTypes() throws Exception { doTest(false); } + public void testSameErasureDifferentReturnTypesJdk14() throws Exception { doTest(false); } public void testDeepConflictingReturnTypes() throws Exception { doTest(false); } public void testInheritFromTypeParameter() throws Exception { doTest(false); } public void testAnnotationsAsPartOfModifierList() throws Exception { doTest(false); } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/PullOverrideMethodUpFixTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/PullOverrideMethodUpFixTest.java index 2d6115085c70..5754db7eb2cb 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/PullOverrideMethodUpFixTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/PullOverrideMethodUpFixTest.java @@ -34,6 +34,10 @@ public class PullOverrideMethodUpFixTest extends LightQuickFixTestCase { doSingleTest("4.java"); } + public void test6() throws Exception { + doSingleTest("6.java"); + } + public void testRefactoringIntentionsAvailable() throws Exception { doTestActionAvailable(5, "Pull members up"); doTestActionAvailable(5, "Extract interface"); diff --git a/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveClassTest.java b/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveClassTest.java index b67073bfcbca..8eab910851f0 100644 --- a/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveClassTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveClassTest.java @@ -8,6 +8,7 @@ import com.intellij.openapi.module.StdModuleTypes; import com.intellij.openapi.roots.ContentEntry; import com.intellij.openapi.roots.ModifiableRootModel; import com.intellij.openapi.roots.ModuleRootManager; +import com.intellij.openapi.roots.OrderRootType; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; @@ -155,6 +156,16 @@ public class ResolveClassTest extends ResolveTestCase { assertNull(target); } + public void testModuleSourceAsLibrarySource() throws Exception { + final PsiReference ref = configure(); + final VirtualFile file = ref.getElement().getContainingFile().getVirtualFile(); + assertNotNull(file); + createFile(myModule, file.getParent(), "ModuleSourceAsLibrarySourceDep.java", loadFile("class/ModuleSourceAsLibrarySourceDep.java")); + addLibraryToRoots(file.getParent(), OrderRootType.SOURCES); + + assertInstanceOf(ref.resolve(), PsiClass.class); + } + public void testStaticImportInTheSameClass() throws Exception { PsiReference ref = configure(); long start = System.currentTimeMillis(); diff --git a/java/openapi/src/com/intellij/openapi/projectRoots/JavaSdkVersion.java b/java/openapi/src/com/intellij/openapi/projectRoots/JavaSdkVersion.java index 57a56966449f..2d7e6629ad3b 100644 --- a/java/openapi/src/com/intellij/openapi/projectRoots/JavaSdkVersion.java +++ b/java/openapi/src/com/intellij/openapi/projectRoots/JavaSdkVersion.java @@ -15,7 +15,11 @@ */ package com.intellij.openapi.projectRoots; +import com.intellij.openapi.module.Module; +import com.intellij.openapi.module.ModuleUtil; +import com.intellij.openapi.roots.ModuleRootManager; import com.intellij.pom.java.LanguageLevel; +import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull; import java.util.Arrays; @@ -70,4 +74,16 @@ public enum JavaSdkVersion { String.format("Can't map Java SDK by description (%s). Available values: %s", description, Arrays.toString(values())) ); } + + public static boolean isAtLeast(PsiElement element, JavaSdkVersion minVersion) { + final Module module = ModuleUtil.findModuleForPsiElement(element); + if (module != null) { + final Sdk sdk = ModuleRootManager.getInstance(module).getSdk(); + if (sdk != null && sdk.getSdkType() instanceof JavaSdk) { + final JavaSdkVersion version = JavaSdk.getInstance().getVersion(sdk); + return version != null && version.isAtLeast(minVersion); + } + } + return false; + } } diff --git a/java/testFramework/src/com/intellij/testFramework/PsiTestCase.java b/java/testFramework/src/com/intellij/testFramework/PsiTestCase.java index 35d132f23637..ec471600d9f5 100644 --- a/java/testFramework/src/com/intellij/testFramework/PsiTestCase.java +++ b/java/testFramework/src/com/intellij/testFramework/PsiTestCase.java @@ -216,7 +216,7 @@ public abstract class PsiTestCase extends ModuleTestCase { addLibraryToRoots(myModule, jarFile, rootType); } - protected static void addLibraryToRoots(final Module module, final VirtualFile jarFile, final OrderRootType rootType) { + protected static void addLibraryToRoots(final Module module, final VirtualFile root, final OrderRootType rootType) { ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { @@ -224,7 +224,7 @@ public abstract class PsiTestCase extends ModuleTestCase { final ModifiableRootModel rootModel = manager.getModifiableModel(); final Library jarLibrary = rootModel.getModuleLibraryTable().createLibrary(); final Library.ModifiableModel libraryModel = jarLibrary.getModifiableModel(); - libraryModel.addRoot(jarFile, rootType); + libraryModel.addRoot(root, rootType); libraryModel.commit(); rootModel.commit(); } diff --git a/platform/core-api/src/com/intellij/psi/PsiElement.java b/platform/core-api/src/com/intellij/psi/PsiElement.java index 99bc7789c90c..fa58ea3d3797 100644 --- a/platform/core-api/src/com/intellij/psi/PsiElement.java +++ b/platform/core-api/src/com/intellij/psi/PsiElement.java @@ -46,7 +46,8 @@ public interface PsiElement extends UserDataHolder, Iconable { * Returns the project to which the PSI element belongs. * * @return the project instance. - * @throws PsiInvalidElementAccessException if this element is invalid + * @throws PsiInvalidElementAccessException + * if this element is invalid */ @NotNull Project getProject() throws PsiInvalidElementAccessException; @@ -56,7 +57,8 @@ public interface PsiElement extends UserDataHolder, Iconable { * * @return the language instance. */ - @NotNull Language getLanguage(); + @NotNull + Language getLanguage(); /** * Returns the PSI manager for the project to which the PSI element belongs. @@ -71,7 +73,8 @@ public interface PsiElement extends UserDataHolder, Iconable { * * @return the array of child elements. */ - @NotNull PsiElement[] getChildren(); + @NotNull + PsiElement[] getChildren(); /** * Returns the parent of the PSI element. @@ -85,34 +88,40 @@ public interface PsiElement extends UserDataHolder, Iconable { * * @return the first child, or null if the element has no children. */ - @Nullable PsiElement getFirstChild(); + @Nullable + PsiElement getFirstChild(); /** * Returns the last child of the PSI element. * * @return the last child, or null if the element has no children. */ - @Nullable PsiElement getLastChild(); + @Nullable + PsiElement getLastChild(); /** * Returns the next sibling of the PSI element. * * @return the next sibling, or null if the node is the last in the list of siblings. */ - @Nullable PsiElement getNextSibling(); + @Nullable + PsiElement getNextSibling(); /** * Returns the previous sibling of the PSI element. * * @return the previous sibling, or null if the node is the first in the list of siblings. */ - @Nullable PsiElement getPrevSibling(); + @Nullable + PsiElement getPrevSibling(); /** * Returns the file containing the PSI element. - * @throws PsiInvalidElementAccessException if this element is invalid + * * @return the file instance, or null if the PSI element is not contained in a file (for example, - * the element represents a package or directory). + * the element represents a package or directory). + * @throws PsiInvalidElementAccessException + * if this element is invalid */ PsiFile getContainingFile() throws PsiInvalidElementAccessException; @@ -178,7 +187,8 @@ public interface PsiElement extends UserDataHolder, Iconable { * * @return the element text as a character array. */ - @NotNull char[] textToCharArray(); + @NotNull + char[] textToCharArray(); /** * Returns the PSI element which should be used as a navigation target @@ -246,7 +256,7 @@ public interface PsiElement extends UserDataHolder, Iconable { /** * Creates a copy of the file containing the PSI element and returns the corresponding * element in the created copy. Resolve operations performed on elements in the copy - * of the file will resolve to elements in the copy, not in the original file. + * of the file will resolve to elements in the copy, not in the original file. * * @return the element in the file copy corresponding to this element. */ @@ -304,9 +314,9 @@ public interface PsiElement extends UserDataHolder, Iconable { /** * Adds a range of elements as children to this PSI element, before the specified anchor element. * - * @param first the first child element to add. - * @param last the last child element to add (must have the same parent as first) - * @param anchor the anchor before which the child element is inserted (must be a child of this PSI element) + * @param first the first child element to add. + * @param last the last child element to add (must have the same parent as first) + * @param anchor the anchor before which the child element is inserted (must be a child of this PSI element) * @return the first child element which was actually added (either first or its copy). * @throws IncorrectOperationException if the modification is not supported or not possible for some reason. */ @@ -315,9 +325,9 @@ public interface PsiElement extends UserDataHolder, Iconable { /** * Adds a range of elements as children to this PSI element, after the specified anchor element. * - * @param first the first child element to add. - * @param last the last child element to add (must have the same parent as first) - * @param anchor the anchor after which the child element is inserted (must be a child of this PSI element) + * @param first the first child element to add. + * @param last the last child element to add (must have the same parent as first) + * @param anchor the anchor after which the child element is inserted (must be a child of this PSI element) * @return the first child element which was actually added (either first or its copy). * @throws IncorrectOperationException if the modification is not supported or not possible for some reason. */ @@ -327,7 +337,7 @@ public interface PsiElement extends UserDataHolder, Iconable { * Deletes this PSI element from the tree. * * @throws IncorrectOperationException if the modification is not supported - * or not possible for some reason (for example, the file containing the element is read-only). + * or not possible for some reason (for example, the file containing the element is read-only). */ void delete() throws IncorrectOperationException; @@ -382,7 +392,7 @@ public interface PsiElement extends UserDataHolder, Iconable { * associated reference. * * @return the reference instance, or null if the PSI element does not have any - * associated references. + * associated references. */ @Nullable PsiReference getReference(); @@ -394,15 +404,16 @@ public interface PsiElement extends UserDataHolder, Iconable { * contains only one text fragment which acts as a reference but the reference has * multiple possible targets, {@link PsiPolyVariantReference} should be used instead * of returning multiple references. - * + *

* Actually, it's preferable to call {@link com.intellij.psi.PsiReferenceService#getReferences} instead * as it allows adding references by plugins when the element implements {@link com.intellij.psi.ContributedReferenceHost}. * * @return the array of references, or an empty array if the element has no associated - * references. + * references. * @see com.intellij.psi.PsiReferenceService#getReferences */ - @NotNull PsiReference[] getReferences(); + @NotNull + PsiReference[] getReferences(); /** * Returns a copyable user data object attached to this element. @@ -411,13 +422,14 @@ public interface PsiElement extends UserDataHolder, Iconable { * @return the user data object, or null if no such object is found in the current element. * @see #putCopyableUserData(com.intellij.openapi.util.Key, Object) */ - @Nullable T getCopyableUserData(Key key); + @Nullable + T getCopyableUserData(Key key); /** * Attaches a copyable user data object to this element. Copyable user data objects are copied * when the PSI elements are copied. * - * @param key the key for accessing the user data object. + * @param key the key for accessing the user data object. * @param value the user data object to attach. * @see #getCopyableUserData(com.intellij.openapi.util.Key) */ @@ -427,12 +439,12 @@ public interface PsiElement extends UserDataHolder, Iconable { * Passes the declarations contained in this PSI element and its children * for processing to the specified scope processor. * - * @param processor the processor receiving the declarations. + * @param processor the processor receiving the declarations. * @param state - * @param lastParent the child of this element has been processed during the previous - * step of the tree up walk (declarations under this element do not need - * to be processed again) - * @param place the original element from which the tree up walk was initiated. + * @param lastParent the child of this element has been processed during the previous + * step of the tree up walk (declarations under this element do not need + * to be processed again) + * @param place the original element from which the tree up walk was initiated. * @return true if the declaration processing should continue or false if it should be stopped. */ boolean processDeclarations(@NotNull PsiScopeProcessor processor, @@ -444,11 +456,12 @@ public interface PsiElement extends UserDataHolder, Iconable { * Returns the element which should be used as the parent of this element in a tree up * walk during a resolve operation. For most elements, this returns getParent(), * but the context can be overridden for some elements like code fragments (see - * {@link PsiElementFactory#createCodeBlockCodeFragment(String, PsiElement, boolean)}). + * {@link PsiElementFactory#createCodeBlockCodeFragment(String, PsiElement, boolean)}). * * @return the resolve context element. */ - @Nullable PsiElement getContext(); + @Nullable + PsiElement getContext(); /** * Checks if an actual source or class file corresponds to the element. Non-physical elements include, @@ -465,7 +478,8 @@ public interface PsiElement extends UserDataHolder, Iconable { * * @return the resolve scope instance. */ - @NotNull GlobalSearchScope getResolveScope(); + @NotNull + GlobalSearchScope getResolveScope(); /** * Returns the scope in which references to this element are searched. @@ -473,7 +487,8 @@ public interface PsiElement extends UserDataHolder, Iconable { * @return the search scope instance. * @see {@link com.intellij.psi.search.PsiSearchHelper#getUseScope(PsiElement)} */ - @NotNull SearchScope getUseScope(); + @NotNull + SearchScope getUseScope(); /** * Returns the AST node corresponding to the element. @@ -485,7 +500,8 @@ public interface PsiElement extends UserDataHolder, Iconable { /** * toString() should never be presented to the user. */ - @NonNls String toString(); + @NonNls + String toString(); boolean isEquivalentTo(PsiElement another); } diff --git a/platform/icons/src/process/fs/step_1.png b/platform/icons/src/process/fs/step_1.png new file mode 100644 index 000000000000..a02f0d104b39 Binary files /dev/null and b/platform/icons/src/process/fs/step_1.png differ diff --git a/platform/icons/src/process/fs/step_10.png b/platform/icons/src/process/fs/step_10.png new file mode 100644 index 000000000000..b6bfb992ece4 Binary files /dev/null and b/platform/icons/src/process/fs/step_10.png differ diff --git a/platform/icons/src/process/fs/step_11.png b/platform/icons/src/process/fs/step_11.png new file mode 100644 index 000000000000..a5c85de9aa18 Binary files /dev/null and b/platform/icons/src/process/fs/step_11.png differ diff --git a/platform/icons/src/process/fs/step_12.png b/platform/icons/src/process/fs/step_12.png new file mode 100644 index 000000000000..fe7462e4093e Binary files /dev/null and b/platform/icons/src/process/fs/step_12.png differ diff --git a/platform/icons/src/process/fs/step_13.png b/platform/icons/src/process/fs/step_13.png new file mode 100644 index 000000000000..29ee72483188 Binary files /dev/null and b/platform/icons/src/process/fs/step_13.png differ diff --git a/platform/icons/src/process/fs/step_14.png b/platform/icons/src/process/fs/step_14.png new file mode 100644 index 000000000000..83adfde6df2a Binary files /dev/null and b/platform/icons/src/process/fs/step_14.png differ diff --git a/platform/icons/src/process/fs/step_15.png b/platform/icons/src/process/fs/step_15.png new file mode 100644 index 000000000000..dd7c72f16c71 Binary files /dev/null and b/platform/icons/src/process/fs/step_15.png differ diff --git a/platform/icons/src/process/fs/step_16.png b/platform/icons/src/process/fs/step_16.png new file mode 100644 index 000000000000..a8628ed26f60 Binary files /dev/null and b/platform/icons/src/process/fs/step_16.png differ diff --git a/platform/icons/src/process/fs/step_17.png b/platform/icons/src/process/fs/step_17.png new file mode 100644 index 000000000000..3184821bf5dc Binary files /dev/null and b/platform/icons/src/process/fs/step_17.png differ diff --git a/platform/icons/src/process/fs/step_18.png b/platform/icons/src/process/fs/step_18.png new file mode 100644 index 000000000000..ba0cb9b6147f Binary files /dev/null and b/platform/icons/src/process/fs/step_18.png differ diff --git a/platform/icons/src/process/fs/step_2.png b/platform/icons/src/process/fs/step_2.png new file mode 100644 index 000000000000..116c7739306a Binary files /dev/null and b/platform/icons/src/process/fs/step_2.png differ diff --git a/platform/icons/src/process/fs/step_3.png b/platform/icons/src/process/fs/step_3.png new file mode 100644 index 000000000000..dfd20857736b Binary files /dev/null and b/platform/icons/src/process/fs/step_3.png differ diff --git a/platform/icons/src/process/fs/step_4.png b/platform/icons/src/process/fs/step_4.png new file mode 100644 index 000000000000..a237bd9c4a91 Binary files /dev/null and b/platform/icons/src/process/fs/step_4.png differ diff --git a/platform/icons/src/process/fs/step_5.png b/platform/icons/src/process/fs/step_5.png new file mode 100644 index 000000000000..a9793e2aa4fc Binary files /dev/null and b/platform/icons/src/process/fs/step_5.png differ diff --git a/platform/icons/src/process/fs/step_6.png b/platform/icons/src/process/fs/step_6.png new file mode 100644 index 000000000000..3c7b285e2e5b Binary files /dev/null and b/platform/icons/src/process/fs/step_6.png differ diff --git a/platform/icons/src/process/fs/step_7.png b/platform/icons/src/process/fs/step_7.png new file mode 100644 index 000000000000..103ba21a4677 Binary files /dev/null and b/platform/icons/src/process/fs/step_7.png differ diff --git a/platform/icons/src/process/fs/step_8.png b/platform/icons/src/process/fs/step_8.png new file mode 100644 index 000000000000..03898c63b27a Binary files /dev/null and b/platform/icons/src/process/fs/step_8.png differ diff --git a/platform/icons/src/process/fs/step_9.png b/platform/icons/src/process/fs/step_9.png new file mode 100644 index 000000000000..10c777aca3c0 Binary files /dev/null and b/platform/icons/src/process/fs/step_9.png differ diff --git a/platform/icons/src/process/fs/step_mask.png b/platform/icons/src/process/fs/step_mask.png new file mode 100644 index 000000000000..1a95fada3d49 Binary files /dev/null and b/platform/icons/src/process/fs/step_mask.png differ diff --git a/platform/icons/src/process/fs/step_passive.png b/platform/icons/src/process/fs/step_passive.png new file mode 100644 index 000000000000..e1d490fdbbeb Binary files /dev/null and b/platform/icons/src/process/fs/step_passive.png differ diff --git a/platform/lang-api/src/com/intellij/codeInsight/intention/IntentionAction.java b/platform/lang-api/src/com/intellij/codeInsight/intention/IntentionAction.java index 15b366e17909..946e31137556 100644 --- a/platform/lang-api/src/com/intellij/codeInsight/intention/IntentionAction.java +++ b/platform/lang-api/src/com/intellij/codeInsight/intention/IntentionAction.java @@ -51,7 +51,8 @@ public interface IntentionAction { * @return the intention family ID. * @see IntentionManager#registerIntentionAndMetaData(com.intellij.codeInsight.intention.IntentionAction, java.lang.String...) */ - @NotNull String getFamilyName(); + @NotNull + String getFamilyName(); /** * Checks whether this intention is available at a caret offset in file. diff --git a/platform/lang-api/src/com/intellij/codeInsight/intention/PsiElementBaseIntentionAction.java b/platform/lang-api/src/com/intellij/codeInsight/intention/PsiElementBaseIntentionAction.java index 453b022dc298..6967f36ecb86 100644 --- a/platform/lang-api/src/com/intellij/codeInsight/intention/PsiElementBaseIntentionAction.java +++ b/platform/lang-api/src/com/intellij/codeInsight/intention/PsiElementBaseIntentionAction.java @@ -43,16 +43,17 @@ public abstract class PsiElementBaseIntentionAction extends BaseIntentionAction throw new IncorrectOperationException(); } + @Override public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { final PsiElement element = getElement(editor, file); return element != null && isAvailable(project, editor, element); } @Nullable - protected static PsiElement getElement(Editor editor, PsiFile file) { + protected static PsiElement getElement(Editor editor, @NotNull PsiFile file) { if (!file.getManager().isInProject(file)) return null; - final CaretModel caretModel = editor.getCaretModel(); - final int position = caretModel.getOffset(); + CaretModel caretModel = editor.getCaretModel(); + int position = caretModel.getOffset(); return file.findElementAt(position); } diff --git a/platform/lang-api/src/com/intellij/codeInsight/intention/impl/BaseIntentionAction.java b/platform/lang-api/src/com/intellij/codeInsight/intention/impl/BaseIntentionAction.java index 31c89570a388..81d3d9a245dc 100644 --- a/platform/lang-api/src/com/intellij/codeInsight/intention/impl/BaseIntentionAction.java +++ b/platform/lang-api/src/com/intellij/codeInsight/intention/impl/BaseIntentionAction.java @@ -25,6 +25,7 @@ import org.jetbrains.annotations.NotNull; public abstract class BaseIntentionAction implements IntentionAction { private String myText = ""; + @Override @NotNull public String getText() { return myText; @@ -34,6 +35,7 @@ public abstract class BaseIntentionAction implements IntentionAction { myText = text; } + @Override public boolean startInWriteAction() { return true; } diff --git a/platform/lang-api/src/com/intellij/openapi/projectRoots/SdkType.java b/platform/lang-api/src/com/intellij/openapi/projectRoots/SdkType.java index bc558a8e2667..3f69ade8052a 100644 --- a/platform/lang-api/src/com/intellij/openapi/projectRoots/SdkType.java +++ b/platform/lang-api/src/com/intellij/openapi/projectRoots/SdkType.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -40,7 +40,7 @@ public abstract class SdkType { private final String myName; /** - * @return path to set up filechooser to or null if not applicable + * @return path to set up file chooser to or null if not applicable */ @Nullable public abstract String suggestHomePath(); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonTooltipRendererProvider.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonTooltipRendererProvider.java index 00d0e8345a60..822e68e24e21 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonTooltipRendererProvider.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonTooltipRendererProvider.java @@ -111,8 +111,9 @@ public class DaemonTooltipRendererProvider implements ErrorStripTooltipRendererP return new MyRenderer(text, width, new Object[] {text}); } + @NotNull @Override - public TrafficTooltipRenderer createTrafficTooltipRenderer(Runnable onHide, Editor editor) { + public TrafficTooltipRenderer createTrafficTooltipRenderer(@NotNull Runnable onHide, @NotNull Editor editor) { return new TrafficTooltipRendererImpl(onHide, editor); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/SeverityRegistrar.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/SeverityRegistrar.java index 4d01d1451764..f153046f4b0d 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/SeverityRegistrar.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/SeverityRegistrar.java @@ -16,6 +16,7 @@ package com.intellij.codeInsight.daemon.impl; +import com.google.common.primitives.Ints; import com.intellij.codeHighlighting.HighlightDisplayLevel; import com.intellij.lang.annotation.HighlightSeverity; import com.intellij.openapi.editor.colors.EditorColorsManager; @@ -265,7 +266,7 @@ public class SeverityRegistrar implements JDOMExternalizable, Comparator id2Pass = new TIntObjectHashMap(); final TIntArrayList passesRefusedToCreate = new TIntArrayList(); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficLightRenderer.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficLightRenderer.java index d34cb067fbf9..7818e095e0cf 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficLightRenderer.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficLightRenderer.java @@ -108,7 +108,7 @@ public class TrafficLightRenderer implements ErrorStripeRenderer, Disposable { private void refresh() { int maxIndex = mySeverityRegistrar.getSeverityMaxIndex(); if (errorCount != null && maxIndex == errorCount.length) return; - int[] newErrors = new int[maxIndex]; + int[] newErrors = new int[maxIndex+1]; if (errorCount != null) { System.arraycopy(errorCount, 0, newErrors, 0, Math.min(errorCount.length, newErrors.length)); } @@ -140,7 +140,7 @@ public class TrafficLightRenderer implements ErrorStripeRenderer, Disposable { HighlightSeverity infoSeverity = info.getSeverity(); final int severityIdx = mySeverityRegistrar.getSeverityIdx(infoSeverity); if (severityIdx != -1) { - errorCount[severityIdx]+= delta; + errorCount[severityIdx] += delta; } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java index 9cd4000274db..23915b48aedc 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java @@ -718,6 +718,7 @@ public class DocumentationManager { myUpdateDocAlarm.addRequest(new Runnable() { public void run() { + if (myProject.isDisposed()) return; final Throwable[] ex = new Throwable[1]; String text = null; try { diff --git a/platform/lang-impl/src/com/intellij/find/editorHeaderActions/Utils.java b/platform/lang-impl/src/com/intellij/find/editorHeaderActions/Utils.java index 0b5249e6757e..03c5c8592feb 100644 --- a/platform/lang-impl/src/com/intellij/find/editorHeaderActions/Utils.java +++ b/platform/lang-impl/src/com/intellij/find/editorHeaderActions/Utils.java @@ -1,14 +1,9 @@ package com.intellij.find.editorHeaderActions; -import com.intellij.openapi.editor.Editor; import com.intellij.openapi.ui.popup.JBPopup; import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.openapi.ui.popup.PopupChooserBuilder; import com.intellij.openapi.util.SystemInfo; -import com.intellij.openapi.vfs.ReadonlyStatusHandler; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.psi.PsiDocumentManager; -import com.intellij.psi.PsiFile; import javax.swing.*; import javax.swing.text.JTextComponent; @@ -42,7 +37,7 @@ public class Utils { .setRequestFocus(true).setItemChoosenCallback(callback).createPopup(); if (ad != null) { - popup.setAdText(ad, SwingUtilities.LEFT); + popup.setAdText(ad, SwingConstants.LEFT); } if (toolbarComponent != null) { @@ -72,20 +67,4 @@ public class Utils { } } } - - public static boolean ensureOkToWrite(Editor e) { - final PsiFile psiFile = PsiDocumentManager.getInstance(e.getProject()).getPsiFile(e.getDocument()); - boolean okWritable; - if (psiFile != null) { - final VirtualFile virtualFile = psiFile.getVirtualFile(); - if (virtualFile != null) { - okWritable = ReadonlyStatusHandler.ensureFilesWritable(e.getProject(), virtualFile); - } else { - okWritable = psiFile.isWritable(); - } - } else { - okWritable = e.getDocument().isWritable(); - } - return okWritable; - } } diff --git a/platform/lang-impl/src/com/intellij/find/impl/livePreview/LivePreviewControllerBase.java b/platform/lang-impl/src/com/intellij/find/impl/livePreview/LivePreviewControllerBase.java index a4d145e343bc..c746ee722c2f 100644 --- a/platform/lang-impl/src/com/intellij/find/impl/livePreview/LivePreviewControllerBase.java +++ b/platform/lang-impl/src/com/intellij/find/impl/livePreview/LivePreviewControllerBase.java @@ -3,13 +3,13 @@ package com.intellij.find.impl.livePreview; import com.intellij.find.FindManager; import com.intellij.find.FindModel; import com.intellij.find.FindUtil; -import com.intellij.find.editorHeaderActions.Utils; import com.intellij.find.impl.FindResultImpl; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.*; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.TextRange; +import com.intellij.openapi.vfs.ReadonlyStatusHandler; import com.intellij.util.Alarm; import org.jetbrains.annotations.Nullable; @@ -169,7 +169,7 @@ public class LivePreviewControllerBase implements LivePreview.Delegate, FindUtil @Nullable @Override public TextRange performReplace(final LiveOccurrence occurrence, final String replacement, final Editor editor) { - if (myReplaceDenied || !Utils.ensureOkToWrite(editor)) return null; + if (myReplaceDenied || !ReadonlyStatusHandler.ensureDocumentWritable(editor.getProject(), editor.getDocument())) return null; TextRange range = occurrence.getPrimaryRange(); FindModel findModel = mySearchResults.getFindModel(); TextRange result = null; @@ -197,7 +197,7 @@ public class LivePreviewControllerBase implements LivePreview.Delegate, FindUtil @Override public void performReplaceAll(Editor e) { - if (!Utils.ensureOkToWrite(e)) return; + if (!ReadonlyStatusHandler.ensureDocumentWritable(e.getProject(), e.getDocument())) return; if (mySearchResults.getFindModel() != null) { final FindModel copy = new FindModel(); copy.copyFrom(mySearchResults.getFindModel()); diff --git a/platform/lang-impl/src/com/intellij/ide/bookmarks/Bookmark.java b/platform/lang-impl/src/com/intellij/ide/bookmarks/Bookmark.java index a94ac1a097e4..db019a2f0eda 100644 --- a/platform/lang-impl/src/com/intellij/ide/bookmarks/Bookmark.java +++ b/platform/lang-impl/src/com/intellij/ide/bookmarks/Bookmark.java @@ -26,6 +26,7 @@ import com.intellij.navigation.NavigationItem; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.RangeMarker; import com.intellij.openapi.editor.ex.MarkupModelEx; +import com.intellij.openapi.editor.ex.RangeHighlighterEx; import com.intellij.openapi.editor.impl.DocumentMarkupModel; import com.intellij.openapi.editor.markup.GutterIconRenderer; import com.intellij.openapi.editor.markup.HighlighterLayer; @@ -41,6 +42,7 @@ import com.intellij.psi.PsiFile; import com.intellij.psi.PsiManager; import com.intellij.ui.LightColors; import com.intellij.util.PlatformIcons; +import com.intellij.util.Processor; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -52,45 +54,41 @@ public class Bookmark { private final VirtualFile myFile; private final OpenFileDescriptor myTarget; - private final RangeHighlighter myHighlighter; private final Project myProject; private String myDescription; private char myMnemonic = 0; public static final Font MNEMONIC_FONT = new Font("Monospaced", 0, 11); - public Bookmark(Project project, VirtualFile file, String description) { - this(project, file, -1, description); - } - - public Bookmark(Project project, VirtualFile file, int line, String description) { + public Bookmark(@NotNull Project project, @NotNull VirtualFile file, int line, @NotNull String description) { myFile = file; myProject = project; myDescription = description; + myTarget = new OpenFileDescriptor(project, file, line, -1, true); + + Document document = FileDocumentManager.getInstance().getCachedDocument(getFile()); + if (document != null) { + createHighlighter((MarkupModelEx)DocumentMarkupModel.forDocument(document, myProject, true)); + } + } + + public RangeHighlighter createHighlighter(@NotNull MarkupModelEx markup) { + final RangeHighlighter myHighlighter; + int line = getLine(); if (line >= 0) { - Document document = getDocument(); - if (document == null) { - myHighlighter = null; - } - else { - MarkupModelEx markup = (MarkupModelEx)DocumentMarkupModel.forDocument(document, myProject, true); - myHighlighter = markup.addPersistentLineHighlighter(line, HighlighterLayer.ERROR + 1, null); + myHighlighter = markup.addPersistentLineHighlighter(line, HighlighterLayer.ERROR + 1, null); + if (myHighlighter != null) { + myHighlighter.setGutterIconRenderer(new MyGutterIconRenderer(this)); - - if (myHighlighter != null) { - myHighlighter.setGutterIconRenderer(new MyGutterIconRenderer()); - - myHighlighter.setErrorStripeMarkColor(Color.black); - myHighlighter.setErrorStripeTooltip(getBookmarkTooltip()); - } + myHighlighter.setErrorStripeMarkColor(Color.black); + myHighlighter.setErrorStripeTooltip(getBookmarkTooltip()); } } else { myHighlighter = null; } - - myTarget = new OpenFileDescriptor(project, file, line, -1, true); + return myHighlighter; } public Document getDocument() { @@ -98,9 +96,28 @@ public class Bookmark { } public void release() { - if (myHighlighter != null) { - myHighlighter.dispose(); + int line = getLine(); + if (line < 0) { + return; } + final Document document = getDocument(); + if (document == null) return; + MarkupModelEx markup = (MarkupModelEx)DocumentMarkupModel.forDocument(document, myProject, true); + int startOffset = markup.getDocument().getLineStartOffset(line); + int endOffset = markup.getDocument().getLineEndOffset(line); + final RangeHighlighterEx[] found = new RangeHighlighterEx[1]; + markup.processRangeHighlightersOverlappingWith(startOffset, endOffset, new Processor() { + @Override + public boolean process(RangeHighlighterEx highlighter) { + GutterIconRenderer renderer = highlighter.getGutterIconRenderer(); + if (renderer instanceof MyGutterIconRenderer && ((MyGutterIconRenderer)renderer).myBookmark == Bookmark.this) { + found[0] = highlighter; + return false; + } + return true; + } + }); + if (found[0] != null) found[0].dispose(); } public Icon getIcon() { @@ -123,25 +140,18 @@ public class Bookmark { myMnemonic = Character.toUpperCase(mnemonic); } + @NotNull public VirtualFile getFile() { return myFile; } @Nullable public String getNotEmptyDescription() { - return isDescriptionEmpty() ? null : myDescription; - } - - public boolean isDescriptionEmpty() { - return myDescription == null || myDescription.trim().length() == 0; - } - - OpenFileDescriptor getTarget() { - return myTarget; + return StringUtil.isEmpty(myDescription) ? null : myDescription; } public boolean isValid() { - if (!getFile().isValid() || (myHighlighter != null && !myHighlighter.isValid())) { + if (!getFile().isValid()) { return false; } @@ -156,8 +166,10 @@ public class Bookmark { } public int getLine() { - if (myHighlighter != null && myHighlighter.isValid()) { - return myHighlighter.getDocument().getLineNumber(myHighlighter.getStartOffset()); + RangeMarker marker = myTarget.getRangeMarker(); + if (marker != null && marker.isValid()) { + Document document = marker.getDocument(); + return document.getLineNumber(marker.getStartOffset()); } return myTarget.getLine(); } @@ -169,7 +181,7 @@ public class Bookmark { public String getQualifiedName() { String presentableUrl = myFile.getPresentableUrl(); - if (myFile.isDirectory() || myHighlighter == null) return presentableUrl; + if (myFile.isDirectory()) return presentableUrl; PsiDocumentManager.getInstance(myProject).commitAllDocuments(); final PsiFile psiFile = PsiManager.getInstance(myProject).findFile(myFile); @@ -188,8 +200,7 @@ public class Bookmark { } } - return IdeBundle - .message("bookmark.file.X.line.Y", presentableUrl, myHighlighter.getDocument().getLineNumber(myHighlighter.getStartOffset()) + 1); + return IdeBundle.message("bookmark.file.X.line.Y", presentableUrl, getLine() + 1); } private String getBookmarkTooltip() { @@ -211,6 +222,7 @@ public class Bookmark { myMnemonic = mnemonic; } + @Override public void paintIcon(Component c, Graphics g, int x, int y) { g.setColor(LightColors.YELLOW); g.fillRect(x, y, getIconWidth(), getIconHeight()); @@ -226,10 +238,12 @@ public class Bookmark { g.setFont(oldFont); } + @Override public int getIconWidth() { return 10; } + @Override public int getIconHeight() { return 12; } @@ -245,14 +259,22 @@ public class Bookmark { } } - private class MyGutterIconRenderer extends GutterIconRenderer { - @NotNull - public Icon getIcon() { - return Bookmark.this.getIcon(); + private static class MyGutterIconRenderer extends GutterIconRenderer { + private final Bookmark myBookmark; + + public MyGutterIconRenderer(@NotNull Bookmark bookmark) { + myBookmark = bookmark; } + @Override + @NotNull + public Icon getIcon() { + return myBookmark.getIcon(); + } + + @Override public String getTooltipText() { - return getBookmarkTooltip(); + return myBookmark.getBookmarkTooltip(); } @Override diff --git a/platform/lang-impl/src/com/intellij/ide/bookmarks/BookmarkManager.java b/platform/lang-impl/src/com/intellij/ide/bookmarks/BookmarkManager.java index 3e46735e892c..0d995bebeb7b 100644 --- a/platform/lang-impl/src/com/intellij/ide/bookmarks/BookmarkManager.java +++ b/platform/lang-impl/src/com/intellij/ide/bookmarks/BookmarkManager.java @@ -16,25 +16,32 @@ package com.intellij.ide.bookmarks; -import com.intellij.openapi.components.*; +import com.intellij.openapi.components.AbstractProjectComponent; +import com.intellij.openapi.components.PersistentStateComponent; +import com.intellij.openapi.components.State; +import com.intellij.openapi.components.Storage; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.EditorFactory; import com.intellij.openapi.editor.event.*; +import com.intellij.openapi.editor.ex.MarkupModelEx; +import com.intellij.openapi.editor.impl.DocumentMarkupModel; +import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.project.DumbAwareRunnable; import com.intellij.openapi.project.Project; import com.intellij.openapi.startup.StartupManager; import com.intellij.openapi.util.SystemInfo; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileManager; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiFile; import com.intellij.util.messages.MessageBus; +import com.intellij.util.ui.UIUtil; import org.jdom.Element; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import javax.swing.*; import java.awt.*; import java.awt.event.InputEvent; import java.util.*; @@ -46,51 +53,54 @@ import java.util.List; @Storage( file = "$WORKSPACE_FILE$") } ) -public class BookmarkManager implements PersistentStateComponent, ProjectComponent { - +public class BookmarkManager extends AbstractProjectComponent implements PersistentStateComponent { private static final int MAX_AUTO_DESCRIPTION_SIZE = 50; - private final List myBookmarks = new ArrayList(); - private final MyEditorMouseListener myEditorMouseListener = new MyEditorMouseListener(); + private final List myBookmarks = new ArrayList(); - private final Project myProject; private final MessageBus myBus; public static BookmarkManager getInstance(Project project) { return project.getComponent(BookmarkManager.class); } - public BookmarkManager(Project project, MessageBus bus) { - myProject = project; + public BookmarkManager(Project project, MessageBus bus, PsiDocumentManager documentManager) { + super(project); myBus = bus; - EditorFactory.getInstance().getEventMulticaster().addDocumentListener(new MyDocumentListener(), myProject); + EditorEventMulticaster multicaster = EditorFactory.getInstance().getEventMulticaster(); + multicaster.addDocumentListener(new MyDocumentListener(), myProject); + multicaster.addEditorMouseListener(new MyEditorMouseListener(), myProject); + + documentManager.addListener(new PsiDocumentManager.Listener() { + @Override + public void documentCreated(@NotNull final Document document, PsiFile psiFile) { + final VirtualFile file = FileDocumentManager.getInstance().getFile(document); + if (file == null) return; + UIUtil.invokeLaterIfNeeded(new Runnable() { + @Override + public void run() { + if (myProject.isDisposed()) return; + for (Bookmark bookmark : myBookmarks) { + if (bookmark.getFile() == file) { + bookmark.createHighlighter((MarkupModelEx)DocumentMarkupModel.forDocument(document, myProject, true)); + } + } + } + }); + } + + @Override + public void fileCreated(@NotNull PsiFile file, @NotNull Document document) { + } + }); } - public void projectOpened() { - EditorFactory.getInstance().getEventMulticaster().addEditorMouseListener(myEditorMouseListener, myProject); - } - - @Override - public void projectClosed() { - EditorFactory.getInstance().getEventMulticaster().removeEditorMouseListener(myEditorMouseListener); - } - - @Override - public void initComponent() {} - - @Override - public void disposeComponent() {} - @NotNull @Override public String getComponentName() { return "BookmarkManager"; } - public Project getProject() { - return myProject; - } - public void addEditorBookmark(Editor editor, int lineIndex) { Document document = editor.getDocument(); PsiFile psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(document); @@ -127,7 +137,7 @@ public class BookmarkManager implements PersistentStateComponent, Proje if (file == null) return null; if (findFileBookmark(file) != null) return null; - Bookmark b = new Bookmark(myProject, file, description); + Bookmark b = new Bookmark(myProject, file, -1, description); myBookmarks.add(0, b); myBus.syncPublisher(BookmarksListener.TOPIC).bookmarkAdded(b); return b; @@ -144,9 +154,9 @@ public class BookmarkManager implements PersistentStateComponent, Proje @Nullable - public Bookmark findEditorBookmark(Document document, int lineIndex) { + public Bookmark findEditorBookmark(@NotNull Document document, int line) { for (Bookmark bookmark : myBookmarks) { - if (bookmark.getDocument() == document && bookmark.getLine() == lineIndex) { + if (bookmark.getDocument() == document && bookmark.getLine() == line) { return bookmark; } } @@ -155,7 +165,7 @@ public class BookmarkManager implements PersistentStateComponent, Proje } @Nullable - public Bookmark findFileBookmark(VirtualFile file) { + public Bookmark findFileBookmark(@NotNull VirtualFile file) { for (Bookmark bookmark : myBookmarks) { if (bookmark.getFile() == file && bookmark.getLine() == -1) return bookmark; } @@ -180,20 +190,23 @@ public class BookmarkManager implements PersistentStateComponent, Proje return false; } - public void removeBookmark(Bookmark bookmark) { + public void removeBookmark(@NotNull Bookmark bookmark) { myBookmarks.remove(bookmark); bookmark.release(); myBus.syncPublisher(BookmarksListener.TOPIC).bookmarkRemoved(bookmark); } + @Override public Element getState() { Element container = new Element("BookmarkManager"); writeExternal(container); return container; } + @Override public void loadState(final Element state) { StartupManager.getInstance(myProject).runWhenProjectIsInitialized(new DumbAwareRunnable() { + @Override public void run() { BookmarksListener publisher = myBus.syncPublisher(BookmarksListener.TOPIC); for (Bookmark bookmark : myBookmarks) { @@ -214,7 +227,7 @@ public class BookmarkManager implements PersistentStateComponent, Proje if ("bookmark".equals(bookmarkElement.getName())) { String url = bookmarkElement.getAttributeValue("url"); String line = bookmarkElement.getAttributeValue("line"); - String description = bookmarkElement.getAttributeValue("description"); + String description = StringUtil.notNullize(bookmarkElement.getAttributeValue("description")); String mnemonic = bookmarkElement.getAttributeValue("mnemonic"); Bookmark b = null; @@ -335,6 +348,7 @@ public class BookmarkManager implements PersistentStateComponent, Proje Bookmark[] bookmarks = answer.toArray(new Bookmark[answer.size()]); Arrays.sort(bookmarks, new Comparator() { + @Override public int compare(final Bookmark o1, final Bookmark o2) { return o1.getLine() - o2.getLine(); } @@ -342,7 +356,7 @@ public class BookmarkManager implements PersistentStateComponent, Proje return bookmarks; } - public void setMnemonic(Bookmark bookmark, char c) { + public void setMnemonic(@NotNull Bookmark bookmark, char c) { final Bookmark old = findBookmarkForMnemonic(c); if (old != null) removeBookmark(old); @@ -350,13 +364,14 @@ public class BookmarkManager implements PersistentStateComponent, Proje myBus.syncPublisher(BookmarksListener.TOPIC).bookmarkChanged(bookmark); } - public void setDescription(Bookmark bookmark, String description) { + public void setDescription(@NotNull Bookmark bookmark, String description) { bookmark.setDescription(description); myBus.syncPublisher(BookmarksListener.TOPIC).bookmarkChanged(bookmark); } private class MyEditorMouseListener extends EditorMouseAdapter { + @Override public void mouseClicked(final EditorMouseEvent e) { if (e.getArea() != EditorMouseEventArea.LINE_MARKERS_AREA) return; if (e.getMouseEvent().isPopupTrigger()) return; diff --git a/platform/lang-impl/src/com/intellij/ide/bookmarks/BookmarksListener.java b/platform/lang-impl/src/com/intellij/ide/bookmarks/BookmarksListener.java index 398ba6ef72cb..ea052a27ad79 100644 --- a/platform/lang-impl/src/com/intellij/ide/bookmarks/BookmarksListener.java +++ b/platform/lang-impl/src/com/intellij/ide/bookmarks/BookmarksListener.java @@ -20,12 +20,13 @@ package com.intellij.ide.bookmarks; import com.intellij.util.messages.Topic; +import org.jetbrains.annotations.NotNull; public interface BookmarksListener { Topic TOPIC = Topic.create("Bookmarks", BookmarksListener.class); - void bookmarkAdded(Bookmark b); - void bookmarkRemoved(Bookmark b); + void bookmarkAdded(@NotNull Bookmark b); + void bookmarkRemoved(@NotNull Bookmark b); - void bookmarkChanged(Bookmark b); + void bookmarkChanged(@NotNull Bookmark b); } diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectTreeBuilder.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectTreeBuilder.java index 83dc5f1c918f..6d2ef559b21a 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectTreeBuilder.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectTreeBuilder.java @@ -64,8 +64,10 @@ public class ProjectTreeBuilder extends BaseProjectTreeBuilder { myPsiTreeChangeListener = createPsiTreeChangeListener(myProject); connection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() { + @Override public void beforeRootsChange(ModuleRootEvent event) { } + @Override public void rootsChanged(ModuleRootEvent event) { queueUpdate(); } @@ -87,6 +89,7 @@ public class ProjectTreeBuilder extends BaseProjectTreeBuilder { initRootNode(); } + @Override public final void dispose() { super.dispose(); PsiManager.getInstance(myProject).removePsiTreeChangeListener(myPsiTreeChangeListener); @@ -110,29 +113,35 @@ public class ProjectTreeBuilder extends BaseProjectTreeBuilder { super(project); } + @Override protected DefaultMutableTreeNode getRootNode(){ return ProjectTreeBuilder.this.getRootNode(); } + @Override protected AbstractTreeUpdater getUpdater() { return ProjectTreeBuilder.this.getUpdater(); } + @Override protected boolean isFlattenPackages(){ return ((AbstractProjectTreeStructure)getTreeStructure()).isFlattenPackages(); } } private final class MyBookmarksListener implements BookmarksListener { - public void bookmarkAdded(Bookmark b) { + @Override + public void bookmarkAdded(@NotNull Bookmark b) { updateForFile(b.getFile()); } - public void bookmarkRemoved(Bookmark b) { + @Override + public void bookmarkRemoved(@NotNull Bookmark b) { updateForFile(b.getFile()); } - public void bookmarkChanged(Bookmark b) { + @Override + public void bookmarkChanged(@NotNull Bookmark b) { updateForFile(b.getFile()); } @@ -145,10 +154,12 @@ public class ProjectTreeBuilder extends BaseProjectTreeBuilder { } private final class MyFileStatusListener implements FileStatusListener { + @Override public void fileStatusesChanged() { queueUpdate(false); } + @Override public void fileStatusChanged(@NotNull VirtualFile vFile) { queueUpdate(false); } @@ -171,10 +182,12 @@ public class ProjectTreeBuilder extends BaseProjectTreeBuilder { private final Alarm myUpdateProblemAlarm = new Alarm(); private final Collection myFilesToRefresh = new THashSet(); + @Override public void problemsAppeared(VirtualFile file) { queueUpdate(file); } + @Override public void problemsDisappeared(VirtualFile file) { queueUpdate(file); } @@ -184,6 +197,7 @@ public class ProjectTreeBuilder extends BaseProjectTreeBuilder { if (myFilesToRefresh.add(fileToRefresh)) { myUpdateProblemAlarm.cancelAllRequests(); myUpdateProblemAlarm.addRequest(new Runnable() { + @Override public void run() { if (!myProject.isOpen()) return; Set filesToRefresh; diff --git a/platform/lang-impl/src/com/intellij/internal/psiView/formattingblocks/BlockTreeNode.java b/platform/lang-impl/src/com/intellij/internal/psiView/formattingblocks/BlockTreeNode.java index 624c8d643c4f..057beb6772be 100644 --- a/platform/lang-impl/src/com/intellij/internal/psiView/formattingblocks/BlockTreeNode.java +++ b/platform/lang-impl/src/com/intellij/internal/psiView/formattingblocks/BlockTreeNode.java @@ -7,6 +7,7 @@ import com.intellij.ui.SimpleTextAttributes; import com.intellij.ui.treeStructure.SimpleNode; import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; import java.awt.*; public class BlockTreeNode extends SimpleNode { @@ -56,6 +57,7 @@ public class BlockTreeNode extends SimpleNode { } + @NotNull @Override public Object[] getEqualityObjects() { return new Object[]{myBlock}; diff --git a/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/NativeFileIconProvider.java b/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/NativeFileIconProvider.java index 92d3cfa6a88b..2793909588ed 100644 --- a/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/NativeFileIconProvider.java +++ b/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/NativeFileIconProvider.java @@ -27,6 +27,7 @@ import com.intellij.ui.DeferredIconImpl; import com.intellij.ui.mac.foundation.Foundation; import com.intellij.util.Function; import com.intellij.util.ui.update.ComparableObject; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -134,6 +135,7 @@ public class NativeFileIconProvider implements FileIconProvider { myText = new Object[] {text, flags}; } + @NotNull public Object[] getEqualityObjects() { return myText; } diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/DirectoryIndexImpl.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/DirectoryIndexImpl.java index 6090e7ab87ae..6c8dd4145c98 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/DirectoryIndexImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/DirectoryIndexImpl.java @@ -248,7 +248,7 @@ public class DirectoryIndexImpl extends DirectoryIndex implements ProjectCompone DirectoryInfo info = stateAndDirs.first.myDirToInfoMap.get(dir); assert info != null; - if (!info.isInLibrarySource || info.libraryClassRoot != null) { + if (!info.isInLibrarySource || info.isInModuleSource || info.libraryClassRoot != null) { if (!consumer.process(dir)) return false; } } @@ -613,7 +613,6 @@ public class DirectoryIndexImpl extends DirectoryIndex implements ProjectCompone if (definedPackage != null && definedPackage.isEmpty()) return; // another library source root starts here } - info.isInModuleSource = false; info.isInLibrarySource = true; info.sourceRoot = sourceRoot; setPackageName(dir, packageName); diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/ModulesCombobox.java b/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/ModulesCombobox.java index ea28984c6757..4b4ca429d416 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/ModulesCombobox.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/ModulesCombobox.java @@ -67,9 +67,15 @@ public class ModulesCombobox extends ComboBox { } public void fillModules(@NotNull Project project) { + fillModules(project, null); + } + + public void fillModules(@NotNull Project project, final @Nullable ModuleType moduleType) { myModel.clear(); for (Module module : ModuleManager.getInstance(project).getModules()) { - myModel.add(module); + if (moduleType == null || moduleType.equals(ModuleType.get(module))) { + myModel.add(module); + } } } diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageUtil.java b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageUtil.java index 84129b3b623a..93b19edb27b4 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageUtil.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageUtil.java @@ -162,7 +162,9 @@ public class InjectedLanguageUtil { @NotNull public static Editor getInjectedEditorForInjectedFile(@NotNull Editor hostEditor, final PsiFile injectedFile) { if (injectedFile == null || hostEditor instanceof EditorWindow || hostEditor.isDisposed()) return hostEditor; - Document document = PsiDocumentManager.getInstance(hostEditor.getProject()).getDocument(injectedFile); + Project project = hostEditor.getProject(); + if (project == null) project = injectedFile.getProject(); + Document document = PsiDocumentManager.getInstance(project).getDocument(injectedFile); if (!(document instanceof DocumentWindowImpl)) return hostEditor; DocumentWindowImpl documentWindow = (DocumentWindowImpl)document; SelectionModel selectionModel = hostEditor.getSelectionModel(); diff --git a/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java b/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java index 3edcb908e65f..2af57b6d6bb2 100644 --- a/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java +++ b/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java @@ -198,7 +198,8 @@ public class StubIndexImpl extends StubIndex implements ApplicationComponent, Pe @NotNull final Project project, @Nullable final GlobalSearchScope scope, @NotNull final Processor processor) { - FileBasedIndex.getInstance().ensureUpToDate(StubUpdatingIndex.INDEX_ID, project, scope); + final FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance(); + fileBasedIndex.ensureUpToDate(StubUpdatingIndex.INDEX_ID, project, scope); final PersistentFS fs = (PersistentFS)ManagingFS.getInstance(); final PsiManager psiManager = PsiManager.getInstance(project); @@ -212,7 +213,7 @@ public class StubIndexImpl extends StubIndex implements ApplicationComponent, Pe index.getReadLock().lock(); final ValueContainer container = index.getData(key); - final FileBasedIndex.ProjectIndexableFilesFilter projectFilesFilter = FileBasedIndex.getInstance().projectIndexableFiles(project); + final FileBasedIndex.ProjectIndexableFilesFilter projectFilesFilter = fileBasedIndex.projectIndexableFiles(project); return container.forEach(new ValueContainer.ContainerAction() { @Override @@ -278,7 +279,7 @@ public class StubIndexImpl extends StubIndex implements ApplicationComponent, Pe ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { - FileBasedIndex.getInstance().requestReindex(file); + fileBasedIndex.requestReindex(file); } }, ModalityState.NON_MODAL); } diff --git a/platform/lang-impl/src/com/intellij/refactoring/util/TextOccurrencesUtil.java b/platform/lang-impl/src/com/intellij/refactoring/util/TextOccurrencesUtil.java index b8b69cea51eb..ab7c5ef996e4 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/util/TextOccurrencesUtil.java +++ b/platform/lang-impl/src/com/intellij/refactoring/util/TextOccurrencesUtil.java @@ -108,11 +108,14 @@ public class TextOccurrencesUtil { @NotNull String stringToSearch, @NotNull final Collection results, @NotNull final UsageInfoFactory factory) { + final Object lock = new Object(); processUsagesInStringsAndComments(element, stringToSearch, false, new PairProcessor() { public boolean process(PsiElement commentOrLiteral, TextRange textRange) { UsageInfo usageInfo = factory.createUsageInfo(commentOrLiteral, textRange.getStartOffset(), textRange.getEndOffset()); if (usageInfo != null) { - results.add(usageInfo); + synchronized (lock) { + results.add(usageInfo); + } } return true; } diff --git a/platform/platform-api/src/com/intellij/execution/util/ExecUtil.java b/platform/platform-api/src/com/intellij/execution/util/ExecUtil.java index f753d2500923..cb39f5fd76f6 100644 --- a/platform/platform-api/src/com/intellij/execution/util/ExecUtil.java +++ b/platform/platform-api/src/com/intellij/execution/util/ExecUtil.java @@ -27,9 +27,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.script.ScriptException; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; +import java.io.*; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -103,12 +101,15 @@ public class ExecUtil { } @Nullable - public static String execAndReadLine(@NotNull final List command) { + public static String execAndReadLine(final String... command) { try { - final ProcessOutput output = execAndGetOutput(command, null); - final List lines = output.getStdoutLines(); - if (lines.size() > 0) { - return lines.get(0); + final Process process = new GeneralCommandLine(command).createProcess(); + final BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); + try { + return reader.readLine(); + } + finally { + reader.close(); } } catch (Exception ignored) { } diff --git a/platform/platform-api/src/com/intellij/ide/BrowserUtil.java b/platform/platform-api/src/com/intellij/ide/BrowserUtil.java index 05f3d11df639..efca09d692a7 100644 --- a/platform/platform-api/src/com/intellij/ide/BrowserUtil.java +++ b/platform/platform-api/src/com/intellij/ide/BrowserUtil.java @@ -133,7 +133,7 @@ public class BrowserUtil { if (SystemInfo.isMac || SystemInfo.isWindows) { return true; } - else if (SystemInfo.isUnix && SystemInfo.hasXdgOpen) { + else if (SystemInfo.isUnix && SystemInfo.hasXdgOpen()) { return true; } else if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) { @@ -152,7 +152,7 @@ public class BrowserUtil { else if (SystemInfo.isMac) { return new String[]{ExecUtil.getOpenCommandPath()}; } - else if (SystemInfo.isUnix && SystemInfo.hasXdgOpen) { + else if (SystemInfo.isUnix && SystemInfo.hasXdgOpen()) { return new String[]{"xdg-open"}; } diff --git a/platform/platform-api/src/com/intellij/ide/UiActivity.java b/platform/platform-api/src/com/intellij/ide/UiActivity.java index baf0d0ce9105..9066837fb0a8 100644 --- a/platform/platform-api/src/com/intellij/ide/UiActivity.java +++ b/platform/platform-api/src/com/intellij/ide/UiActivity.java @@ -17,6 +17,7 @@ package com.intellij.ide; import com.intellij.util.ui.update.ComparableObject; import com.intellij.util.ui.update.ComparableObjectCheck; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; @@ -38,6 +39,7 @@ public class UiActivity implements ComparableObject{ } } + @NotNull @Override public Object[] getEqualityObjects() { return new Object[] {myElements}; diff --git a/platform/platform-api/src/com/intellij/ide/projectView/PresentationData.java b/platform/platform-api/src/com/intellij/ide/projectView/PresentationData.java index 0f9a05a55653..146be9277bce 100644 --- a/platform/platform-api/src/com/intellij/ide/projectView/PresentationData.java +++ b/platform/platform-api/src/com/intellij/ide/projectView/PresentationData.java @@ -247,6 +247,7 @@ public class PresentationData implements ColoredItemPresentation, ComparableObje mySeparatorAbove = false; } + @NotNull public Object[] getEqualityObjects() { return new Object[]{myOpenIcon, myClosedIcon, myColoredText, myAttributesKey, myFont, myForcedTextForeground, myPresentableText, myLocationString, mySeparatorAbove}; diff --git a/platform/platform-api/src/com/intellij/openapi/fileTypes/ExtensionFileNameMatcher.java b/platform/platform-api/src/com/intellij/openapi/fileTypes/ExtensionFileNameMatcher.java index f7d793af382d..fb1f1d8ab1b5 100644 --- a/platform/platform-api/src/com/intellij/openapi/fileTypes/ExtensionFileNameMatcher.java +++ b/platform/platform-api/src/com/intellij/openapi/fileTypes/ExtensionFileNameMatcher.java @@ -24,13 +24,15 @@ import org.jetbrains.annotations.NotNull; */ public class ExtensionFileNameMatcher implements FileNameMatcher { private final String myExtension; - + private final String myDotExtension; + public ExtensionFileNameMatcher(@NotNull @NonNls String extension) { myExtension = extension.toLowerCase(); + myDotExtension = "." + myExtension; } public boolean accept(@NotNull @NonNls String fileName) { - return fileName.regionMatches(true, fileName.length() - myExtension.length() - 1, "." + myExtension, 0, myExtension.length() + 1); + return fileName.regionMatches(true, fileName.length() - myDotExtension.length(), myDotExtension, 0, myDotExtension.length()); } @NonNls diff --git a/platform/platform-api/src/com/intellij/openapi/util/ActiveRunnable.java b/platform/platform-api/src/com/intellij/openapi/util/ActiveRunnable.java index df59623806dd..d18d087232c2 100644 --- a/platform/platform-api/src/com/intellij/openapi/util/ActiveRunnable.java +++ b/platform/platform-api/src/com/intellij/openapi/util/ActiveRunnable.java @@ -16,17 +16,18 @@ package com.intellij.openapi.util; import com.intellij.util.ui.update.ComparableObject; +import org.jetbrains.annotations.NotNull; public abstract class ActiveRunnable extends ComparableObject.Impl { protected ActiveRunnable() { } - protected ActiveRunnable(final Object object) { + protected ActiveRunnable(@NotNull Object object) { super(object); } - protected ActiveRunnable(final Object[] objects) { + protected ActiveRunnable(@NotNull Object[] objects) { super(objects); } diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/ReadonlyStatusHandler.java b/platform/platform-api/src/com/intellij/openapi/vfs/ReadonlyStatusHandler.java index 53c8c5b651be..21ddd3bd36c4 100644 --- a/platform/platform-api/src/com/intellij/openapi/vfs/ReadonlyStatusHandler.java +++ b/platform/platform-api/src/com/intellij/openapi/vfs/ReadonlyStatusHandler.java @@ -16,7 +16,10 @@ package com.intellij.openapi.vfs; import com.intellij.openapi.components.ServiceManager; +import com.intellij.openapi.editor.Document; import com.intellij.openapi.project.Project; +import com.intellij.psi.PsiDocumentManager; +import com.intellij.psi.PsiFile; import org.jetbrains.annotations.NotNull; import java.util.Collection; @@ -26,6 +29,24 @@ public abstract class ReadonlyStatusHandler { return !getInstance(project).ensureFilesWritable(files).hasReadonlyFiles(); } + public static boolean ensureDocumentWritable(@NotNull Project project, @NotNull Document document) { + final PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(document); + boolean okWritable; + if (psiFile != null) { + final VirtualFile virtualFile = psiFile.getVirtualFile(); + if (virtualFile != null) { + okWritable = ensureFilesWritable(project, virtualFile); + } + else { + okWritable = psiFile.isWritable(); + } + } + else { + okWritable = document.isWritable(); + } + return okWritable; + } + public abstract static class OperationStatus { @NotNull public abstract VirtualFile[] getReadonlyFiles(); diff --git a/platform/platform-api/src/com/intellij/ui/GuiUtils.java b/platform/platform-api/src/com/intellij/ui/GuiUtils.java index 6abc627f752f..68c970d04780 100644 --- a/platform/platform-api/src/com/intellij/ui/GuiUtils.java +++ b/platform/platform-api/src/com/intellij/ui/GuiUtils.java @@ -17,6 +17,7 @@ package com.intellij.ui; import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.fileChooser.FileChooser; import com.intellij.openapi.fileChooser.FileChooserDescriptor; import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; @@ -382,4 +383,18 @@ public class GuiUtils { invokeAndWait(runnable); } } + + /** + * Runs the runnable, if called from the dispatch thread. + * Otherwise calls {@link Application#invokeAndWait(Runnable, com.intellij.openapi.application.ModalityState)} + */ + public static void invokeAndWaitIfNeeded(@NotNull Runnable runnable, @NotNull ModalityState modalityState) { + Application application = ApplicationManager.getApplication(); + if (application.isDispatchThread()) { + runnable.run(); + } + else { + application.invokeAndWait(runnable, modalityState); + } + } } diff --git a/platform/platform-api/src/com/intellij/ui/navigation/Place.java b/platform/platform-api/src/com/intellij/ui/navigation/Place.java index cc88c74b6745..1bddf5a01215 100644 --- a/platform/platform-api/src/com/intellij/ui/navigation/Place.java +++ b/platform/platform-api/src/com/intellij/ui/navigation/Place.java @@ -29,6 +29,7 @@ public class Place implements ComparableObject { private LinkedHashMap myPath = new LinkedHashMap(); + @NotNull public final Object[] getEqualityObjects() { return new Object[] {myPath}; } diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java index 53ec6dcc98ab..4ec35a3fd404 100644 --- a/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java +++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java @@ -3221,6 +3221,7 @@ public class JBTabsImpl extends JComponent return myInfo.getText(); } + @NotNull @Override public Object[] getEqualityObjects() { return new Object[] {myInfo}; diff --git a/platform/platform-api/src/com/intellij/ui/treeStructure/SimpleNode.java b/platform/platform-api/src/com/intellij/ui/treeStructure/SimpleNode.java index f39d2581d301..780680254082 100644 --- a/platform/platform-api/src/com/intellij/ui/treeStructure/SimpleNode.java +++ b/platform/platform-api/src/com/intellij/ui/treeStructure/SimpleNode.java @@ -24,6 +24,7 @@ import com.intellij.openapi.vcs.FileStatus; import com.intellij.ui.SimpleTextAttributes; import com.intellij.util.ui.update.ComparableObject; import com.intellij.util.ui.update.ComparableObjectCheck; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -263,6 +264,7 @@ public abstract class SimpleNode extends PresentableNodeDescriptor implements Co return list.toArray(new ColoredFragment[list.size()]); } + @NotNull public Object[] getEqualityObjects() { return NONE; } diff --git a/platform/platform-api/src/com/intellij/ui/treeStructure/filtered/FilteringTreeStructure.java b/platform/platform-api/src/com/intellij/ui/treeStructure/filtered/FilteringTreeStructure.java index 9b391992054f..b8b944ff8a46 100644 --- a/platform/platform-api/src/com/intellij/ui/treeStructure/filtered/FilteringTreeStructure.java +++ b/platform/platform-api/src/com/intellij/ui/treeStructure/filtered/FilteringTreeStructure.java @@ -243,6 +243,7 @@ public class FilteringTreeStructure extends AbstractTreeStructure { return super.getWeight(); } + @NotNull public Object[] getEqualityObjects() { return new Object[]{myDelegate}; } diff --git a/platform/platform-api/src/com/intellij/util/ui/RangeBlinker.java b/platform/platform-api/src/com/intellij/util/ui/RangeBlinker.java index 059da22b5e34..f4f815b77116 100644 --- a/platform/platform-api/src/com/intellij/util/ui/RangeBlinker.java +++ b/platform/platform-api/src/com/intellij/util/ui/RangeBlinker.java @@ -73,8 +73,9 @@ public class RangeBlinker { MarkupModel markupModel = myEditor.getMarkupModel(); if (show) { - for (Segment rangeMarker : myMarkers) { - RangeHighlighter highlighter = markupModel.addRangeHighlighter(rangeMarker.getStartOffset(), rangeMarker.getEndOffset(), + for (Segment segment : myMarkers) { + if (segment.getEndOffset() > myEditor.getDocument().getTextLength()) continue; + RangeHighlighter highlighter = markupModel.addRangeHighlighter(segment.getStartOffset(), segment.getEndOffset(), HighlighterLayer.ADDITIONAL_SYNTAX, myAttributes, HighlighterTargetArea.EXACT_RANGE); myAddedHighlighters.add(highlighter); @@ -85,6 +86,7 @@ public class RangeBlinker { } stopBlinking(); myBlinkingAlarm.addRequest(new Runnable() { + @Override public void run() { if (myTimeToLive > 0 || show) { myTimeToLive--; diff --git a/platform/platform-api/src/com/intellij/util/ui/RefreshFileSystemIcon.java b/platform/platform-api/src/com/intellij/util/ui/RefreshFileSystemIcon.java new file mode 100644 index 000000000000..dea652841547 --- /dev/null +++ b/platform/platform-api/src/com/intellij/util/ui/RefreshFileSystemIcon.java @@ -0,0 +1,54 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.util.ui; + +import com.intellij.openapi.util.IconLoader; + +import javax.swing.*; +import java.awt.*; + +/** + * @author Konstantin Bulenkov + */ +public class RefreshFileSystemIcon extends AnimatedIcon { + private static final Icon[] ICONS = getIcons("/process/fs/step_", 18); + + private static Icon[] getIcons(String path, int count) { + Icon[] icons = new Icon[count]; + for (int i = 0; i < icons.length; i++) { + int index = i + 1; + icons[i] = IconLoader.getIcon(path + index + ".png"); + } + return icons; + } + + public RefreshFileSystemIcon() { + super("Refreshing filesystem", ICONS, EmptyIcon.ICON_16, 800); + } + + @Override + public Dimension getPreferredSize() { + if (!isRunning()) return new Dimension(0, 0); + return super.getPreferredSize(); + } + + @Override + public void paint(Graphics g) { + g.translate(0, -1); + super.paint(g); + g.translate(0, 1); + } +} diff --git a/platform/platform-impl/src/com/intellij/ide/IdeTooltip.java b/platform/platform-impl/src/com/intellij/ide/IdeTooltip.java index 59511366ce00..44224ed6f10e 100644 --- a/platform/platform-impl/src/com/intellij/ide/IdeTooltip.java +++ b/platform/platform-impl/src/com/intellij/ide/IdeTooltip.java @@ -50,7 +50,7 @@ public class IdeTooltip extends ComparableObject.Impl { private Ui myUi; - private boolean hint = false; + private boolean myHint = false; public IdeTooltip(Component component, Point point, JComponent tipComponent, Object... identity) { @@ -235,12 +235,12 @@ public class IdeTooltip extends ComparableObject.Impl { } public IdeTooltip setHint(boolean hint) { - this.hint = hint; + this.myHint = hint; return this; } public boolean isHint() { - return hint; + return myHint; } public boolean isInside(RelativePoint target) { diff --git a/platform/platform-impl/src/com/intellij/ide/actions/RevealFileAction.java b/platform/platform-impl/src/com/intellij/ide/actions/RevealFileAction.java index cbfaa06466b8..aa929d43c63b 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/RevealFileAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/RevealFileAction.java @@ -41,7 +41,7 @@ public class RevealFileAction extends DumbAwareAction { @NotNull public static String getActionName() { - return SystemInfo.isMac ? "Reveal in Finder" : "Show in " + SystemInfo.nativeFileManagerName; + return SystemInfo.isMac ? "Reveal in Finder" : "Show in " + SystemInfo.getFileManagerName(); } @Override diff --git a/platform/platform-impl/src/com/intellij/ide/actions/ShowFilePathAction.java b/platform/platform-impl/src/com/intellij/ide/actions/ShowFilePathAction.java index c7a065c40589..7d29e02c02a6 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/ShowFilePathAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/ShowFilePathAction.java @@ -35,6 +35,7 @@ import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.openapi.ui.popup.ListPopup; import com.intellij.openapi.ui.popup.PopupStep; import com.intellij.openapi.ui.popup.util.BaseListPopupStep; +import com.intellij.openapi.util.NotNullLazyValue; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.vfs.JarFileSystem; @@ -51,11 +52,19 @@ import java.awt.event.MouseEvent; import java.io.File; import java.io.IOException; import java.util.ArrayList; -import java.util.Arrays; public class ShowFilePathAction extends AnAction { private static final Logger LOG = Logger.getInstance("#com.intellij.ide.actions.ShowFilePathAction"); + private static NotNullLazyValue hasNautilusV3 = new NotNullLazyValue() { + @NotNull + @Override + protected Boolean compute() { + final String version = ExecUtil.execAndReadLine("nautilus", "--version"); + return version != null && version.startsWith("GNOME nautilus 3"); + } + }; + @Override public void update(final AnActionEvent e) { if (SystemInfo.isMac || !isSupported()) { @@ -166,7 +175,7 @@ public class ShowFilePathAction extends AnAction { public static boolean isSupported() { return SystemInfo.isWindows || Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.OPEN) || - SystemInfo.hasXdgOpen || SystemInfo.hasNautilus; + SystemInfo.hasXdgOpen() || SystemInfo.hasNautilus(); } /** @deprecated use {@linkplain #openFile(java.io.File)} (to remove in IDEA 13) */ @@ -231,7 +240,7 @@ public class ShowFilePathAction extends AnAction { return; } - if (Registry.is("ide.use.nautilus3") && SystemInfo.hasNautilus && hasNautilusV3()) { + if (Registry.is("ide.use.nautilus3") && SystemInfo.hasNautilus() && hasNautilusV3.getValue()) { if (toSelect != null) { new GeneralCommandLine("nautilus", toSelect.getCanonicalPath()).createProcess(); } @@ -242,10 +251,10 @@ public class ShowFilePathAction extends AnAction { } final String path = dir.getCanonicalPath(); - if (SystemInfo.hasXdgOpen) { + if (SystemInfo.hasXdgOpen()) { new GeneralCommandLine("/usr/bin/xdg-open", path).createProcess(); } - else if (SystemInfo.hasNautilus) { + else if (SystemInfo.hasNautilus()) { new GeneralCommandLine("nautilus", path).createProcess(); } else if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.OPEN)) { @@ -256,16 +265,6 @@ public class ShowFilePathAction extends AnAction { } } - private static Boolean hasNautilusV3 = null; - - private static boolean hasNautilusV3() { - if (hasNautilusV3 == null) { - final String version = ExecUtil.execAndReadLine(Arrays.asList("nautilus", "--version")); - hasNautilusV3 = version != null && version.startsWith("GNOME nautilus 3"); - } - return hasNautilusV3; - } - @Nullable private static VirtualFile getFile(final AnActionEvent e) { return PlatformDataKeys.VIRTUAL_FILE.getData(e.getDataContext()); diff --git a/platform/platform-impl/src/com/intellij/ide/actions/ShowLogAction.java b/platform/platform-impl/src/com/intellij/ide/actions/ShowLogAction.java index 1c99f828dcf8..ed5914b49483 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/ShowLogAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/ShowLogAction.java @@ -44,6 +44,6 @@ public class ShowLogAction extends AnAction implements DumbAware { @NotNull public static String getActionName() { - return "Reveal Log in " + SystemInfo.nativeFileManagerName; + return "Reveal Log in " + SystemInfo.getFileManagerName(); } } diff --git a/platform/platform-impl/src/com/intellij/ide/actions/Switcher.java b/platform/platform-impl/src/com/intellij/ide/actions/Switcher.java index 63b0ae1525a1..757c5a9d194a 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/Switcher.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/Switcher.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -34,6 +34,7 @@ import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.Iconable; import com.intellij.openapi.util.Pair; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vcs.FileStatus; import com.intellij.openapi.vcs.FileStatusManager; import com.intellij.openapi.vfs.VirtualFile; @@ -43,10 +44,8 @@ import com.intellij.openapi.wm.ToolWindowManager; import com.intellij.openapi.wm.ex.WindowManagerEx; import com.intellij.openapi.wm.impl.IdeFrameImpl; import com.intellij.openapi.wm.impl.ToolWindowManagerImpl; -import com.intellij.ui.ColoredListCellRenderer; -import com.intellij.ui.Gray; -import com.intellij.ui.IdeBorderFactory; -import com.intellij.ui.SimpleTextAttributes; +import com.intellij.openapi.wm.impl.content.GraphicsConfig; +import com.intellij.ui.*; import com.intellij.ui.components.JBList; import com.intellij.util.Alarm; import com.intellij.util.ArrayUtil; @@ -62,6 +61,8 @@ import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import java.awt.*; import java.awt.event.*; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; import java.io.File; import java.util.*; import java.util.List; @@ -121,10 +122,12 @@ public class Switcher extends AnAction implements DumbAware { ToolWindow tw; if (SWITCHER != null && event instanceof KeyEvent) { final KeyEvent keyEvent = (KeyEvent)event; - if (event.getID() == KEY_RELEASED && keyEvent.getKeyCode() == CTRL_KEY && UISettings.getInstance().HIDE_SWITCHER_ON_CONTROL_RELEASE) { + if (event.getID() == KEY_RELEASED && keyEvent.getKeyCode() == CTRL_KEY && isAutoHide()) { SwingUtilities.invokeLater(CHECKER); } - else if (event.getID() == KEY_PRESSED && (tw = SWITCHER.twShortcuts.get(String.valueOf((char)keyEvent.getKeyCode()))) != null) { + else if (isAutoHide() + && event.getID() == KEY_PRESSED + && (tw = SWITCHER.twShortcuts.get(String.valueOf((char)keyEvent.getKeyCode()))) != null) { SWITCHER.myPopup.closeOk(null); tw.activate(null, true, true); } @@ -176,6 +179,7 @@ public class Switcher extends AnAction implements DumbAware { final Project project; final Map twShortcuts; final Alarm myAlarm; + final SwitcherSpeedSearch mySpeedSearch = isAutoHide() ? null : new SwitcherSpeedSearch(); @SuppressWarnings({"ManualArrayToCollectionCopy"}) SwitcherPanel(Project project) { @@ -225,7 +229,7 @@ public class Switcher extends AnAction implements DumbAware { toolWindows = new JBList(twModel); toolWindows.setBorder(IdeBorderFactory.createEmptyBorder(5, 5, 5, 20)); toolWindows.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - toolWindows.setCellRenderer(new SwitcherToolWindowsListRenderer(ids, map) { + toolWindows.setCellRenderer(new SwitcherToolWindowsListRenderer(mySpeedSearch, ids, map) { @Override public Component getListCellRendererComponent(JList list, Object value, @@ -297,7 +301,7 @@ public class Switcher extends AnAction implements DumbAware { files = new JBList(filesModel); files.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); files.setBorder(IdeBorderFactory.createEmptyBorder(5, 5, 5, 20)); - files.setCellRenderer(new VirtualFilesRenderer(project) { + files.setCellRenderer(new VirtualFilesRenderer(project, mySpeedSearch) { @Override public Component getListCellRendererComponent(JList list, Object value, @@ -381,19 +385,33 @@ public class Switcher extends AnAction implements DumbAware { .setRequestFocus(true) .setTitle(SWITCHER_TITLE) .setMovable(false) + .setCancelKeyEnabled(false) .setCancelCallback(new Computable() { - public Boolean compute() { - SWITCHER = null; - return true; - } - }).createPopup(); + public Boolean compute() { + SWITCHER = null; + return true; + } + }).createPopup(); - new AnAction(null, null, null){ + if (!isAutoHide()) { + new AnAction(null, null, null) { @Override public void actionPerformed(AnActionEvent e) { //suppress all actions to activate a toolwindow : IDEA-71277 } }.registerCustomShortcutSet(TW_SHORTCUT, this, myPopup); + new AnAction(null, null, null) { + + @Override + public void actionPerformed(AnActionEvent e) { + if (mySpeedSearch != null && mySpeedSearch.isPopupActive()) { + mySpeedSearch.hidePopup(); + } else { + myPopup.cancel(); + } + } + }.registerCustomShortcutSet(CustomShortcutSet.fromString("ESCAPE"), this, myPopup); + } Component comp = null; final EditorWindow result = FileEditorManagerEx.getInstanceEx(project).getActiveWindow().getResult(); @@ -407,6 +425,7 @@ public class Switcher extends AnAction implements DumbAware { myPopup.showInCenterOf(comp); } + private Map createShortcuts(List windows) { final Map keymap = new HashMap(windows.size()); final List pluginToolWindows = new ArrayList(); @@ -441,7 +460,7 @@ public class Switcher extends AnAction implements DumbAware { } public void keyReleased(KeyEvent e) { - if ((e.getKeyCode() == CTRL_KEY && UISettings.getInstance().HIDE_SWITCHER_ON_CONTROL_RELEASE) + if ((e.getKeyCode() == CTRL_KEY && isAutoHide()) || e.getKeyCode() == VK_ENTER) { navigate(); } else @@ -453,6 +472,8 @@ public class Switcher extends AnAction implements DumbAware { } public void keyPressed(KeyEvent e) { + if (mySpeedSearch != null && mySpeedSearch.isPopupActive()) return; + switch (e.getKeyCode()) { case VK_UP: goBack(); @@ -546,7 +567,7 @@ public class Switcher extends AnAction implements DumbAware { } private void goRight() { - if ((isFilesSelected() || !isFilesVisible()) && UISettings.getInstance().HIDE_SWITCHER_ON_CONTROL_RELEASE) { + if ((isFilesSelected() || !isFilesVisible()) && isAutoHide()) { cancel(); } else { @@ -562,7 +583,7 @@ public class Switcher extends AnAction implements DumbAware { } private void goLeft() { - if (isToolWindowsSelected() && UISettings.getInstance().HIDE_SWITCHER_ON_CONTROL_RELEASE) { + if (isToolWindowsSelected() && isAutoHide()) { cancel(); } else { @@ -699,26 +720,102 @@ public class Switcher extends AnAction implements DumbAware { repaintLists(); } public void mouseDragged(MouseEvent e) {} + + private class SwitcherSpeedSearch extends SpeedSearchBase implements PropertyChangeListener { + private Object[] myElements; + + public SwitcherSpeedSearch() { + super(SwitcherPanel.this); + addChangeListener(this); + } + + @Override + protected int getSelectedIndex() { + return isFilesSelected() + ? files.getSelectedIndex() + : files.getModel().getSize() + toolWindows.getSelectedIndex(); + } + + @Override + protected Object[] getAllElements() { + if (myElements == null) { + final SwitcherPanel switcher = SwitcherPanel.this; + final Object[] files = ((DefaultListModel)switcher.files.getModel()).toArray(); + final Object[] toolWindows = ((DefaultListModel)switcher.toolWindows.getModel()).toArray(); + myElements = new Object[files.length + toolWindows.length]; + System.arraycopy(files, 0, myElements, 0, files.length); + System.arraycopy(toolWindows, 0, myElements, files.length, toolWindows.length); + } + return myElements; + } + + + @Override + protected String getElementText(Object element) { + return element instanceof ToolWindow + ? ids.get(element) + : element instanceof FileInfo + ? ((FileInfo)element).getFirst().getName() : ""; + } + + @Override + protected void selectElement(Object element, String selectedText) { + if (element instanceof FileInfo) { + toolWindows.getSelectionModel().clearSelection(); + files.setSelectedValue(element, false); + } else { + files.clearSelection(); + toolWindows.setSelectedValue(element, false); + } + } + + @Override + public void propertyChange(PropertyChangeEvent evt) { + files.repaint(); + toolWindows.repaint(); + } + } + } + + private static boolean isAutoHide() { + return UISettings.getInstance().HIDE_SWITCHER_ON_CONTROL_RELEASE; } private static class VirtualFilesRenderer extends ColoredListCellRenderer { private final Project myProject; + private final SpeedSearchBase mySearch; + private boolean hide = false; - public VirtualFilesRenderer(Project project) { + public VirtualFilesRenderer(Project project, SpeedSearchBase search) { myProject = project; + mySearch = search; } protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) { + hide = false; if (value instanceof FileInfo) { final VirtualFile virtualFile = ((FileInfo)value).first; final String name = virtualFile.getPresentableName(); setIcon(IconUtil.getIcon(virtualFile, Iconable.ICON_FLAG_READ_STATUS, myProject)); + if ( mySearch != null && mySearch.isPopupActive()) { + hide = mySearch.matchingFragments(name) == null && !StringUtil.isEmpty(mySearch.getEnteredPrefix()); + } final FileStatus fileStatus = FileStatusManager.getInstance(myProject).getStatus(virtualFile); final TextAttributes attributes = new TextAttributes(fileStatus.getColor(), null, null, EffectType.LINE_UNDERSCORE, Font.PLAIN); append(name, SimpleTextAttributes.fromTextAttributes(attributes)); } } + + @Override + protected void doPaint(Graphics2D g) { + GraphicsConfig config = new GraphicsConfig(g); + if (hide) { + g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f)); + } + super.doPaint(g); + config.restore(); + } } private static class FileInfo extends Pair { diff --git a/platform/platform-impl/src/com/intellij/ide/actions/SwitcherToolWindowsListRenderer.java b/platform/platform-impl/src/com/intellij/ide/actions/SwitcherToolWindowsListRenderer.java index c56a31fd792d..e9117d735aa7 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/SwitcherToolWindowsListRenderer.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/SwitcherToolWindowsListRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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,11 +15,15 @@ */ package com.intellij.ide.actions; +import com.intellij.ide.ui.UISettings; import com.intellij.openapi.editor.markup.EffectType; import com.intellij.openapi.editor.markup.TextAttributes; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.wm.ToolWindow; +import com.intellij.openapi.wm.impl.content.GraphicsConfig; import com.intellij.ui.ColoredListCellRenderer; import com.intellij.ui.SimpleTextAttributes; +import com.intellij.ui.SpeedSearchBase; import com.intellij.util.PlatformIcons; import javax.swing.*; @@ -34,26 +38,51 @@ import java.util.Map; class SwitcherToolWindowsListRenderer extends ColoredListCellRenderer { private static final Map iconCache = new HashMap(); private static final SimpleTextAttributes ID_STYLE = new SimpleTextAttributes(SimpleTextAttributes.STYLE_UNDERLINE, Color.black); + private final SpeedSearchBase mySpeedSearch; private final Map ids; private final Map shortcuts; + private boolean hide = false; - SwitcherToolWindowsListRenderer(Map ids, Map shortcuts) { + SwitcherToolWindowsListRenderer(SpeedSearchBase speedSearch, + Map ids, + Map shortcuts) { + mySpeedSearch = speedSearch; this.ids = ids; this.shortcuts = shortcuts; } protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) { + hide = false; if (value instanceof ToolWindow) { final ToolWindow tw = (ToolWindow)value; setIcon(getIcon(tw)); - append(shortcuts.get(tw), ID_STYLE); - final String name = ": " + ids.get(tw); + final String name; + + if (UISettings.getInstance().HIDE_SWITCHER_ON_CONTROL_RELEASE) { + append(shortcuts.get(tw), ID_STYLE); + name = ": " + ids.get(tw); + } else { + name = ids.get(tw); + } final TextAttributes attributes = new TextAttributes(Color.BLACK, null, null, EffectType.LINE_UNDERSCORE, Font.PLAIN); append(name, SimpleTextAttributes.fromTextAttributes(attributes)); + if (mySpeedSearch != null && mySpeedSearch.isPopupActive()) { + hide = mySpeedSearch.matchingFragments(ids.get(tw)) == null && !StringUtil.isEmpty(mySpeedSearch.getEnteredPrefix()); + } } } + @Override + protected void doPaint(Graphics2D g) { + GraphicsConfig config = new GraphicsConfig(g); + if (hide) { + g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f)); + } + super.doPaint(g); + config.restore(); + } + private Icon getIcon(ToolWindow toolWindow) { Icon icon = iconCache.get(ids.get(toolWindow)); if (icon != null) return icon; diff --git a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterKeyPasswordSafe.java b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterKeyPasswordSafe.java index 82fad28a4996..c632778b2646 100644 --- a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterKeyPasswordSafe.java +++ b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterKeyPasswordSafe.java @@ -26,6 +26,7 @@ import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.SystemInfo; +import com.intellij.ui.GuiUtils; import java.io.UnsupportedEncodingException; import java.util.HashMap; @@ -182,7 +183,7 @@ public class MasterKeyPasswordSafe extends BasePasswordSafeProvider { } if (key.get() == null) { final Ref ex = new Ref(); - ApplicationManager.getApplication().invokeAndWait(new Runnable() { + GuiUtils.invokeAndWaitIfNeeded(new Runnable() { public void run() { if (key.get() == null) { try { diff --git a/platform/platform-impl/src/com/intellij/ide/passwordSafe/ui/PasswordSafePromptDialog.java b/platform/platform-impl/src/com/intellij/ide/passwordSafe/ui/PasswordSafePromptDialog.java index 21254efc1ba6..798875c744f9 100644 --- a/platform/platform-impl/src/com/intellij/ide/passwordSafe/ui/PasswordSafePromptDialog.java +++ b/platform/platform-impl/src/com/intellij/ide/passwordSafe/ui/PasswordSafePromptDialog.java @@ -18,12 +18,12 @@ package com.intellij.ide.passwordSafe.ui; import com.intellij.ide.passwordSafe.PasswordSafe; import com.intellij.ide.passwordSafe.PasswordSafeException; import com.intellij.ide.passwordSafe.impl.PasswordSafeImpl; -import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.Messages; +import com.intellij.ui.GuiUtils; import com.intellij.util.ui.UIUtil; import javax.swing.*; @@ -273,7 +273,7 @@ public class PasswordSafePromptDialog extends DialogWrapper { } } final AtomicReference pw = new AtomicReference(null); - ApplicationManager.getApplication().invokeAndWait(new Runnable() { + GuiUtils.invokeAndWaitIfNeeded(new Runnable() { public void run() { final PasswordSafePromptDialog d = new PasswordSafePromptDialog(project, ps, title, message); if (promptLabel != null) { diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/impl/incrementalMerge/Change.java b/platform/platform-impl/src/com/intellij/openapi/diff/impl/incrementalMerge/Change.java index faca9fb447ed..553b31a4e6f2 100644 --- a/platform/platform-impl/src/com/intellij/openapi/diff/impl/incrementalMerge/Change.java +++ b/platform/platform-impl/src/com/intellij/openapi/diff/impl/incrementalMerge/Change.java @@ -40,13 +40,13 @@ import java.util.Comparator; public abstract class Change { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.diff.impl.incrementalMerge.Change"); - private void apply(FragmentSide original) { + private void apply(@NotNull FragmentSide original) { FragmentSide targetSide = original.otherSide(); RangeMarker originalRangeMarker = getRangeMarker(original); RangeMarker rangeMarker = getRangeMarker(targetSide); if (originalRangeMarker != null && rangeMarker != null) { - ChangeType.apply(originalRangeMarker, rangeMarker); + ChangeType.apply(getProject(), originalRangeMarker, rangeMarker); if (isValid()) { removeFromList(); } diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/impl/incrementalMerge/ChangeType.java b/platform/platform-impl/src/com/intellij/openapi/diff/impl/incrementalMerge/ChangeType.java index e444ae67651e..fceefcf3cdf3 100644 --- a/platform/platform-impl/src/com/intellij/openapi/diff/impl/incrementalMerge/ChangeType.java +++ b/platform/platform-impl/src/com/intellij/openapi/diff/impl/incrementalMerge/ChangeType.java @@ -25,7 +25,9 @@ import com.intellij.openapi.editor.markup.HighlighterLayer; import com.intellij.openapi.editor.markup.HighlighterTargetArea; import com.intellij.openapi.editor.markup.RangeHighlighter; import com.intellij.openapi.editor.markup.SeparatorPlacement; +import com.intellij.openapi.project.Project; import com.intellij.openapi.util.TextRange; +import com.intellij.openapi.vfs.ReadonlyStatusHandler; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -92,8 +94,9 @@ public class ChangeType { return CHANGE; } - public static void apply(RangeMarker original, RangeMarker target) { + public static void apply(@NotNull Project project, @NotNull RangeMarker original, @NotNull RangeMarker target) { Document document = target.getDocument(); + if (!ReadonlyStatusHandler.ensureDocumentWritable(project, document)) return; if (DocumentUtil.isEmpty(original)) { int offset = target.getStartOffset(); document.deleteString(offset, target.getEndOffset()); diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/impl/util/DocumentUtil.java b/platform/platform-impl/src/com/intellij/openapi/diff/impl/util/DocumentUtil.java index b1567ece92f1..d15496b1a543 100644 --- a/platform/platform-impl/src/com/intellij/openapi/diff/impl/util/DocumentUtil.java +++ b/platform/platform-impl/src/com/intellij/openapi/diff/impl/util/DocumentUtil.java @@ -17,6 +17,7 @@ package com.intellij.openapi.diff.impl.util; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.RangeMarker; +import org.jetbrains.annotations.NotNull; public class DocumentUtil { @@ -24,7 +25,7 @@ public class DocumentUtil { return range.getDocument().getText().substring(range.getStartOffset(), range.getEndOffset()); } - public static boolean isEmpty(RangeMarker rangeMarker) { + public static boolean isEmpty(@NotNull RangeMarker rangeMarker) { return rangeMarker.getStartOffset() == rangeMarker.getEndOffset(); } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/ex/ErrorStripTooltipRendererProvider.java b/platform/platform-impl/src/com/intellij/openapi/editor/ex/ErrorStripTooltipRendererProvider.java index 195fe6ffcd35..9236d90ae977 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/ex/ErrorStripTooltipRendererProvider.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/ex/ErrorStripTooltipRendererProvider.java @@ -34,5 +34,6 @@ public interface ErrorStripTooltipRendererProvider { TooltipRenderer calcTooltipRenderer(@NotNull String text); TooltipRenderer calcTooltipRenderer(@NotNull String text, int width); - TrafficTooltipRenderer createTrafficTooltipRenderer(Runnable onHide, Editor editor); + @NotNull + TrafficTooltipRenderer createTrafficTooltipRenderer(@NotNull Runnable onHide, @NotNull Editor editor); } \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorMarkupModelImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorMarkupModelImpl.java index 698ddff7dabd..2b11e3e28c5a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorMarkupModelImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorMarkupModelImpl.java @@ -813,8 +813,9 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark return new LineTooltipRenderer(text, width, new Object[] {text}); } + @NotNull @Override - public TrafficTooltipRenderer createTrafficTooltipRenderer(final Runnable onHide, Editor editor) { + public TrafficTooltipRenderer createTrafficTooltipRenderer(@NotNull final Runnable onHide, @NotNull Editor editor) { return new TrafficTooltipRenderer() { @Override public void repaintTooltipWindow() { diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java index be81bbc8b2ea..20cc6e469da5 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java @@ -166,7 +166,7 @@ public class EditorsSplitters extends JPanel { painter.appendLine("Open a file by name with " + getActionShortcutText("GotoFile")).smaller().withBullet() .appendLine("Open Recent files with " + getActionShortcutText("RecentFiles")).smaller().withBullet() .appendLine("Open Navigation Bar with " + getActionShortcutText("ShowNavBar")).smaller().withBullet() - .appendLine("Drag'n'Drop file(s) here from " + SystemInfo.nativeFileManagerName).smaller().withBullet() + .appendLine("Drag'n'Drop file(s) here from " + SystemInfo.getFileManagerName()).smaller().withBullet() .draw(g, new PairFunction>() { @Override public Pair fun(Integer width, Integer height) { diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ToolWindowContentUi.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ToolWindowContentUi.java index 460b3ffe3810..a47f9ca87997 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ToolWindowContentUi.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ToolWindowContentUi.java @@ -556,6 +556,7 @@ public class ToolWindowContentUi extends JPanel implements ContentUI, PropertyCh return myContent.getDisplayName(); } + @NotNull @Override public Object[] getEqualityObjects() { return new Object[] {myContent}; diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/InfoAndProgressPanel.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/InfoAndProgressPanel.java index 0de178212d6d..7cbd2336fe4d 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/InfoAndProgressPanel.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/InfoAndProgressPanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -41,10 +41,7 @@ import com.intellij.ui.components.labels.LinkLabel; import com.intellij.ui.components.labels.LinkListener; import com.intellij.ui.components.panels.Wrapper; import com.intellij.util.Alarm; -import com.intellij.util.ui.AbstractLayoutManager; -import com.intellij.util.ui.AsyncProcessIcon; -import com.intellij.util.ui.EmptyIcon; -import com.intellij.util.ui.UIUtil; +import com.intellij.util.ui.*; import com.intellij.util.ui.update.MergingUpdateQueue; import com.intellij.util.ui.update.Update; import org.jetbrains.annotations.NotNull; @@ -63,7 +60,7 @@ public class InfoAndProgressPanel extends JPanel implements CustomStatusBarWidge private final StatusPanel myInfoPanel = new StatusPanel(); private final JPanel myRefreshAndInfoPanel = new JPanel(); - private final AsyncProcessIcon myProgressIcon; + private final AnimatedIcon myProgressIcon; private final ArrayList myOriginals = new ArrayList(); private final ArrayList myInfos = new ArrayList(); @@ -78,7 +75,7 @@ public class InfoAndProgressPanel extends JPanel implements CustomStatusBarWidge private boolean myShouldClosePopupAndOnProcessFinish; private final Alarm myRefreshAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD); - private AsyncProcessIcon myRefreshIcon; + private AnimatedIcon myRefreshIcon; private EmptyIcon myEmptyRefreshIcon; private String myCurrentRequestor; @@ -89,24 +86,25 @@ public class InfoAndProgressPanel extends JPanel implements CustomStatusBarWidge setOpaque(false); - myRefreshIcon = new AsyncProcessIcon("Refreshing filesystem") { - protected Icon getPassiveIcon() { - return myEmptyRefreshIcon; - } - - @Override - public Dimension getPreferredSize() { - if (!isRunning()) return new Dimension(0, 0); - return super.getPreferredSize(); - } - - @Override - public void paint(Graphics g) { - g.translate(0, -1); - super.paint(g); - g.translate(0, 1); - } - }; + myRefreshIcon = new RefreshFileSystemIcon(); + // new AsyncProcessIcon("Refreshing filesystem") { + // protected Icon getPassiveIcon() { + // return myEmptyRefreshIcon; + // } + // + // @Override + // public Dimension getPreferredSize() { + // if (!isRunning()) return new Dimension(0, 0); + // return super.getPreferredSize(); + // } + // + // @Override + // public void paint(Graphics g) { + // g.translate(0, -1); + // super.paint(g); + // g.translate(0, 1); + // } + //}; myRefreshIcon.setPaintPassiveIcon(false); myEmptyRefreshIcon = new EmptyIcon(0, myRefreshIcon.getPreferredSize().height); diff --git a/platform/platform-impl/src/com/intellij/platform/NewDirectoryProjectDialog.form b/platform/platform-impl/src/com/intellij/platform/NewDirectoryProjectDialog.form index f6cb2a950a68..d7c77b76f80f 100644 --- a/platform/platform-impl/src/com/intellij/platform/NewDirectoryProjectDialog.form +++ b/platform/platform-impl/src/com/intellij/platform/NewDirectoryProjectDialog.form @@ -69,6 +69,14 @@ + + + + + + + + diff --git a/platform/platform-impl/src/com/intellij/platform/NewDirectoryProjectDialog.java b/platform/platform-impl/src/com/intellij/platform/NewDirectoryProjectDialog.java index 5db9e834d197..8f5be8dea8d3 100644 --- a/platform/platform-impl/src/com/intellij/platform/NewDirectoryProjectDialog.java +++ b/platform/platform-impl/src/com/intellij/platform/NewDirectoryProjectDialog.java @@ -46,6 +46,12 @@ public class NewDirectoryProjectDialog extends DialogWrapper { private JPanel myProjectTypePanel; private JLabel myLocationLabel; + protected JPanel getPlaceHolder() { + return myPlaceHolder; + } + + private JPanel myPlaceHolder; + private static final Object EMPTY_PROJECT_GENERATOR = new Object(); protected NewDirectoryProjectDialog(Project project) { diff --git a/platform/platform-impl/src/com/intellij/ui/HeavyweightHint.java b/platform/platform-impl/src/com/intellij/ui/HeavyweightHint.java index e6f2553604c3..374c3fa89a0c 100644 --- a/platform/platform-impl/src/com/intellij/ui/HeavyweightHint.java +++ b/platform/platform-impl/src/com/intellij/ui/HeavyweightHint.java @@ -115,17 +115,17 @@ public class HeavyweightHint implements Hint { } @Override - public void setLocation(RelativePoint point) { + public void setLocation(@NotNull RelativePoint point) { if (myWindow != null) { myWindow.setLocation(point.getScreenPoint().x, point.getScreenPoint().y); } } - public void addHintListener(HintListener listener) { + public void addHintListener(@NotNull HintListener listener) { myListenerList.add(HintListener.class, listener); } - public void removeHintListener(HintListener listener) { + public void removeHintListener(@NotNull HintListener listener) { myListenerList.remove(HintListener.class, listener); } } \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/ui/Hint.java b/platform/platform-impl/src/com/intellij/ui/Hint.java index 451ee6fbffd9..bbdba268e32b 100644 --- a/platform/platform-impl/src/com/intellij/ui/Hint.java +++ b/platform/platform-impl/src/com/intellij/ui/Hint.java @@ -48,13 +48,13 @@ public interface Hint { */ void hide(); - void addHintListener(HintListener listener); + void addHintListener(@NotNull HintListener listener); - void removeHintListener(HintListener listener); + void removeHintListener(@NotNull HintListener listener); void pack(); - void setLocation(RelativePoint point); + void setLocation(@NotNull RelativePoint point); /** * Pack and set location diff --git a/platform/platform-impl/src/com/intellij/ui/LightweightHint.java b/platform/platform-impl/src/com/intellij/ui/LightweightHint.java index 0f09b4ec66dc..895b38a61e3e 100644 --- a/platform/platform-impl/src/com/intellij/ui/LightweightHint.java +++ b/platform/platform-impl/src/com/intellij/ui/LightweightHint.java @@ -110,6 +110,7 @@ public class LightweightHint extends UserDataHolderBase implements Hint { * are in parentComponent coordinate system. Note that the component * appears on 250 layer. */ + @Override public void show(@NotNull final JComponent parentComponent, final int x, final int y, @@ -129,29 +130,33 @@ public class LightweightHint extends UserDataHolderBase implements Hint { myComponent.validate(); if (!myForceShowAsPopup && - (myForceLightweightPopup || fitsLayeredPane(layeredPane, myComponent, new RelativePoint(parentComponent, new Point(x, y)), hintHint))) { + (myForceLightweightPopup || + fitsLayeredPane(layeredPane, myComponent, new RelativePoint(parentComponent, new Point(x, y)), hintHint))) { beforeShow(); final Dimension preferredSize = myComponent.getPreferredSize(); if (hintHint.isAwtTooltip()) { - IdeTooltip tooltip = new IdeTooltip(hintHint.getOriginalComponent(), hintHint.getOriginalPoint(), myComponent, hintHint, myComponent) { - @Override - protected boolean canAutohideOn(TooltipEvent event) { - if (event.getInputEvent() instanceof MouseEvent) { - return !(hintHint.isContentActive() && event.isIsEventInsideBalloon()); - } else if (event.getAction() != null) { - return false; - } else { - return true; + IdeTooltip tooltip = + new IdeTooltip(hintHint.getOriginalComponent(), hintHint.getOriginalPoint(), myComponent, hintHint, myComponent) { + @Override + protected boolean canAutohideOn(TooltipEvent event) { + if (event.getInputEvent() instanceof MouseEvent) { + return !(hintHint.isContentActive() && event.isIsEventInsideBalloon()); + } + else if (event.getAction() != null) { + return false; + } + else { + return true; + } } - } - @Override - protected void onHidden() { - fireHintHidden(); - TooltipController.getInstance().resetCurrent(); - } + @Override + protected void onHidden() { + fireHintHidden(); + TooltipController.getInstance().resetCurrent(); + } @Override public boolean canBeDismissedOnTimeout() { @@ -170,7 +175,8 @@ public class LightweightHint extends UserDataHolderBase implements Hint { .setHint(true); myComponent.validate(); myCurrentIdeTooltip = IdeTooltipManager.getInstance().show(tooltip, hintHint.isShowImmediately()); - } else { + } + else { final Point layeredPanePoint = SwingUtilities.convertPoint(parentComponent, x, y, layeredPane); myComponent.setBounds(layeredPanePoint.x, layeredPanePoint.y, preferredSize.width, preferredSize.height); layeredPane.add(myComponent, JLayeredPane.POPUP_LAYER); @@ -218,8 +224,9 @@ public class LightweightHint extends UserDataHolderBase implements Hint { myPopup.show(new RelativePoint(myParentComponent, new Point(actualPoint.x, actualPoint.y))); } } - - protected void onPopupCancel() {} + + protected void onPopupCancel() { + } private void fixActualPoint(Point actualPoint) { if (!isAwtTooltip()) return; @@ -263,11 +270,13 @@ public class LightweightHint extends UserDataHolderBase implements Hint { if (pos == Balloon.Position.above || pos == Balloon.Position.below) { boolean heightFit = target.y - size.height - pointer > 0 || target.y + size.height + pointer < paneSize.height; return heightFit && size.width + pointer < paneSize.width; - } else { + } + else { boolean widthFit = target.x - size.width - pointer > 0 || target.x + size.width + pointer < paneSize.width; return widthFit && size.height + pointer < paneSize.height; } - } else { + } + else { final Rectangle lpRect = new Rectangle(pane.getLocationOnScreen().x, pane.getLocationOnScreen().y, pane.getWidth(), pane.getHeight()); Rectangle componentRect = new Rectangle(desiredLocation.getScreenPoint().x, desiredLocation.getScreenPoint().y, @@ -291,12 +300,15 @@ public class LightweightHint extends UserDataHolderBase implements Hint { return myComponent.getBounds(); } + @Override public boolean isVisible() { if (myIsRealPopup) { return myPopup != null && myPopup.isVisible(); - } else if (myCurrentIdeTooltip != null) { + } + else if (myCurrentIdeTooltip != null) { return myComponent.isShowing() || IdeTooltipManager.getInstance().isQueuedToShow(myCurrentIdeTooltip); - } else { + } + else { return myComponent.isShowing(); } } @@ -305,6 +317,7 @@ public class LightweightHint extends UserDataHolderBase implements Hint { return myIsRealPopup | myForceShowAsPopup; } + @Override public void hide() { hide(false); } @@ -314,7 +327,8 @@ public class LightweightHint extends UserDataHolderBase implements Hint { if (myIsRealPopup) { if (ok) { myPopup.closeOk(null); - } else { + } + else { myPopup.cancel(); } myPopup = null; @@ -324,7 +338,8 @@ public class LightweightHint extends UserDataHolderBase implements Hint { IdeTooltip tooltip = myCurrentIdeTooltip; myCurrentIdeTooltip = null; tooltip.hide(); - } else { + } + else { final JRootPane rootPane = myComponent.getRootPane(); if (rootPane != null) { final Rectangle bounds = myComponent.getBounds(); @@ -375,11 +390,13 @@ public class LightweightHint extends UserDataHolderBase implements Hint { return myComponent; } - public final void addHintListener(final HintListener listener) { + @Override + public final void addHintListener(@NotNull final HintListener listener) { myListenerList.add(HintListener.class, listener); } - public final void removeHintListener(final HintListener listener) { + @Override + public final void removeHintListener(@NotNull final HintListener listener) { myListenerList.remove(HintListener.class, listener); } @@ -388,13 +405,14 @@ public class LightweightHint extends UserDataHolderBase implements Hint { if (isRealPopup()) { location = myPopup.getLocationOnScreen(); SwingUtilities.convertPointFromScreen(location, c); - } else { + } + else { if (myCurrentIdeTooltip != null) { Point tipPoint = myCurrentIdeTooltip.getPoint(); Component tipComponent = myCurrentIdeTooltip.getComponent(); return SwingUtilities.convertPoint(tipComponent, tipPoint, c); - - } else { + } + else { location = SwingUtilities.convertPoint( myComponent.getParent(), myComponent.getLocation(), @@ -407,10 +425,11 @@ public class LightweightHint extends UserDataHolderBase implements Hint { } @Override - public void setLocation(RelativePoint point) { + public void setLocation(@NotNull RelativePoint point) { if (isRealPopup()) { myPopup.setLocation(point.getScreenPoint()); - } else { + } + else { if (myCurrentIdeTooltip != null) { Point screenPoint = point.getScreenPoint(); if (!screenPoint.equals(new RelativePoint(myCurrentIdeTooltip.getComponent(), myCurrentIdeTooltip.getPoint()).getScreenPoint())) { @@ -418,7 +437,8 @@ public class LightweightHint extends UserDataHolderBase implements Hint { myCurrentIdeTooltip.setComponent(point.getComponent()); IdeTooltipManager.getInstance().show(myCurrentIdeTooltip, true, false); } - } else { + } + else { Point targetPoint = point.getPoint(myComponent.getParent()); myComponent.setLocation(targetPoint); @@ -431,11 +451,13 @@ public class LightweightHint extends UserDataHolderBase implements Hint { public void setSize(Dimension size) { if (myIsRealPopup) { myPopup.setSize(size); - } else { + } + else { //todo kirillk if (isAwtTooltip()) { return; - } else { + } + else { myComponent.setSize(size); myComponent.revalidate(); @@ -458,14 +480,17 @@ public class LightweightHint extends UserDataHolderBase implements Hint { if (myIsRealPopup) { Window wnd = SwingUtilities.getWindowAncestor(myComponent); return wnd.getBounds().contains(target.getScreenPoint()); - } else if (myCurrentIdeTooltip != null) { + } + else if (myCurrentIdeTooltip != null) { return myCurrentIdeTooltip.isInside(target); - } else { + } + else { return new Rectangle(myComponent.getLocationOnScreen(), myComponent.getSize()).contains(target.getScreenPoint()); } } private final class MyEscListener implements ActionListener { + @Override public final void actionPerformed(final ActionEvent e) { hide(); } @@ -477,7 +502,7 @@ public class LightweightHint extends UserDataHolderBase implements Hint { } public boolean canControlAutoHide() { - return myCurrentIdeTooltip != null && myCurrentIdeTooltip.getTipComponent().isShowing() ; + return myCurrentIdeTooltip != null && myCurrentIdeTooltip.getTipComponent().isShowing(); } public IdeTooltip getCurrentIdeTooltip() { diff --git a/platform/platform-impl/src/com/intellij/ui/SpeedSearchBase.java b/platform/platform-impl/src/com/intellij/ui/SpeedSearchBase.java index 797edb0b4f98..458426a846dd 100644 --- a/platform/platform-impl/src/com/intellij/ui/SpeedSearchBase.java +++ b/platform/platform-impl/src/com/intellij/ui/SpeedSearchBase.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -17,6 +17,7 @@ package com.intellij.ui; import com.intellij.featureStatistics.FeatureUsageTracker; import com.intellij.ide.DataManager; +import com.intellij.ide.ui.UISettings; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CustomShortcutSet; @@ -198,6 +199,15 @@ public abstract class SpeedSearchBase extends SpeedSear final Object element = it.next(); if (isMatchingElement(element, _s)) return element; } + + if (UISettings.getInstance().CYCLE_SCROLLING) { + final ListIterator i = getElementIterator(0); + while (i.hasNext()) { + final Object element = i.next(); + if (isMatchingElement(element, _s)) return element; + } + } + return ( current != null && isMatchingElement(current, _s) ) ? current : null; } @@ -217,6 +227,15 @@ public abstract class SpeedSearchBase extends SpeedSear final Object element = it.previous(); if (isMatchingElement(element, _s)) return element; } + + if (UISettings.getInstance().CYCLE_SCROLLING) { + final ListIterator i = getElementIterator(getAllElements().length); + while (i.hasPrevious()) { + final Object element = i.previous(); + if (isMatchingElement(element, _s)) return element; + } + } + return selectedIndex != -1 && isMatchingElement(current, _s) ? current : null; } diff --git a/platform/platform-tests/testSrc/com/intellij/ide/bookmarks/BookmarkManagerTest.java b/platform/platform-tests/testSrc/com/intellij/ide/bookmarks/BookmarkManagerTest.java index 81be185a1aa4..eae298f2cd06 100644 --- a/platform/platform-tests/testSrc/com/intellij/ide/bookmarks/BookmarkManagerTest.java +++ b/platform/platform-tests/testSrc/com/intellij/ide/bookmarks/BookmarkManagerTest.java @@ -19,7 +19,12 @@ import com.intellij.openapi.editor.CaretModel; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.LogicalPosition; import com.intellij.openapi.editor.impl.AbstractEditorProcessingOnDocumentModificationTest; +import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.fileEditor.OpenFileDescriptor; +import com.intellij.openapi.vfs.VfsUtil; +import com.intellij.testFramework.LeakHunter; +import com.intellij.testFramework.TestFileType; +import org.jetbrains.annotations.NonNls; import java.io.IOException; import java.util.ArrayList; @@ -30,7 +35,6 @@ import java.util.List; * @since 12/27/10 1:43 PM */ public class BookmarkManagerTest extends AbstractEditorProcessingOnDocumentModificationTest { - private final List myBookmarks = new ArrayList(); @Override @@ -43,13 +47,13 @@ public class BookmarkManagerTest extends AbstractEditorProcessingOnDocumentModif } public void testWholeTextReplace() throws IOException { - String text = + @NonNls String text = "public class Test {\n" + " public void test() {\n" + " int i = 1;\n" + " }\n" + "}"; - init(text); + init(text, TestFileType.TEXT); addBookmark(2); List bookmarksBefore = getManager().getValidBookmarks(); @@ -60,19 +64,19 @@ public class BookmarkManagerTest extends AbstractEditorProcessingOnDocumentModif assertEquals(1, bookmarksAfter.size()); assertSame(bookmarksBefore.get(0), bookmarksAfter.get(0)); for (Bookmark bookmark : bookmarksAfter) { - checkBookmark(bookmark); + checkBookmarkNavigation(bookmark); } } public void testBookmarkLineRemove() throws IOException { - String text = + @NonNls String text = "public class Test {\n" + " public void test() {\n" + " int i = 1;\n" + " }\n" + "}"; - init(text); - + init(text, TestFileType.TEXT); + addBookmark(2); Document document = myEditor.getDocument(); myEditor.getSelectionModel().setSelection(document.getLineStartOffset(2) - 1, document.getLineEndOffset(2)); @@ -81,13 +85,13 @@ public class BookmarkManagerTest extends AbstractEditorProcessingOnDocumentModif } public void testBookmarkIsSavedAfterRemoteChange() throws IOException { - String text = + @NonNls String text = "public class Test {\n" + " public void test() {\n" + " int i = 1;\n" + " }\n" + "}"; - init(text); + init(text, TestFileType.TEXT); addBookmark(2); myEditor.getDocument().setText("111\n222" + text + "333"); @@ -95,7 +99,29 @@ public class BookmarkManagerTest extends AbstractEditorProcessingOnDocumentModif assertEquals(1, bookmarks.size()); Bookmark bookmark = bookmarks.get(0); assertEquals(3, bookmark.getLine()); - checkBookmark(bookmark); + checkBookmarkNavigation(bookmark); + } + + public void testBookmarkManagerDoesNotHardReferenceDocuments() throws IOException { + @NonNls String text = + "public class Test {\n" + + "}"; + + myVFile = getSourceRoot().createChildData(null, getTestName(false) + ".txt"); + VfsUtil.saveText(myVFile, text); + + Bookmark bookmark = getManager().addTextBookmark(myVFile, 1, "xxx"); + assertNotNull(bookmark); + LeakHunter.checkLeak(getManager(), Document.class); + + Document document = FileDocumentManager.getInstance().getDocument(myVFile); + assertNotNull(document); + + document.insertString(0, "line 0\n"); + assertEquals(2, bookmark.getLine()); + + myEditor = createEditor(myVFile); + checkBookmarkNavigation(bookmark); } private void addBookmark(int line) { @@ -106,8 +132,16 @@ public class BookmarkManagerTest extends AbstractEditorProcessingOnDocumentModif private static BookmarkManager getManager() { return BookmarkManager.getInstance(getProject()); } - - private static void checkBookmark(Bookmark bookmark) { + + @Override + public Object getData(String dataId) { + if (dataId.equals(OpenFileDescriptor.NAVIGATE_IN_EDITOR.getName())) { + return myEditor; + } + return super.getData(dataId); + } + + private static void checkBookmarkNavigation(Bookmark bookmark) { int line = bookmark.getLine(); int anotherLine = line; if (line > 0) { @@ -118,9 +152,7 @@ public class BookmarkManagerTest extends AbstractEditorProcessingOnDocumentModif } CaretModel caretModel = myEditor.getCaretModel(); caretModel.moveToLogicalPosition(new LogicalPosition(anotherLine, 0)); - OpenFileDescriptor target = bookmark.getTarget(); - assertTrue(target.canNavigate()); - target.navigateIn(myEditor); + bookmark.navigate(); assertEquals(line, caretModel.getLogicalPosition().line); } } diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/AbstractEditorProcessingOnDocumentModificationTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/AbstractEditorProcessingOnDocumentModificationTest.java index d9a2fc1ccfb2..daeed2381f55 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/AbstractEditorProcessingOnDocumentModificationTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/AbstractEditorProcessingOnDocumentModificationTest.java @@ -44,12 +44,7 @@ import java.util.regex.Pattern; * @since 11/18/10 7:43 PM */ public abstract class AbstractEditorProcessingOnDocumentModificationTest extends LightPlatformCodeInsightTestCase { - - protected void init(String fileText) throws IOException { - init(fileText, TestFileType.TEXT); - } - - protected void init(String fileText, TestFileType type) throws IOException { + protected void init(@NotNull String fileText, @NotNull TestFileType type) throws IOException { configureFromFileText(getFileName(type), fileText); } diff --git a/platform/util-rt/src/com/intellij/openapi/diagnostic/rt/Logger.java b/platform/util-rt/src/com/intellij/openapi/diagnostic/LoggerRt.java similarity index 89% rename from platform/util-rt/src/com/intellij/openapi/diagnostic/rt/Logger.java rename to platform/util-rt/src/com/intellij/openapi/diagnostic/LoggerRt.java index 8eb116e18585..2e25291e4b6c 100644 --- a/platform/util-rt/src/com/intellij/openapi/diagnostic/rt/Logger.java +++ b/platform/util-rt/src/com/intellij/openapi/diagnostic/LoggerRt.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.intellij.openapi.diagnostic.rt; +package com.intellij.openapi.diagnostic; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -22,15 +22,16 @@ import org.jetbrains.annotations.Nullable; import java.lang.reflect.Method; import java.util.logging.Level; import java.util.logging.LogManager; +import java.util.logging.Logger; /** * A wrapper which uses either IDE logging subsystem (if available) or java.util.logging. * * @since 12.0 */ -public abstract class Logger { +public abstract class LoggerRt { private interface Factory { - Logger getInstance(@NotNull @NonNls final String category); + LoggerRt getInstance(@NotNull @NonNls final String category); } private static Factory ourFactory; @@ -48,7 +49,7 @@ public abstract class Logger { } @NotNull - public static Logger getInstance(@NotNull @NonNls final String category) { + public static LoggerRt getInstance(@NotNull @NonNls final String category) { return getFactory().getInstance(category); } @@ -84,9 +85,9 @@ public abstract class Logger { private final LogManager myManager = LogManager.getLogManager(); @Override - public Logger getInstance(@NotNull @NonNls final String category) { - final java.util.logging.Logger logger = myManager.getLogger(category); - return new Logger() { + public LoggerRt getInstance(@NotNull @NonNls final String category) { + final Logger logger = myManager.getLogger(category); + return new LoggerRt() { @Override public void info(@Nullable @NonNls final String message, @Nullable final Throwable t) { logger.log(Level.INFO, message, t); @@ -124,10 +125,10 @@ public abstract class Logger { } @Override - public Logger getInstance(@NotNull @NonNls final String category) { + public LoggerRt getInstance(@NotNull @NonNls final String category) { try { final Object logger = myGetInstance.invoke(null, category); - return new Logger() { + return new LoggerRt() { @Override public void info(@Nullable @NonNls final String message, @Nullable final Throwable t) { try { diff --git a/platform/util-rt/src/com/intellij/openapi/util/io/FileUtilRt.java b/platform/util-rt/src/com/intellij/openapi/util/io/FileUtilRt.java index 2881afe12457..1b7440f97c56 100644 --- a/platform/util-rt/src/com/intellij/openapi/util/io/FileUtilRt.java +++ b/platform/util-rt/src/com/intellij/openapi/util/io/FileUtilRt.java @@ -15,7 +15,7 @@ */ package com.intellij.openapi.util.io; -import com.intellij.openapi.diagnostic.rt.Logger; +import com.intellij.openapi.diagnostic.LoggerRt; import com.intellij.openapi.util.SystemInfoRt; import com.intellij.openapi.util.text.StringUtilRt; import org.jetbrains.annotations.NonNls; @@ -34,7 +34,7 @@ import java.util.UUID; */ @SuppressWarnings({"UtilityClassWithoutPrivateConstructor"}) public class FileUtilRt { - private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.util.io.FileUtilLight"); + private static final LoggerRt LOG = LoggerRt.getInstance("#com.intellij.openapi.util.io.FileUtilLight"); protected static final ThreadLocal BUFFER = new ThreadLocal() { protected byte[] initialValue() { diff --git a/platform/util/src/com/intellij/openapi/util/SystemInfo.java b/platform/util/src/com/intellij/openapi/util/SystemInfo.java index c62c32b6a71e..5921da2f0e62 100644 --- a/platform/util/src/com/intellij/openapi/util/SystemInfo.java +++ b/platform/util/src/com/intellij/openapi/util/SystemInfo.java @@ -51,9 +51,6 @@ public class SystemInfo extends SystemInfoRt { public static final boolean isKDE = _SUN_DESKTOP.contains("kde"); public static final boolean isGnome = _SUN_DESKTOP.contains("gnome"); - public static final boolean hasNautilus = isUnix && new File("/usr/bin/nautilus").canExecute(); - public static final boolean hasXdgOpen = isUnix && new File("/usr/bin/xdg-open").canExecute(); - public static final boolean isMacSystemMenu = isMac && "true".equals(System.getProperty("apple.laf.useScreenMenuBar")); public static final boolean isFileSystemCaseSensitive = SystemInfoRt.isFileSystemCaseSensitive; @@ -65,10 +62,46 @@ public class SystemInfo extends SystemInfoRt { public static final boolean isAMD64 = "amd64".equals(OS_ARCH); public static final boolean isMacIntel64 = isMac && "x86_64".equals(OS_ARCH); - public static final String nativeFileManagerName = isMac ? "Finder" : - isWindows ? "Explorer" : - hasNautilus ? "Nautilus" : - "File Manager"; + /** @deprecated use {@linkplain #hasXdgOpen()} (to remove in IDEA 13) */ + public static final boolean hasXdgOpen = false; + private static final NotNullLazyValue ourHasXdgOpen = new AtomicNotNullLazyValue() { + @NotNull + @Override + protected Boolean compute() { + return isUnix && new File("/usr/bin/xdg-open").canExecute(); + } + }; + public static boolean hasXdgOpen() { + return ourHasXdgOpen.getValue(); + } + + private static final NotNullLazyValue hasNautilus = new AtomicNotNullLazyValue() { + @NotNull + @Override + protected Boolean compute() { + return isUnix && new File("/usr/bin/nautilus").canExecute(); + } + }; + public static boolean hasNautilus() { + return hasNautilus.getValue(); + } + + /** @deprecated use {@linkplain #getFileManagerName()} (to remove in IDEA 13) */ + public static final String nativeFileManagerName = "File Manager"; + private static final NotNullLazyValue ourFileManagerName = new AtomicNotNullLazyValue() { + @NotNull + @Override + protected String compute() { + return isMac ? "Finder" : + isWindows ? "Explorer" : + hasNautilus() ? "Nautilus" : + "File Manager"; + } + }; + @NotNull + public static String getFileManagerName() { + return ourFileManagerName.getValue(); + } /** * Whether IDEA is running under MacOS X version 10.4 or later. diff --git a/platform/util/src/com/intellij/util/WalkingState.java b/platform/util/src/com/intellij/util/WalkingState.java index 9106b72fa6d2..c4bcb1db6081 100644 --- a/platform/util/src/com/intellij/util/WalkingState.java +++ b/platform/util/src/com/intellij/util/WalkingState.java @@ -48,8 +48,12 @@ public class WalkingState { if (!startedWalking) { stopped = false; startedWalking = true; - walkChildren(element); - startedWalking = false; + try { + walkChildren(element); + } + finally { + startedWalking = false; + } } } diff --git a/platform/util/src/com/intellij/util/ui/update/ComparableObject.java b/platform/util/src/com/intellij/util/ui/update/ComparableObject.java index bfe5f48d776e..dea34bd8b0f9 100644 --- a/platform/util/src/com/intellij/util/ui/update/ComparableObject.java +++ b/platform/util/src/com/intellij/util/ui/update/ComparableObject.java @@ -16,40 +16,43 @@ package com.intellij.util.ui.update; import com.intellij.util.ArrayUtil; +import org.jetbrains.annotations.NotNull; public interface ComparableObject { - Object[] NONE = ArrayUtil.EMPTY_OBJECT_ARRAY; + @NotNull Object[] getEqualityObjects(); class Impl implements ComparableObject { - - private Object[] myObjects; + private final Object[] myObjects; public Impl() { this(NONE); } - public Impl(Object object) { + public Impl(@NotNull Object object) { this(new Object[] {object}); } - public Impl(Object[] objects) { + public Impl(@NotNull Object[] objects) { myObjects = objects; } + @NotNull + @Override public Object[] getEqualityObjects() { return myObjects; } + @Override public final boolean equals(Object obj) { return ComparableObjectCheck.equals(this, obj); } + @Override public final int hashCode() { return ComparableObjectCheck.hashCode(this, super.hashCode()); } } - } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/RevertCommittedStuffAbstractAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/RevertCommittedStuffAbstractAction.java index 42b5a2838876..82bd8486d1ec 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/RevertCommittedStuffAbstractAction.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/RevertCommittedStuffAbstractAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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,36 +18,35 @@ package com.intellij.openapi.vcs.changes.actions; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.PlatformDataKeys; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.diff.impl.patch.BinaryFilePatch; import com.intellij.openapi.diff.impl.patch.FilePatch; import com.intellij.openapi.diff.impl.patch.IdeaTextPatchBuilder; import com.intellij.openapi.diff.impl.patch.formove.PatchApplier; +import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.progress.Task; import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.vcs.FilePath; import com.intellij.openapi.vcs.VcsBundle; import com.intellij.openapi.vcs.VcsDataKeys; import com.intellij.openapi.vcs.VcsException; -import com.intellij.openapi.vcs.changes.BackgroundFromStartOption; -import com.intellij.openapi.vcs.changes.Change; -import com.intellij.openapi.vcs.changes.ChangeList; -import com.intellij.openapi.vcs.changes.ChangeListManager; +import com.intellij.openapi.vcs.changes.*; import com.intellij.openapi.vcs.changes.ui.ChangeListChooser; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.WaitForProgressToShow; import com.intellij.util.containers.Convertor; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; +import java.util.*; abstract class RevertCommittedStuffAbstractAction extends AnAction implements DumbAware { private final Convertor myForUpdateConvertor; private final Convertor myForPerformConvertor; + private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.changes.actions.RevertCommittedStuffAbstractAction"); public RevertCommittedStuffAbstractAction(final Convertor forUpdateConvertor, final Convertor forPerformConvertor) { @@ -63,6 +62,7 @@ abstract class RevertCommittedStuffAbstractAction extends AnAction implements Du if (changes == null || changes.length == 0) return; final List changesList = new ArrayList(); Collections.addAll(changesList, changes); + FileDocumentManager.getInstance().saveAllDocuments(); String defaultName = null; final ChangeList[] changeLists = e.getData(VcsDataKeys.CHANGE_LISTS); @@ -81,7 +81,8 @@ abstract class RevertCommittedStuffAbstractAction extends AnAction implements Du @Override public void run(@NotNull ProgressIndicator indicator) { try { - patches.addAll(IdeaTextPatchBuilder.buildPatch(project, changesList, baseDir.getPresentableUrl(), true)); + final List preprocessed = preprocessChanges(changesList); + patches.addAll(IdeaTextPatchBuilder.buildPatch(project, preprocessed, baseDir.getPresentableUrl(), true)); } catch (final VcsException ex) { WaitForProgressToShow.runOrInvokeLaterAboveProgress(new Runnable() { @@ -101,6 +102,35 @@ abstract class RevertCommittedStuffAbstractAction extends AnAction implements Du }); } + private List preprocessChanges(List list) { + final List result = new ArrayList(); + final Map map = new HashMap(); + for (Change change : list) { + if (change.getBeforeRevision() == null) { + result.add(change); + } else { + final FilePath beforePath = ChangesUtil.getBeforePath(change); + final Change existing = map.get(beforePath); + if (existing == null) { + map.put(beforePath, change); + continue; + } + if (change.getAfterRevision() == null && existing.getAfterRevision() == null) continue; + if (change.getAfterRevision() != null && existing.getAfterRevision() != null) { + LOG.error("Incorrect changes list: " + list); + } + if (existing.getAfterRevision() != null && change.getAfterRevision() == null) { + continue; // skip delete change + } + if (change.getAfterRevision() != null && existing.getAfterRevision() == null) { + map.put(beforePath, change); // skip delete change + } + } + } + result.addAll(map.values()); + return result; + } + public void update(final AnActionEvent e) { final Project project = e.getData(PlatformDataKeys.PROJECT); final Change[] changes = myForUpdateConvertor.convert(e); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationPanel.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationPanel.java index 2b1b63bf1b6f..70428d9c5989 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationPanel.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationPanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -95,7 +95,8 @@ public class VcsGeneralConfigurationPanel implements SearchableConfigurable { } myPromptsPanel.setSize(myPromptsPanel.getPreferredSize()); - myOnPatchCreation.setName((SystemInfo.isMac ? "Reveal patch in" : "Show patch in ") + SystemInfo.nativeFileManagerName + " after creation:"); + myOnPatchCreation.setName((SystemInfo.isMac ? "Reveal patch in" : "Show patch in ") + + SystemInfo.getFileManagerName() + " after creation:"); } public void apply() throws ConfigurationException { diff --git a/plugins/android/testSrc/org/jetbrains/android/AndroidTestCase.java b/plugins/android/testSrc/org/jetbrains/android/AndroidTestCase.java index cd47db4f160f..563eb772b0ff 100644 --- a/plugins/android/testSrc/org/jetbrains/android/AndroidTestCase.java +++ b/plugins/android/testSrc/org/jetbrains/android/AndroidTestCase.java @@ -78,7 +78,7 @@ public abstract class AndroidTestCase extends UsefulTestCase { public void setUp() throws Exception { super.setUp(); - final TestFixtureBuilder projectBuilder = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(); + final TestFixtureBuilder projectBuilder = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(getName()); myFixture = JavaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(projectBuilder.getFixture()); final JavaModuleFixtureBuilder moduleFixtureBuilder = projectBuilder.addModule(JavaModuleFixtureBuilder.class); tuneModule(moduleFixtureBuilder, myFixture.getTempDirPath()); diff --git a/plugins/android/testSrc/org/jetbrains/android/dom/AndroidLibraryProjectTest.java b/plugins/android/testSrc/org/jetbrains/android/dom/AndroidLibraryProjectTest.java index 2c6ee20e6da2..50b9e37c84c4 100644 --- a/plugins/android/testSrc/org/jetbrains/android/dom/AndroidLibraryProjectTest.java +++ b/plugins/android/testSrc/org/jetbrains/android/dom/AndroidLibraryProjectTest.java @@ -49,7 +49,7 @@ public class AndroidLibraryProjectTest extends UsefulTestCase { @Override public void setUp() throws Exception { super.setUp(); - final TestFixtureBuilder projectBuilder = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(); + final TestFixtureBuilder projectBuilder = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(getName()); myFixture = JavaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(projectBuilder.getFixture()); myFixture.enableInspections(AndroidDomInspection.class); diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/history/CvsHistoryProvider.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/history/CvsHistoryProvider.java index b3bc6111df5d..9467e665d90b 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/history/CvsHistoryProvider.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/history/CvsHistoryProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -207,8 +207,7 @@ public class CvsHistoryProvider implements VcsHistoryProvider { } private static VcsRevisionNumber getCurrentRevision(FilePath filePath) { - final Entry entryFor = CvsEntriesManager.getInstance().getEntryFor(filePath.getVirtualFileParent(), - filePath.getName()); + final Entry entryFor = CvsEntriesManager.getInstance().getEntryFor(filePath.getVirtualFileParent(), filePath.getName()); if (entryFor == null) { return new CvsRevisionNumber("0"); } @@ -219,13 +218,13 @@ public class CvsHistoryProvider implements VcsHistoryProvider { @Nullable public List createRevisions(final FilePath filePath) { - final ArrayList result = new ArrayList(); final File file = filePath.getIOFile(); final VirtualFile root = CvsVfsUtil.refreshAndFindFileByIoFile(file.getParentFile()); // check if we have a history pane open for a file in a package which has just been deleted if (root == null) return null; final LocalPathIndifferentLogOperation logOperation = new LocalPathIndifferentLogOperation(file); final CvsOperationExecutor executor = new CvsOperationExecutor(myProject); + final ArrayList result = new ArrayList(); executor.performActionSync(new CommandCvsHandler(CvsBundle.message("operation.name.load.file.content"), logOperation), new CvsOperationExecutorCallback() { public void executionFinished(boolean successfully) { @@ -247,6 +246,7 @@ public class CvsHistoryProvider implements VcsHistoryProvider { } } }); + Collections.sort(result, VcsFileRevisionComparator.INSTANCE); return result; } @@ -306,12 +306,19 @@ public class CvsHistoryProvider implements VcsHistoryProvider { } private static List sortRevisions(List revisionsList) { - Collections.sort(revisionsList, new Comparator() { - public int compare(VcsFileRevision rev1, VcsFileRevision rev2) { - return VcsHistoryUtil.compare(rev1, rev2); - } - }); + Collections.sort(revisionsList, VcsFileRevisionComparator.INSTANCE); return revisionsList; } } + + private static class VcsFileRevisionComparator implements Comparator { + + public static final VcsFileRevisionComparator INSTANCE = new VcsFileRevisionComparator(); + + private VcsFileRevisionComparator() {} + + public int compare(VcsFileRevision rev1, VcsFileRevision rev2) { + return VcsHistoryUtil.compare(rev2, rev1); + } + } } diff --git a/plugins/devkit/src/module/PluginModuleType.java b/plugins/devkit/src/module/PluginModuleType.java index 1336a52594c5..59b4f93aad08 100644 --- a/plugins/devkit/src/module/PluginModuleType.java +++ b/plugins/devkit/src/module/PluginModuleType.java @@ -19,6 +19,7 @@ import com.intellij.ide.util.projectWizard.ModuleWizardStep; import com.intellij.ide.util.projectWizard.ProjectWizardStepFactory; import com.intellij.ide.util.projectWizard.WizardContext; import com.intellij.openapi.module.*; +import com.intellij.openapi.project.Project; import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.roots.ModuleRootManager; import com.intellij.openapi.roots.ui.configuration.ModulesProvider; @@ -153,4 +154,15 @@ public class PluginModuleType extends ModuleType { public boolean isValidSdk(final Module module, final Sdk projectSdk) { return JavaModuleType.isValidJavaSdk(module); } + + public static Module[] getAllPluginModules(final Project project) { + List modules = new ArrayList(); + Module[] allModules = ModuleManager.getInstance(project).getModules(); + for (Module module : allModules) { + if (get(module) == getInstance()) { + modules.add(module); + } + } + return modules.toArray(new Module[modules.size()]); + } } \ No newline at end of file diff --git a/plugins/devkit/src/projectRoots/IdeaJdk.java b/plugins/devkit/src/projectRoots/IdeaJdk.java index 07d46ffd7de4..9501558fb101 100644 --- a/plugins/devkit/src/projectRoots/IdeaJdk.java +++ b/plugins/devkit/src/projectRoots/IdeaJdk.java @@ -46,6 +46,7 @@ import java.io.File; import java.io.FileFilter; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; /** @@ -183,17 +184,18 @@ public class IdeaJdk extends SdkType implements JavaSdkType { private static VirtualFile[] getIdeaLibrary(String home) { ArrayList result = new ArrayList(); - appendIdeaLibrary(home + File.separator + LIB_DIR_NAME, null, result); - appendIdeaLibrary(home + File.separator + PLUGINS_DIR + File.separator + JAVAEE_DIR + File.separator + LIB_DIR_NAME, "javaee-impl.jar", - result); - appendIdeaLibrary(home + File.separator + PLUGINS_DIR + File.separator + JSF_DIR + File.separator + LIB_DIR_NAME, "jsf-impl.jar", result); - appendIdeaLibrary(home + File.separator + PLUGINS_DIR + File.separator + PERSISTENCE_SUPPORT + File.separator + LIB_DIR_NAME, "persistence-impl.jar", result); - appendIdeaLibrary(home + File.separator + PLUGINS_DIR + File.separator + DATABASE_DIR + File.separator + LIB_DIR_NAME, "database-impl.jar", result); - appendIdeaLibrary(home + File.separator + PLUGINS_DIR + File.separator + CSS_DIR + File.separator + LIB_DIR_NAME, "css.jar", result); + appendIdeaLibrary(home + File.separator + LIB_DIR_NAME, result, "junit.jar"); + appendIdeaLibrary(home + File.separator + PLUGINS_DIR + File.separator + JAVAEE_DIR + File.separator + LIB_DIR_NAME, result, "javaee-impl.jar"); + appendIdeaLibrary(home + File.separator + PLUGINS_DIR + File.separator + JSF_DIR + File.separator + LIB_DIR_NAME, result, "jsf-impl.jar"); + appendIdeaLibrary(home + File.separator + PLUGINS_DIR + File.separator + PERSISTENCE_SUPPORT + File.separator + LIB_DIR_NAME, result, "persistence-impl.jar"); + appendIdeaLibrary(home + File.separator + PLUGINS_DIR + File.separator + DATABASE_DIR + File.separator + LIB_DIR_NAME, result, "database-impl.jar"); + appendIdeaLibrary(home + File.separator + PLUGINS_DIR + File.separator + CSS_DIR + File.separator + LIB_DIR_NAME, result, "css.jar"); return VfsUtil.toVirtualFileArray(result); } - private static void appendIdeaLibrary(final String path, @Nullable @NonNls final String forbidden, final ArrayList result) { + private static void appendIdeaLibrary(final String path, + final ArrayList result, + @NonNls final String... forbidden) { final JarFileSystem jfs = JarFileSystem.getInstance(); final File lib = new File(path); if (lib.isDirectory()) { @@ -201,7 +203,7 @@ public class IdeaJdk extends SdkType implements JavaSdkType { if (jars != null) { for (File jar : jars) { @NonNls String name = jar.getName(); - if (jar.isFile() && !name.equals(forbidden) && (name.endsWith(".jar") || name.endsWith(".zip"))) { + if (jar.isFile() && Arrays.binarySearch(forbidden, name) < 0 && (name.endsWith(".jar") || name.endsWith(".zip"))) { result.add(jfs.findFileByPath(jar.getPath() + JarFileSystem.JAR_SEPARATOR)); } } diff --git a/plugins/devkit/src/run/PluginConfigurationType.java b/plugins/devkit/src/run/PluginConfigurationType.java index 7d1641fc5614..a40431a6604b 100644 --- a/plugins/devkit/src/run/PluginConfigurationType.java +++ b/plugins/devkit/src/run/PluginConfigurationType.java @@ -26,6 +26,7 @@ import com.intellij.openapi.util.IconLoader; import com.intellij.openapi.util.io.FileUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.devkit.DevKitBundle; +import org.jetbrains.idea.devkit.module.PluginModuleType; import javax.swing.*; import java.io.File; @@ -50,7 +51,7 @@ public class PluginConfigurationType implements ConfigurationType { public RunConfiguration createConfiguration(String name, RunConfiguration template) { final PluginRunConfiguration pluginRunConfiguration = (PluginRunConfiguration)template; if (pluginRunConfiguration.getModule() == null) { - final Module[] modules = pluginRunConfiguration.getModules(); + final Module[] modules = PluginModuleType.getAllPluginModules(pluginRunConfiguration.getProject()); if (modules.length > 0){ pluginRunConfiguration.setModule(modules[0]); } diff --git a/plugins/devkit/src/run/PluginRunConfiguration.java b/plugins/devkit/src/run/PluginRunConfiguration.java index 1a0f22c0bad3..f8fe6a24f2e7 100644 --- a/plugins/devkit/src/run/PluginRunConfiguration.java +++ b/plugins/devkit/src/run/PluginRunConfiguration.java @@ -25,7 +25,6 @@ import com.intellij.execution.runners.ProgramRunner; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; -import com.intellij.openapi.module.ModuleType; import com.intellij.openapi.options.SettingsEditor; import com.intellij.openapi.project.Project; import com.intellij.openapi.projectRoots.JavaSdkType; @@ -39,14 +38,11 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.devkit.DevKitBundle; -import org.jetbrains.idea.devkit.module.PluginModuleType; import org.jetbrains.idea.devkit.projectRoots.IdeaJdk; import org.jetbrains.idea.devkit.projectRoots.Sandbox; import java.io.File; import java.io.IOException; -import java.util.ArrayList; -import java.util.List; public class PluginRunConfiguration extends RunConfigurationBase implements ModuleRunConfiguration { private Module myModule; @@ -246,14 +242,8 @@ public class PluginRunConfiguration extends RunConfigurationBase implements Modu @NotNull public Module[] getModules() { - List modules = new ArrayList(); - Module[] allModules = ModuleManager.getInstance(getProject()).getModules(); - for (Module module : allModules) { - if (ModuleType.get(module) == PluginModuleType.getInstance()) { - modules.add(module); - } - } - return modules.toArray(new Module[modules.size()]); + final Module module = getModule(); + return module != null ? new Module[]{module} : Module.EMPTY_ARRAY; } public void readExternal(Element element) throws InvalidDataException { diff --git a/plugins/devkit/src/run/PluginRunConfigurationEditor.java b/plugins/devkit/src/run/PluginRunConfigurationEditor.java index 6abca2f12397..8b4ae5bdf778 100644 --- a/plugins/devkit/src/run/PluginRunConfigurationEditor.java +++ b/plugins/devkit/src/run/PluginRunConfigurationEditor.java @@ -18,14 +18,13 @@ package org.jetbrains.idea.devkit.run; import com.intellij.execution.ExecutionBundle; import com.intellij.execution.configurations.LogFileOptions; import com.intellij.execution.ui.AlternativeJREPanel; -import com.intellij.ide.ui.ListCellRendererWrapper; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.module.Module; -import com.intellij.openapi.module.ModuleType; import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.options.SettingsEditor; import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.roots.ModuleRootManager; +import com.intellij.openapi.roots.ui.configuration.ModulesCombobox; import com.intellij.openapi.ui.LabeledComponent; import com.intellij.ui.PanelWithAnchor; import com.intellij.ui.RawCommandLineEditor; @@ -35,6 +34,7 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.devkit.DevKitBundle; +import org.jetbrains.idea.devkit.module.PluginModuleType; import org.jetbrains.idea.devkit.projectRoots.IdeaJdk; import org.jetbrains.idea.devkit.projectRoots.Sandbox; @@ -49,9 +49,7 @@ import java.io.IOException; import java.util.ArrayList; public class PluginRunConfigurationEditor extends SettingsEditor implements PanelWithAnchor { - - private DefaultComboBoxModel myModulesModel = new DefaultComboBoxModel(); - private final JComboBox myModules = new JComboBox(myModulesModel); + private final ModulesCombobox myModules = new ModulesCombobox(); private final JBLabel myModuleLabel = new JBLabel(ExecutionBundle.message("application.configuration.use.classpath.and.jdk.of.module.label")); private final LabeledComponent myVMParameters = new LabeledComponent(); private final LabeledComponent myProgramParameters = new LabeledComponent(); @@ -73,9 +71,10 @@ public class PluginRunConfigurationEditor extends SettingsEditor(myModules.getRenderer()) { - @Override - public void customize(JList list, final Module module, int index, boolean selected, boolean hasFocus) { - if (module != null) { - setText(module.getName()); - setIcon(ModuleType.get(module).getNodeIcon(true)); - } - } - }); + myModules.fillModules(myPRC.getProject(), PluginModuleType.getInstance()); JPanel wholePanel = new JPanel(new GridBagLayout()); myVMParameters.setText(DevKitBundle.message("vm.parameters")); myVMParameters.setComponent(new RawCommandLineEditor()); diff --git a/plugins/git4idea/src/git4idea/Notificator.java b/plugins/git4idea/src/git4idea/Notificator.java index c164ac37bfbf..b1b11f4ab7f7 100644 --- a/plugins/git4idea/src/git4idea/Notificator.java +++ b/plugins/git4idea/src/git4idea/Notificator.java @@ -67,7 +67,7 @@ public class Notificator { notify(notificationGroup, title, message, type, null); } - public void notifyError(String title, String message) { + public void notifyError(@NotNull String title, @NotNull String message) { notify(GitVcs.IMPORTANT_ERROR_NOTIFICATION, title, message, NotificationType.ERROR, null); } diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubCreateGistAction.java b/plugins/github/src/org/jetbrains/plugins/github/GithubCreateGistAction.java index 50f1f8b6c625..83412ba7f292 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/GithubCreateGistAction.java +++ b/plugins/github/src/org/jetbrains/plugins/github/GithubCreateGistAction.java @@ -143,7 +143,7 @@ public class GithubCreateGistAction extends DumbAwareAction { response = method.getResponseBodyAsString(); } catch (IOException e1) { - showError(project, "Failed to create gist", null, null, e1); + showError(project, "Failed to create gist", "", null, e1); return; } finally { @@ -155,7 +155,7 @@ public class GithubCreateGistAction extends DumbAwareAction { jsonResponse = new JsonParser().parse(response).getAsJsonObject(); } catch (JsonSyntaxException jse) { - showError(project, "Couldn't parse GitHub response", null, response, jse); + showError(project, "Couldn't parse GitHub response", "", response, jse); return; } @@ -188,7 +188,7 @@ public class GithubCreateGistAction extends DumbAwareAction { } } - private static void showError(@NotNull Project project, @NotNull String title, @Nullable String content, + private static void showError(@NotNull Project project, @NotNull String title, @NotNull String content, @Nullable String details, @Nullable Exception e) { Notificator.getInstance(project).notifyError(title, content); LOG.info("Couldn't parse response as json data: \n" + content + "\n" + details, e); diff --git a/plugins/github/src/org/jetbrains/plugins/github/ui/GitHubSettingsConfigurable.java b/plugins/github/src/org/jetbrains/plugins/github/ui/GitHubSettingsConfigurable.java index b5dfe06f98a9..3ec134a45def 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/ui/GitHubSettingsConfigurable.java +++ b/plugins/github/src/org/jetbrains/plugins/github/ui/GitHubSettingsConfigurable.java @@ -2,8 +2,6 @@ package org.jetbrains.plugins.github.ui; import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.options.SearchableConfigurable; -import com.intellij.openapi.util.Comparing; -import com.intellij.openapi.util.IconLoader; import org.jetbrains.annotations.NotNull; import org.jetbrains.plugins.github.GithubSettings; import org.jetbrains.plugins.github.GithubUtil; @@ -29,38 +27,27 @@ public class GitHubSettingsConfigurable implements SearchableConfigurable { return GithubUtil.GITHUB_ICON; } + @NotNull public String getHelpTopic() { return "settings.github"; } public JComponent createComponent() { if (mySettingsPane == null) { - mySettingsPane = new GithubSettingsPanel(); + mySettingsPane = new GithubSettingsPanel(mySettings); } reset(); return mySettingsPane.getPanel(); } public boolean isModified() { - return mySettingsPane != null && (!Comparing.equal(mySettings.getLogin(), mySettingsPane.getLogin()) || - !Comparing.strEqual(mySettings.getPassword(), mySettingsPane.getPassword()) || - !Comparing.equal(mySettings.getHost(), mySettingsPane.getHost())); + return false; } public void apply() throws ConfigurationException { - if (mySettingsPane != null) { - mySettings.setLogin(mySettingsPane.getLogin()); - mySettings.setPassword(mySettingsPane.getPassword()); - mySettings.setHost(mySettingsPane.getHost()); - } } public void reset() { - if (mySettingsPane != null) { - mySettingsPane.setLogin(mySettings.getLogin()); - mySettingsPane.setPassword(mySettings.getPassword()); - mySettingsPane.setHost(mySettings.getHost()); - } } public void disposeUIResources() { diff --git a/plugins/github/src/org/jetbrains/plugins/github/ui/GithubSettingsPanel.form b/plugins/github/src/org/jetbrains/plugins/github/ui/GithubSettingsPanel.form index f828dabfa194..043dc84c7ab0 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/ui/GithubSettingsPanel.form +++ b/plugins/github/src/org/jetbrains/plugins/github/ui/GithubSettingsPanel.form @@ -1,6 +1,6 @@
- + @@ -8,36 +8,9 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -45,55 +18,25 @@ + - - - - - - - - - - - - - - - - - - - - - + - + - + - - - - - - - - - - - diff --git a/plugins/github/src/org/jetbrains/plugins/github/ui/GithubSettingsPanel.java b/plugins/github/src/org/jetbrains/plugins/github/ui/GithubSettingsPanel.java index 29e352692067..267941384273 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/ui/GithubSettingsPanel.java +++ b/plugins/github/src/org/jetbrains/plugins/github/ui/GithubSettingsPanel.java @@ -16,11 +16,11 @@ package org.jetbrains.plugins.github.ui; import com.intellij.ide.BrowserUtil; +import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.ui.Messages; -import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.HyperlinkAdapter; -import org.jetbrains.plugins.github.GithubUtil; +import org.jetbrains.plugins.github.GithubSettings; import javax.swing.*; import javax.swing.event.HyperlinkEvent; @@ -33,14 +33,11 @@ import java.awt.event.ActionListener; * @date 10/20/10 */ public class GithubSettingsPanel { - private JTextField myLoginTextField; - private JPasswordField myPasswordField; private JTextPane mySignupTextField; private JPanel myPane; private JButton myTestButton; - private JTextField myHostTextField; - public GithubSettingsPanel() { + public GithubSettingsPanel(final GithubSettings settings) { mySignupTextField.addHyperlinkListener(new HyperlinkAdapter() { @Override protected void hyperlinkActivated(final HyperlinkEvent e) { @@ -54,10 +51,12 @@ public class GithubSettingsPanel { myTestButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - if (GithubUtil.checkCredentials(ProjectManager.getInstance().getDefaultProject(), getHost(), getLogin(), getPassword())){ - Messages.showInfoMessage("Connection successful", "Success"); - } else { - Messages.showErrorDialog("Cannot login to the " + getHost() + " using given credentials", "Failure"); + Project project = ProjectManager.getInstance().getDefaultProject(); + final GithubLoginDialog dialog = new GithubLoginDialog(project); + dialog.show(); + if (dialog.isOK()){ + // the dialog won't let close after pressing OK if the connection is not successful + Messages.showInfoMessage(myPane, "Connection successful", "Success"); } } }); @@ -67,29 +66,5 @@ public class GithubSettingsPanel { return myPane; } - public void setLogin(final String login) { - myLoginTextField.setText(login); - } - - public void setPassword(final String password) { - // Show password as blank if password is empty - myPasswordField.setText(StringUtil.isEmpty(password) ? null : password); - } - - public String getLogin() { - return myLoginTextField.getText().trim(); - } - - public String getPassword() { - return String.valueOf(myPasswordField.getPassword()); - } - - public void setHost(final String host) { - myHostTextField.setText(host); - } - - public String getHost() { - return myHostTextField.getText().trim(); - } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/SuppressForMemberFix.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/SuppressForMemberFix.java index c327b42e1131..f23d90d93da8 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/SuppressForMemberFix.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/SuppressForMemberFix.java @@ -94,7 +94,7 @@ public class SuppressForMemberFix extends SuppressIntentionAction { return container != null && context != null && context.getManager().isInProject(context); } - public void invoke(final Project project, final Editor editor, final PsiElement element) throws IncorrectOperationException { + public void invoke(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) throws IncorrectOperationException { GrDocCommentOwner container = getContainer(element); assert container != null; if (!CodeInsightUtilBase.preparePsiElementForWrite(container)) return; diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/noReturnMethod/MissingReturnInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/noReturnMethod/MissingReturnInspection.java index f2e268a51217..bf16de6542e3 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/noReturnMethod/MissingReturnInspection.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/noReturnMethod/MissingReturnInspection.java @@ -18,9 +18,7 @@ package org.jetbrains.plugins.groovy.codeInspection.noReturnMethod; import com.intellij.codeInspection.ProblemsHolder; import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.TextRange; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiElementVisitor; -import com.intellij.psi.PsiType; +import com.intellij.psi.*; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -65,14 +63,33 @@ public class MissingReturnInspection extends GroovySuppressableInspectionTool { return GroovyInspectionBundle.message("no.return.display.name"); } + public enum ReturnStatus { + mustReturnValue, shouldReturnValue, shouldNotReturnValue; + + public static ReturnStatus getReturnStatus(PsiElement subject) { + if (subject instanceof GrClosableBlock) { + final PsiType inferredReturnType = GroovyExpectedTypesProvider.getExpectedClosureReturnType((GrClosableBlock)subject); + if (inferredReturnType instanceof PsiClassType) { + PsiClass resolved = ((PsiClassType)inferredReturnType).resolve(); + if (resolved != null && !(resolved instanceof PsiTypeParameter)) return mustReturnValue; + } + return inferredReturnType != null && inferredReturnType != PsiType.VOID ? shouldReturnValue : shouldNotReturnValue; + } + else if (subject instanceof GrMethod) { + return ((GrMethod)subject).getReturnTypeElementGroovy() != null && ((GrMethod)subject).getReturnType() != PsiType.VOID + ? mustReturnValue + : shouldNotReturnValue; + } + return shouldNotReturnValue; + } + } + @NotNull public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder problemsHolder, boolean onTheFly) { return new GroovyPsiElementVisitor(new GroovyElementVisitor() { public void visitClosure(GrClosableBlock closure) { super.visitClosure(closure); - - final PsiType expectedClosureType = GroovyExpectedTypesProvider.getExpectedClosureReturnType(closure); - check(closure, problemsHolder, expectedClosureType != null && expectedClosureType != PsiType.VOID); + check(closure, problemsHolder, ReturnStatus.getReturnStatus(closure)); } public void visitMethod(GrMethod method) { @@ -80,72 +97,70 @@ public class MissingReturnInspection extends GroovySuppressableInspectionTool { final GrOpenBlock block = method.getBlock(); if (block != null) { - final boolean mustReturnValue = method.getReturnTypeElementGroovy() != null && method.getReturnType() != PsiType.VOID; - check(block, problemsHolder, mustReturnValue); + check(block, problemsHolder, ReturnStatus.getReturnStatus(method)); } } }); - } - private static void check(GrCodeBlock block, ProblemsHolder holder, boolean mustReturnValue) { - if (methodMissesSomeReturns(block, mustReturnValue)) { + private static void check(GrCodeBlock block, ProblemsHolder holder, ReturnStatus returnStatus) { + if (methodMissesSomeReturns(block, returnStatus)) { addNoReturnMessage(block, holder); } } - public static boolean methodMissesSomeReturns(GrControlFlowOwner block, boolean mustReturnValue) { - if (!mustReturnValue) { + public static boolean methodMissesSomeReturns(GrControlFlowOwner block, ReturnStatus returnStatus) { + if (returnStatus == ReturnStatus.shouldNotReturnValue) { return false; } - final Ref always = new Ref(true); + final Ref alwaysHaveReturn = new Ref(true); + final Ref sometimesHaveReturn = new Ref(false); final Ref hasExplicitReturn = new Ref(false); - final Ref sometimes = new Ref(false); ControlFlowUtils.visitAllExitPoints(block, new ControlFlowUtils.ExitPointVisitor() { @Override public boolean visitExitPoint(Instruction instruction, @Nullable GrExpression returnValue) { if (instruction instanceof MaybeReturnInstruction) { if (((MaybeReturnInstruction)instruction).mayReturnValue()) { - sometimes.set(true); + sometimesHaveReturn.set(true); } else { - always.set(false); + alwaysHaveReturn.set(false); } return true; } final PsiElement element = instruction.getElement(); if (element instanceof GrReturnStatement) { - sometimes.set(true); + sometimesHaveReturn.set(true); if (returnValue != null) { hasExplicitReturn.set(true); } } else if (instruction instanceof ThrowingInstruction) { - sometimes.set(true); + sometimesHaveReturn.set(true); } else if (element instanceof GrAssertStatement) { - sometimes.set(true); + sometimesHaveReturn.set(true); int count = 0; for (Instruction _i : instruction.allSuccessors()) { count++; } if (count <= 1) { - always.set(false); + alwaysHaveReturn.set(false); } } else { - always.set(false); + alwaysHaveReturn.set(false); } return true; } }); - if (!sometimes.get()) { + if (returnStatus == ReturnStatus.mustReturnValue && !sometimesHaveReturn.get()) { return true; } - return sometimes.get() && !always.get(); + return sometimesHaveReturn.get() && !alwaysHaveReturn.get(); } private static void addNoReturnMessage(GrCodeBlock block, ProblemsHolder holder) { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyCodeStyleSettings.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyCodeStyleSettings.java index 895f178c762a..2869eb12bcf2 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyCodeStyleSettings.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyCodeStyleSettings.java @@ -43,6 +43,7 @@ public class GroovyCodeStyleSettings extends CustomCodeStyleSettings { public boolean SPACE_IN_NAMED_ARGUMENT = true; public boolean ALIGN_MULTILINE_LIST_OR_MAP = false; + public boolean SPACE_WITHIN_LIST_OR_MAP = false; public GroovyCodeStyleSettings(CodeStyleSettings container) { super("GroovyCodeStyleSettings", container); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyLanguageCodeStyleSettingsProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyLanguageCodeStyleSettingsProvider.java index 6cd8df934c1a..a93b3cf1549b 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyLanguageCodeStyleSettingsProvider.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyLanguageCodeStyleSettingsProvider.java @@ -115,6 +115,7 @@ public class GroovyLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSe "SPACE_WITHIN_ANNOTATION_PARENTHESES" ); consumer.showCustomOption(GroovyCodeStyleSettings.class, "SPACE_IN_NAMED_ARGUMENT", "In named argument after ':'", CodeStyleSettingsCustomizable.SPACES_OTHER); + consumer.showCustomOption(GroovyCodeStyleSettings.class, "SPACE_WITHIN_LIST_OR_MAP", "List and maps literals", CodeStyleSettingsCustomizable.SPACES_WITHIN); return; } consumer.showAllStandardOptions(); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovySpacingProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovySpacingProcessor.java index 970d869780a1..46805d001b79 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovySpacingProcessor.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovySpacingProcessor.java @@ -546,7 +546,7 @@ public class GroovySpacingProcessor extends GroovyElementVisitor { @Override public void visitListOrMap(GrListOrMap listOrMap) { if (myType1 == mLBRACK || myType2 == mRBRACK) { - createSpaceInCode(mySettings.SPACE_WITHIN_BRACKETS); + createSpaceInCode(myGroovySettings.SPACE_WITHIN_LIST_OR_MAP); } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/folding/GroovyFoldingBuilder.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/folding/GroovyFoldingBuilder.java index 574c5c9d4e1b..f695d0ebe0d8 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/folding/GroovyFoldingBuilder.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/folding/GroovyFoldingBuilder.java @@ -24,10 +24,7 @@ import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.FoldingGroup; import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.util.TextRange; -import com.intellij.psi.PsiAnonymousClass; -import com.intellij.psi.PsiClass; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiFile; +import com.intellij.psi.*; import com.intellij.psi.impl.source.tree.LeafPsiElement; import com.intellij.psi.tree.IElementType; import com.intellij.util.containers.hash.HashSet; @@ -215,6 +212,7 @@ public class GroovyFoldingBuilder extends CustomFoldingBuilder implements Groovy return text.contains("\n") || text.contains("\r") || text.contains("\r\n"); } + @Nullable @Override protected String getLanguagePlaceholderText(@NotNull ASTNode node, @NotNull TextRange range) { final IElementType elemType = node.getElementType(); @@ -245,8 +243,21 @@ public class GroovyFoldingBuilder extends CustomFoldingBuilder implements Groovy return settings.isCollapseImports(); } - if (node.getElementType() == GROOVY_DOC_COMMENT) { - return settings.isCollapseJavadocs(); + if (node.getElementType() == GROOVY_DOC_COMMENT || node.getElementType() == mML_COMMENT) { + PsiElement element = node.getPsi(); + PsiElement parent = element.getParent(); + if (parent instanceof GroovyFile) { + PsiElement firstChild = parent.getFirstChild(); + if (firstChild instanceof PsiWhiteSpace) { + firstChild = firstChild.getNextSibling(); + } + if (element.equals(firstChild)) { + return settings.isCollapseFileHeader(); + } + } + if (node.getElementType() == GROOVY_DOC_COMMENT) { + return settings.isCollapseJavadocs(); + } } if ((node.getElementType() == OPEN_BLOCK || node.getElementType() == CONSTRUCTOR_BODY) && node.getTreeParent().getElementType() == METHOD_DEFINITION) { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ClassItemGeneratorImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ClassItemGeneratorImpl.java index 32355663ea49..f47fbf22631a 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ClassItemGeneratorImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ClassItemGeneratorImpl.java @@ -247,7 +247,7 @@ public class ClassItemGeneratorImpl implements ClassItemGenerator { ExpressionContext extended = context.extend(); extended.searchForLocalVarsToWrap((GroovyPsiElement)scriptFile); new CodeBlockGenerator(builder, extended, exitPoints) - .visitStatementOwner((GroovyFile)scriptFile, MissingReturnInspection.methodMissesSomeReturns((GroovyFile)scriptFile, true)); + .visitStatementOwner((GroovyFile)scriptFile, MissingReturnInspection.methodMissesSomeReturns((GroovyFile)scriptFile, MissingReturnInspection.ReturnStatus.mustReturnValue)); builder.append("\n}\n"); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ClosureGenerator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ClosureGenerator.java index b526545ce770..ff4ac8cd4acc 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ClosureGenerator.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ClosureGenerator.java @@ -87,7 +87,7 @@ public class ClosureGenerator { Collection myExitPoints = ControlFlowUtils.collectReturns(block); boolean shouldInsertReturnNull = - !(returnType instanceof PsiPrimitiveType) && MissingReturnInspection.methodMissesSomeReturns(block, false); + !(returnType instanceof PsiPrimitiveType) && MissingReturnInspection.methodMissesSomeReturns(block, MissingReturnInspection.ReturnStatus.shouldNotReturnValue); new CodeBlockGenerator(builder, context.extend(), myExitPoints).generateCodeBlock(block, shouldInsertReturnNull); builder.append('\n'); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/CodeBlockGenerator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/CodeBlockGenerator.java index f42e83d4de65..f921633f3d27 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/CodeBlockGenerator.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/CodeBlockGenerator.java @@ -101,7 +101,8 @@ public class CodeBlockGenerator extends Generator { if (!method.isConstructor() && returnType != PsiType.VOID) { myExitPoints.addAll(ControlFlowUtils.collectReturns(block)); shouldInsertReturnNull = !(returnType instanceof PsiPrimitiveType) && - MissingReturnInspection.methodMissesSomeReturns(block, method.getReturnTypeElementGroovy() != null); + MissingReturnInspection.methodMissesSomeReturns(block, + MissingReturnInspection.ReturnStatus.getReturnStatus(method)); } if (block != null) { diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/MissingReturnTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/MissingReturnTest.groovy index e85cc9cd0a44..538fac39a666 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/MissingReturnTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/MissingReturnTest.groovy @@ -41,6 +41,7 @@ public class MissingReturnTest extends LightCodeInsightFixtureTestCase { public void testImplicitReturnNull() throws Throwable {doTest();} public void testMissingReturnInClosure() {doTest();} public void testFinally() {doTest();} + public void testClosureWithExplicitExpectedType() {doTest()} private void doTest() { myFixture.enableInspections(new MissingReturnInspection()); diff --git a/plugins/groovy/testdata/highlighting/missingReturn/ClosureWithExplicitExpectedType.groovy b/plugins/groovy/testdata/highlighting/missingReturn/ClosureWithExplicitExpectedType.groovy new file mode 100644 index 000000000000..d8a58ad50356 --- /dev/null +++ b/plugins/groovy/testdata/highlighting/missingReturn/ClosureWithExplicitExpectedType.groovy @@ -0,0 +1,19 @@ +def foo(Closure c) { + return c().substring(1) +} + +foo { + print 2 +} + +foo { + 's' +} + +foo { + if (a) 's' +} + +foo { + if (a) 'a' else 'b' +} diff --git a/plugins/groovy/testdata/highlighting/missingReturn/MissingReturnInClosure.groovy b/plugins/groovy/testdata/highlighting/missingReturn/MissingReturnInClosure.groovy index dd8a60c60789..4fc8273eeaee 100644 --- a/plugins/groovy/testdata/highlighting/missingReturn/MissingReturnInClosure.groovy +++ b/plugins/groovy/testdata/highlighting/missingReturn/MissingReturnInClosure.groovy @@ -2,7 +2,7 @@ def mkString(def i) {} print([1, 2, 3].collect { mkString(it) -}) +}) print([1, 2, 3].collect { @@ -10,5 +10,5 @@ print([1, 2, 3].collect { }) Closure c1 = { mkString(it)} -Closure c2 = {mkString(it)} +Closure c2 = {mkString(it); if (a) return 2} def c3 = {mkString(it)} \ No newline at end of file diff --git a/plugins/java-i18n/src/com/intellij/codeInspection/i18n/SuppressByCommentOutAction.java b/plugins/java-i18n/src/com/intellij/codeInspection/i18n/SuppressByCommentOutAction.java index 0c9ecaa47ce9..f674084163a0 100644 --- a/plugins/java-i18n/src/com/intellij/codeInspection/i18n/SuppressByCommentOutAction.java +++ b/plugins/java-i18n/src/com/intellij/codeInspection/i18n/SuppressByCommentOutAction.java @@ -41,7 +41,7 @@ class SuppressByCommentOutAction extends SuppressIntentionAction { } @Override - public void invoke(Project project, Editor editor, PsiElement element) throws IncorrectOperationException { + public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException { if (!CodeInsightUtilBase.preparePsiElementForWrite(element)) return; element = findJavaCodeUpThere(element); PsiFile file = element.getContainingFile(); diff --git a/plugins/junit_rt/src/com/intellij/junit4/JUnit4TestResultsSender.java b/plugins/junit_rt/src/com/intellij/junit4/JUnit4TestResultsSender.java index bfb590a18a02..9a2b844f55e4 100644 --- a/plugins/junit_rt/src/com/intellij/junit4/JUnit4TestResultsSender.java +++ b/plugins/junit_rt/src/com/intellij/junit4/JUnit4TestResultsSender.java @@ -34,6 +34,11 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; public class JUnit4TestResultsSender extends RunListener { + private static final String JUNIT_FRAMEWORK_COMPARISON_NAME = ComparisonFailure.class.getName(); + private static final String ORG_JUNIT_COMPARISON_NAME = "org.junit.ComparisonFailure"; + private static final String ASSERTION_CLASS_NAME = AssertionError.class.getName(); + private static final String ASSERTION_FAILED_CLASS_NAME = "junit.framework.AssertionFailedError"; + private final OutputObjectRegistry myRegistry; private Map myCurrentTestMeters = new HashMap(); private Set myCurrentTests = new HashSet(); @@ -46,7 +51,8 @@ public class JUnit4TestResultsSender extends RunListener { final Description description = failure.getDescription(); final Throwable throwable = failure.getException(); - if (throwable instanceof AssertionError || throwable.getCause() instanceof AssertionError) { + final Throwable cause = throwable.getCause(); + if (isAssertionError(throwable.getClass()) || isAssertionError(cause != null ? cause.getClass() : null)) { // junit4 makes no distinction between errors and failures doAddFailure(description, throwable); } @@ -81,13 +87,25 @@ public class JUnit4TestResultsSender extends RunListener { createExceptionNotification(assertion).createPacket(myRegistry, test).send(); } + private static boolean isComparisonFailure(Throwable throwable) { + final String throwableClassName = throwable.getClass().getName(); + return throwableClassName.equals(JUNIT_FRAMEWORK_COMPARISON_NAME) || throwableClassName.equals(ORG_JUNIT_COMPARISON_NAME); + } + + private static boolean isAssertionError(Class throwableClass) { + if (throwableClass == null) return false; + final String throwableClassName = throwableClass.getName(); + if (throwableClassName.equals(ASSERTION_CLASS_NAME) || throwableClassName.equals(ASSERTION_FAILED_CLASS_NAME)) return true; + return isAssertionError(throwableClass.getSuperclass()); + } + private static PacketFactory createExceptionNotification(Throwable assertion) { if (assertion instanceof KnownException) return ((KnownException)assertion).getPacketFactory(); - if (assertion instanceof ComparisonFailure || assertion instanceof org.junit.ComparisonFailure) { + if (isComparisonFailure(assertion)) { return ComparisonDetailsExtractor.create(assertion); } final Throwable cause = assertion.getCause(); - if (cause instanceof ComparisonFailure || cause instanceof org.junit.ComparisonFailure) { + if (isComparisonFailure(cause)) { try { return ComparisonDetailsExtractor.create(assertion, ComparisonDetailsExtractor.getExpected(cause), ComparisonDetailsExtractor.getActual(cause)); } diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDomTestCase.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDomTestCase.java index 97af461e12a6..3dcbe20edc8f 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDomTestCase.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDomTestCase.java @@ -73,7 +73,7 @@ public abstract class MavenDomTestCase extends MavenImportingTestCase { @Override protected void setUpFixtures() throws Exception { - myTestFixture = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder().getFixture(); + myTestFixture = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(getName()).getFixture(); myFixture = IdeaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(myTestFixture); myFixture.setUp(); diff --git a/plugins/properties/src/com/intellij/lang/properties/PropertySuppressableInspectionBase.java b/plugins/properties/src/com/intellij/lang/properties/PropertySuppressableInspectionBase.java index 6bbdcace6701..499e1fc8a78f 100644 --- a/plugins/properties/src/com/intellij/lang/properties/PropertySuppressableInspectionBase.java +++ b/plugins/properties/src/com/intellij/lang/properties/PropertySuppressableInspectionBase.java @@ -110,7 +110,7 @@ public abstract class PropertySuppressableInspectionBase extends LocalInspection return property != null && property.isValid(); } - public void invoke(final Project project, final Editor editor, final PsiElement element) throws IncorrectOperationException { + public void invoke(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) throws IncorrectOperationException { final PsiFile file = element.getContainingFile(); if (!CodeInsightUtilBase.prepareFileForWrite(file)) return; @@ -149,7 +149,7 @@ public abstract class PropertySuppressableInspectionBase extends LocalInspection return element.isValid() && element.getContainingFile() instanceof PropertiesFile; } - public void invoke(final Project project, final Editor editor, final PsiElement element) throws IncorrectOperationException { + public void invoke(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) throws IncorrectOperationException { final PsiFile file = element.getContainingFile(); if (!CodeInsightUtilBase.prepareFileForWrite(file)) return; diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn16/SvnCommittedViewTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn16/SvnCommittedViewTest.java index 9d214220cfae..f6fb8dbd5458 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn16/SvnCommittedViewTest.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn16/SvnCommittedViewTest.java @@ -10,10 +10,12 @@ import com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettings; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.SvnConfiguration; import org.jetbrains.idea.svn.SvnVcs; import org.jetbrains.idea.svn.history.SvnChangeList; import org.jetbrains.idea.svn.history.SvnRepositoryLocation; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; import java.io.File; @@ -23,6 +25,13 @@ import java.util.List; public class SvnCommittedViewTest extends SvnTestCase { + @Override + @Before + public void setUp() throws Exception { + super.setUp(); + SvnConfiguration.getInstance(myProject).DETECT_NESTED_COPIES = false; + } + @Test public void testAdd() throws Exception { enableSilentOperation(VcsConfiguration.StandardConfirmation.ADD); @@ -37,6 +46,7 @@ public class SvnCommittedViewTest extends SvnTestCase { checkin(); final SvnVcs vcs = SvnVcs.getInstance(myProject); + vcs.invokeRefreshSvnRoots(false); final CommittedChangesProvider committedChangesProvider = vcs.getCommittedChangesProvider(); final List changeListList = committedChangesProvider.getCommittedChanges(committedChangesProvider.createDefaultSettings(), @@ -68,6 +78,7 @@ public class SvnCommittedViewTest extends SvnTestCase { checkin(); final SvnVcs vcs = SvnVcs.getInstance(myProject); + vcs.invokeRefreshSvnRoots(false); final CommittedChangesProvider committedChangesProvider = vcs.getCommittedChangesProvider(); final List changeListList = committedChangesProvider.getCommittedChanges(committedChangesProvider.createDefaultSettings(), @@ -96,6 +107,7 @@ public class SvnCommittedViewTest extends SvnTestCase { checkin(); final SvnVcs vcs = SvnVcs.getInstance(myProject); + vcs.invokeRefreshSvnRoots(false); final CommittedChangesProvider committedChangesProvider = vcs.getCommittedChangesProvider(); final List changeListList = committedChangesProvider.getCommittedChanges(committedChangesProvider.createDefaultSettings(), @@ -124,6 +136,7 @@ public class SvnCommittedViewTest extends SvnTestCase { checkin(); final SvnVcs vcs = SvnVcs.getInstance(myProject); + vcs.invokeRefreshSvnRoots(false); final CommittedChangesProvider committedChangesProvider = vcs.getCommittedChangesProvider(); final List changeListList = committedChangesProvider.getCommittedChanges(committedChangesProvider.createDefaultSettings(), @@ -156,6 +169,7 @@ public class SvnCommittedViewTest extends SvnTestCase { checkin(); final SvnVcs vcs = SvnVcs.getInstance(myProject); + vcs.invokeRefreshSvnRoots(false); final CommittedChangesProvider committedChangesProvider = vcs.getCommittedChangesProvider(); final List changeListList = committedChangesProvider.getCommittedChanges(committedChangesProvider.createDefaultSettings(), @@ -181,6 +195,7 @@ public class SvnCommittedViewTest extends SvnTestCase { verify(runSvn("copy", "-m", "test", myRepoUrl + "/trunk", myRepoUrl + "/branch")); final SvnVcs vcs = SvnVcs.getInstance(myProject); + vcs.invokeRefreshSvnRoots(false); final CommittedChangesProvider committedChangesProvider = vcs.getCommittedChangesProvider(); final List changeListList = committedChangesProvider.getCommittedChanges(committedChangesProvider.createDefaultSettings(), @@ -210,6 +225,7 @@ public class SvnCommittedViewTest extends SvnTestCase { checkin(); final SvnVcs vcs = SvnVcs.getInstance(myProject); + vcs.invokeRefreshSvnRoots(false); final CommittedChangesProvider committedChangesProvider = vcs.getCommittedChangesProvider(); final List changeListList = committedChangesProvider.getCommittedChanges(committedChangesProvider.createDefaultSettings(), diff --git a/xml/dom-openapi/src/com/intellij/util/xml/tree/BaseDomElementNode.java b/xml/dom-openapi/src/com/intellij/util/xml/tree/BaseDomElementNode.java index b24e352313a1..92aaedede5a5 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/tree/BaseDomElementNode.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/tree/BaseDomElementNode.java @@ -178,6 +178,7 @@ public class BaseDomElementNode extends AbstractDomElementNode { return consolidated; } + @NotNull public Object[] getEqualityObjects() { return new Object[]{myDomElement}; } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/tree/DomElementsGroupNode.java b/xml/dom-openapi/src/com/intellij/util/xml/tree/DomElementsGroupNode.java index 83fba1184617..ea8ca192df60 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/tree/DomElementsGroupNode.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/tree/DomElementsGroupNode.java @@ -28,6 +28,7 @@ import com.intellij.util.xml.highlighting.DomElementAnnotationsManager; import com.intellij.util.xml.highlighting.DomElementProblemDescriptor; import com.intellij.util.xml.highlighting.DomElementsProblemsHolder; import com.intellij.util.xml.reflect.DomCollectionChildDescription; +import org.jetbrains.annotations.NotNull; import javax.swing.*; import java.util.ArrayList; @@ -60,6 +61,7 @@ public class DomElementsGroupNode extends AbstractDomElementNode { return simpleNodes.toArray(new SimpleNode[simpleNodes.size()]); } + @NotNull public Object[] getEqualityObjects() { return new Object[]{myParentElement, myChildrenTagName}; } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/tree/GenericValueNode.java b/xml/dom-openapi/src/com/intellij/util/xml/tree/GenericValueNode.java index 77b161179468..d71a64c4692d 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/tree/GenericValueNode.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/tree/GenericValueNode.java @@ -20,6 +20,7 @@ import com.intellij.ui.treeStructure.SimpleNode; import com.intellij.util.xml.GenericDomValue; import com.intellij.util.xml.DomElement; import com.intellij.ui.SimpleTextAttributes; +import org.jetbrains.annotations.NotNull; public class GenericValueNode extends AbstractDomElementNode { protected GenericDomValue myModelElement; @@ -66,6 +67,7 @@ public class GenericValueNode extends AbstractDomElementNode { return NO_CHILDREN; } + @NotNull public Object[] getEqualityObjects() { return new Object[]{myModelElement}; } diff --git a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/AddSchemaPrefixIntention.java b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/AddSchemaPrefixIntention.java index 21c95935dd7a..e7d65657d0b4 100644 --- a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/AddSchemaPrefixIntention.java +++ b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/AddSchemaPrefixIntention.java @@ -57,7 +57,7 @@ public class AddSchemaPrefixIntention extends PsiElementBaseIntentionAction { } @Override - public void invoke(Project project, Editor editor, PsiElement element) throws IncorrectOperationException { + public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException { final XmlAttribute xmlns = getXmlnsDeclaration(element); if (xmlns == null) return; final String namespace = xmlns.getValue(); diff --git a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/ConvertSchemaPrefixToDefaultIntention.java b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/ConvertSchemaPrefixToDefaultIntention.java index d524eb2c95bd..34c4809aa811 100644 --- a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/ConvertSchemaPrefixToDefaultIntention.java +++ b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/ConvertSchemaPrefixToDefaultIntention.java @@ -45,7 +45,7 @@ public class ConvertSchemaPrefixToDefaultIntention extends PsiElementBaseIntenti } @Override - public void invoke(Project project, Editor editor, PsiElement element) throws IncorrectOperationException { + public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException { final XmlAttribute xmlns = getXmlnsDeclaration(element); if (xmlns == null) return; SchemaPrefixReference prefixRef = null; diff --git a/xml/openapi/src/com/intellij/codeInspection/XmlSuppressableInspectionTool.java b/xml/openapi/src/com/intellij/codeInspection/XmlSuppressableInspectionTool.java index 84623dd6d72d..26191bac3220 100644 --- a/xml/openapi/src/com/intellij/codeInspection/XmlSuppressableInspectionTool.java +++ b/xml/openapi/src/com/intellij/codeInspection/XmlSuppressableInspectionTool.java @@ -66,7 +66,7 @@ public abstract class XmlSuppressableInspectionTool extends LocalInspectionTool return PsiTreeUtil.getParentOfType(element, XmlTag.class) != null; } - public void invoke(final Project project, final Editor editor, final PsiElement element) throws IncorrectOperationException { + public void invoke(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) throws IncorrectOperationException { XmlSuppressionProvider.getProvider(element.getContainingFile()).suppressForTag(element, id); } } @@ -88,7 +88,7 @@ public abstract class XmlSuppressableInspectionTool extends LocalInspectionTool return getText(); } - public void invoke(final Project project, final Editor editor, final PsiElement element) throws IncorrectOperationException { + public void invoke(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) throws IncorrectOperationException { XmlSuppressionProvider.getProvider(element.getContainingFile()).suppressForFile(element, myInspectionId); } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/inspections/BaseInspection.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/inspections/BaseInspection.java index e01543514e80..0f8288f379aa 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/inspections/BaseInspection.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/inspections/BaseInspection.java @@ -205,7 +205,7 @@ public abstract class BaseInspection extends XmlSuppressableInspectionTool { return getDisplayName(); } - public void invoke(Project project, Editor editor, PsiElement element) throws IncorrectOperationException { + public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException { suppress(element.getContainingFile(), getTarget(element)); } diff --git a/xml/relaxng/test/org/intellij/plugins/relaxNG/HighlightingTestBase.java b/xml/relaxng/test/org/intellij/plugins/relaxNG/HighlightingTestBase.java index b8631e8083d7..130ea0ef209a 100644 --- a/xml/relaxng/test/org/intellij/plugins/relaxNG/HighlightingTestBase.java +++ b/xml/relaxng/test/org/intellij/plugins/relaxNG/HighlightingTestBase.java @@ -24,12 +24,14 @@ import com.intellij.codeInspection.InspectionToolProvider; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.htmlInspections.RequiredAttributesInspection; import com.intellij.javaee.ExternalResourceManagerEx; -import com.intellij.mock.MockProgressIndicator; -import com.intellij.openapi.application.*; +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.Result; +import com.intellij.openapi.application.WriteAction; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.*; +import com.intellij.openapi.util.Pair; +import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.io.FileUtil; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiFile; @@ -48,7 +50,6 @@ import org.intellij.plugins.relaxNG.inspections.RngDomInspection; import org.intellij.plugins.testUtil.IdeaCodeInsightTestCase; import org.intellij.plugins.testUtil.ResourceUtil; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import java.io.File; import java.io.IOException; @@ -130,7 +131,7 @@ public abstract class HighlightingTestBase extends UsefulTestCase implements Ide } protected CodeInsightTestFixture createContentFixture(IdeaTestFixtureFactory factory) { - final TestFixtureBuilder builder = factory.createFixtureBuilder(); + final TestFixtureBuilder builder = factory.createFixtureBuilder(getName()); final EmptyModuleFixtureBuilder moduleBuilder = builder.addModule(EmptyModuleFixtureBuilder.class); final IdeaProjectTestFixture fixture = builder.getFixture();