diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java index 3f0ecd3bb51d..aeda55d6c3f6 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java @@ -772,6 +772,7 @@ public abstract class DebugProcessImpl implements DebugProcess { myPositionManager = null; myReturnValueWatcher = null; myNodeRederersMap.clear(); + myRenderers.clear(); myState.set(STATE_DETACHED); try { myDebugProcessDispatcher.getMulticaster().processDetached(this, closedByUser); diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java index d2a350e0d918..95a4eca5463a 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java @@ -27,7 +27,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.IndexNotReadyException; import com.intellij.openapi.project.Project; import com.intellij.openapi.projectRoots.JavaSdkVersion; -import com.intellij.openapi.projectRoots.JavaSdkVersionUtil; +import com.intellij.openapi.projectRoots.JavaVersionService; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.TextRange; import com.intellij.pom.java.LanguageLevel; @@ -509,7 +509,8 @@ public class GenericsHighlightUtil { final PsiType retErasure2 = TypeConversionUtil.erasure(superMethod.getReturnType()); boolean differentReturnTypeErasure = !Comparing.equal(retErasure1, retErasure2); - if (checkEqualsSuper && JavaSdkVersionUtil.isAtLeast(checkMethod, JavaSdkVersion.JDK_1_7)) { + final boolean atLeast17 = JavaVersionService.getInstance().isAtLeast(checkMethod, JavaSdkVersion.JDK_1_7); + if (checkEqualsSuper && atLeast17) { if (retErasure1 != null && retErasure2 != null) { differentReturnTypeErasure = !TypeConversionUtil.isAssignable(retErasure1, retErasure2); } else { @@ -520,8 +521,17 @@ public class GenericsHighlightUtil { if (differentReturnTypeErasure && !TypeConversionUtil.isVoidType(retErasure1) && !TypeConversionUtil.isVoidType(retErasure2) && - !(checkEqualsSuper && Arrays.equals(superSignature.getParameterTypes(), signatureToCheck.getParameterTypes()))) { - return null; + !(checkEqualsSuper && Arrays.equals(superSignature.getParameterTypes(), signatureToCheck.getParameterTypes())) && + !atLeast17) { + int idx = 0; + final PsiType[] parameterTypes = signatureToCheck.getParameterTypes(); + boolean erasure = parameterTypes.length > 0; + for (PsiType type : superSignature.getParameterTypes()) { + erasure &= Comparing.equal(type, TypeConversionUtil.erasure(parameterTypes[idx])); + idx++; + } + + if (!erasure) return null; } if (!checkEqualsSuper && MethodSignatureUtil.isSubsignature(superSignature, signatureToCheck)) { diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFixBase.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFixBase.java index 240c852bd404..4304af0384cb 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFixBase.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFixBase.java @@ -30,6 +30,7 @@ import com.intellij.codeInsight.hint.QuestionAction; import com.intellij.codeInsight.intention.HighPriorityAction; import com.intellij.codeInspection.HintAction; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.impl.LaterInvocator; import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; @@ -67,13 +68,7 @@ public abstract class ImportClassFixBase im return false; } PsiManager manager = file.getManager(); - if (!manager.isInProject(file)) { - return false; - } - if (getClassesToImport().isEmpty()) { - return false; - } - return true; + return manager.isInProject(file) && !getClassesToImport().isEmpty(); } @Nullable @@ -188,6 +183,7 @@ public abstract class ImportClassFixBase im CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY) && (ApplicationManager.getApplication().isUnitTestMode() || codeAnalyzer.canChangeFileSilently(psiFile)) && !autoImportWillInsertUnexpectedCharacters(classes[0]) + && !LaterInvocator.isInModalContext() ) { CommandProcessor.getInstance().runUndoTransparentAction(new Runnable() { @Override diff --git a/java/java-impl/src/com/intellij/codeInspection/dependencyViolation/DependencyInspection.java b/java/java-impl/src/com/intellij/codeInspection/dependencyViolation/DependencyInspection.java index 0f8874d86549..83d937f9393e 100644 --- a/java/java-impl/src/com/intellij/codeInspection/dependencyViolation/DependencyInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/dependencyViolation/DependencyInspection.java @@ -40,7 +40,6 @@ import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.text.MessageFormat; import java.util.ArrayList; /** diff --git a/java/java-impl/src/com/intellij/codeInspection/ex/EntryPointsManagerImpl.java b/java/java-impl/src/com/intellij/codeInspection/ex/EntryPointsManagerImpl.java index 9797dc6e7b12..9e194b30253c 100644 --- a/java/java-impl/src/com/intellij/codeInspection/ex/EntryPointsManagerImpl.java +++ b/java/java-impl/src/com/intellij/codeInspection/ex/EntryPointsManagerImpl.java @@ -192,6 +192,7 @@ public class EntryPointsManagerImpl implements PersistentStateComponent public void resolveEntryPoints(final RefManager manager) { if (!myResolved) { myResolved = true; + cleanup(); validateEntryPoints(); ApplicationManager.getApplication().runReadAction(new Runnable() { diff --git a/java/java-impl/src/com/intellij/openapi/projectRoots/JavaVersionServiceImpl.java b/java/java-impl/src/com/intellij/openapi/projectRoots/JavaVersionServiceImpl.java index 366a0b870404..b1bba82602b5 100644 --- a/java/java-impl/src/com/intellij/openapi/projectRoots/JavaVersionServiceImpl.java +++ b/java/java-impl/src/com/intellij/openapi/projectRoots/JavaVersionServiceImpl.java @@ -15,6 +15,7 @@ */ package com.intellij.openapi.projectRoots; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.psi.PsiElement; /** @@ -22,8 +23,15 @@ import com.intellij.psi.PsiElement; * Date: 3/28/12 */ public class JavaVersionServiceImpl extends JavaVersionService { + private boolean myTestVersion = false; + + public void setTestVersion(boolean testVersion) { + myTestVersion = testVersion; + } + @Override public boolean isAtLeast(PsiElement element, JavaSdkVersion version) { + if (ApplicationManager.getApplication().isUnitTestMode()) return myTestVersion; return JavaSdkVersionUtil.isAtLeast(element, version); } } diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiImplUtil.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiImplUtil.java index d4dcd96dd43f..4849ba75312c 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiImplUtil.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiImplUtil.java @@ -131,6 +131,8 @@ public class PsiImplUtil { } public static int getParameterIndex(@NotNull PsiParameter parameter, @NotNull PsiParameterList parameterList) { + PsiElement parameterParent = parameter.getParent(); + assert parameterParent == parameterList : parameterList +"; "+parameterParent; PsiParameter[] parameters = parameterList.getParameters(); for (int i = 0; i < parameters.length; i++) { PsiParameter paramInList = parameters[i]; @@ -146,9 +148,8 @@ public class PsiImplUtil { break; } } - String message = parameter + ":"+parameter.getClass()+" not found among parameters: " + Arrays.asList(parameters) + "." + + String message = parameter + ":" + parameter.getClass() + " not found among parameters: " + Arrays.asList(parameters) + "." + " parameterList' parent: " + parameterList.getParent() + ";" + - " parameter.getParent()==paramList: " + (parameter.getParent() == parameterList) + "; " + parameterList.getClass() + ";" + " parameter.isValid()=" + parameter.isValid() + ";" + " parameterList.isValid()= " + parameterList.isValid() + ";" + " parameterList stub: " + (parameterList instanceof StubBasedPsiElement ? ((StubBasedPsiElement)parameterList).getStub() : "---") + "; " + diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA66311.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA66311.java new file mode 100644 index 000000000000..d67ac65edd9f --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA66311.java @@ -0,0 +1,21 @@ +import java.util.*; + +class ErasureTest { + public static double[] toArrayDouble(List v) { + return null; + } + + public static double[][] toArrayDouble(List v) { + return null; + } +} + +class ErasureTest1 { + public static double[] toArrayDouble(List v) { + return null; + } + + public static double[][] toArrayDouble(List v) { + return null; + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA66311_16.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA66311_16.java new file mode 100644 index 000000000000..db7abdc9fef7 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA66311_16.java @@ -0,0 +1,31 @@ +import java.util.*; + +class ErasureTest { + public static double[] toArrayDouble(List v) { + return null; + } + + public static double[][] toArrayDouble(List v) { + return null; + } +} + +class ErasureTest1 { + public static double[] toArrayDouble(List v) { + return null; + } + + public static double[][] toArrayDouble(List v) { + return null; + } +} + +class ErasureTest2 { + public static double[] toArrayDouble(List v) { + return null; + } + + public static double[] toArrayDouble(List v) { + return null; + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeParameterBoundVisibility.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeParameterBoundVisibility.java index 406efc451e3d..f93f67b83582 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeParameterBoundVisibility.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeParameterBoundVisibility.java @@ -15,3 +15,27 @@ abstract class Foo> { return t.field; } } + +public class Bug { + // Idea incorrectly analyses this code with JDK 7 + public void doit(T other) { + // Oops, was legal with JDK 6, no longer legal with JDK 7 + other.mPrivate(); + // Redundant with JDK 6, not a redundant cast with JDK 7 + ((Bug)other).mPrivate(); + } + + // Idea correctly analyses this code + public void doit2(SubClass other) { + // Not legal with JDK 6 or 7 + other.mPrivate(); + // Not redundant with JDK 6 or 7 + ((Bug)other).mPrivate(); + } + + private void mPrivate() { + } +} + +class SubClass extends Bug { +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeParameterBoundVisibilityJdk14.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeParameterBoundVisibilityJdk14.java index ce2e57ded675..df04ee7de906 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeParameterBoundVisibilityJdk14.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeParameterBoundVisibilityJdk14.java @@ -6,4 +6,28 @@ class A { System.out.println(t.value); } } +} + +public class Bug { + // Idea incorrectly analyses this code with JDK 7 + public void doit(T other) { + // Oops, was legal with JDK 6, no longer legal with JDK 7 + other.mPrivate(); + // Redundant with JDK 6, not a redundant cast with JDK 7 + ((Bug)other).mPrivate(); + } + + // Idea correctly analyses this code + public void doit2(SubClass other) { + // Not legal with JDK 6 or 7 + other.mPrivate(); + // Not redundant with JDK 6 or 7 + ((Bug)other).mPrivate(); + } + + private void mPrivate() { + } +} + +class SubClass extends Bug { } \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java index 7d767cf5c083..4471d00c1e30 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java @@ -4,6 +4,8 @@ import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection; import com.intellij.codeInspection.unusedImport.UnusedImportLocalInspection; import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection; +import com.intellij.openapi.projectRoots.JavaVersionService; +import com.intellij.openapi.projectRoots.JavaVersionServiceImpl; import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.projectRoots.impl.JavaSdkImpl; import com.intellij.openapi.roots.LanguageLevelProjectExtension; @@ -100,7 +102,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase { public void testSOE() throws Exception { doTest(true); } public void testGenericExtendException() throws Exception { doTest(false); } - public void testSameErasureDifferentReturnTypes() throws Exception { doTest(false); } + public void testSameErasureDifferentReturnTypes() throws Exception { doTest17Incompatibility(); } public void testSameErasureDifferentReturnTypesJdk14() throws Exception { doTest(false); } public void testDeepConflictingReturnTypes() throws Exception { doTest(false); } public void testInheritFromTypeParameter() throws Exception { doTest(false); } @@ -116,13 +118,16 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase { public void testPrivateInnerClassRef() throws Exception { doTest(false); } public void testWideningCastToTypeParam() throws Exception { doTest(false); } public void testCapturedWildcardAssignments() throws Exception { doTest(false);} - public void testTypeParameterBoundVisibility() throws Exception { doTest(false);} + public void testTypeParameterBoundVisibility() throws Exception { doTest17Incompatibility(); } public void testTypeParameterBoundVisibilityJdk14() throws Exception { doTest(false);} public void testUncheckedWarningsLevel6() throws Exception { doTest(true);} public void testIDEA77991() throws Exception { doTest(false);} public void testIDEA80386() throws Exception { doTest(false);} + public void testIDEA66311() throws Exception { doTest17Incompatibility();} + public void testIDEA66311_16() throws Exception { doTest(false);} + public void testJavaUtilCollections_NoVerify() throws Exception { PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule())); @@ -132,4 +137,15 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase { configureFromFileText("Collections.java", text.replaceAll("\r","\n")); doTestConfiguredFile(false, false, null); } + + private void doTest17Incompatibility() throws Exception { + final JavaVersionServiceImpl javaVersionService = (JavaVersionServiceImpl)JavaVersionService.getInstance(); + try { + javaVersionService.setTestVersion(true); + doTest(false); + } + finally { + javaVersionService.setTestVersion(false); + } + } } diff --git a/java/openapi/src/com/intellij/psi/util/PropertyUtil.java b/java/openapi/src/com/intellij/psi/util/PropertyUtil.java index 89b7159f9554..bccea7b55699 100644 --- a/java/openapi/src/com/intellij/psi/util/PropertyUtil.java +++ b/java/openapi/src/com/intellij/psi/util/PropertyUtil.java @@ -388,7 +388,7 @@ public class PropertyUtil { return ArrayUtil.toStringArray(result); } - public static PsiMethod generateGetterPrototype(PsiField field) { + public static PsiMethod generateGetterPrototype(@NotNull PsiField field) { PsiElementFactory factory = JavaPsiFacade.getInstance(field.getProject()).getElementFactory(); Project project = field.getProject(); String name = field.getName(); diff --git a/jps/model/src/org/jetbrains/ether/dependencyView/Mappings.java b/jps/model/src/org/jetbrains/ether/dependencyView/Mappings.java index 985ad7d5bf86..427496953f08 100644 --- a/jps/model/src/org/jetbrains/ether/dependencyView/Mappings.java +++ b/jps/model/src/org/jetbrains/ether/dependencyView/Mappings.java @@ -43,8 +43,17 @@ public class Mappings { private final TIntHashSet myChangedClasses; private final TIntHashSet myChangedFiles; + private final TIntHashSet myDeletedClasses; private final Object myLock; + private void addDeletedClass (final int it) { + assert (myDeletedClasses != null); + + myDeletedClasses.add(it); + + addChangedClass(it); + } + private void addChangedClass(final int it) { assert (myChangedClasses != null && myChangedFiles != null); myChangedClasses.add(it); @@ -58,6 +67,10 @@ public class Mappings { myIsDifferentiated = true; } + private TIntHashSet getDeletedClasses() { + return myDeletedClasses; + } + private TIntHashSet getChangedClasses() { return myChangedClasses; } @@ -129,6 +142,7 @@ public class Mappings { myPostPasses = new LinkedList(); myChangedClasses = new TIntHashSet(DEFAULT_SET_CAPACITY, DEFAULT_SET_LOAD_FACTOR); myChangedFiles = new TIntHashSet(DEFAULT_SET_CAPACITY, DEFAULT_SET_LOAD_FACTOR); + myDeletedClasses = new TIntHashSet(DEFAULT_SET_CAPACITY, DEFAULT_SET_LOAD_FACTOR); myDeltaIsTransient = base.myDeltaIsTransient; myRootDir = new File(FileUtil.toSystemIndependentName(base.myRootDir.getAbsolutePath()) + File.separatorChar + "delta"); myContext = base.myContext; @@ -144,6 +158,7 @@ public class Mappings { myPostPasses = new LinkedList(); myChangedClasses = null; myChangedFiles = null; + myDeletedClasses = null; myDeltaIsTransient = transientDelta; myRootDir = rootDir; createImplementation(); @@ -918,7 +933,7 @@ public class Mappings { } }); - for (FileClasses compiledFile : newClasses) { + for (final FileClasses compiledFile : newClasses) { final int fileName = compiledFile.fileName; final Set classes = compiledFile.fileClasses; final Set pastClasses = (Set)mySourceFileToClasses.get(fileName); @@ -931,7 +946,7 @@ public class Mappings { final Difference.Specifier classDiff = Difference.make(pastClasses, classes); debug("Processing changed classes:"); - for (Pair changed : classDiff.changed()) { + for (final Pair changed : classDiff.changed()) { final ClassRepr it = changed.first; final ClassRepr.Diff diff = (ClassRepr.Diff)changed.second; @@ -1024,7 +1039,7 @@ public class Mappings { .createAnnotationUsage(myContext, TypeRepr.createClassType(myContext, it.name), null, removedtargets)); } - for (MethodRepr m : diff.methods().added()) { + for (final MethodRepr m : diff.methods().added()) { if (!m.hasValue()) { debug("Added method with no default value: ", m.name); debug("Adding class usage to affected usages"); @@ -1079,7 +1094,7 @@ public class Mappings { final Collection lessSpecific = it.findMethods(u.lessSpecific(m)); - for (MethodRepr mm : lessSpecific) { + for (final MethodRepr mm : lessSpecific) { if (!mm.equals(m)) { debug("Found less specific method, affecting method usages"); u.affectMethodUsages(mm, propagated, mm.createUsage(myContext, it.name), affectedUsages, dependants); @@ -1087,7 +1102,7 @@ public class Mappings { } debug("Processing affected by specificity methods"); - for (Pair p : affectedMethods) { + for (final Pair p : affectedMethods) { final MethodRepr mm = p.first; final ClassRepr cc = p.second; @@ -1183,7 +1198,7 @@ public class Mappings { boolean clear = true; loop: - for (Pair overriden : overridenMethods) { + for (final Pair overriden : overridenMethods) { final MethodRepr mm = overriden.first; if (mm == myMockMethod || !mm.type.equals(m.type) || !empty(mm.signature) || !empty(m.signature)) { @@ -1219,7 +1234,7 @@ public class Mappings { boolean allAbstract = true; boolean visited = false; - for (Pair pp : overridenInS) { + for (final Pair pp : overridenInS) { final ClassRepr cc = pp.second; if (cc == myMockClass) { @@ -1259,7 +1274,7 @@ public class Mappings { debug("End of removed methods processing"); debug("Processing changed methods:"); - for (Pair mr : diff.methods().changed()) { + for (final Pair mr : diff.methods().changed()) { final MethodRepr m = mr.first; final MethodRepr.Diff d = (MethodRepr.Diff)mr.second; final boolean throwsChanged = (d.exceptions().added().size() > 0) || (d.exceptions().changed().size() > 0); @@ -1286,7 +1301,7 @@ public class Mappings { debug("Method became package-local, affecting method usages outside the package"); u.affectMethodUsages(m, propagated, m.createUsage(myContext, it.name), usages, dependants); - for (UsageRepr.Usage usage : usages) { + for (final UsageRepr.Usage usage : usages) { usageConstraints.put(usage, u.new InheritanceConstraint(it.name)); } @@ -1333,7 +1348,7 @@ public class Mappings { affectedUsages.addAll(usages); } - for (UsageRepr.Usage usage : usages) { + for (final UsageRepr.Usage usage : usages) { usageConstraints.put(usage, u.new InheritanceConstraint(it.name)); } } @@ -1396,7 +1411,7 @@ public class Mappings { final Collection> overridden = u.findOverridenFields(f, it); - for (Pair p : overridden) { + for (final Pair p : overridden) { final FieldRepr ff = p.first; final ClassRepr cc = p.second; @@ -1429,7 +1444,7 @@ public class Mappings { u.new NegationConstraint(u.new PackageConstraint(cc.getPackageName()))); } - for (UsageRepr.Usage usage : localUsages) { + for (final UsageRepr.Usage usage : localUsages) { usageConstraints.put(usage, constaint); } } @@ -1441,7 +1456,7 @@ public class Mappings { debug("End of added fields processing"); debug("Processing removed fields:"); - for (FieldRepr f : diff.fields().removed()) { + for (final FieldRepr f : diff.fields().removed()) { debug("Field: ", f.name); if ((f.access & Opcodes.ACC_PRIVATE) == 0 && (f.access & mask) == mask && f.hasValue()) { @@ -1458,7 +1473,7 @@ public class Mappings { debug("End of removed fields processing"); debug("Processing changed fields:"); - for (Pair f : diff.fields().changed()) { + for (final Pair f : diff.fields().changed()) { final Difference d = f.second; final FieldRepr field = f.first; @@ -1507,7 +1522,7 @@ public class Mappings { affectedUsages.addAll(usages); } - for (UsageRepr.Usage usage : usages) { + for (final UsageRepr.Usage usage : usages) { if ((d.addedModifiers() & Opcodes.ACC_PROTECTED) > 0) { usageConstraints.put(usage, u.new InheritanceConstraint(it.name)); } @@ -1525,8 +1540,8 @@ public class Mappings { debug("End of changed classes processing"); debug("Processing removed classes:"); - for (ClassRepr c : classDiff.removed()) { - delta.addChangedClass(c.name); + for (final ClassRepr c : classDiff.removed()) { + delta.addDeletedClass(c.name); self.appendDependents(c, dependants); debug("Adding usages of class ", c.name); affectedUsages.add(c.createUsage()); @@ -1534,7 +1549,7 @@ public class Mappings { debug("End of removed classes processing."); debug("Processing added classes:"); - for (ClassRepr c : classDiff.added()) { + for (final ClassRepr c : classDiff.added()) { delta.addChangedClass(c.name); final TIntHashSet depClasses = myClassToClassDependency.get(c.name); @@ -1573,7 +1588,7 @@ public class Mappings { filewise: - for (int depFile : dependentFiles.toArray()) { // todo: avoid toArray()? + for (final int depFile : dependentFiles.toArray()) { // todo: avoid toArray()? final File theFile = new File(myContext.getValue(depFile)); if (affectedFiles.contains(theFile) || compiledFiles.contains(theFile)) { @@ -1583,7 +1598,7 @@ public class Mappings { debug("Dependent file: ", depFile); final Collection depClusters = mySourceFileToUsages.get(depFile); if (depClusters != null) { - for (UsageRepr.Cluster depCluster : depClusters) { + for (final UsageRepr.Cluster depCluster : depClusters) { final Set depUsages = depCluster.getUsages(); if (depUsages == null) { continue; @@ -1603,7 +1618,7 @@ public class Mappings { } else { final TIntHashSet residenceClasses = depCluster.getResidence(usage); - for (int residentName : residenceClasses.toArray()) { + for (final int residentName : residenceClasses.toArray()) { if (constraint.checkResidence(residentName)) { debug("Added file with satisfied constraint"); affectedFiles.add(theFile); @@ -1617,8 +1632,8 @@ public class Mappings { if (annotationQuery.size() > 0) { final Collection annotationUsages = mySourceFileToAnnotationUsages.get(depFile); - for (UsageRepr.Usage usage : annotationUsages) { - for (UsageRepr.AnnotationUsage query : annotationQuery) { + for (final UsageRepr.Usage usage : annotationUsages) { + for (final UsageRepr.AnnotationUsage query : annotationQuery) { if (query.satisfies(usage)) { debug("Added file due to annotation query"); affectedFiles.add(theFile); @@ -1633,7 +1648,7 @@ public class Mappings { } if (removed != null) { - for (String r : removed) { + for (final String r : removed) { affectedFiles.remove(new File(r)); } } @@ -1649,26 +1664,26 @@ public class Mappings { delta.runPostPasses(); if (removed != null) { - for (String file : removed) { + for (final String file : removed) { final int key = myContext.get(file); final Set classes = (Set)mySourceFileToClasses.get(key); final Collection clusters = mySourceFileToUsages.get(key); if (classes != null) { - for (ClassRepr cr : classes) { + for (final ClassRepr cr : classes) { myClassToSubclasses.remove(cr.name); myClassToSourceFile.remove(cr.name); myClassToClassDependency.remove(cr.name); - for (int superSomething : cr.getSupers()) { + for (final int superSomething : cr.getSupers()) { myClassToSubclasses.removeFrom(superSomething, cr.name); } if (clusters != null) { - for (UsageRepr.Cluster cluster : clusters) { + for (final UsageRepr.Cluster cluster : clusters) { final Set usages = cluster.getUsages(); if (usages != null) { - for (UsageRepr.Usage u : usages) { + for (final UsageRepr.Usage u : usages) { if (u instanceof UsageRepr.ClassUsage) { final TIntHashSet residents = cluster.getResidence(u); @@ -1690,6 +1705,16 @@ public class Mappings { } if (delta.isDifferentiated()) { + delta.getDeletedClasses().forEach(new TIntProcedure() { + @Override + public boolean execute(int value) { + myClassToClassDependency.remove(value); + myClassToSubclasses.remove(value); + myClassToSourceFile.remove(value); + return true; + } + }); + delta.getChangedClasses().forEach(new TIntProcedure() { @Override public boolean execute(int c) { @@ -1795,11 +1820,11 @@ public class Mappings { private int[] getClassNames(Collection compiled) { final TIntHashSet classnames = new TIntHashSet(compiled.size()); - for (File c : compiled) { + for (final File c : compiled) { final int fileName = myContext.get(FileUtil.toSystemIndependentName(c.getAbsolutePath())); final Collection reprs = mySourceFileToClasses.get(fileName); if (reprs != null) { - for (ClassRepr repr : reprs) { + for (final ClassRepr repr : reprs) { classnames.add(repr.name); } } @@ -1843,11 +1868,11 @@ public class Mappings { myClassToSourceFile.put(repr.name, sourceFileNameS); mySourceFileToClasses.put(sourceFileNameS, repr); - for (int s : repr.getSupers()) { + for (final int s : repr.getSupers()) { myClassToSubclasses.put(s, repr.name); } - for (UsageRepr.Usage u : localUsages.getUsages()) { + for (final UsageRepr.Usage u : localUsages.getUsages()) { final int owner = u.getOwner(); if (owner != className) { @@ -1883,7 +1908,7 @@ public class Mappings { @Override public void registerImports(final String className, final Collection imports, Collection staticImports) { - for (String s : staticImports) { + for (final String s : staticImports) { int i = s.length() - 1; for (; s.charAt(i) != '.'; i--) ; imports.add(s.substring(0, i)); @@ -1982,6 +2007,4 @@ public class Mappings { }); return changed.get(); } - - } diff --git a/platform/core-impl/src/com/intellij/psi/impl/DebugUtil.java b/platform/core-impl/src/com/intellij/psi/impl/DebugUtil.java index c8cb5460e197..36eb4d7feaa9 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/DebugUtil.java +++ b/platform/core-impl/src/com/intellij/psi/impl/DebugUtil.java @@ -27,7 +27,6 @@ import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.UserDataHolderBase; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiLock; import com.intellij.psi.PsiWhiteSpace; import com.intellij.psi.TokenType; import com.intellij.psi.impl.source.SourceTreeToPsiMap; @@ -77,7 +76,7 @@ public class DebugUtil { } public static /*final*/ boolean CHECK = false; - public static final boolean DO_EXPENSIVE_CHECKS = ApplicationManager.getApplication().isInternal() || ApplicationManager.getApplication().isUnitTestMode(); + public static final boolean DO_EXPENSIVE_CHECKS = ApplicationManager.getApplication().isUnitTestMode(); public static final boolean CHECK_INSIDE_ATOMIC_ACTION_ENABLED = DO_EXPENSIVE_CHECKS; public static String psiTreeToString(@NotNull final PsiElement element, final boolean skipWhitespaces) { @@ -333,9 +332,7 @@ public class DebugUtil { root = root.getTreeParent(); } if (root instanceof CompositeElement) { - synchronized (PsiLock.LOCK) { - checkSubtree((CompositeElement)root); - } + checkSubtree((CompositeElement)root); } } diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/text/BlockSupportImpl.java b/platform/core-impl/src/com/intellij/psi/impl/source/text/BlockSupportImpl.java index 14ce9c6860c1..53419feb35f6 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/source/text/BlockSupportImpl.java +++ b/platform/core-impl/src/com/intellij/psi/impl/source/text/BlockSupportImpl.java @@ -190,9 +190,8 @@ public class BlockSupportImpl extends BlockSupport { final PsiFileImpl newFile = (PsiFileImpl)copy.getPsi(language); if (newFile == null) { - LOG.error("View provider " + viewProvider + " refused to parse text with " + language + + throw new RuntimeException("View provider " + viewProvider + " refused to parse text with " + language + "; base: " + viewProvider.getBaseLanguage() + "; copy: " + copy.getBaseLanguage() + "; fileType: " + fileType); - return null; } newFile.setOriginalFile(fileImpl); diff --git a/platform/lang-impl/src/com/intellij/find/impl/FindInProjectUtil.java b/platform/lang-impl/src/com/intellij/find/impl/FindInProjectUtil.java index 4d6a8a80cd70..e073957689ed 100644 --- a/platform/lang-impl/src/com/intellij/find/impl/FindInProjectUtil.java +++ b/platform/lang-impl/src/com/intellij/find/impl/FindInProjectUtil.java @@ -457,7 +457,7 @@ public class FindInProjectUtil { return (GlobalSearchScope)scope; } if (scope == null) { - return GlobalSearchScope.projectScope(project); + return projectContentScope(project); } Set files = new HashSet(); for (PsiElement element : ((LocalSearchScope)scope).getScope()) { @@ -554,6 +554,15 @@ public class FindInProjectUtil { return new Pair>(fast, resultFiles); } + private static GlobalSearchScope projectContentScope(final Project project) { + GlobalSearchScope result = null; + for (Module module : ModuleManager.getInstance(project).getModules()) { + GlobalSearchScope moduleContent = moduleContentScope(module); + result = result == null ? moduleContent : result.uniteWith(moduleContent); + } + return result == null ? GlobalSearchScope.EMPTY_SCOPE : result; + } + @Nullable private static GlobalSearchScope moduleContentScope(@NotNull final Module module) { VirtualFile[] contentRoots = ModuleRootManager.getInstance(module).getContentRoots(); @@ -566,10 +575,7 @@ public class FindInProjectUtil { result = result == null ? moduleContent : result.uniteWith(moduleContent); } } - if (result == null) { - result = GlobalSearchScope.EMPTY_SCOPE; - } - return result; + return result == null ? GlobalSearchScope.EMPTY_SCOPE : result; } private static void filterMaskedFiles(@NotNull final Set resultFiles, @Nullable final Pattern fileMaskRegExp) { diff --git a/platform/lang-impl/src/com/intellij/packageDependencies/ui/FileNode.java b/platform/lang-impl/src/com/intellij/packageDependencies/ui/FileNode.java index 623ed98483dc..7ce75860b780 100644 --- a/platform/lang-impl/src/com/intellij/packageDependencies/ui/FileNode.java +++ b/platform/lang-impl/src/com/intellij/packageDependencies/ui/FileNode.java @@ -44,7 +44,10 @@ public class FileNode extends PackageDependenciesNode implements Comparable set, boolean recursively) { super.fillFiles(set, recursively); - set.add(getFile()); + final PsiFile file = getFile(); + if (file != null && file.isValid()) { + set.add(file); + } } public boolean hasUnmarked() { diff --git a/platform/lang-impl/src/com/intellij/packageDependencies/ui/ProjectPatternProvider.java b/platform/lang-impl/src/com/intellij/packageDependencies/ui/ProjectPatternProvider.java index 7c263449c640..5933d377590e 100644 --- a/platform/lang-impl/src/com/intellij/packageDependencies/ui/ProjectPatternProvider.java +++ b/platform/lang-impl/src/com/intellij/packageDependencies/ui/ProjectPatternProvider.java @@ -105,6 +105,7 @@ public class ProjectPatternProvider extends PatternDialectProvider { if (recursively) return null; FileNode fNode = (FileNode)node; final PsiFile file = (PsiFile)fNode.getPsiElement(); + if (file == null) return null; final VirtualFile virtualFile = file.getVirtualFile(); LOG.assertTrue(virtualFile != null); final VirtualFile contentRoot = ProjectRootManager.getInstance(file.getProject()).getFileIndex().getContentRootForFile(virtualFile); diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageManagerImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageManagerImpl.java index 0fbc6ce60b8f..2f1c8dd29e84 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageManagerImpl.java @@ -188,7 +188,7 @@ public class InjectedLanguageManagerImpl extends InjectedLanguageManager impleme if (Thread.holdsLock(PsiLock.LOCK)) { // hack for the case when docCommit was called from within PSI modification, e.g. in formatter. // we can't spawn threads to do injections there, otherwise a deadlock is imminent - ContainerUtil.process(injected, commitProcessor); + ContainerUtil.process(new ArrayList(injected), commitProcessor); } else { commitInjectionsRunnable.run(); diff --git a/platform/lang-impl/src/com/intellij/refactoring/move/moveFilesOrDirectories/MoveFilesOrDirectoriesHandler.java b/platform/lang-impl/src/com/intellij/refactoring/move/moveFilesOrDirectories/MoveFilesOrDirectoriesHandler.java index 5970e028411f..7c74b3522101 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/move/moveFilesOrDirectories/MoveFilesOrDirectoriesHandler.java +++ b/platform/lang-impl/src/com/intellij/refactoring/move/moveFilesOrDirectories/MoveFilesOrDirectoriesHandler.java @@ -70,7 +70,7 @@ public class MoveFilesOrDirectoriesHandler extends MoveHandlerDelegate { } public void doMove(final Project project, final PsiElement[] elements, final PsiElement targetContainer, @Nullable final MoveCallback callback) { - if (!LOG.assertTrue(targetContainer == null || targetContainer instanceof PsiDirectory || targetContainer instanceof PsiDirectoryContainer)) { + if (!LOG.assertTrue(targetContainer == null || targetContainer instanceof PsiDirectory || targetContainer instanceof PsiDirectoryContainer, targetContainer)) { return; } MoveFilesOrDirectoriesUtil.doMove(project, adjustForMove(project, elements, targetContainer), new PsiElement[] {targetContainer}, callback); diff --git a/java/openapi/src/com/intellij/lang/StdLanguages.java b/platform/platform-api/src/com/intellij/lang/StdLanguages.java similarity index 100% rename from java/openapi/src/com/intellij/lang/StdLanguages.java rename to platform/platform-api/src/com/intellij/lang/StdLanguages.java index e03adddd793b..cac0badb8f36 100644 --- a/java/openapi/src/com/intellij/lang/StdLanguages.java +++ b/platform/platform-api/src/com/intellij/lang/StdLanguages.java @@ -15,8 +15,8 @@ */ package com.intellij.lang; -import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.fileTypes.FileTypes; +import com.intellij.openapi.fileTypes.StdFileTypes; /** * Defines the standard languages supported by IDEA. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/colors/EditorColorsManager.java b/platform/platform-api/src/com/intellij/openapi/editor/colors/EditorColorsManager.java index 037df73d11ff..c7db5a6b3df0 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/colors/EditorColorsManager.java +++ b/platform/platform-api/src/com/intellij/openapi/editor/colors/EditorColorsManager.java @@ -35,6 +35,7 @@ public abstract class EditorColorsManager { public abstract void setGlobalScheme(EditorColorsScheme scheme); + @NotNull public abstract EditorColorsScheme getGlobalScheme(); public abstract EditorColorsScheme getScheme(@NonNls String schemeName); diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsManagerImpl.java index 4a27a07a35a5..ba744d6cea9f 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsManagerImpl.java @@ -289,10 +289,12 @@ public class EditorColorsManagerImpl extends EditorColorsManager implements Name fireChanges(scheme); } + @NotNull private static DefaultColorsScheme getDefaultScheme() { return DefaultColorSchemesManager.getInstance().getAllSchemes()[0]; } + @NotNull @Override public EditorColorsScheme getGlobalScheme() { final EditorColorsScheme scheme = mySchemesManager.getCurrentScheme(); diff --git a/platform/util/src/com/intellij/util/concurrency/AtomicFieldUpdater.java b/platform/util/src/com/intellij/util/concurrency/AtomicFieldUpdater.java index 81ff40283392..18f6a0443b8b 100644 --- a/platform/util/src/com/intellij/util/concurrency/AtomicFieldUpdater.java +++ b/platform/util/src/com/intellij/util/concurrency/AtomicFieldUpdater.java @@ -32,7 +32,7 @@ public class AtomicFieldUpdater { private static final Unsafe unsafe = getUnsafe(); @NotNull - private static Unsafe getUnsafe() { + public static Unsafe getUnsafe() { Unsafe unsafe = null; Class uc = Unsafe.class; try { @@ -69,6 +69,9 @@ public class AtomicFieldUpdater { Field[] declaredFields = ownerClass.getDeclaredFields(); Field found = null; for (Field field : declaredFields) { + if ((field.getModifiers() & (Modifier.STATIC | Modifier.FINAL)) != 0) { + continue; + } if (fieldType.isAssignableFrom(field.getType())) { if (found == null) { found = field; @@ -79,15 +82,12 @@ public class AtomicFieldUpdater { } } if (found == null) { - throw new IllegalArgumentException("No field of "+fieldType+" found in the "+ownerClass); + throw new IllegalArgumentException("No (non-static, non-final) field of "+fieldType+" found in the "+ownerClass); } found.setAccessible(true); if ((found.getModifiers() & Modifier.VOLATILE) == 0) { throw new IllegalArgumentException("Field "+found+" in the "+ownerClass+" must be volatile"); } - if ((found.getModifiers() & (Modifier.STATIC | Modifier.FINAL)) != 0) { - throw new IllegalArgumentException("Field "+found+" in the "+ownerClass+" must be non-final non-static"); - } offset = unsafe.objectFieldOffset(found); } diff --git a/platform/util/src/com/intellij/util/containers/StripedLockIntObjectConcurrentHashMap.java b/platform/util/src/com/intellij/util/containers/StripedLockIntObjectConcurrentHashMap.java index e394ebb02ea1..a862b2a8b782 100644 --- a/platform/util/src/com/intellij/util/containers/StripedLockIntObjectConcurrentHashMap.java +++ b/platform/util/src/com/intellij/util/containers/StripedLockIntObjectConcurrentHashMap.java @@ -16,6 +16,9 @@ package com.intellij.util.containers; +import gnu.trove.THashSet; +import org.jetbrains.annotations.NotNull; + import java.util.*; /** similar to java.util.ConcurrentHashMap except: @@ -27,14 +30,14 @@ import java.util.*; added hashing strategy argument made not Serializable */ -public class StripedLockIntObjectConcurrentHashMap extends IntSegment { +public class StripedLockIntObjectConcurrentHashMap { /* ---------------- Constants -------------- */ /** * The default initial number of table slots for this table. * Used when not otherwise specified in constructor. */ - static int DEFAULT_INITIAL_CAPACITY = 16; + private static final int DEFAULT_INITIAL_CAPACITY = 16; /** * The maximum capacity, used if a higher value is implicitly @@ -42,13 +45,13 @@ public class StripedLockIntObjectConcurrentHashMap extends IntSegment { * be a power of two <= 1<<30 to ensure that entries are indexible * using ints. */ - static final int MAXIMUM_CAPACITY = 1 << 30; + private static final int MAXIMUM_CAPACITY = 1 << 30; /** * The default load factor for this table. Used when not * otherwise specified in constructor. */ - public static final float DEFAULT_LOAD_FACTOR = 0.75f; + protected static final float DEFAULT_LOAD_FACTOR = 0.75f; /* ---------------- Fields -------------- */ @@ -74,7 +77,8 @@ public class StripedLockIntObjectConcurrentHashMap extends IntSegment { * nonpositive. */ public StripedLockIntObjectConcurrentHashMap(int initialCapacity, float loadFactor) { - super(getInitCap(initialCapacity, loadFactor), loadFactor); + int cap = getInitCap(initialCapacity, loadFactor); + setTable(new IntHashEntry[cap]); } private static int getInitCap(int initialCapacity, float loadFactor) { @@ -141,10 +145,7 @@ public class StripedLockIntObjectConcurrentHashMap extends IntSegment { * @throws NullPointerException if the key or value is * null. */ - public V put(int key, V value) { - if (value == null) { - throw new NullPointerException(); - } + public V put(int key, @NotNull V value) { return put(key, value, false); } @@ -167,10 +168,7 @@ public class StripedLockIntObjectConcurrentHashMap extends IntSegment { * @throws NullPointerException if the specified key or value is * null. */ - public V putIfAbsent(int key, V value) { - if (value == null) { - throw new NullPointerException(); - } + public V putIfAbsent(int key, @NotNull V value) { return put(key, value, true); } @@ -205,23 +203,21 @@ public class StripedLockIntObjectConcurrentHashMap extends IntSegment { * Returns an enumeration of the values in this table. * * @return an enumeration of the values in this table. - * @see #values */ + @NotNull public Enumeration elements() { return new ValueIterator(); } /* ---------------- Iterator Support -------------- */ - abstract class HashIterator { - int nextSegmentIndex; - int nextTableIndex; - IntHashEntry[] currentTable; - IntHashEntry nextEntry; - IntHashEntry lastReturned; + private class HashIterator { + private int nextTableIndex; + private IntHashEntry[] currentTable; + private IntHashEntry nextEntry; + private IntHashEntry lastReturned; - HashIterator() { - nextSegmentIndex = 0; + private HashIterator() { nextTableIndex = -1; advance(); } @@ -230,7 +226,7 @@ public class StripedLockIntObjectConcurrentHashMap extends IntSegment { return hasNext(); } - final void advance() { + private void advance() { if (nextEntry != null && (nextEntry = nextEntry.next) != null) { return; } @@ -241,16 +237,13 @@ public class StripedLockIntObjectConcurrentHashMap extends IntSegment { } } - while (nextSegmentIndex >= 0) { - IntSegment seg = StripedLockIntObjectConcurrentHashMap.this; - nextSegmentIndex--; - if (seg.count != 0) { - currentTable = seg.table; - for (int j = currentTable.length - 1; j >= 0; --j) { - if ((nextEntry = (IntHashEntry)currentTable[j]) != null) { - nextTableIndex = j - 1; - return; - } + StripedLockIntObjectConcurrentHashMap seg = StripedLockIntObjectConcurrentHashMap.this; + if (seg.count != 0) { + currentTable = seg.table; + for (int j = currentTable.length - 1; j >= 0; --j) { + if ((nextEntry = (IntHashEntry)currentTable[j]) != null) { + nextTableIndex = j - 1; + return; } } } @@ -260,7 +253,7 @@ public class StripedLockIntObjectConcurrentHashMap extends IntSegment { return nextEntry != null; } - IntHashEntry nextEntry() { + protected IntHashEntry nextEntry() { if (nextEntry == null) { throw new NoSuchElementException(); } @@ -278,84 +271,60 @@ public class StripedLockIntObjectConcurrentHashMap extends IntSegment { } } - final class ValueIterator extends HashIterator implements Iterator, Enumeration { + private final class ValueIterator extends HashIterator implements Iterator, Enumeration { + @Override public V next() { return nextEntry().value; } + @Override public V nextElement() { return nextEntry().value; } } - interface IntEntry { + public interface IntEntry { int getKey(); - V getValue(); - V setValue(V value); + @NotNull V getValue(); } - final class Values extends AbstractCollection { - public Iterator iterator() { - return new ValueIterator(); - } - - public int size() { - return StripedLockIntObjectConcurrentHashMap.this.size(); - } - - public boolean contains(Object o) { - return containsValue(o); - } - - public void clear() { - StripedLockIntObjectConcurrentHashMap.this.clear(); - } - - public Object[] toArray() { - Collection c = new ArrayList(); - for (V k : this) { - c.add(k); - } - return c.toArray(); - } - - public T[] toArray(T[] a) { - Collection c = new ArrayList(); - for (V k : this) { - c.add(k); - } - return c.toArray(a); + public Collection> entries() { + HashIterator iterator = new HashIterator(); + Set> result = new THashSet>(); + while (iterator.hasNext()) { + IntHashEntry ie = iterator.nextEntry; + SimpleEntry entry = new SimpleEntry(ie.key, ie.value); + result.add(entry); } + return result; } /** * This duplicates java.util.AbstractMap.SimpleEntry until this class * is made accessible. */ - static final class SimpleEntry implements IntEntry { - int key; - V value; + private static final class SimpleEntry implements IntEntry { + private final int key; + private final V value; - public SimpleEntry(IntEntry e) { - key = e.getKey(); - value = e.getValue(); + private SimpleEntry(int key, @NotNull V value) { + this.key = key; + this.value = value; } + @Override public int getKey() { return key; } + @Override + @NotNull public V getValue() { return value; } - public V setValue(V value) { - V oldValue = this.value; - this.value = value; - return oldValue; - } - + @Override public boolean equals(Object o) { if (!(o instanceof SimpleEntry)) { return false; @@ -365,30 +334,31 @@ public class StripedLockIntObjectConcurrentHashMap extends IntSegment { return key == o2 && eq(value, e.getValue()); } + @Override public int hashCode() { return key ^ (value == null ? 0 : value.hashCode()); } + @Override public String toString() { return key + "=" + value; } - boolean eq(Object o1, Object o2) { + private static boolean eq(Object o1, Object o2) { return o1 == null ? o2 == null : o1.equals(o2); } } -} -class IntSegment { + private static final StripedReentrantLocks STRIPED_REENTRANT_LOCKS = StripedReentrantLocks.getInstance(); private final byte lockIndex = (byte)STRIPED_REENTRANT_LOCKS.allocateLockIndex(); - public void lock() { + private void lock() { STRIPED_REENTRANT_LOCKS.lock(lockIndex & 0xff); } - public void unlock() { + private void unlock() { STRIPED_REENTRANT_LOCKS.unlock(lockIndex & 0xff); } /* @@ -431,7 +401,7 @@ class IntSegment { /** * The number of elements in this segment's region. */ - volatile int count; + protected volatile int count; /** * Number of updates that alter the size of the table. This is @@ -441,47 +411,33 @@ class IntSegment { * we might have an inconsistent view of state so (usually) * must retry. */ - int modCount; + protected int modCount; /** * The table is rehashed when its size exceeds this threshold. */ - int threshold() { - return (int)(table.length * loadFactor); + private int threshold() { + return (int)(table.length * StripedLockIntObjectConcurrentHashMap.DEFAULT_LOAD_FACTOR); } /** * The per-segment table. Declared as a raw type, casted * to IntHashEntry on each use. */ - volatile IntHashEntry[] table; - - /** - * The load factor for the hash table. Even though this value - * is same for all segments, it is replicated to avoid needing - * links to outer object. - * - * @serial - */ - final float loadFactor; - - IntSegment(int initialCapacity, float lf) { - loadFactor = lf; - setTable(new IntHashEntry[initialCapacity]); - } + protected volatile IntHashEntry[] table; /** * Set table to new IntHashEntry array. * Call only while holding lock or in constructor. */ - void setTable(IntHashEntry[] newTable) { + private void setTable(IntHashEntry[] newTable) { table = newTable; } /** * Return properly casted first entry of bin for given hash */ - IntHashEntry getFirst(int hash) { + private IntHashEntry getFirst(int hash) { IntHashEntry[] tab = table; return tab[hash & tab.length - 1]; } @@ -493,7 +449,7 @@ class IntSegment { * its table assignment, which is legal under memory model * but is not known to ever occur. */ - V readValueUnderLock(IntHashEntry e) { + private V readValueUnderLock(IntHashEntry e) { lock(); try { return e.value; @@ -535,32 +491,7 @@ class IntSegment { return false; } - public boolean containsValue(Object value) { - if (count != 0) { // read-volatile - IntHashEntry[] tab = table; - int len = tab.length; - for (int i = 0; i < len; i++) { - for (IntHashEntry e = tab[i]; - e != null; - e = e.next) { - V v = e.value; - if (v == null) // recheck - { - v = readValueUnderLock(e); - } - if (value.equals(v)) { - return true; - } - } - } - } - return false; - } - - public boolean replace(int key, V oldValue, V newValue) { - if (oldValue == null || newValue == null) { - throw new NullPointerException(); - } + public boolean replace(int key, @NotNull V oldValue, @NotNull V newValue) { lock(); try { IntHashEntry e = getFirst(key); @@ -580,31 +511,7 @@ class IntSegment { } } - public V replace(int key, V newValue) { - if (newValue == null) { - throw new NullPointerException(); - } - lock(); - try { - IntHashEntry e = getFirst(key); - while (e != null && !(key == e.key)) { - e = e.next; - } - - V oldValue = null; - if (e != null) { - oldValue = e.value; - e.value = newValue; - } - return oldValue; - } - finally { - unlock(); - } - } - - - V put(int key, V value, boolean onlyIfAbsent) { + protected V put(int key, @NotNull V value, boolean onlyIfAbsent) { lock(); try { int c = count; @@ -640,10 +547,10 @@ class IntSegment { } } - void rehash() { + private void rehash() { IntHashEntry[] oldTable = table; int oldCapacity = oldTable.length; - if (oldCapacity >= StripedLockConcurrentHashMap.MAXIMUM_CAPACITY) { + if (oldCapacity >= MAXIMUM_CAPACITY) { return; } @@ -696,8 +603,7 @@ class IntSegment { for (IntHashEntry p = e; p != lastRun; p = p.next) { int k = p.key & sizeMask; IntHashEntry n = newTable[k]; - newTable[k] = new IntHashEntry(p.key, - n, p.value); + newTable[k] = new IntHashEntry(p.key, n, p.value); } } } @@ -708,7 +614,7 @@ class IntSegment { /** * Remove; match on key only if value null, else match both. */ - public V remove(int key, Object value) { + protected V remove(int key, Object value) { lock(); try { int c = count - 1; @@ -731,8 +637,7 @@ class IntSegment { ++modCount; IntHashEntry newFirst = e.next; for (IntHashEntry p = first; p != e; p = p.next) { - newFirst = new IntHashEntry(p.key, - newFirst, p.value); + newFirst = new IntHashEntry(p.key, newFirst, p.value); } tab[index] = newFirst; count = c; // write-volatile @@ -761,28 +666,37 @@ class IntSegment { } } } -} -/** - * ConcurrentHashMap list entry. Note that this is never exported - * out as a user-visible Map.Entry. - *

- * Because the value field is volatile, not final, it is legal wrt - * the Java Memory Model for an unsynchronized reader to see null - * instead of initial value when read via a data race. Although a - * reordering leading to this is not likely to ever actually - * occur, the Segment.readValueUnderLock method is used as a - * backup in case a null (pre-initialized) value is ever seen in - * an unsynchronized access method. - */ -final class IntHashEntry { - final int key; - volatile V value; - final IntHashEntry next; + public void putAll(@NotNull StripedLockIntObjectConcurrentHashMap t) { + for (IntEntry e : t.entries()) { + V value = e.getValue(); + put(e.getKey(), value); + } + } - IntHashEntry(int key, IntHashEntry next, V value) { - this.key = key; - this.next = next; - this.value = value; + + + /** + * ConcurrentHashMap list entry. Note that this is never exported + * out as a user-visible Map.Entry. + *

+ * Because the value field is volatile, not final, it is legal wrt + * the Java Memory Model for an unsynchronized reader to see null + * instead of initial value when read via a data race. Although a + * reordering leading to this is not likely to ever actually + * occur, the Segment.readValueUnderLock method is used as a + * backup in case a null (pre-initialized) value is ever seen in + * an unsynchronized access method. + */ + private static final class IntHashEntry { + final int key; + @NotNull volatile V value; + final IntHashEntry next; + + IntHashEntry(int key, IntHashEntry next, @NotNull V value) { + this.key = key; + this.next = next; + this.value = value; + } } } diff --git a/plugins/android-designer/src/com/intellij/android/designer/designSurface/AndroidDesignerEditorPanel.java b/plugins/android-designer/src/com/intellij/android/designer/designSurface/AndroidDesignerEditorPanel.java index ad495bb8cf80..3a43efa2225b 100644 --- a/plugins/android-designer/src/com/intellij/android/designer/designSurface/AndroidDesignerEditorPanel.java +++ b/plugins/android-designer/src/com/intellij/android/designer/designSurface/AndroidDesignerEditorPanel.java @@ -35,6 +35,7 @@ import com.intellij.designer.designSurface.tools.ComponentPasteFactory; import com.intellij.designer.model.RadComponent; import com.intellij.designer.palette.Item; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.ex.ApplicationManagerEx; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Computable; @@ -43,6 +44,7 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiManager; import com.intellij.psi.xml.XmlFile; +import com.intellij.util.Alarm; import com.intellij.util.ThrowableRunnable; import org.jetbrains.android.facet.AndroidFacet; import org.jetbrains.android.sdk.AndroidPlatform; @@ -63,9 +65,10 @@ public final class AndroidDesignerEditorPanel extends DesignerEditorPanel { private final XmlFile myXmlFile; private final ExternalPSIChangeListener myPSIChangeListener; private final ProfileAction myProfileAction; - private int myProfileLastVersion; + private final Alarm mySessionAlarm = new Alarm(); private volatile RenderSession mySession; private boolean myParseTime; + private int myProfileLastVersion; public AndroidDesignerEditorPanel(@NotNull Module module, @NotNull VirtualFile file) { super(module, file); @@ -264,31 +267,24 @@ public final class AndroidDesignerEditorPanel extends DesignerEditorPanel { } private void createRenderer(final String layoutXmlText, final ThrowableRunnable runnable) { - if (mySession == null) { - ApplicationManager.getApplication().invokeLater( - new Runnable() { - @Override - public void run() { - if (mySession == null) { - showProgress("Create RenderLib"); - } - } - }, new Condition() { - @Override - public boolean value(Object o) { - return mySession != null; - } - } - ); - } - else { + if (mySession != null) { disposeSession(); } + mySessionAlarm.addRequest(new Runnable() { + @Override + public void run() { + if (mySession == null) { + showProgress("Create RenderLib"); + } + } + }, 500); ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { @Override public void run() { try { + long time = System.currentTimeMillis(); + myProfileLastVersion = myProfileAction.getVersion(); AndroidPlatform platform = AndroidPlatform.getInstance(myModule); @@ -332,6 +328,11 @@ public final class AndroidDesignerEditorPanel extends DesignerEditorPanel { } } + if (ApplicationManagerEx.getApplicationEx().isInternal()) { + System.out.println("Render time: " + (System.currentTimeMillis() - time)); + } + mySessionAlarm.cancelAllRequests(); + ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { @@ -355,6 +356,9 @@ public final class AndroidDesignerEditorPanel extends DesignerEditorPanel { } }); } + finally { + mySessionAlarm.cancelAllRequests(); + } } }); } diff --git a/plugins/android/resources/messages/AndroidBundle.properties b/plugins/android/resources/messages/AndroidBundle.properties index 1538759af6aa..6a859976f2aa 100644 --- a/plugins/android/resources/messages/AndroidBundle.properties +++ b/plugins/android/resources/messages/AndroidBundle.properties @@ -317,7 +317,7 @@ android.lint.inspections.add.android.prefix=Add Android prefix android.lint.inspections.replace.with.zero.dp=Replace size attribute with 0dp android.lint.inspections.set.baseline.attribute=Set 'baselineAligned' attribute android.lint.inspections.remove.attribute=Remove attribute -android.lint.inspections.convert.to.dp=Convert to \\"dp\\"... +android.lint.inspections.convert.to.dp=Convert to \"dp\"... android.lint.inspections.set.to.wrap.content=Replace size attribute with 'wrap_content' android.lint.inspections.add.permission.attribute=Add 'permission' attribute android.lint.inspections.add.input.type.attribute=Add 'inputType' attribute @@ -403,4 +403,5 @@ android.disable.adb.service.title=Disable ADB service android.launch.hierarchy.viewer.action=Hierarchy Viewer android.launch.draw.9.patch.action=Draw 9 Patch android.facet.settings.include.system.proguard=Include system proguard file -file.already.exists.error=File {0} already exists \ No newline at end of file +file.already.exists.error=File {0} already exists +deployment.target.settings.min.sdk.info.message=Min API level is set to {0} in AndroidManifest.xml. Only compatible AVDs are shown \ No newline at end of file diff --git a/plugins/android/src/org/jetbrains/android/actions/CreateXmlResourceDialog.java b/plugins/android/src/org/jetbrains/android/actions/CreateXmlResourceDialog.java index edcb31fb12c9..c452763c43e8 100644 --- a/plugins/android/src/org/jetbrains/android/actions/CreateXmlResourceDialog.java +++ b/plugins/android/src/org/jetbrains/android/actions/CreateXmlResourceDialog.java @@ -281,6 +281,10 @@ public class CreateXmlResourceDialog extends DialogWrapper { if (newSelectedIndex >= 0) { myDirectoriesList.setSelectedIndex(newSelectedIndex); } + + if (checkBoxList.size() == 1) { + checkBoxList.get(0).setSelected(true); + } } @Override diff --git a/plugins/android/src/org/jetbrains/android/dom/converters/ResourceReferenceConverter.java b/plugins/android/src/org/jetbrains/android/dom/converters/ResourceReferenceConverter.java index d02dcee87ddd..30f6d2608222 100644 --- a/plugins/android/src/org/jetbrains/android/dom/converters/ResourceReferenceConverter.java +++ b/plugins/android/src/org/jetbrains/android/dom/converters/ResourceReferenceConverter.java @@ -314,6 +314,10 @@ public class ResourceReferenceConverter extends ResolvingConverter value, PsiElement element, ConvertContext context) { + if ("@null".equals(value.getStringValue())) { + return PsiReference.EMPTY_ARRAY; + } + Module module = context.getModule(); if (module != null) { AndroidFacet facet = AndroidFacet.getInstance(module); diff --git a/plugins/android/src/org/jetbrains/android/dom/drawable/AndroidDrawableDomUtil.java b/plugins/android/src/org/jetbrains/android/dom/drawable/AndroidDrawableDomUtil.java index f71c06983e48..898f5ad629d7 100644 --- a/plugins/android/src/org/jetbrains/android/dom/drawable/AndroidDrawableDomUtil.java +++ b/plugins/android/src/org/jetbrains/android/dom/drawable/AndroidDrawableDomUtil.java @@ -30,7 +30,8 @@ import java.util.Map; public class AndroidDrawableDomUtil { public static final Map SPECIAL_STYLEABLE_NAMES = new HashMap(); private static final String[] POSSIBLE_DRAWABLE_ROOTS = - new String[]{"selector", "bitmap", "nine-patch", "layer-list", "level-list", "transition", "inset", "clip", "scale", "shape"}; + new String[]{"selector", "bitmap", "nine-patch", "layer-list", "level-list", "transition", "inset", "clip", "scale", "shape", + "animation-list", "animated-rotate"}; static { SPECIAL_STYLEABLE_NAMES.put("selector", "StateListDrawable"); @@ -41,6 +42,7 @@ public class AndroidDrawableDomUtil { SPECIAL_STYLEABLE_NAMES.put("clip", "ClipDrawable"); SPECIAL_STYLEABLE_NAMES.put("scale", "ScaleDrawable"); SPECIAL_STYLEABLE_NAMES.put("animation-list", "AnimationDrawable"); + SPECIAL_STYLEABLE_NAMES.put("animated-rotate", "AnimatedRotateDrawable"); SPECIAL_STYLEABLE_NAMES.put("shape", "GradientDrawable"); SPECIAL_STYLEABLE_NAMES.put("corners", "DrawableCorners"); diff --git a/plugins/android/src/org/jetbrains/android/dom/drawable/InsetOrClipOrScaleDomFileDescription.java b/plugins/android/src/org/jetbrains/android/dom/drawable/InsetOrClipOrScaleDomFileDescription.java index d87e25d3056a..f2ca48fc1200 100644 --- a/plugins/android/src/org/jetbrains/android/dom/drawable/InsetOrClipOrScaleDomFileDescription.java +++ b/plugins/android/src/org/jetbrains/android/dom/drawable/InsetOrClipOrScaleDomFileDescription.java @@ -29,7 +29,7 @@ import org.jetbrains.annotations.Nullable; */ public class InsetOrClipOrScaleDomFileDescription extends AndroidResourceDomFileDescription { - @NonNls private static final String[] ROOT_TAGS = new String[] {"inset", "clip", "scale"}; + @NonNls private static final String[] ROOT_TAGS = new String[] {"inset", "clip", "scale", "animated-rotate"}; public InsetOrClipOrScaleDomFileDescription() { super(InsetOrClipOrScale.class, ROOT_TAGS[0], "drawable"); diff --git a/plugins/android/src/org/jetbrains/android/dom/drawable/ListItemBase.java b/plugins/android/src/org/jetbrains/android/dom/drawable/ListItemBase.java index 2678a7c45560..b1a2834f7352 100644 --- a/plugins/android/src/org/jetbrains/android/dom/drawable/ListItemBase.java +++ b/plugins/android/src/org/jetbrains/android/dom/drawable/ListItemBase.java @@ -27,4 +27,6 @@ public interface ListItemBase extends DrawableDomElement { List getScales(); List getInsets(); + + List getAnimatedRotates(); } diff --git a/plugins/android/src/org/jetbrains/android/exportSignedPackage/ApkStep.java b/plugins/android/src/org/jetbrains/android/exportSignedPackage/ApkStep.java index 54a7aec23702..b1934e9d23b8 100644 --- a/plugins/android/src/org/jetbrains/android/exportSignedPackage/ApkStep.java +++ b/plugins/android/src/org/jetbrains/android/exportSignedPackage/ApkStep.java @@ -349,7 +349,7 @@ class ApkStep extends ExportSignedPackageWizardStep { } @Override - protected void commitForNext() throws CommitStepException { + public void _commit(boolean finishChosen) throws CommitStepException { final String apkPath = myApkPathField.getText().trim(); if (apkPath.length() == 0) { throw new CommitStepException(AndroidBundle.message("android.extract.package.specify.apk.path.error")); @@ -378,7 +378,7 @@ class ApkStep extends ExportSignedPackageWizardStep { AndroidCompileUtil.setReleaseBuild(compileScope); properties.setValue(RUN_PROGUARD_PROPERTY, Boolean.toString(myProguardCheckBox.isSelected())); - + if (myProguardCheckBox.isSelected()) { final String proguardCfgPath = myProguardConfigFilePathField.getText().trim(); if (proguardCfgPath.length() == 0) { @@ -386,11 +386,11 @@ class ApkStep extends ExportSignedPackageWizardStep { } properties.setValue(PROGUARD_CFG_PATH_PROPERTY, proguardCfgPath); properties.setValue(INCLUDE_SYSTEM_PROGUARD_FILE_PROPERTY, Boolean.toString(myIncludeSystemProguardFileCheckBox.isSelected())); - + if (!new File(proguardCfgPath).isFile()) { throw new CommitStepException("Cannot find file " + proguardCfgPath); } - + compileScope.putUserData(AndroidProguardCompiler.PROGUARD_CFG_PATH_KEY, proguardCfgPath); compileScope.putUserData(AndroidProguardCompiler.INCLUDE_SYSTEM_PROGUARD_FILE, myIncludeSystemProguardFileCheckBox.isSelected()); } @@ -410,4 +410,8 @@ class ApkStep extends ExportSignedPackageWizardStep { } }); } + + @Override + protected void commitForNext() throws CommitStepException { + } } diff --git a/plugins/android/src/org/jetbrains/android/run/AndroidRunConfigurationEditor.form b/plugins/android/src/org/jetbrains/android/run/AndroidRunConfigurationEditor.form index 07bf420c713a..2d077d43deed 100644 --- a/plugins/android/src/org/jetbrains/android/run/AndroidRunConfigurationEditor.form +++ b/plugins/android/src/org/jetbrains/android/run/AndroidRunConfigurationEditor.form @@ -65,7 +65,7 @@ - + @@ -102,7 +102,7 @@ - + @@ -116,6 +116,14 @@ + + + + + + + + diff --git a/plugins/android/src/org/jetbrains/android/run/AndroidRunConfigurationEditor.java b/plugins/android/src/org/jetbrains/android/run/AndroidRunConfigurationEditor.java index 4c24b71a6a4b..01c91556d885 100644 --- a/plugins/android/src/org/jetbrains/android/run/AndroidRunConfigurationEditor.java +++ b/plugins/android/src/org/jetbrains/android/run/AndroidRunConfigurationEditor.java @@ -24,10 +24,14 @@ import com.intellij.openapi.options.SettingsEditor; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.LabeledComponent; import com.intellij.openapi.util.Disposer; +import com.intellij.openapi.util.IconLoader; +import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.PanelWithAnchor; import com.intellij.ui.RawCommandLineEditor; import com.intellij.ui.components.JBLabel; import org.jetbrains.android.facet.AndroidFacet; +import org.jetbrains.android.sdk.AndroidPlatform; +import org.jetbrains.android.util.AndroidBundle; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -39,6 +43,8 @@ import java.awt.event.ActionListener; * @author yole */ public class AndroidRunConfigurationEditor extends SettingsEditor implements PanelWithAnchor { + private static final Icon INFO_MESSAGE_ICON = IconLoader.getIcon("/compiler/warning.png"); + private JPanel myPanel; private JComboBox myModulesComboBox; private LabeledComponent myCommandLineComponent; @@ -53,6 +59,7 @@ public class AndroidRunConfigurationEditor myAvdComboComponent; + private JBLabel myMinSdkInfoMessageLabel; private AvdComboBox myAvdCombo; private RawCommandLineEditor myCommandLineField; private String incorrectPreferredAvd; @@ -93,17 +100,23 @@ public class AndroidRunConfigurationEditor= 0) { + myMinSdkInfoMessageLabel.setText(AndroidBundle.message("deployment.target.settings.min.sdk.info.message", apiLevel)); + myMinSdkInfoMessageLabel.setVisible(true); + } + else { + myMinSdkInfoMessageLabel.setText(""); + myMinSdkInfoMessageLabel.setVisible(false); + } + } + @Override public JComponent getAnchor() { return anchor; @@ -163,6 +196,7 @@ public class AndroidRunConfigurationEditor + +/> \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/animatedRotateCompletion1_after.xml b/plugins/android/testData/dom/drawable/animatedRotateCompletion1_after.xml new file mode 100644 index 000000000000..5c4384a19d06 --- /dev/null +++ b/plugins/android/testData/dom/drawable/animatedRotateCompletion1_after.xml @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/animatedRotateCompletion2.xml b/plugins/android/testData/dom/drawable/animatedRotateCompletion2.xml new file mode 100644 index 000000000000..94ada6552661 --- /dev/null +++ b/plugins/android/testData/dom/drawable/animatedRotateCompletion2.xml @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/animatedRotateHighlighting1.xml b/plugins/android/testData/dom/drawable/animatedRotateHighlighting1.xml new file mode 100644 index 000000000000..1148432c8556 --- /dev/null +++ b/plugins/android/testData/dom/drawable/animatedRotateHighlighting1.xml @@ -0,0 +1,8 @@ + + + \ No newline at end of file diff --git a/plugins/android/testData/dom/drawable/animatedRotateHighlighting2.xml b/plugins/android/testData/dom/drawable/animatedRotateHighlighting2.xml new file mode 100644 index 000000000000..258b0b05d235 --- /dev/null +++ b/plugins/android/testData/dom/drawable/animatedRotateHighlighting2.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/plugins/android/testData/dom/layout/hl.xml b/plugins/android/testData/dom/layout/hl.xml index 519ff42443e3..b12d6da966ed 100644 --- a/plugins/android/testData/dom/layout/hl.xml +++ b/plugins/android/testData/dom/layout/hl.xml @@ -9,6 +9,7 @@ android:layout_height="wrap_content" android:layout_marginBottom="10dip" android:text="@string/welcome" + android:padding="@null" /> diff --git a/plugins/android/testSrc/org/jetbrains/android/dom/AndroidDrawableResourcesDomTest.java b/plugins/android/testSrc/org/jetbrains/android/dom/AndroidDrawableResourcesDomTest.java index 684fc270c6b6..34c54686254a 100644 --- a/plugins/android/testSrc/org/jetbrains/android/dom/AndroidDrawableResourcesDomTest.java +++ b/plugins/android/testSrc/org/jetbrains/android/dom/AndroidDrawableResourcesDomTest.java @@ -249,13 +249,29 @@ public class AndroidDrawableResourcesDomTest extends AndroidDomTest { doTestCompletion(); } + public void testAnimatedRotateCompletion1() throws Throwable { + doTestCompletion(); + } + + public void testAnimatedRotateCompletion2() throws Throwable { + doTestOnlyDrawableReferences(); + } + + public void testAnimatedRotateHighlighting1() throws Throwable { + doTestHighlighting(); + } + + public void testAnimatedRotateHighlighting2() throws Throwable { + doTestHighlighting(); + } + public void testIncorrectRootTag() throws Throwable { doTestHighlighting(); } public void testRootTagCompletion() throws Throwable { doTestCompletionVariants(getTestName(true) + ".xml", "selector", "bitmap", "nine-patch", "layer-list", "level-list", "transition", - "inset", "clip", "scale", "shape"); + "inset", "clip", "scale", "shape", "animation-list", "animated-rotate"); } public void testInlineClip() throws Throwable { diff --git a/plugins/devkit/src/build/PluginModuleBuildConfEditor.java b/plugins/devkit/src/build/PluginModuleBuildConfEditor.java index 98584b6c427e..b2be3bc68f32 100644 --- a/plugins/devkit/src/build/PluginModuleBuildConfEditor.java +++ b/plugins/devkit/src/build/PluginModuleBuildConfEditor.java @@ -27,7 +27,6 @@ import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.IconLoader; import com.intellij.openapi.util.io.FileUtil; -import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.ui.IdeBorderFactory; import org.jetbrains.annotations.NonNls; import org.jetbrains.idea.devkit.DevKitBundle; @@ -128,7 +127,6 @@ public class PluginModuleBuildConfEditor implements ModuleConfigurationEditor { } public void reset() { - LocalFileSystem.getInstance().refresh(false); myPluginXML.setText(myBuildProperties.getPluginXmlPath().substring(0, myBuildProperties.getPluginXmlPath().length() - META_INF.length() - PLUGIN_XML.length() - 2)); myManifest.setText(myBuildProperties.getManifestPath()); myUseUserManifest.setSelected(myBuildProperties.isUseUserManifest()); diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/references/MavenPropertyPsiReference.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/references/MavenPropertyPsiReference.java index ea987636dded..981dd7b3a7e1 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/references/MavenPropertyPsiReference.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/references/MavenPropertyPsiReference.java @@ -23,6 +23,7 @@ import com.intellij.openapi.util.TextRange; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.pom.Navigatable; import com.intellij.psi.*; +import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.xml.XmlDocument; import com.intellij.psi.xml.XmlFile; import com.intellij.psi.xml.XmlTag; @@ -74,7 +75,12 @@ public class MavenPropertyPsiReference extends MavenPsiReference { @Nullable public PsiElement resolve() { PsiElement result = doResolve(); - if (result == null) return result; + if (result == null) { + if (MavenDomUtil.isMavenFile(getElement())) { + result = tryResolveToActivationSection(); + if (result == null) return null; + } + } if (result instanceof XmlTag) { XmlTagChild[] children = ((XmlTag)result).getValue().getChildren(); @@ -85,6 +91,30 @@ public class MavenPropertyPsiReference extends MavenPsiReference { return result; } + private PsiElement tryResolveToActivationSection() { + XmlTag xmlTag = PsiTreeUtil.getParentOfType(getElement(), XmlTag.class); + while (xmlTag != null) { + if (xmlTag.getName().equals("profile")) { + XmlTag activation = xmlTag.findFirstSubTag("activation"); + if (activation != null) { + for (XmlTag propertyTag : activation.findSubTags("property")) { + XmlTag nameTag = propertyTag.findFirstSubTag("name"); + if (nameTag != null) { + if (nameTag.getValue().getTrimmedText().equals(myText)) { + return nameTag; + } + } + } + } + break; + } + + xmlTag = xmlTag.getParentTag(); + } + + return null; + } + // See org.apache.maven.project.interpolation.AbstractStringBasedModelInterpolator.createValueSources() @Nullable protected PsiElement doResolve() { diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDomTestCase.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDomTestCase.java index 3dcbe20edc8f..41c0cd7e753c 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDomTestCase.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDomTestCase.java @@ -194,11 +194,25 @@ public abstract class MavenDomTestCase extends MavenImportingTestCase { String text = VfsUtilCore.loadText(file); int index = text.indexOf(referenceText); assert index >= 0; - + assert text.indexOf(referenceText, index + referenceText.length()) == -1 : "Reference text '" + referenceText + "' occurs more than one times"; - + return getReferenceAt(file, index); } + + @Nullable + protected PsiReference getReference(VirtualFile file, @NotNull String referenceText, int index) throws IOException { + String text = VfsUtilCore.loadText(file); + int k = -1; + + do { + k = text.indexOf(referenceText, k + 1); + assert k >= 0 : index; + } + while (--index >= 0); + + return getReferenceAt(file, k); + } @Nullable protected PsiElement resolveReference(VirtualFile file, @NotNull String referenceText) throws IOException { diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPropertyInActivationSectionTest.groovy b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPropertyInActivationSectionTest.groovy new file mode 100644 index 000000000000..89af8f0fbd0b --- /dev/null +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPropertyInActivationSectionTest.groovy @@ -0,0 +1,57 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.maven.dom + +/** + * @author Sergey Evdokimov + */ +class MavenPropertyInActivationSectionTest extends MavenDomTestCase { + + public void testResolvePropertyFromActivationSection() throws IOException { + importProject(""" + example + parent + jar + 1.0 + example + + + + glassfish-env-path + + + env.GLASSFISH_HOME_123 + + + + + \${env.GLASSFISH_HOME_123} + + + + + + + \${env.GLASSFISH_HOME_123} + +"""); + + + assert getReference(myProjectPom, "env.GLASSFISH_HOME_123", 1).resolve() != null + assert getReference(myProjectPom, "env.GLASSFISH_HOME_123", 2).resolve() == null + } + +} diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/plugins/sql/MavenSqlInjectionTest.groovy b/plugins/maven/src/test/java/org/jetbrains/idea/maven/plugins/sql/MavenSqlInjectionTest.groovy deleted file mode 100644 index 5e0e3252b430..000000000000 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/plugins/sql/MavenSqlInjectionTest.groovy +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2000-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.idea.maven.plugins.sql - -import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase -import gnu.trove.THashSet -import gnu.trove.TObjectHashingStrategy -import com.intellij.util.text.CaseInsensitiveStringHashingStrategy - -/** - * @author Sergey Evdokimov - */ -class MavenSqlInjectionTest extends LightCodeInsightFixtureTestCase { - - public void testCompletion() { - myFixture.configureByText("pom.xml", """ - - - 4.0.0 - - simpleMaven - simpleMaven - 1.0 - - jar - - - - - org.codehaus.mojo - sql-maven-plugin - 1.0 - - - groovy-magic - package - - execute - - - - - - - - - - - org.apache.ant - ant-nodeps - 1.8.0 - - - - - - - -""") - - myFixture.completeBasic() - - def lookups = myFixture.lookupElementStrings - lookups = new THashSet(lookups, CaseInsensitiveStringHashingStrategy.INSTANCE) - assert lookups.containsAll(["select", "update", "delete"]) - } - -} diff --git a/plugins/tasks/tasks-core/lib/axis-saaj-1.3.jar b/plugins/tasks/tasks-core/lib/axis-saaj-1.3.jar new file mode 100644 index 000000000000..ae32ad94f501 Binary files /dev/null and b/plugins/tasks/tasks-core/lib/axis-saaj-1.3.jar differ diff --git a/plugins/tasks/tasks-core/lib/wsdl4j-1.4.jar b/plugins/tasks/tasks-core/lib/wsdl4j-1.4.jar new file mode 100644 index 000000000000..49cc2c6eb83a Binary files /dev/null and b/plugins/tasks/tasks-core/lib/wsdl4j-1.4.jar differ diff --git a/plugins/tasks/tasks-core/tasks-core.iml b/plugins/tasks/tasks-core/tasks-core.iml index e7c5ba007155..e3f7b2bde526 100644 --- a/plugins/tasks/tasks-core/tasks-core.iml +++ b/plugins/tasks/tasks-core/tasks-core.iml @@ -18,7 +18,9 @@ + + diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/DesignerEditorPanel.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/DesignerEditorPanel.java index 337cafc9da8d..db4db0918eb9 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/DesignerEditorPanel.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/DesignerEditorPanel.java @@ -316,6 +316,7 @@ public abstract class DesignerEditorPanel extends JPanel implements DataProvider protected final void showProgress(String message) { myProgressMessage.setText(message); if (myProgressPanel.getParent() == null) { + myGlassLayer.setEnabled(false); myProgressIcon.resume(); myLayeredPane.add(myProgressPanel, LAYER_PROGRESS); myLayeredPane.repaint(); @@ -323,6 +324,7 @@ public abstract class DesignerEditorPanel extends JPanel implements DataProvider } protected final void hideProgress() { + myGlassLayer.setEnabled(true); myProgressIcon.suspend(); myLayeredPane.remove(myProgressPanel); } diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/GlassLayer.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/GlassLayer.java index e2263af6d68e..2d4719534750 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/GlassLayer.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/GlassLayer.java @@ -29,13 +29,26 @@ import java.awt.event.MouseEvent; * @author Alexander Lobas */ public final class GlassLayer extends JComponent implements PopupOwner, DataProvider { + private static final long EVENT_FLAGS = AWTEvent.KEY_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK; + private final ToolProvider myToolProvider; private final EditableArea myArea; public GlassLayer(ToolProvider provider, EditableArea area) { myToolProvider = provider; myArea = area; - enableEvents(AWTEvent.KEY_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK); + enableEvents(EVENT_FLAGS); + } + + @Override + public void setEnabled(boolean enabled) { + super.setEnabled(enabled); + if (enabled) { + enableEvents(EVENT_FLAGS); + } + else { + disableEvents(EVENT_FLAGS); + } } @Override diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml index 4983fc2a2427..7cbc5ff778b1 100644 --- a/resources/src/META-INF/IdeaPlugin.xml +++ b/resources/src/META-INF/IdeaPlugin.xml @@ -111,10 +111,6 @@ interface="com.intellij.openapi.compiler.util.InspectionValidator" area="IDEA_PROJECT"/> - - -