diff --git a/bin/scripts/unix/idea.sh b/bin/scripts/unix/idea.sh index 1b436d488e97..7a7601646348 100755 --- a/bin/scripts/unix/idea.sh +++ b/bin/scripts/unix/idea.sh @@ -86,13 +86,17 @@ BITS=$? if [ $OPEN_JDK -eq 0 ]; then echo "WARNING: You are launching the IDE using OpenJDK Java runtime." echo - echo " THIS IS STRICTLY UNSUPPORTED DUE TO KNOWN PERFORMANCE AND GRAPHICS PROBLEMS!" + echo " ITS KNOWN TO HAVE PERFORMANCE AND GRAPHICS ISSUES!" + echo " SWITCH TO THE ORACLE(SUN) JDK BEFORE REPORTING PROBLEMS!" echo echo "NOTE: If you have both Oracle (Sun) JDK and OpenJDK installed" echo " please validate either @@product_uc@@_JDK, JDK_HOME, or JAVA_HOME environment variable points to valid Oracle (Sun) JDK installation." echo " See http://ow.ly/6TuKQ for more info on switching default JDK." echo echo "Press Enter to continue." +# --------------------------------------------------------------------- +# COMMENT LINE BELOW TO REMOVE PAUSE AFTER OPEN JDK WARNING +# --------------------------------------------------------------------- read IGNORE fi if [ $BITS -eq 0 ]; then @@ -141,7 +145,7 @@ if [ "$IS_EAP" = "true" ]; then OS_NAME=`echo $OS_TYPE | "$TR" '[:upper:]' '[:lower:]'` AGENT_LIB="yjpagent-$OS_NAME$BITS" if [ -r "$IDE_BIN_HOME/lib$AGENT_LIB.so" ]; then - AGENT="-agentlib:$AGENT_LIB=disablej2ee,disablecounts,disablealloc,sessionname=@@system_selector@@" + AGENT="-agentlib:$AGENT_LIB=disablej2ee,disablealloc,sessionname=@@system_selector@@" fi fi diff --git a/build/scripts/libLicenses.gant b/build/scripts/libLicenses.gant index d03bc5586bc6..29b981ef038e 100644 --- a/build/scripts/libLicenses.gant +++ b/build/scripts/libLicenses.gant @@ -206,6 +206,7 @@ libraryLicense(name: "Maven3", libraryNames: ["Maven3", "maven-dependency-tree-1 libraryLicense(name: "markdownj", attachedTo: "tasks-core", version: "", license: "BSD", url: "http://markdownj.org/", licenseUrl: "http://www.opensource.org/licenses/bsd-license.php") libraryLicense(name: "mercurial_prompthooks", attachedTo: "hg4idea", version: "", license: "GPLv2 (used as hg extension called from hg executable)", url: "https://github.com/willemv/mercurial_prompthooks", licenseUrl: "https://github.com/willemv/mercurial_prompthooks/blob/master/LICENSE.txt") libraryLicense(name: "Microba", libraryName: "microba", version: "0.4.2", license: "BSD", url: "http://microba.sourceforge.net/", licenseUrl: "http://microba.sourceforge.net/license.txt") +libraryLicense(name: "MigLayout", libraryName: "miglayout-swing", version: "3.7.1", license: "BSD", url: "http://www.miglayout.com/", licenseUrl: "http://www.miglayout.com/mavensite/license.html") libraryLicense(name: "NanoXML", version: "2.2.3", license: "zlib/libpng", url: "http://nanoxml.cyberelf.be/", licenseUrl: "http://devkix.com/nanoxml.php") libraryLicense(name: "nekohtml", libraryName: "nekohtml", version: "1.9.14", license: "Apache 2.0", url: "http://nekohtml.sourceforge.net/", licenseUrl: "http://apache.org/licenses/LICENSE-2.0.txt") libraryLicense(name: "Eclipse JDT Core", libraryName: "Eclipse", version: "3.3", license: "CPL 1.0", url: "http://www.eclipse.org/jdt/core/index.php") diff --git a/build/scripts/utils.gant b/build/scripts/utils.gant index 09ebb86f8101..0913128f69f4 100644 --- a/build/scripts/utils.gant +++ b/build/scripts/utils.gant @@ -60,10 +60,10 @@ binding.setVariable("vmOptions", { "$common_vmoptions ${isEap() ? '-XX:+HeapDump binding.setVariable("vmOptions32", { "$mem32 ${vmOptions()}".trim() }) binding.setVariable("vmOptions64", { "$mem64 ${vmOptions()}".trim() }) binding.setVariable("vmOptions32yjp", { String systemSelector -> - "${vmOptions32()} -agentlib:yjpagent=disablej2ee,disablecounts,disablealloc,sessionname=$systemSelector".trim() + "${vmOptions32()} -agentlib:yjpagent=disablej2ee,disablealloc,sessionname=$systemSelector".trim() }) binding.setVariable("vmOptions64yjp", { String systemSelector -> - "${vmOptions64()} -agentlib:yjpagent64=disablej2ee,disablecounts,disablealloc,sessionname=$systemSelector".trim() + "${vmOptions64()} -agentlib:yjpagent64=disablej2ee,disablealloc,sessionname=$systemSelector".trim() }) binding.setVariable("isDefined", {String key -> @@ -252,7 +252,7 @@ binding.setVariable("layoutMacApp", { String path, String ch, Map args -> String vmOptions = "${vmOptions()} -Xverify:none" if (isEap() && !args.mac_no_yjp) { - vmOptions += " -agentlib:yjpagent=disablej2ee,disablecounts,disablealloc,sessionname=${args.system_selector}" + vmOptions += " -agentlib:yjpagent=disablej2ee,disablealloc,sessionname=${args.system_selector}" } String version = isEap() ? "EAP $args.buildNumber" : "${p("component.version.major")}.${p("component.version.minor")}" diff --git a/java/idea-ui/src/com/intellij/projectImport/SelectImportedProjectsStep.java b/java/idea-ui/src/com/intellij/projectImport/SelectImportedProjectsStep.java index bc10db18f06a..6d9e22b1b3b6 100644 --- a/java/idea-ui/src/com/intellij/projectImport/SelectImportedProjectsStep.java +++ b/java/idea-ui/src/com/intellij/projectImport/SelectImportedProjectsStep.java @@ -71,11 +71,20 @@ public abstract class SelectImportedProjectsStep extends ProjectImportWizardS return panel; } + protected boolean isElementEnabled(T element) { + return true; + } + public void updateStep() { fileChooser.clear(); for (T element : getContext().getList()) { - fileChooser.addElement(element, getContext().isMarked(element)); + boolean isEnabled = isElementEnabled(element); + fileChooser.addElement(element, isEnabled && getContext().isMarked(element)); + if (!isEnabled) { + fileChooser.disableElement(element); + } } + fileChooser.setBorder(IdeBorderFactory.createTitledBorder( IdeBundle.message("project.import.select.title", getContext().getName()), false)); openModuleSettingsCheckBox.setSelected(getBuilder().isOpenProjectSettingsAfter()); 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 9186a5ba227c..23eb2f2969cc 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 @@ -973,6 +973,13 @@ public class GenericsHighlightUtil { return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, ref, JavaErrorMessages.message("generics.cannot.instanceof.type.parameters")); } + if (resolved instanceof PsiClass) { + final PsiClass containingClass = ((PsiClass)resolved).getContainingClass(); + if (containingClass != null && ref.getQualifier() == null && containingClass.getTypeParameters().length > 0) { + return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, typeElement, JavaErrorMessages.message("illegal.generic.type.for.instanceof")); + } + } + final PsiType[] parameters = ref.getTypeParameters(); for (PsiType parameterType : parameters) { if (parameterType != null && diff --git a/java/java-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java b/java/java-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java index 2f18c00301b0..b7222381c9e2 100644 --- a/java/java-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java +++ b/java/java-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java @@ -1506,6 +1506,10 @@ public class JavaDocInfoGenerator { } } + if (type instanceof PsiCapturedWildcardType) { + type = ((PsiCapturedWildcardType)type).getWildcard(); + } + if (type instanceof PsiWildcardType){ PsiWildcardType wt = ((PsiWildcardType)type); diff --git a/java/java-impl/src/com/intellij/codeInspection/deadCode/DummyEntryPointsTool.java b/java/java-impl/src/com/intellij/codeInspection/deadCode/DummyEntryPointsTool.java index 94c0fc425da8..ed7445199c3c 100644 --- a/java/java-impl/src/com/intellij/codeInspection/deadCode/DummyEntryPointsTool.java +++ b/java/java-impl/src/com/intellij/codeInspection/deadCode/DummyEntryPointsTool.java @@ -47,7 +47,9 @@ public class DummyEntryPointsTool extends FilteringInspectionTool { public void runInspection(@NotNull AnalysisScope scope, @NotNull final InspectionManager manager) {} - public void exportResults(@NotNull Element parentNode) {} + @Override + public void exportResults(@NotNull Element parentNode, RefEntity refEntity) { + } @NotNull public JobDescriptor[] getJobDescriptors(GlobalInspectionContext globalInspectionContext) { diff --git a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java index d3ffbc9bb33b..6968e8ff5f9f 100644 --- a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java @@ -631,45 +631,43 @@ public class UnusedDeclarationInspection extends FilteringInspectionTool { return myComposer; } - public void exportResults(@NotNull final Element parentNode) { + @Override + public void exportResults(@NotNull final Element parentNode, RefEntity refEntity) { + if (!(refEntity instanceof RefJavaElement)) return; final WeakUnreferencedFilter filter = new WeakUnreferencedFilter(this); - getRefManager().iterate(new RefJavaVisitor() { - @Override public void visitElement(RefEntity refEntity) { - if (!(refEntity instanceof RefJavaElement)) return; - if (!getIgnoredRefElements().contains(refEntity) && filter.accepts((RefJavaElement)refEntity)) { - if (refEntity instanceof RefImplicitConstructor) refEntity = ((RefImplicitConstructor)refEntity).getOwnerClass(); - Element element = refEntity.getRefManager().export(refEntity, parentNode, -1); - @NonNls Element problemClassElement = new Element(InspectionsBundle.message("inspection.export.results.problem.element.tag")); + if (!getIgnoredRefElements().contains(refEntity) && filter.accepts((RefJavaElement)refEntity)) { + if (refEntity instanceof RefImplicitConstructor) refEntity = ((RefImplicitConstructor)refEntity).getOwnerClass(); + Element element = refEntity.getRefManager().export(refEntity, parentNode, -1); + @NonNls Element problemClassElement = new Element(InspectionsBundle.message("inspection.export.results.problem.element.tag")); - if (refEntity instanceof RefElement) { - final RefElement refElement = (RefElement)refEntity; - final HighlightSeverity severity = getCurrentSeverity(refElement); - final String attributeKey = getTextAttributeKey(refElement.getElement().getProject(), severity, ProblemHighlightType.LIKE_UNUSED_SYMBOL); - problemClassElement.setAttribute("severity", severity.myName); - problemClassElement.setAttribute("attribute_key", attributeKey); - } - - problemClassElement.addContent(InspectionsBundle.message("inspection.export.results.dead.code")); - element.addContent(problemClassElement); - - @NonNls Element hintsElement = new Element("hints"); - - for (String hint : HINTS) { - @NonNls Element hintElement = new Element("hint"); - hintElement.setAttribute("value", hint); - hintsElement.addContent(hintElement); - } - element.addContent(hintsElement); - - - Element descriptionElement = new Element(InspectionsBundle.message("inspection.export.results.description.tag")); - StringBuffer buf = new StringBuffer(); - DeadHTMLComposer.appendProblemSynopsis((RefElement)refEntity, buf); - descriptionElement.addContent(buf.toString()); - element.addContent(descriptionElement); - } + if (refEntity instanceof RefElement) { + final RefElement refElement = (RefElement)refEntity; + final HighlightSeverity severity = getCurrentSeverity(refElement); + final String attributeKey = + getTextAttributeKey(refElement.getElement().getProject(), severity, ProblemHighlightType.LIKE_UNUSED_SYMBOL); + problemClassElement.setAttribute("severity", severity.myName); + problemClassElement.setAttribute("attribute_key", attributeKey); } - }); + + problemClassElement.addContent(InspectionsBundle.message("inspection.export.results.dead.code")); + element.addContent(problemClassElement); + + @NonNls Element hintsElement = new Element("hints"); + + for (String hint : HINTS) { + @NonNls Element hintElement = new Element("hint"); + hintElement.setAttribute("value", hint); + hintsElement.addContent(hintElement); + } + element.addContent(hintsElement); + + + Element descriptionElement = new Element(InspectionsBundle.message("inspection.export.results.description.tag")); + StringBuffer buf = new StringBuffer(); + DeadHTMLComposer.appendProblemSynopsis((RefElement)refEntity, buf); + descriptionElement.addContent(buf.toString()); + element.addContent(descriptionElement); + } } public QuickFixAction[] getQuickFixes(final RefEntity[] refElements) { diff --git a/java/java-impl/src/com/intellij/codeInspection/reference/RefJavaUtilImpl.java b/java/java-impl/src/com/intellij/codeInspection/reference/RefJavaUtilImpl.java index d5c2ea5ded2d..63c25f321f39 100644 --- a/java/java-impl/src/com/intellij/codeInspection/reference/RefJavaUtilImpl.java +++ b/java/java-impl/src/com/intellij/codeInspection/reference/RefJavaUtilImpl.java @@ -75,7 +75,7 @@ public class RefJavaUtilImpl extends RefJavaUtil{ if (refConstructor == null) { // No explicit constructor referenced. Should use default one. PsiType newType = newExpr.getType(); if (newType instanceof PsiClassType) { - processClassReference(PsiUtil.resolveClassInType(newType), refFrom, psiFrom); + processClassReference(PsiUtil.resolveClassInType(newType), refFrom, psiFrom, true); } } } @@ -124,22 +124,38 @@ public class RefJavaUtilImpl extends RefJavaUtil{ final PsiTypeElement operand = expression.getOperand(); final PsiType type = operand.getType(); if (type instanceof PsiClassType) { - processClassReference(((PsiClassType)type).resolve(), refFrom, psiFrom); + processClassReference(((PsiClassType)type).resolve(), refFrom, psiFrom, false); } } - private void processClassReference(final PsiClass psiClass, final RefJavaElementImpl refFrom, final PsiModifierListOwner psiFrom) { + private void processClassReference(final PsiClass psiClass, + final RefJavaElementImpl refFrom, + final PsiModifierListOwner psiFrom, + boolean defaultConstructorOnly) { if (psiClass != null) { RefClassImpl refClass = (RefClassImpl)refFrom.getRefManager().getReference(psiClass); if (refClass != null) { - RefMethodImpl refDefaultConstructor = (RefMethodImpl)refClass.getDefaultConstructor(); + boolean hasConstructorsMarked = false; - if (refDefaultConstructor != null && !(refDefaultConstructor instanceof RefImplicitConstructor)) { - refDefaultConstructor.addInReference(refFrom); - refFrom.addOutReference(refDefaultConstructor); + if (defaultConstructorOnly) { + RefMethodImpl refDefaultConstructor = (RefMethodImpl)refClass.getDefaultConstructor(); + if (refDefaultConstructor != null && !(refDefaultConstructor instanceof RefImplicitConstructor)) { + refDefaultConstructor.addInReference(refFrom); + refFrom.addOutReference(refDefaultConstructor); + hasConstructorsMarked = true; + } } else { + for (RefMethod cons : refClass.getConstructors()) { + if (cons instanceof RefImplicitConstructor) continue; + ((RefMethodImpl)cons).addInReference(refFrom); + refFrom.addOutReference(cons); + hasConstructorsMarked = true; + } + } + + if (!hasConstructorsMarked) { refFrom.addReference(refClass, psiClass, psiFrom, false, true, null); } } @@ -385,4 +401,4 @@ public class RefJavaUtilImpl extends RefJavaUtil{ } } } -} \ No newline at end of file +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IllegalGenericTypeInInstanceof.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IllegalGenericTypeInInstanceof.java new file mode 100644 index 000000000000..bb183a1c2622 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IllegalGenericTypeInInstanceof.java @@ -0,0 +1,27 @@ +class A { + public void foo(Object object) { + if (object instanceof B) {} + if (object instanceof A.B) {} + if (object instanceof A.B) {} + if (object instanceof A) {} + if (object instanceof A) {} + if (object instanceof A) {} + if (object instanceof A[]) {} + if (object instanceof B[]) {} + if (object instanceof A.B[]) {} + } + + private class B { + } +} + +class A1 { + public void foo(Object object) { + if (object instanceof B1) {} + if (object instanceof A1.B1) {} + if (object instanceof B1[]) {} + } + + private class B1 { + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/UncheckedWarningsLevel6.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/UncheckedWarningsLevel6.java index ad6d8e79d114..2765ed42befa 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/UncheckedWarningsLevel6.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/UncheckedWarningsLevel6.java @@ -1,3 +1,4 @@ +import java.lang.Override; import java.util.*; class GenericsTest { @@ -91,4 +92,30 @@ class GenericsTest2 { } }; } +} +class Example { + private static void assertThat(T actual, Matcher matcher) { + assert actual != null; + assert matcher != null; + } + + private static Matcher> hasSize(int size) { + assert size >=0; + return new Matcher>() { + @Override + public void foo(Collection es) { + System.out.println(es); + } + }; + } + + public static void main(String[] args) { + List list = new ArrayList(); + System.out.println(list); + assertThat(new ArrayList(), hasSize(0)); + } + + private interface Matcher { + void foo(T t); + } } \ No newline at end of file diff --git a/java/java-tests/testData/inspection/deadCode/classLiteralRef/expected.xml b/java/java-tests/testData/inspection/deadCode/classLiteralRef/expected.xml new file mode 100644 index 000000000000..bdafc52f107c --- /dev/null +++ b/java/java-tests/testData/inspection/deadCode/classLiteralRef/expected.xml @@ -0,0 +1,4 @@ + + + + diff --git a/java/java-tests/testData/inspection/deadCode/classLiteralRef/src/Test.java b/java/java-tests/testData/inspection/deadCode/classLiteralRef/src/Test.java new file mode 100644 index 000000000000..13500191cfe2 --- /dev/null +++ b/java/java-tests/testData/inspection/deadCode/classLiteralRef/src/Test.java @@ -0,0 +1,12 @@ +import java.lang.Class; +import java.lang.String; + +public class Test { + public static void main(String[] args) { + Test.class.getDeclaredConstructor(String.class).newInstance("Foo"); + } + + public Test(String param) { + System.out.println("This is used!"); + } +} 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 246a97b67eb6..e86b90d047ac 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java @@ -132,6 +132,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase { public void testIDEA74899() throws Exception {doTest(false);} public void testIDEA63291() throws Exception {doTest(false);} public void testIDEA72912() throws Exception {doTest(false);} + public void testIllegalGenericTypeInInstanceof() throws Exception {doTest(false);} public void testJavaUtilCollections_NoVerify() throws Exception { PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule())); diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/UnusedDeclarationTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/UnusedDeclarationTest.java index 5dcd702f8835..aa8049be425e 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/UnusedDeclarationTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/UnusedDeclarationTest.java @@ -184,4 +184,8 @@ public class UnusedDeclarationTest extends InspectionTestCase { public void testAbstractClassWithSerializableSubclasses() throws Exception { doTest(); } + + public void testclassLiteralRef() throws Exception { + doTest(); + } } diff --git a/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java b/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java index 660ba9dcfe0c..a2dd05bde64c 100644 --- a/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java +++ b/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java @@ -379,20 +379,19 @@ public class FindManagerTest extends DaemonAnalyzerTestCase { findModel.setWholeWordsOnly(false); assertSize(2, findUsages(findModel)); - /* todo findModel.setWholeWordsOnly(true); assertSize(2, findUsages(findModel)); - */ } - public void testLocalScopeSearchPerformance() throws Exception { - final int count = 3000; + public void testLocalScopeSearchPerformance() throws Throwable { + final int fileCount = 3000; + final int lineCount = 500; TempDirTestFixture fixture = new LightTempDirTestFixtureImpl(); fixture.setUp(); try { - String sampleText = StringUtil.repeat("zoo TargetWord foo bar goo\n", count); - for (int i = 0; i < count; i++) { + String sampleText = StringUtil.repeat("zoo TargetWord foo bar goo\n", lineCount); + for (int i = 0; i < fileCount; i++) { fixture.createFile("a" + i + ".txt", sampleText); } PsiTestUtil.addSourceContentToRoots(myModule, fixture.getFile("")); @@ -409,15 +408,15 @@ public class FindManagerTest extends DaemonAnalyzerTestCase { ThrowableRunnable test = new ThrowableRunnable() { @Override public void run() throws Throwable { - assertSize(count, findUsages(findModel)); + assertSize(lineCount, findUsages(findModel)); } }; findModel.setCustomScope(GlobalSearchScope.fileScope(psiFile)); - PlatformTestUtil.startPerformanceTest("slow", 500, test).attempts(1).cpuBound().usesAllCPUCores().assertTiming(); + PlatformTestUtil.startPerformanceTest("slow", 400, test).attempts(2).cpuBound().usesAllCPUCores().assertTiming(); findModel.setCustomScope(new LocalSearchScope(psiFile)); - PlatformTestUtil.startPerformanceTest("slow", 500, test).attempts(1).cpuBound().usesAllCPUCores().assertTiming(); + PlatformTestUtil.startPerformanceTest("slow", 400, test).attempts(2).cpuBound().usesAllCPUCores().assertTiming(); } finally { fixture.tearDown(); diff --git a/lib/src/trove4j_changes.txt b/lib/src/trove4j_changes.txt index 4d8619f3cdfb..e52489551ccf 100644 --- a/lib/src/trove4j_changes.txt +++ b/lib/src/trove4j_changes.txt @@ -1,3 +1,13 @@ +Date: 16 Apr 2012 + Changed classes: + gnu.trove.THash + gnu.trove.TPrimitiveHash + gnu.trove.TObjectHash + gnu.trove.TIterator + gnu.trove.benchmark.Main + and many others + - implement autocompact on removing keys. Failure to do so leads to linear access time + Date: 15 Jan 2008 Changed classes: gnu.trove.THashMap - fixed bug in put() method for null value diff --git a/lib/src/trove4j_src.jar b/lib/src/trove4j_src.jar index 8f333ba3f843..408696db4c66 100644 Binary files a/lib/src/trove4j_src.jar and b/lib/src/trove4j_src.jar differ diff --git a/lib/trove4j.jar b/lib/trove4j.jar index 8f3c6a7f8438..ff1ae6039f1e 100644 Binary files a/lib/trove4j.jar and b/lib/trove4j.jar differ diff --git a/license/miglayout_swing_license.txt b/license/miglayout_swing_license.txt new file mode 100644 index 000000000000..7a28881c8add --- /dev/null +++ b/license/miglayout_swing_license.txt @@ -0,0 +1,28 @@ +Copyright (c) 2011 MiG InfoCom AB +All rights reserved. + + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/platform/core-impl/src/com/intellij/psi/search/ProjectScopeImpl.java b/platform/core-impl/src/com/intellij/psi/search/ProjectScopeImpl.java index 1b45424b150e..684136c1b0e8 100644 --- a/platform/core-impl/src/com/intellij/psi/search/ProjectScopeImpl.java +++ b/platform/core-impl/src/com/intellij/psi/search/ProjectScopeImpl.java @@ -35,8 +35,6 @@ public class ProjectScopeImpl extends GlobalSearchScope { public boolean contains(VirtualFile file) { if (file instanceof VirtualFileWindow) return true; - if (myFileIndex.isInLibraryClasses(file) && !myFileIndex.isInSourceContent(file)) return false; - return myFileIndex.isInContent(file); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonTooltipRendererProvider.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonTooltipRendererProvider.java index 822e68e24e21..370963eec023 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonTooltipRendererProvider.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonTooltipRendererProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -133,28 +133,34 @@ public class DaemonTooltipRendererProvider implements ErrorStripTooltipRendererP @Override protected boolean dressDescription(@NotNull final Editor editor) { - final String[] problems = UIUtil.getHtmlBody(myText).split(BORDER_LINE); + final List problems = StringUtil.split(UIUtil.getHtmlBody(myText), BORDER_LINE); String text = ""; for (String problem : problems) { final String ref = getLinkRef(problem); if (ref != null) { String description = TooltipLinkHandlerEP.getDescription(ref, editor); if (description != null) { - final Pattern pattern = Pattern.compile(".*Use.*(the (panel|checkbox|checkboxes|field|button|controls).*below).*", Pattern.DOTALL); - final Matcher matcher = pattern.matcher(description); - int startFindIdx = 0; - while (matcher.find(startFindIdx)) { - final int end = matcher.end(1); - startFindIdx = end; - description = description.substring(0, matcher.start(1)) + " inspection settings " + description.substring(end); + description = UIUtil.getHtmlBody(description); + final int descriptionEnd = description.indexOf(""); + if (descriptionEnd < 0) { + final Pattern pattern = Pattern.compile(".*Use.*(the (panel|checkbox|checkboxes|field|button|controls).*below).*", Pattern.DOTALL); + final Matcher matcher = pattern.matcher(description); + int startFindIdx = 0; + while (matcher.find(startFindIdx)) { + final int end = matcher.end(1); + startFindIdx = end; + description = description.substring(0, matcher.start(1)) + " inspection settings " + description.substring(end); + } + } else { + description = description.substring(0, descriptionEnd); } text += UIUtil.getHtmlBody(problem).replace(DaemonBundle.message("inspection.extended.description"), DaemonBundle.message("inspection.collapse.description")) + - BORDER_LINE + UIUtil.getHtmlBody(description) + BORDER_LINE; + BORDER_LINE + description + BORDER_LINE; } } } - if (text.length() > 0) { //otherwise do not change anything + if (!text.isEmpty()) { //otherwise do not change anything myText = "" + StringUtil.trimEnd(text, BORDER_LINE) + ""; return true; } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/CompletionExtender.java b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/CompletionExtender.java index 3ff721a98175..99e9b05e7517 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/CompletionExtender.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/CompletionExtender.java @@ -17,11 +17,14 @@ package com.intellij.codeInsight.lookup.impl; import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.ui.HeavyweightHint; +import com.intellij.ui.awt.RelativePoint; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import javax.swing.*; import java.awt.*; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; /** * @author Konstantin Bulenkov @@ -36,6 +39,17 @@ public class CompletionExtender extends HeavyweightHint { myElement = element; myLookup = lookup; myIndex = myLookup.getList().getSelectedIndex(); + myLookup.getComponent().addComponentListener(new ComponentAdapter() { + @Override + public void componentResized(ComponentEvent e) { + recalculateLocation(); + } + + @Override + public void componentMoved(ComponentEvent e) { + recalculateLocation(); + } + }); } public LookupElement getLookupElement() { @@ -74,6 +88,18 @@ public class CompletionExtender extends HeavyweightHint { return false; } + void recalculateLocation() { + if (!isVisible()) return; + final JList list = myLookup.getList(); + final Point p = list.getLocationOnScreen(); + p.y += list.indexToLocation(list.getSelectedIndex()).y; + final JComponent rootPane = UIUtil.getRootPane(myLookup.getEditor().getContentComponent()); + if (rootPane != null) { + SwingUtilities.convertPointFromScreen(p, rootPane); + setLocation(new RelativePoint(rootPane, p)); + } + } + @Override public void hide() { super.hide(); diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/CommonInspectionToolWrapper.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/CommonInspectionToolWrapper.java index 3858734b488c..60013c809bf1 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/CommonInspectionToolWrapper.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/CommonInspectionToolWrapper.java @@ -20,6 +20,7 @@ import com.intellij.codeInspection.GlobalInspectionContext; import com.intellij.codeInspection.InspectionEP; import com.intellij.codeInspection.InspectionManager; import com.intellij.codeInspection.reference.RefEntity; +import com.intellij.codeInspection.reference.RefVisitor; import com.intellij.codeInspection.ui.InspectionNode; import com.intellij.codeInspection.ui.InspectionTreeNode; import org.jdom.Element; @@ -111,7 +112,7 @@ public class CommonInspectionToolWrapper extends InspectionToolWrapper\n"); } for (Object o : list) { @@ -263,19 +262,16 @@ public abstract class DescriptorProviderInspection extends InspectionTool implem return myComposer; } - public void exportResults(@NotNull final Element parentNode) { - getRefManager().iterate(new RefVisitor() { - @Override public void visitElement(final RefEntity refEntity) { - synchronized (lock) { - if (getProblemElements().containsKey(refEntity)) { - CommonProblemDescriptor[] descriptions = getDescriptions(refEntity); - if (descriptions != null) { - exportResults(descriptions, refEntity, parentNode); - } - } + @Override + public void exportResults(final @NotNull Element parentNode, RefEntity refEntity) { + synchronized (lock) { + if (getProblemElements().containsKey(refEntity)) { + CommonProblemDescriptor[] descriptions = getDescriptions(refEntity); + if (descriptions != null) { + exportResults(descriptions, refEntity, parentNode); } } - }); + } } private void exportResults(@NotNull final CommonProblemDescriptor[] descriptions, final RefEntity refEntity, final Element parentNode) { 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 872844b78bbf..18d9ef0bc84e 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java @@ -105,6 +105,7 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G private final Map myTools = new THashMap(); private AnalysisUIOptions myUIOptions; + @NonNls static final String LOCAL_TOOL_ATTRIBUTE = "is_local_tool"; public GlobalInspectionContextImpl(Project project, NotNullLazyValue contentManager) { myProject = project; @@ -296,44 +297,63 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G public void run() { performInspectionsWithProgress(scope, manager); @NonNls final String ext = ".xml"; + final Map globalTools = new HashMap(); for (Map.Entry stringSetEntry : myTools.entrySet()) { - final Element root = new Element(InspectionsBundle.message("inspection.problems")); - final Document doc = new Document(root); final Tools sameTools = stringSetEntry.getValue(); boolean hasProblems = false; - boolean isLocalTool = false; String toolName = stringSetEntry.getKey(); if (sameTools != null) { for (ScopeToolState toolDescr : sameTools.getTools()) { final InspectionTool tool = (InspectionTool)toolDescr.getTool(); if (tool instanceof LocalInspectionToolWrapper) { hasProblems = new File(outputPath, toolName + ext).exists(); - isLocalTool = true; } else { tool.updateContent(); if (tool.hasReportedProblems()) { - hasProblems = true; - tool.exportResults(root); + final Element root = new Element(InspectionsBundle.message("inspection.problems")); + globalTools.put(root, sameTools); + LOG.assertTrue(!hasProblems, toolName); + break; } } } } if (!hasProblems) continue; - @NonNls final String isLocalToolAttribute = "is_local_tool"; - root.setAttribute(isLocalToolAttribute, String.valueOf(isLocalTool)); try { new File(outputPath).mkdirs(); final File file = new File(outputPath, toolName + ext); inspectionsResults.add(file); - if (isLocalTool) { - FileUtil.writeToFile(file, ("").getBytes("UTF-8"), true); - } - else { - PathMacroManager.getInstance(getProject()).collapsePaths(doc.getRootElement()); - JDOMUtil.writeDocument(doc, file, "\n"); + FileUtil.writeToFile(file, ("").getBytes("UTF-8"), true); + } + catch (IOException e) { + LOG.error(e); + } + } + + getRefManager().iterate(new RefVisitor() { + @Override + public void visitElement(final RefEntity refEntity) { + for (Element element : globalTools.keySet()) { + final Tools tools = globalTools.get(element); + for (ScopeToolState state : tools.getTools()) { + ((InspectionTool)state.getTool()).exportResults(element, refEntity); + } } } + }); + + for (Element element : globalTools.keySet()) { + final String toolName = globalTools.get(element).getShortName(); + element.setAttribute(LOCAL_TOOL_ATTRIBUTE, Boolean.toString(false)); + final Document doc = new Document(element); + PathMacroManager.getInstance(getProject()).collapsePaths(doc.getRootElement()); + try { + new File(outputPath).mkdirs(); + final File file = new File(outputPath, toolName + ext); + inspectionsResults.add(file); + JDOMUtil.writeDocument(doc, file, "\n"); + } catch (IOException e) { LOG.error(e); } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionTool.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionTool.java index 279ef0b60f33..e9d0aa00349d 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionTool.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionTool.java @@ -29,10 +29,7 @@ import com.intellij.codeInsight.daemon.impl.HighlightInfoType; import com.intellij.codeInsight.daemon.impl.SeverityRegistrar; import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.codeInspection.*; -import com.intellij.codeInspection.reference.RefElement; -import com.intellij.codeInspection.reference.RefEntity; -import com.intellij.codeInspection.reference.RefManager; -import com.intellij.codeInspection.reference.RefModule; +import com.intellij.codeInspection.reference.*; import com.intellij.codeInspection.ui.InspectionNode; import com.intellij.codeInspection.ui.InspectionTreeNode; import com.intellij.lang.annotation.HighlightSeverity; @@ -69,7 +66,16 @@ public abstract class InspectionTool extends InspectionProfileEntry { public abstract void runInspection(@NotNull AnalysisScope scope, @NotNull InspectionManager manager); - public abstract void exportResults(@NotNull Element parentNode); + public void exportResults(@NotNull final Element parentNode) { + getRefManager().iterate(new RefVisitor(){ + @Override + public void visitElement(RefEntity elem) { + exportResults(parentNode, elem); + } + }); + } + + public abstract void exportResults(@NotNull Element parentNode, RefEntity refEntity); public abstract boolean isGraphNeeded(); @Nullable diff --git a/platform/lang-impl/src/com/intellij/codeInspection/inspection-black-list.txt b/platform/lang-impl/src/com/intellij/codeInspection/inspection-black-list.txt index 0310181f4ccb..9527d222bb38 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/inspection-black-list.txt +++ b/platform/lang-impl/src/com/intellij/codeInspection/inspection-black-list.txt @@ -78,6 +78,7 @@ com.siyeh.ig.classlayout.EmptyClassInspection com.siyeh.ig.classlayout.InnerClassOnInterfaceInspection com.siyeh.ig.classlayout.ListenerMayUseAdapterInspection com.siyeh.ig.classlayout.MissingOverrideAnnotationInspection +com.siyeh.ig.classlayout.UtilityClassInspection com.siyeh.ig.classlayout.UtilityClassWithoutPrivateConstructorInspection com.siyeh.ig.classmetrics.AnonymousClassComplexityInspection com.siyeh.ig.classmetrics.AnonymousClassMethodCountInspection diff --git a/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java b/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java index 0061cdad34f7..ca49a0227f8e 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java @@ -439,7 +439,17 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable, if (!(settings.getConfiguration() instanceof UnknownRunConfiguration)) { final List tasks = getBeforeRunTasks(settings.getConfiguration()); final Element methodsElement = new Element(METHOD); + Map,BeforeRunTask> templateTasks = null; + if (!settings.isTemplate()) { + List beforeRunTasks = getBeforeRunTasks(getConfigurationTemplate(settings.getFactory()).getConfiguration()); + templateTasks = new HashMap, BeforeRunTask>(); + for (BeforeRunTask task : beforeRunTasks) { + templateTasks.put(task.getProviderId(), task); + } + } for (BeforeRunTask task : tasks) { + if (templateTasks != null && task.equals(templateTasks.get(task.getProviderId()))) + continue; // not neccesary saving if the task is the same as template final Element child = new Element(OPTION); child.setAttribute(NAME_ATTR, task.getProviderId().toString()); task.writeExternal(child); @@ -793,7 +803,11 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable, @NotNull @Override public List getBeforeRunTasks(RunConfiguration settings, Key taskProviderID) { - List tasks = getBeforeRunTasks(settings); + List tasks = myConfigurationToBeforeTasksMap.get(settings); + if (tasks == null) { + tasks = getBeforeRunTasks(settings); + myConfigurationToBeforeTasksMap.put(settings, tasks); + } List result = new ArrayList(); for (BeforeRunTask task : tasks) { if (task.getProviderId() == taskProviderID) @@ -859,7 +873,20 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable, } public final void setBeforeRunTasks(final RunConfiguration runConfiguration, List tasks) { - myConfigurationToBeforeTasksMap.put(runConfiguration, tasks); + List templates = getBeforeRunTasks(runConfiguration);//here may be some disabled templates + Set> idsToSet = new HashSet>(); + List result = new ArrayList(tasks); + for (BeforeRunTask task : tasks) { + idsToSet.add(task.getProviderId()); + } + int i = 0; + for (BeforeRunTask template : templates) { + if (!idsToSet.contains(template.getProviderId())) { + result.add(i, template); + i++; + } + } + myConfigurationToBeforeTasksMap.put(runConfiguration, result); fireBeforeRunTasksUpdated(); } diff --git a/platform/lang-impl/src/com/intellij/ide/actions/CloneElementAction.java b/platform/lang-impl/src/com/intellij/ide/actions/CloneElementAction.java index e5d3ac3e9352..8e6a97451901 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/CloneElementAction.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/CloneElementAction.java @@ -39,13 +39,13 @@ public class CloneElementAction extends CopyElementAction { } protected void updateForToolWindow(String id, DataContext dataContext,Presentation presentation) { + if (!ToolWindowId.COMMANDER.equals(id)) { + presentation.setVisible(false); + return; + } // work only with single selection PsiElement[] elements = LangDataKeys.PSI_ELEMENT_ARRAY.getData(dataContext); presentation.setEnabled(elements != null && elements.length == 1 && CopyHandler.canClone(elements)); presentation.setVisible(true); - - if (!ToolWindowId.COMMANDER.equals(id)) { - presentation.setVisible(false); - } } } diff --git a/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/BookmarksAction.java b/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/BookmarksAction.java index d5e7b3be28d6..53c9d8c4e43a 100644 --- a/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/BookmarksAction.java +++ b/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/BookmarksAction.java @@ -468,7 +468,7 @@ public class BookmarksAction extends AnAction implements DumbAware { myFile = PlatformDataKeys.VIRTUAL_FILE.getData(myDataContext); myLine = -1; - if (myBookmarkAtPlace == null) { + if (myBookmarkAtPlace == null && myFile != null) { myBookmarkAtPlace = bookmarkManager.findFileBookmark(myFile); } } diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionsConfigTreeComparator.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionsConfigTreeComparator.java index 6783f85dc4d7..80a71ff5a6fb 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionsConfigTreeComparator.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionsConfigTreeComparator.java @@ -34,6 +34,13 @@ public class InspectionsConfigTreeComparator implements Comparator 0) { final CopyHandlerDelegate[] copyHandlers = Extensions.getExtensions(CopyHandlerDelegate.EP_NAME); for (CopyHandlerDelegate delegate : copyHandlers) { - if (delegate.canCopy(elements)) { + if (delegate instanceof CopyHandlerDelegateBase ? ((CopyHandlerDelegateBase)delegate).canCopy(elements, true) : delegate.canCopy(elements)) { if (delegate instanceof CopyHandlerDelegateBase && ((CopyHandlerDelegateBase)delegate).forbidToClone(elements, true)){ return false; } diff --git a/platform/lang-impl/src/com/intellij/tools/Tool.java b/platform/lang-impl/src/com/intellij/tools/Tool.java index 1ad5476014d3..cfa2d8426c74 100644 --- a/platform/lang-impl/src/com/intellij/tools/Tool.java +++ b/platform/lang-impl/src/com/intellij/tools/Tool.java @@ -34,6 +34,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Comparing; import org.jetbrains.annotations.NonNls; +import java.io.File; import java.util.ArrayList; public class Tool implements SchemeElement { @@ -300,7 +301,15 @@ public class Tool implements SchemeElement { commandLine.setWorkDirectory(MacroManager.getInstance().expandMacrosInString(workingDir, false, dataContext)); exePath = MacroManager.getInstance().expandMacrosInString(exePath, false, dataContext); if (exePath == null) return null; - commandLine.setExePath(exePath); + + File exeFile = new File(exePath); + if (exeFile.isDirectory() && exeFile.getName().endsWith(".app")) { + commandLine.setExePath("open"); + commandLine.getParametersList().prependAll("-a", exePath); + } + else { + commandLine.setExePath(exePath); + } } catch (Macro.ExecutionCancelledException e) { return null; diff --git a/platform/lang-impl/src/com/intellij/tools/ToolEditorDialog.java b/platform/lang-impl/src/com/intellij/tools/ToolEditorDialog.java index 7c4055402403..35905c7b2688 100644 --- a/platform/lang-impl/src/com/intellij/tools/ToolEditorDialog.java +++ b/platform/lang-impl/src/com/intellij/tools/ToolEditorDialog.java @@ -21,9 +21,10 @@ import com.intellij.ide.macro.MacroManager; import com.intellij.ide.macro.MacrosDialog; import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.PlatformDataKeys; -import com.intellij.openapi.fileChooser.FileChooser; import com.intellij.openapi.fileChooser.FileChooserDescriptor; import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; +import com.intellij.openapi.fileChooser.FileChooserFactory; +import com.intellij.openapi.fileChooser.PathChooserDialog; import com.intellij.openapi.help.HelpManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.ComboBox; @@ -34,6 +35,7 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.ui.DocumentAdapter; import com.intellij.ui.IdeBorderFactory; +import com.intellij.util.Consumer; import javax.swing.*; import javax.swing.event.DocumentEvent; @@ -42,6 +44,7 @@ import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; +import java.util.List; public class ToolEditorDialog extends DialogWrapper { private final JTextField myNameField = new JTextField(); @@ -179,7 +182,7 @@ public class ToolEditorDialog extends DialogWrapper { } private JPanel createCommandPane() { - JPanel pane = new JPanel(new GridBagLayout()); + final JPanel pane = new JPanel(new GridBagLayout()); pane.setBorder(IdeBorderFactory.createTitledBorder(ToolsBundle.message("tools.tool.group"), true)); GridBagConstraints constr; @@ -196,18 +199,24 @@ public class ToolEditorDialog extends DialogWrapper { browseCommandButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { - FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor(); - VirtualFile file = FileChooser.chooseFile(descriptor, myProject, null); - if (file != null) { - myTfCommand.setText(file.getPresentableUrl()); - String workingDirectory = myTfCommandWorkingDirectory.getText(); - if (workingDirectory == null || workingDirectory.length() == 0){ - VirtualFile parent = file.getParent(); - if (parent != null && parent.isDirectory()) { - myTfCommandWorkingDirectory.setText(parent.getPresentableUrl()); + FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileOrExecutableAppDescriptor(); + PathChooserDialog chooser = FileChooserFactory.getInstance().createPathChooser(descriptor, myProject, pane); + chooser.choose(null, new Consumer>() { + @Override + public void consume(List files) { + VirtualFile file = files.size() > 0 ? files.get(0) : null; + if (file != null) { + myTfCommand.setText(file.getPresentableUrl()); + String workingDirectory = myTfCommandWorkingDirectory.getText(); + if (workingDirectory == null || workingDirectory.length() == 0){ + VirtualFile parent = file.getParent(); + if (parent != null && parent.isDirectory()) { + myTfCommandWorkingDirectory.setText(parent.getPresentableUrl()); + } + } } } - } + }); } } ); @@ -276,10 +285,17 @@ public class ToolEditorDialog extends DialogWrapper { new ActionListener() { public void actionPerformed(ActionEvent e) { FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); - VirtualFile file = FileChooser.chooseFile(descriptor, myProject, null); - if (file != null) { - myTfCommandWorkingDirectory.setText(file.getPresentableUrl()); - } + PathChooserDialog chooser = FileChooserFactory.getInstance().createPathChooser(descriptor, myProject, pane); + + chooser.choose(null, new Consumer>() { + @Override + public void consume(List files) { + VirtualFile file = files.size() > 0 ? files.get(0) : null; + if (file != null) { + myTfCommandWorkingDirectory.setText(file.getPresentableUrl()); + } + } + }); } } ); @@ -463,4 +479,4 @@ public class ToolEditorDialog extends DialogWrapper { if (s.length() == 0) return null; return s.replace('/', File.separatorChar); } -} \ No newline at end of file +} diff --git a/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDescriptor.java b/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDescriptor.java index d69b4c68c2bb..ea6067421823 100644 --- a/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDescriptor.java +++ b/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDescriptor.java @@ -206,7 +206,7 @@ public class FileChooserDescriptor implements Cloneable { @Nullable public final VirtualFile getFileToSelect(VirtualFile file) { - if (file.isDirectory() && myChooseFolders) { + if (file.isDirectory() && (myChooseFolders || isFileSelectable(file))) { return file; } boolean isJar = file.getFileType() == FileTypes.ARCHIVE; diff --git a/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDescriptorFactory.java b/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDescriptorFactory.java index 2696d8904ceb..057ca54e3b4b 100644 --- a/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDescriptorFactory.java +++ b/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDescriptorFactory.java @@ -16,6 +16,7 @@ package com.intellij.openapi.fileChooser; import com.intellij.openapi.fileTypes.FileType; +import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.UIBundle; @@ -39,6 +40,21 @@ public class FileChooserDescriptorFactory { return new FileChooserDescriptor(true, false, false, false, false, false); } + public static FileChooserDescriptor createSingleFileOrExecutableAppDescriptor() { + return new FileChooserDescriptor(true, false, false, false, false, false) { + @Override + public boolean isFileSelectable(VirtualFile file) { + if (super.isFileSelectable(file)) return true; + + if (SystemInfo.isMac && file.isDirectory() && "app".equals(file.getExtension())) { + return true; + } + + return false; + } + }; + } + public static FileChooserDescriptor createSingleLocalFileDescriptor() { return new FileChooserDescriptor(true, true, true, true, false, false); } diff --git a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java index 8e178949308d..a9a028b012ba 100644 --- a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java @@ -130,9 +130,11 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application new SynchronousQueue(), new ThreadFactory() { int i; + @Override public Thread newThread(Runnable r) { final int count = myAliveThreads.incrementAndGet(); final Thread thread = new Thread(r, "ApplicationImpl pooled thread "+i++) { + @Override public void interrupt() { if (LOG.isDebugEnabled()) { LOG.debug("Interrupted worker, will remove from pool"); @@ -140,6 +142,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application super.interrupt(); } + @Override public void run() { try { super.run(); @@ -166,18 +169,20 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application private Boolean myActive; private static final ThreadLocal ourEdtSafe = new ThreadLocal(); - private static final ModalityState ANY = new ModalityState() { + @NonNls private static final ModalityState ANY = new ModalityState() { @Override public boolean dominates(@NotNull ModalityState anotherState) { return false; } + @NonNls @Override public String toString() { return "ANY"; } }; + @Override protected void bootstrapPicoContainer() { super.bootstrapPicoContainer(); getPicoContainer().registerComponentImplementation(IComponentStore.class, StoresFactory.getApplicationStoreClass()); @@ -260,7 +265,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application registerFont("/fonts/Inconsolata.ttf"); } - private void registerFont(String name) { + private void registerFont(@NonNls String name) { if (isHeadlessEnvironment()) return; InputStream is = null; @@ -271,7 +276,8 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application } catch (Exception e) { LOG.info(e); - } finally { + } + finally { if (is != null) { try { is.close(); @@ -287,11 +293,13 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application ShutDownTracker.getInstance(); // Necessary to avoid creating an instance while already shutting down. ShutDownTracker.getInstance().registerShutdownTask(new Runnable() { + @Override public void run() { if (isDisposed() || isDisposeInProgress()) { return; } ShutDownTracker.invokeAndWait(isUnitTestMode(), true, new Runnable() { + @Override public void run() { if (ApplicationManager.getApplication() != ApplicationImpl.this) return; try { @@ -299,7 +307,9 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application saveAll(); } finally { - disposeSelf(true); + if (!disposeSelf(true)) { + myDisposeInProgress = false; + } } } }); @@ -313,6 +323,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application for (final Project project : ProjectManagerEx.getInstanceEx().getOpenProjects()) { try { commandProcessor.executeCommand(project, new Runnable() { + @Override public void run() { final ProjectManagerImpl manager = (ProjectManagerImpl)ProjectManagerEx.getInstanceEx(); if (!manager.closeProject(project, true, true, checkCanCloseProject)) { @@ -325,7 +336,6 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application LOG.error(e); } if (!canClose.get()) { - myDisposeInProgress = false; return false; } } @@ -335,11 +345,13 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application return true; } + @Override @NotNull public String getName() { return myName; } + @Override public boolean holdsReadLock() { return myActionsLock.isReadLockAcquired(); } @@ -406,14 +418,17 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application return component; } + @Override protected MutablePicoContainer createPicoContainer() { return Extensions.getRootArea().getPicoContainer(); } + @Override public boolean isInternal() { return myIsInternal; } + @Override public boolean isUnitTestMode() { return myTestModeFlag; } @@ -422,16 +437,20 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application myTestModeFlag = testModeFlag; } + @Override public boolean isHeadlessEnvironment() { return myHeadlessMode; } + @Override public boolean isCommandLine() { return myCommandLineMode; } + @Override public Future executeOnPooledThread(@NotNull final Runnable action) { return ourThreadExecutorsService.submit(new Runnable() { + @Override public void run() { try { action.run(); @@ -453,6 +472,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application @Override public Future executeOnPooledThread(@NotNull final Callable action) { return ourThreadExecutorsService.submit(new Callable() { + @Override public T call() { try { return action.call(); @@ -474,32 +494,39 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application private static Thread ourDispatchThread = null; + @Override public boolean isDispatchThread() { return EventQueue.isDispatchThread(); } + @Override @NotNull public ModalityInvokator getInvokator() { return myInvokator; } + @Override public void invokeLater(@NotNull final Runnable runnable) { myInvokator.invokeLater(runnable); } + @Override public void invokeLater(@NotNull final Runnable runnable, @NotNull final Condition expired) { myInvokator.invokeLater(runnable, expired); } + @Override public void invokeLater(@NotNull final Runnable runnable, @NotNull final ModalityState state) { myInvokator.invokeLater(runnable, state); } + @Override public void invokeLater(@NotNull final Runnable runnable, @NotNull final ModalityState state, @NotNull final Condition expired) { myInvokator.invokeLater(runnable, state, expired); } + @Override public void load(String path) throws IOException, InvalidDataException { getStateStore().setOptionsPath(path); getStateStore().setConfigPath(PathManager.getConfigPath()); @@ -564,6 +591,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application } + @Override public void dispose() { fireApplicationExiting(); @@ -584,6 +612,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application } } + @Override public boolean runProcessWithProgressSynchronously(@NotNull final Runnable process, @NotNull String progressTitle, boolean canBeCanceled, @@ -591,6 +620,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application return runProcessWithProgressSynchronously(process, progressTitle, canBeCanceled, project, null); } + @Override public boolean runProcessWithProgressSynchronously(@NotNull final Runnable process, @NotNull final String progressTitle, final boolean canBeCanceled, @@ -599,6 +629,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application return runProcessWithProgressSynchronously(process, progressTitle, canBeCanceled, project, parentComponent, null); } + @Override public boolean runProcessWithProgressSynchronously(@NotNull final Runnable process, @NotNull final String progressTitle, final boolean canBeCanceled, @@ -627,12 +658,14 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application myExceptionalThreadWithReadAccessRunnable = process; final boolean[] threadStarted = {false}; SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { if (myExceptionalThreadWithReadAccessRunnable != process) { LOG.error("myExceptionalThreadWithReadAccessRunnable != process, process = " + myExceptionalThreadWithReadAccessRunnable); } executeOnPooledThread(new Runnable() { + @Override public void run() { if (myExceptionalThreadWithReadAccessRunnable != process) { LOG.error("myExceptionalThreadWithReadAccessRunnable != process, process = " + myExceptionalThreadWithReadAccessRunnable); @@ -674,6 +707,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application return !progress.isCanceled(); } + @Override public boolean isInModalProgressThread() { if (myExceptionalThreadWithReadAccessRunnable == null || !isExceptionalThreadWithReadAccess()) { return false; @@ -682,6 +716,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application return progressIndicator.isModal() && ((ProgressIndicatorEx)progressIndicator).isModalityEntered(); } + @Override public void invokeAndWait(@NotNull Runnable runnable, @NotNull ModalityState modalityState) { if (isDispatchThread()) { LOG.error("invokeAndWait must not be called from event queue thread"); @@ -701,12 +736,14 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application LaterInvocator.invokeAndWait(runnable, modalityState); } + @Override @NotNull public ModalityState getCurrentModalityState() { Object[] entities = LaterInvocator.getCurrentModalEntities(); return entities.length > 0 ? new ModalityStateEx(entities) : getNoneModalityState(); } + @Override @NotNull public ModalityState getModalityStateForComponent(@NotNull Component c) { Window window = c instanceof Window ? (Window)c : SwingUtilities.windowForComponent(c); @@ -719,6 +756,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application return ANY; } + @Override @NotNull public ModalityState getDefaultModalityState() { if (EventQueue.isDispatchThread()) { @@ -730,23 +768,28 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application } } + @Override @NotNull public ModalityState getNoneModalityState() { return MODALITY_STATE_NONE; } + @Override public long getStartTime() { return myStartTime; } + @Override public long getIdleTime() { return IdeEventQueue.getInstance().getIdleTime(); } + @Override public void exit() { exit(false); } + @Override public void exit(final boolean force) { exit(force, true); } @@ -757,6 +800,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application } Runnable runnable = new Runnable() { + @Override public void run() { if (!force && !showConfirmation()) { saveAll(); @@ -859,6 +903,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application return true; } + @Override public void runReadAction(@NotNull final Runnable action) { final AccessToken token = acquireReadActionLockImpl(false); @@ -887,6 +932,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application return old; } + @Override public T runReadAction(@NotNull final Computable computation) { final AccessToken token = acquireReadActionLockImpl(false); @@ -898,6 +944,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application } } + @Override public void runWriteAction(@NotNull final Runnable action) { final AccessToken token = acquireWriteActionLock(action.getClass()); try { @@ -908,6 +955,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application } } + @Override public T runWriteAction(@NotNull final Computable computation) { final AccessToken token = acquireWriteActionLock(computation.getClass()); try { @@ -918,16 +966,18 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application } } + @Override public boolean hasWriteAction(@Nullable Class actionClass) { assertCanRunWriteAction(); for (int i = myWriteActionsStack.size() - 1; i >= 0; i--) { Class action = myWriteActionsStack.get(i); - if (actionClass == action || action != null && ReflectionCache.isAssignable(actionClass, action)) return true; + if (actionClass == action || action != null && actionClass != null && ReflectionCache.isAssignable(actionClass, action)) return true; } return false; } + @Override public void assertReadAccessAllowed() { if (myHeadlessMode) return; if (!isReadAccessAllowed()) { @@ -958,6 +1008,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application return null; } + @Override public boolean isReadAccessAllowed() { Thread currentThread = Thread.currentThread(); return ourDispatchThread == currentThread || @@ -971,6 +1022,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application assertIsDispatchThread("Write access is allowed from event dispatch thread only"); } + @Override public void assertIsDispatchThread() { assertIsDispatchThread("Access is allowed from event dispatch thread only."); } @@ -994,6 +1046,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application "SystemEventQueueThread: " + describe(getEventQueueThread())); } + @Override public void runEdtSafeAction(@NotNull Runnable runnable) { Integer value = ourEdtSafe.get(); if (value == null) { @@ -1011,6 +1064,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application } } + @Override public void assertIsDispatchThread(@Nullable final JComponent component) { if (component == null) return; @@ -1031,11 +1085,13 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application } } + @Override public void assertTimeConsuming() { if (myTestModeFlag || myHeadlessMode || ShutDownTracker.isShutdownHookRunning()) return; LOG.assertTrue(!isDispatchThread(), "This operation is time consuming and must not be called on EDT"); } + @Override public boolean tryRunReadAction(@NotNull Runnable action) { /** if we are inside read action, do not try to acquire read lock again since it will deadlock if there is a pending writeAction * see {@link com.intellij.util.concurrency.ReentrantWriterPreferenceReadWriteLock#allowReader()} */ @@ -1084,6 +1140,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application return false; } + @Override public boolean isActive() { if (isUnitTestMode()) return true; @@ -1195,11 +1252,13 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application } } + @Override public void assertWriteAccessAllowed() { LOG.assertTrue(isWriteAccessAllowed(), "Write access is allowed inside write-action only (see com.intellij.openapi.application.Application.runWriteAction())"); } + @Override public boolean isWriteAccessAllowed() { return myActionsLock.isWriteLockAcquired(Thread.currentThread()); } @@ -1213,14 +1272,17 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application LOG.assertTrue(myInEditorPaintCounter >= 0); } + @Override public void addApplicationListener(@NotNull ApplicationListener l) { myDispatcher.addListener(l); } + @Override public void addApplicationListener(@NotNull ApplicationListener l, @NotNull Disposable parent) { myDispatcher.addListener(l, parent); } + @Override public void removeApplicationListener(@NotNull ApplicationListener l) { myDispatcher.removeListener(l); } @@ -1254,6 +1316,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application else { LOG.info("Saving application settings failed", ex); invokeLater(new Runnable() { + @Override public void run() { if (ex instanceof PluginException) { final PluginException pluginException = (PluginException)ex; @@ -1279,11 +1342,13 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application } } + @Override public void saveSettings() { if (myDoNotSave) return; _saveSettings(); } + @Override public void saveAll() { if (myDoNotSave) return; @@ -1298,30 +1363,37 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application saveSettings(); } + @Override public void doNotSave() { doNotSave(true); } + @Override public void doNotSave(boolean value) { myDoNotSave = value; } + @Override public boolean isDoNotSave() { return myDoNotSave; } + @Override public T[] getExtensions(final ExtensionPointName extensionPointName) { return Extensions.getRootArea().getExtensionPoint(extensionPointName).getExtensions(); } + @Override public boolean isDisposeInProgress() { return myDisposeInProgress || ShutDownTracker.isShutdownHookRunning(); } + @Override public boolean isRestartCapable() { return Restarter.isSupported() || myRestartCode > 0; } + @Override public void restart() { boolean restarted = false; try { diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/MarkupModelImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/MarkupModelImpl.java index dbf009d2ea8d..9f291f683e54 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/MarkupModelImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/MarkupModelImpl.java @@ -91,7 +91,7 @@ public class MarkupModelImpl extends UserDataHolderBase implements MarkupModelEx return addRangeHighlighterAndChangeAttributes(offset, offset, layer, textAttributes, HighlighterTargetArea.LINES_IN_RANGE, true, null); } - static int getFirstNonspaceCharOffset(@NotNull Document doc, int lineNumber) { + private static int getFirstNonspaceCharOffset(@NotNull Document doc, int lineNumber) { int lineStart = doc.getLineStartOffset(lineNumber); int lineEnd = doc.getLineEndOffset(lineNumber); CharSequence text = doc.getCharsSequence(); diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorWindow.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorWindow.java index d71329695812..dcb42a23a658 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorWindow.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorWindow.java @@ -430,12 +430,17 @@ public class EditorWindow { else if (myTabbedPane != null) { final boolean focusEditor = ToolWindowManager.getInstance(getManager().getProject()).isEditorComponentActive(); final VirtualFile currentFile = getSelectedFile(); + if (currentFile != null) { + // do not close associated language console on tab placement change + currentFile.putUserData(FileEditorManagerImpl.CLOSING_TO_REOPEN, Boolean.TRUE); + } final VirtualFile[] files = getFiles(); for (VirtualFile file : files) { closeFile(file, false); } disposeTabs(); if (currentFile != null) { + currentFile.putUserData(FileEditorManagerImpl.CLOSING_TO_REOPEN, null); getManager().openFileImpl2(this, currentFile, focusEditor && myOwner.getCurrentWindow() == this); } else { diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/VirtualFilePointerManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/VirtualFilePointerManagerImpl.java index afde58208c46..93d834757446 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/VirtualFilePointerManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/VirtualFilePointerManagerImpl.java @@ -134,23 +134,23 @@ public class VirtualFilePointerManagerImpl extends VirtualFilePointerManager imp } private static boolean startsWith(final String url, final String pointerUrl) { - String urlSuffix = stripSuffix(url); - String pointerPrefix = stripToJarPrefix(pointerUrl); - if (urlSuffix.length() > 0) { - return Comparing.equal(stripToJarPrefix(url), pointerPrefix, SystemInfo.isFileSystemCaseSensitive) && - StringUtil.startsWith(urlSuffix, stripSuffix(pointerUrl)); + String urlSuffix = substringAfterJarSeparator(url); + String pointerPrefix = substringBeforeJarSeparator(pointerUrl); + if (!urlSuffix.isEmpty()) { + return Comparing.equal(substringBeforeJarSeparator(url), pointerPrefix, SystemInfo.isFileSystemCaseSensitive) && + StringUtil.startsWith(urlSuffix, substringAfterJarSeparator(pointerUrl)); } - return FileUtil.startsWith(pointerPrefix, stripToJarPrefix(url)); + return FileUtil.startsWith(pointerPrefix, substringBeforeJarSeparator(url)); } - private static String stripToJarPrefix(String url) { + private static String substringBeforeJarSeparator(String url) { int separatorIndex = url.indexOf(JarFileSystem.JAR_SEPARATOR); if (separatorIndex < 0) return url; return url.substring(0, separatorIndex); } - private static String stripSuffix(String url) { + private static String substringAfterJarSeparator(String url) { int separatorIndex = url.indexOf(JarFileSystem.JAR_SEPARATOR); if (separatorIndex < 0) return ""; return url.substring(separatorIndex + JarFileSystem.JAR_SEPARATOR.length()); diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/jar/JarFileSystemImpl.java b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/jar/JarFileSystemImpl.java index ee58d65f44ba..12337975ee83 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/jar/JarFileSystemImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/jar/JarFileSystemImpl.java @@ -28,6 +28,7 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.*; import com.intellij.openapi.vfs.newvfs.*; import com.intellij.openapi.vfs.newvfs.events.VFileEvent; +import com.intellij.util.ArrayUtil; import com.intellij.util.containers.ConcurrentHashSet; import com.intellij.util.messages.MessageBus; import com.intellij.util.text.CaseInsensitiveStringHashingStrategy; @@ -76,11 +77,10 @@ public class JarFileSystemImpl extends JarFileSystem implements ApplicationCompo String[] jarPaths; synchronized (LOCK) { - if (jarPathsCache == null) { - Set jarPathsSet = myHandlers.keySet(); - jarPathsCache = jarPathsSet.toArray(new String[jarPathsSet.size()]); - } jarPaths = jarPathsCache; + if (jarPaths == null) { + jarPathsCache = jarPaths = ArrayUtil.toStringArray(myHandlers.keySet()); + } } for (String jarPath : jarPaths) { diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ProjectWindowAction.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ProjectWindowAction.java index 250ec9cda7f2..38a8a481a6ba 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ProjectWindowAction.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ProjectWindowAction.java @@ -15,16 +15,19 @@ */ package com.intellij.openapi.wm.impl; -import com.intellij.ide.impl.ProjectUtil; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.actionSystem.ToggleAction; import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectManager; +import com.intellij.openapi.wm.WindowManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.*; +import java.awt.*; + /** * @ author Bas Leijdekkers * This class is programmatically instantiated and registered when opening and closing projects @@ -115,7 +118,15 @@ public class ProjectWindowAction extends ToggleAction implements DumbAware { if (project == null) { return; } - ProjectUtil.focusProjectWindow(project, true); + final JFrame projectFrame = WindowManager.getInstance().getFrame(project); + final int frameState = projectFrame.getExtendedState(); + if ((frameState & Frame.ICONIFIED) == Frame.ICONIFIED) { + // restore the frame if it is minimized + projectFrame.setExtendedState(frameState ^ Frame.ICONIFIED); + } + projectFrame.toFront(); + projectFrame.requestFocus(); + //ProjectUtil.focusProjectWindow(project, true); } @Override diff --git a/platform/util/src/com/intellij/openapi/util/ShutDownTracker.java b/platform/util/src/com/intellij/openapi/util/ShutDownTracker.java index 8cee75fb6bc2..5cddf3912004 100644 --- a/platform/util/src/com/intellij/openapi/util/ShutDownTracker.java +++ b/platform/util/src/com/intellij/openapi/util/ShutDownTracker.java @@ -18,7 +18,6 @@ package com.intellij.openapi.util; import com.intellij.openapi.diagnostic.Logger; import com.intellij.util.concurrency.Semaphore; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.util.ArrayList; @@ -41,6 +40,7 @@ public class ShutDownTracker implements Runnable { private static final ShutDownTracker ourInstance = new ShutDownTracker(); } + @NotNull public static ShutDownTracker getInstance() { return ShutDownTrackerHolder.ourInstance; } @@ -49,6 +49,7 @@ public class ShutDownTracker implements Runnable { return getInstance().myIsShutdownHookRunning; } + @Override public void run() { myIsShutdownHookRunning = true; @@ -128,28 +129,27 @@ public class ShutDownTracker implements Runnable { myShutdownTasks.remove(task); } - @Nullable - private synchronized T removeLast(LinkedList list) { + private synchronized T removeLast(@NotNull LinkedList list) { return list.isEmpty()? null : list.removeLast(); } - public static void invokeAndWait(boolean timed, boolean edt, final Runnable runnable) { + public static void invokeAndWait(boolean timed, boolean edt, @NotNull final Runnable runnable) { if (!edt) { - if (!timed) { + if (timed) { + final Semaphore semaphore = new Semaphore(); + semaphore.down(); + new Thread(new Runnable() { + @Override + public void run() { + runnable.run(); + semaphore.up(); + } + }).start(); + semaphore.waitFor(1000); + } + else { runnable.run(); } - - final Semaphore semaphore = new Semaphore(); - semaphore.down(); - new Thread(new Runnable() { - @Override - public void run() { - runnable.run(); - semaphore.up(); - } - }).start(); - semaphore.waitFor(1000); - return; } diff --git a/platform/util/src/com/intellij/openapi/util/objectTree/ObjectTree.java b/platform/util/src/com/intellij/openapi/util/objectTree/ObjectTree.java index 788456702bbc..4f6734447c02 100644 --- a/platform/util/src/com/intellij/openapi/util/objectTree/ObjectTree.java +++ b/platform/util/src/com/intellij/openapi/util/objectTree/ObjectTree.java @@ -37,14 +37,8 @@ public final class ObjectTree { private final CopyOnWriteArraySet myListeners = new CopyOnWriteArraySet(); // identity used here to prevent problems with hashCode/equals overridden by not very bright minds - private final THashSet myRootObjects = new MyTHashSet(); - private final THashMap> myObject2NodeMap = new THashMap>(TObjectHashingStrategy.IDENTITY) { - public void compact() { - if (((int)(capacity() * _loadFactor)/ Math.max(1, size())) >= 3) { - super.compact(); - } - } - }; + private final THashSet myRootObjects = new THashSet(TObjectHashingStrategy.IDENTITY); + private final THashMap> myObject2NodeMap = new THashMap>(TObjectHashingStrategy.IDENTITY); private final List> myExecutedNodes = new ArrayList>(); private final List myExecutedUnregisteredNodes = new ArrayList(); @@ -118,26 +112,18 @@ public final class ObjectTree { } public final boolean executeAll(@NotNull T object, boolean disposeTree, @NotNull ObjectTreeAction action, boolean processUnregistered) { - try { - ObjectNode node = getNode(object); - if (node == null) { - if (processUnregistered) { - executeUnregistered(object, action); - return true; - } - else { - return false; - } + ObjectNode node = getNode(object); + if (node == null) { + if (processUnregistered) { + executeUnregistered(object, action); + return true; } else { - return node.execute(disposeTree, action); + return false; } } - finally { - synchronized (treeLock) { - myObject2NodeMap.compact(); - myRootObjects.compact(); - } + else { + return node.execute(disposeTree, action); } } @@ -286,18 +272,6 @@ public final class ObjectTree { } } - private static class MyTHashSet extends THashSet { - private MyTHashSet() { - super(IDENTITY); - } - - public void compact() { - if (((int)(capacity() * _loadFactor)/ Math.max(1, size())) >= 3) { - super.compact(); - } - } - } - public long getModification() { return myModification; } diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java index 2736edbb4e0e..255ba36442ad 100644 --- a/platform/util/src/com/intellij/util/ui/UIUtil.java +++ b/platform/util/src/com/intellij/util/ui/UIUtil.java @@ -1399,7 +1399,7 @@ public class UIUtil { @NonNls String fontFamilyAndSize = "font-family:" + font.getFamily() + "; font-size:" + font.getSize() + ";"; @NonNls @Language("HTML") - String body = "body, div, td {" + fontFamilyAndSize + " " + (fgColor != null ? "color:" + ColorUtil.toHex(fgColor) : "") + "}"; + String body = "body, div, td, p {" + fontFamilyAndSize + " " + (fgColor != null ? "color:" + ColorUtil.toHex(fgColor) : "") + "}"; if (resource != null) { body += "ul {list-style-image: " + resource.toExternalForm() +"}"; } diff --git a/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties b/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties index 013f1a273a15..ed07c640c0c5 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties +++ b/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties @@ -1970,4 +1970,5 @@ ambiguous.field.access.hides.parameter.problem.descriptor=Field #ref#ref from super class ''{0}'' accessed, while field access from surrounding class might be expected #loc ambiguous.field.access.quickfix=Qualify field access with 'super.' string.builder.replaceable.by.string.quickfix=Replace 'StringBuilder' with 'String' -string.buffer.replaceable.by.string.quickfix=Replace 'StringBuffer' with 'String' \ No newline at end of file +string.buffer.replaceable.by.string.quickfix=Replace 'StringBuffer' with 'String' +add.0.to.ignore.if.annotated.by.list.quickfix=Add ''{0}'' to ''Ignore if annotated by'' list \ No newline at end of file diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/abstraction/PublicMethodNotExposedInInterfaceInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/abstraction/PublicMethodNotExposedInInterfaceInspection.java index 99224547564d..808ddca84208 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/abstraction/PublicMethodNotExposedInInterfaceInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/abstraction/PublicMethodNotExposedInInterfaceInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2011 Dave Griffith, Bas Leijdekkers + * Copyright 2003-2012 Dave Griffith, Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,14 +17,13 @@ package com.siyeh.ig.abstraction; import com.intellij.codeInsight.AnnotationUtil; import com.intellij.codeInspection.util.SpecialAnnotationsUtil; -import com.intellij.psi.CommonClassNames; -import com.intellij.psi.PsiClass; -import com.intellij.psi.PsiMethod; -import com.intellij.psi.PsiModifier; +import com.intellij.psi.*; import com.intellij.util.ui.CheckBox; import com.siyeh.InspectionGadgetsBundle; import com.siyeh.ig.BaseInspection; import com.siyeh.ig.BaseInspectionVisitor; +import com.siyeh.ig.InspectionGadgetsFix; +import com.siyeh.ig.fixes.AddToIgnoreIfAnnotatedByListQuickFix; import com.siyeh.ig.psiutils.LibraryUtil; import com.siyeh.ig.psiutils.TestUtils; import com.siyeh.ig.ui.ExternalizableStringSet; @@ -57,14 +56,17 @@ public class PublicMethodNotExposedInInterfaceInspection "public.method.not.in.interface.problem.descriptor"); } + @NotNull + @Override + protected InspectionGadgetsFix[] buildFixes(Object... infos) { + return AddToIgnoreIfAnnotatedByListQuickFix.build((PsiModifierListOwner)infos[0], ignorableAnnotations); + } + @Override public JComponent createOptionsPanel() { final JPanel panel = new JPanel(new GridBagLayout()); - final JPanel annotationsListControl = - SpecialAnnotationsUtil.createSpecialAnnotationsListControl( - ignorableAnnotations, - InspectionGadgetsBundle.message( - "ignore.if.annotated.by")); + final JPanel annotationsListControl = SpecialAnnotationsUtil.createSpecialAnnotationsListControl( + ignorableAnnotations, InspectionGadgetsBundle.message("ignore.if.annotated.by")); final GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 0; @@ -74,8 +76,7 @@ public class PublicMethodNotExposedInInterfaceInspection constraints.fill = GridBagConstraints.BOTH; panel.add(annotationsListControl, constraints); final CheckBox checkBox = new CheckBox(InspectionGadgetsBundle.message( - "public.method.not.in.interface.option"), - this, "onlyWarnIfContainingClassImplementsAnInterface"); + "public.method.not.in.interface.option"), this, "onlyWarnIfContainingClassImplementsAnInterface"); constraints.gridy = 1; constraints.weighty = 0.0; constraints.anchor = GridBagConstraints.WEST; @@ -141,7 +142,7 @@ public class PublicMethodNotExposedInInterfaceInspection if (TestUtils.isJUnitTestMethod(method)) { return; } - registerMethodError(method); + registerMethodError(method, method); } private boolean exposedInInterface(PsiMethod method) { diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/classlayout/EmptyClassInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/classlayout/EmptyClassInspection.java index c0e4787d23ee..7b543f7fb266 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/classlayout/EmptyClassInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/classlayout/EmptyClassInspection.java @@ -23,6 +23,8 @@ import com.intellij.util.ui.CheckBox; import com.siyeh.InspectionGadgetsBundle; import com.siyeh.ig.BaseInspection; import com.siyeh.ig.BaseInspectionVisitor; +import com.siyeh.ig.InspectionGadgetsFix; +import com.siyeh.ig.fixes.AddToIgnoreIfAnnotatedByListQuickFix; import com.siyeh.ig.ui.ExternalizableStringSet; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -87,6 +89,16 @@ public class EmptyClassInspection extends BaseInspection { return panel; } + @NotNull + @Override + protected InspectionGadgetsFix[] buildFixes(Object... infos) { + final Object info = infos[0]; + if (!(info instanceof PsiModifierListOwner)) { + return InspectionGadgetsFix.EMPTY_ARRAY; + } + return AddToIgnoreIfAnnotatedByListQuickFix.build((PsiModifierListOwner)info, ignorableAnnotations); + } + @Override public BaseInspectionVisitor buildVisitor() { return new EmptyClassVisitor(); diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/classlayout/UtilityClassInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/classlayout/UtilityClassInspection.java index 3d9a3902ed01..3bfe6cd9aea3 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/classlayout/UtilityClassInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/classlayout/UtilityClassInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Dave Griffith, Bas Leijdekkers + * Copyright 2003-2012 Dave Griffith, Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,31 +15,57 @@ */ package com.siyeh.ig.classlayout; +import com.intellij.codeInsight.AnnotationUtil; +import com.intellij.codeInspection.util.SpecialAnnotationsUtil; import com.intellij.psi.PsiClass; +import com.intellij.psi.PsiModifierListOwner; import com.siyeh.InspectionGadgetsBundle; import com.siyeh.ig.BaseInspection; import com.siyeh.ig.BaseInspectionVisitor; +import com.siyeh.ig.InspectionGadgetsFix; +import com.siyeh.ig.fixes.AddToIgnoreIfAnnotatedByListQuickFix; import com.siyeh.ig.psiutils.UtilityClassUtil; +import com.siyeh.ig.ui.ExternalizableStringSet; import org.jetbrains.annotations.NotNull; +import javax.swing.*; + public class UtilityClassInspection extends BaseInspection { + @SuppressWarnings({"PublicField"}) + public final ExternalizableStringSet ignorableAnnotations = new ExternalizableStringSet(); + + @Override @NotNull public String getDisplayName() { return InspectionGadgetsBundle.message("utility.class.display.name"); } + @Override @NotNull protected String buildErrorString(Object... infos) { return InspectionGadgetsBundle.message( "utility.class.problem.descriptor"); } + @NotNull + @Override + protected InspectionGadgetsFix[] buildFixes(Object... infos) { + return AddToIgnoreIfAnnotatedByListQuickFix.build((PsiModifierListOwner) infos[0], ignorableAnnotations); + } + + @Override + public JComponent createOptionsPanel() { + return SpecialAnnotationsUtil.createSpecialAnnotationsListControl( + ignorableAnnotations, InspectionGadgetsBundle.message("ignore.if.annotated.by")); + } + + @Override public BaseInspectionVisitor buildVisitor() { return new UtilityClassVisitor(); } - private static class UtilityClassVisitor extends BaseInspectionVisitor { + private class UtilityClassVisitor extends BaseInspectionVisitor { @Override public void visitClass(@NotNull PsiClass aClass) { @@ -47,7 +73,10 @@ public class UtilityClassInspection extends BaseInspection { if (!UtilityClassUtil.isUtilityClass(aClass)) { return; } - registerClassError(aClass); + if (AnnotationUtil.isAnnotated(aClass, ignorableAnnotations)) { + return; + } + registerClassError(aClass, aClass); } } } \ No newline at end of file diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/classlayout/UtilityClassWithoutPrivateConstructorInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/classlayout/UtilityClassWithoutPrivateConstructorInspection.java index 84801a054748..722fc10ce773 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/classlayout/UtilityClassWithoutPrivateConstructorInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/classlayout/UtilityClassWithoutPrivateConstructorInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010 Dave Griffith, Bas Leijdekkers + * Copyright 2003-2012 Dave Griffith, Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,8 +15,9 @@ */ package com.siyeh.ig.classlayout; +import com.intellij.codeInsight.AnnotationUtil; import com.intellij.codeInspection.ProblemDescriptor; -import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel; +import com.intellij.codeInspection.util.SpecialAnnotationsUtil; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; import com.intellij.psi.*; @@ -27,25 +28,32 @@ import com.intellij.psi.search.searches.ClassInheritorsSearch; import com.intellij.psi.search.searches.ReferencesSearch; import com.intellij.util.IncorrectOperationException; import com.intellij.util.Query; +import com.intellij.util.ui.CheckBox; import com.siyeh.HardcodedMethodConstants; import com.siyeh.InspectionGadgetsBundle; import com.siyeh.ig.BaseInspection; import com.siyeh.ig.BaseInspectionVisitor; import com.siyeh.ig.InspectionGadgetsFix; +import com.siyeh.ig.fixes.AddToIgnoreIfAnnotatedByListQuickFix; import com.siyeh.ig.psiutils.UtilityClassUtil; +import com.siyeh.ig.ui.ExternalizableStringSet; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; +import java.awt.*; +import java.util.ArrayList; +import java.util.List; public class UtilityClassWithoutPrivateConstructorInspection extends BaseInspection { - /** - * @noinspection PublicField for externalization - */ + @SuppressWarnings({"PublicField"}) public boolean ignoreClassesWithOnlyMain = false; + @SuppressWarnings({"PublicField"}) + public final ExternalizableStringSet ignorableAnnotations = new ExternalizableStringSet(); + @Override @NotNull public String getDisplayName() { @@ -63,30 +71,34 @@ public class UtilityClassWithoutPrivateConstructorInspection @Override @Nullable public JComponent createOptionsPanel() { - return new SingleCheckboxOptionsPanel(InspectionGadgetsBundle.message( - "utility.class.without.private.constructor.option"), this, - "ignoreClassesWithOnlyMain"); + final JPanel panel = new JPanel(new BorderLayout()); + final JPanel annotationsPanel = SpecialAnnotationsUtil.createSpecialAnnotationsListControl( + ignorableAnnotations, InspectionGadgetsBundle.message("ignore.if.annotated.by")); + panel.add(annotationsPanel, BorderLayout.CENTER); + final CheckBox checkBox = new CheckBox(InspectionGadgetsBundle.message("utility.class.without.private.constructor.option"), + this, "ignoreClassesWithOnlyMain"); + panel.add(checkBox, BorderLayout.SOUTH); + return panel; } + @NotNull @Override - protected InspectionGadgetsFix buildFix(Object... infos) { + protected InspectionGadgetsFix[] buildFixes(Object... infos) { + final List fixes = new ArrayList(); final PsiClass aClass = (PsiClass)infos[0]; final PsiMethod constructor = getNullArgConstructor(aClass); if (constructor == null) { - return new CreateEmptyPrivateConstructor(); + fixes.add(new CreateEmptyPrivateConstructor()); } else { - final Query query = - ReferencesSearch.search(constructor, - constructor.getUseScope()); + final Query query = ReferencesSearch.search(constructor, constructor.getUseScope()); final PsiReference reference = query.findFirst(); if (reference == null) { - return new MakeConstructorPrivateFix(); - } - else { - return null; + fixes.add(new MakeConstructorPrivateFix()); } } + AddToIgnoreIfAnnotatedByListQuickFix.build(aClass, ignorableAnnotations, fixes); + return fixes.toArray(new InspectionGadgetsFix[fixes.size()]); } private static class CreateEmptyPrivateConstructor @@ -131,14 +143,12 @@ public class UtilityClassWithoutPrivateConstructorInspection final PsiModifierList modifierList = constructor.getModifierList(); modifierList.setModifierProperty(PsiModifier.PRIVATE, true); aClass.add(constructor); - final CodeStyleManager styleManager = - CodeStyleManager.getInstance(project); + final CodeStyleManager styleManager = CodeStyleManager.getInstance(project); styleManager.reformat(constructor); } } - private static class MakeConstructorPrivateFix - extends InspectionGadgetsFix { + private static class MakeConstructorPrivateFix extends InspectionGadgetsFix { @NotNull public String getName() { @@ -154,13 +164,11 @@ public class UtilityClassWithoutPrivateConstructorInspection if (aClass == null) { return; } - final PsiMethod[] constructurs = aClass.getConstructors(); - for (final PsiMethod constructor : constructurs) { - final PsiParameterList parameterList = - constructor.getParameterList(); + final PsiMethod[] constructors = aClass.getConstructors(); + for (final PsiMethod constructor : constructors) { + final PsiParameterList parameterList = constructor.getParameterList(); if (parameterList.getParametersCount() == 0) { - final PsiModifierList modifiers = - constructor.getModifierList(); + final PsiModifierList modifiers = constructor.getModifierList(); modifiers.setModifierProperty(PsiModifier.PUBLIC, false); modifiers.setModifierProperty(PsiModifier.PROTECTED, false); modifiers.setModifierProperty(PsiModifier.PRIVATE, true); @@ -174,8 +182,7 @@ public class UtilityClassWithoutPrivateConstructorInspection return new UtilityClassWithoutPrivateConstructorVisitor(); } - private class UtilityClassWithoutPrivateConstructorVisitor - extends BaseInspectionVisitor { + private class UtilityClassWithoutPrivateConstructorVisitor extends BaseInspectionVisitor { @Override public void visitClass(@NotNull PsiClass aClass) { @@ -192,10 +199,11 @@ public class UtilityClassWithoutPrivateConstructorInspection if (hasPrivateConstructor(aClass)) { return; } - final SearchScope scope = - GlobalSearchScope.projectScope(aClass.getProject()); - final Query query = - ClassInheritorsSearch.search(aClass, scope, true, true); + if (AnnotationUtil.isAnnotated(aClass, ignorableAnnotations)) { + return; + } + final SearchScope scope = GlobalSearchScope.projectScope(aClass.getProject()); + final Query query = ClassInheritorsSearch.search(aClass, scope, true, true); final PsiClass subclass = query.findFirst(); if (subclass != null) { return; @@ -229,8 +237,7 @@ public class UtilityClassWithoutPrivateConstructorInspection if (!PsiType.VOID.equals(returnType)) { return false; } - final PsiParameterList parameterList = - method.getParameterList(); + final PsiParameterList parameterList = method.getParameterList(); if (parameterList.getParametersCount() != 1) { return false; } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/encapsulation/PublicFieldInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/encapsulation/PublicFieldInspection.java index d85659757e76..aca4a96f814a 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/encapsulation/PublicFieldInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/encapsulation/PublicFieldInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2011 Dave Griffith, Bas Leijdekkers + * Copyright 2003-2012 Dave Griffith, Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import com.siyeh.InspectionGadgetsBundle; import com.siyeh.ig.BaseInspection; import com.siyeh.ig.BaseInspectionVisitor; import com.siyeh.ig.InspectionGadgetsFix; +import com.siyeh.ig.fixes.AddToIgnoreIfAnnotatedByListQuickFix; import com.siyeh.ig.fixes.EncapsulateVariableFix; import com.siyeh.ig.psiutils.ClassUtils; import com.siyeh.ig.ui.ExternalizableStringSet; @@ -31,6 +32,8 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; +import java.util.ArrayList; +import java.util.List; public class PublicFieldInspection extends BaseInspection { @@ -66,10 +69,14 @@ public class PublicFieldInspection extends BaseInspection { return panel; } + @NotNull @Override - protected InspectionGadgetsFix buildFix(Object... infos) { + protected InspectionGadgetsFix[] buildFixes(Object... infos) { + final List fixes = new ArrayList(); final PsiField field = (PsiField)infos[0]; - return new EncapsulateVariableFix(field.getName()); + fixes.add(new EncapsulateVariableFix(field.getName())); + AddToIgnoreIfAnnotatedByListQuickFix.build(field, ignorableAnnotations, fixes); + return fixes.toArray(new InspectionGadgetsFix[fixes.size()]); } @Override diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/fixes/AddToIgnoreIfAnnotatedByListQuickFix.java b/plugins/InspectionGadgets/src/com/siyeh/ig/fixes/AddToIgnoreIfAnnotatedByListQuickFix.java new file mode 100644 index 000000000000..0f8757324903 --- /dev/null +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/fixes/AddToIgnoreIfAnnotatedByListQuickFix.java @@ -0,0 +1,76 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.siyeh.ig.fixes; + +import com.intellij.codeInsight.daemon.QuickFixBundle; +import com.intellij.codeInspection.util.SpecialAnnotationsUtil; +import com.intellij.psi.PsiAnnotation; +import com.intellij.psi.PsiModifierList; +import com.intellij.psi.PsiModifierListOwner; +import com.intellij.util.Processor; +import com.siyeh.InspectionGadgetsBundle; +import com.siyeh.ig.DelegatingFix; +import com.siyeh.ig.InspectionGadgetsFix; +import org.jetbrains.annotations.NonNls; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Bas Leijdekkers + */ +public class AddToIgnoreIfAnnotatedByListQuickFix { + + private AddToIgnoreIfAnnotatedByListQuickFix() {} + + public static InspectionGadgetsFix[] build(PsiModifierListOwner modifierListOwner, List configurationList) { + final List fixes = build(modifierListOwner, configurationList, new ArrayList()); + return fixes.isEmpty() ? InspectionGadgetsFix.EMPTY_ARRAY : fixes.toArray(new InspectionGadgetsFix[fixes.size()]); + } + + public static List build(final PsiModifierListOwner modifierListOwner, + final List configurationList, + final List fixes) { + processAnnotationTexts(modifierListOwner, new Processor() { + @Override + public boolean process(String annotationText) { + fixes.add(new DelegatingFix(SpecialAnnotationsUtil.createAddToSpecialAnnotationsListQuickFix( + InspectionGadgetsBundle.message("add.0.to.ignore.if.annotated.by.list.quickfix", annotationText), + QuickFixBundle.message("fix.add.special.annotation.family"), + configurationList, annotationText, modifierListOwner))); + return true; + } + }); + return fixes; + } + + private static void processAnnotationTexts(final PsiModifierListOwner owner, final Processor processor) { + final PsiModifierList modifierList = owner.getModifierList(); + if (modifierList == null) { + return; + } + final PsiAnnotation[] annotations = modifierList.getAnnotations(); + for (PsiAnnotation annotation : annotations) { + @NonNls final String text = annotation.getText(); + if (text.startsWith("java.") || text.startsWith("javax.") || text.startsWith("org.jetbrains.")) { + continue; + } + if (!processor.process(text)) { + break; + } + } + } +} diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/initialization/InstanceVariableUninitializedUseInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/initialization/InstanceVariableUninitializedUseInspection.java index c2a6b4dfa29d..e692c19069b5 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/initialization/InstanceVariableUninitializedUseInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/initialization/InstanceVariableUninitializedUseInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2011 Dave Griffith, Bas Leijdekkers + * Copyright 2003-2012 Dave Griffith, Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,8 @@ import com.intellij.util.ui.CheckBox; import com.siyeh.InspectionGadgetsBundle; import com.siyeh.ig.BaseInspection; import com.siyeh.ig.BaseInspectionVisitor; +import com.siyeh.ig.InspectionGadgetsFix; +import com.siyeh.ig.fixes.AddToIgnoreIfAnnotatedByListQuickFix; import com.siyeh.ig.psiutils.ClassUtils; import com.siyeh.ig.psiutils.UninitializedReadCollector; import org.jdom.Element; @@ -39,8 +41,7 @@ import java.awt.GridBagLayout; import java.util.ArrayList; import java.util.List; -public class InstanceVariableUninitializedUseInspection - extends BaseInspection { +public class InstanceVariableUninitializedUseInspection extends BaseInspection { /** * @noinspection PublicField @@ -94,10 +95,8 @@ public class InstanceVariableUninitializedUseInspection public JComponent createOptionsPanel() { final JComponent panel = new JPanel(new GridBagLayout()); - final JPanel annotationsPanel = - SpecialAnnotationsUtil.createSpecialAnnotationsListControl( - annotationNames, InspectionGadgetsBundle.message( - "ignore.if.annotated.by")); + final JPanel annotationsPanel = SpecialAnnotationsUtil.createSpecialAnnotationsListControl( + annotationNames, InspectionGadgetsBundle.message("ignore.if.annotated.by")); final CheckBox checkBox = new CheckBox(InspectionGadgetsBundle.message( "primitive.fields.ignore.option"), this, "m_ignorePrimitives"); @@ -117,13 +116,19 @@ public class InstanceVariableUninitializedUseInspection return panel; } + @NotNull + @Override + protected InspectionGadgetsFix[] buildFixes(Object... infos) { + final PsiField field = (PsiField)infos[0]; + return AddToIgnoreIfAnnotatedByListQuickFix.build(field, annotationNames); + } + @Override public BaseInspectionVisitor buildVisitor() { return new InstanceVariableInitializationVisitor(); } - private class InstanceVariableInitializationVisitor - extends BaseInspectionVisitor { + private class InstanceVariableInitializationVisitor extends BaseInspectionVisitor { @Override public void visitField(@NotNull PsiField field) { @@ -133,8 +138,7 @@ public class InstanceVariableUninitializedUseInspection if (field.getInitializer() != null) { return; } - final PsiAnnotation annotation = - AnnotationUtil.findAnnotation(field, annotationNames); + final PsiAnnotation annotation = AnnotationUtil.findAnnotation(field, annotationNames); if (annotation != null) { return; } @@ -154,26 +158,21 @@ public class InstanceVariableUninitializedUseInspection return; } } - final UninitializedReadCollector uninitializedReadsCollector = - new UninitializedReadCollector(); - if (!isInitializedInInitializer(field, - uninitializedReadsCollector)) { + final UninitializedReadCollector uninitializedReadsCollector = new UninitializedReadCollector(); + if (!isInitializedInInitializer(field, uninitializedReadsCollector)) { final PsiMethod[] constructors = aClass.getConstructors(); for (final PsiMethod constructor : constructors) { final PsiCodeBlock body = constructor.getBody(); - uninitializedReadsCollector.blockAssignsVariable(body, - field); + uninitializedReadsCollector.blockAssignsVariable(body, field); } } - final PsiExpression[] badReads = - uninitializedReadsCollector.getUninitializedReads(); + final PsiExpression[] badReads = uninitializedReadsCollector.getUninitializedReads(); for (PsiExpression expression : badReads) { - registerError(expression); + registerError(expression, field); } } - private boolean isInitializedInInitializer( - @NotNull PsiField field, + private boolean isInitializedInInitializer(@NotNull PsiField field, UninitializedReadCollector uninitializedReadsCollector) { final PsiClass aClass = field.getContainingClass(); if (aClass == null) { @@ -183,8 +182,7 @@ public class InstanceVariableUninitializedUseInspection for (final PsiClassInitializer initializer : initializers) { if (!initializer.hasModifierProperty(PsiModifier.STATIC)) { final PsiCodeBlock body = initializer.getBody(); - if (uninitializedReadsCollector.blockAssignsVariable(body, - field)) { + if (uninitializedReadsCollector.blockAssignsVariable(body, field)) { return true; } } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/serialization/NonSerializableFieldInSerializableClassInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/serialization/NonSerializableFieldInSerializableClassInspection.java index a4d462f0eee5..00eb633b7cc9 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/serialization/NonSerializableFieldInSerializableClassInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/serialization/NonSerializableFieldInSerializableClassInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2011 Dave Griffith, Bas Leijdekkers + * Copyright 2006-2012 Dave Griffith, Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,14 +23,15 @@ import com.intellij.psi.PsiField; import com.intellij.psi.PsiModifier; import com.siyeh.InspectionGadgetsBundle; import com.siyeh.ig.BaseInspectionVisitor; +import com.siyeh.ig.InspectionGadgetsFix; +import com.siyeh.ig.fixes.AddToIgnoreIfAnnotatedByListQuickFix; import com.siyeh.ig.psiutils.SerializationUtils; import com.siyeh.ig.ui.ExternalizableStringSet; import org.jetbrains.annotations.NotNull; import javax.swing.*; -public class NonSerializableFieldInSerializableClassInspection - extends SerializableInspection { +public class NonSerializableFieldInSerializableClassInspection extends SerializableInspection { @SuppressWarnings({"PublicField"}) public final ExternalizableStringSet ignorableAnnotations = new ExternalizableStringSet(); @@ -55,6 +56,13 @@ public class NonSerializableFieldInSerializableClassInspection ignorableAnnotations, InspectionGadgetsBundle.message("ignore.if.annotated.by"))}; } + @NotNull + @Override + protected InspectionGadgetsFix[] buildFixes(Object... infos) { + final PsiField field = (PsiField)infos[0]; + return AddToIgnoreIfAnnotatedByListQuickFix.build(field, ignorableAnnotations); + } + @Override public BaseInspectionVisitor buildVisitor() { return new NonSerializableFieldInSerializableClassVisitor(); @@ -90,7 +98,7 @@ public class NonSerializableFieldInSerializableClassInspection if (AnnotationUtil.isAnnotated(field, ignorableAnnotations)) { return; } - registerFieldError(field); + registerFieldError(field, field); } } } \ No newline at end of file diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/EmptyClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/EmptyClass.html index 11084c2b9191..a127f913ffd8 100644 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/EmptyClass.html +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/EmptyClass.html @@ -3,6 +3,7 @@ This inspection reports empty classes and Java files without any defined classes. A class is empty if it doesn't have any fields, methods, constructors or initializers. Empty classes are often left over after large changes or refactorings. +

