> inn3 = Main.Inner[]::new;
+ }
+
+ class Inner {}
+
+ interface I {
+ K[] v(int i);
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/MethodReferenceTypeArgumentsApplicability.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/MethodReferenceTypeArgumentsApplicability.java
new file mode 100644
index 000000000000..4d2d0b1ef6a7
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/MethodReferenceTypeArgumentsApplicability.java
@@ -0,0 +1,24 @@
+import java.util.Collection;
+import java.util.List;
+import java.util.stream.Stream;
+
+abstract class Test {
+ void p(final Stream> stream){
+ stream.flatMap(Collection::stream);
+ stream.flatMap(Collection::<? extends String>stream);
+ stream.flatMap(Collection::<?>stream);
+ stream.flatMap(Collection::<? super String>stream);
+ }
+
+ static void foo(T t) {}
+ interface I {
+ void m(String s);
+ }
+
+ {
+ I i = Test::foo;
+ I i1 = Test::foo;
+ I i2 = Test::foo;
+
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/NewParameterizedReferenceOnRawType.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/NewParameterizedReferenceOnRawType.java
new file mode 100644
index 000000000000..f0d4fcbc7179
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/NewParameterizedReferenceOnRawType.java
@@ -0,0 +1,11 @@
+import java.util.concurrent.Callable;
+class Test {
+
+ public Test() {
+ }
+
+ {
+ Callable> c = Test::new;
+ Callable> c1 = Test::new;
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/RawReferenceTypeWithReceiver.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/RawReferenceTypeWithReceiver.java
new file mode 100644
index 000000000000..f9fdc86e67cb
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/RawReferenceTypeWithReceiver.java
@@ -0,0 +1,12 @@
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.stream.Stream;
+
+class Main {
+ public static void main(String[] args) {
+ Stream> listStream = new ArrayList>().stream();
+ Stream extends Main> l1 = listStream.flatMap(Collection::stream);
+ Stream extends Main> l2 = listStream.flatMap(List::stream);
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/TypeNameInterfaceSuperMethodReferenceApplicability.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/TypeNameInterfaceSuperMethodReferenceApplicability.java
new file mode 100644
index 000000000000..28f175aae9e4
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/TypeNameInterfaceSuperMethodReferenceApplicability.java
@@ -0,0 +1,42 @@
+interface I {
+ default void a() {}
+}
+
+interface J extends I {}
+
+class A implements I {}
+class B extends A {}
+class C implements J {}
+
+class Test1 implements I { { Runnable r = I.super::a; } }
+class Test2 implements J { { Runnable r = I.super::a; } }
+class Test3 implements I, J { { Runnable r = I.super::a; } }
+class Test5 extends A implements I { { Runnable r = I.super::a; } }
+class Test6 extends A implements J { { Runnable r = I.super::a; } }
+class Test7 extends B { { Runnable r = I.super::a; } }
+class Test8 extends C { { Runnable r = I.super::a; } }
+
+class Test {
+ {
+ class LocalJ implements I {
+ }
+ class Test3 extends LocalJ implements I {
+ {
+ Runnable r = I.super::a;
+ }
+ }
+
+ new I() {
+ {
+ Runnable r = I.super::a;
+ }
+ };
+
+ new A() {
+ {
+ Runnable r = I.super::a;
+ }
+ };
+ }
+}
+
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/overloadResolution/DetectNotEqualParametersInFunctionalTypesForExactMethodReferences.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/overloadResolution/DetectNotEqualParametersInFunctionalTypesForExactMethodReferences.java
new file mode 100644
index 000000000000..d84573859381
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/overloadResolution/DetectNotEqualParametersInFunctionalTypesForExactMethodReferences.java
@@ -0,0 +1,29 @@
+interface I1 {
+ int i1(int i);
+}
+
+interface I2 {
+ Integer i2(Integer i);
+}
+
+interface I3 {
+ Integer i3(int i);
+}
+
+class Test {
+
+ private void m(I1 i1) {System.out.println(i1);}
+ private void m(I2 i2) {System.out.println(i2);}
+
+ private void m1(I1 i1) {System.out.println(i1);}
+ private void m1(I3 i2) {System.out.println(i2);}
+
+ void test() {
+ m (this::bar);
+ m1(this::bar);
+ }
+
+ int bar(int i) {
+ return i;
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/overloadResolution/DetectPolyExpressionInReturnsOfExplicitlyTypedLambdaWhenPrimitiveCouldWin.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/overloadResolution/DetectPolyExpressionInReturnsOfExplicitlyTypedLambdaWhenPrimitiveCouldWin.java
new file mode 100644
index 000000000000..323b8505dbd1
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/overloadResolution/DetectPolyExpressionInReturnsOfExplicitlyTypedLambdaWhenPrimitiveCouldWin.java
@@ -0,0 +1,37 @@
+class Test {
+ interface GetInt { int get(); }
+ interface GetInteger { Integer get(); }
+
+ private void m(GetInt getter) {
+ System.out.println(getter);
+ }
+
+ private void m(GetInteger getter) {
+ System.out.println(getter);
+ }
+
+ void test(boolean cond) {
+ m(() -> {
+ if (cond)
+ return 42;
+ else
+ return foo();
+ });
+
+ m(() -> {
+ return foo();
+ });
+
+ m(() -> {
+ if (cond)
+ return new Integer(42);
+ else
+ return foo();
+ });
+
+ }
+
+ private T foo() {
+ return null;
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/overloadResolution/LambdaIsNotCongruentWithFunctionalTypeWithTypeParams.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/overloadResolution/LambdaIsNotCongruentWithFunctionalTypeWithTypeParams.java
new file mode 100644
index 000000000000..1242b170c92e
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/overloadResolution/LambdaIsNotCongruentWithFunctionalTypeWithTypeParams.java
@@ -0,0 +1,18 @@
+interface I {
+ void g();
+
+}
+interface J {
+ <T> void f();
+}
+class Test {
+ void m(I i) {System.out.println(i);}
+ void m(J j) {System.out.println(j);}
+
+ void m2(J j){System.out.println(j);}
+
+ {
+ m (() -> {});
+ m2(() -> {});
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/MethodReferenceOnNullable.java b/java/java-tests/testData/inspection/dataFlow/fixture/MethodReferenceOnNullable.java
new file mode 100644
index 000000000000..7b27c2e28bc3
--- /dev/null
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/MethodReferenceOnNullable.java
@@ -0,0 +1,18 @@
+import org.jetbrains.annotations.Nullable;
+
+class BrokenAlignment {
+
+ {
+ Runnable t = getString()::length;
+ Runnable t2 = BrokenAlignment::getStringStatic;
+ }
+
+ @Nullable
+ private String getString() {
+ return null;
+ }
+ @Nullable
+ private static String getStringStatic() {
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/NullableArray.java b/java/java-tests/testData/inspection/dataFlow/fixture/NullableArray.java
new file mode 100644
index 000000000000..2f92bc94f2c3
--- /dev/null
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/NullableArray.java
@@ -0,0 +1,53 @@
+import org.jetbrains.annotations.*;
+
+class Test {
+ @NotNull
+ public static int[] add(@Nullable final int[] ints, final int from, final int to) {
+ if (ints == null || ints.length == 0)
+ return new int[]{from, to};
+
+ for (int i = 0, j = 1; j < ints.length; i+=2, j+=2) {
+ final int intStart = ints[i];
+ final int intFinish = ints[j];
+
+ //check contained
+ if (intStart <= from && to <= intFinish)
+ return ints;
+
+ //try expand 'to' bound
+ if (intStart <= from && from <= intFinish) {
+ ints[j] = to;
+ return ints;
+ }
+
+ //try expand 'from' bound
+ if (intStart <= to && to <= intFinish) {
+ ints[i] = from;
+ return ints;
+ }
+
+ //if we add an interval that contains ors interval
+ //may produce duplicates
+ if (from <= intStart && intFinish <= to) {
+ ints[i] = from;
+ ints[j] = to;
+ return ints;
+ }
+
+ if (from == intFinish + 1) {
+ ints[j] = to;
+ return ints;
+ }
+ if (to == intStart - 1) {
+ ints[i] = from;
+ return ints;
+ }
+ }
+
+ //TODO: insert interval sorted?
+ final int[] newInts = new int[ints.length + 2];
+ System.arraycopy(ints, 0, newInts, 0, ints.length);
+ newInts[ints.length] = from;
+ newInts[ints.length+1] = to;
+ return newInts;
+ }}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/extractMethodObject/multipleExitPoints/ReturnExitStatement.java.after b/java/java-tests/testData/refactoring/extractMethodObject/multipleExitPoints/ReturnExitStatement.java.after
index aab751a7dae3..35dae91d81f2 100644
--- a/java/java-tests/testData/refactoring/extractMethodObject/multipleExitPoints/ReturnExitStatement.java.after
+++ b/java/java-tests/testData/refactoring/extractMethodObject/multipleExitPoints/ReturnExitStatement.java.after
@@ -2,7 +2,7 @@ class A {
boolean foo() {
Inner inner = new Inner().invoke();
- if (inner.is()) return inner.getFoo();
+ if (inner.is()) return inner.isFoo();
return false;
@@ -16,7 +16,7 @@ class A {
return myResult;
}
- public Boolean getFoo() {
+ public Boolean isFoo() {
return foo;
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/JavaCheckRegexpWithFlagsTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/JavaCheckRegexpWithFlagsTest.java
new file mode 100644
index 000000000000..4505368df013
--- /dev/null
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/JavaCheckRegexpWithFlagsTest.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2000-2015 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.codeInsight;
+
+import com.intellij.ide.highlighter.JavaFileType;
+import com.intellij.lang.LanguageParserDefinitions;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiFile;
+import com.intellij.psi.PsiLanguageInjectionHost;
+import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
+import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.testFramework.IdeaTestUtil;
+import com.intellij.testFramework.PsiTestUtil;
+import com.intellij.util.ArrayUtil;
+import org.intellij.lang.regexp.RegExpLanguage;
+import org.intellij.lang.regexp.RegExpParserDefinition;
+import org.intellij.lang.regexp.intention.CheckRegExpForm;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.List;
+import java.util.regex.Pattern;
+
+public class JavaCheckRegexpWithFlagsTest extends CodeInsightTestCase {
+
+ private static String getJavaText(@NotNull String regExp, int flags) {
+ return "import java.util.regex.Pattern;\n" +
+ "\n" +
+ "public class Test {\n" +
+ " public void foo() {\n" +
+ " Pattern.compile(\"" + regExp + "\", " + flags + ");\n" +
+ " }\n" +
+ "}\n";
+ }
+
+ private void defaultTest(@NotNull String regExp, int flags, @NotNull String[] matching, @NotNull String[] nonMatching) throws Exception {
+ LanguageParserDefinitions.INSTANCE.addExplicitExtension(RegExpLanguage.INSTANCE,
+ new RegExpParserDefinition());
+
+ // the 1.8 mock jdk has the needed Pattern class
+ PsiTestUtil.removeAllRoots(myModule, IdeaTestUtil.getMockJdk18());
+
+ configureByText(JavaFileType.INSTANCE, getJavaText(regExp, flags));
+ final PsiFile regexpFile = setUpRegexpInjectionAndGetRegexpFile();
+
+ for (String text : matching) {
+ assertTrue("Text '" + text + "' should match", CheckRegExpForm.isMatchingTextTest(regexpFile, text));
+ }
+ for (String text : nonMatching) {
+ assertFalse("Text '" + text + "' should not match", CheckRegExpForm.isMatchingTextTest(regexpFile, text));
+ }
+ }
+
+ @NotNull
+ private PsiFile setUpRegexpInjectionAndGetRegexpFile() {
+ final PsiFile file = getFile();
+
+ int offsetWithRegexp = file.getText().indexOf("Pattern.compile(\"")
+ + "Pattern.compile(\"".length();
+
+ final PsiElement stringLiteralLeaf = file.findElementAt(offsetWithRegexp);
+ assertNotNull(stringLiteralLeaf);
+ assertNotNull(stringLiteralLeaf.getParent());
+ assertTrue(stringLiteralLeaf.getParent() instanceof PsiLanguageInjectionHost);
+
+ final PsiLanguageInjectionHost elementWithInjection = ((PsiLanguageInjectionHost)stringLiteralLeaf.getParent());
+
+ InjectedLanguageUtil.enumerate(elementWithInjection, file, false, new PsiLanguageInjectionHost.InjectedPsiVisitor() {
+ @Override
+ public void visit(@NotNull final PsiFile injectedPsi, @NotNull List places) {
+ }
+ });
+
+ assertTrue(InjectedLanguageUtil.hasInjections(elementWithInjection));
+ final PsiElement elementInInjected =
+ InjectedLanguageUtil.findElementInInjected(elementWithInjection, offsetWithRegexp);
+
+ final PsiFile regexpFile = PsiTreeUtil.getParentOfType(elementInInjected, PsiFile.class);
+ assertNotNull(regexpFile);
+
+ return regexpFile;
+ }
+
+ public void testSimple() throws Exception {
+ defaultTest("abc|def|xy.", 0, new String[]{"abc", "def", "xyz"}, new String[]{"", "abcd", "Abc", "xy\n"});
+ }
+
+ public void testEnsureFlagsParameterIsUsed() throws Exception {
+ defaultTest("abc|def|xy.", Pattern.DOTALL, new String[]{"xyz", "xy\n"}, ArrayUtil.EMPTY_STRING_ARRAY);
+ }
+
+ public void testEnsureJavaNotRubyModeIsEnabled() throws Exception {
+ defaultTest("(?ms:^abc$.*)|(?m:xy.)", 0, new String[]{"abc", "abc\na", "xyz"}, new String[]{"xy\n"});
+ }
+}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java
index 96f5c3da5154..88ec8af16dd3 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java
@@ -788,6 +788,10 @@ public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase {
doTest(false);
}
+ public void testSuperInterfaceMethodCalledByMatterOfInterface() throws Exception {
+ doTest(false);
+ }
+
private void doTest() {
doTest(false);
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java
index 200321a39df9..cf5189bb567c 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java
@@ -80,6 +80,7 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testLiftedIntersectionType() { doTest(); }
public void testInferenceFromReturnStatements() { doTest(); }
public void testDownUpThroughLambdaReturnStatements() { doTest(); }
+ @Bombed(year = 2015, month = Calendar.MARCH, day = 30)
public void testIDEA124547() { doTest(); }
public void testIDEA118362() { doTest(); }
public void testIDEA126056() { doTest(); }
@@ -162,6 +163,7 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
doTest();
}
+ @Bombed(year = 2015, month = Calendar.MARCH, day = 30)
public void testIDEA127124() throws Exception {
doTest();
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java
index 2742c287dd18..59624a3099fc 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java
@@ -342,6 +342,26 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
doTest();
}
+ public void testRawReferenceTypeWithReceiver() throws Exception {
+ doTest();
+ }
+
+ public void testMethodReferenceTypeArgumentsApplicability() throws Exception {
+ doTest();
+ }
+
+ public void testTypeNameInterfaceSuperMethodReferenceApplicability() throws Exception {
+ doTest();
+ }
+
+ public void testNewParameterizedReferenceOnRawType() throws Exception {
+ doTest();
+ }
+
+ public void testArrayTypeNewReifiable() throws Exception {
+ doTest();
+ }
+
private void doTest() {
doTest(false);
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/OverloadResolutionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/OverloadResolutionTest.java
index 5f6fcf97c60b..3e3852503280 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/OverloadResolutionTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/OverloadResolutionTest.java
@@ -67,6 +67,18 @@ public class OverloadResolutionTest extends LightDaemonAnalyzerTestCase {
doTest();
}
+ public void testLambdaIsNotCongruentWithFunctionalTypeWithTypeParams() throws Exception {
+ doTest();
+ }
+
+ public void testDetectPolyExpressionInReturnsOfExplicitlyTypedLambdaWhenPrimitiveCouldWin() throws Exception {
+ doTest();
+ }
+
+ public void testDetectNotEqualParametersInFunctionalTypesForExactMethodReferences() throws Exception {
+ doTest();
+ }
+
private void doTest() {
doTest(true);
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspection8Test.java b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspection8Test.java
index 9581ab124ecc..34b1c015678f 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspection8Test.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspection8Test.java
@@ -76,6 +76,8 @@ public class DataFlowInspection8Test extends LightCodeInsightFixtureTestCase {
});
}
+ public void testMethodReferenceOnNullable() { doTest(); }
+
public void testNullableForeachVariable() {
setupCustomAnnotations();
doTest();
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java
index fbedf9bd82d4..2d44dcbd70b9 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java
@@ -282,6 +282,8 @@ public class DataFlowInspectionTest extends LightCodeInsightFixtureTestCase {
public void testNumberComparisonsWhenValueIsKnown() { doTest(); }
public void testFloatComparisons() { doTest(); }
+ public void testNullableArray() { doTest(); }
+
public void testAccessingSameArrayElements() { doTest(); }
public void testParametersAreNonnullByDefault() {
diff --git a/java/openapi/src/com/intellij/ide/util/projectWizard/JavaModuleBuilder.java b/java/openapi/src/com/intellij/ide/util/projectWizard/JavaModuleBuilder.java
index 516248de7b81..02773d89f1c8 100644
--- a/java/openapi/src/com/intellij/ide/util/projectWizard/JavaModuleBuilder.java
+++ b/java/openapi/src/com/intellij/ide/util/projectWizard/JavaModuleBuilder.java
@@ -16,22 +16,26 @@
package com.intellij.ide.util.projectWizard;
+import com.intellij.openapi.module.ModifiableModuleModel;
+import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleType;
import com.intellij.openapi.module.StdModuleTypes;
import com.intellij.openapi.options.ConfigurationException;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.projectRoots.JavaSdkType;
import com.intellij.openapi.projectRoots.SdkTypeId;
-import com.intellij.openapi.roots.CompilerModuleExtension;
-import com.intellij.openapi.roots.ContentEntry;
-import com.intellij.openapi.roots.ModifiableRootModel;
-import com.intellij.openapi.roots.OrderRootType;
+import com.intellij.openapi.roots.*;
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.roots.libraries.LibraryTable;
+import com.intellij.openapi.roots.ui.configuration.ModulesProvider;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VfsUtil;
+import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.pom.java.LanguageLevel;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -128,7 +132,7 @@ public class JavaModuleBuilder extends ModuleBuilder implements SourcePathsBuild
canonicalPath = myCompilerOutputPath;
}
compilerModuleExtension
- .setCompilerOutputPath(VfsUtil.pathToUrl(FileUtil.toSystemIndependentName(canonicalPath)));
+ .setCompilerOutputPath(VfsUtilCore.pathToUrl(FileUtil.toSystemIndependentName(canonicalPath)));
}
else {
compilerModuleExtension.inheritCompilerOutputPath(true);
@@ -148,6 +152,14 @@ public class JavaModuleBuilder extends ModuleBuilder implements SourcePathsBuild
}
}
+ @Nullable
+ @Override
+ public List commit(@NotNull Project project, ModifiableModuleModel model, ModulesProvider modulesProvider) {
+ LanguageLevel defaultLevel = LanguageLevelProjectExtension.getInstance(ProjectManager.getInstance().getDefaultProject()).getLanguageLevel();
+ LanguageLevelProjectExtension.getInstance(project).setLanguageLevel(defaultLevel);
+ return super.commit(project, model, modulesProvider);
+ }
+
private static String getUrlByPath(final String path) {
return VfsUtil.getUrlForLibraryRoot(new File(path));
}
diff --git a/jps/jps-builders/testData/incremental/multipleSources/changeTargetPackage.log b/jps/jps-builders/testData/incremental/multipleSources/changeTargetPackage.log
index 94b62af89351..f54bb07dc934 100644
--- a/jps/jps-builders/testData/incremental/multipleSources/changeTargetPackage.log
+++ b/jps/jps-builders/testData/incremental/multipleSources/changeTargetPackage.log
@@ -7,6 +7,7 @@ src/b.p
End of files
Cleaning output files:
out/production/m/PackageFacade.class
+out/production/m/a.class
out/production/m/xxx/PackageFacade.class
out/production/m/xxx/b.class
End of files
diff --git a/jps/jps-builders/testData/incremental/multipleSources/deleteFile.log b/jps/jps-builders/testData/incremental/multipleSources/deleteFile.log
index d30e27b99613..893d2fc1d06f 100644
--- a/jps/jps-builders/testData/incremental/multipleSources/deleteFile.log
+++ b/jps/jps-builders/testData/incremental/multipleSources/deleteFile.log
@@ -4,6 +4,7 @@ out/production/m/b.class
End of files
Cleaning output files:
out/production/m/PackageFacade.class
+out/production/m/a.class
End of files
Compiling files:
src/a.p
diff --git a/jps/jps-builders/testSrc/org/jetbrains/jps/builders/BuildResult.java b/jps/jps-builders/testSrc/org/jetbrains/jps/builders/BuildResult.java
index 7ef0495d6a8a..84dcedf39359 100644
--- a/jps/jps-builders/testSrc/org/jetbrains/jps/builders/BuildResult.java
+++ b/jps/jps-builders/testSrc/org/jetbrains/jps/builders/BuildResult.java
@@ -15,19 +15,25 @@
*/
package org.jetbrains.jps.builders;
+import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.Function;
+import com.intellij.util.ObjectUtils;
+import gnu.trove.TIntHashSet;
+import gnu.trove.TIntObjectHashMap;
+import gnu.trove.TIntProcedure;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.jps.builders.storage.SourceToOutputMapping;
import org.jetbrains.jps.cmdline.ProjectDescriptor;
import org.jetbrains.jps.incremental.MessageHandler;
import org.jetbrains.jps.incremental.messages.BuildMessage;
import org.jetbrains.jps.incremental.messages.DoneSomethingNotification;
+import org.jetbrains.jps.incremental.storage.OutputToTargetRegistry;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.*;
import static org.junit.Assert.*;
@@ -53,6 +59,7 @@ public class BuildResult implements MessageHandler {
final PrintStream stream = new PrintStream(dump);
try {
pd.dataManager.getMappings().toStream(stream);
+ dumpSourceToOutputMappings(pd, stream);
}
finally {
stream.close();
@@ -62,6 +69,63 @@ public class BuildResult implements MessageHandler {
myMappingsDump = dump.toString();
}
+ private static void dumpSourceToOutputMappings(ProjectDescriptor pd, PrintStream stream) throws IOException {
+ List> targets = new ArrayList>(pd.getBuildTargetIndex().getAllTargets());
+ Collections.sort(targets, new Comparator>() {
+ @Override
+ public int compare(BuildTarget> o1, BuildTarget> o2) {
+ return StringUtil.comparePairs(o1.getTargetType().getTypeId(), o1.getId(), o2.getTargetType().getTypeId(), o2.getId(), false);
+ }
+ });
+ final TIntObjectHashMap> id2Target = new TIntObjectHashMap>();
+ for (BuildTarget> target : targets) {
+ id2Target.put(pd.dataManager.getTargetsState().getBuildTargetId(target), target);
+ }
+ TIntObjectHashMap hashCodeToOutputPath = new TIntObjectHashMap();
+ for (BuildTarget> target : targets) {
+ stream.println("Begin Of SourceToOutput (target " + getTargetIdWithTypeId(target) + ")");
+ SourceToOutputMapping map = pd.dataManager.getSourceToOutputMap(target);
+ List sourcesList = new ArrayList(map.getSources());
+ Collections.sort(sourcesList);
+ for (String source : sourcesList) {
+ List outputs = new ArrayList(ObjectUtils.notNull(map.getOutputs(source), Collections.emptySet()));
+ Collections.sort(outputs);
+ for (String output : outputs) {
+ hashCodeToOutputPath.put(FileUtil.pathHashCode(output), output);
+ }
+ stream.println(" " + source + " -> " + StringUtil.join(outputs, ","));
+ }
+ stream.println("End Of SourceToOutput (target " + getTargetIdWithTypeId(target) + ")");
+ }
+
+
+ OutputToTargetRegistry registry = pd.dataManager.getOutputToTargetRegistry();
+ List keys = new ArrayList(registry.getKeys());
+ Collections.sort(keys);
+ stream.println("Begin Of OutputToTarget");
+ for (Integer key : keys) {
+ TIntHashSet targetsIds = registry.getState(key);
+ if (targetsIds == null) continue;
+ final List targetsNames = new ArrayList();
+ targetsIds.forEach(new TIntProcedure() {
+ @Override
+ public boolean execute(int value) {
+ BuildTarget> target = id2Target.get(value);
+ targetsNames.add(target != null ? getTargetIdWithTypeId(target) : "");
+ return true;
+ }
+ });
+ Collections.sort(targetsNames);
+ stream.println(hashCodeToOutputPath.get(key) + " -> " + targetsNames);
+ }
+ stream.println("End Of OutputToTarget");
+ }
+
+ @NotNull
+ private static String getTargetIdWithTypeId(BuildTarget> target) {
+ return target.getTargetType().getTypeId() + ":" + target.getId();
+ }
+
@Override
public void processMessage(BuildMessage msg) {
if (msg.getKind() == BuildMessage.Kind.ERROR) {
diff --git a/jps/jps-builders/testSrc/org/jetbrains/jps/builders/java/MockPackageFacadeBuilder.kt b/jps/jps-builders/testSrc/org/jetbrains/jps/builders/java/MockPackageFacadeBuilder.kt
index d141a39ac307..ca0e338aeb44 100644
--- a/jps/jps-builders/testSrc/org/jetbrains/jps/builders/java/MockPackageFacadeBuilder.kt
+++ b/jps/jps-builders/testSrc/org/jetbrains/jps/builders/java/MockPackageFacadeBuilder.kt
@@ -72,7 +72,8 @@ class MockPackageFacadeGenerator : ModuleLevelBuilder(BuilderCategory.SOURCE_PRO
val mappings = context.getProjectDescriptor().dataManager.getMappings()
val callback = JavaBuilderUtil.getDependenciesRegistrar(context)
- fun generateClass(packageName: String, className: String, target: ModuleBuildTarget, sources: Collection, generate: (ClassWriter.() -> Unit)? = null) {
+ fun generateClass(packageName: String, className: String, target: ModuleBuildTarget, sources: Collection,
+ allSources: Collection, generate: (ClassWriter.() -> Unit)? = null) {
val writer = ClassWriter(ClassWriter.COMPUTE_FRAMES)
val fullClassName = StringUtil.getQualifiedName(packageName, className).replace('.', '/')
writer.visit(Opcodes.V1_6, Opcodes.ACC_PUBLIC, fullClassName, null, "java/lang/Object", null)
@@ -84,39 +85,53 @@ class MockPackageFacadeGenerator : ModuleLevelBuilder(BuilderCategory.SOURCE_PRO
val classBytes = writer.toByteArray()
FileUtil.writeToFile(outputFile, classBytes)
outputConsumer.registerOutputFile(target, outputFile, sources)
- callback.associate(fullClassName.replace('/', '.'), sources, ClassReader(classBytes))
+ callback.associate(fullClassName.replace('/', '.'), allSources, ClassReader(classBytes))
}
for (target in chunk.getTargets()) {
val packagesStorage = context.getProjectDescriptor().dataManager.getStorage(target, PACKAGE_CACHE_STORAGE_PROVIDER)
for (file in filesToCompile[target]) {
- generateClass(getPackageName(file), FileUtil.getNameWithoutExtension(file), target, listOf(file.getAbsolutePath()))
+ val sources = listOf(file.getAbsolutePath())
+ generateClass(getPackageName(file), FileUtil.getNameWithoutExtension(file), target, sources, sources)
}
- val packagesToGenerate = filesToCompile[target].mapTo(THashSet(), ::getPackageName)
- filesToCompile[target].mapNotNullTo(packagesToGenerate) { packagesStorage.getState(it.getAbsolutePath()) }
+ val packagesToGenerate = LinkedHashMap>()
+ filesToCompile[target].forEach {
+ val currentName = getPackageName(it)
+ if (currentName !in packagesToGenerate) packagesToGenerate[currentName] = ArrayList()
+ packagesToGenerate[currentName].add(it)
+ val oldName = packagesStorage.getState(it.getAbsolutePath())
+ if (oldName != null && oldName != currentName && oldName !in packagesToGenerate) {
+ packagesToGenerate[oldName] = ArrayList()
+ }
+ }
val packagesFromDeletedFiles = dirtyFilesHolder.getRemovedFiles(target).filter { isCompilable(File(it)) }.mapNotNull { packagesStorage.getState(it) }
- packagesToGenerate.addAll(packagesFromDeletedFiles)
+ packagesFromDeletedFiles.forEach {
+ if (it !in packagesToGenerate) {
+ packagesToGenerate[it] = ArrayList()
+ }
+ }
val getParentFile: (File) -> File = { it.getParentFile() }
val dirsToCheck = filesToCompile[target].mapTo(THashSet(FileUtil.FILE_HASHING_STRATEGY), getParentFile)
packagesFromDeletedFiles.flatMap { mappings.getClassSources(mappings.getName(StringUtil.getQualifiedName(it, "PackageFacade"))) }
.map(getParentFile).filterNotNullTo(dirsToCheck)
- for (packageName in packagesToGenerate) {
+ for ((packageName, dirtyFiles) in packagesToGenerate) {
val files = dirsToCheck.map { it.listFiles() }.filterNotNull().flatMap { it.toList() }.filter { isCompilable(it) && packageName == getPackageName(it) }
if (files.isEmpty()) continue
val classNames = files.map { FileUtilRt.getNameWithoutExtension(it.getName()) }.sort()
- val sources = files.map { it.getAbsolutePath() }
+ val dirtySource = dirtyFiles.map { it.getAbsolutePath() }
+ val allSources = files.map { it.getAbsolutePath() }
- generateClass(packageName, "PackageFacade", target, sources) {
+ generateClass(packageName, "PackageFacade", target, dirtySource, allSources) {
for (fileName in classNames) {
val fieldClass = StringUtil.getQualifiedName(packageName, fileName).replace('.', '/')
visitField(Opcodes.ACC_PUBLIC, StringUtil.decapitalize(fileName), "L$fieldClass;", null, null).visitEnd()
}
}
- for (source in sources) {
+ for (source in dirtySource) {
packagesStorage.update(FileUtil.toSystemIndependentName(source), packageName)
}
}
diff --git a/platform/analysis-api/src/com/intellij/codeHighlighting/HighlightDisplayLevel.java b/platform/analysis-api/src/com/intellij/codeHighlighting/HighlightDisplayLevel.java
index bb197ca6b683..738e970fbca1 100644
--- a/platform/analysis-api/src/com/intellij/codeHighlighting/HighlightDisplayLevel.java
+++ b/platform/analysis-api/src/com/intellij/codeHighlighting/HighlightDisplayLevel.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,6 +15,7 @@
*/
package com.intellij.codeHighlighting;
+import com.intellij.icons.AllIcons;
import com.intellij.lang.annotation.HighlightSeverity;
import com.intellij.openapi.editor.colors.CodeInsightColors;
import com.intellij.openapi.editor.colors.EditorColorsManager;
@@ -22,6 +23,7 @@ import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.util.Comparing;
import com.intellij.ui.JBColor;
+import com.intellij.util.IconUtil;
import com.intellij.util.ObjectUtils;
import com.intellij.util.containers.HashMap;
import com.intellij.util.ui.ColorIcon;
@@ -38,7 +40,18 @@ public class HighlightDisplayLevel {
public static final HighlightDisplayLevel GENERIC_SERVER_ERROR_OR_WARNING = new HighlightDisplayLevel(HighlightSeverity.GENERIC_SERVER_ERROR_OR_WARNING,
createIconByKey(CodeInsightColors.GENERIC_SERVER_ERROR_OR_WARNING));
- public static final HighlightDisplayLevel ERROR = new HighlightDisplayLevel(HighlightSeverity.ERROR, createIconByKey(CodeInsightColors.ERRORS_ATTRIBUTES));
+ public static final HighlightDisplayLevel ERROR = new HighlightDisplayLevel(HighlightSeverity.ERROR, createErrorIcon());
+
+ @NotNull
+ private static Icon createErrorIcon() {
+ return new SingleColorIcon(CodeInsightColors.ERRORS_ATTRIBUTES) {
+ @Override
+ public void paintIcon(Component c, Graphics g, int x, int y) {
+ IconUtil.colorize(AllIcons.General.InspectionsError, getColor()).paintIcon(c, g, x, y);
+ }
+ };
+ }
+
public static final HighlightDisplayLevel WARNING = new HighlightDisplayLevel(HighlightSeverity.WARNING, createIconByKey(CodeInsightColors.WARNINGS_ATTRIBUTES));
private static final Icon DO_NOT_SHOW_KEY = createIconByKey(TextAttributesKey.createTextAttributesKey("DO_NOT_SHOW"));
public static final HighlightDisplayLevel DO_NOT_SHOW = new HighlightDisplayLevel(HighlightSeverity.INFORMATION, DO_NOT_SHOW_KEY);
@@ -99,8 +112,8 @@ public class HighlightDisplayLevel {
return mySeverity;
}
- public static void registerSeverity(@NotNull HighlightSeverity severity, final TextAttributesKey key) {
- Icon severityIcon = createIconByKey(key);
+ public static void registerSeverity(@NotNull HighlightSeverity severity, @NotNull TextAttributesKey key, @Nullable Icon icon) {
+ Icon severityIcon = icon != null ? icon : createIconByKey(key);
final HighlightDisplayLevel level = ourMap.get(severity);
if (level == null) {
new HighlightDisplayLevel(severity, severityIcon);
@@ -111,7 +124,7 @@ public class HighlightDisplayLevel {
}
public static int getEmptyIconDim() {
- return JBUI.scale(13);
+ return JBUI.scale(14);
}
public static Icon createIconByKey(@NotNull TextAttributesKey key) {
@@ -141,7 +154,7 @@ public class HighlightDisplayLevel {
public static class SingleColorIcon implements Icon, ColoredIcon {
private final TextAttributesKey myKey;
- public SingleColorIcon(final TextAttributesKey key) {
+ public SingleColorIcon(@NotNull TextAttributesKey key) {
myKey = key;
}
@@ -165,11 +178,9 @@ public class HighlightDisplayLevel {
}
@Override
- public void paintIcon(final Component c, final Graphics g, final int x, final int y) {
+ public void paintIcon(Component c, Graphics g, int x, int y) {
g.setColor(getColor());
- g.translate(x, y);
- g.fillPolygon(new int[]{0, getEmptyIconDim(), getEmptyIconDim()}, new int[]{0, 0, getEmptyIconDim()}, 3);
- g.translate(-x, -y);
+ g.fillRect(x + 2, y + 2, 10, 10);
}
@Override
diff --git a/platform/analysis-api/src/com/intellij/codeInspection/InjectionAwareSuppressQuickFix.java b/platform/analysis-api/src/com/intellij/codeInspection/InjectionAwareSuppressQuickFix.java
new file mode 100644
index 000000000000..27baddcd3220
--- /dev/null
+++ b/platform/analysis-api/src/com/intellij/codeInspection/InjectionAwareSuppressQuickFix.java
@@ -0,0 +1,18 @@
+package com.intellij.codeInspection;
+
+import com.intellij.psi.PsiElement;
+import com.intellij.util.ThreeState;
+
+/**
+ * This kind of suppression fix allows to clients to specify whether the fix should
+ * be invoked on injected elements or on elements of host files.
+ *
+ * By default suppression fixes on injected elements are able to make suppression inside injection only.
+ * Whereas implementation of this interface will be provided for suppressing inside injection and in injection host.
+ * See {@link InspectionProfileEntry#getBatchSuppressActions(PsiElement)} for details.
+ */
+public interface InjectionAwareSuppressQuickFix extends SuppressQuickFix {
+ ThreeState isShouldBeAppliedToInjectionHost();
+
+ void setShouldBeAppliedToInjectionHost(ThreeState shouldBeAppliedToInjectionHost);
+}
diff --git a/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfileEntry.java b/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfileEntry.java
index af1e65c67598..886d02aa55a2 100644
--- a/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfileEntry.java
+++ b/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfileEntry.java
@@ -17,6 +17,7 @@ package com.intellij.codeInspection;
import com.intellij.codeHighlighting.HighlightDisplayLevel;
import com.intellij.lang.Language;
+import com.intellij.lang.injection.InjectedLanguageManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.InvalidDataException;
@@ -24,8 +25,10 @@ import com.intellij.openapi.util.WriteExternalException;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.FileViewProvider;
import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiLanguageInjectionHost;
import com.intellij.psi.templateLanguages.TemplateLanguageFileViewProvider;
import com.intellij.util.ResourceUtil;
+import com.intellij.util.ThreeState;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.xmlb.SerializationFilter;
import com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters;
@@ -44,14 +47,16 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
-import java.util.*;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.Set;
/**
* @author anna
* @since 28-Nov-2005
*/
-@SuppressWarnings("JavadocReference")
-public abstract class InspectionProfileEntry implements BatchSuppressableTool{
+public abstract class InspectionProfileEntry implements BatchSuppressableTool {
public static final String GENERAL_GROUP_NAME = InspectionsBundle.message("inspection.general.tools.group.name");
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.InspectionProfileEntry");
@@ -93,22 +98,52 @@ public abstract class InspectionProfileEntry implements BatchSuppressableTool{
Set fixes = new THashSet(new TObjectHashingStrategy() {
@Override
public int computeHashCode(SuppressQuickFix object) {
- return object.getName().hashCode();
+ int result = object instanceof InjectionAwareSuppressQuickFix
+ ? ((InjectionAwareSuppressQuickFix)object).isShouldBeAppliedToInjectionHost().hashCode()
+ : 0;
+ return 31 * result + object.getName().hashCode();
}
@Override
public boolean equals(SuppressQuickFix o1, SuppressQuickFix o2) {
+ if (o1 instanceof InjectionAwareSuppressQuickFix && o2 instanceof InjectionAwareSuppressQuickFix) {
+ if (((InjectionAwareSuppressQuickFix)o1).isShouldBeAppliedToInjectionHost() != ((InjectionAwareSuppressQuickFix)o2).isShouldBeAppliedToInjectionHost()) {
+ return false;
+ }
+ }
return o1.getName().equals(o2.getName());
}
});
+
Set suppressors = getSuppressors(element);
+ final PsiLanguageInjectionHost injectionHost = InjectedLanguageManager.getInstance(element.getProject()).getInjectionHost(element);
+ if (injectionHost != null) {
+ Set injectionHostSuppressors = getSuppressors(injectionHost);
+ for (InspectionSuppressor suppressor : injectionHostSuppressors) {
+ addAllSuppressActions(fixes, injectionHost, suppressor, ThreeState.YES, getShortName());
+ }
+ }
+
for (InspectionSuppressor suppressor : suppressors) {
- SuppressQuickFix[] actions = suppressor.getSuppressActions(element, getShortName());
- fixes.addAll(Arrays.asList(actions));
+ addAllSuppressActions(fixes, element, suppressor, injectionHost != null ? ThreeState.NO : ThreeState.UNSURE, getShortName());
}
return fixes.toArray(new SuppressQuickFix[fixes.size()]);
}
+ private static void addAllSuppressActions(Set fixes,
+ PsiElement element,
+ InspectionSuppressor suppressor,
+ ThreeState appliedToInjectionHost,
+ String toolShortName) {
+ final SuppressQuickFix[] actions = suppressor.getSuppressActions(element, toolShortName);
+ for (SuppressQuickFix action : actions) {
+ if (action instanceof InjectionAwareSuppressQuickFix) {
+ ((InjectionAwareSuppressQuickFix)action).setShouldBeAppliedToInjectionHost(appliedToInjectionHost);
+ }
+ fixes.add(action);
+ }
+ }
+
private boolean isSuppressed(@NotNull String toolId,
@NotNull InspectionSuppressor suppressor,
@NotNull PsiElement element) {
@@ -132,7 +167,9 @@ public abstract class InspectionProfileEntry implements BatchSuppressableTool{
ContainerUtil.addIfNotNull(suppressors, elementLanguageSuppressor);
return suppressors;
}
- return elementLanguageSuppressor != null ? Collections.singleton(elementLanguageSuppressor) : Collections.emptySet();
+ return elementLanguageSuppressor != null
+ ? Collections.singleton(elementLanguageSuppressor)
+ : Collections.emptySet();
}
public void cleanup(Project project) {
@@ -148,9 +185,9 @@ public abstract class InspectionProfileEntry implements BatchSuppressableTool{
protected volatile DefaultNameProvider myNameProvider = null;
/**
- * @see com.intellij.codeInspection.InspectionEP#groupDisplayName
- * @see com.intellij.codeInspection.InspectionEP#groupKey
- * @see com.intellij.codeInspection.InspectionEP#groupBundle
+ * @see InspectionEP#groupDisplayName
+ * @see InspectionEP#groupKey
+ * @see InspectionEP#groupBundle
*/
@Nls
@NotNull
@@ -166,7 +203,7 @@ public abstract class InspectionProfileEntry implements BatchSuppressableTool{
}
/**
- * @see com.intellij.codeInspection.InspectionEP#groupPath
+ * @see InspectionEP#groupPath
*/
@NotNull
public String[] getGroupPath() {
@@ -178,9 +215,9 @@ public abstract class InspectionProfileEntry implements BatchSuppressableTool{
}
/**
- * @see com.intellij.codeInspection.InspectionEP#displayName
- * @see com.intellij.codeInspection.InspectionEP#key
- * @see com.intellij.codeInspection.InspectionEP#bundle
+ * @see InspectionEP#displayName
+ * @see InspectionEP#key
+ * @see InspectionEP#bundle
*/
@Nls
@NotNull
@@ -198,7 +235,7 @@ public abstract class InspectionProfileEntry implements BatchSuppressableTool{
/**
* DO NOT OVERRIDE this method.
*
- * @see com.intellij.codeInspection.InspectionEP#shortName
+ * @see InspectionEP#shortName
*/
@NonNls
@NotNull
@@ -214,13 +251,13 @@ public abstract class InspectionProfileEntry implements BatchSuppressableTool{
@NotNull
public static String getShortName(@NotNull String className) {
- return StringUtil.trimEnd(StringUtil.trimEnd(className, "Inspection"),"InspectionBase");
+ return StringUtil.trimEnd(StringUtil.trimEnd(className, "Inspection"), "InspectionBase");
}
/**
* DO NOT OVERRIDE this method.
*
- * @see com.intellij.codeInspection.InspectionEP#level
+ * @see InspectionEP#level
*/
@NotNull
public HighlightDisplayLevel getDefaultLevel() {
@@ -230,7 +267,7 @@ public abstract class InspectionProfileEntry implements BatchSuppressableTool{
/**
* DO NOT OVERRIDE this method.
*
- * @see com.intellij.codeInspection.InspectionEP#enabledByDefault
+ * @see InspectionEP#enabledByDefault
*/
public boolean isEnabledByDefault() {
return false;
@@ -238,6 +275,7 @@ public abstract class InspectionProfileEntry implements BatchSuppressableTool{
/**
* This method is called each time UI is shown.
+ *
* @return null if no UI options required.
*/
@Nullable
@@ -348,7 +386,7 @@ public abstract class InspectionProfileEntry implements BatchSuppressableTool{
* Initialize inspection with project. Is called on project opened for all profiles as well as on profile creation.
*
* @param project to be associated with this entry
- * @deprecated this won't work for inspections configured via {@link com.intellij.codeInspection.InspectionEP}
+ * @deprecated this won't work for inspections configured via {@link InspectionEP}
*/
public void projectOpened(@NotNull Project project) {
}
@@ -357,7 +395,7 @@ public abstract class InspectionProfileEntry implements BatchSuppressableTool{
* Cleanup inspection settings corresponding to the project. Is called on project closed for all profiles as well as on profile deletion.
*
* @param project to be disassociated from this entry
- * @deprecated this won't work for inspections configured via {@link com.intellij.codeInspection.InspectionEP}
+ * @deprecated this won't work for inspections configured via {@link InspectionEP}
*/
public void projectClosed(@NotNull Project project) {
}
@@ -411,7 +449,8 @@ public abstract class InspectionProfileEntry implements BatchSuppressableTool{
if (descriptionUrl == null) return null;
return ResourceUtil.loadText(descriptionUrl);
}
- catch (IOException ignored) { }
+ catch (IOException ignored) {
+ }
return null;
}
diff --git a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoType.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoType.java
index 458e02b368b9..9b97727328e8 100644
--- a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoType.java
+++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoType.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,6 +36,8 @@ import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import javax.swing.*;
+
public interface HighlightInfoType {
@NonNls String UNUSED_SYMBOL_SHORT_NAME = "unused";
@NonNls String UNUSED_SYMBOL_DISPLAY_NAME = InspectionsBundle.message("inspection.dead.code.display.name");
@@ -201,4 +203,8 @@ public interface HighlightInfoType {
return myToolKey;
}
}
+
+ interface Iconable {
+ Icon getIcon();
+ }
}
diff --git a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/SeverityRegistrar.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/SeverityRegistrar.java
index a6a9770223a6..8176f3ad0d4f 100644
--- a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/SeverityRegistrar.java
+++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/SeverityRegistrar.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +27,6 @@ import com.intellij.openapi.util.JDOMExternalizableStringList;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.profile.codeInspection.InspectionProfileManager;
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
-import com.intellij.ui.JBColor;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.concurrency.AtomicFieldUpdater;
import com.intellij.util.containers.ContainerUtil;
@@ -94,7 +93,7 @@ public class SeverityRegistrar implements JDOMExternalizable, Comparator> 16) & 0xff, (rgb >> 8) & 0xff, rgb & 0xff, rgba[3]});
+ img.getRaster().setPixel(x, y, new int[]{rgb >> 16 & 0xff, rgb >> 8 & 0xff, rgb & 0xff, rgba[3]});
}
}
}
diff --git a/platform/core-impl/src/com/intellij/psi/impl/PsiManagerImpl.java b/platform/core-impl/src/com/intellij/psi/impl/PsiManagerImpl.java
index cefb5dc1919f..ce78e78b2609 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/PsiManagerImpl.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/PsiManagerImpl.java
@@ -22,7 +22,6 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.fileEditor.FileDocumentManager;
-import com.intellij.openapi.fileTypes.InternalFileType;
import com.intellij.openapi.progress.ProgressIndicatorProvider;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.FileIndexFacade;
@@ -49,7 +48,7 @@ public class PsiManagerImpl extends PsiManagerEx {
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.PsiManagerImpl");
private final Project myProject;
- private final FileIndexFacade myExcludedFileIndex;
+ private final FileIndexFacade myFileIndex;
private final MessageBus myMessageBus;
private final PsiModificationTracker myModificationTracker;
@@ -71,11 +70,11 @@ public class PsiManagerImpl extends PsiManagerEx {
public PsiManagerImpl(Project project,
FileDocumentManager fileDocumentManager,
PsiBuilderFactory psiBuilderFactory,
- FileIndexFacade excludedFileIndex,
+ FileIndexFacade fileIndex,
MessageBus messageBus,
PsiModificationTracker modificationTracker) {
myProject = project;
- myExcludedFileIndex = excludedFileIndex;
+ myFileIndex = fileIndex;
myMessageBus = messageBus;
myModificationTracker = modificationTracker;
@@ -84,7 +83,7 @@ public class PsiManagerImpl extends PsiManagerEx {
boolean isProjectDefault = project.isDefault();
- myFileManager = isProjectDefault ? new EmptyFileManager(this) : new FileManagerImpl(this, fileDocumentManager, excludedFileIndex);
+ myFileManager = isProjectDefault ? new EmptyFileManager(this) : new FileManagerImpl(this, fileDocumentManager, fileIndex);
myTreeChangePreprocessors.add((PsiTreeChangePreprocessor)modificationTracker);
Collections.addAll(myTreeChangePreprocessors, Extensions.getExtensions(PsiTreeChangePreprocessor.EP_NAME, myProject));
@@ -131,10 +130,9 @@ public class PsiManagerImpl extends PsiManagerEx {
virtualFile = ((PsiFileSystemItem)element).getVirtualFile();
}
if (file != null && file.isPhysical() && virtualFile instanceof LightVirtualFile) return true;
- if (virtualFile != null && virtualFile.getFileType() instanceof InternalFileType) return true;
if (virtualFile != null) {
- return myExcludedFileIndex.isInContent(virtualFile);
+ return myFileIndex.isInContent(virtualFile);
}
return false;
}
diff --git a/platform/core-impl/src/com/intellij/psi/stubs/StubTree.java b/platform/core-impl/src/com/intellij/psi/stubs/StubTree.java
index 16488845acff..fa5bc5b3de91 100644
--- a/platform/core-impl/src/com/intellij/psi/stubs/StubTree.java
+++ b/platform/core-impl/src/com/intellij/psi/stubs/StubTree.java
@@ -62,7 +62,10 @@ public class StubTree extends ObjectStubTree> {
@NotNull
@Override
public List> getPlainListFromAllRoots() {
- return ContainerUtil.concat(getRoot().getStubRoots(), new Function>>() {
+ final PsiFileStub[] roots = getRoot().getStubRoots();
+ if (roots.length == 1) return super.getPlainListFromAllRoots();
+
+ return ContainerUtil.concat(roots, new Function>>() {
@Override
public Collection extends StubElement>> fun(PsiFileStub stub) {
final ObjectStubTree existingTree = stub.getUserData(STUB_TO_TREE_REFERENCE);
diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/RepositoryNode.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/RepositoryNode.java
index 26097d26e035..54c7d56d1c0a 100644
--- a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/RepositoryNode.java
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/RepositoryNode.java
@@ -83,20 +83,20 @@ public class RepositoryNode extends CheckedTreeNode implements EditableTreeNode,
repoFixedWidth += checkBoxWidth;
if (myCheckBoxHGap > 0) {
renderer.append("");
- renderer.appendFixedTextFragmentWidth(checkBoxWidth + renderer.getIconTextGap() + borderHOffset);
+ renderer.appendTextPadding(checkBoxWidth + renderer.getIconTextGap() + borderHOffset);
}
}
else {
if (myCheckBoxHGap <= 0) {
renderer.append("");
- renderer.appendFixedTextFragmentWidth(myRepositoryPanel.calculateRendererShiftH(renderer));
+ renderer.appendTextPadding(myRepositoryPanel.calculateRendererShiftH(renderer));
}
}
SimpleTextAttributes repositoryDetailsTextAttributes = PushLogTreeUtil
.addTransparencyIfNeeded(SimpleTextAttributes.REGULAR_ATTRIBUTES, isChecked());
renderer.append(getRepoName(renderer, repoFixedWidth), repositoryDetailsTextAttributes);
- renderer.appendFixedTextFragmentWidth(repoFixedWidth);
+ renderer.appendTextPadding(repoFixedWidth);
renderer.append(myRepositoryPanel.getSourceName(), repositoryDetailsTextAttributes);
renderer.append(myRepositoryPanel.getArrow(), repositoryDetailsTextAttributes);
PushTargetPanel pushTargetPanel = myRepositoryPanel.getTargetPanel();
diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/RepositoryWithBranchPanel.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/RepositoryWithBranchPanel.java
index c943ab0b32ff..e11d8f7ac9f6 100644
--- a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/RepositoryWithBranchPanel.java
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/RepositoryWithBranchPanel.java
@@ -147,10 +147,10 @@ public class RepositoryWithBranchPanel extends NonOpaquePa
myRepositoryCheckbox.setVisible(true);
if (myCheckBoxLoadingIconGapH < 0) {
myTextRenderer.append("");
- myTextRenderer.appendFixedTextFragmentWidth(calculateRendererShiftH(myTextRenderer));
+ myTextRenderer.appendTextPadding(calculateRendererShiftH(myTextRenderer));
}
myTextRenderer.append(getRepositoryName(), SimpleTextAttributes.GRAY_ATTRIBUTES);
- myTextRenderer.appendFixedTextFragmentWidth(120);
+ myTextRenderer.appendTextPadding(120);
}
else {
myRepositoryCheckbox.setVisible(false);
diff --git a/platform/icons/src/actions/profile.png b/platform/icons/src/actions/profile.png
new file mode 100644
index 000000000000..cc8213ca882e
Binary files /dev/null and b/platform/icons/src/actions/profile.png differ
diff --git a/platform/icons/src/actions/profile@2x.png b/platform/icons/src/actions/profile@2x.png
new file mode 100644
index 000000000000..0c5fc458a0ae
Binary files /dev/null and b/platform/icons/src/actions/profile@2x.png differ
diff --git a/platform/icons/src/general/eye.png b/platform/icons/src/general/eye.png
deleted file mode 100644
index a762227beceb..000000000000
Binary files a/platform/icons/src/general/eye.png and /dev/null differ
diff --git a/platform/icons/src/general/eye@2x.png b/platform/icons/src/general/eye@2x.png
deleted file mode 100644
index c234032e0c80..000000000000
Binary files a/platform/icons/src/general/eye@2x.png and /dev/null differ
diff --git a/platform/icons/src/general/eye@2x_dark.png b/platform/icons/src/general/eye@2x_dark.png
deleted file mode 100644
index e41e2263871d..000000000000
Binary files a/platform/icons/src/general/eye@2x_dark.png and /dev/null differ
diff --git a/platform/icons/src/general/eye_dark.png b/platform/icons/src/general/eye_dark.png
deleted file mode 100644
index e27c69cfa37e..000000000000
Binary files a/platform/icons/src/general/eye_dark.png and /dev/null differ
diff --git a/platform/icons/src/general/inspectionsError.png b/platform/icons/src/general/inspectionsError.png
new file mode 100644
index 000000000000..abfa0f68ade6
Binary files /dev/null and b/platform/icons/src/general/inspectionsError.png differ
diff --git a/platform/icons/src/general/inspectionsError@2x.png b/platform/icons/src/general/inspectionsError@2x.png
new file mode 100644
index 000000000000..3637348aeb9d
Binary files /dev/null and b/platform/icons/src/general/inspectionsError@2x.png differ
diff --git a/platform/icons/src/general/inspectionsEye.png b/platform/icons/src/general/inspectionsEye.png
new file mode 100755
index 000000000000..73417f25bca9
Binary files /dev/null and b/platform/icons/src/general/inspectionsEye.png differ
diff --git a/platform/icons/src/general/inspectionsEye@2x.png b/platform/icons/src/general/inspectionsEye@2x.png
new file mode 100755
index 000000000000..faa6719d52e8
Binary files /dev/null and b/platform/icons/src/general/inspectionsEye@2x.png differ
diff --git a/platform/icons/src/general/inspectionsOK.png b/platform/icons/src/general/inspectionsOK.png
new file mode 100755
index 000000000000..4ba59a036063
Binary files /dev/null and b/platform/icons/src/general/inspectionsOK.png differ
diff --git a/platform/icons/src/general/inspectionsOK@2x.png b/platform/icons/src/general/inspectionsOK@2x.png
new file mode 100755
index 000000000000..60b6b235f462
Binary files /dev/null and b/platform/icons/src/general/inspectionsOK@2x.png differ
diff --git a/platform/icons/src/general/inspectionsPause.png b/platform/icons/src/general/inspectionsPause.png
old mode 100644
new mode 100755
index 5635f94a6723..0c5b60763f44
Binary files a/platform/icons/src/general/inspectionsPause.png and b/platform/icons/src/general/inspectionsPause.png differ
diff --git a/platform/icons/src/general/inspectionsPause@2x.png b/platform/icons/src/general/inspectionsPause@2x.png
old mode 100644
new mode 100755
index cb94ad040fe9..675522bf895d
Binary files a/platform/icons/src/general/inspectionsPause@2x.png and b/platform/icons/src/general/inspectionsPause@2x.png differ
diff --git a/platform/icons/src/general/inspectionsPause@2x_dark.png b/platform/icons/src/general/inspectionsPause@2x_dark.png
old mode 100644
new mode 100755
index 388917cccc70..30074fdbec67
Binary files a/platform/icons/src/general/inspectionsPause@2x_dark.png and b/platform/icons/src/general/inspectionsPause@2x_dark.png differ
diff --git a/platform/icons/src/general/inspectionsPause_dark.png b/platform/icons/src/general/inspectionsPause_dark.png
old mode 100644
new mode 100755
index b89b52504b4b..c60578ce9482
Binary files a/platform/icons/src/general/inspectionsPause_dark.png and b/platform/icons/src/general/inspectionsPause_dark.png differ
diff --git a/platform/icons/src/general/inspectionsTrafficOff.png b/platform/icons/src/general/inspectionsTrafficOff.png
new file mode 100755
index 000000000000..7f0ecb58f646
Binary files /dev/null and b/platform/icons/src/general/inspectionsTrafficOff.png differ
diff --git a/platform/icons/src/general/inspectionsTrafficOff@2x.png b/platform/icons/src/general/inspectionsTrafficOff@2x.png
new file mode 100755
index 000000000000..3f75c1e2ac4d
Binary files /dev/null and b/platform/icons/src/general/inspectionsTrafficOff@2x.png differ
diff --git a/platform/icons/src/general/inspectionsTypos.png b/platform/icons/src/general/inspectionsTypos.png
new file mode 100755
index 000000000000..da83aa03879a
Binary files /dev/null and b/platform/icons/src/general/inspectionsTypos.png differ
diff --git a/platform/icons/src/general/inspectionsTypos@2x.png b/platform/icons/src/general/inspectionsTypos@2x.png
new file mode 100755
index 000000000000..11c7c81ae428
Binary files /dev/null and b/platform/icons/src/general/inspectionsTypos@2x.png differ
diff --git a/platform/lang-api/src/com/intellij/execution/util/EnvVariablesTable.java b/platform/lang-api/src/com/intellij/execution/util/EnvVariablesTable.java
index 8a355d263a07..552d7563a2f2 100644
--- a/platform/lang-api/src/com/intellij/execution/util/EnvVariablesTable.java
+++ b/platform/lang-api/src/com/intellij/execution/util/EnvVariablesTable.java
@@ -143,7 +143,7 @@ public class EnvVariablesTable extends ListTableWithButtons
public void actionPerformed(@NotNull AnActionEvent e) {
stopEditing();
StringBuilder sb = new StringBuilder();
- List variables = getEnvironmentVariables();
+ List variables = getSelection();
for (EnvironmentVariable environmentVariable : variables) {
if (environmentVariable.getIsPredefined() || isEmpty(environmentVariable)) continue;
if (sb.length() > 0) sb.append('\n');
@@ -152,10 +152,16 @@ public class EnvVariablesTable extends ListTableWithButtons
}
CopyPasteManager.getInstance().setContents(new StringSelection(sb.toString()));
}
+
+ @Override
+ public boolean isEnabled() {
+ return super.isEnabled() && !getSelection().isEmpty();
+ }
};
AnActionButton pasteButton = new AnActionButton(ActionsBundle.message("action.EditorPaste.text"), AllIcons.Actions.Menu_paste) {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
+ removeSelected();
stopEditing();
String content = CopyPasteManager.getInstance().getContents(DataFlavor.stringFlavor);
if (content == null || !content.contains("=")) return;
@@ -172,13 +178,7 @@ public class EnvVariablesTable extends ListTableWithButtons
StringUtil.unescapeStringCharacters(line.substring(pos + 1)),
false));
}
- List variables =
- new ArrayList(ContainerUtil.filter(getEnvironmentVariables(), new Condition() {
- @Override
- public boolean value(EnvironmentVariable variable) {
- return variable.getIsPredefined();
- }
- }));
+ List variables = new ArrayList(getEnvironmentVariables());
variables.addAll(parsed);
setValues(variables);
}
diff --git a/platform/lang-api/src/com/intellij/execution/util/ListTableWithButtons.java b/platform/lang-api/src/com/intellij/execution/util/ListTableWithButtons.java
index 1e243d636503..5ea5a2ae5ac7 100644
--- a/platform/lang-api/src/com/intellij/execution/util/ListTableWithButtons.java
+++ b/platform/lang-api/src/com/intellij/execution/util/ListTableWithButtons.java
@@ -16,6 +16,7 @@
package com.intellij.execution.util;
import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.util.Condition;
import com.intellij.ui.*;
import com.intellij.ui.table.TableView;
import com.intellij.util.containers.ContainerUtil;
@@ -30,6 +31,7 @@ import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellRenderer;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Observable;
@@ -110,31 +112,19 @@ public abstract class ListTableWithButtons extends Observable {
}).setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
- myTableView.stopEditing();
- setModified();
- T selected = getSelection();
- if (selected != null) {
- int selectedIndex = myElements.indexOf(selected);
- myTableView.scrollRectToVisible(myTableView.getCellRect(selectedIndex, 0, true));
- myElements.remove(selected);
- myTableView.getTableViewModel().setItems(myElements);
-
- int prev = selectedIndex - 1;
- if (prev >= 0) {
- myTableView.getComponent().getSelectionModel().setSelectionInterval(prev, prev);
- }
- else if (selectedIndex < myElements.size()) {
- myTableView.getComponent().getSelectionModel().setSelectionInterval(selectedIndex, selectedIndex);
- }
- }
+ removeSelected();
}
}).disableUpDownActions().addExtraActions(createExtraActions()).createPanel();
ToolbarDecorator.findRemoveButton(myPanel).addCustomUpdater(new AnActionButtonUpdater() {
@Override
public boolean isEnabled(AnActionEvent e) {
- T selection = getSelection();
- return selection != null && myIsEnabled && canDeleteElement(selection);
+ List selection = getSelection();
+ if (selection.isEmpty() || !myIsEnabled) return false;
+ for (T t : selection) {
+ if (!canDeleteElement(t)) return false;
+ }
+ return true;
}
});
ToolbarDecorator.findAddButton(myPanel).addCustomUpdater(new AnActionButtonUpdater() {
@@ -146,9 +136,33 @@ public abstract class ListTableWithButtons extends Observable {
myActionsPanel = decorator.getActionsPanel();
- myTableView.getComponent().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
-
- myTableView.getComponent().putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
+ myTableView.getComponent().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+ }
+
+ protected void removeSelected() {
+ List selected = getSelection();
+ if (!selected.isEmpty()) {
+ myTableView.stopEditing();
+ setModified();
+ int selectedIndex = myTableView.getSelectionModel().getLeadSelectionIndex();
+ myTableView.scrollRectToVisible(myTableView.getCellRect(selectedIndex, 0, true));
+ selected = ContainerUtil.filter(selected, new Condition() {
+ @Override
+ public boolean value(T t) {
+ return canDeleteElement(t);
+ }
+ });
+ myElements.removeAll(selected);
+ myTableView.getTableViewModel().setItems(myElements);
+
+ int prev = selectedIndex - 1;
+ if (prev >= 0) {
+ myTableView.getComponent().getSelectionModel().setSelectionInterval(prev, prev);
+ }
+ else if (selectedIndex < myElements.size()) {
+ myTableView.getComponent().getSelectionModel().setSelectionInterval(selectedIndex, selectedIndex);
+ }
+ }
}
@NotNull
@@ -199,7 +213,9 @@ public abstract class ListTableWithButtons extends Observable {
}
protected void editSelection(int column) {
- int row = myElements.indexOf(getSelection());
+ List selection = getSelection();
+ if (selection.size() != 1) return;
+ int row = myElements.indexOf(selection.get(0));
if (row != -1) {
TableUtil.editCellAt(myTableView, row, column);
}
@@ -215,13 +231,18 @@ public abstract class ListTableWithButtons extends Observable {
}
- protected T getSelection() {
- int selIndex = myTableView.getComponent().getSelectionModel().getMinSelectionIndex();
- if (selIndex < 0) {
- return null;
+ @NotNull
+ protected List getSelection() {
+ int[] selection = myTableView.getComponent().getSelectedRows();
+ if (selection.length == 0) {
+ return Collections.emptyList();
}
else {
- return myElements.get(selIndex);
+ List result = new ArrayList(selection.length);
+ for (int row : selection) {
+ result.add(myElements.get(row));
+ }
+ return result;
}
}
diff --git a/platform/lang-api/src/com/intellij/ide/util/projectWizard/ModuleBuilder.java b/platform/lang-api/src/com/intellij/ide/util/projectWizard/ModuleBuilder.java
index 861123ab7839..f7b00afd6fff 100644
--- a/platform/lang-api/src/com/intellij/ide/util/projectWizard/ModuleBuilder.java
+++ b/platform/lang-api/src/com/intellij/ide/util/projectWizard/ModuleBuilder.java
@@ -334,7 +334,7 @@ public abstract class ModuleBuilder extends AbstractModuleBuilder {
@Override
@Nullable
- public List commit(final Project project, final ModifiableModuleModel model, final ModulesProvider modulesProvider) {
+ public List commit(@NotNull final Project project, final ModifiableModuleModel model, final ModulesProvider modulesProvider) {
final Module module = commitModule(project, model);
return module != null ? Collections.singletonList(module) : null;
}
diff --git a/platform/lang-api/src/com/intellij/ide/util/projectWizard/ProjectBuilder.java b/platform/lang-api/src/com/intellij/ide/util/projectWizard/ProjectBuilder.java
index 56d45ded3906..79f5d1cee8e0 100644
--- a/platform/lang-api/src/com/intellij/ide/util/projectWizard/ProjectBuilder.java
+++ b/platform/lang-api/src/com/intellij/ide/util/projectWizard/ProjectBuilder.java
@@ -28,25 +28,28 @@ import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.projectRoots.SdkTypeId;
import com.intellij.openapi.roots.ui.configuration.DefaultModulesProvider;
import com.intellij.openapi.roots.ui.configuration.ModulesProvider;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public abstract class ProjectBuilder {
+
public boolean isUpdate() {
return false;
}
@Nullable
- public abstract List commit(final Project project, @Nullable final ModifiableModuleModel model, final ModulesProvider modulesProvider);
+ public abstract List commit(final @NotNull Project project, @Nullable final ModifiableModuleModel model, final ModulesProvider modulesProvider);
- public List commit(@Nullable Project project) {
+ public List commit(@NotNull Project project) {
return commit(project, null, DefaultModulesProvider.createForProject(project));
}
public boolean validate(Project current, Project dest) {
return true;
}
+
public void cleanup() {}
public boolean isOpenProjectSettingsAfter() {
@@ -54,7 +57,7 @@ public abstract class ProjectBuilder {
}
/**
- * Deprecated. Use {@link #isSuitableSdkType(com.intellij.openapi.projectRoots.SdkTypeId)} instead.
+ * Deprecated. Use {@link #isSuitableSdkType(SdkTypeId)} instead.
*
* Used for automatically assigning an SDK to the project when it gets created.
* If no SDK is specified in the template project and there is no specific SDK chooser step,
@@ -73,7 +76,6 @@ public abstract class ProjectBuilder {
return true;
}
-
@Nullable
public Project createProject(String name, String path) {
return ProjectManager.getInstance().createProject(name, path);
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 5c8b6544ca08..9dde14d31836 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
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,7 +16,6 @@
package com.intellij.codeInsight.daemon.impl;
-import com.intellij.codeHighlighting.HighlightDisplayLevel;
import com.intellij.codeHighlighting.TextEditorHighlightingPass;
import com.intellij.codeInsight.daemon.DaemonBundle;
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
@@ -29,7 +28,6 @@ import com.intellij.lang.annotation.HighlightSeverity;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Document;
-import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.editor.ex.EditorMarkupModel;
import com.intellij.openapi.editor.ex.MarkupModelEx;
import com.intellij.openapi.editor.ex.RangeHighlighterEx;
@@ -64,8 +62,6 @@ import java.util.*;
import java.util.List;
public class TrafficLightRenderer implements ErrorStripeRenderer, Disposable {
- private static final TextAttributesKey NO_ANALYSIS = TextAttributesKey.createTextAttributesKey("NO_ANALYSIS");
- private static final Icon NO_ANALYSIS_ICON = new HighlightDisplayLevel.SingleColorIcon(NO_ANALYSIS);
private final Project myProject;
private final Document myDocument;
private final PsiFile myFile;
@@ -296,7 +292,7 @@ public class TrafficLightRenderer implements ErrorStripeRenderer, Disposable {
if (PowerSaveMode.isEnabled() || status.reasonWhySuspended != null || status.reasonWhyDisabled != null || status.errorAnalyzingFinished) {
return icon;
}
- return AllIcons.General.Eye;
+ return AllIcons.General.InspectionsEye;
}
// return true if panel needs to be rebuilt
@@ -326,7 +322,7 @@ public class TrafficLightRenderer implements ErrorStripeRenderer, Disposable {
statusExtraLine = "(" + status.reasonWhyDisabled + ")";
passStatusesVisible = true;
progressBarsCompleted = Boolean.FALSE;
- icon = NO_ANALYSIS_ICON;
+ icon = AllIcons.General.InspectionsTrafficOff;
return result;
}
if (status.reasonWhySuspended != null) {
@@ -338,7 +334,7 @@ public class TrafficLightRenderer implements ErrorStripeRenderer, Disposable {
return result;
}
- Icon icon = HighlightDisplayLevel.DO_NOT_SHOW.getIcon();
+ Icon icon = AllIcons.General.InspectionsOK;
for (int i = status.errorCount.length - 1; i >= 0; i--) {
if (status.errorCount[i] != 0) {
icon = SeverityRegistrar.getSeverityRegistrar(project).getRendererIconByIndex(i);
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/IntentionHintComponent.java b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/IntentionHintComponent.java
index d71f60589150..436356065f2c 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/IntentionHintComponent.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/IntentionHintComponent.java
@@ -28,10 +28,14 @@ import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.codeInsight.intention.impl.config.IntentionActionWrapper;
import com.intellij.codeInsight.intention.impl.config.IntentionManagerSettings;
import com.intellij.codeInsight.intention.impl.config.IntentionSettingsConfigurable;
+import com.intellij.codeInsight.unwrap.ScopeHighlighter;
+import com.intellij.codeInspection.SuppressIntentionActionFromFix;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.ActionManager;
+import com.intellij.openapi.actionSystem.DataProvider;
import com.intellij.openapi.actionSystem.IdeActions;
+import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
@@ -52,7 +56,9 @@ import com.intellij.openapi.ui.popup.ListPopup;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Disposer;
+import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
+import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
import com.intellij.refactoring.BaseRefactoringIntentionAction;
import com.intellij.ui.HintHint;
import com.intellij.ui.LightweightHint;
@@ -61,6 +67,7 @@ import com.intellij.ui.RowIcon;
import com.intellij.ui.awt.RelativePoint;
import com.intellij.util.Alarm;
import com.intellij.util.IncorrectOperationException;
+import com.intellij.util.ThreeState;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.EmptyIcon;
import org.jetbrains.annotations.NotNull;
@@ -69,11 +76,14 @@ import org.jetbrains.annotations.TestOnly;
import javax.swing.*;
import javax.swing.border.Border;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
+import java.util.Collections;
import java.util.List;
/**
@@ -441,12 +451,52 @@ public class IntentionHintComponent extends JPanel implements Disposable, Scroll
Disposer.dispose(myPopup);
}
myPopup = JBPopupFactory.getInstance().createListPopup(step);
+
+ final PsiFile injectedFile = InjectedLanguageUtil.findInjectedPsiNoCommit(myFile, myEditor.getCaretModel().getOffset());
+ final Editor injectedEditor = InjectedLanguageUtil.getInjectedEditorForInjectedFile(myEditor, injectedFile);
+
+ final ScopeHighlighter highlighter = new ScopeHighlighter(myEditor);
+ final ScopeHighlighter injectionHighlighter = new ScopeHighlighter(injectedEditor);
+
myPopup.addListener(new JBPopupListener.Adapter() {
@Override
public void onClosed(LightweightWindowEvent event) {
+ highlighter.dropHighlight();
+ injectionHighlighter.dropHighlight();
myPopupShown = false;
}
});
+ myPopup.addListSelectionListener(new ListSelectionListener() {
+ @Override
+ public void valueChanged(ListSelectionEvent e) {
+ final Object source = e.getSource();
+ highlighter.dropHighlight();
+ injectionHighlighter.dropHighlight();
+
+ if (source instanceof DataProvider) {
+ final Object selectedItem = PlatformDataKeys.SELECTED_ITEM.getData((DataProvider)source);
+ if (selectedItem instanceof IntentionActionWithTextCaching) {
+ final IntentionAction action = ((IntentionActionWithTextCaching)selectedItem).getAction();
+ if (action instanceof SuppressIntentionActionFromFix) {
+ if (injectedFile != null && ((SuppressIntentionActionFromFix)action).isShouldBeAppliedToInjectionHost() == ThreeState.NO) {
+ final PsiElement at = injectedFile.findElementAt(injectedEditor.getCaretModel().getOffset());
+ final PsiElement container = ((SuppressIntentionActionFromFix)action).getContainer(at);
+ if (container != null) {
+ injectionHighlighter.highlight(container, Collections.singletonList(container));
+ }
+ }
+ else {
+ final PsiElement at = myFile.findElementAt(myEditor.getCaretModel().getOffset());
+ final PsiElement container = ((SuppressIntentionActionFromFix)action).getContainer(at);
+ if (container != null) {
+ highlighter.highlight(container, Collections.singletonList(container));
+ }
+ }
+ }
+ }
+ }
+ }
+ });
if (myEditor.isOneLineMode()) {
// hide popup on combobox popup show
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/IntentionListStep.java b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/IntentionListStep.java
index 0700b6e1e1b2..491508e2c7a8 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/IntentionListStep.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/IntentionListStep.java
@@ -27,6 +27,7 @@ import com.intellij.codeInsight.intention.impl.config.IntentionActionWrapper;
import com.intellij.codeInsight.intention.impl.config.IntentionManagerSettings;
import com.intellij.codeInspection.IntentionWrapper;
import com.intellij.codeInspection.LocalQuickFix;
+import com.intellij.codeInspection.SuppressIntentionActionFromFix;
import com.intellij.codeInspection.ex.QuickFixWrapper;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.application.ApplicationManager;
@@ -39,6 +40,7 @@ import com.intellij.openapi.util.Iconable;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
import com.intellij.psi.util.PsiUtilBase;
+import com.intellij.util.ThreeState;
import com.intellij.util.containers.ContainerUtil;
import gnu.trove.THashSet;
import gnu.trove.TObjectHashingStrategy;
@@ -321,6 +323,11 @@ class IntentionListStep implements ListPopupStep
if (a instanceof LowPriorityAction) {
return group - 3;
}
+ if (a instanceof SuppressIntentionActionFromFix) {
+ if (((SuppressIntentionActionFromFix)a).isShouldBeAppliedToInjectionHost() == ThreeState.NO) {
+ return group - 1;
+ }
+ }
if (a instanceof QuickFixWrapper) {
final LocalQuickFix quickFix = ((QuickFixWrapper)a).getFix();
if (quickFix instanceof HighPriorityAction) {
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/ShowIntentionActionsHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/ShowIntentionActionsHandler.java
index 8ddebd7c383f..31c1ecd533d1 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/ShowIntentionActionsHandler.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/ShowIntentionActionsHandler.java
@@ -27,6 +27,7 @@ import com.intellij.codeInsight.lookup.LookupEx;
import com.intellij.codeInsight.lookup.LookupManager;
import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
import com.intellij.codeInsight.template.impl.TemplateState;
+import com.intellij.codeInspection.SuppressIntentionActionFromFix;
import com.intellij.featureStatistics.FeatureUsageTracker;
import com.intellij.featureStatistics.FeatureUsageTrackerImpl;
import com.intellij.injected.editor.EditorWindow;
@@ -45,6 +46,7 @@ import com.intellij.psi.PsiFile;
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.PairProcessor;
+import com.intellij.util.ThreeState;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -107,6 +109,16 @@ public class ShowIntentionActionsHandler implements CodeInsightActionHandler {
private static boolean isAvailableHere(Editor editor, PsiFile psiFile, PsiElement psiElement, boolean inProject, IntentionAction action) {
try {
Project project = psiFile.getProject();
+ if (action instanceof SuppressIntentionActionFromFix) {
+ final ThreeState shouldBeAppliedToInjectionHost = ((SuppressIntentionActionFromFix)action).isShouldBeAppliedToInjectionHost();
+ if (editor instanceof EditorWindow && shouldBeAppliedToInjectionHost == ThreeState.YES) {
+ return false;
+ }
+ if (!(editor instanceof EditorWindow) && shouldBeAppliedToInjectionHost == ThreeState.NO) {
+ return false;
+ }
+ }
+
if (action instanceof PsiElementBaseIntentionAction) {
if (!inProject || psiElement == null || !((PsiElementBaseIntentionAction)action).isAvailable(project, editor, psiElement)) return false;
}
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java
index 21d9aedbb18b..05f813bc7dd1 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java
@@ -406,7 +406,7 @@ public class GlobalInspectionContextImpl extends GlobalInspectionContextBase imp
throw e;
}
catch (Throwable e) {
- LOG.error("In file: " + file, e);
+ LOG.error("In file: " + file.getName(), e);
}
finally {
InjectedLanguageManager.getInstance(getProject()).dropFileCaches(file);
diff --git a/platform/lang-impl/src/com/intellij/execution/console/RunIdeConsoleAction.java b/platform/lang-impl/src/com/intellij/execution/console/RunIdeConsoleAction.java
index be475d17559e..0d82da088444 100644
--- a/platform/lang-impl/src/com/intellij/execution/console/RunIdeConsoleAction.java
+++ b/platform/lang-impl/src/com/intellij/execution/console/RunIdeConsoleAction.java
@@ -19,20 +19,22 @@ import com.intellij.execution.ExecutionManager;
import com.intellij.execution.Executor;
import com.intellij.execution.executors.DefaultRunExecutor;
import com.intellij.execution.filters.TextConsoleBuilderFactory;
+import com.intellij.execution.impl.ConsoleViewImpl;
import com.intellij.execution.ui.ConsoleView;
import com.intellij.execution.ui.ConsoleViewContentType;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.execution.ui.actions.CloseAction;
import com.intellij.ide.scratch.ScratchFileService;
import com.intellij.openapi.actionSystem.*;
+import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.ex.util.EditorUtil;
import com.intellij.openapi.fileEditor.FileEditor;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.fileEditor.TextEditor;
-import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.TextRange;
@@ -45,6 +47,7 @@ import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import javax.script.ScriptContext;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineFactory;
import javax.script.ScriptEngineManager;
@@ -58,56 +61,70 @@ import java.util.Map;
/**
* @author gregsh
*/
-public class RunIdeConsoleAction extends ActionGroup implements DumbAware {
+public class RunIdeConsoleAction extends DumbAwareAction {
+ private static final String DEFAULT_FILE_NAME = "ide-scripting";
private static final Key> CONSOLE_VIEW_KEY = Key.create("CONSOLE_VIEW_KEY");
private static final Key HISTORY_CONTROLLER_KEY = Key.create("HISTORY_CONTROLLER_KEY");
- private static final Map ourEngines = ContainerUtil.newLinkedHashMap();
-
- static {
- for (ScriptEngineFactory factory : new ScriptEngineManager().getEngineFactories()) {
- ourEngines.put(factory.getLanguageName(), factory);
+ static class Engines {
+ static final Map ourEngines = ContainerUtil.newLinkedHashMap();
+ static {
+ for (ScriptEngineFactory factory : new ScriptEngineManager().getEngineFactories()) {
+ ourEngines.put(factory.getLanguageName(), factory);
+ }
}
}
@Override
public void update(AnActionEvent e) {
- boolean enabled = !ourEngines.isEmpty() && e.getProject() != null;
+ boolean enabled = !Engines.ourEngines.isEmpty() && e.getProject() != null;
e.getPresentation().setEnabledAndVisible(enabled);
}
- @NotNull
@Override
- public AnAction[] getChildren(@Nullable AnActionEvent e) {
- if (e == null) return EMPTY_ARRAY;
- return ContainerUtil.map2Array(ourEngines.values(), AnAction.class, new NotNullFunction() {
- @NotNull
- @Override
- public AnAction fun(final ScriptEngineFactory engine) {
- return new AnAction(engine.getLanguageName()) {
+ public void actionPerformed(AnActionEvent e) {
+ if (Engines.ourEngines.size() == 1) {
+ runConsole(e, Engines.ourEngines.values().iterator().next());
+ }
+ else {
+ DefaultActionGroup actions = new DefaultActionGroup(
+ ContainerUtil.map(Engines.ourEngines.values(), new NotNullFunction() {
+ @NotNull
@Override
- public void actionPerformed(@NotNull AnActionEvent e) {
- Project project = e.getProject();
- if (project == null) return;
- List extensions = engine.getExtensions();
- try {
- String pathName = PathUtil.makeFileName(engine.getLanguageName(), ContainerUtil.getFirstItem(extensions));
- VirtualFile virtualFile = IdeConsoleRootType.getInstance().findFile(project, pathName, ScratchFileService.Option.create_if_missing);
- if (virtualFile != null) {
- FileEditorManager.getInstance(project).openFile(virtualFile, true);
+ public AnAction fun(final ScriptEngineFactory engine) {
+ return new AnAction(engine.getLanguageName()) {
+ @Override
+ public void actionPerformed(@NotNull AnActionEvent e) {
+ runConsole(e, engine);
}
- }
- catch (IOException ignored) {
- }
+ };
}
- };
+ })
+ );
+ JBPopupFactory.getInstance().createActionGroupPopup("Script Engine", actions, e.getDataContext(), JBPopupFactory.ActionSelectionAid.NUMBERING, false).
+ showInBestPositionFor(e.getDataContext());
+ }
+ }
+
+ protected void runConsole(@NotNull AnActionEvent e, @NotNull ScriptEngineFactory engine) {
+ Project project = e.getProject();
+ if (project == null) return;
+ List extensions = engine.getExtensions();
+ try {
+ String pathName = PathUtil.makeFileName(DEFAULT_FILE_NAME, ContainerUtil.getFirstItem(extensions));
+ VirtualFile virtualFile = IdeConsoleRootType.getInstance().findFile(project, pathName, ScratchFileService.Option.create_if_missing);
+ if (virtualFile != null) {
+ FileEditorManager.getInstance(project).openFile(virtualFile, true);
}
- });
+ }
+ catch (IOException ignored) {
+ }
}
public static void configureConsole(@NotNull VirtualFile file, @NotNull FileEditorManager source) {
- ScriptEngine engine = createScriptEngine(file);
+ ScriptEngine engine = findScriptEngine(file);
+ if (engine == null) return;
//new ConsoleHistoryController(IdeConsoleRootType.getInstance(), engine.getFactory().getLanguageName())
MyRunAction runAction = new MyRunAction(engine);
for (FileEditor fileEditor : source.getEditors(file)) {
@@ -117,32 +134,47 @@ public class RunIdeConsoleAction extends ActionGroup implements DumbAware {
}
}
- @NotNull
- private static ScriptEngine createScriptEngine(VirtualFile file) {
- for (ScriptEngineFactory factory : ourEngines.values()) {
+ @Nullable
+ private static ScriptEngine findScriptEngine(@NotNull VirtualFile file) {
+ for (ScriptEngineFactory factory : Engines.ourEngines.values()) {
if (factory.getExtensions().contains(file.getExtension())) {
return factory.getScriptEngine();
}
}
- throw new AssertionError(file);
+ return null;
}
private static void executeQuery(@NotNull Project project,
@NotNull VirtualFile file,
@NotNull Editor editor,
@NotNull ScriptEngine engine) {
+
TextRange selectedRange = EditorUtil.getSelectionInAnyMode(editor);
- if (selectedRange.getLength() == 0) return;
- String command = editor.getDocument().getText(selectedRange);
- ConsoleView consoleView = getConsoleView(project, file, engine);
+ Document document = editor.getDocument();
+ if (selectedRange.getLength() == 0) {
+ int line = document.getLineNumber(selectedRange.getStartOffset());
+ selectedRange = TextRange.create(document.getLineStartOffset(line), document.getLineEndOffset(line));
+ }
+ String command = document.getText(selectedRange);
+ final ConsoleView consoleView = getConsoleView(project, file, engine);
try {
+ class IDE {
+ public void print(String s) {
+ consoleView.print(s + "\n", ConsoleViewContentType.NORMAL_OUTPUT);
+ }
+ public void error(String s) {
+ consoleView.print(s + "\n", ConsoleViewContentType.ERROR_OUTPUT);
+ }
+ }
+
// todo
//myHistoryController.getModel().addToHistory(command);
consoleView.print("> " + command, ConsoleViewContentType.USER_INPUT);
consoleView.print("\n", ConsoleViewContentType.USER_INPUT);
+ engine.getBindings(ScriptContext.ENGINE_SCOPE).put("IDE", new IDE());
Object o = engine.eval(command);
- String string = o == null ? "nil" : String.valueOf(o);
- consoleView.print(string, ConsoleViewContentType.NORMAL_OUTPUT);
+ consoleView.print("=> " + o, ConsoleViewContentType.NORMAL_OUTPUT);
+ consoleView.print("\n", ConsoleViewContentType.NORMAL_OUTPUT);
consoleView.print("\n", ConsoleViewContentType.NORMAL_OUTPUT);
}
catch (Exception e) {
@@ -150,6 +182,7 @@ public class RunIdeConsoleAction extends ActionGroup implements DumbAware {
//consoleView.print(ExceptionUtil.getThrowableText(e), ConsoleViewContentType.ERROR_OUTPUT);
consoleView.print("\n", ConsoleViewContentType.ERROR_OUTPUT);
}
+ ((ConsoleViewImpl)consoleView).scrollToEnd();
}
@NotNull
@@ -158,8 +191,6 @@ public class RunIdeConsoleAction extends ActionGroup implements DumbAware {
WeakReference ref = psiFile == null ? null : psiFile.getCopyableUserData(CONSOLE_VIEW_KEY);
ConsoleView existing = ref == null ? null : ref.get();
if (existing != null && !Disposer.isDisposed(existing)) return existing;
- //LanguageConsoleImpl console = new LanguageConsoleImpl(project, "", file, true);
- //ConsoleView consoleView = new LanguageConsoleViewImpl(console);
ConsoleView consoleView = TextConsoleBuilderFactory.getInstance().createBuilder(project).getConsole();
if (psiFile != null) psiFile.putCopyableUserData(CONSOLE_VIEW_KEY, new WeakReference(consoleView));
DefaultActionGroup toolbarActions = new DefaultActionGroup();
diff --git a/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java b/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java
index 9600cdd6c572..de55c96b7683 100644
--- a/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java
+++ b/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java
@@ -757,7 +757,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
}
private boolean isTheAmountOfTextTooBig(final int textLength) {
- return textLength > myBuffer.getCyclicBufferSize() / consoleTooMuchTextBufferRatio;
+ return myBuffer.isUseCyclicBuffer() && textLength > myBuffer.getCyclicBufferSize() / consoleTooMuchTextBufferRatio;
}
private void clearHyperlinkAndFoldings() {
diff --git a/platform/lang-impl/src/com/intellij/find/impl/FindDialog.java b/platform/lang-impl/src/com/intellij/find/impl/FindDialog.java
index 25f1e631ca9e..c984ab3d4576 100644
--- a/platform/lang-impl/src/com/intellij/find/impl/FindDialog.java
+++ b/platform/lang-impl/src/com/intellij/find/impl/FindDialog.java
@@ -379,6 +379,7 @@ public class FindDialog extends DialogWrapper {
@Override
public void run() {
model.addRow(new Object[]{usage});
+ if (model.getRowCount() == 1) myResultsPreviewTable.setRowSelectionInterval(0, 0);
}
}, state);
return resultsCount.incrementAndGet() < ShowUsagesAction.USAGES_PAGE_SIZE;
diff --git a/platform/lang-impl/src/com/intellij/ide/scratch/ScratchFileServiceImpl.java b/platform/lang-impl/src/com/intellij/ide/scratch/ScratchFileServiceImpl.java
index f6496810aea0..f792078c5a54 100644
--- a/platform/lang-impl/src/com/intellij/ide/scratch/ScratchFileServiceImpl.java
+++ b/platform/lang-impl/src/com/intellij/ide/scratch/ScratchFileServiceImpl.java
@@ -169,7 +169,7 @@ public abstract class ScratchFileServiceImpl extends ScratchFileService {
@Override
public Language getMapping(@Nullable VirtualFile file) {
Language language = super.getMapping(file);
- if (language == null && file != null && file.getFileType() == ScratchRootType.SCRATCH_FILE_TYPE) {
+ if (language == null && file != null && file.getFileType() == ScratchFileType.INSTANCE) {
String extension = file.getExtension();
FileType fileType = extension == null ? null : FileTypeManager.getInstance().getFileTypeByExtension(extension);
language = fileType instanceof LanguageFileType ? ((LanguageFileType)fileType).getLanguage() : null;
@@ -229,6 +229,14 @@ public abstract class ScratchFileServiceImpl extends ScratchFileService {
}
}
+ public static class TypeFactory extends FileTypeFactory {
+
+ @Override
+ public void createFileTypes(@NotNull FileTypeConsumer consumer) {
+ consumer.consume(ScratchFileType.INSTANCE);
+ }
+ }
+
public static class Substitutor extends LanguageSubstitutor {
@Nullable
@Override
@@ -275,7 +283,7 @@ public abstract class ScratchFileServiceImpl extends ScratchFileService {
@Override
public boolean isWritable(@NotNull VirtualFile file) {
- return ScratchFileService.getInstance().getRootType(file) != null;
+ return file.getFileType() == ScratchFileType.INSTANCE;
}
}
diff --git a/platform/lang-impl/src/com/intellij/ide/scratch/ScratchFileType.java b/platform/lang-impl/src/com/intellij/ide/scratch/ScratchFileType.java
new file mode 100644
index 000000000000..6a4f1c027b25
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/ide/scratch/ScratchFileType.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2000-2015 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.ide.scratch;
+
+import com.intellij.openapi.fileTypes.LanguageFileType;
+import com.intellij.openapi.fileTypes.PlainTextFileType;
+import com.intellij.openapi.fileTypes.PlainTextLanguage;
+import com.intellij.openapi.fileTypes.ex.FileTypeIdentifiableByVirtualFile;
+import com.intellij.openapi.vfs.VirtualFile;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+
+/**
+ * @author gregsh
+ */
+public class ScratchFileType extends LanguageFileType implements FileTypeIdentifiableByVirtualFile {
+
+ public static final LanguageFileType INSTANCE = new ScratchFileType();
+
+ ScratchFileType() {
+ super(PlainTextLanguage.INSTANCE);
+ }
+
+ @Override
+ public boolean isMyFileType(@NotNull VirtualFile file) {
+ return ScratchFileService.getInstance().getRootType(file) != null;
+ }
+
+ @NotNull
+ @Override
+ public String getName() {
+ return "Scratch";
+ }
+
+ @NotNull
+ @Override
+ public String getDescription() {
+ return "Scratch";
+ }
+
+ @NotNull
+ @Override
+ public String getDefaultExtension() {
+ return "";
+ }
+
+ @Nullable
+ @Override
+ public Icon getIcon() {
+ return PlainTextFileType.INSTANCE.getIcon();
+ }
+
+ @Override
+ public boolean isReadOnly() {
+ return true;
+ }
+
+ @Nullable
+ @Override
+ public String getCharset(@NotNull VirtualFile file, @NotNull byte[] content) {
+ return null;
+ }
+}
diff --git a/platform/lang-impl/src/com/intellij/ide/scratch/ScratchRootType.java b/platform/lang-impl/src/com/intellij/ide/scratch/ScratchRootType.java
index 937fee52279b..e128110c388b 100644
--- a/platform/lang-impl/src/com/intellij/ide/scratch/ScratchRootType.java
+++ b/platform/lang-impl/src/com/intellij/ide/scratch/ScratchRootType.java
@@ -18,8 +18,6 @@ package com.intellij.ide.scratch;
import com.intellij.icons.AllIcons;
import com.intellij.lang.Language;
import com.intellij.lang.PerFileMappings;
-import com.intellij.openapi.fileTypes.*;
-import com.intellij.openapi.fileTypes.ex.FileTypeIdentifiableByVirtualFile;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.LanguageSubstitutors;
@@ -35,8 +33,6 @@ import javax.swing.*;
*/
public final class ScratchRootType extends RootType {
- public static final LanguageFileType SCRATCH_FILE_TYPE = new MyFileType();
-
@NotNull
public static ScratchRootType getInstance() {
return findByClass(ScratchRootType.class);
@@ -50,69 +46,14 @@ public final class ScratchRootType extends RootType {
public Language substituteLanguage(@NotNull Project project, @NotNull VirtualFile file) {
PerFileMappings mapping = ScratchFileService.getInstance().getScratchesMapping();
Language language = mapping.getMapping(file);
- return language != null && language != SCRATCH_FILE_TYPE.getLanguage() ?
+ return language != null && language != ScratchFileType.INSTANCE.getLanguage() ?
LanguageSubstitutors.INSTANCE.substituteLanguage(language, file, project) : language;
}
@Nullable
@Override
public Icon substituteIcon(@NotNull Project project, @NotNull VirtualFile file) {
- Icon icon = ObjectUtils.chooseNotNull(super.substituteIcon(project, file), SCRATCH_FILE_TYPE.getIcon());
+ Icon icon = ObjectUtils.chooseNotNull(super.substituteIcon(project, file), ScratchFileType.INSTANCE.getIcon());
return LayeredIcon.create(icon, AllIcons.Actions.Scratch);
}
-
- public static class TypeFactory extends FileTypeFactory {
-
- @Override
- public void createFileTypes(@NotNull FileTypeConsumer consumer) {
- consumer.consume(SCRATCH_FILE_TYPE);
- }
- }
-
- private static class MyFileType extends LanguageFileType implements FileTypeIdentifiableByVirtualFile, InternalFileType {
-
- MyFileType() {
- super(PlainTextLanguage.INSTANCE);
- }
-
- @Override
- public boolean isMyFileType(@NotNull VirtualFile file) {
- return ScratchFileService.getInstance().getRootType(file) != null;
- }
-
- @NotNull
- @Override
- public String getName() {
- return "Scratch";
- }
-
- @NotNull
- @Override
- public String getDescription() {
- return "Scratch";
- }
-
- @NotNull
- @Override
- public String getDefaultExtension() {
- return "";
- }
-
- @Nullable
- @Override
- public Icon getIcon() {
- return PlainTextFileType.INSTANCE.getIcon();
- }
-
- @Override
- public boolean isReadOnly() {
- return true;
- }
-
- @Nullable
- @Override
- public String getCharset(@NotNull VirtualFile file, @NotNull byte[] content) {
- return null;
- }
- }
}
diff --git a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoActionModel.java b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoActionModel.java
index 84fb10920923..d2ffc12f2dfd 100644
--- a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoActionModel.java
+++ b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoActionModel.java
@@ -270,7 +270,7 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel, C
public static AnActionEvent updateActionBeforeShow(AnAction anAction, DataContext dataContext) {
final AnActionEvent event = new AnActionEvent(null, dataContext,
- ActionPlaces.UNKNOWN, new Presentation(), ActionManager.getInstance(),
+ ActionPlaces.ACTION_SEARCH, new Presentation(), ActionManager.getInstance(),
0);
ActionUtil.performDumbAwareUpdate(anAction, event, false);
ActionUtil.performDumbAwareUpdate(anAction, event, true);
diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProfileManagerImpl.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProfileManagerImpl.java
index 85838608509f..f0f1fb63e156 100644
--- a/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProfileManagerImpl.java
+++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProfileManagerImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -52,6 +52,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
+import javax.swing.*;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
@@ -145,11 +146,12 @@ public class InspectionProfileManagerImpl extends InspectionProfileManager imple
public static void registerProvidedSeverities() {
for (SeveritiesProvider provider : Extensions.getExtensions(SeveritiesProvider.EP_NAME)) {
- for (HighlightInfoType highlightInfoType : provider.getSeveritiesHighlightInfoTypes()) {
- HighlightSeverity highlightSeverity = highlightInfoType.getSeverity(null);
- SeverityRegistrar.registerStandard(highlightInfoType, highlightSeverity);
- TextAttributesKey attributesKey = highlightInfoType.getAttributesKey();
- HighlightDisplayLevel.registerSeverity(highlightSeverity, attributesKey);
+ for (HighlightInfoType t : provider.getSeveritiesHighlightInfoTypes()) {
+ HighlightSeverity highlightSeverity = t.getSeverity(null);
+ SeverityRegistrar.registerStandard(t, highlightSeverity);
+ TextAttributesKey attributesKey = t.getAttributesKey();
+ Icon icon = t instanceof HighlightInfoType.Iconable ? ((HighlightInfoType.Iconable)t).getIcon() : null;
+ HighlightDisplayLevel.registerSeverity(highlightSeverity, attributesKey, icon);
}
}
}
diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/PsiElementRenameHandler.java b/platform/lang-impl/src/com/intellij/refactoring/rename/PsiElementRenameHandler.java
index 3afbee098ac6..157a1282fcc3 100644
--- a/platform/lang-impl/src/com/intellij/refactoring/rename/PsiElementRenameHandler.java
+++ b/platform/lang-impl/src/com/intellij/refactoring/rename/PsiElementRenameHandler.java
@@ -17,6 +17,7 @@
package com.intellij.refactoring.rename;
import com.intellij.featureStatistics.FeatureUsageTracker;
+import com.intellij.ide.scratch.ScratchFileType;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.DataKey;
@@ -26,15 +27,18 @@ import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.ScrollType;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.extensions.Extensions;
+import com.intellij.openapi.fileEditor.impl.NonProjectFileWritingAccessProvider;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
import com.intellij.psi.meta.PsiMetaOwner;
import com.intellij.psi.meta.PsiWritableMetaData;
+import com.intellij.psi.util.PsiUtilCore;
import com.intellij.refactoring.RefactoringBundle;
import com.intellij.refactoring.actions.BaseRefactoringAction;
import com.intellij.refactoring.util.CommonRefactoringUtil;
@@ -88,8 +92,11 @@ public class PsiElementRenameHandler implements RenameHandler {
return;
}
+ VirtualFile contextFile = PsiUtilCore.getVirtualFile(nameSuggestionContext);
+
if (nameSuggestionContext != null &&
nameSuggestionContext.isPhysical() &&
+ (contextFile == null || contextFile.getFileType() != ScratchFileType.INSTANCE) &&
!PsiManager.getInstance(project).isInProject(nameSuggestionContext)) {
final String message = "Selected element is used from non-project files. These usages won't be renamed. Proceed anyway?";
if (ApplicationManager.getApplication().isUnitTestMode()) throw new CommonRefactoringUtil.RefactoringErrorHintException(message);
@@ -126,8 +133,11 @@ public class PsiElementRenameHandler implements RenameHandler {
if (!PsiManager.getInstance(project).isInProject(element)) {
if (element.isPhysical()) {
- final String message = RefactoringBundle.message("error.out.of.project.element", UsageViewUtil.getType(element));
- return RefactoringBundle.getCannotRefactorMessage(message);
+ VirtualFile virtualFile = PsiUtilCore.getVirtualFile(element);
+ if (!(virtualFile != null && NonProjectFileWritingAccessProvider.isWriteAccessAllowedExplicitly(virtualFile, project))) {
+ String message = RefactoringBundle.message("error.out.of.project.element", UsageViewUtil.getType(element));
+ return RefactoringBundle.getCannotRefactorMessage(message);
+ }
}
if (!element.isWritable()) {
diff --git a/platform/lvcs-impl/src/com/intellij/history/integration/ui/views/HistoryDialog.java b/platform/lvcs-impl/src/com/intellij/history/integration/ui/views/HistoryDialog.java
index 8cbace110527..24c7f1c66236 100644
--- a/platform/lvcs-impl/src/com/intellij/history/integration/ui/views/HistoryDialog.java
+++ b/platform/lvcs-impl/src/com/intellij/history/integration/ui/views/HistoryDialog.java
@@ -32,6 +32,7 @@ import com.intellij.ide.actions.ShowFilePathAction;
import com.intellij.ide.ui.SplitterProportionsDataImpl;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
+import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diff.DiffContent;
import com.intellij.openapi.diff.SimpleDiffRequest;
import com.intellij.openapi.help.HelpManager;
@@ -339,16 +340,21 @@ public abstract class HistoryDialog extends FrameW
final SimpleDiffRequest r = new SimpleDiffRequest(myProject, m.getTitle());
new Task.Modal(myProject, message("message.processing.revisions"), false) {
- public void run(@NotNull ProgressIndicator i) {
- RevisionProcessingProgressAdapter p = new RevisionProcessingProgressAdapter(i);
- p.processingLeftRevision();
- DiffContent left = m.getLeftDiffContent(p);
+ public void run(@NotNull final ProgressIndicator i) {
+ ApplicationManager.getApplication().runReadAction(new Runnable() {
+ @Override
+ public void run() {
+ RevisionProcessingProgressAdapter p = new RevisionProcessingProgressAdapter(i);
+ p.processingLeftRevision();
+ DiffContent left = m.getLeftDiffContent(p);
- p.processingRightRevision();
- DiffContent right = m.getRightDiffContent(p);
+ p.processingRightRevision();
+ DiffContent right = m.getRightDiffContent(p);
- r.setContents(left, right);
- r.setContentTitles(m.getLeftTitle(p), m.getRightTitle(p));
+ r.setContents(left, right);
+ r.setContentTitles(m.getLeftTitle(p), m.getRightTitle(p));
+ }
+ });
}
}.queue();
diff --git a/platform/platform-api/src/com/intellij/openapi/diff/DiffRequest.java b/platform/platform-api/src/com/intellij/openapi/diff/DiffRequest.java
index 2262948ae269..4bb6a45862fe 100644
--- a/platform/platform-api/src/com/intellij/openapi/diff/DiffRequest.java
+++ b/platform/platform-api/src/com/intellij/openapi/diff/DiffRequest.java
@@ -20,6 +20,7 @@ import com.intellij.openapi.actionSystem.IdeActions;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Factory;
import com.intellij.openapi.util.Pair;
+import com.intellij.util.SmartList;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -45,7 +46,7 @@ public abstract class DiffRequest {
protected DiffRequest(@Nullable Project project) {
myProject = project;
myGenericData = new HashMap(2);
- myAdditional = new ArrayList>(0);
+ myAdditional = new SmartList>();
}
public void setToolbarAddons(@NotNull ToolbarAddons toolbarAddons) {
diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/FileAttribute.java b/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/FileAttribute.java
index 3c775f5b2e8c..3277cfb920e1 100644
--- a/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/FileAttribute.java
+++ b/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/FileAttribute.java
@@ -21,6 +21,7 @@ package com.intellij.openapi.vfs.newvfs;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.VirtualFile;
+import gnu.trove.THashSet;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -28,15 +29,19 @@ import org.jetbrains.annotations.Nullable;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
-import java.util.HashSet;
import java.util.Set;
public class FileAttribute {
- private static final Set ourRegisteredIds = new HashSet();
+ private static final Set ourRegisteredIds = new THashSet();
+ private static final int UNDEFINED_VERSION = -1;
private final String myId;
private final int myVersion;
private final boolean myFixedSize;
+ public FileAttribute(@NonNls @NotNull String id) {
+ this(id, UNDEFINED_VERSION, false);
+ }
+
/**
* @deprecated
* @see #FileAttribute(String, int, boolean)
@@ -113,4 +118,8 @@ public class FileAttribute {
public int getVersion() {
return myVersion;
}
+
+ public boolean isVersioned() {
+ return myVersion != UNDEFINED_VERSION;
+ }
}
diff --git a/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java b/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java
index 3a3037930c85..309c698355d8 100644
--- a/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java
+++ b/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java
@@ -60,39 +60,40 @@ public class SimpleColoredComponent extends JComponent implements Accessible, Co
private final List myFragments;
private final List myAttributes;
private List