From 4d3eb320b26935483645af2b5a87e4c3fb25c7c7 Mon Sep 17 00:00:00 2001 From: anna Date: Wed, 28 Dec 2011 12:04:48 +0100 Subject: [PATCH 01/28] junit: avoid NoSuchMethodError when multiple junit versions are found in the classpath (IDEA-79383) --- .../intellij/junit4/JUnit4TestRunnerUtil.java | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/plugins/junit_rt/src/com/intellij/junit4/JUnit4TestRunnerUtil.java b/plugins/junit_rt/src/com/intellij/junit4/JUnit4TestRunnerUtil.java index a58bc2d06605..822325d1ab13 100644 --- a/plugins/junit_rt/src/com/intellij/junit4/JUnit4TestRunnerUtil.java +++ b/plugins/junit_rt/src/com/intellij/junit4/JUnit4TestRunnerUtil.java @@ -15,7 +15,6 @@ */ package com.intellij.junit4; -import com.intellij.rt.execution.junit.JUnitForkedStarter; import org.junit.Ignore; import org.junit.internal.AssumptionViolatedException; import org.junit.internal.requests.ClassRequest; @@ -82,13 +81,10 @@ public class JUnit4TestRunnerUtil { allClasses = JUnit46ClassesRequestBuilder.getClassesRequest(suiteName, classes); } catch (ClassNotFoundException e) { - try { - Class.forName("org.junit.internal.requests.ClassesRequest"); - allClasses = JUnit4ClassesRequestBuilder.getClassesRequest(suiteName, classes); - } - catch (ClassNotFoundException e1) { - allClasses = JUnit45ClassesRequestBuilder.getClassesRequest(suiteName, classes); - } + allClasses = getClassRequestsUsing44API(suiteName, classes); + } + catch (NoSuchMethodError e) { + allClasses = getClassRequestsUsing44API(suiteName, classes); } return classMethods.isEmpty() ? allClasses : allClasses.filterWith(new Filter() { @@ -160,6 +156,18 @@ public class JUnit4TestRunnerUtil { return result.size() == 1 ? Request.aClass((Class)result.get(0)) : Request.classes(getArrayOfClasses(result)); } + private static Request getClassRequestsUsing44API(String suiteName, Class[] classes) { + Request allClasses; + try { + Class.forName("org.junit.internal.requests.ClassesRequest"); + allClasses = JUnit4ClassesRequestBuilder.getClassesRequest(suiteName, classes); + } + catch (ClassNotFoundException e1) { + allClasses = JUnit45ClassesRequestBuilder.getClassesRequest(suiteName, classes); + } + return allClasses; + } + private static void appendTestClass(Vector result, String className) { final Class aClass = loadTestClass(className); if (!result.contains(aClass)) { //do not append classes twice: rerun failed tests from one test suite From d8bffa0d94a681a8c6f86f3c1b07a6d6b19e02e4 Mon Sep 17 00:00:00 2001 From: nik Date: Wed, 28 Dec 2011 15:19:09 +0400 Subject: [PATCH 02/28] jps: jpa test moved to corresponding module --- jps/plugins/jpa/jps-jpa.iml | 1 + jps/{ => plugins/jpa}/testData/jpaTest/jpaTest.iml | 0 jps/{ => plugins/jpa}/testData/jpaTest/jpaTest.ipr | 0 .../jpa}/testData/jpaTest/src/META-INF/persistence.xml | 0 jps/{ => plugins/jpa}/testSrc/org/jetbrains/jps/JpaTest.groovy | 2 +- 5 files changed, 2 insertions(+), 1 deletion(-) rename jps/{ => plugins/jpa}/testData/jpaTest/jpaTest.iml (100%) rename jps/{ => plugins/jpa}/testData/jpaTest/jpaTest.ipr (100%) rename jps/{ => plugins/jpa}/testData/jpaTest/src/META-INF/persistence.xml (100%) rename jps/{ => plugins/jpa}/testSrc/org/jetbrains/jps/JpaTest.groovy (89%) diff --git a/jps/plugins/jpa/jps-jpa.iml b/jps/plugins/jpa/jps-jpa.iml index f8fe61eb4d9e..9d7005eff21a 100644 --- a/jps/plugins/jpa/jps-jpa.iml +++ b/jps/plugins/jpa/jps-jpa.iml @@ -4,6 +4,7 @@ + diff --git a/jps/testData/jpaTest/jpaTest.iml b/jps/plugins/jpa/testData/jpaTest/jpaTest.iml similarity index 100% rename from jps/testData/jpaTest/jpaTest.iml rename to jps/plugins/jpa/testData/jpaTest/jpaTest.iml diff --git a/jps/testData/jpaTest/jpaTest.ipr b/jps/plugins/jpa/testData/jpaTest/jpaTest.ipr similarity index 100% rename from jps/testData/jpaTest/jpaTest.ipr rename to jps/plugins/jpa/testData/jpaTest/jpaTest.ipr diff --git a/jps/testData/jpaTest/src/META-INF/persistence.xml b/jps/plugins/jpa/testData/jpaTest/src/META-INF/persistence.xml similarity index 100% rename from jps/testData/jpaTest/src/META-INF/persistence.xml rename to jps/plugins/jpa/testData/jpaTest/src/META-INF/persistence.xml diff --git a/jps/testSrc/org/jetbrains/jps/JpaTest.groovy b/jps/plugins/jpa/testSrc/org/jetbrains/jps/JpaTest.groovy similarity index 89% rename from jps/testSrc/org/jetbrains/jps/JpaTest.groovy rename to jps/plugins/jpa/testSrc/org/jetbrains/jps/JpaTest.groovy index 32d2ff15ffab..11255f751ab0 100644 --- a/jps/testSrc/org/jetbrains/jps/JpaTest.groovy +++ b/jps/plugins/jpa/testSrc/org/jetbrains/jps/JpaTest.groovy @@ -5,7 +5,7 @@ package org.jetbrains.jps */ class JpaTest extends JpsBuildTestCase { public void testOverwriteArtifacts() throws Exception { - doTest("testData/jpaTest/jpaTest.ipr", null, { + doTest("plugins/jpa/testData/jpaTest/jpaTest.ipr", null, { dir("artifacts") { dir("jpaTest") { dir("WEB-INF") { From 4d6cdd19b95a465880d7174e45862c9939d411dc Mon Sep 17 00:00:00 2001 From: nik Date: Wed, 28 Dec 2011 15:19:52 +0400 Subject: [PATCH 03/28] jps: fixes --- jps/model/src/org/jetbrains/jps/Library.groovy | 4 ++-- jps/model/src/org/jetbrains/jps/Module.groovy | 8 ++++---- jps/plugins/gwt/jps-gwt.iml | 10 +--------- .../org/jetbrains/jps/gwt/GwtModulesSearcherTest.java | 1 - jps/src/org/jetbrains/jps/ProjectBuilder.groovy | 5 +++-- .../org/jetbrains/jps/builders/StandardBuilders.groovy | 4 +++- 6 files changed, 13 insertions(+), 19 deletions(-) diff --git a/jps/model/src/org/jetbrains/jps/Library.groovy b/jps/model/src/org/jetbrains/jps/Library.groovy index 474e0d7ad1e3..4e5fc5fffa82 100644 --- a/jps/model/src/org/jetbrains/jps/Library.groovy +++ b/jps/model/src/org/jetbrains/jps/Library.groovy @@ -23,11 +23,11 @@ class Library extends LazyInitializeableObject implements ClasspathItem { Closure lazyInit = { def meta = new InitializingExpando() meta.classpath = {Object[] arg -> - arg.each { classpath << it } + arg.each { classpath << it.toString() } } meta.src = {Object[] arg -> - arg.each { sourceRoots << it } + arg.each { sourceRoots << it.toString() } } initializer.delegate = meta diff --git a/jps/model/src/org/jetbrains/jps/Module.groovy b/jps/model/src/org/jetbrains/jps/Module.groovy index ae7baafcb8f1..bf21d1ce0a1a 100644 --- a/jps/model/src/org/jetbrains/jps/Module.groovy +++ b/jps/model/src/org/jetbrains/jps/Module.groovy @@ -58,19 +58,19 @@ class Module extends LazyInitializeableObject implements ClasspathItem {//}, Com } meta.content = {Object[] arg -> - arg.each { contentRoots << it} + arg.each { contentRoots << it.toString() } } meta.src = {Object[] arg -> - arg.each { sourceRoots << it } + arg.each { sourceRoots << it.toString() } } meta.testSrc = {Object[] arg -> - arg.each { testRoots << it } + arg.each { testRoots << it.toString() } } meta.exclude = {Object[] arg -> - arg.each { excludes << it } + arg.each { excludes << it.toString() } } initializer.delegate = meta diff --git a/jps/plugins/gwt/jps-gwt.iml b/jps/plugins/gwt/jps-gwt.iml index b5a325a384ba..621daa2f0ea8 100644 --- a/jps/plugins/gwt/jps-gwt.iml +++ b/jps/plugins/gwt/jps-gwt.iml @@ -11,15 +11,7 @@ - - - - - - - - - + diff --git a/jps/plugins/gwt/testSrc/org/jetbrains/jps/gwt/GwtModulesSearcherTest.java b/jps/plugins/gwt/testSrc/org/jetbrains/jps/gwt/GwtModulesSearcherTest.java index 0a1d17892aba..0375f1105c49 100644 --- a/jps/plugins/gwt/testSrc/org/jetbrains/jps/gwt/GwtModulesSearcherTest.java +++ b/jps/plugins/gwt/testSrc/org/jetbrains/jps/gwt/GwtModulesSearcherTest.java @@ -5,7 +5,6 @@ import junit.framework.TestCase; import java.util.Arrays; import java.util.HashSet; import java.util.List; -import java.util.Set; /** * @author nik diff --git a/jps/src/org/jetbrains/jps/ProjectBuilder.groovy b/jps/src/org/jetbrains/jps/ProjectBuilder.groovy index 29a397ba907b..22b5ead3770d 100644 --- a/jps/src/org/jetbrains/jps/ProjectBuilder.groovy +++ b/jps/src/org/jetbrains/jps/ProjectBuilder.groovy @@ -94,11 +94,12 @@ class ProjectBuilder { if (chunk.elements.size() > 1) { File outputDir if (targetFolder != null) { - def basePath = tests ? new File(targetFolder, "test").absolutePath : new File(targetFolder, "production").absolutePath + def basePath = forTests ? new File(targetFolder, "test").absolutePath : new File(targetFolder, "production").absolutePath + def name = chunk.name if (name.length() > 100) { name = name.substring(0, 100) + "_etc" } - outputDir = new File(basePath, name).absolutePath + outputDir = new File(basePath, name) } else { outputDir = new File(forTests ? chunk.representativeModule().testOutputPath : chunk.representativeModule().outputPath) diff --git a/jps/src/org/jetbrains/jps/builders/StandardBuilders.groovy b/jps/src/org/jetbrains/jps/builders/StandardBuilders.groovy index 9c326160a20f..daecae206150 100644 --- a/jps/src/org/jetbrains/jps/builders/StandardBuilders.groovy +++ b/jps/src/org/jetbrains/jps/builders/StandardBuilders.groovy @@ -60,7 +60,9 @@ class JavacBuilder implements ModuleBuilder, ModuleCycleBuilder { params.debug = String.valueOf(debugInfo); params.nowarn = String.valueOf(nowarn); params.deprecation = String.valueOf(deprecation); - params.verbose = "true" + if (state.projectWrapper != null) { + params.verbose = "true" + } def javacExecutable = getJavacExecutable(module) if (javacExecutable != null) { From d1c692b35d3888de8fffccad7f1886d3bc33910b Mon Sep 17 00:00:00 2001 From: nik Date: Wed, 28 Dec 2011 15:32:59 +0400 Subject: [PATCH 04/28] jps plugins modules added to project --- .idea/modules.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.idea/modules.xml b/.idea/modules.xml index 1f2298ba989d..3712cc836f1b 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -57,8 +57,13 @@ + + + + + From b9fc77c4339eb2a939527f151d097f0b97926bf4 Mon Sep 17 00:00:00 2001 From: nik Date: Wed, 28 Dec 2011 15:33:17 +0400 Subject: [PATCH 05/28] jps artifacts configured --- .idea/artifacts/jps.xml | 27 +++++++++++++++++++++++++++ .idea/artifacts/jps_plugins.xml | 12 ++++++++++++ .idea/artifacts/jps_sources.xml | 15 +++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 .idea/artifacts/jps.xml create mode 100644 .idea/artifacts/jps_plugins.xml create mode 100644 .idea/artifacts/jps_sources.xml diff --git a/.idea/artifacts/jps.xml b/.idea/artifacts/jps.xml new file mode 100644 index 000000000000..dfbf48d9121b --- /dev/null +++ b/.idea/artifacts/jps.xml @@ -0,0 +1,27 @@ + + + $PROJECT_DIR$/out/artifacts/jps + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/artifacts/jps_plugins.xml b/.idea/artifacts/jps_plugins.xml new file mode 100644 index 000000000000..fee03eee74f7 --- /dev/null +++ b/.idea/artifacts/jps_plugins.xml @@ -0,0 +1,12 @@ + + + $PROJECT_DIR$/out/artifacts/jps + + + + + + + + + \ No newline at end of file diff --git a/.idea/artifacts/jps_sources.xml b/.idea/artifacts/jps_sources.xml new file mode 100644 index 000000000000..2cd42352db97 --- /dev/null +++ b/.idea/artifacts/jps_sources.xml @@ -0,0 +1,15 @@ + + + $PROJECT_DIR$/out/artifacts/jps + + + + + + + + + + + + \ No newline at end of file From 7ff4ca271c307b8a7e7a334538c90147577339ae Mon Sep 17 00:00:00 2001 From: Oleg Shpynov Date: Wed, 28 Dec 2011 15:50:23 +0400 Subject: [PATCH 06/28] EA-32740 --- .../jetbrains/plugins/github/GithubUtil.java | 79 +++++++------------ 1 file changed, 27 insertions(+), 52 deletions(-) diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubUtil.java b/plugins/github/src/org/jetbrains/plugins/github/GithubUtil.java index b9cf47431b05..3be5b107733e 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/GithubUtil.java +++ b/plugins/github/src/org/jetbrains/plugins/github/GithubUtil.java @@ -66,31 +66,21 @@ public class GithubUtil { return url.startsWith("https://") ? url.substring(8) : url.startsWith("http://") ? url.substring(7) : url.startsWith("git@") ? url.substring(4) : url; } - public static T accessToGithubWithModalProgress(final Project project, final Computable computable) throws CancelledException { + public static T accessToGithubWithModalProgress(final Project project, final Computable computable) { final Ref result = new Ref(); ProgressManager.getInstance().run(new Task.Modal(project, "Access to GitHub", true) { public void run(@NotNull ProgressIndicator indicator) { result.set(computable.compute()); } - - @Override - public void onCancel() { - throw new CancelledException(); - } }); return result.get(); } - public static void accessToGithubWithModalProgress(final Project project, final Runnable runnable) throws CancelledException { + public static void accessToGithubWithModalProgress(final Project project, final Runnable runnable) { ProgressManager.getInstance().run(new Task.Modal(project, "Access to GitHub", true) { public void run(@NotNull ProgressIndicator indicator) { runnable.run(); } - - @Override - public void onCancel() { - throw new CancelledException(); - } }); } @@ -246,8 +236,6 @@ public class GithubUtil { }); } - public static class CancelledException extends RuntimeException {} - /** * Shows GitHub login settings if credentials are wrong or empty and return the list of all the watched repos by user * @param project @@ -263,20 +251,15 @@ public class GithubUtil { } } // Otherwise our credentials are valid and they are successfully stored in settings - try { - final GithubSettings settings = GithubSettings.getInstance(); - final String validPassword = settings.getPassword(); - return accessToGithubWithModalProgress(project, new Computable>() { - @Override - public List compute() { - ProgressManager.getInstance().getProgressIndicator().setText("Extracting info about available repositories"); - return getAvailableRepos(settings.getHost(), settings.getLogin(), validPassword, ownOnly); - } - }); - } - catch (CancelledException e) { - return null; - } + final GithubSettings settings = GithubSettings.getInstance(); + final String validPassword = settings.getPassword(); + return accessToGithubWithModalProgress(project, new Computable>() { + @Override + public List compute() { + ProgressManager.getInstance().getProgressIndicator().setText("Extracting info about available repositories"); + return getAvailableRepos(settings.getHost(), settings.getLogin(), validPassword, ownOnly); + } + }); } /** @@ -288,17 +271,14 @@ public class GithubUtil { public static RepositoryInfo getDetailedRepositoryInfo(final Project project, final String owner, final String name) { final GithubSettings settings = GithubSettings.getInstance(); final String password = settings.getPassword(); - final boolean validCredentials; - try { - validCredentials = accessToGithubWithModalProgress(project, new Computable() { - @Override - public Boolean compute() { - ProgressManager.getInstance().getProgressIndicator().setText("Trying to login to GitHub"); - return testConnection(settings.getHost(), settings.getLogin(), password); - } - }); - } - catch (CancelledException e) { + final Boolean validCredentials = accessToGithubWithModalProgress(project, new Computable() { + @Override + public Boolean compute() { + ProgressManager.getInstance().getProgressIndicator().setText("Trying to login to GitHub"); + return testConnection(settings.getHost(), settings.getLogin(), password); + } + }); + if (validCredentials == null) { return null; } if (!validCredentials){ @@ -309,19 +289,14 @@ public class GithubUtil { } } // Otherwise our credentials are valid and they are successfully stored in settings - try { - final String validPassword = settings.getPassword(); - return accessToGithubWithModalProgress(project, new Computable() { - @Override - public RepositoryInfo compute() { - ProgressManager.getInstance().getProgressIndicator().setText("Extracting detailed info about repository ''" + name + "''"); - return getDetailedRepoInfo(settings.getHost(), settings.getLogin(), validPassword, owner, name); - } - }); - } - catch (CancelledException e) { - return null; - } + final String validPassword = settings.getPassword(); + return accessToGithubWithModalProgress(project, new Computable() { + @Override + public RepositoryInfo compute() { + ProgressManager.getInstance().getProgressIndicator().setText("Extracting detailed info about repository ''" + name + "''"); + return getDetailedRepoInfo(settings.getHost(), settings.getLogin(), validPassword, owner, name); + } + }); } @Nullable From c423dc43dc01c086505c0eeb102bf9ef8933d4d4 Mon Sep 17 00:00:00 2001 From: Oleg Shpynov Date: Wed, 28 Dec 2011 16:19:30 +0400 Subject: [PATCH 07/28] Compilation fixed --- .../plugins/github/GithubShareAction.java | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java b/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java index 3134de7f1fb7..e043f207ba3e 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java +++ b/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java @@ -14,7 +14,6 @@ import com.intellij.openapi.project.DumbAwareAction; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Computable; -import com.intellij.openapi.util.IconLoader; import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.Ref; import com.intellij.openapi.vcs.VcsException; @@ -37,7 +36,6 @@ import git4idea.i18n.GitBundle; import git4idea.ui.GitUIUtil; import org.jetbrains.plugins.github.ui.GithubShareDialog; -import javax.swing.*; import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -98,17 +96,14 @@ public class GithubShareAction extends DumbAwareAction { final GithubSettings settings = GithubSettings.getInstance(); final String password = settings.getPassword(); - final boolean privateRepoAllowed; - try { - privateRepoAllowed = GithubUtil.accessToGithubWithModalProgress(project, new Computable() { - @Override - public Boolean compute() { - ProgressManager.getInstance().getProgressIndicator().setText("Trying to login to GitHub"); - return GithubUtil.isPrivateRepoAllowed(settings.getHost(), settings.getLogin(), password); - } - }); - } - catch (GithubUtil.CancelledException ex) { + final Boolean privateRepoAllowed = GithubUtil.accessToGithubWithModalProgress(project, new Computable() { + @Override + public Boolean compute() { + ProgressManager.getInstance().getProgressIndicator().setText("Trying to login to GitHub"); + return GithubUtil.isPrivateRepoAllowed(settings.getHost(), settings.getLogin(), password); + } + }); + if (privateRepoAllowed == null) { return; } final GithubShareDialog shareDialog = new GithubShareDialog(project, names, privateRepoAllowed); From d5d06f613ae255cdb53329b600ffd4f1bfb304e9 Mon Sep 17 00:00:00 2001 From: Sergey Evdokimov Date: Wed, 28 Dec 2011 16:15:22 +0300 Subject: [PATCH 08/28] Cosmetic bug fix: Change title of "Flip == to ==" to "Flip '=='" like in java intention com.siyeh.ipp.bool.FlipComparisonIntention --- .../intentions/GroovyIntentionsBundle.properties | 12 ++++++------ .../intentions/control/FlipComparisonIntention.java | 4 ++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/GroovyIntentionsBundle.properties b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/GroovyIntentionsBundle.properties index f5e53960a867..5f9d36c8c1ca 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/GroovyIntentionsBundle.properties +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/GroovyIntentionsBundle.properties @@ -5,8 +5,8 @@ intention.category.comments=Comments intention.category.groovy.style=Groovy-style intention.category.control.flow=Control Flow demorgans.law.intention.family.name=DeMorgan's Law -demorgans.intention.name1=Replace \\&\\& with || -demorgans.intention.name2=Replace || with \\&\\& +demorgans.intention.name1=Replace ''\\&\\&'' with ''||'' +demorgans.intention.name2=Replace ''||'' with ''\\&\\&'' merge.if.and.intention.name=Merge if's merge.if.and.intention.family.name=Merge Nested Ifs To ANDed Condition make.closure.call.explicit.intention.name=Make closure call explicit @@ -32,9 +32,9 @@ convert.integer.to.octal.intention.name=Convert to octal convert.integer.to.octal.intention.family.name=Convert To Octal convert.integer.to.binary.intention.name=Convert to binary convert.integer.to.binary.intention.family.name=Convert To Binary -flip.comparison.intention.name=Flip {0} to {1} -negate.comparison.intention.name=Negate {0} to {1} -flip.smth.intention.name=Flip {0} +flip.comparison.intention.name=Flip ''{0}'' to ''{1}'' +negate.comparison.intention.name=Negate ''{0}'' to ''{1}'' +flip.smth.intention.name=Flip ''{0}'' merge.else.if.intention.name=Merge else-if merge.else.if.intention.family.name=Merge Else If split.else.if.intention.name=Split else-if @@ -43,7 +43,7 @@ split.if.intention.name=Split into 2 if's split.if.intention.family.name=Split into 2 if's invert.if.intention.name=Invert If Condition invert.if.intention.family.name=Invert If Condition -flip.conditional.intention.name=Flip ?: +flip.conditional.intention.name=Flip ''?:'' flip.conditional.intention.family.name=Flip Conditional conditional.to.elvis.intention.name=Convert Conditional to Elvis conditional.to.elvis.intention.family.name=Convert Conditional diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/control/FlipComparisonIntention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/control/FlipComparisonIntention.java index 639c3db3b54e..1517bb072ac5 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/control/FlipComparisonIntention.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/control/FlipComparisonIntention.java @@ -37,6 +37,10 @@ public class FlipComparisonIntention extends MutablyNamedIntention { final String comparison = ComparisonUtils.getStringForComparison(tokenType); final String flippedComparison = ComparisonUtils.getFlippedComparison(tokenType); + if (comparison.equals(flippedComparison)) { + return GroovyIntentionsBundle.message("flip.smth.intention.name", comparison); + } + return GroovyIntentionsBundle.message("flip.comparison.intention.name", comparison, flippedComparison); } From 65c8a7e494ddc0e09064e563d335274fc93db0ab Mon Sep 17 00:00:00 2001 From: anna Date: Wed, 28 Dec 2011 12:49:11 +0100 Subject: [PATCH 09/28] EA-32770 - assert: MoveFilesOrDirectoriesUtil.doMoveFile --- .../move/moveFilesOrDirectories/MoveFilesOrDirectoriesUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/refactoring/move/moveFilesOrDirectories/MoveFilesOrDirectoriesUtil.java b/platform/lang-impl/src/com/intellij/refactoring/move/moveFilesOrDirectories/MoveFilesOrDirectoriesUtil.java index ef10be43254e..87711a25bdc9 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/move/moveFilesOrDirectories/MoveFilesOrDirectoriesUtil.java +++ b/platform/lang-impl/src/com/intellij/refactoring/move/moveFilesOrDirectories/MoveFilesOrDirectoriesUtil.java @@ -83,7 +83,7 @@ public class MoveFilesOrDirectoriesUtil { try { final VirtualFile virtualFile = file.getVirtualFile(); - assert virtualFile != null; + LOG.assertTrue(virtualFile != null, file); virtualFile.move(manager, newDirectory.getVirtualFile()); } catch (IOException e) { From f7b796bbb9041401460100a75d8ee58b7d630fdf Mon Sep 17 00:00:00 2001 From: anna Date: Wed, 28 Dec 2011 12:53:04 +0100 Subject: [PATCH 10/28] EA-31584 - NPE: DependencyNodeComparator.compare --- .../packageDependencies/ui/DependencyNodeComparator.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/packageDependencies/ui/DependencyNodeComparator.java b/platform/lang-impl/src/com/intellij/packageDependencies/ui/DependencyNodeComparator.java index ebf9a1808b31..32b4f6247802 100644 --- a/platform/lang-impl/src/com/intellij/packageDependencies/ui/DependencyNodeComparator.java +++ b/platform/lang-impl/src/com/intellij/packageDependencies/ui/DependencyNodeComparator.java @@ -16,6 +16,8 @@ package com.intellij.packageDependencies.ui; +import com.intellij.openapi.util.Comparing; + import java.util.Comparator; public class DependencyNodeComparator implements Comparator{ @@ -36,6 +38,6 @@ public class DependencyNodeComparator implements Comparator Date: Wed, 28 Dec 2011 13:16:58 +0100 Subject: [PATCH 11/28] move via dnd: do not move package in directory when target module contains multiple directories for the package (EA-30802 - AIOOBE: MoveClassesOrPackagesProcessor.performRefactoring) --- .../moveClassesOrPackages/JavaMoveClassesOrPackagesHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/JavaMoveClassesOrPackagesHandler.java b/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/JavaMoveClassesOrPackagesHandler.java index 95f450575d7a..d454f2d99151 100644 --- a/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/JavaMoveClassesOrPackagesHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/JavaMoveClassesOrPackagesHandler.java @@ -246,7 +246,7 @@ public class JavaMoveClassesOrPackagesHandler extends MoveHandlerDelegate { final Module module = LangDataKeys.TARGET_MODULE.getData(dataContext); if (module != null) { final PsiDirectory[] directories = ((PsiPackage)targetContainer).getDirectories(GlobalSearchScope.moduleScope(module)); - if (directories.length > 0) { + if (directories.length == 1) { return directories[0]; } } From ec76f6982419a07028fa8fb424fe51f408218c58 Mon Sep 17 00:00:00 2001 From: anna Date: Wed, 28 Dec 2011 13:32:38 +0100 Subject: [PATCH 12/28] EA-32493 - UOE: AopPointcutExpressionFindUsagesProvider.getDescriptiveName --- .../com/intellij/refactoring/util/ConflictsUtil.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/java/java-impl/src/com/intellij/refactoring/util/ConflictsUtil.java b/java/java-impl/src/com/intellij/refactoring/util/ConflictsUtil.java index 902ae2547824..0ae871c7447f 100644 --- a/java/java-impl/src/com/intellij/refactoring/util/ConflictsUtil.java +++ b/java/java-impl/src/com/intellij/refactoring/util/ConflictsUtil.java @@ -21,6 +21,7 @@ package com.intellij.refactoring.util; import com.intellij.psi.*; +import com.intellij.psi.impl.source.resolve.FileContextUtil; import com.intellij.psi.util.PsiFormatUtil; import com.intellij.psi.util.PsiUtil; import com.intellij.refactoring.RefactoringBundle; @@ -37,9 +38,16 @@ public class ConflictsUtil { public static PsiElement getContainer(PsiElement place) { PsiElement parent = place; while (true) { - if (parent instanceof PsiMember && !(parent instanceof PsiTypeParameter)) + if (parent instanceof PsiMember && !(parent instanceof PsiTypeParameter)) { return parent; - if (parent instanceof PsiFile) return parent; + } + if (parent instanceof PsiFile) { + PsiElement host = FileContextUtil.getFileContext((PsiFile)parent); + if (host == null) { + return parent; + } + parent = host; + } parent = parent.getParent(); } } From 7ffa73e5b15ad1b3b5456979a31e31fd9ca8d485 Mon Sep 17 00:00:00 2001 From: anna Date: Wed, 28 Dec 2011 13:37:27 +0100 Subject: [PATCH 13/28] base refactoring processor: do not proceed with the refactoring if find usages throws an exception EA-32497 - assert: BaseRefactoringProcessor.doRun --- .../intellij/refactoring/BaseRefactoringProcessor.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/platform/lang-impl/src/com/intellij/refactoring/BaseRefactoringProcessor.java b/platform/lang-impl/src/com/intellij/refactoring/BaseRefactoringProcessor.java index e97159e220cb..b65b5e289ff8 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/BaseRefactoringProcessor.java +++ b/platform/lang-impl/src/com/intellij/refactoring/BaseRefactoringProcessor.java @@ -149,6 +149,7 @@ public abstract class BaseRefactoringProcessor { final Ref refErrorLanguage = new Ref(); final Ref refProcessCanceled = new Ref(); final Ref dumbModeOccurred = new Ref(); + final Ref anyException = new Ref(); final Runnable findUsagesRunnable = new Runnable() { @Override @@ -170,6 +171,9 @@ public abstract class BaseRefactoringProcessor { catch (IndexNotReadyException e) { dumbModeOccurred.set(Boolean.TRUE); } + catch (Throwable e) { + anyException.set(Boolean.TRUE); + } } }; @@ -191,6 +195,10 @@ public abstract class BaseRefactoringProcessor { return; } + if (!anyException.isNull()) { + //do not proceed if find usages fails + return; + } assert !refUsages.isNull(): "Null usages from processor " + this; if (!preprocessUsages(refUsages)) return; final UsageInfo[] usages = refUsages.get(); From e91319d6e2ca5e7eb9d6905496c57c7b53e53775 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 28 Dec 2011 13:41:28 +0100 Subject: [PATCH 14/28] EA-31247 more diagnostics for failed stub-ast binding --- .../extapi/psi/StubBasedPsiElementBase.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/platform/core-impl/src/com/intellij/extapi/psi/StubBasedPsiElementBase.java b/platform/core-impl/src/com/intellij/extapi/psi/StubBasedPsiElementBase.java index 3e723b6d87e2..c38b1e3f54be 100644 --- a/platform/core-impl/src/com/intellij/extapi/psi/StubBasedPsiElementBase.java +++ b/platform/core-impl/src/com/intellij/extapi/psi/StubBasedPsiElementBase.java @@ -76,7 +76,7 @@ public class StubBasedPsiElementBase extends ASTDelegateP FileElement treeElement = file.getTreeElement(); StubTree stubTree = file.getStubTree(); if (treeElement != null) { - throw new AssertionError("this="+this+"; file.isPhysical="+file.isPhysical() + "; node=" + myNode + "; file=" + file + "; tree=" + treeElement + "; stubTree=" + stubTree); + return notBoundInExistingAst(file, treeElement, stubTree); } final FileElement fileElement = file.loadTreeElement(); node = myNode; @@ -104,6 +104,26 @@ public class StubBasedPsiElementBase extends ASTDelegateP return node; } + private ASTNode notBoundInExistingAst(PsiFileImpl file, FileElement treeElement, StubTree stubTree) { + String message = "this=" + this + + "; file.isPhysical=" + file.isPhysical() + + "; node=" + myNode + + "; file=" + file + + "; tree=" + treeElement + + "; stubTree=" + stubTree; + PsiElement each = this; + while (each != null) { + message += "\n each=" + each + " of class " + each.getClass(); + if (each instanceof StubBasedPsiElementBase) { + message += "; node=" + ((StubBasedPsiElementBase)each).myNode + "; stub=" + ((StubBasedPsiElementBase)each).myStub; + each = ((StubBasedPsiElementBase)each).getParentByStub(); + } else { + break; + } + } + throw new AssertionError(message); + } + public void setNode(final ASTNode node) { myNode = node; } From 45e18bd409dd736ecfbf20b27bfec217a19da885 Mon Sep 17 00:00:00 2001 From: nik Date: Wed, 28 Dec 2011 16:49:07 +0400 Subject: [PATCH 15/28] added run configuration for JPS tests --- .idea/modules.xml | 17 +++++++------- .idea/runConfigurations/JPS_tests.xml | 33 +++++++++++++++++++++++++++ jps/jps-tests.iml | 16 +++++++++++++ 3 files changed, 58 insertions(+), 8 deletions(-) create mode 100644 .idea/runConfigurations/JPS_tests.xml create mode 100644 jps/jps-tests.iml diff --git a/.idea/modules.xml b/.idea/modules.xml index 3712cc836f1b..c95d45fbe908 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -56,14 +56,15 @@ - - - - - - - - + + + + + + + + + diff --git a/.idea/runConfigurations/JPS_tests.xml b/.idea/runConfigurations/JPS_tests.xml new file mode 100644 index 000000000000..c60f67c434ce --- /dev/null +++ b/.idea/runConfigurations/JPS_tests.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/jps/jps-tests.iml b/jps/jps-tests.iml new file mode 100644 index 000000000000..38b2f30cb1e4 --- /dev/null +++ b/jps/jps-tests.iml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + From bd4891595267225f4cd301ed8253da5eb5330d4d Mon Sep 17 00:00:00 2001 From: nik Date: Wed, 28 Dec 2011 16:55:11 +0400 Subject: [PATCH 16/28] jps: fixed test on Windows --- jps/testSrc/org/jetbrains/jps/ModuleInitTest.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jps/testSrc/org/jetbrains/jps/ModuleInitTest.groovy b/jps/testSrc/org/jetbrains/jps/ModuleInitTest.groovy index dd20ae33ff73..7ff8e118e50e 100644 --- a/jps/testSrc/org/jetbrains/jps/ModuleInitTest.groovy +++ b/jps/testSrc/org/jetbrains/jps/ModuleInitTest.groovy @@ -4,7 +4,7 @@ class ModuleInitTest extends JpsBuildTestCase { public void testBasePath() { Project project = loadProject("testData/moduleCycle/moduleCycle.ipr", [:]); for (def name: ['module1', 'module2']) { - assertTrue(project.modules[name].basePath.endsWith(File.separator + name)); + assertTrue(project.modules[name].basePath.endsWith("/" + name)); } } } From cefb68d840433bff746895d56a40dd5c7434e706 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 28 Dec 2011 14:09:59 +0100 Subject: [PATCH 17/28] fix this$0 groovyc problem --- jps/src/org/jetbrains/jps/builders/StandardBuilders.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jps/src/org/jetbrains/jps/builders/StandardBuilders.groovy b/jps/src/org/jetbrains/jps/builders/StandardBuilders.groovy index daecae206150..92e395bf7549 100644 --- a/jps/src/org/jetbrains/jps/builders/StandardBuilders.groovy +++ b/jps/src/org/jetbrains/jps/builders/StandardBuilders.groovy @@ -281,7 +281,7 @@ class GroovyStubGenerator implements ModuleBuilder { } class JetBrainsInstrumentations implements ModuleBuilder { - class CustomFormInstrumenter extends + static class CustomFormInstrumenter extends FormInstrumenter { final List formFiles; final ModuleBuildState state; From 347883d9fc458116171ccfb225a478d96370d879 Mon Sep 17 00:00:00 2001 From: nik Date: Wed, 28 Dec 2011 17:17:00 +0400 Subject: [PATCH 18/28] jps: types fixed --- jps/src/org/jetbrains/jps/builders/StandardBuilders.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jps/src/org/jetbrains/jps/builders/StandardBuilders.groovy b/jps/src/org/jetbrains/jps/builders/StandardBuilders.groovy index 92e395bf7549..babacca78d33 100644 --- a/jps/src/org/jetbrains/jps/builders/StandardBuilders.groovy +++ b/jps/src/org/jetbrains/jps/builders/StandardBuilders.groovy @@ -283,7 +283,7 @@ class GroovyStubGenerator implements ModuleBuilder { class JetBrainsInstrumentations implements ModuleBuilder { static class CustomFormInstrumenter extends FormInstrumenter { - final List formFiles; + final List formFiles; final ModuleBuildState state; @Override @@ -306,7 +306,7 @@ class JetBrainsInstrumentations implements ModuleBuilder { throw new RuntimeException(msg); } - CustomFormInstrumenter(final File destDir, final List nestedFormPathList, final List ff, final ModuleBuildState s) { + CustomFormInstrumenter(final File destDir, final List nestedFormPathList, final List ff, final ModuleBuildState s) { super(destDir, nestedFormPathList); formFiles = ff; state = s; From 9e32f737a2e679f43534328815577e3e79751824 Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Wed, 28 Dec 2011 16:55:35 +0400 Subject: [PATCH 19/28] InspectionProfileEntry.getShortName() default implementation --- .../codeInspection/InspectionProfileEntry.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/platform/lang-api/src/com/intellij/codeInspection/InspectionProfileEntry.java b/platform/lang-api/src/com/intellij/codeInspection/InspectionProfileEntry.java index 61a2c8020a73..07eab0479b42 100644 --- a/platform/lang-api/src/com/intellij/codeInspection/InspectionProfileEntry.java +++ b/platform/lang-api/src/com/intellij/codeInspection/InspectionProfileEntry.java @@ -21,6 +21,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.WriteExternalException; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.ResourceUtil; import com.intellij.util.xmlb.SerializationFilter; import com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters; @@ -66,12 +67,20 @@ public abstract class InspectionProfileEntry { public abstract String getDisplayName(); /** + * This method is not supposed to be overridden. * @return short name that is used in two cases: \inspectionDescriptions\<short_name>.html resource may contain short inspection * description to be shown in "Inspect Code..." dialog and also provide some file name convention when using offline * inspection or export to HTML function. Should be unique among all inspections. + * @see InspectionEP#shortName */ @NonNls @NotNull - public abstract String getShortName(); + public String getShortName() { + return getShortName(getClass()); + } + + public static String getShortName(Class aClass) { + return StringUtil.trimEnd(aClass.getSimpleName(), "Inspection"); + } /** * @return highlighting level for this inspection tool that is used in default settings. From e405e12a216281b47520294a6a1bb0cfe3fc5869 Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Wed, 28 Dec 2011 16:57:19 +0400 Subject: [PATCH 20/28] running devkit tests on their own classpath --- plugins/devkit/devkit.iml | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/devkit/devkit.iml b/plugins/devkit/devkit.iml index 996d0202eb8c..e9caa7d79161 100644 --- a/plugins/devkit/devkit.iml +++ b/plugins/devkit/devkit.iml @@ -25,6 +25,7 @@ + From f710215221cbb2d9dca96d295317df45a699e396 Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Wed, 28 Dec 2011 16:58:55 +0400 Subject: [PATCH 21/28] running test inspections by language + inspection language fixes --- .../ex/InspectionToolWrapper.java | 8 ++++++-- .../ex/LocalInspectionToolWrapper.java | 4 ++++ .../impl/CodeInsightTestFixtureImpl.java | 18 +++++++++++++++--- resources/src/META-INF/IdeaPlugin.xml | 2 +- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionToolWrapper.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionToolWrapper.java index 4123e2f6736b..2a9609e47a9a 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionToolWrapper.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionToolWrapper.java @@ -40,12 +40,16 @@ public abstract class InspectionToolWrapper myExtensions = new HashMap(); public CodeInsightTestFixtureImpl(IdeaProjectTestFixture projectFixture, TempDirTestFixture tempDirTestFixture) { myProjectFixture = projectFixture; @@ -1024,6 +1026,10 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(false); ensureIndexesUpToDate(getProject()); ((StartupManagerImpl)StartupManagerEx.getInstanceEx(getProject())).runPostStartupActivities(); + LocalInspectionEP[] extensions = Extensions.getExtensions(LocalInspectionEP.LOCAL_INSPECTION); + for (LocalInspectionEP extension : extensions) { + myExtensions.put(extension.shortName, extension); + } } @Override @@ -1057,9 +1063,15 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig HighlightDisplayKey.register(shortName, tool.getDisplayName(), id); } myAvailableTools.put(shortName, tool); - myAvailableLocalTools.put(shortName, tool instanceof LocalInspectionTool ? - new LocalInspectionToolWrapper((LocalInspectionTool)tool) : - (InspectionTool)tool); + InspectionTool inspectionTool; + if (tool instanceof LocalInspectionTool) { + LocalInspectionEP ep = myExtensions.get(tool.getShortName()); + inspectionTool = new LocalInspectionToolWrapper((LocalInspectionTool)tool, ep); + } + else { + inspectionTool = (InspectionTool)tool; + } + myAvailableLocalTools.put(shortName, inspectionTool); } private void configureInspections(final InspectionProfileEntry[] tools) { diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml index cb291100c94c..67cf4dc7faa9 100644 --- a/resources/src/META-INF/IdeaPlugin.xml +++ b/resources/src/META-INF/IdeaPlugin.xml @@ -430,7 +430,7 @@ - Date: Wed, 28 Dec 2011 13:13:13 +0400 Subject: [PATCH 22/28] close popup on second combo click --- .../openapi/wm/impl/ToolWindowImpl.java | 2 +- .../wm/impl/content/ContentComboLabel.java | 2 +- .../wm/impl/content/ToolWindowContentUi.java | 27 ++++++++++++++++--- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowImpl.java index 7b25a70d32b6..3e302e59735f 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowImpl.java @@ -434,7 +434,7 @@ public final class ToolWindowImpl implements ToolWindowEx { } public void showContentPopup(InputEvent inputEvent) { - myContentUI.showContentPopup(inputEvent); + myContentUI.toggleContentPopup(inputEvent); } @Override diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ContentComboLabel.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ContentComboLabel.java index 0267330d2410..868c303cb024 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ContentComboLabel.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ContentComboLabel.java @@ -52,7 +52,7 @@ public class ContentComboLabel extends BaseLabel { super.processMouseEvent(e); if (UIUtil.isActionClick(e)) { - myUi.showContentPopup(e); + myUi.toggleContentPopup(e); } } diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ToolWindowContentUi.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ToolWindowContentUi.java index f546e5eeafab..491c441c4cc9 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ToolWindowContentUi.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ToolWindowContentUi.java @@ -21,7 +21,7 @@ import com.intellij.ide.actions.ShowContentAction; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.actionSystem.impl.ActionManagerImpl; import com.intellij.openapi.actionSystem.impl.MenuItemPresentationFactory; -import com.intellij.openapi.ui.popup.JBPopupFactory; +import com.intellij.openapi.ui.popup.ListPopup; import com.intellij.openapi.ui.popup.ListSeparator; import com.intellij.openapi.ui.popup.PopupStep; import com.intellij.openapi.ui.popup.util.BaseListPopupStep; @@ -34,6 +34,7 @@ import com.intellij.ui.awt.RelativeRectangle; import com.intellij.ui.content.*; import com.intellij.ui.content.tabs.PinToolwindowTabAction; import com.intellij.ui.content.tabs.TabbedContentAction; +import com.intellij.ui.popup.list.ListPopupImpl; import com.intellij.ui.switcher.SwitchProvider; import com.intellij.ui.switcher.SwitchTarget; import com.intellij.util.ui.UIUtil; @@ -76,6 +77,7 @@ public class ToolWindowContentUi extends JPanel implements ContentUI, PropertyCh ContentLayout myComboLayout = new ComboContentLayout(this); private ToolWindowContentUiType myType = ToolWindowContentUiType.TABBED; + private boolean myShouldNotShowPopup; public ToolWindowContentUi(ToolWindowImpl window) { myWindow = window; @@ -420,7 +422,11 @@ public class ToolWindowContentUi extends JPanel implements ContentUI, PropertyCh return getCurrentLayout() == layout; } - public void showContentPopup(InputEvent inputEvent) { + public void toggleContentPopup(InputEvent inputEvent) { + if (myShouldNotShowPopup) { + myShouldNotShowPopup = false; + return; + } BaseListPopupStep step = new BaseListPopupStep(null, myManager.getContents()) { @Override public PopupStep onChosen(Content selectedValue, boolean finalChoice) { @@ -453,8 +459,21 @@ public class ToolWindowContentUi extends JPanel implements ContentUI, PropertyCh }; step.setDefaultOptionIndex(Arrays.asList(myManager.getContents()).indexOf(myManager.getSelectedContent())); - getCurrentLayout().showContentPopup(JBPopupFactory.getInstance().createListPopup(step)); - + final ListPopup popup = new ListPopupImpl(step) { + @Override + public void cancel(InputEvent e) { + super.cancel(e); + if (e instanceof MouseEvent) { + final MouseEvent me = (MouseEvent)e; + final Component component = SwingUtilities.getDeepestComponentAt(e.getComponent(), me.getX(), me.getY()); + if (UIUtil.isActionClick(me) && component instanceof ContentComboLabel && + SwingUtilities.isDescendingFrom(component, ToolWindowContentUi.this)) { + myShouldNotShowPopup = true; + } + } + } + }; + getCurrentLayout().showContentPopup(popup); } public List getTargets(boolean onlyVisible, boolean originalProvider) { From d26039455e46a9687b4d4ddacdd4ef21ac77644d Mon Sep 17 00:00:00 2001 From: Dennis Ushakov Date: Wed, 28 Dec 2011 18:20:38 +0400 Subject: [PATCH 23/28] added scroll from source action to titlebar --- platform/icons/src/general/divider.png | Bin 0 -> 1004 bytes platform/icons/src/general/locate.png | Bin 0 -> 1418 bytes .../ide/projectView/impl/ProjectViewImpl.java | 26 ++++++++++- .../openapi/wm/impl/InternalDecorator.java | 4 ++ .../openapi/wm/impl/ToolWindowHeader.java | 42 ++++++++++++++---- 5 files changed, 62 insertions(+), 10 deletions(-) create mode 100644 platform/icons/src/general/divider.png create mode 100644 platform/icons/src/general/locate.png diff --git a/platform/icons/src/general/divider.png b/platform/icons/src/general/divider.png new file mode 100644 index 0000000000000000000000000000000000000000..ea797b974d888d7e1823e2cf1383e34b800517c6 GIT binary patch literal 1004 zcmaJ=J8aWH7FqDc)s6vb^hyg|lnclYc6zW?>z{bJ$LK>uJr zMNtF!8LdS217w{%a)|t2W#Q=QN1H} zrHZTiW!XdyV?;ho=y(K8QJKlmGt7C2!7QA!U4`C#wMhfpQs^t9&gotj*6o>PAC{L3 z6?1vslq`Dk0?33iA#flzK4N7KdM~M}UIba>Lm)C-+~g*B zFp*^VBqt@MaUgI!$MOQprQ$p%iz%7oLF=PQG~cSpC2hJDi`*2tjTHucGUI%yE;zCJHRElpYK13gUXTz*%A!UqHmJH)rO-`o}BfefstQ9XrbN3 zVjW==)R70WWs%{5ZkVg1Wv>)*}} xg|TBBV~LH}>gaHKY^U(>=QaOD&yz<~FZJf|Q0&CjU%S!!%jXK()2SPG{{Wj{JnaAg literal 0 HcmV?d00001 diff --git a/platform/icons/src/general/locate.png b/platform/icons/src/general/locate.png new file mode 100644 index 0000000000000000000000000000000000000000..82ba59505afe2de43c1719fb20cc58d8825c230c GIT binary patch literal 1418 zcmeAS@N?(olHy`uVBq!ia0vp^d_XL~!3HGNrubO_DajJoh?3y^w370~qErUQl>DSr z1<%~X^wgl##FWaylc_cg49qH-ArU1JzCKpT`MG+DAT@dwxdlMo3=B5*6$OdO*{LN8 zNvY|XdA3ULckfqH$V{%1*XSQL?vFu&J;D8jzb> zlBiITo0C^;Rbi_HHrEQs1_|pcDS(xfWZNo192Makpx~Tel&WB=XP}#GU}mUbW};_k zVqj@vsiRh+i#(Mch>H3D2mX`VkM*2oZxQ#zd*q`*i_F@!8b8E zGY=#J*5T`G<(XGpl9-pA>gi&u1T;f0Gc(1?#LUIf(Z$rj$kN=>(9qS;(#hP=)zQ_& z!o|YC(bUl#rq?AuximL5uLPzy1)eUB2MjsTlNKp+F0;V4j6P|E^9C*@C%>$d+yv?S$+NWT`N|+2wae4J;CC_1n2ef`?vl3 z^YioE`S$f}Z*OdTEOlq4gKv(FjZOB_rAvPvI(*ps*YDrljb;W71|7UY%qJVKG+b%= zvY~;)%xs&KprBxCef|HC^78M!4h#7mmLG~KJ$L>3ce#MGzrVh|e*WLr*WtVYYx)?U zTv@VY$#GLtQ})IjIRW{uy$d9cJ!f3WxRUjw2)qqDQ|&zXY%|7y#`{Qb}WFMogU@9~o-PqOgHtZ~%W*5+Oo85!yL?;ram z<|3wKSJ$I|j~zSK95JW;QO*RZ2~iW|0yzGNi-_FeD_Q32;BY`%pjfd(dPL_GT z+<(5#blqsNvghYyy%QW>G_uqKec~A!`n95<;Db~`j65q>?QxIQ7pADNADQH!!y#JD mf8>1Q55p5`Gn^V2m>E{?;V6)oHl7G79X(zBT-G@yGywpd0}Gb` literal 0 HcmV?d00001 diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java index d7b3b7dfea22..a8fc864f69c3 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java @@ -21,6 +21,7 @@ import com.intellij.history.LocalHistory; import com.intellij.history.LocalHistoryAction; import com.intellij.ide.*; import com.intellij.ide.FileEditorProvider; +import com.intellij.ide.actions.CollapseAllToolbarAction; import com.intellij.ide.impl.ProjectViewSelectInTarget; import com.intellij.ide.projectView.HelpID; import com.intellij.ide.projectView.ProjectView; @@ -69,6 +70,7 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.wm.*; import com.intellij.openapi.wm.ex.ToolWindowManagerAdapter; import com.intellij.openapi.wm.ex.ToolWindowManagerEx; +import com.intellij.openapi.wm.impl.InternalDecorator; import com.intellij.openapi.wm.impl.ToolWindowImpl; import com.intellij.openapi.wm.impl.content.ToolWindowContentUi; import com.intellij.psi.*; @@ -471,6 +473,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo myViewContentPanel.revalidate(); myViewContentPanel.repaint(); createToolbarActions(); + updateTitleActions(); newPane.setTreeChangeListener(myTreeChangeListener); myAutoScrollToSourceHandler.install(newPane.myTree); @@ -506,6 +509,25 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo myAutoScrollToSourceHandler.onMouseClicked(newPane.myTree); } + private void updateTitleActions() { + final ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow("Project"); + if (window == null) return; + final InternalDecorator decorator = ((ToolWindowImpl)window).getDecorator(); + ScrollFromSourceAction scrollAction = null; + CollapseAllToolbarAction collapseAction = null; + for (AnAction action : myActionGroup.getChildren(null)) { + if (action instanceof ScrollFromSourceAction) { + scrollAction = (ScrollFromSourceAction)action; + myActionGroup.remove(scrollAction); + } + if (action instanceof CollapseAllToolbarAction) { + collapseAction = (CollapseAllToolbarAction)action; + myActionGroup.remove(collapseAction); + } + } + decorator.setTitleActions(new AnAction[] {scrollAction, collapseAction}); + } + // public for tests public synchronized void setupImpl(final ToolWindow toolWindow) { setupImpl(toolWindow, true); @@ -670,7 +692,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo return true; } }, getComponent()); - myActionGroup.add(collapseAllAction); + //myActionGroup.add(collapseAllAction); getCurrentProjectViewPane().addToolbarActions(myActionGroup); } @@ -1732,7 +1754,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo private class ScrollFromSourceAction extends AnAction implements DumbAware { private ScrollFromSourceAction() { - super("Scroll from Source", "Select the file open in the active editor", IconLoader.getIcon("/general/autoscrollFromSource.png")); + super("Scroll from Source", "Select the file open in the active editor", IconLoader.getIcon("/general/locate.png")); } @Override diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/InternalDecorator.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/InternalDecorator.java index 24bb21a9c8fa..3f09393c3616 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/InternalDecorator.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/InternalDecorator.java @@ -334,6 +334,10 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); } + public void setTitleActions(AnAction[] actions) { + myHeader.setAdditionalTitleActions(actions); + } + private static class InnerPanelBorder implements Border { private final ToolWindow myWindow; diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowHeader.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowHeader.java index 73b627a60a5c..141317e87c2c 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowHeader.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowHeader.java @@ -63,6 +63,7 @@ public abstract class ToolWindowHeader extends JPanel implements Disposable { private static final Icon ourHideDownIcon = IconLoader.getIcon("/general/hideDownPart.png"); private static final Icon ourSettingsIcon = IconLoader.getIcon("/general/gear.png"); + private static final Icon ourSeparatorIcon = IconLoader.getIcon("/general/divider.png"); private ToolWindow myToolWindow; private WindowInfoImpl myInfo; @@ -70,6 +71,8 @@ public abstract class ToolWindowHeader extends JPanel implements Disposable { private BufferedImage myImage; private BufferedImage myActiveImage; private ToolWindowType myImageType; + private JPanel myButtonPanel; + private final ToolWindowHeader.ActionButton myGearButton; public ToolWindowHeader(final ToolWindowImpl toolWindow, WindowInfoImpl info, @NotNull final Producer gearProducer) { setLayout(new BorderLayout()); @@ -106,12 +109,13 @@ public abstract class ToolWindowHeader extends JPanel implements Disposable { eastPanel.setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 3)); add(eastPanel, BorderLayout.EAST); - eastPanel.add(new ActionButton(new AnAction() { + myGearButton = new ActionButton(new AnAction() { @Override public void actionPerformed(AnActionEvent e) { final InputEvent inputEvent = e.getInputEvent(); final ActionPopupMenu popupMenu = - ((ActionManagerImpl)ActionManager.getInstance()).createActionPopupMenu(ToolWindowContentUi.POPUP_PLACE, gearProducer.produce(), new MenuItemPresentationFactory(true)); + ((ActionManagerImpl)ActionManager.getInstance()) + .createActionPopupMenu(ToolWindowContentUi.POPUP_PLACE, gearProducer.produce(), new MenuItemPresentationFactory(true)); int x = 0; int y = 0; @@ -122,9 +126,7 @@ public abstract class ToolWindowHeader extends JPanel implements Disposable { popupMenu.getComponent().show(inputEvent.getComponent(), x, y); } - }, ourSettingsIcon)); - - eastPanel.add(Box.createHorizontalStrut(3)); + }, ourSettingsIcon); myHideButton = new ActionButton(new HideAction() { @Override @@ -137,7 +139,7 @@ public abstract class ToolWindowHeader extends JPanel implements Disposable { sideHidden(); } }, - ourHideLeftSideIcon, null, null + ourHideLeftSideIcon, null, null ) { @Override protected Icon getActiveIcon() { @@ -150,7 +152,8 @@ public abstract class ToolWindowHeader extends JPanel implements Disposable { } }; - eastPanel.add(myHideButton); + addDefaultActions(eastPanel); + myButtonPanel = eastPanel; addMouseListener(new PopupHandler() { public void invokePopup(final Component comp, final int x, final int y) { @@ -180,6 +183,13 @@ public abstract class ToolWindowHeader extends JPanel implements Disposable { setBorder(BorderFactory.createEmptyBorder(TabsUtil.TABS_BORDER, 1, TabsUtil.TABS_BORDER, 1)); } + private void addDefaultActions(JPanel eastPanel) { + eastPanel.add(myGearButton); + eastPanel.add(Box.createHorizontalStrut(6)); + eastPanel.add(myHideButton); + eastPanel.add(Box.createHorizontalStrut(1)); + } + @Override public void dispose() { removeAll(); @@ -192,7 +202,23 @@ public abstract class ToolWindowHeader extends JPanel implements Disposable { myHideButton.updateTooltip(); } } - + + public void setAdditionalTitleActions(AnAction[] actions) { + myButtonPanel.removeAll(); + boolean actionAdded = false; + for (AnAction action : actions) { + if (action == null) continue; + myButtonPanel.add(new ActionButton(action, action.getTemplatePresentation().getIcon())); + myButtonPanel.add(Box.createHorizontalStrut(7)); + actionAdded = true; + } + if (actionAdded) { + myButtonPanel.add(new JLabel(ourSeparatorIcon)); + myButtonPanel.add(Box.createHorizontalStrut(6)); + } + addDefaultActions(myButtonPanel); + } + private static Icon getHideToolWindowIcon(ToolWindow toolWindow) { ToolWindowAnchor anchor = toolWindow.getAnchor(); if (anchor == ToolWindowAnchor.BOTTOM) { From 4f513cbd946f42a1851027cd82d02e8a7399f967 Mon Sep 17 00:00:00 2001 From: anna Date: Wed, 28 Dec 2011 14:22:20 +0100 Subject: [PATCH 24/28] EA-31069 - assert: RefactoringUtil.getChainedConstructor --- .../intellij/refactoring/util/RefactoringUtil.java | 2 +- .../afterAbstractConstructor.java | 11 +++++++++++ .../beforeAbstractConstructor.java | 10 ++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createConstructorParameterFromField/afterAbstractConstructor.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createConstructorParameterFromField/beforeAbstractConstructor.java diff --git a/java/java-impl/src/com/intellij/refactoring/util/RefactoringUtil.java b/java/java-impl/src/com/intellij/refactoring/util/RefactoringUtil.java index 610bcdf579d0..b1bef4267f30 100644 --- a/java/java-impl/src/com/intellij/refactoring/util/RefactoringUtil.java +++ b/java/java-impl/src/com/intellij/refactoring/util/RefactoringUtil.java @@ -901,7 +901,7 @@ public class RefactoringUtil { @Nullable public static PsiMethod getChainedConstructor(PsiMethod constructor) { final PsiCodeBlock constructorBody = constructor.getBody(); - LOG.assertTrue(constructorBody != null); + if (constructorBody == null) return null; final PsiStatement[] statements = constructorBody.getStatements(); if (statements.length == 1 && statements[0] instanceof PsiExpressionStatement) { final PsiExpression expression = ((PsiExpressionStatement)statements[0]).getExpression(); diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createConstructorParameterFromField/afterAbstractConstructor.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createConstructorParameterFromField/afterAbstractConstructor.java new file mode 100644 index 000000000000..cd0507ff3c9a --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createConstructorParameterFromField/afterAbstractConstructor.java @@ -0,0 +1,11 @@ +// "Add constructor parameter" "true" +public enum La { + ; + private String s; + + private La(String s) { + this.s = s; + } + + private La(int a, String s); +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createConstructorParameterFromField/beforeAbstractConstructor.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createConstructorParameterFromField/beforeAbstractConstructor.java new file mode 100644 index 000000000000..626f7c630337 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createConstructorParameterFromField/beforeAbstractConstructor.java @@ -0,0 +1,10 @@ +// "Add constructor parameter" "true" +public enum La { + ; + private String s; + + private La() { + } + + private La(int a); +} From 45a82ea5cfee3519968dbaf19b1b3bc07ffdc2e3 Mon Sep 17 00:00:00 2001 From: anna Date: Wed, 28 Dec 2011 15:51:53 +0100 Subject: [PATCH 25/28] logging --- .../com/intellij/codeInsight/template/TemplateBuilderImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/TemplateBuilderImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/template/TemplateBuilderImpl.java index 8551a333416c..04f26ab11815 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/TemplateBuilderImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/TemplateBuilderImpl.java @@ -192,7 +192,7 @@ public class TemplateBuilderImpl implements TemplateBuilder { int start = 0; for (final RangeMarker element : myElements) { int offset = element.getStartOffset() - containerStart; - LOG.assertTrue(start <= offset,"container: " + myContainerElement.getClass() + " markers: " + + LOG.assertTrue(start <= offset,"container: " + myContainerElement + " markers: " + StringUtil.join(myElements, new Function() { @Override public String fun(RangeMarker rangeMarker) { From 12aa35d77f4f9cc236b292163eac6055f28e6d53 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 28 Dec 2011 14:59:21 +0100 Subject: [PATCH 26/28] cleanup --- .../com/intellij/ide/util/treeView/AbstractTreeUi.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeUi.java b/platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeUi.java index f90b2f9dc8e9..6997d30dbed7 100644 --- a/platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeUi.java +++ b/platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeUi.java @@ -3261,16 +3261,6 @@ public class AbstractTreeUi { } - private boolean isValid(DefaultMutableTreeNode node) { - if (node == null) return false; - final Object object = node.getUserObject(); - if (object instanceof NodeDescriptor) { - return isValid((NodeDescriptor)object); - } - - return false; - } - private boolean isValid(NodeDescriptor descriptor) { return descriptor != null && isValid(getElementFromDescriptor(descriptor)); } From f6ba04736b0d23df2ef53c9639c333678893fa77 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 28 Dec 2011 15:36:42 +0100 Subject: [PATCH 27/28] remove unneeded field --- .../util/xml/impl/DomInvocationHandler.java | 2 +- .../intellij/util/xml/impl/DomSemContributor.java | 2 +- .../xml/impl/IndexedElementInvocationHandler.java | 14 +++----------- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/DomInvocationHandler.java b/xml/dom-impl/src/com/intellij/util/xml/impl/DomInvocationHandler.java index e3bd50133df9..44d69049c9a7 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/DomInvocationHandler.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/DomInvocationHandler.java @@ -588,7 +588,7 @@ public abstract class DomInvocationHandler{ private static final Logger LOG = Logger.getInstance("#com.intellij.util.xml.impl.IndexedElementInvocationHandler"); private final int myIndex; - private String myNamespace; public IndexedElementInvocationHandler(final EvaluatedXmlName tagName, final FixedChildDescriptionImpl description, final int index, final DomParentStrategy strategy, - final DomManagerImpl manager, - final String namespace) { + final DomManagerImpl manager) { super(description.getType(), strategy, tagName, description, manager, strategy.getXmlElement() != null); myIndex = index; - myNamespace = namespace; } @SuppressWarnings({"EqualsWhichDoesntCheckParameterClass"}) @@ -49,9 +46,7 @@ public class IndexedElementInvocationHandler extends DomInvocationHandler tags = DomImplUtil.findSubTags(tag, getXmlName(), parentHandler.getFile()); if (tags.size() <= myIndex) return null; - final XmlTag childTag = tags.get(myIndex); - myNamespace = childTag.getNamespace(); - return childTag; + return tags.get(myIndex); } protected XmlTag setEmptyXmlTag() { @@ -62,9 +57,7 @@ public class IndexedElementInvocationHandler extends DomInvocationHandler tags = DomImplUtil.findSubTags(parent.getXmlTag(), getXmlName(), xmlFile); if (tags.size() > myIndex) { - final XmlTag tag = tags.get(myIndex); - myNamespace = tag.getNamespace(); - return tag; + return tags.get(myIndex); } final XmlTag[] newTag = new XmlTag[1]; @@ -79,7 +72,6 @@ public class IndexedElementInvocationHandler extends DomInvocationHandler Date: Wed, 28 Dec 2011 16:20:15 +0100 Subject: [PATCH 28/28] EA-31702 don't create dom for second aspectj-autoproxy --- .../intellij/util/xml/impl/DomAnchorImpl.java | 29 +++++++++++++------ .../util/xml/impl/DomSemContributor.java | 2 +- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/DomAnchorImpl.java b/xml/dom-impl/src/com/intellij/util/xml/impl/DomAnchorImpl.java index dc7ada986a01..adc993471f88 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/DomAnchorImpl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/DomAnchorImpl.java @@ -76,24 +76,35 @@ public abstract class DomAnchorImpl implements DomAnchor(parentAnchor, description, index); } - private static void diagnoseNegativeIndex(T t, - DomElement parent, - AbstractDomChildrenDescription description, - List values) { + private static void diagnoseNegativeIndex2(T t, + DomElement parent, + AbstractDomChildrenDescription description, + List values) { final XmlTag parentTag = parent.getXmlTag(); StringBuilder diag = new StringBuilder("Index<0: description=" + description + "\nparent=" + parent + "\nt=" + t + "\nvalues=" + values + "\n"); - for (DomElement value : values) { + for (int i = 0, size = values.size(); i < size; i++) { + DomElement value = values.get(i); if (value.toString().equals(t.toString())) { - diag.append(" hasSame, same=" + (value == t) + + final XmlElement tElement = t.getXmlElement(); + final XmlElement valElement = value.getXmlElement(); + diag.append(" hasSame, i=" + i + + "; same=" + (value == t) + ", equal=" + value.equals(t) + ", equal2=" + t.equals(value) + - ", sameElements=" + (t.getXmlElement() == value.getXmlElement()) + + ", t.physical=" + (tElement == null ? "null" : String.valueOf(tElement.isPhysical())) + + ", value.physical=" + (valElement == null ? "null" : String.valueOf(valElement.isPhysical())) + + ", sameElements=" + (tElement == value.getXmlElement()) + "\n"); + if (tElement != null && valElement != null) { + diag.append(" sameFile=" + (tElement.getContainingFile() == valElement.getContainingFile()) + + ", sameParent=" + (tElement.getParent() == valElement.getParent()) + + "\n"); + } } } @@ -106,7 +117,7 @@ public abstract class DomAnchorImpl implements DomAnchor= totalCount) { return null;