Use the list below to specify special annotations. Classes annotated with one of these annotations will be ignored by this inspection. diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceVariableUninitializedUse.html b/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceVariableUninitializedUse.html index 58616d14b98e..4b0e5a48b4c1 100644 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceVariableUninitializedUse.html +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceVariableUninitializedUse.html @@ -2,10 +2,14 @@ This inspection reports reads of instance variables which are not yet initialized.

-Use the checkbox below to indicate whether you want uninitialized primitive fields to be reported. -

Note: This inspection uses a very conservative dataflow algorithm, and may report instance variables as uninitialized incorrectly. Variables reported as initialized will always be initialized. + +

+Use the list below to specify special annotations. Fields annotated with one of +these annotations will be ignored by this inspection. +

+Use the checkbox below to indicate whether you want uninitialized primitive fields to be reported.

Powered by InspectionGadgets diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NonSerializableFieldInSerializableClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NonSerializableFieldInSerializableClass.html index 5e38286da202..993ffb6ce652 100644 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/NonSerializableFieldInSerializableClass.html +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NonSerializableFieldInSerializableClass.html @@ -10,12 +10,16 @@ method. For purposes of this inspection, fields with java.util.Map types are assumed to be Serializable, unless the types they are declared to contain are non-Serializable. +

