From dd8676fb1b2daeae4dd6716f8d48746536ce8ce0 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Fri, 16 Jul 2010 12:33:45 +0400 Subject: [PATCH 01/26] [Mercurial] fixed package name --- .../hg4idea/testSrc/org/zmlx/hg4idea/AbstractHgTestCase.java | 2 +- .../{org/zmlx/hg4idea => }/test/TestChangeListManager.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename plugins/hg4idea/testSrc/org/zmlx/hg4idea/{org/zmlx/hg4idea => }/test/TestChangeListManager.java (98%) diff --git a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/AbstractHgTestCase.java b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/AbstractHgTestCase.java index 23e1d5586630..cf110608bd40 100644 --- a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/AbstractHgTestCase.java +++ b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/AbstractHgTestCase.java @@ -24,7 +24,7 @@ import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory; import com.intellij.testFramework.fixtures.TempDirTestFixture; import com.intellij.vcsUtil.VcsUtil; import org.testng.annotations.BeforeMethod; -import org.zmlx.hg4idea.org.zmlx.hg4idea.test.TestChangeListManager; +import org.zmlx.hg4idea.test.TestChangeListManager; import java.io.*; diff --git a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/org/zmlx/hg4idea/test/TestChangeListManager.java b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/TestChangeListManager.java similarity index 98% rename from plugins/hg4idea/testSrc/org/zmlx/hg4idea/org/zmlx/hg4idea/test/TestChangeListManager.java rename to plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/TestChangeListManager.java index e0bb3b3c56a6..791699be0f9f 100644 --- a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/org/zmlx/hg4idea/test/TestChangeListManager.java +++ b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/TestChangeListManager.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.zmlx.hg4idea.org.zmlx.hg4idea.test; +package org.zmlx.hg4idea.test; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.project.Project; From 1b1436b3637df0f2d08dc7444c74c905dc26a8e8 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Fri, 16 Jul 2010 12:57:31 +0400 Subject: [PATCH 02/26] [Mercurial] Moved tests to the .test subpackage. --- .../org/zmlx/hg4idea/{ => test}/AbstractHgTestCase.java | 5 +++-- .../testSrc/org/zmlx/hg4idea/{ => test}/HgAddTestCase.java | 2 +- .../testSrc/org/zmlx/hg4idea/{ => test}/HgCopyTestCase.java | 2 +- .../org/zmlx/hg4idea/{ => test}/HgDeleteTestCase.java | 2 +- .../org/zmlx/hg4idea/{ => test}/HgFromClonedTestCase.java | 3 ++- .../org/zmlx/hg4idea/{ => test}/HgHistoryTestCase.java | 3 ++- .../testSrc/org/zmlx/hg4idea/{ => test}/HgLogTestCase.java | 3 ++- .../testSrc/org/zmlx/hg4idea/{ => test}/HgMoveTestCase.java | 2 +- .../org/zmlx/hg4idea/{ => test}/HgRenameTestCase.java | 2 +- .../zmlx/hg4idea/{ => test}/HgResolveConflictTestCase.java | 2 +- .../org/zmlx/hg4idea/{ => test}/HgRevertTestCase.java | 3 ++- .../org/zmlx/hg4idea/{ => test}/HgUpdateTestCase.java | 4 +++- .../testSrc/org/zmlx/hg4idea/{ => test}/HgUrlTestCase.java | 2 +- 13 files changed, 21 insertions(+), 14 deletions(-) rename plugins/hg4idea/testSrc/org/zmlx/hg4idea/{ => test}/AbstractHgTestCase.java (98%) rename plugins/hg4idea/testSrc/org/zmlx/hg4idea/{ => test}/HgAddTestCase.java (98%) rename plugins/hg4idea/testSrc/org/zmlx/hg4idea/{ => test}/HgCopyTestCase.java (98%) rename plugins/hg4idea/testSrc/org/zmlx/hg4idea/{ => test}/HgDeleteTestCase.java (98%) rename plugins/hg4idea/testSrc/org/zmlx/hg4idea/{ => test}/HgFromClonedTestCase.java (98%) rename plugins/hg4idea/testSrc/org/zmlx/hg4idea/{ => test}/HgHistoryTestCase.java (98%) rename plugins/hg4idea/testSrc/org/zmlx/hg4idea/{ => test}/HgLogTestCase.java (95%) rename plugins/hg4idea/testSrc/org/zmlx/hg4idea/{ => test}/HgMoveTestCase.java (98%) rename plugins/hg4idea/testSrc/org/zmlx/hg4idea/{ => test}/HgRenameTestCase.java (99%) rename plugins/hg4idea/testSrc/org/zmlx/hg4idea/{ => test}/HgResolveConflictTestCase.java (98%) rename plugins/hg4idea/testSrc/org/zmlx/hg4idea/{ => test}/HgRevertTestCase.java (95%) rename plugins/hg4idea/testSrc/org/zmlx/hg4idea/{ => test}/HgUpdateTestCase.java (99%) rename plugins/hg4idea/testSrc/org/zmlx/hg4idea/{ => test}/HgUrlTestCase.java (99%) diff --git a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/AbstractHgTestCase.java b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/AbstractHgTestCase.java similarity index 98% rename from plugins/hg4idea/testSrc/org/zmlx/hg4idea/AbstractHgTestCase.java rename to plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/AbstractHgTestCase.java index cf110608bd40..c1df16416bf9 100644 --- a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/AbstractHgTestCase.java +++ b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/AbstractHgTestCase.java @@ -10,7 +10,7 @@ // the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, // either express or implied. See the License for the specific language governing permissions and // limitations under the License. -package org.zmlx.hg4idea; +package org.zmlx.hg4idea.test; import com.intellij.execution.process.ProcessOutput; import com.intellij.openapi.application.PluginPathManager; @@ -24,7 +24,8 @@ import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory; import com.intellij.testFramework.fixtures.TempDirTestFixture; import com.intellij.vcsUtil.VcsUtil; import org.testng.annotations.BeforeMethod; -import org.zmlx.hg4idea.test.TestChangeListManager; +import org.zmlx.hg4idea.HgFile; +import org.zmlx.hg4idea.HgVcs; import java.io.*; diff --git a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/HgAddTestCase.java b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgAddTestCase.java similarity index 98% rename from plugins/hg4idea/testSrc/org/zmlx/hg4idea/HgAddTestCase.java rename to plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgAddTestCase.java index 84755453a10f..5c5ad4763fb1 100644 --- a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/HgAddTestCase.java +++ b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgAddTestCase.java @@ -10,7 +10,7 @@ // the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, // either express or implied. See the License for the specific language governing permissions and // limitations under the License. -package org.zmlx.hg4idea; +package org.zmlx.hg4idea.test; import com.intellij.openapi.vfs.VirtualFile; import org.testng.annotations.Test; diff --git a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/HgCopyTestCase.java b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgCopyTestCase.java similarity index 98% rename from plugins/hg4idea/testSrc/org/zmlx/hg4idea/HgCopyTestCase.java rename to plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgCopyTestCase.java index 5288f98a17e2..74e61d02cd20 100644 --- a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/HgCopyTestCase.java +++ b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgCopyTestCase.java @@ -10,7 +10,7 @@ // the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, // either express or implied. See the License for the specific language governing permissions and // limitations under the License. -package org.zmlx.hg4idea; +package org.zmlx.hg4idea.test; import com.intellij.openapi.vfs.VirtualFile; import org.testng.annotations.Test; diff --git a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/HgDeleteTestCase.java b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgDeleteTestCase.java similarity index 98% rename from plugins/hg4idea/testSrc/org/zmlx/hg4idea/HgDeleteTestCase.java rename to plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgDeleteTestCase.java index 2e46e5b0668c..7144af3216be 100644 --- a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/HgDeleteTestCase.java +++ b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgDeleteTestCase.java @@ -10,7 +10,7 @@ // the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, // either express or implied. See the License for the specific language governing permissions and // limitations under the License. -package org.zmlx.hg4idea; +package org.zmlx.hg4idea.test; import com.intellij.openapi.vfs.VirtualFile; import org.testng.Assert; diff --git a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/HgFromClonedTestCase.java b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgFromClonedTestCase.java similarity index 98% rename from plugins/hg4idea/testSrc/org/zmlx/hg4idea/HgFromClonedTestCase.java rename to plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgFromClonedTestCase.java index d5ebdb7fcc00..d4eab2111280 100644 --- a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/HgFromClonedTestCase.java +++ b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgFromClonedTestCase.java @@ -10,7 +10,7 @@ // the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, // either express or implied. See the License for the specific language governing permissions and // limitations under the License. -package org.zmlx.hg4idea; +package org.zmlx.hg4idea.test; import com.intellij.openapi.vcs.VcsConfiguration; import com.intellij.openapi.vfs.VirtualFile; @@ -19,6 +19,7 @@ import com.intellij.testFramework.fixtures.TempDirTestFixture; import com.intellij.vcsUtil.VcsUtil; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; +import org.zmlx.hg4idea.HgVcs; import java.io.File; diff --git a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/HgHistoryTestCase.java b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgHistoryTestCase.java similarity index 98% rename from plugins/hg4idea/testSrc/org/zmlx/hg4idea/HgHistoryTestCase.java rename to plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgHistoryTestCase.java index 1cfc4ac5f6f1..713b0455f444 100644 --- a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/HgHistoryTestCase.java +++ b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgHistoryTestCase.java @@ -1,10 +1,11 @@ -package org.zmlx.hg4idea; +package org.zmlx.hg4idea.test; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vcs.history.VcsFileRevision; import com.intellij.openapi.vcs.history.VcsHistorySession; import com.intellij.vcsUtil.VcsUtil; import org.testng.annotations.Test; +import org.zmlx.hg4idea.HgVcs; import java.io.File; import java.util.Collection; diff --git a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/HgLogTestCase.java b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgLogTestCase.java similarity index 95% rename from plugins/hg4idea/testSrc/org/zmlx/hg4idea/HgLogTestCase.java rename to plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgLogTestCase.java index 3ca617d2cfd0..be90f35a70ca 100644 --- a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/HgLogTestCase.java +++ b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgLogTestCase.java @@ -10,9 +10,10 @@ // the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, // either express or implied. See the License for the specific language governing permissions and // limitations under the License. -package org.zmlx.hg4idea; +package org.zmlx.hg4idea.test; import org.testng.annotations.Test; +import org.zmlx.hg4idea.HgFileRevision; import org.zmlx.hg4idea.command.HgLogCommand; import java.util.List; diff --git a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/HgMoveTestCase.java b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgMoveTestCase.java similarity index 98% rename from plugins/hg4idea/testSrc/org/zmlx/hg4idea/HgMoveTestCase.java rename to plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgMoveTestCase.java index def256e6a0f2..841cc7de22c7 100644 --- a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/HgMoveTestCase.java +++ b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgMoveTestCase.java @@ -10,7 +10,7 @@ // the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, // either express or implied. See the License for the specific language governing permissions and // limitations under the License. -package org.zmlx.hg4idea; +package org.zmlx.hg4idea.test; import com.intellij.openapi.vfs.VirtualFile; import org.testng.annotations.Test; diff --git a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/HgRenameTestCase.java b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgRenameTestCase.java similarity index 99% rename from plugins/hg4idea/testSrc/org/zmlx/hg4idea/HgRenameTestCase.java rename to plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgRenameTestCase.java index a97949c990d1..55160e1b4011 100644 --- a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/HgRenameTestCase.java +++ b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgRenameTestCase.java @@ -10,7 +10,7 @@ // the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, // either express or implied. See the License for the specific language governing permissions and // limitations under the License. -package org.zmlx.hg4idea; +package org.zmlx.hg4idea.test; import com.intellij.openapi.vfs.VirtualFile; import org.testng.annotations.Test; diff --git a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/HgResolveConflictTestCase.java b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgResolveConflictTestCase.java similarity index 98% rename from plugins/hg4idea/testSrc/org/zmlx/hg4idea/HgResolveConflictTestCase.java rename to plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgResolveConflictTestCase.java index 8d1443264c5f..bdb38f402b0d 100644 --- a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/HgResolveConflictTestCase.java +++ b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgResolveConflictTestCase.java @@ -10,7 +10,7 @@ // the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, // either express or implied. See the License for the specific language governing permissions and // limitations under the License. -package org.zmlx.hg4idea; +package org.zmlx.hg4idea.test; import com.intellij.openapi.vfs.VirtualFile; import org.testng.Assert; diff --git a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/HgRevertTestCase.java b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgRevertTestCase.java similarity index 95% rename from plugins/hg4idea/testSrc/org/zmlx/hg4idea/HgRevertTestCase.java rename to plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgRevertTestCase.java index 14e895755f1c..1a894840f5d5 100644 --- a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/HgRevertTestCase.java +++ b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgRevertTestCase.java @@ -1,6 +1,7 @@ -package org.zmlx.hg4idea; +package org.zmlx.hg4idea.test; import org.testng.annotations.Test; +import org.zmlx.hg4idea.HgRevisionNumber; import org.zmlx.hg4idea.command.HgCatCommand; import org.zmlx.hg4idea.command.HgRevertCommand; diff --git a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/HgUpdateTestCase.java b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgUpdateTestCase.java similarity index 99% rename from plugins/hg4idea/testSrc/org/zmlx/hg4idea/HgUpdateTestCase.java rename to plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgUpdateTestCase.java index 4fed9d4d2dbe..619f0e231675 100644 --- a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/HgUpdateTestCase.java +++ b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgUpdateTestCase.java @@ -10,7 +10,7 @@ // the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, // either express or implied. See the License for the specific language governing permissions and // limitations under the License. -package org.zmlx.hg4idea; +package org.zmlx.hg4idea.test; import com.intellij.execution.process.ProcessOutput; import com.intellij.openapi.progress.EmptyProgressIndicator; @@ -18,6 +18,8 @@ import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vcs.update.UpdatedFiles; import com.intellij.openapi.vfs.VirtualFile; import org.testng.annotations.Test; +import org.zmlx.hg4idea.HgFile; +import org.zmlx.hg4idea.HgRevisionNumber; import org.zmlx.hg4idea.command.*; import org.zmlx.hg4idea.provider.update.HgRegularUpdater; diff --git a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/HgUrlTestCase.java b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgUrlTestCase.java similarity index 99% rename from plugins/hg4idea/testSrc/org/zmlx/hg4idea/HgUrlTestCase.java rename to plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgUrlTestCase.java index 0cda4bc06df8..ed7f7086aaef 100644 --- a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/HgUrlTestCase.java +++ b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgUrlTestCase.java @@ -10,7 +10,7 @@ // the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, // either express or implied. See the License for the specific language governing permissions and // limitations under the License. -package org.zmlx.hg4idea; +package org.zmlx.hg4idea.test; import org.testng.Assert; import org.testng.annotations.Test; From 0352e2a1f90747a5d4cbe6df3e59632b1a193d46 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Fri, 16 Jul 2010 12:58:53 +0400 Subject: [PATCH 03/26] [Mercurial Tests] Renamed AbstractHgTestCase to HgAbstractTestCase for unification. --- .../test/{AbstractHgTestCase.java => HgAbstractTestCase.java} | 2 +- .../hg4idea/testSrc/org/zmlx/hg4idea/test/HgAddTestCase.java | 2 +- .../hg4idea/testSrc/org/zmlx/hg4idea/test/HgCopyTestCase.java | 2 +- .../hg4idea/testSrc/org/zmlx/hg4idea/test/HgDeleteTestCase.java | 2 +- .../testSrc/org/zmlx/hg4idea/test/HgFromClonedTestCase.java | 2 +- .../testSrc/org/zmlx/hg4idea/test/HgHistoryTestCase.java | 2 +- .../hg4idea/testSrc/org/zmlx/hg4idea/test/HgLogTestCase.java | 2 +- .../hg4idea/testSrc/org/zmlx/hg4idea/test/HgMoveTestCase.java | 2 +- .../hg4idea/testSrc/org/zmlx/hg4idea/test/HgRenameTestCase.java | 2 +- .../org/zmlx/hg4idea/test/HgResolveConflictTestCase.java | 2 +- .../hg4idea/testSrc/org/zmlx/hg4idea/test/HgRevertTestCase.java | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) rename plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/{AbstractHgTestCase.java => HgAbstractTestCase.java} (99%) diff --git a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/AbstractHgTestCase.java b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgAbstractTestCase.java similarity index 99% rename from plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/AbstractHgTestCase.java rename to plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgAbstractTestCase.java index c1df16416bf9..bf6c44932ee2 100644 --- a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/AbstractHgTestCase.java +++ b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgAbstractTestCase.java @@ -34,7 +34,7 @@ import static org.testng.Assert.assertTrue; /** * The ancestor of all hg4idea test cases. */ -public abstract class AbstractHgTestCase extends AbstractVcsTestCase { +public abstract class HgAbstractTestCase extends AbstractVcsTestCase { public static final String HG_EXECUTABLE_PATH = "IDEA_TEST_HG_EXECUTABLE_PATH"; diff --git a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgAddTestCase.java b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgAddTestCase.java index 5c5ad4763fb1..9f945b127033 100644 --- a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgAddTestCase.java +++ b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgAddTestCase.java @@ -18,7 +18,7 @@ import org.testng.annotations.Test; /** * Tests adding files to the Mercurial repository. */ -public class HgAddTestCase extends AbstractHgTestCase { +public class HgAddTestCase extends HgAbstractTestCase { /** * 1. Create a file in the file system. diff --git a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgCopyTestCase.java b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgCopyTestCase.java index 74e61d02cd20..f58ce982a6b2 100644 --- a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgCopyTestCase.java +++ b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgCopyTestCase.java @@ -17,7 +17,7 @@ import org.testng.annotations.Test; import java.io.File; -public class HgCopyTestCase extends AbstractHgTestCase { +public class HgCopyTestCase extends HgAbstractTestCase { @Test public void testCopyUnmodifiedFile() throws Exception { diff --git a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgDeleteTestCase.java b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgDeleteTestCase.java index 7144af3216be..b118ffc62d24 100644 --- a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgDeleteTestCase.java +++ b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgDeleteTestCase.java @@ -18,7 +18,7 @@ import org.testng.annotations.Test; import java.io.File; -public class HgDeleteTestCase extends AbstractHgTestCase { +public class HgDeleteTestCase extends HgAbstractTestCase { @Test public void testDeleteUnmodifiedFile() throws Exception { diff --git a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgFromClonedTestCase.java b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgFromClonedTestCase.java index d4eab2111280..05a632198a3b 100644 --- a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgFromClonedTestCase.java +++ b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgFromClonedTestCase.java @@ -25,7 +25,7 @@ import java.io.File; import static org.testng.Assert.assertTrue; -public class HgFromClonedTestCase extends AbstractHgTestCase { +public class HgFromClonedTestCase extends HgAbstractTestCase { protected File remoteRepo; protected File projectRepo; diff --git a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgHistoryTestCase.java b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgHistoryTestCase.java index 713b0455f444..b0d3be8157d0 100644 --- a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgHistoryTestCase.java +++ b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgHistoryTestCase.java @@ -17,7 +17,7 @@ import static org.testng.Assert.assertTrue; /** * HgHistoryTestCase tests retrieving file history and specific revisions. */ -public class HgHistoryTestCase extends AbstractHgTestCase { +public class HgHistoryTestCase extends HgAbstractTestCase { /** * 1. Make two versions of a file (create, add, commit, modify, commit). diff --git a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgLogTestCase.java b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgLogTestCase.java index be90f35a70ca..581cb62e38fa 100644 --- a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgLogTestCase.java +++ b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgLogTestCase.java @@ -20,7 +20,7 @@ import java.util.List; import static org.testng.Assert.assertEquals; -public class HgLogTestCase extends AbstractHgTestCase { +public class HgLogTestCase extends HgAbstractTestCase { @Test public void testCommitMessagesWithMultipleLines() throws Exception { diff --git a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgMoveTestCase.java b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgMoveTestCase.java index 841cc7de22c7..af9e863d2bef 100644 --- a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgMoveTestCase.java +++ b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgMoveTestCase.java @@ -17,7 +17,7 @@ import org.testng.annotations.Test; import java.io.File; -public class HgMoveTestCase extends AbstractHgTestCase { +public class HgMoveTestCase extends HgAbstractTestCase { @Test public void testMoveNewFile() throws Exception { diff --git a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgRenameTestCase.java b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgRenameTestCase.java index 55160e1b4011..8d8310071b1f 100644 --- a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgRenameTestCase.java +++ b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgRenameTestCase.java @@ -17,7 +17,7 @@ import org.testng.annotations.Test; import java.io.File; -public class HgRenameTestCase extends AbstractHgTestCase { +public class HgRenameTestCase extends HgAbstractTestCase { @Test public void testRenameUnmodifiedFile() throws Exception { diff --git a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgResolveConflictTestCase.java b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgResolveConflictTestCase.java index bdb38f402b0d..bf5a0df75e61 100644 --- a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgResolveConflictTestCase.java +++ b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgResolveConflictTestCase.java @@ -17,7 +17,7 @@ import org.testng.Assert; import org.testng.annotations.Test; import org.zmlx.hg4idea.command.HgResolveCommand; -public class HgResolveConflictTestCase extends AbstractHgTestCase { +public class HgResolveConflictTestCase extends HgAbstractTestCase { public static final String BASE = "one\n" + "conflicting\n" + diff --git a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgRevertTestCase.java b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgRevertTestCase.java index 1a894840f5d5..674835517c0c 100644 --- a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgRevertTestCase.java +++ b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgRevertTestCase.java @@ -9,7 +9,7 @@ import java.nio.charset.Charset; import static org.testng.Assert.assertEquals; -public class HgRevertTestCase extends AbstractHgTestCase { +public class HgRevertTestCase extends HgAbstractTestCase { @Test public void testRevertToCurrentRevision() throws Exception { fillFile(myProjectRepo, new String[]{"file.txt"}, "initial contents"); From 6815d02c65bd232548f7023160091c0281851e5e Mon Sep 17 00:00:00 2001 From: Maxim Medvedev Date: Tue, 20 Jul 2010 10:52:16 +0400 Subject: [PATCH 04/26] IDEA-56174 Highlight class references in Groovy --- .../groovy/annotator/GroovyAnnotator.java | 24 ++++++++++++++----- .../highlighter/DefaultHighlighter.java | 5 ++++ .../highlighter/GroovyColorsAndFontsPage.java | 15 ++++++------ 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java index e9429f30b52e..ef9bbbb5c317 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java @@ -283,6 +283,7 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator { if (body != null) checkDuplicateMethod(body.getGroovyMethods(), myHolder); checkImplementedMethodsOfClass(myHolder, typeDefinition); checkConstructors(myHolder, typeDefinition); + highligtClassReference(myHolder, typeDefinition.getNameIdentifierGroovy()); } private static void checkConstructors(AnnotationHolder holder, GrTypeDefinition typeDefinition) { @@ -1296,6 +1297,9 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator { if (member instanceof PsiMethod) { annotation.setTextAttributes(!isStatic ? DefaultHighlighter.METHOD_CALL : DefaultHighlighter.STATIC_METHOD_ACCESS); } + if (member instanceof PsiClass) { + highligtClassReference(holder, refExpr); + } } @@ -1536,16 +1540,24 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator { private static void highlightAnnotation(AnnotationHolder holder, PsiElement refElement, GroovyResolveResult result) { PsiElement element = result.getElement(); PsiElement parent = refElement.getParent(); - if (element instanceof PsiClass && ((PsiClass)element).isAnnotationType() && !(parent instanceof GrImportStatement)) { - Annotation annotation = holder.createInfoAnnotation(parent, null); - annotation.setTextAttributes(DefaultHighlighter.ANNOTATION); - GroovyPsiElement context = result.getCurrentFileResolveContext(); - if (context instanceof GrImportStatement) { - annotation = holder.createInfoAnnotation(((GrImportStatement)context).getImportReference(), null); + if (element instanceof PsiClass) { + if (((PsiClass)element).isAnnotationType() && !(parent instanceof GrImportStatement)) { + Annotation annotation = holder.createInfoAnnotation(parent, null); annotation.setTextAttributes(DefaultHighlighter.ANNOTATION); + GroovyPsiElement context = result.getCurrentFileResolveContext(); + if (context instanceof GrImportStatement) { + annotation = holder.createInfoAnnotation(((GrImportStatement)context).getImportReference(), null); + annotation.setTextAttributes(DefaultHighlighter.ANNOTATION); + } + } else { + highligtClassReference(holder, refElement); } } + } + private static void highligtClassReference(AnnotationHolder holder, PsiElement classReference) { + final Annotation annotation = holder.createInfoAnnotation(classReference, null); + annotation.setTextAttributes(DefaultHighlighter.CLASS_REFERENCE); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/highlighter/DefaultHighlighter.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/highlighter/DefaultHighlighter.java index a924b235f92a..a3b5dd8321e9 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/highlighter/DefaultHighlighter.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/highlighter/DefaultHighlighter.java @@ -70,6 +70,8 @@ public class DefaultHighlighter { static final String METHOD_CALL_ID = "Method call"; @NonNls static final String STATIC_METHOD_ACCESS_ID = "Static method access"; + @NonNls + static final String CLASS_REFERENCE_ID = "Class"; @NonNls @@ -103,6 +105,9 @@ public class DefaultHighlighter { public static TextAttributesKey DOC_COMMENT_TAG = TextAttributesKey.createTextAttributesKey(DOC_COMMENT_TAG_ID, SyntaxHighlighterColors.DOC_COMMENT_TAG.getDefaultAttributes()); + public static TextAttributesKey CLASS_REFERENCE = + TextAttributesKey.createTextAttributesKey(CLASS_REFERENCE_ID, HighlighterColors.TEXT.getDefaultAttributes().clone()); + public static final TextAttributes KEYWORD_ATTRIBUTES = SyntaxHighlighterColors.KEYWORD.getDefaultAttributes().clone(); static{ diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/highlighter/GroovyColorsAndFontsPage.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/highlighter/GroovyColorsAndFontsPage.java index d19624f62087..e9bab50b59a5 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/highlighter/GroovyColorsAndFontsPage.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/highlighter/GroovyColorsAndFontsPage.java @@ -67,7 +67,7 @@ public class GroovyColorsAndFontsPage implements ColorSettingsPage { new AttributesDescriptor(DefaultHighlighter.ANNOTATION_ID, DefaultHighlighter.ANNOTATION), new AttributesDescriptor(DefaultHighlighter.STATIC_FIELD_ID, DefaultHighlighter.STATIC_FIELD), new AttributesDescriptor(DefaultHighlighter.STATIC_FIELD_ID, DefaultHighlighter.INSTANCE_FIELD), - new AttributesDescriptor(DefaultHighlighter.STATIC_METHOD_ACCESS_ID, DefaultHighlighter.STATIC_METHOD_ACCESS), + new AttributesDescriptor(DefaultHighlighter.CLASS_REFERENCE_ID, DefaultHighlighter.CLASS_REFERENCE), }; @NotNull @@ -83,23 +83,23 @@ public class GroovyColorsAndFontsPage implements ColorSettingsPage { @NonNls @NotNull public String getDemoText() { - return "import javax.swing.JPanel\n" + + return "import javax.swing.JPanel\n" + " ### \n" + "/**\n" + " * This is Groovydoc comment\n" + - " * @see java.lang.String#equals\n" + + " * @see java.lang.String#equals\n" + " */\n" + "@SpecialBean \n" + - "class Demo {\n" + + "class Demo {\n" + " def property\n" + "//This is a line comment\n" + "/* This is a block comment */\n" + " static def foo(int i) { return [i, i, property] }\n" + - " static def panel = new JPanel()\n" + + " static def panel = new JPanel()\n" + "}\n" + "\n" + - "Demo.panel.size = " + - "Demo.foo(\"123${456}789\".toInteger()) \n" + + "Demo.panel.size = " + + "Demo.foo(\"123${456}789\".toInteger()) \n" + "'JetBrains'.matches(/Jw+Bw+/) \n" + "def x=1 + unresolved" ; @@ -115,6 +115,7 @@ public class GroovyColorsAndFontsPage implements ColorSettingsPage { map.put("gdoc", DefaultHighlighter.DOC_COMMENT_CONTENT); map.put("doctag", DefaultHighlighter.DOC_COMMENT_TAG); map.put("unresolved", DefaultHighlighter.UNRESOLVED_ACCESS); + map.put("classref", DefaultHighlighter.CLASS_REFERENCE); return map; } From 0d689b8f58406736b15e2acf4ecc24731c5ef592 Mon Sep 17 00:00:00 2001 From: Maxim Medvedev Date: Tue, 20 Jul 2010 12:26:03 +0400 Subject: [PATCH 05/26] IDEA-56126 Groovy: "Convert parameter to map entry" intention applied to closure doesn't change its arguments in explicit call --- .../ConvertParameterToMapEntryIntention.java | 83 ++++++++++--------- .../ParameterToMapEntryTest.java | 22 +++-- .../testdata/paramToMap/callMethod/A.groovy | 3 + .../testdata/paramToMap/callMethod/A.test | 3 + 4 files changed, 65 insertions(+), 46 deletions(-) create mode 100644 plugins/groovy/testdata/paramToMap/callMethod/A.groovy create mode 100644 plugins/groovy/testdata/paramToMap/callMethod/A.test diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/parameterToEntry/ConvertParameterToMapEntryIntention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/parameterToEntry/ConvertParameterToMapEntryIntention.java index 3ce5f8148c7d..494bdb90eb55 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/parameterToEntry/ConvertParameterToMapEntryIntention.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/parameterToEntry/ConvertParameterToMapEntryIntention.java @@ -185,42 +185,53 @@ public class ConvertParameterToMapEntryIntention extends Intention { //final List calls = getCallOccurrences(occurrences); try { for (PsiElement occurrence : occurrences) { - if (occurrence instanceof GrReferenceExpression && occurrence.getParent() instanceof GrCall) { - final GrReferenceExpression refExpr = (GrReferenceExpression)occurrence; - final GrClosureSignature signature = generateSignature(owner, refExpr); - if (signature == null) continue; - final GrCall call = (GrCall)refExpr.getParent(); - final GrArgumentList argumentList = call.getArgumentList(); - final GrClosableBlock[] closureArguments = - call instanceof GrCallExpression ? ((GrCallExpression)call).getClosureArguments() : GrClosableBlock.EMPTY_ARRAY; - - final GrClosureSignatureUtil.ArgInfo[] argInfos = - GrClosureSignatureUtil.mapParametersToArguments(signature, argumentList, closureArguments, owner.getResolveScope()); - if (argInfos == null) continue; - final GrClosureSignatureUtil.ArgInfo argInfo = argInfos[index]; - - final GrNamedArgument namedArg; - if (argInfo.isMultiArg) { - if (argInfo.args.size() == 0) continue; - String arg = "[" + StringUtil.join(ContainerUtil.map(argInfo.args, new Function() { - public String fun(PsiElement element) { - return element.getText(); - } - }), ", ") + "]"; - for (PsiElement psiElement : argInfo.args) { - psiElement.delete(); + GrReferenceExpression refExpr = null; + if (occurrence instanceof GrReferenceExpression) { + final PsiElement parent = occurrence.getParent(); + if (parent instanceof GrCall) { + refExpr = (GrReferenceExpression)occurrence; + } + else if (parent instanceof GrReferenceExpression) { + final PsiElement resolved = ((GrReferenceExpression)parent).resolve(); + if (resolved instanceof PsiMethod && "call".equals(((PsiMethod)resolved).getName())) { + refExpr = (GrReferenceExpression)parent; } - namedArg = factory.createNamedArgument(paramName, factory.createExpressionFromText(arg)); } - else { - if (argInfo.args.size() == 0) continue; - final PsiElement argument = argInfo.args.iterator().next(); - assert argument instanceof GrExpression; - namedArg = factory.createNamedArgument(paramName, (GrExpression)argument); - argument.delete(); - } - ((GrCall)refExpr.getParent()).addNamedArgument(namedArg); } + if (refExpr == null) continue; + final GrClosureSignature signature = generateSignature(owner, refExpr); + if (signature == null) continue; + final GrCall call = (GrCall)refExpr.getParent(); + final GrArgumentList argumentList = call.getArgumentList(); + final GrClosableBlock[] closureArguments = + call instanceof GrCallExpression ? ((GrCallExpression)call).getClosureArguments() : GrClosableBlock.EMPTY_ARRAY; + + final GrClosureSignatureUtil.ArgInfo[] argInfos = + GrClosureSignatureUtil.mapParametersToArguments(signature, argumentList, closureArguments, owner.getResolveScope()); + if (argInfos == null) continue; + final GrClosureSignatureUtil.ArgInfo argInfo = argInfos[index]; + + final GrNamedArgument namedArg; + if (argInfo.isMultiArg) { + if (argInfo.args.size() == 0) continue; + String arg = "[" + StringUtil.join(ContainerUtil.map(argInfo.args, new Function() { + public String fun(PsiElement element) { + return element.getText(); + } + }), ", ") + "]"; + for (PsiElement psiElement : argInfo.args) { + psiElement.delete(); + } + namedArg = factory.createNamedArgument(paramName, factory.createExpressionFromText(arg)); + } + else { + if (argInfo.args.size() == 0) continue; + final PsiElement argument = argInfo.args.iterator().next(); + assert argument instanceof GrExpression; + namedArg = factory.createNamedArgument(paramName, (GrExpression)argument); + argument.delete(); + } + ((GrCall)refExpr.getParent()).addNamedArgument(namedArg); } } catch (IncorrectOperationException e) { @@ -369,10 +380,8 @@ public class ConvertParameterToMapEntryIntention extends Intention { final PsiElement namedElem = getReferencedElement(owner); if (namedElem == null) return true; final Ref result = new Ref(true); - final Task task = new Task.Modal(project, GroovyIntentionsBundle.message("find.method.ro.closure.usages.0", - owner instanceof GrClosableBlock - ? CLOSURE_CAPTION - : METHOD_CAPTION), true) { + final Task task = new Task.Modal(project, GroovyIntentionsBundle + .message("find.method.ro.closure.usages.0", owner instanceof GrClosableBlock ? CLOSURE_CAPTION : METHOD_CAPTION), true) { public void run(@NotNull final ProgressIndicator indicator) { final GlobalSearchScope projectScope = GlobalSearchScope.projectScope(getProject()); final Query query = ReferencesSearch.search(namedElem, projectScope); diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/style/parameterToEntry/ParameterToMapEntryTest.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/style/parameterToEntry/ParameterToMapEntryTest.java index f8692a9da4c8..8fa073f22a6f 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/style/parameterToEntry/ParameterToMapEntryTest.java +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/style/parameterToEntry/ParameterToMapEntryTest.java @@ -56,39 +56,43 @@ public class ParameterToMapEntryTest extends GroovyFormatterTestCase { } */ - public void testParam1() throws Throwable { + public void testParam1() { doTestImpl("A.groovy"); } - public void testFormatter() throws Throwable { + public void testFormatter() { doTestImpl("A.groovy"); } - public void testClosureAtEnd() throws Throwable { + public void testClosureAtEnd() { doTestImpl("A.groovy"); } - public void testClosure1() throws Throwable { + public void testClosure1() { doTestImpl("A.groovy"); } - public void testNewMap() throws Throwable { + public void testNewMap() { doTestImpl("A.groovy"); } - public void testTestError() throws Throwable { + public void testTestError() { doTestImpl("A.groovy"); } - public void testSecondClosure() throws Throwable { + public void testSecondClosure() { doTestImpl("A.groovy"); } - public void testVarArgs() throws Throwable { + public void testVarArgs() { doTestImpl("A.groovy"); } - private void doTestImpl(String filePath) throws Throwable { + public void testCallMethod() { + doTestImpl("A.groovy"); + } + + private void doTestImpl(String filePath) { myFixture.configureByFile(filePath); int offset = myFixture.getEditor().getCaretModel().getOffset(); final PsiFile file = myFixture.getFile(); diff --git a/plugins/groovy/testdata/paramToMap/callMethod/A.groovy b/plugins/groovy/testdata/paramToMap/callMethod/A.groovy new file mode 100644 index 000000000000..23d1c8b94211 --- /dev/null +++ b/plugins/groovy/testdata/paramToMap/callMethod/A.groovy @@ -0,0 +1,3 @@ +def clos = { int i -> println(i) } +clos(1) +clos.call(1) \ No newline at end of file diff --git a/plugins/groovy/testdata/paramToMap/callMethod/A.test b/plugins/groovy/testdata/paramToMap/callMethod/A.test new file mode 100644 index 000000000000..0b7f54921e34 --- /dev/null +++ b/plugins/groovy/testdata/paramToMap/callMethod/A.test @@ -0,0 +1,3 @@ +def clos = { Map attrs -> println(attrs.i) } +clos(i: 1) +clos.call(i: 1) From b3cac21b5e013e6ef8f9e5a0f4c219c2e6a6b36b Mon Sep 17 00:00:00 2001 From: Maxim Medvedev Date: Tue, 20 Jul 2010 12:57:24 +0400 Subject: [PATCH 06/26] IDEA-56528 Renaming Groovy class should preserve file extension --- .../groovy/lang/psi/impl/PsiImplUtil.java | 31 ++----------------- .../typedef/GrTypeDefinitionImpl.java | 12 +++++-- .../refactoring/rename/RenameTest.groovy | 6 ++++ 3 files changed, 18 insertions(+), 31 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/PsiImplUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/PsiImplUtil.java index c2f07fe0df08..23a3fd0794f6 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/PsiImplUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/PsiImplUtil.java @@ -227,38 +227,11 @@ public class PsiImplUtil { } public static void setName(String name, PsiElement nameElement) { - ASTNode node = nameElement.getNode(); - ASTNode newNameNode = GroovyPsiElementFactory.getInstance(nameElement.getProject()).createReferenceNameFromText(name).getNode(); - assert newNameNode != null && node != null; - node.getTreeParent().replaceChild(node, newNameNode); + final PsiElement newNameElement = GroovyPsiElementFactory.getInstance(nameElement.getProject()).createReferenceNameFromText(name); + nameElement.replace(newNameElement); } public static boolean isExtendsSignature(MethodSignature superSignatureCandidate, MethodSignature subSignature) { - /*final String name1 = superSignatureCandidate.getName(); - final String name2 = subSignature.getName(); - if (!name1.equals(name2)) return false; - - final PsiType[] superTypes = superSignatureCandidate.getParameterTypes(); - final PsiType[] subTypes = subSignature.getParameterTypes(); - if (subTypes.length != superTypes.length) return false; - for (int i = 0; i < subTypes.length - 1; i++) { - PsiType superType = TypeConversionUtil.erasure(superTypes[i]); - PsiType subType = subTypes[i]; - if (!superType.isAssignableFrom(subType)) return false; - } - - if (superTypes.length > 0) { - final PsiType lastSuperType = TypeConversionUtil.erasure(superTypes[superTypes.length - 1]); - final PsiType lastSubType = subTypes[superTypes.length - 1]; - if (lastSuperType instanceof PsiArrayType && !(lastSubType instanceof PsiArrayType)) { - final PsiType componentType = ((PsiArrayType) lastSuperType).getComponentType(); - if (!lastSubType.isConvertibleFrom(componentType)) return false; - } else { - if (!lastSuperType.isAssignableFrom(lastSubType)) return false; - } - } - - return true;*/ return MethodSignatureUtil.isSubsignature(superSignatureCandidate, subSignature); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrTypeDefinitionImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrTypeDefinitionImpl.java index 68d1dc80d232..b21d9252909f 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrTypeDefinitionImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrTypeDefinitionImpl.java @@ -138,6 +138,7 @@ public abstract class GrTypeDefinitionImpl extends GroovyBaseElementImpl Date: Mon, 19 Jul 2010 22:55:15 +0400 Subject: [PATCH 07/26] EA-21019 --- .../com/intellij/codeInspection/ui/InspectionResultsView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java index 5980a99f166a..6d80319c7077 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java @@ -572,7 +572,7 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren if (myTree == null) return null; TreePath[] paths = myTree.getSelectionPaths(); - if (paths == null) return null; + if (paths == null || paths.length == 0) return null; if (paths.length > 1) { if (LangDataKeys.PSI_ELEMENT_ARRAY.is(dataId)) { From 842d07671dbceaf1e1380dae61d0847372551765 Mon Sep 17 00:00:00 2001 From: anna Date: Mon, 19 Jul 2010 23:07:22 +0400 Subject: [PATCH 08/26] @NotNulls --- .../com/intellij/ide/util/newProjectWizard/StepSequence.java | 3 ++- .../src/com/intellij/ide/wizard/AbstractWizard.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/StepSequence.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/StepSequence.java index 26ab9a35bf03..87dd1330a927 100644 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/StepSequence.java +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/StepSequence.java @@ -23,6 +23,7 @@ package com.intellij.ide.util.newProjectWizard; import com.intellij.ide.util.projectWizard.ModuleWizardStep; import com.intellij.openapi.module.ModuleType; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.*; @@ -41,7 +42,7 @@ public class StepSequence { myParentSequence = stepSequence; } - public void addCommonStep(ModuleWizardStep step){ + public void addCommonStep(@NotNull ModuleWizardStep step){ myCommonSteps.add(step); } diff --git a/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizard.java b/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizard.java index 0c6efad5db99..e9c6eab32b81 100644 --- a/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizard.java +++ b/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizard.java @@ -25,6 +25,7 @@ import com.intellij.openapi.ui.Messages; import com.intellij.ui.CommandButtonGroup; import com.intellij.ui.components.panels.OpaquePanel; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -221,7 +222,7 @@ public abstract class AbstractWizard extends DialogWrapper { return mySteps.get(myCurrentStep); } - public void addStep(final T step) { + public void addStep(@NotNull final T step) { mySteps.add(step); if (step instanceof StepAdapter) { From 2bacc5e0ed30cbb7c70e524b53db8d46379f26c4 Mon Sep 17 00:00:00 2001 From: anna Date: Tue, 20 Jul 2010 10:24:51 +0400 Subject: [PATCH 09/26] NPE (EA-20586) --- .../introduceField/IntroduceFieldHandler.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/java/java-impl/src/com/intellij/refactoring/introduceField/IntroduceFieldHandler.java b/java/java-impl/src/com/intellij/refactoring/introduceField/IntroduceFieldHandler.java index 967b5054fd2d..69f89f7678b0 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceField/IntroduceFieldHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceField/IntroduceFieldHandler.java @@ -65,9 +65,13 @@ public class IntroduceFieldHandler extends BaseExpressionToFieldHandler { protected Settings showRefactoringDialog(Project project, Editor editor, PsiClass parentClass, PsiExpression expr, PsiType type, PsiExpression[] occurences, PsiElement anchorElement, PsiElement anchorElementIfAll) { - final PsiMethod containingMethod = PsiTreeUtil.getParentOfType(expr, PsiMethod.class); - PsiElement element = expr.getUserData(ElementToWorkOn.PARENT); - if (element == null) element = expr; + final PsiMethod containingMethod = PsiTreeUtil.getParentOfType(expr != null ? expr : anchorElement, PsiMethod.class); + PsiElement element = null; + if (expr != null) { + element = expr.getUserData(ElementToWorkOn.PARENT); + if (element == null) element = expr; + } + if (element == null) element = anchorElement; final PsiModifierListOwner staticParentElement = PsiUtil.getEnclosingStaticElement(element, parentClass); boolean declareStatic = staticParentElement != null; From c93c6966bff6a67dfea148e20eccc3872f2d0fb3 Mon Sep 17 00:00:00 2001 From: anna Date: Tue, 20 Jul 2010 10:33:27 +0400 Subject: [PATCH 10/26] NPE --- platform/usageView/src/com/intellij/usages/TextChunk.java | 2 +- .../src/com/intellij/usages/UsageInfo2UsageAdapter.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/platform/usageView/src/com/intellij/usages/TextChunk.java b/platform/usageView/src/com/intellij/usages/TextChunk.java index 3888ddae0f8b..bc2cabcef047 100644 --- a/platform/usageView/src/com/intellij/usages/TextChunk.java +++ b/platform/usageView/src/com/intellij/usages/TextChunk.java @@ -23,7 +23,7 @@ public class TextChunk { private final AttributesFlyweight myAttributes; private final String myText; - public TextChunk(TextAttributes attributesKey, @NotNull String text) { + public TextChunk(@NotNull TextAttributes attributesKey, @NotNull String text) { myAttributes = attributesKey.getFlyweight(); myText = text; } diff --git a/platform/usageView/src/com/intellij/usages/UsageInfo2UsageAdapter.java b/platform/usageView/src/com/intellij/usages/UsageInfo2UsageAdapter.java index 7d10f844cf4b..d7bc0a6acb7a 100644 --- a/platform/usageView/src/com/intellij/usages/UsageInfo2UsageAdapter.java +++ b/platform/usageView/src/com/intellij/usages/UsageInfo2UsageAdapter.java @@ -24,6 +24,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.RangeMarker; +import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.fileEditor.*; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; @@ -91,7 +92,7 @@ public class UsageInfo2UsageAdapter implements UsageInModule, UsageInLibrary, Us initChunks(); } else { // element over light virtual file myTextChunks = new TextChunk[] { - new TextChunk(null, element.getText()) + new TextChunk(new TextAttributes(), element.getText()) }; myOffset = element.getTextOffset(); } From 2c41963ef11c2ea3ed4a82c67a06f7c2f42193d4 Mon Sep 17 00:00:00 2001 From: anna Date: Tue, 20 Jul 2010 12:31:47 +0400 Subject: [PATCH 11/26] NPE (EA-19846) --- .../moveMembers/MoveMembersProcessor.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveMembersProcessor.java b/java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveMembersProcessor.java index 6ddce912fa95..bc6d43828c3b 100644 --- a/java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveMembersProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveMembersProcessor.java @@ -156,19 +156,21 @@ public class MoveMembersProcessor extends BaseRefactoringProcessor { protected void performRefactoring(final UsageInfo[] usages) { try { // correct references to moved members from the outside - LanguageExtension extension=new LanguageExtension("com.intellij.refactoring.moveMemberHandler"); PsiClass targetClass = JavaPsiFacade.getInstance(myProject) .findClass(myOptions.getTargetClassName(), GlobalSearchScope.projectScope(myProject)); if (targetClass == null) return; final Map anchors = new HashMap(); for (PsiMember member : myMembersToMove) { - anchors.put(member, extension.forLanguage(member.getLanguage()).getAnchor(member, targetClass)); + final MoveMemberHandler handler = MoveMemberHandler.EP_NAME.forLanguage(member.getLanguage()); + if (handler != null) { + anchors.put(member, handler.getAnchor(member, targetClass)); + } } ArrayList otherUsages = new ArrayList(); for (UsageInfo usageInfo : usages) { MoveMembersUsageInfo usage = (MoveMembersUsageInfo)usageInfo; if (!usage.reference.isValid()) continue; - final MoveMemberHandler handler = extension.forLanguage(usageInfo.getElement().getLanguage()); + final MoveMemberHandler handler = MoveMemberHandler.EP_NAME.forLanguage(usageInfo.getElement().getLanguage()); if (handler!=null) { if (handler.changeExternalUsage(myOptions, usage)) continue; } @@ -189,13 +191,15 @@ public class MoveMembersProcessor extends BaseRefactoringProcessor { } } final RefactoringElementListener elementListener = getTransaction().getElementListener(member); - final MoveMemberHandler handler = extension.forLanguage(member.getLanguage()); - PsiMember newMember=handler.doMove(myOptions, member, anchors.get(member), targetClass); - elementListener.elementMoved(newMember); + final MoveMemberHandler handler = MoveMemberHandler.EP_NAME.forLanguage(member.getLanguage()); + if (handler != null) { + PsiMember newMember=handler.doMove(myOptions, member, anchors.get(member), targetClass); + elementListener.elementMoved(newMember); - fixModifierList(newMember, usages); - for (PsiReference reference : refsToBeRebind) { - reference.bindToElement(newMember); + fixModifierList(newMember, usages); + for (PsiReference reference : refsToBeRebind) { + reference.bindToElement(newMember); + } } } From dbb3eaf4b352a2f45437cf3af2ec96274fdc2f15 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Tue, 20 Jul 2010 13:00:04 +0400 Subject: [PATCH 12/26] PSI builder: more consistent validity checks --- .../intellij/lang/impl/PsiBuilderImpl.java | 80 +++++++++---------- .../intellij/lang/LightPsiBuilderTest.java | 64 +++++++++++++++ 2 files changed, 101 insertions(+), 43 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java b/platform/lang-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java index fd614033652e..7a55ed3f5969 100644 --- a/platform/lang-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java +++ b/platform/lang-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java @@ -569,15 +569,7 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder { @SuppressWarnings({"SuspiciousMethodCalls"}) public void doneBefore(Marker marker, Marker before) { -// TODO: there could be not done markers after 'marker' and that's normal - if (((StartMarker)marker).myDoneMarker != null) { - LOG.error("Marker already done."); - } - - int idx = myProduction.lastIndexOf(marker); - if (idx < 0) { - LOG.error("Marker never been added."); - } + doValidityChecks(marker, before); int beforeIndex = myProduction.lastIndexOf(before); @@ -599,7 +591,7 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder { } public void error(Marker marker, String message) { - doValidityChecks(marker); + doValidityChecks(marker, null); DoneWithErrorMarker doneMarker = new DoneWithErrorMarker((StartMarker)marker, myCurrentLexeme, message); ((StartMarker)marker).myDoneMarker = doneMarker; @@ -608,27 +600,18 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder { @SuppressWarnings({"SuspiciousMethodCalls"}) public void errorBefore(Marker marker, String message, Marker before) { -// TODO: there could be not done markers after 'marker' and that's normal - if (((StartMarker)marker).myDoneMarker != null) { - LOG.error("Marker already done."); - } - - int idx = myProduction.lastIndexOf(marker); - if (idx < 0) { - LOG.error("Marker has never been added."); - } + doValidityChecks(marker, before); int beforeIndex = myProduction.lastIndexOf(before); DoneWithErrorMarker doneMarker = new DoneWithErrorMarker((StartMarker)marker, myCurrentLexeme, message); doneMarker.myLexemeIndex = ((StartMarker)before).myLexemeIndex; - ((StartMarker)marker).myDoneMarker = doneMarker; myProduction.add(beforeIndex, doneMarker); } public void done(final Marker marker) { - doValidityChecks(marker); + doValidityChecks(marker, null); DoneMarker doneMarker = DONE_MARKERS.alloc(); doneMarker.myStart = (StartMarker)marker; @@ -644,30 +627,41 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder { } @SuppressWarnings({"UseOfSystemOutOrSystemErr", "SuspiciousMethodCalls"}) - private void doValidityChecks(final Marker marker) { - if (myDebugMode) { - final DoneMarker doneMarker = ((StartMarker)marker).myDoneMarker; - if (doneMarker != null) { - LOG.error("Marker already done."); - } - int idx = myProduction.lastIndexOf(marker); - if (idx < 0) { - LOG.error("Marker never been added."); - } + private void doValidityChecks(final Marker marker, @Nullable final Marker before) { + if (!myDebugMode) return; - for (int i = myProduction.size() - 1; i > idx; i--) { - Object item = myProduction.get(i); - if (item instanceof StartMarker) { - StartMarker otherMarker = (StartMarker)item; - if (otherMarker.myDoneMarker == null) { - final Throwable debugAllocOther = otherMarker.myDebugAllocationPosition; - final Throwable debugAllocThis = ((StartMarker)marker).myDebugAllocationPosition; - if (debugAllocOther != null) { - debugAllocThis.printStackTrace(System.err); - debugAllocOther.printStackTrace(System.err); - } - LOG.error("Another not done marker added after this one. Must be done before this."); + final DoneMarker doneMarker = ((StartMarker)marker).myDoneMarker; + if (doneMarker != null) { + LOG.error("Marker already done."); + } + int idx = myProduction.lastIndexOf(marker); + if (idx < 0) { + LOG.error("Marker has never been added."); + } + + int endIdx = myProduction.size(); + if (before != null) { + endIdx = myProduction.lastIndexOf(before); + if (endIdx < 0) { + LOG.error("'Before' marker has never been added."); + } + if (idx > endIdx) { + LOG.error("'Before' marker precedes this one."); + } + } + + for (int i = endIdx - 1; i > idx; i--) { + Object item = myProduction.get(i); + if (item instanceof StartMarker) { + StartMarker otherMarker = (StartMarker)item; + if (otherMarker.myDoneMarker == null) { + final Throwable debugAllocOther = otherMarker.myDebugAllocationPosition; + final Throwable debugAllocThis = ((StartMarker)marker).myDebugAllocationPosition; + if (debugAllocOther != null) { + debugAllocThis.printStackTrace(System.err); + debugAllocOther.printStackTrace(System.err); } + LOG.error("Another not done marker added after this one. Must be done before this."); } } } diff --git a/platform/lang-impl/testSrc/com/intellij/lang/LightPsiBuilderTest.java b/platform/lang-impl/testSrc/com/intellij/lang/LightPsiBuilderTest.java index 83ee93a92f03..111228759fff 100644 --- a/platform/lang-impl/testSrc/com/intellij/lang/LightPsiBuilderTest.java +++ b/platform/lang-impl/testSrc/com/intellij/lang/LightPsiBuilderTest.java @@ -20,9 +20,13 @@ import com.intellij.lexer.LexerBase; import com.intellij.psi.impl.DebugUtil; import com.intellij.psi.tree.IElementType; import com.intellij.psi.tree.TokenSet; +import com.sun.tools.internal.xjc.util.NullStream; import org.junit.Test; +import java.io.PrintStream; + import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; public class LightPsiBuilderTest { @@ -140,6 +144,45 @@ public class LightPsiBuilderTest { " PsiElement(DIGIT)('1')\n"); } + @Test + public void testValidityChecksOnDone() throws Exception { + doFailTest("a", + new Parser() { + public void parse(PsiBuilder builder) { + final PsiBuilder.Marker first = builder.mark(); + builder.advanceLexer(); + builder.mark(); + first.done(LETTER); + } + }); + } + + @Test + public void testValidityChecksOnDoneBefore1() throws Exception { + doFailTest("a", + new Parser() { + public void parse(PsiBuilder builder) { + final PsiBuilder.Marker first = builder.mark(); + builder.advanceLexer(); + final PsiBuilder.Marker second = builder.mark(); + second.precede(); + first.doneBefore(LETTER, second); + } + }); + } + + @Test + public void testValidityChecksOnDoneBefore2() throws Exception { + doFailTest("a", + new Parser() { + public void parse(PsiBuilder builder) { + final PsiBuilder.Marker first = builder.mark(); + builder.advanceLexer(); + final PsiBuilder.Marker second = builder.mark(); + second.doneBefore(LETTER, first); + } + }); + } private interface Parser { void parse(PsiBuilder builder); @@ -154,6 +197,27 @@ public class LightPsiBuilderTest { assertEquals(expected, DebugUtil.nodeTreeToString(root, true)); } + private static void doFailTest(final String text, final Parser parser) { + final PrintStream std = System.err; + //noinspection IOResourceOpenedButNotSafelyClosed + System.setErr(new PrintStream(new NullStream())); + try { + try { + final PsiBuilder builder = new PsiBuilderImpl(new MyTestLexer(), TokenSet.EMPTY, TokenSet.EMPTY, text); + builder.setDebugMode(true); + parser.parse(builder); + fail("should fail"); + } + catch (AssertionError e) { + //System.out.println("caught: " + e); + if ("should fail".equals(e.getMessage())) throw e; + } + } + finally { + System.setErr(std); + } + } + private static class MyTestLexer extends LexerBase { private CharSequence myBuffer = ""; private int myIndex = 0; From aca6ea27a8ee4fc7389f775fd0a9210799b69aa1 Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Mon, 19 Jul 2010 16:33:01 +0400 Subject: [PATCH 13/26] IDEA-56168: duplicate id reference inspection marks good code as error --- .../src/com/intellij/xml/util/XmlRefCountHolder.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/xml/impl/src/com/intellij/xml/util/XmlRefCountHolder.java b/xml/impl/src/com/intellij/xml/util/XmlRefCountHolder.java index 58c1ead70368..ef8dc3839ce9 100644 --- a/xml/impl/src/com/intellij/xml/util/XmlRefCountHolder.java +++ b/xml/impl/src/com/intellij/xml/util/XmlRefCountHolder.java @@ -17,7 +17,6 @@ package com.intellij.xml.util; import com.intellij.codeInsight.daemon.impl.analysis.XmlHighlightVisitor; import com.intellij.lang.Language; -import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.UserDataCache; @@ -31,6 +30,7 @@ import com.intellij.psi.util.CachedValueProvider; import com.intellij.psi.util.CachedValuesManager; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.xml.*; +import com.intellij.util.NullableFunction; import com.intellij.util.containers.ContainerUtil; import com.intellij.xml.XmlAttributeDescriptor; import com.intellij.xml.XmlElementDescriptor; @@ -102,14 +102,14 @@ public class XmlRefCountHolder { } else if (!soft) { // mark as duplicate - Pair notSoft = ContainerUtil.find(list, new Condition>() { + List notSoft = ContainerUtil.mapNotNull(list, new NullableFunction, XmlAttributeValue>() { @Override - public boolean value(Pair xmlAttributeValueBooleanPair) { - return !xmlAttributeValueBooleanPair.second; + public XmlAttributeValue fun(Pair pair) { + return pair.second ? null : pair.first; } }); - if (notSoft != null) { - myPossiblyDuplicateIds.add(notSoft.first); + if (!notSoft.isEmpty()) { + myPossiblyDuplicateIds.addAll(notSoft); myPossiblyDuplicateIds.add(attributeValue); } } From ff490194ebc96443b1a36a19f1e4e45a8c6af46d Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Mon, 19 Jul 2010 19:19:43 +0400 Subject: [PATCH 14/26] exclude zipped files --- .../psi/impl/include/FileIncludeIndex.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/psi/impl/include/FileIncludeIndex.java b/platform/lang-impl/src/com/intellij/psi/impl/include/FileIncludeIndex.java index fea3861e633b..997c4578e2f4 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/include/FileIncludeIndex.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/include/FileIncludeIndex.java @@ -17,6 +17,7 @@ package com.intellij.psi.impl.include; import com.intellij.openapi.extensions.Extensions; +import com.intellij.openapi.vfs.JarFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.util.containers.FactoryMap; @@ -68,14 +69,14 @@ public class FileIncludeIndex extends FileBasedIndexExtension, FileContent> getIndexer() { - return new DataIndexer, FileContent>() { + public DataIndexer, FileContent> getIndexer() { + return new DataIndexer, FileContent>() { @NotNull - public Map> map(FileContent inputData) { + public Map> map(FileContent inputData) { - Map> map = new FactoryMap>() { + Map> map = new FactoryMap>() { @Override - protected List create(FileIncludeIndex.Key key) { + protected List create(Key key) { return new ArrayList(); } }; @@ -144,6 +145,9 @@ public class FileIncludeIndex extends FileBasedIndexExtension Date: Mon, 19 Jul 2010 20:04:26 +0400 Subject: [PATCH 15/26] hide actions not relevant for current language --- .../actions/BaseRefactoringAction.java | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/refactoring/actions/BaseRefactoringAction.java b/platform/lang-impl/src/com/intellij/refactoring/actions/BaseRefactoringAction.java index f738a908d8af..fe2e9504d750 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/actions/BaseRefactoringAction.java +++ b/platform/lang-impl/src/com/intellij/refactoring/actions/BaseRefactoringAction.java @@ -83,12 +83,8 @@ public abstract class BaseRefactoringAction extends AnAction { presentation.setEnabled(true); DataContext dataContext = e.getDataContext(); Project project = e.getData(PlatformDataKeys.PROJECT); - if (project == null) { - disableAction(e); - return; - } - if (isHidden()) { - e.getPresentation().setVisible(false); + if (project == null || isHidden()) { + hideAction(e); return; } @@ -103,7 +99,7 @@ public abstract class BaseRefactoringAction extends AnAction { if (editor == null) { if (isAvailableInEditorOnly()) { - disableAction(e); + hideAction(e); return; } final PsiElement[] elements = getPsiElementArray(dataContext); @@ -116,21 +112,30 @@ public abstract class BaseRefactoringAction extends AnAction { PsiElement element = e.getData(LangDataKeys.PSI_ELEMENT); if (element == null || !isAvailableForLanguage(element.getLanguage())) { if (file == null) { - disableAction(e); + hideAction(e); return; } element = getElementAtCaret(editor, file); } - final boolean isEnabled = element != null && - !(element instanceof SyntheticElement) && - isAvailableForLanguage(PsiUtilBase.getLanguageInEditor(editor, project)) && - isAvailableOnElementInEditor(element, editor); - if (!isEnabled) { - disableAction(e); + boolean isVisible = element != null && + !(element instanceof SyntheticElement) && + isAvailableForLanguage(PsiUtilBase.getLanguageInEditor(editor, project)); + if (isVisible) { + boolean isEnabled = isAvailableOnElementInEditor(element, editor); + if (!isEnabled) { + disableAction(e); + } + } + else { + hideAction(e); } } } + private static void hideAction(AnActionEvent e) { + e.getPresentation().setVisible(false); + } + protected boolean isHidden() { return false; } @@ -162,7 +167,7 @@ public abstract class BaseRefactoringAction extends AnAction { private static void disableAction(final AnActionEvent e) { e.getPresentation().setEnabled(false); if (ActionPlaces.isPopupPlace(e.getPlace())) { - e.getPresentation().setVisible(false); + hideAction(e); } } From f1a2ef058338d5df21686fa386e7985278213baf Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Tue, 20 Jul 2010 14:36:08 +0400 Subject: [PATCH 16/26] Inline Included File reanimated --- .../intellij/lang/refactoring/InlineActionHandler.java | 4 ++++ .../lang-api/src/com/intellij/psi/util/PsiUtilBase.java | 8 ++++++++ .../com/intellij/refactoring/actions/InlineAction.java | 8 ++++---- .../src/messages/RefactoringBundle.properties | 7 +++---- xml/openapi/src/com/intellij/psi/xml/XmlTagChild.java | 1 - 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/platform/lang-api/src/com/intellij/lang/refactoring/InlineActionHandler.java b/platform/lang-api/src/com/intellij/lang/refactoring/InlineActionHandler.java index 950d9660c986..bc9ddaf7a954 100644 --- a/platform/lang-api/src/com/intellij/lang/refactoring/InlineActionHandler.java +++ b/platform/lang-api/src/com/intellij/lang/refactoring/InlineActionHandler.java @@ -38,6 +38,10 @@ public abstract class InlineActionHandler { return canInlineElement(element); } + public boolean isEnabledOnElement(PsiElement element, Editor editor) { + return isEnabledOnElement(element); + } + public abstract boolean isEnabledForLanguage(Language l); public abstract boolean canInlineElement(PsiElement element); diff --git a/platform/lang-api/src/com/intellij/psi/util/PsiUtilBase.java b/platform/lang-api/src/com/intellij/psi/util/PsiUtilBase.java index 34509ab6cb43..02577d3b0d7b 100644 --- a/platform/lang-api/src/com/intellij/psi/util/PsiUtilBase.java +++ b/platform/lang-api/src/com/intellij/psi/util/PsiUtilBase.java @@ -431,6 +431,14 @@ public class PsiUtilBase { return narrowLanguage(lang, file.getLanguage()); } + @Nullable + public static PsiElement getElementAtCaret(Editor editor) { + Project project = editor.getProject(); + if (project == null) return null; + PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()); + return file == null ? null : file.findElementAt(editor.getCaretModel().getOffset()); + } + public static Language getDialect(@NotNull PsiElement element) { return narrowLanguage(element.getLanguage(), element.getContainingFile().getLanguage()); } diff --git a/platform/lang-impl/src/com/intellij/refactoring/actions/InlineAction.java b/platform/lang-impl/src/com/intellij/refactoring/actions/InlineAction.java index 2f60105e59ee..dd167029e2c1 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/actions/InlineAction.java +++ b/platform/lang-impl/src/com/intellij/refactoring/actions/InlineAction.java @@ -45,16 +45,16 @@ public class InlineAction extends BasePlatformRefactoringAction { @Override protected boolean isAvailableOnElementInEditor(PsiElement element, Editor editor) { - return hasInlineActionHandler(element, PsiUtilBase.getLanguageInEditor(editor, element.getProject())); + return hasInlineActionHandler(element, PsiUtilBase.getLanguageInEditor(editor, element.getProject()), editor); } public boolean isEnabledOnElements(PsiElement[] elements) { - return elements.length == 1 && hasInlineActionHandler(elements [0], null); + return elements.length == 1 && hasInlineActionHandler(elements [0], null, null); } - private static boolean hasInlineActionHandler(PsiElement element, @Nullable Language editorLanguage) { + private static boolean hasInlineActionHandler(PsiElement element, @Nullable Language editorLanguage, Editor editor) { for(InlineActionHandler handler: Extensions.getExtensions(InlineActionHandler.EP_NAME)) { - if (handler.isEnabledOnElement(element)) { + if (handler.isEnabledOnElement(element, editor)) { return true; } } diff --git a/platform/platform-resources-en/src/messages/RefactoringBundle.properties b/platform/platform-resources-en/src/messages/RefactoringBundle.properties index 69c2d469036d..031d2b333c23 100644 --- a/platform/platform-resources-en/src/messages/RefactoringBundle.properties +++ b/platform/platform-resources-en/src/messages/RefactoringBundle.properties @@ -452,11 +452,10 @@ instances.upcasted.to.object=Instances upcasted to Object instances.upcasted.to.java.lang.object.found=Instances upcasted to java.lang.Object found replace.inheritance.with.delegation.command=Replacing inheritance with delegation in {0} replace.inheritance.with.delegation.elements.header=Replace inheritance with delegation +# Inline included file inline.included.file.title=Inline included file -the.caret.should.be.positioned.on.the.include.directive.to.inline=The caret should be positioned on the include directive to inline -cannot.determine.the.structure.of.included.file=Cannot determine the structure of included file. -included.file.uses.another.syntax=Included file uses another syntax. -cannot.resolve.included.file=Cannot resolve included file +the.caret.should.be.positioned.on.the.included.file.to.inline=The caret should be positioned on the included file reference to inline + inline.the.contents.include.prompt=Inline the contents of ''{0}''? remove.include.prompt=Included file is no longer used. Remove it? delete.include.command=Delete {0} diff --git a/xml/openapi/src/com/intellij/psi/xml/XmlTagChild.java b/xml/openapi/src/com/intellij/psi/xml/XmlTagChild.java index 60c822b92d3a..5e0129ab5df5 100644 --- a/xml/openapi/src/com/intellij/psi/xml/XmlTagChild.java +++ b/xml/openapi/src/com/intellij/psi/xml/XmlTagChild.java @@ -20,7 +20,6 @@ import org.jetbrains.annotations.Nullable; public interface XmlTagChild extends XmlElement{ XmlTagChild[] EMPTY_ARRAY = new XmlTagChild[0]; - @Nullable XmlTag getParentTag(); @Nullable From 5d575db14294b9af17c58c8a985e9a95d7fa97a4 Mon Sep 17 00:00:00 2001 From: anna Date: Tue, 20 Jul 2010 13:36:34 +0400 Subject: [PATCH 17/26] preserve suggestions order --- .../src/com/intellij/refactoring/rename/RenameDialog.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/RenameDialog.java b/platform/lang-impl/src/com/intellij/refactoring/rename/RenameDialog.java index e323b8732287..bfa5458b7066 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/rename/RenameDialog.java +++ b/platform/lang-impl/src/com/intellij/refactoring/rename/RenameDialog.java @@ -134,7 +134,7 @@ public class RenameDialog extends RefactoringDialog { } public String[] getSuggestedNames() { - Set result = new HashSet(); + LinkedHashSet result = new LinkedHashSet(); final NameSuggestionProvider[] providers = Extensions.getExtensions(NameSuggestionProvider.EP_NAME); for(NameSuggestionProvider provider: providers) { SuggestedNameInfo info = provider.getSuggestedNames(myPsiElement, myNameSuggestionContext, result); From 23f0bfee45e5181effea97effcfe2ec8939db08a Mon Sep 17 00:00:00 2001 From: Kirill Kalishev Date: Tue, 20 Jul 2010 15:09:46 +0400 Subject: [PATCH 18/26] deferred painting, fix for uml --- .../src/com/intellij/ui/DeferredIconImpl.java | 81 +++++++++++++++---- .../src/com/intellij/ui/PaintingParent.java | 39 +++++++++ 2 files changed, 105 insertions(+), 15 deletions(-) create mode 100644 platform/platform-api/src/com/intellij/ui/PaintingParent.java diff --git a/platform/lang-impl/src/com/intellij/ui/DeferredIconImpl.java b/platform/lang-impl/src/com/intellij/ui/DeferredIconImpl.java index 7dbc4a248c92..11c207c33154 100644 --- a/platform/lang-impl/src/com/intellij/ui/DeferredIconImpl.java +++ b/platform/lang-impl/src/com/intellij/ui/DeferredIconImpl.java @@ -23,6 +23,7 @@ import com.intellij.concurrency.Job; import com.intellij.concurrency.JobUtil; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.project.IndexNotReadyException; +import com.intellij.openapi.util.Ref; import com.intellij.util.Alarm; import com.intellij.util.Function; import com.intellij.util.ui.EmptyIcon; @@ -66,29 +67,37 @@ public class DeferredIconImpl implements DeferredIcon { if (!myIsScheduled) { myIsScheduled = true; - final Component target; + final Ref target = new Ref(null); + final Ref paintingParent = new Ref(null); + final Ref paintingParentRec = new Ref(null); final Container list = SwingUtilities.getAncestorOfClass(JList.class, c); if (list != null) { - target = list; + target.set(list); } else { final Container tree = SwingUtilities.getAncestorOfClass(JTree.class, c); if (tree != null) { - target = tree; + target.set(tree); } else { final Container table = SwingUtilities.getAncestorOfClass(JTable.class, c); if (table != null) { - target = table; + target.set(table); } else { - target = c; + target.set(c); } } } - myLastTarget = new WeakReference(target); + Container pp = SwingUtilities.getAncestorOfClass(PaintingParent.class, c); + paintingParent.set(pp); + if (paintingParent.get() != null) { + paintingParentRec.set(((PaintingParent)pp).getChildRec(c)); + } + + myLastTarget = new WeakReference(target.get()); JobUtil.submitToJobThread(new Runnable() { public void run() { @@ -100,10 +109,23 @@ public class DeferredIconImpl implements DeferredIcon { //noinspection SSBasedInspection SwingUtilities.invokeLater(new Runnable() { public void run() { + Component actualTarget = target.get(); + if (SwingUtilities.getWindowAncestor(actualTarget) == null) { + actualTarget = paintingParent.get(); + if (actualTarget == null || SwingUtilities.getWindowAncestor(actualTarget) == null) { + actualTarget = null; + myLastTarget = null; + } + } + + if (actualTarget == null) return; + + myLastTarget = new WeakReference(actualTarget); + if (shouldRevalidate) { // revalidate will not work: jtree caches size of nodes - if (target instanceof JTree) { - final TreeUI ui = ((JTree)target).getUI(); + if (actualTarget instanceof JTree) { + final TreeUI ui = ((JTree)actualTarget).getUI(); if (ui instanceof BasicTreeUI) { // this call is "fake" and only need to reset tree layout cache ((BasicTreeUI)ui).setLeftChildIndent(((Integer)UIManager.get("Tree.leftChildIndent")).intValue()); @@ -111,11 +133,16 @@ public class DeferredIconImpl implements DeferredIcon { } } - if (c == target) { + if (c == actualTarget) { c.repaint(x, y, getIconWidth(), getIconHeight()); } else { - ourRepaintScheduler.pushDirtyComponent(target); + Rectangle rec = null; + if (paintingParentRec.get() != null) { + rec = paintingParentRec.get(); + } + + ourRepaintScheduler.pushDirtyComponent(actualTarget, rec); } } }); @@ -191,20 +218,44 @@ public class DeferredIconImpl implements DeferredIcon { private static class RepaintScheduler { private final Alarm myAlarm = new Alarm(); - private final Set myQueue = new LinkedHashSet(); + private final Set myQueue = new LinkedHashSet(); - public void pushDirtyComponent(Component c) { + public void pushDirtyComponent(final Component c, final Rectangle rec) { myAlarm.cancelAllRequests(); myAlarm.addRequest(new Runnable() { public void run() { - for (Component component : myQueue) { - component.repaint(); + for (RepaintRequest each : myQueue) { + Rectangle r = each.getRectangle(); + if (r != null) { + each.getComponent().repaint(r.x, r.y, r.width, r.height); + } else { + each.getComponent().repaint(); + } } myQueue.clear(); } }, 50); - myQueue.add(c); + myQueue.add(new RepaintRequest(c, rec)); } } + + private static class RepaintRequest { + private Component myComponent; + private Rectangle myRectangle; + + private RepaintRequest(Component component, Rectangle rectangle) { + myComponent = component; + myRectangle = rectangle; + } + + public Component getComponent() { + return myComponent; + } + + public Rectangle getRectangle() { + return myRectangle; + } + } + } diff --git a/platform/platform-api/src/com/intellij/ui/PaintingParent.java b/platform/platform-api/src/com/intellij/ui/PaintingParent.java new file mode 100644 index 000000000000..a49f1235e11f --- /dev/null +++ b/platform/platform-api/src/com/intellij/ui/PaintingParent.java @@ -0,0 +1,39 @@ +/* + * Copyright 2000-2010 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.ui; + +import org.jetbrains.annotations.Nullable; + +import java.awt.*; + +/** + * Used for deferred re-painting (i.e. for deferred icons). As a paint() method is invoked through the normal AWT painting cycle, deferred painting + * of children may be queued. It means that actual data used for painting is pushed for calculation and, as it gets ready, there is need for repaint. + * The target component for further repaint() is either the component that was originally exposed to painting or, if it's no longer showing (in case of a flyweight + * renderer) -- the first component up in the hierarchy that implements PaintingParent. + * + */ +public interface PaintingParent { + + /** + * Returns rectangle of a child component for further repainting + * @param c + * @return a rectange, if null -- the whole component will be repainted + */ + @Nullable + Rectangle getChildRec(Component c); + +} From 8329536c4999347b654adb9dcb36bdb226b37572 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Tue, 20 Jul 2010 15:54:28 +0400 Subject: [PATCH 19/26] case-insensitive comparator (IDEA-56602) --- .../intellij/openapi/wm/impl/welcomeScreen/WelcomeScreen.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/WelcomeScreen.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/WelcomeScreen.java index a23ab8fb9e91..2a54b574ba1b 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/WelcomeScreen.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/WelcomeScreen.java @@ -440,7 +440,7 @@ public class WelcomeScreen { final boolean e2 = ((IdeaPluginDescriptorImpl)o2).isEnabled(); if (e1 && !e2) return -1; if (!e1 && e2) return 1; - return o1.getName().compareTo(o2.getName()); + return o1.getName().toLowerCase().compareTo(o2.getName().toLowerCase()); } }; Collections.sort(installedPlugins, pluginsComparator); From 04095647a5ab2d7c857893be1a11e354dadd080f Mon Sep 17 00:00:00 2001 From: Maxim Medvedev Date: Tue, 20 Jul 2010 16:04:36 +0400 Subject: [PATCH 20/26] IDEA-47083 Quickfix to convert Java-style array creation to Groovy-style --- plugins/groovy/src/META-INF/plugin.xml | 5 ++ .../GroovyIntentionsBundle.properties | 5 +- ...onvertJavaStyleArrayCreationIntention.java | 65 +++++++++++++++++++ .../ConvertJavaStyleArrayCreationTest.java | 32 +++++++++ .../Conversion.groovy | 1 + .../Conversion_after.groovy | 1 + 6 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/ConvertJavaStyleArrayCreationIntention.java create mode 100644 plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/ConvertJavaStyleArrayCreationTest.java create mode 100644 plugins/groovy/testdata/intentions/convertJavaStyleArrayCreation/Conversion.groovy create mode 100644 plugins/groovy/testdata/intentions/convertJavaStyleArrayCreation/Conversion_after.groovy diff --git a/plugins/groovy/src/META-INF/plugin.xml b/plugins/groovy/src/META-INF/plugin.xml index 0418c136e6bf..1eedae80b8bd 100644 --- a/plugins/groovy/src/META-INF/plugin.xml +++ b/plugins/groovy/src/META-INF/plugin.xml @@ -375,6 +375,11 @@ --> + + org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle + intention.category.groovy/intention.category.conversions + org.jetbrains.plugins.groovy.intentions.conversions.ConvertJavaStyleArrayCreationIntention + org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle intention.category.groovy/intention.category.conversions 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 113f31b0d971..beb7dffac824 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/GroovyIntentionsBundle.properties +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/GroovyIntentionsBundle.properties @@ -82,4 +82,7 @@ do.not.create.first.new=Use &existing first parameter as map for named arguments convert.cannot.itself=Refactoring is not available for map parameter itself perform.refactoring=Performing refactoring map.param.name=Map parameter &name: -convert.param.to.map.entry=Convert parameter to map entry \ No newline at end of file +convert.param.to.map.entry=Convert parameter to map entry + +convert.java.style.array.creation.intention.name=Convert java-style array creation +convert.java.style.array.creation.intention.family.name=Convert Java-Style Array Creation to Groovy Syntax \ No newline at end of file diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/ConvertJavaStyleArrayCreationIntention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/ConvertJavaStyleArrayCreationIntention.java new file mode 100644 index 000000000000..a2c6052d879e --- /dev/null +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/ConvertJavaStyleArrayCreationIntention.java @@ -0,0 +1,65 @@ +/* + * Copyright 2000-2010 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.plugins.groovy.intentions.conversions; + +import com.intellij.psi.PsiElement; +import com.intellij.util.IncorrectOperationException; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.plugins.groovy.intentions.base.Intention; +import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate; +import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrNewExpression; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrMethodCallExpression; + +/** + * @author Maxim.Medvedev + */ +public class ConvertJavaStyleArrayCreationIntention extends Intention { + @Override + protected void processIntention(@NotNull PsiElement element) throws IncorrectOperationException { + final GrClosableBlock block = ((GrMethodCallExpression)element).getClosureArguments()[0]; + final String text = block.getText(); + int start = block.getLBrace().getStartOffsetInParent() + 1; + int finish = block.getRBrace().getStartOffsetInParent(); + String newText = "[" + text.substring(start, finish) + "]"; + final GrExpression newExpr = GroovyPsiElementFactory.getInstance(element.getProject()).createExpressionFromText(newText); + ((GrMethodCallExpression)element).replaceWithStatement(newExpr); + } + + @NotNull + @Override + protected PsiElementPredicate getElementPredicate() { + return new PsiElementPredicate() { + @Override + public boolean satisfiedBy(PsiElement element) { + if (!(element instanceof GrMethodCallExpression)) return false; + final GrExpression expression = ((GrMethodCallExpression)element).getInvokedExpression(); + if (!(expression instanceof GrNewExpression)) return false; + if (((GrNewExpression)expression).getArrayCount() == 0) return false; + + if (((GrMethodCallExpression)element).getArgumentList().getText().trim().length() > 0) return false; + + final GrClosableBlock[] closureArguments = ((GrMethodCallExpression)element).getClosureArguments(); + if (closureArguments.length != 1) return false; + final GrClosableBlock block = closureArguments[0]; + if (block.getLBrace() == null || block.getRBrace() == null) return false; + return true; + } + }; + } +} diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/ConvertJavaStyleArrayCreationTest.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/ConvertJavaStyleArrayCreationTest.java new file mode 100644 index 000000000000..0353936fa62a --- /dev/null +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/ConvertJavaStyleArrayCreationTest.java @@ -0,0 +1,32 @@ +/* + * Copyright 2000-2010 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.plugins.groovy.intentions; + +import org.jetbrains.plugins.groovy.util.TestUtils; + +/** + * @author Maxim.Medvedev + */ +public class ConvertJavaStyleArrayCreationTest extends GrIntentionTestCase{ + @Override + protected String getBasePath() { + return TestUtils.getTestDataPath() + "intentions/convertJavaStyleArrayCreation/"; + } + + public void testConversion() { + doTest(GroovyIntentionsBundle.message("convert.java.style.array.creation.intention.name"), true); + } +} diff --git a/plugins/groovy/testdata/intentions/convertJavaStyleArrayCreation/Conversion.groovy b/plugins/groovy/testdata/intentions/convertJavaStyleArrayCreation/Conversion.groovy new file mode 100644 index 000000000000..11781d79e883 --- /dev/null +++ b/plugins/groovy/testdata/intentions/convertJavaStyleArrayCreation/Conversion.groovy @@ -0,0 +1 @@ +def foo = new Object[] {1, 2, 3} \ No newline at end of file diff --git a/plugins/groovy/testdata/intentions/convertJavaStyleArrayCreation/Conversion_after.groovy b/plugins/groovy/testdata/intentions/convertJavaStyleArrayCreation/Conversion_after.groovy new file mode 100644 index 000000000000..2be10eba8fd1 --- /dev/null +++ b/plugins/groovy/testdata/intentions/convertJavaStyleArrayCreation/Conversion_after.groovy @@ -0,0 +1 @@ +def foo = [1, 2, 3] \ No newline at end of file From ca690f8efc43341b6c052cf571b13517db8fa8de Mon Sep 17 00:00:00 2001 From: Maxim Medvedev Date: Tue, 20 Jul 2010 16:13:33 +0400 Subject: [PATCH 21/26] IDEA-47083 intention description --- .../after.groovy.template | 1 + .../before.groovy.template | 1 + .../description.html | 7 +++++++ 3 files changed, 9 insertions(+) create mode 100644 plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/after.groovy.template create mode 100644 plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/before.groovy.template create mode 100644 plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/description.html diff --git a/plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/after.groovy.template b/plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/after.groovy.template new file mode 100644 index 000000000000..221308e2c833 --- /dev/null +++ b/plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/after.groovy.template @@ -0,0 +1 @@ +def objects = [foo, bar] \ No newline at end of file diff --git a/plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/before.groovy.template b/plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/before.groovy.template new file mode 100644 index 000000000000..9944d004075f --- /dev/null +++ b/plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/before.groovy.template @@ -0,0 +1 @@ +def objects = new Object[] {foo, bar} diff --git a/plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/description.html b/plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/description.html new file mode 100644 index 000000000000..a57eb1cb3c81 --- /dev/null +++ b/plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/description.html @@ -0,0 +1,7 @@ + + + +This intention converts java-style array creation to groovy syntax. + + + From ba50b765d85c7f90be7b3c8c0818f6526b442b75 Mon Sep 17 00:00:00 2001 From: Kirill Kalishev Date: Tue, 20 Jul 2010 17:34:35 +0400 Subject: [PATCH 22/26] navbar popup fix --- .../src/com/intellij/ide/navigationToolbar/NavBarPanel.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarPanel.java b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarPanel.java index b0dc4e89699c..139614aae1c7 100644 --- a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarPanel.java +++ b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarPanel.java @@ -555,6 +555,10 @@ public class NavBarPanel extends OpaquePanel.List implements DataProvider, Popup } }); + if (!isValid()) { + validate(); + } + myNodePopup.showUnderneathOf(item); } } From 1649c442f2e2c00ca68fd7e67db3491e62791d86 Mon Sep 17 00:00:00 2001 From: Kirill Kalishev Date: Tue, 20 Jul 2010 17:39:09 +0400 Subject: [PATCH 23/26] optimized project files for CE project --- .idea/libraries/Ant.xml | 1 - .idea/libraries/CGLIB.xml | 1 - .idea/libraries/DTDParser.xml | 2 -- .idea/libraries/EasyMock.xml | 2 -- .idea/libraries/Eclipse.xml | 1 - .idea/libraries/Gant.xml | 1 - .idea/libraries/Groovy.xml | 1 - .idea/libraries/JDOM.xml | 1 - .idea/libraries/JMock1.xml | 2 -- .idea/libraries/JUnit3.xml | 2 -- .idea/libraries/JUnit4.xml | 1 - .idea/libraries/JavaHelp.xml | 1 - .idea/libraries/Jaxen.xml | 2 -- .idea/libraries/Log4J.xml | 1 - .idea/libraries/Mac.xml | 1 - .idea/libraries/Mocks.xml | 2 -- .idea/libraries/NanoXML.xml | 1 - .idea/libraries/OroMatcher.xml | 2 -- .idea/libraries/TestNG.xml | 2 -- .idea/libraries/Trove4j.xml | 1 - .idea/libraries/Velocity.xml | 1 - .idea/libraries/XStream.xml | 2 -- .idea/libraries/Xerces.xml | 1 - .idea/libraries/XmlBeans.xml | 2 -- .idea/libraries/XmlRPC.xml | 1 - .idea/libraries/asm.xml | 1 - .idea/libraries/commons_codec.xml | 2 -- .idea/libraries/commons_collections.xml | 1 - .idea/libraries/commons_lang.xml | 2 -- .idea/libraries/commons_net.xml | 1 - .idea/libraries/jcip.xml | 2 -- .idea/libraries/jgoodies_forms.xml | 1 - .idea/libraries/jna.xml | 2 -- .idea/libraries/microba.xml | 2 -- .idea/libraries/picocontainer.xml | 1 - .idea/libraries/tcServiceMessages.xml | 1 - 36 files changed, 51 deletions(-) diff --git a/.idea/libraries/Ant.xml b/.idea/libraries/Ant.xml index dfdd147fd7bc..4d69c6899db3 100644 --- a/.idea/libraries/Ant.xml +++ b/.idea/libraries/Ant.xml @@ -28,7 +28,6 @@ - diff --git a/.idea/libraries/CGLIB.xml b/.idea/libraries/CGLIB.xml index 061f6f213744..b7e692fa647e 100644 --- a/.idea/libraries/CGLIB.xml +++ b/.idea/libraries/CGLIB.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/DTDParser.xml b/.idea/libraries/DTDParser.xml index dcc82b44e627..c40d012406c8 100644 --- a/.idea/libraries/DTDParser.xml +++ b/.idea/libraries/DTDParser.xml @@ -3,7 +3,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/EasyMock.xml b/.idea/libraries/EasyMock.xml index 05648438f07a..cc51a3eea9a6 100644 --- a/.idea/libraries/EasyMock.xml +++ b/.idea/libraries/EasyMock.xml @@ -4,7 +4,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/Eclipse.xml b/.idea/libraries/Eclipse.xml index 09b7e2c73bd4..7fa7c6724800 100644 --- a/.idea/libraries/Eclipse.xml +++ b/.idea/libraries/Eclipse.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/Gant.xml b/.idea/libraries/Gant.xml index ec46297abec3..ccd8bf04bef7 100644 --- a/.idea/libraries/Gant.xml +++ b/.idea/libraries/Gant.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/Groovy.xml b/.idea/libraries/Groovy.xml index 82c7bd9c0740..39ef164c7fa7 100644 --- a/.idea/libraries/Groovy.xml +++ b/.idea/libraries/Groovy.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/JDOM.xml b/.idea/libraries/JDOM.xml index 17d2e7336796..bce78cc5489e 100644 --- a/.idea/libraries/JDOM.xml +++ b/.idea/libraries/JDOM.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/JMock1.xml b/.idea/libraries/JMock1.xml index ca4dac06d5e2..28bec95a2700 100644 --- a/.idea/libraries/JMock1.xml +++ b/.idea/libraries/JMock1.xml @@ -4,7 +4,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/JUnit3.xml b/.idea/libraries/JUnit3.xml index c8e5da0d1ec9..c1b662d9bfb0 100644 --- a/.idea/libraries/JUnit3.xml +++ b/.idea/libraries/JUnit3.xml @@ -3,7 +3,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/JUnit4.xml b/.idea/libraries/JUnit4.xml index 6e7ba44fb1d0..3293fe32308b 100644 --- a/.idea/libraries/JUnit4.xml +++ b/.idea/libraries/JUnit4.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/JavaHelp.xml b/.idea/libraries/JavaHelp.xml index 458f03548750..a581fbd1d42b 100644 --- a/.idea/libraries/JavaHelp.xml +++ b/.idea/libraries/JavaHelp.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/Jaxen.xml b/.idea/libraries/Jaxen.xml index dd17c6df93a6..8c9fa7adb99c 100644 --- a/.idea/libraries/Jaxen.xml +++ b/.idea/libraries/Jaxen.xml @@ -3,7 +3,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/Log4J.xml b/.idea/libraries/Log4J.xml index 6e3948c15fc9..3179b1470772 100644 --- a/.idea/libraries/Log4J.xml +++ b/.idea/libraries/Log4J.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/Mac.xml b/.idea/libraries/Mac.xml index 256d4c9e54a9..a12291d435e5 100644 --- a/.idea/libraries/Mac.xml +++ b/.idea/libraries/Mac.xml @@ -4,7 +4,6 @@ - diff --git a/.idea/libraries/Mocks.xml b/.idea/libraries/Mocks.xml index 5a52b9d16391..e4bf218554bf 100644 --- a/.idea/libraries/Mocks.xml +++ b/.idea/libraries/Mocks.xml @@ -12,7 +12,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/NanoXML.xml b/.idea/libraries/NanoXML.xml index b189c1aeccf4..0bb733ed7323 100644 --- a/.idea/libraries/NanoXML.xml +++ b/.idea/libraries/NanoXML.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/OroMatcher.xml b/.idea/libraries/OroMatcher.xml index 11cae893cfea..91713b2ea1e2 100644 --- a/.idea/libraries/OroMatcher.xml +++ b/.idea/libraries/OroMatcher.xml @@ -3,7 +3,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/TestNG.xml b/.idea/libraries/TestNG.xml index 5ab2412b1a6e..a5778213fdef 100644 --- a/.idea/libraries/TestNG.xml +++ b/.idea/libraries/TestNG.xml @@ -3,7 +3,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/Trove4j.xml b/.idea/libraries/Trove4j.xml index ffb447bb506b..3f41197d62e8 100644 --- a/.idea/libraries/Trove4j.xml +++ b/.idea/libraries/Trove4j.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/Velocity.xml b/.idea/libraries/Velocity.xml index 6af932840678..3d7e67090faf 100644 --- a/.idea/libraries/Velocity.xml +++ b/.idea/libraries/Velocity.xml @@ -4,7 +4,6 @@ - diff --git a/.idea/libraries/XStream.xml b/.idea/libraries/XStream.xml index 1ae2bba6df3e..d910ea261e1e 100644 --- a/.idea/libraries/XStream.xml +++ b/.idea/libraries/XStream.xml @@ -3,7 +3,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/Xerces.xml b/.idea/libraries/Xerces.xml index 70f9b6a585a0..c5dbcdcf4e97 100644 --- a/.idea/libraries/Xerces.xml +++ b/.idea/libraries/Xerces.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/XmlBeans.xml b/.idea/libraries/XmlBeans.xml index 9ba2a85a0698..77058a249a98 100644 --- a/.idea/libraries/XmlBeans.xml +++ b/.idea/libraries/XmlBeans.xml @@ -5,7 +5,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/XmlRPC.xml b/.idea/libraries/XmlRPC.xml index 4dc45f5b4c27..ac9c9a5dbc94 100644 --- a/.idea/libraries/XmlRPC.xml +++ b/.idea/libraries/XmlRPC.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/asm.xml b/.idea/libraries/asm.xml index 449c600c9d8d..183a1bb65b08 100644 --- a/.idea/libraries/asm.xml +++ b/.idea/libraries/asm.xml @@ -4,7 +4,6 @@ - diff --git a/.idea/libraries/commons_codec.xml b/.idea/libraries/commons_codec.xml index 3921ae1a3395..edbee5956ef0 100644 --- a/.idea/libraries/commons_codec.xml +++ b/.idea/libraries/commons_codec.xml @@ -3,7 +3,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/commons_collections.xml b/.idea/libraries/commons_collections.xml index 489c3f067ebf..346eec1cf896 100644 --- a/.idea/libraries/commons_collections.xml +++ b/.idea/libraries/commons_collections.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/commons_lang.xml b/.idea/libraries/commons_lang.xml index ba16df792f70..735f56f94f1e 100644 --- a/.idea/libraries/commons_lang.xml +++ b/.idea/libraries/commons_lang.xml @@ -3,7 +3,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/commons_net.xml b/.idea/libraries/commons_net.xml index 73d5abb5afc1..a67717822b3e 100644 --- a/.idea/libraries/commons_net.xml +++ b/.idea/libraries/commons_net.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/jcip.xml b/.idea/libraries/jcip.xml index 5109f151a699..1a6bfae9c4c1 100644 --- a/.idea/libraries/jcip.xml +++ b/.idea/libraries/jcip.xml @@ -3,7 +3,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/jgoodies_forms.xml b/.idea/libraries/jgoodies_forms.xml index 0acd33f16bd7..6d2c19a1d4c8 100644 --- a/.idea/libraries/jgoodies_forms.xml +++ b/.idea/libraries/jgoodies_forms.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/jna.xml b/.idea/libraries/jna.xml index 8c0751775e1e..9fbb37eb48fc 100644 --- a/.idea/libraries/jna.xml +++ b/.idea/libraries/jna.xml @@ -4,7 +4,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/microba.xml b/.idea/libraries/microba.xml index 893e0dcc7f2a..771a1df5a98f 100644 --- a/.idea/libraries/microba.xml +++ b/.idea/libraries/microba.xml @@ -4,7 +4,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/picocontainer.xml b/.idea/libraries/picocontainer.xml index 0850ebb24085..e07ed90f94b5 100644 --- a/.idea/libraries/picocontainer.xml +++ b/.idea/libraries/picocontainer.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/tcServiceMessages.xml b/.idea/libraries/tcServiceMessages.xml index e3cc93f1d751..2117ae66d481 100644 --- a/.idea/libraries/tcServiceMessages.xml +++ b/.idea/libraries/tcServiceMessages.xml @@ -3,7 +3,6 @@ - From 1be17ebb83cf160910ae336bf82171da15a92717 Mon Sep 17 00:00:00 2001 From: Maxim Medvedev Date: Tue, 20 Jul 2010 17:47:42 +0400 Subject: [PATCH 24/26] IDEA-47083 fix upperCase --- .../after.groovy.template | 1 - .../before.groovy.template | 1 - .../description.html | 7 ------- 3 files changed, 9 deletions(-) delete mode 100644 plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/after.groovy.template delete mode 100644 plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/before.groovy.template delete mode 100644 plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/description.html diff --git a/plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/after.groovy.template b/plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/after.groovy.template deleted file mode 100644 index 221308e2c833..000000000000 --- a/plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/after.groovy.template +++ /dev/null @@ -1 +0,0 @@ -def objects = [foo, bar] \ No newline at end of file diff --git a/plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/before.groovy.template b/plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/before.groovy.template deleted file mode 100644 index 9944d004075f..000000000000 --- a/plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/before.groovy.template +++ /dev/null @@ -1 +0,0 @@ -def objects = new Object[] {foo, bar} diff --git a/plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/description.html b/plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/description.html deleted file mode 100644 index a57eb1cb3c81..000000000000 --- a/plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/description.html +++ /dev/null @@ -1,7 +0,0 @@ - - - -This intention converts java-style array creation to groovy syntax. - - - From bf30b4b438a84d658285fbd5bb65c5cd82a6bf35 Mon Sep 17 00:00:00 2001 From: Maxim Medvedev Date: Tue, 20 Jul 2010 17:51:03 +0400 Subject: [PATCH 25/26] IDEA-47083 fixUppercase step2 --- .../com/intellij/ui/classFilter/ClassFilterEditor.java | 8 ++++++-- .../after.groovy.template | 1 + .../before.groovy.template | 1 + .../description.html | 7 +++++++ 4 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 plugins/groovy/resources/intentionDescriptions/ConvertJavaStyleArrayCreationIntention/after.groovy.template create mode 100644 plugins/groovy/resources/intentionDescriptions/ConvertJavaStyleArrayCreationIntention/before.groovy.template create mode 100644 plugins/groovy/resources/intentionDescriptions/ConvertJavaStyleArrayCreationIntention/description.html diff --git a/java/openapi/src/com/intellij/ui/classFilter/ClassFilterEditor.java b/java/openapi/src/com/intellij/ui/classFilter/ClassFilterEditor.java index d2ebffc8bfbd..b475e65c66c4 100644 --- a/java/openapi/src/com/intellij/ui/classFilter/ClassFilterEditor.java +++ b/java/openapi/src/com/intellij/ui/classFilter/ClassFilterEditor.java @@ -29,9 +29,9 @@ import com.intellij.psi.util.PsiTreeUtil; import com.intellij.ui.ScrollPaneFactory; import com.intellij.ui.TableUtil; import com.intellij.ui.UIBundle; +import com.intellij.ui.table.JBTable; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.ItemRemovable; -import com.intellij.util.ui.Table; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -66,7 +66,7 @@ public class ClassFilterEditor extends JPanel { myAddClassButton = new JButton(getAddButtonText()); myAddPatternButton = new JButton(getAddPatternButtonText()); myRemoveButton = new JButton(UIBundle.message("button.remove")); - myTable = new Table(); + myTable = new JBTable(); JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTable); add(scrollPane, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 3, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(4, 4, 4, 6), 0, 0)); @@ -347,4 +347,8 @@ public class ClassFilterEditor extends JPanel { TableUtil.removeSelectedItems(myTable); } } + + public void setAddPatternButtonVisible(boolean visible) { + myAddPatternButton.setVisible(visible); + } } diff --git a/plugins/groovy/resources/intentionDescriptions/ConvertJavaStyleArrayCreationIntention/after.groovy.template b/plugins/groovy/resources/intentionDescriptions/ConvertJavaStyleArrayCreationIntention/after.groovy.template new file mode 100644 index 000000000000..221308e2c833 --- /dev/null +++ b/plugins/groovy/resources/intentionDescriptions/ConvertJavaStyleArrayCreationIntention/after.groovy.template @@ -0,0 +1 @@ +def objects = [foo, bar] \ No newline at end of file diff --git a/plugins/groovy/resources/intentionDescriptions/ConvertJavaStyleArrayCreationIntention/before.groovy.template b/plugins/groovy/resources/intentionDescriptions/ConvertJavaStyleArrayCreationIntention/before.groovy.template new file mode 100644 index 000000000000..9944d004075f --- /dev/null +++ b/plugins/groovy/resources/intentionDescriptions/ConvertJavaStyleArrayCreationIntention/before.groovy.template @@ -0,0 +1 @@ +def objects = new Object[] {foo, bar} diff --git a/plugins/groovy/resources/intentionDescriptions/ConvertJavaStyleArrayCreationIntention/description.html b/plugins/groovy/resources/intentionDescriptions/ConvertJavaStyleArrayCreationIntention/description.html new file mode 100644 index 000000000000..a57eb1cb3c81 --- /dev/null +++ b/plugins/groovy/resources/intentionDescriptions/ConvertJavaStyleArrayCreationIntention/description.html @@ -0,0 +1,7 @@ + + + +This intention converts java-style array creation to groovy syntax. + + + From a907766a0324aaf5424fbccf192a46c0ac811492 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Tue, 20 Jul 2010 17:52:14 +0400 Subject: [PATCH 26/26] [SVN] IDEA-56464 Providing option to save credentials in plaintext. 1. When saving credentials encrypted is not possible (*nix/OSX) and store-plaintext-passwords is not enabled, we ask user if he want to save this password in plaintext instead of just frightening him with a warning message. 2. Also this questioning message is now shown more correctly: just after success authentication but before actual save and before providing access (e.g. before showing repository content). Details: 1. Introduce myStoreInPlainTextAnyway boolean value. Update it in checkContinueSaveCredentials, read it in the overriden isStorePlainTextPasswords: if it's true, then plain text password saving is allowed even when user preference doesn't allow it. 2. Moved checkContinueSaveCredentials to SvnAuthenticationManager.PersistentAuthenticationProviderProxy.saveAuthentication. --- .../idea/svn/SvnAuthenticationManager.java | 123 +++++++++++------- .../SvnInteractiveAuthenticationProvider.java | 8 +- 2 files changed, 78 insertions(+), 53 deletions(-) diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationManager.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationManager.java index 93f5c6b26672..937be282dd2b 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationManager.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationManager.java @@ -16,12 +16,14 @@ package org.jetbrains.idea.svn; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.MessageType; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vcs.changes.ui.ChangesViewBalloonProblemNotifier; +import com.intellij.ui.GuiUtils; import com.intellij.util.containers.SoftHashMap; import com.intellij.util.net.HttpConfigurable; import org.jetbrains.annotations.Nullable; @@ -35,36 +37,41 @@ import org.tmatesoft.svn.core.io.SVNRepository; import java.io.File; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; import java.util.Iterator; import java.util.Map; import java.util.StringTokenizer; +import java.util.concurrent.atomic.AtomicBoolean; /** * @author alex */ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager { + private static final Logger LOG = Logger.getInstance(SvnAuthenticationManager.class.getName()); private final Project myProject; private final File myConfigDirectory; private PersistentAuthenticationProviderProxy myPersistentAuthenticationProviderProxy; private SvnConfiguration myConfig; + private AtomicBoolean myStoreInPlainTextAnyway = new AtomicBoolean(false); public SvnAuthenticationManager(final Project project, final File configDirectory) { - super(configDirectory, true, null, null); - myProject = project; + super(configDirectory, true, null, null); + myProject = project; myConfigDirectory = configDirectory; myConfig = SvnConfiguration.getInstance(myProject); - if (myPersistentAuthenticationProviderProxy != null) { - myPersistentAuthenticationProviderProxy.setProject(myProject); - } + if (myPersistentAuthenticationProviderProxy != null) { + myPersistentAuthenticationProviderProxy.setProject(myProject); } + } @Override protected ISVNAuthenticationProvider createCacheAuthenticationProvider(File authDir, String userName) { + myStoreInPlainTextAnyway = new AtomicBoolean(false); myPersistentAuthenticationProviderProxy = new PersistentAuthenticationProviderProxy(super.createCacheAuthenticationProvider(authDir, userName), authDir); return myPersistentAuthenticationProviderProxy; } - private static class PersistentAuthenticationProviderProxy implements ISVNAuthenticationProvider, IPersistentAuthenticationProvider { + private class PersistentAuthenticationProviderProxy implements ISVNAuthenticationProvider, IPersistentAuthenticationProvider { private final Map myRewritePreventer; private static final long ourRefreshInterval = 6000 * 1000; private final ISVNAuthenticationProvider myDelegate; @@ -84,7 +91,7 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager { public SVNAuthentication requestClientAuthentication(final String kind, final SVNURL url, final String realm, final SVNErrorMessage errorMessage, final SVNAuthentication previousAuth, final boolean authMayBeStored) { - return myDelegate.requestClientAuthentication(kind, url, realm, errorMessage, previousAuth, authMayBeStored); + return myDelegate.requestClientAuthentication(kind, url, realm, errorMessage, previousAuth, false); } public int acceptServerAuthentication(final SVNURL url, final String realm, final Object certificate, final boolean resultMayBeStored) { @@ -101,7 +108,22 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager { File authFile = new File(dir, fileName); if ((! authFile.exists()) || recent == null || ((recent != null) && ((currTime - recent.longValue()) > ourRefreshInterval))) { - ((IPersistentAuthenticationProvider) myDelegate).saveAuthentication(auth, kind, realm); + + if (auth.isStorageAllowed() && ISVNAuthenticationManager.USERNAME != kind) { + try { + GuiUtils.runOrInvokeAndWait(new Runnable() { + public void run() { + checkContinueSaveCredentials(auth, kind, realm); + } + }); + } catch (InvocationTargetException e) { + LOG.error(e); + } catch (InterruptedException e) { + LOG.error(e); + } + } + + ((DefaultSVNAuthenticationManager.IPersistentAuthenticationProvider)myDelegate).saveAuthentication(auth, kind, realm); // do not make password file readonly setWriteable(authFile); @@ -305,7 +327,7 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager { catch (SVNException e) { return false; } - + final String host = svnurl.getHost(); return matches(patterns, host) && (! matches(exceptions, host)); } @@ -419,52 +441,61 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager { } // check can encrypt - if (! (SystemInfo.isWindows && SVNJNAUtil.isWinCryptEnabled())) { + if (!(SystemInfo.isWindows && SVNJNAUtil.isWinCryptEnabled())) { if (ISVNAuthenticationManager.SSL.equals(kind)) { try { - if (! isStorePlainTextPassphrases(realm, auth)) { - final SVNSSLAuthentication svnsslAuthentication = (SVNSSLAuthentication)auth; - ApplicationManager.getApplication().invokeLater(new Runnable() { - public void run() { - Messages.showWarningDialog(myProject, "Your passphrase for client certificate:\n\n" + - svnsslAuthentication.getCertificateFile().getPath() + - "\n\ncan only be stored to disk unencrypted. (Encryption is not supported)\n\n" + - "But storage in plain text is not allowed.\nTo allow plain text passphrases caching, set \"store-ssl-client-cert-pp-plaintext=yes\"", - "Cannot save passphrase"); - } - }); - /*ChangesViewBalloonProblemNotifier.showMe(myProject, "Your passphrase for client certificate:\n" + - svnsslAuthentication.getCertificateFile().getPath() + - "\ncan only be stored to disk unencrypted! (Encryption is not supported)\n" + - "But storage in plain text is not allowed.\nTo allow plain text passphrases caching, set \"store-ssl-client-cert-pp-plaintext\"=\"yes\"", MessageType.ERROR);*/ - return false; + if (!isStorePlainTextPassphrases(realm, auth)) { + return askToStoreUnencrypted("Store the passphrase in plaintext?", + String.format("Your passphrase for client certificate:\n%s\ncan only be stored to disk unencrypted. Would you like to store it in plaintext?", + ((SVNSSLAuthentication)auth).getCertificateFile().getPath())); } - } - catch (SVNException e) { - // should not occur, anyway means not allowed + } catch (SVNException e) { + LOG.error(e); // should not occur, anyway means not allowed } } else { try { - if (! isStorePlainTextPasswords(realm, auth)) { - ApplicationManager.getApplication().invokeLater(new Runnable() { - public void run() { - Messages.showWarningDialog(myProject, "Your password for authentication realm:\n\n" + realm + - "\n\ncan only be stored to disk unencrypted. (Encryption is not supported)\n\n" + - "But storage in plain text is not allowed.\nTo allow plain text passwords caching, set \"store-plaintext-passwords=yes\"", - "Cannot save password"); - } - }); - /*ChangesViewBalloonProblemNotifier.showMe(myProject, "Your password for authentication realm:\n" + realm + - "\ncan only be stored to disk unencrypted! (Encryption is not supported)\n" + - "But storage in plain text is not allowed.\nTo allow plain text passwords caching, set \"store-plaintext-passwords\"=\"yes\"", MessageType.ERROR);*/ - return false; + if (!isStorePlainTextPasswords(realm, auth)) { + return askToStoreUnencrypted("Store the password in plaintext?", + String.format("Your password for authentication realm:\n%s\ncan only be stored to disk unencrypted. Would you like to store it in plaintext?", + realm)); } - } - catch (SVNException e) { - // + } catch (SVNException e) { + LOG.error(e); } } } return true; } -} + + @Override + protected boolean isStorePlainTextPasswords(String realm, SVNAuthentication auth) throws SVNException { + // normally check user preferences, but the user may override them via the dialog from checkContinueSaveCredentials() + return myStoreInPlainTextAnyway.get() || super.isStorePlainTextPasswords(realm, auth); + } + + @Override + protected boolean isStorePlainTextPassphrases(String realm, SVNAuthentication auth) throws SVNException { + return myStoreInPlainTextAnyway.get() || super.isStorePlainTextPassphrases(realm, auth); + } + + /** + * Shows a yes/no question whether user wants to store his password in plain text and returns his answer. + * Also updates the 'myStoreInPlainTextAnyway' variable correspondingly. + * This method shuld be called from the event dispatching thread. + * @param title title of the questioning dialog. + * @param message questioning message to be displayed. + * @return true if user agrees to store his password in plaintext, false if he doesn't. + */ + private boolean askToStoreUnencrypted(String title, String message) { + final int answer = Messages.showYesNoDialog(myProject, message, title, Messages.getQuestionIcon()); + if (answer == 0) { + myStoreInPlainTextAnyway.set(true); + } else { + myStoreInPlainTextAnyway.set(false); + ChangesViewBalloonProblemNotifier.showMe(myProject, "Cannot store password", MessageType.ERROR); + } + return myStoreInPlainTextAnyway.get(); + + } + +} \ No newline at end of file diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SvnInteractiveAuthenticationProvider.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SvnInteractiveAuthenticationProvider.java index 6a8e6c1ab2de..e26528930dda 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SvnInteractiveAuthenticationProvider.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SvnInteractiveAuthenticationProvider.java @@ -173,15 +173,9 @@ public class SvnInteractiveAuthenticationProvider implements ISVNAuthenticationP } log("3 authentication result: " + result[0]); } + final boolean wasCanceled = result[0] == null; callState.setWasCancelled(wasCanceled); - if ((! wasCanceled) && (ISVNAuthenticationManager.USERNAME != kind) && (result[0].isStorageAllowed())) { - ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { - public void run() { - myManager.checkContinueSaveCredentials(result[0], kind, realm); - } - }); - } return result[0]; }