-Use the table below to specify what specific classes and inheritors should be excluded +Use the first list below to specify what specific classes and inheritors should be excluded from being checked by this inspection. This is meant for those classes which, although they inherit Serializable from a superclass, are not intended for serialization. Such classes would lead this inspection to report unnecessarily.

+Use the second list below to specify special annotations. Fields annotated with one of +these annotations will be ignored by this inspection. +

Powered by InspectionGadgets \ No newline at end of file diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/PublicField.html b/plugins/InspectionGadgets/src/inspectionDescriptions/PublicField.html index af58c31186a5..7d0c3238ca8a 100644 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/PublicField.html +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/PublicField.html @@ -2,6 +2,7 @@ This inspection reports public instance variables. Constants (i.e. variables marked static and final) are not reported. +

Use the list below to specify special annotations. Fields annotated with one of these annotations will be ignored by this inspection.

diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/PublicMethodNotExposedInInterface.html b/plugins/InspectionGadgets/src/inspectionDescriptions/PublicMethodNotExposedInInterface.html index bc21479d9c2f..5d50ce17e6d9 100644 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/PublicMethodNotExposedInInterface.html +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/PublicMethodNotExposedInInterface.html @@ -3,6 +3,7 @@ This inspection reports public methods in classes which are not exposed as in interface. Exposing all public methods via interface is important for maintaining loose coupling, and may be necessary for certain component-based programming styles. +

Use the list below to specify special annotations. Methods annotated with one of these annotations will be ignored by this inspection. diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UtilityClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UtilityClass.html index 3ef56b615e82..0db80e730d40 100644 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/UtilityClass.html +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UtilityClass.html @@ -3,6 +3,10 @@ This inspection reports utility classes. Utility classes have all fields and methods declared static, and their presence may indicate a lack of object-oriented design. + +

+Use the list below to specify special annotations. Classes annotated with one of +these annotations will be ignored by this inspection.

Powered by InspectionGadgets diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UtilityClassWithoutPrivateConstructor.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UtilityClassWithoutPrivateConstructor.html index 30544809801f..012ce5634fbc 100644 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/UtilityClassWithoutPrivateConstructor.html +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UtilityClassWithoutPrivateConstructor.html @@ -3,6 +3,12 @@ This inspection reports utility classes which do not have private constructors. Utility classes have all fields and methods declared static. Giving such classes a private constructor prevents them from being inadvertently instantiated. + +

+Use the list below to specify special annotations. Classes annotated with one of +these annotations will be ignored by this inspection. +

+Use the checkbox below to ignore classes which only have a main method and no other methods.

Powered by InspectionGadgets diff --git a/plugins/android/src/org/jetbrains/android/compiler/AndroidAptCompiler.java b/plugins/android/src/org/jetbrains/android/compiler/AndroidAptCompiler.java index 2e0d4d54db6c..6349f4880e33 100644 --- a/plugins/android/src/org/jetbrains/android/compiler/AndroidAptCompiler.java +++ b/plugins/android/src/org/jetbrains/android/compiler/AndroidAptCompiler.java @@ -263,7 +263,7 @@ public class AndroidAptCompiler implements SourceGeneratingCompiler { final String[] libPackages = getLibPackages(module, packageName); final Module circularDepLibWithSamePackage = AndroidCompileUtil.findCircularDependencyOnLibraryWithSamePackage(facet); - if (circularDepLibWithSamePackage != null) { + if (circularDepLibWithSamePackage != null && !facet.getConfiguration().LIBRARY_PROJECT) { myContext.addMessage(CompilerMessageCategory.WARNING, AndroidBundle.message("android.compilation.warning.circular.app.dependency", packageName, module.getName(), diff --git a/plugins/android/src/org/jetbrains/android/compiler/AndroidAutogenerator.java b/plugins/android/src/org/jetbrains/android/compiler/AndroidAutogenerator.java index 623ade3e0a71..c5d4f05b6c48 100644 --- a/plugins/android/src/org/jetbrains/android/compiler/AndroidAutogenerator.java +++ b/plugins/android/src/org/jetbrains/android/compiler/AndroidAutogenerator.java @@ -163,7 +163,7 @@ public class AndroidAutogenerator { final String manifestFileOsPath = FileUtil.toSystemDependentName(manifestFile.getPath()); final Module circularDepLibWithSamePackage = AndroidCompileUtil.findCircularDependencyOnLibraryWithSamePackage(facet); - if (circularDepLibWithSamePackage != null) { + if (circularDepLibWithSamePackage != null && !facet.getConfiguration().LIBRARY_PROJECT) { context.addMessage(CompilerMessageCategory.WARNING, AndroidBundle.message("android.compilation.warning.circular.app.dependency", packageName, module.getName(), circularDepLibWithSamePackage.getName()), null, -1, -1); diff --git a/plugins/android/src/org/jetbrains/android/compiler/AndroidCompileUtil.java b/plugins/android/src/org/jetbrains/android/compiler/AndroidCompileUtil.java index c1db61d2f1bc..53041f9739b3 100644 --- a/plugins/android/src/org/jetbrains/android/compiler/AndroidCompileUtil.java +++ b/plugins/android/src/org/jetbrains/android/compiler/AndroidCompileUtil.java @@ -655,19 +655,20 @@ public class AndroidCompileUtil { final GlobalSearchScope moduleScope = facet.getModule().getModuleScope(); initializeGenSourceRoot(module, AndroidRootUtil.getRenderscriptGenSourceRootPath(facet), - FileTypeIndex.getFiles(AndroidRenderscriptFileType.INSTANCE, moduleScope).size() > 0); + FileTypeIndex.getFiles(AndroidRenderscriptFileType.INSTANCE, moduleScope).size() > 0, true); if (AndroidAptCompiler.isToCompileModule(module, facet.getConfiguration())) { - initializeGenSourceRoot(module, AndroidRootUtil.getAptGenSourceRootPath(facet), true); + initializeGenSourceRoot(module, AndroidRootUtil.getAptGenSourceRootPath(facet), true, true); } else { // we need to include generated-sources/r to compilation, because it contains R.java generated by Maven, // which should be used in Maven-based resource processing mode + initializeGenSourceRoot(module, AndroidRootUtil.getAptGenSourceRootPath(facet), true, false); includeAaptGenSourceRootToCompilation(facet); } initializeGenSourceRoot(module, AndroidRootUtil.getAidlGenSourceRootPath(facet), - FileTypeIndex.getFiles(AndroidIdlFileType.ourFileType, moduleScope).size() > 0); + FileTypeIndex.getFiles(AndroidIdlFileType.ourFileType, moduleScope).size() > 0, true); } private static void includeAaptGenSourceRootToCompilation(AndroidFacet facet) { @@ -686,7 +687,7 @@ public class AndroidCompileUtil { } } - private static void initializeGenSourceRoot(@NotNull Module module, @Nullable String sourceRootPath, boolean createIfNotExist) { + private static void initializeGenSourceRoot(@NotNull Module module, @Nullable String sourceRootPath, boolean createIfNotExist, boolean exclude) { if (sourceRootPath == null) { return; } @@ -701,7 +702,7 @@ public class AndroidCompileUtil { if (sourceRoot == null) { sourceRoot = LocalFileSystem.getInstance().findFileByPath(sourceRootPath); } - if (sourceRoot != null) { + if (sourceRoot != null && exclude) { excludeFromCompilation(module.getProject(), sourceRoot); } } diff --git a/plugins/android/src/org/jetbrains/android/compiler/tools/AndroidMavenExecutor.java b/plugins/android/src/org/jetbrains/android/compiler/tools/AndroidMavenExecutor.java index 3d0d9ff9d037..0798f83d368f 100644 --- a/plugins/android/src/org/jetbrains/android/compiler/tools/AndroidMavenExecutor.java +++ b/plugins/android/src/org/jetbrains/android/compiler/tools/AndroidMavenExecutor.java @@ -19,14 +19,16 @@ import com.intellij.execution.ExecutionException; import com.intellij.execution.configurations.CommandLineBuilder; import com.intellij.execution.configurations.GeneralCommandLine; import com.intellij.execution.configurations.JavaParameters; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.compiler.CompilerMessageCategory; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.module.Module; +import com.intellij.openapi.util.Computable; import com.intellij.util.containers.HashMap; import org.jetbrains.android.util.AndroidUtils; import org.jetbrains.android.util.ExecutionStatus; +import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.maven.execution.MavenExternalParameters; -import org.jetbrains.idea.maven.execution.MavenRunner; import org.jetbrains.idea.maven.execution.MavenRunnerParameters; import org.jetbrains.idea.maven.project.MavenProjectsManager; @@ -42,24 +44,39 @@ public class AndroidMavenExecutor { private static final Logger LOG = Logger.getInstance("#org.jetbrains.android.compiler.tools.AndroidMavenExecutor"); private static final String BUILD_ERROR_INDICATOR = "[error]"; - private static final String FAILED_TO_RESOLVE_ARTIFACT_INDICATOR = "[info] failed to resolve artifact"; private AndroidMavenExecutor() { } - public static Map> generateResources(Module module) { + public static Map> generateResources(final Module module) { MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(module.getProject()); - MavenRunnerParameters parameters = + final MavenRunnerParameters parameters = new MavenRunnerParameters(true, projectsManager.findProject(module).getDirectory(), Collections.singletonList("process-resources"), projectsManager.getExplicitProfiles()); - Map> result = new HashMap>(); + final Map> result = new HashMap>(); result.put(CompilerMessageCategory.ERROR, new ArrayList()); try { - JavaParameters javaParams = MavenExternalParameters.createJavaParameters(module.getProject(), parameters); + JavaParameters javaParams = ApplicationManager.getApplication().runReadAction(new Computable() { + @Nullable + @Override + public JavaParameters compute() { + try { + return MavenExternalParameters.createJavaParameters(module.getProject(), parameters); + } + catch (ExecutionException e) { + LOG.info(e); + result.get(CompilerMessageCategory.ERROR).add(e.getMessage()); + return null; + } + } + }); + if (javaParams == null) { + return result; + } GeneralCommandLine commandLine = CommandLineBuilder.createFromJavaParameters(javaParams); StringBuilder messageBuilder = new StringBuilder(); @@ -70,13 +87,7 @@ public class AndroidMavenExecutor { String lcmessage = message.toLowerCase(); int buildErrorIndex = lcmessage.indexOf(BUILD_ERROR_INDICATOR); if (buildErrorIndex >= 0) { - int failedToResolveIndex = lcmessage.indexOf(FAILED_TO_RESOLVE_ARTIFACT_INDICATOR); - /*if (failedToResolveIndex >= 0) { - result.get(CompilerMessageCategory.ERROR).add("Failed to copy Android resources from Maven artifacts"); - } - else {*/ - result.get(CompilerMessageCategory.ERROR).add(message.substring(buildErrorIndex)); - //} + result.get(CompilerMessageCategory.ERROR).add(message.substring(buildErrorIndex)); } } } diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EclipseClasspathWriter.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EclipseClasspathWriter.java index cb6c69f8f5c5..7e7559287839 100644 --- a/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EclipseClasspathWriter.java +++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EclipseClasspathWriter.java @@ -129,14 +129,21 @@ public class EclipseClasspathWriter { } else { boolean newVarLibrary = false; + + boolean link = false; String eclipseVariablePath = eclipseModuleManager.getEclipseVariablePath(files[0]); + if (eclipseVariablePath == null) { + eclipseVariablePath = eclipseModuleManager.getEclipseLinkedVarPath(files[0]); + link = eclipseVariablePath != null; + } + if (eclipseVariablePath == null && !eclipseModuleManager.isEclipseLibUrl(files[0])) { //new library was added newVarLibrary = true; eclipseVariablePath = EPathUtil.collapse2EclipseVariabledPath(libraryOrderEntry, OrderRootType.CLASSES); } Element orderEntry; if (eclipseVariablePath != null) { - orderEntry = addOrderEntry(EclipseXml.VAR_KIND, eclipseVariablePath, classpathRoot); + orderEntry = addOrderEntry(link ? EclipseXml.LIB_KIND : EclipseXml.VAR_KIND, eclipseVariablePath, classpathRoot); } else { LOG.assertTrue(!StringUtil.isEmptyOrSpaces(files[0]), "Library: " + libraryName); @@ -156,6 +163,9 @@ public class EclipseClasspathWriter { srcRelativePath = EPathUtil.collapse2EclipsePath(srcFile, myModel); if (eclipseVariablePath != null) { eclipseSrcVariablePath = eclipseModuleManager.getEclipseSrcVariablePath(srcFile); + if (eclipseSrcVariablePath == null) { + eclipseSrcVariablePath = eclipseModuleManager.getEclipseLinkedSrcVariablePath(srcFile); + } if (eclipseSrcVariablePath == null) { eclipseSrcVariablePath = EPathUtil.collapse2EclipseVariabledPath(libraryOrderEntry, OrderRootType.SOURCES); if (eclipseSrcVariablePath != null) { diff --git a/plugins/eclipse/testData/linked/resolvedVarsInLibImlCheck1/test/.classpath b/plugins/eclipse/testData/linked/resolvedVarsInLibImlCheck1/test/.classpath new file mode 100644 index 000000000000..f116e23ea584 --- /dev/null +++ b/plugins/eclipse/testData/linked/resolvedVarsInLibImlCheck1/test/.classpath @@ -0,0 +1,5 @@ + + + + + diff --git a/plugins/eclipse/testData/linked/resolvedVarsInLibImlCheck1/test/.project b/plugins/eclipse/testData/linked/resolvedVarsInLibImlCheck1/test/.project new file mode 100644 index 000000000000..af1e53c8465b --- /dev/null +++ b/plugins/eclipse/testData/linked/resolvedVarsInLibImlCheck1/test/.project @@ -0,0 +1,30 @@ + + + eclipse_project + + + + + + org.eclipse.jdt.core.javabuilder + + + + + net.sf.eclipsensis.installoptions.InstallOptionsBuilder + + + + + + org.eclipse.jdt.core.javanature + net.sf.eclipsensis.installoptions.InstallOptionsNature + + + + 3rdParty + 2 + variable/project1 + + + diff --git a/plugins/eclipse/testData/linked/resolvedVarsInLibImlCheck1/variableidea/project1/subdir/empty.jar b/plugins/eclipse/testData/linked/resolvedVarsInLibImlCheck1/variableidea/project1/subdir/empty.jar new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseLinkedResourcesTest.java b/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseLinkedResourcesTest.java index c9851214e3a6..e2dd0a76365b 100644 --- a/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseLinkedResourcesTest.java +++ b/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseLinkedResourcesTest.java @@ -45,4 +45,8 @@ public class EclipseLinkedResourcesTest extends EclipseVarsTest{ public void testResolvedVarsInLibImlCheck() throws Exception { EclipseImlTest.doTest("/test", getProject()); } + + public void testResolvedVarsInLibImlCheck1() throws Exception { + EclipseClasspathTest.doTest("/test", getProject()); + } } diff --git a/plugins/git4idea/src/git4idea/GitRevisionNumber.java b/plugins/git4idea/src/git4idea/GitRevisionNumber.java index 0b7afd0b3bc9..334e7a069fe7 100644 --- a/plugins/git4idea/src/git4idea/GitRevisionNumber.java +++ b/plugins/git4idea/src/git4idea/GitRevisionNumber.java @@ -223,6 +223,11 @@ public class GitRevisionNumber implements ShortVcsRevisionNumber { h.addParameters("--timestamp", "--max-count=1", rev); h.endOptions(); final String output = h.run(); + return parseRevlistOutputAsRevisionNumber(h, output); + } + + @NotNull + public static GitRevisionNumber parseRevlistOutputAsRevisionNumber(@NotNull GitSimpleHandler h, @NotNull String output) { StringTokenizer tokenizer = new StringTokenizer(output, "\n\r \t", false); Date timestamp = GitUtil.parseTimestampWithNFEReport(tokenizer.nextToken(), h, output); return new GitRevisionNumber(tokenizer.nextToken(), timestamp); diff --git a/plugins/git4idea/src/git4idea/commands/GitHandler.java b/plugins/git4idea/src/git4idea/commands/GitHandler.java index f08a21597a60..c6c33d227d2d 100644 --- a/plugins/git4idea/src/git4idea/commands/GitHandler.java +++ b/plugins/git4idea/src/git4idea/commands/GitHandler.java @@ -728,4 +728,9 @@ public abstract class GitHandler { public String toString() { return myCommandLine.toString(); } + + public void dontEscapeQuotes() { + myCommandLine.putUserData(GeneralCommandLine.DO_NOT_ESCAPE_QUOTES, true); + } + } diff --git a/plugins/git4idea/src/git4idea/config/GitVcsPanel.java b/plugins/git4idea/src/git4idea/config/GitVcsPanel.java index 6eedc1507ba3..d031d595c1d1 100644 --- a/plugins/git4idea/src/git4idea/config/GitVcsPanel.java +++ b/plugins/git4idea/src/git4idea/config/GitVcsPanel.java @@ -164,7 +164,7 @@ public class GitVcsPanel { !crlfPolicyItem(settings).equals(myConvertTextFilesComboBox.getSelectedItem()) || !settings.autoUpdateIfPushRejected() == myAutoUpdateIfPushRejected.isSelected() || ((settings.getSyncSetting() == GitBranchSyncSetting.SYNC) != mySyncBranchControl.isSelected() || - settings.isAutoCommitOnCherryPick() == myAutoCommitOnCherryPick.isSelected()); + settings.isAutoCommitOnCherryPick() != myAutoCommitOnCherryPick.isSelected()); } /** diff --git a/plugins/git4idea/src/git4idea/stash/GitStashChangesSaver.java b/plugins/git4idea/src/git4idea/stash/GitStashChangesSaver.java index 3f42006cd2b7..0d551e4d4ee2 100644 --- a/plugins/git4idea/src/git4idea/stash/GitStashChangesSaver.java +++ b/plugins/git4idea/src/git4idea/stash/GitStashChangesSaver.java @@ -79,21 +79,12 @@ public class GitStashChangesSaver extends GitChangesSaver { } public void load() throws VcsException { - Collection conflictedRoots = new ArrayList(); for (VirtualFile root : myStashedRoots) { - boolean conflict = loadRoot(root); - if (conflict) { - conflictedRoots.add(root); - } + loadRoot(root); } boolean conflictsResolved = new UnstashConflictResolver(myProject, myGit, myStashedRoots, myParams).merge(); - if (conflictsResolved) { - LOG.info("load: all conflicts resolved, dropping stash in " + myStashedRoots); - for (VirtualFile root : conflictedRoots) { - GitStashUtils.dropStash(myProject, root); - } - } + LOG.info("load: conflicts resolved status is " + conflictsResolved + " in roots " + myStashedRoots); } @Override diff --git a/plugins/git4idea/src/git4idea/ui/GitUnstashDialog.java b/plugins/git4idea/src/git4idea/ui/GitUnstashDialog.java index 0eeb561ce5a8..a75118b218db 100644 --- a/plugins/git4idea/src/git4idea/ui/GitUnstashDialog.java +++ b/plugins/git4idea/src/git4idea/ui/GitUnstashDialog.java @@ -18,6 +18,7 @@ package git4idea.ui; import com.intellij.notification.Notification; import com.intellij.notification.NotificationListener; import com.intellij.notification.NotificationType; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProgressIndicator; @@ -173,27 +174,18 @@ public class GitUnstashDialog extends DialogWrapper { ProgressManager.getInstance().run(new Task.Modal(myProject, "Removing stash " + stash.getStash(), false) { @Override public void run(@NotNull ProgressIndicator indicator) { - GitSimpleHandler h = dropHandler(stash.getStash()); + final GitSimpleHandler h = dropHandler(stash.getStash()); try { h.run(); h.unsilence(); } - catch (VcsException ex) { - try { - //noinspection HardCodedStringLiteral - if (ex.getMessage().startsWith("fatal: Needed a single revision")) { - h = dropHandler(translateStash(stash.getStash())); - h.run(); + catch (final VcsException ex) { + ApplicationManager.getApplication().invokeLater(new Runnable() { + @Override + public void run() { + GitUIUtil.showOperationError(myProject, ex, h.printableCommandLine()); } - else { - h.unsilence(); - throw ex; - } - } - catch (VcsException ex2) { - GitUIUtil.showOperationError(myProject, ex, h.printableCommandLine()); - return; - } + }); } } }); @@ -205,7 +197,8 @@ public class GitUnstashDialog extends DialogWrapper { private GitSimpleHandler dropHandler(String stash) { GitSimpleHandler h = new GitSimpleHandler(myProject, getGitRoot(), GitCommand.STASH); h.setNoSSH(true); - h.addParameters("drop", stash); + h.addParameters("drop"); + addStashParameter(h, stash); return h; } }); @@ -215,23 +208,18 @@ public class GitUnstashDialog extends DialogWrapper { String resolvedStash; String selectedStash = getSelectedStash().getStash(); try { - resolvedStash = GitRevisionNumber.resolve(myProject, root, selectedStash).asString(); + GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.REV_LIST); + h.setNoSSH(true); + h.setSilent(true); + h.addParameters("--timestamp", "--max-count=1"); + addStashParameter(h, selectedStash); + h.endOptions(); + final String output = h.run(); + resolvedStash = GitRevisionNumber.parseRevlistOutputAsRevisionNumber(h, output).asString(); } catch (VcsException ex) { - try { - //noinspection HardCodedStringLiteral - if (ex.getMessage().startsWith("fatal: bad revision 'stash@")) { - selectedStash = translateStash(selectedStash); - resolvedStash = GitRevisionNumber.resolve(myProject, root, selectedStash).asString(); - } - else { - throw ex; - } - } - catch (VcsException ex2) { - GitUIUtil.showOperationError(myProject, ex, "resolving revision"); - return; - } + GitUIUtil.showOperationError(myProject, ex, "resolving revision"); + return; } GitShowAllSubmittedFilesAction.showSubmittedFiles(myProject, resolvedStash, root); } @@ -241,13 +229,16 @@ public class GitUnstashDialog extends DialogWrapper { } /** - * Translate stash name so that { } are escaped. - * - * @param selectedStash a selected stash - * @return translated name + * Adds {@code stash@{x}} parameter to the handler, quotes it if needed. */ - private static String translateStash(String selectedStash) { - return selectedStash.replaceAll("([\\{}])", "\\\\$1"); + private void addStashParameter(@NotNull GitHandler handler, @NotNull String stash) { + if (GitVersionSpecialty.NEEDS_QUOTES_IN_STASH_NAME.existsIn(myVcs.getVersion())) { + handler.addParameters("\"" + stash + "\""); + handler.dontEscapeQuotes(); + } + else { + handler.addParameters(stash); + } } /** @@ -329,6 +320,7 @@ public class GitUnstashDialog extends DialogWrapper { catch (VcsException e) { // ignore error } + myStashList.setSelectedIndex(0); } /** @@ -339,10 +331,9 @@ public class GitUnstashDialog extends DialogWrapper { } /** - * @param escaped if true stash name will be escaped * @return unstash handler */ - private GitLineHandler handler(boolean escaped) { + private GitLineHandler handler() { GitLineHandler h = new GitLineHandler(myProject, getGitRoot(), GitCommand.STASH); h.setNoSSH(true); String branch = myBranchTextField.getText(); @@ -356,12 +347,7 @@ public class GitUnstashDialog extends DialogWrapper { h.addParameters("branch", branch); } String selectedStash = getSelectedStash().getStash(); - if (escaped) { - selectedStash = translateStash(selectedStash); - } else if (GitVersionSpecialty.NEEDS_QUOTES_IN_STASH_NAME.existsIn(myVcs.getVersion())) { // else if, because escaping {} also solves the issue - selectedStash = "\"" + selectedStash + "\""; - } - h.addParameters(selectedStash); + addStashParameter(h, selectedStash); return h; } @@ -396,6 +382,11 @@ public class GitUnstashDialog extends DialogWrapper { return "reference.VersionControl.Git.Unstash"; } + @Override + public JComponent getPreferredFocusedComponent() { + return myStashList; + } + /** * Show unstash dialog and process its result * @@ -414,32 +405,22 @@ public class GitUnstashDialog extends DialogWrapper { return; } affectedRoots.add(d.getGitRoot()); - GitLineHandler h = d.handler(false); - final AtomicBoolean needToEscapedBraces = new AtomicBoolean(false); + GitLineHandler h = d.handler(); final AtomicBoolean conflict = new AtomicBoolean(); h.addLineListener(new GitLineHandlerAdapter() { public void onLineAvailable(String line, Key outputType) { - if (line.startsWith("fatal: Needed a single revision")) { - needToEscapedBraces.set(true); - } else if (line.contains("Merge conflict")) { + if (line.contains("Merge conflict")) { conflict.set(true); } } }); int rc = GitHandlerUtil.doSynchronously(h, GitBundle.getString("unstash.unstashing"), h.printableCommandLine(), false); - if (needToEscapedBraces.get()) { - h = d.handler(true); - rc = GitHandlerUtil.doSynchronously(h, GitBundle.getString("unstash.unstashing"), h.printableCommandLine(), false); - } if (conflict.get()) { VirtualFile root = d.getGitRoot(); boolean conflictsResolved = new UnstashConflictResolver(project, root, d.getSelectedStash()).merge(); - if (conflictsResolved) { - LOG.info("loadRoot " + root + " conflicts resolved, dropping stash"); - GitStashUtils.dropStash(project, root); - } + LOG.info("loadRoot " + root + ", conflictsResolved: " + conflictsResolved); } else if (rc != 0) { GitUIUtil.showOperationErrors(project, h.errors(), h.printableCommandLine()); } diff --git a/plugins/groovy/src/META-INF/plugin.xml b/plugins/groovy/src/META-INF/plugin.xml index 6c859cfc3554..a271e68e9f9c 100644 --- a/plugins/groovy/src/META-INF/plugin.xml +++ b/plugins/groovy/src/META-INF/plugin.xml @@ -1012,7 +1012,7 @@ - diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/compiler/GroovyCompilerBase.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/compiler/GroovyCompilerBase.java index d546b64d0ebc..c76fad7a4e3c 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/compiler/GroovyCompilerBase.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/compiler/GroovyCompilerBase.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -143,7 +143,7 @@ public abstract class GroovyCompilerBase implements TranslatingCompiler { if (profileGroovyc) { parameters.getVMParametersList().defineProperty("java.library.path", PathManager.getBinPath()); parameters.getVMParametersList().defineProperty("profile.groovy.compiler", "true"); - parameters.getVMParametersList().add("-agentlib:yjpagent=disablej2ee,disablecounts,disablealloc,sessionname=GroovyCompiler"); + parameters.getVMParametersList().add("-agentlib:yjpagent=disablej2ee,disablealloc,sessionname=GroovyCompiler"); classPathBuilder.add(PathManager.findFileInLibDirectory("yjp-controller-api-redist.jar").getAbsolutePath()); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/griffon/GriffonFramework.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/griffon/GriffonFramework.java index 7c96df71a060..37b103725224 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/griffon/GriffonFramework.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/griffon/GriffonFramework.java @@ -55,7 +55,7 @@ import java.util.Map; */ public class GriffonFramework extends MvcFramework { public static final Icon GRIFFON_ICON = IconLoader.getIcon("/icons/griffon/griffon.png"); - public static final Icon GRIFFON_TOOLWINDOW_ICON = IconLoader.getIcon("/icons/griffon/griffonToolWindow.png"); + @NonNls private static final String GRIFFON_COMMON_PLUGINS = "-griffonPlugins"; private static final String GLOBAL_PLUGINS_MODULE_NAME = "GriffonGlobalPlugins"; diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/griffon/GriffonToolWindowFactory.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/griffon/GriffonToolWindowFactory.java index c2f7e1ae647d..d7c0ffa84c13 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/griffon/GriffonToolWindowFactory.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/griffon/GriffonToolWindowFactory.java @@ -92,7 +92,7 @@ public class GriffonToolWindowFactory extends MvcToolWindowDescriptor { @Override public Icon getModuleNodeIcon() { - return GriffonFramework.GRIFFON_TOOLWINDOW_ICON; + return GriffonFramework.GRIFFON_ICON; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcModuleStructureSynchronizer.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcModuleStructureSynchronizer.java index 5043085dee36..c0b2fe7a0f32 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcModuleStructureSynchronizer.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcModuleStructureSynchronizer.java @@ -422,6 +422,7 @@ public class MvcModuleStructureSynchronizer extends AbstractProjectComponent { if (shouldShow && toolWindow == null) { toolWindow = toolWindowManager.registerToolWindow(id, true, ToolWindowAnchor.LEFT, myProject, true); + toolWindow.setIcon(IconLoader.getIcon(ep.icon)); descriptor.createToolWindowContent(myProject, toolWindow); } else if (!shouldShow && toolWindow != null) { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/projectView/MvcToolWindowDescriptor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/projectView/MvcToolWindowDescriptor.java index 9f9e4d8bbd52..ca1d2e31920b 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/projectView/MvcToolWindowDescriptor.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/projectView/MvcToolWindowDescriptor.java @@ -51,7 +51,6 @@ public abstract class MvcToolWindowDescriptor implements ToolWindowFactory, Cond } public void createToolWindowContent(Project project, ToolWindow toolWindow) { - toolWindow.setIcon(myFramework.getIcon()); toolWindow.setAvailable(true, null); toolWindow.setToHideOnEmptyContent(true); toolWindow.setTitle(myFramework.getDisplayName()); diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/MavenProjectImportProvider.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/MavenProjectImportProvider.java index e38981093af8..a068595e4851 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/MavenProjectImportProvider.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/MavenProjectImportProvider.java @@ -23,11 +23,13 @@ package org.jetbrains.idea.maven.wizards; import com.intellij.ide.util.projectWizard.ModuleWizardStep; import com.intellij.ide.util.projectWizard.ProjectWizardStepFactory; import com.intellij.ide.util.projectWizard.WizardContext; +import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.projectImport.ProjectImportProvider; import com.intellij.projectImport.SelectImportedProjectsStep; import org.jetbrains.idea.maven.project.MavenProject; +import org.jetbrains.idea.maven.project.MavenProjectsManager; import java.io.File; @@ -36,7 +38,7 @@ public class MavenProjectImportProvider extends ProjectImportProvider { super(builder); } - public ModuleWizardStep[] createSteps(WizardContext wizardContext) { + public ModuleWizardStep[] createSteps(final WizardContext wizardContext) { final ProjectWizardStepFactory stepFactory = ProjectWizardStepFactory.getInstance(); return new ModuleWizardStep[]{new MavenProjectImportStep(wizardContext), new SelectProfilesStep(wizardContext), new SelectImportedProjectsStep(wizardContext) { @@ -50,9 +52,22 @@ public class MavenProjectImportProvider extends ProjectImportProvider { stringBuilder.append(" [").append(relPath).append("]"); } } + + if (!isElementEnabled(project)) { + stringBuilder.append(" (project is ignored. See Settings -> Maven -> Ignored Files)"); + } + return stringBuilder.toString(); } + @Override + protected boolean isElementEnabled(MavenProject mavenProject) { + Project project = wizardContext.getProject(); + if (project == null) return true; + + return !MavenProjectsManager.getInstance(project).isIgnored(mavenProject); + } + public void updateDataModel() { super.updateDataModel(); getWizardContext().setProjectName(((MavenProjectBuilder)getBuilder()).getSuggestedProjectName()); diff --git a/xml/impl/src/com/intellij/ide/actions/CreateHtmlFileAction.java b/xml/impl/src/com/intellij/ide/actions/CreateHtmlFileAction.java index 7bc5112917cc..cbf690cf4ceb 100644 --- a/xml/impl/src/com/intellij/ide/actions/CreateHtmlFileAction.java +++ b/xml/impl/src/com/intellij/ide/actions/CreateHtmlFileAction.java @@ -43,8 +43,8 @@ public class CreateHtmlFileAction extends CreateFileFromTemplateAction implement protected void buildDialog(Project project, PsiDirectory directory, CreateFileFromTemplateDialog.Builder builder) { builder .setTitle(XmlBundle.message("new.html.file.action")) - .addKind("HTML file", StdFileTypes.HTML.getIcon(), FileTemplateManager.INTERNAL_HTML_TEMPLATE_NAME) - .addKind("HTML5 file", StdFileTypes.HTML.getIcon(), FileTemplateManager.INTERNAL_HTML5_TEMPLATE_NAME) + .addKind("HTML file", StdFileTypes.HTML.getIcon(), FileTemplateManager.INTERNAL_HTML5_TEMPLATE_NAME) + .addKind("HTML4 file", StdFileTypes.HTML.getIcon(), FileTemplateManager.INTERNAL_HTML_TEMPLATE_NAME) .addKind("XHTML file", StdFileTypes.XHTML.getIcon(), FileTemplateManager.INTERNAL_XHTML_TEMPLATE_NAME); } diff --git a/xml/impl/src/com/intellij/javaee/ExternalResourceManagerImpl.java b/xml/impl/src/com/intellij/javaee/ExternalResourceManagerImpl.java index 76a786182ce8..d2119ef9c9e0 100644 --- a/xml/impl/src/com/intellij/javaee/ExternalResourceManagerImpl.java +++ b/xml/impl/src/com/intellij/javaee/ExternalResourceManagerImpl.java @@ -417,7 +417,8 @@ public class ExternalResourceManagerImpl extends ExternalResourceManagerEx imple @Override @NotNull public String getDefaultHtmlDoctype(@NotNull Project project) { - return getProjectResources(project).myDefaultHtmlDoctype; + final String doctype = getProjectResources(project).myDefaultHtmlDoctype; + return XmlUtil.XHTML_URI.equals(doctype) ? XmlUtil.XHTML4_SCHEMA_LOCATION : doctype; } @Override diff --git a/xml/impl/src/com/intellij/javaee/HtmlLanguageLevelForm.java b/xml/impl/src/com/intellij/javaee/HtmlLanguageLevelForm.java index f978d1da683e..ba5f870f9273 100644 --- a/xml/impl/src/com/intellij/javaee/HtmlLanguageLevelForm.java +++ b/xml/impl/src/com/intellij/javaee/HtmlLanguageLevelForm.java @@ -80,7 +80,7 @@ public class HtmlLanguageLevelForm { } public void resetFromDoctype(String doctype) { - if (doctype == null || doctype.length() == 0 || doctype.equals(XmlUtil.XHTML_URI)) { + if (doctype == null || doctype.length() == 0 || doctype.equals(XmlUtil.XHTML4_SCHEMA_LOCATION)) { myHtml4RadioButton.setSelected(true); myDoctypeTextField.setEnabled(false); } diff --git a/xml/impl/src/com/intellij/psi/impl/source/xml/XmlDocumentImpl.java b/xml/impl/src/com/intellij/psi/impl/source/xml/XmlDocumentImpl.java index 2a9ba82516e3..cc2cb22980ed 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/xml/XmlDocumentImpl.java +++ b/xml/impl/src/com/intellij/psi/impl/source/xml/XmlDocumentImpl.java @@ -43,6 +43,7 @@ import com.intellij.psi.util.CachedValueProvider; import com.intellij.psi.xml.*; import com.intellij.util.IncorrectOperationException; import com.intellij.util.containers.ConcurrentHashMap; +import com.intellij.xml.Html5SchemaProvider; import com.intellij.xml.XmlExtension; import com.intellij.xml.XmlNSDescriptor; import com.intellij.xml.util.XmlNSDescriptorSequence; @@ -207,12 +208,19 @@ public class XmlDocumentImpl extends XmlElementImpl implements XmlDocument { if (nsDescriptor == null) { String htmlns = ExternalResourceManagerEx.getInstanceEx().getDefaultHtmlDoctype(getProject()); if (htmlns == null || htmlns.length() == 0) { - htmlns = XmlUtil.XHTML_URI; + htmlns = Html5SchemaProvider.HTML5_SCHEMA_LOCATION; } nsDescriptor = getDefaultNSDescriptor(htmlns, false); } return new HtmlNSDescriptorImpl(nsDescriptor); } + else if (XmlUtil.XHTML_URI.equals(namespace)) { + String xhtmlNamespace = XmlUtil.getDefaultXhtmlNamespace(getProject()); + if (xhtmlNamespace == null || xhtmlNamespace.length() == 0) { + xhtmlNamespace = Html5SchemaProvider.XHTML5_SCHEMA_LOCATION; + } + return getDefaultNSDescriptor(xhtmlNamespace, false); + } else if (namespace != null && namespace != XmlUtil.EMPTY_URI) { if (doctype == null || !namespace.equals(XmlUtil.getDtdUri(doctype))) { boolean documentIsSchemaThatDefinesNs = namespace.equals(XmlUtil.getTargetSchemaNsFromTag(getRootTag())); diff --git a/xml/impl/src/com/intellij/xml/util/XmlUtil.java b/xml/impl/src/com/intellij/xml/util/XmlUtil.java index 8fff78934727..ff45a36b38c3 100644 --- a/xml/impl/src/com/intellij/xml/util/XmlUtil.java +++ b/xml/impl/src/com/intellij/xml/util/XmlUtil.java @@ -19,6 +19,7 @@ import com.intellij.codeInsight.completion.CompletionUtil; import com.intellij.codeInsight.daemon.Validator; import com.intellij.javaee.ExternalResourceManager; import com.intellij.javaee.ExternalResourceManagerEx; +import com.intellij.javaee.ExternalResourceManagerImpl; import com.intellij.javaee.UriUtil; import com.intellij.lang.ASTNode; import com.intellij.lang.Language; @@ -35,9 +36,11 @@ import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.Pair; +import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.CharsetToolkit; import com.intellij.openapi.vfs.LocalFileSystem; +import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.patterns.StandardPatterns; import com.intellij.patterns.StringPattern; @@ -74,6 +77,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.File; +import java.net.URL; import java.util.*; /** @@ -152,10 +156,16 @@ public class XmlUtil { @NonNls public static final String WSDL_SCHEMA_URI = "http://schemas.xmlsoap.org/wsdl/"; public static final Key ORIGINAL_ELEMENT = Key.create("ORIGINAL_ELEMENT"); + public static final String XHTML4_SCHEMA_LOCATION; private XmlUtil() { } + static { + final URL xhtml4SchemaLocationUrl = XmlUtil.class.getResource(ExternalResourceManagerImpl.STANDARD_SCHEMAS + "xhtml1-transitional.xsd"); + XHTML4_SCHEMA_LOCATION = VfsUtil.urlToPath(VfsUtil.fixURLforIDEA(FileUtil.unquote(xhtml4SchemaLocationUrl.toExternalForm()))); + } + @Nullable public static String getSchemaLocation(XmlTag tag, String namespace) { final String uri = ExternalResourceManagerEx.getInstanceEx().getResourceLocation(namespace, tag.getProject()); @@ -604,11 +614,10 @@ public class XmlUtil { } public static String getDefaultXhtmlNamespace(Project project) { - String defaultHtmlDoctype = ExternalResourceManagerEx.getInstanceEx().getDefaultHtmlDoctype(project); - if (Html5SchemaProvider.HTML5_SCHEMA_LOCATION.equals(defaultHtmlDoctype)) { - defaultHtmlDoctype = Html5SchemaProvider.XHTML5_SCHEMA_LOCATION; - } - return defaultHtmlDoctype; + final String doctype = ExternalResourceManagerEx.getInstanceEx().getDefaultHtmlDoctype(project); + return Html5SchemaProvider.HTML5_SCHEMA_LOCATION.equals(doctype) + ? Html5SchemaProvider.XHTML5_SCHEMA_LOCATION + : doctype; } // //public static void expandTag(@NotNull XmlTag tag) {