From d077e329800a75de1b5bf041c63f8ea47046e730 Mon Sep 17 00:00:00 2001 From: anna Date: Thu, 11 Apr 2013 09:10:23 +0200 Subject: [PATCH 01/31] type->diamond: rename warning message after inspection name (IDEA-104448) --- .../codeInspection/ExplicitTypeCanBeDiamondInspection.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/java-impl/src/com/intellij/codeInspection/ExplicitTypeCanBeDiamondInspection.java b/java/java-impl/src/com/intellij/codeInspection/ExplicitTypeCanBeDiamondInspection.java index 044daee18695..5f5b0e24448b 100644 --- a/java/java-impl/src/com/intellij/codeInspection/ExplicitTypeCanBeDiamondInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/ExplicitTypeCanBeDiamondInspection.java @@ -67,7 +67,7 @@ public class ExplicitTypeCanBeDiamondInspection extends BaseJavaLocalInspectionT LOG.assertTrue(classReference != null); final PsiReferenceParameterList parameterList = classReference.getParameterList(); LOG.assertTrue(parameterList != null); - holder.registerProblem(parameterList, "Redundant type argument #ref #loc", + holder.registerProblem(parameterList, "Explicit type argument #ref #loc can be replaced with <>", ProblemHighlightType.LIKE_UNUSED_SYMBOL, new ReplaceWithDiamondFix()); } } From 02b8f9c71a237adb6ea93dcdad9909db0a33ff34 Mon Sep 17 00:00:00 2001 From: Fedor Korotkov Date: Thu, 11 Apr 2013 11:24:53 +0400 Subject: [PATCH 02/31] WEB-6592 Schemeless (protocol-relative) URLs in HTML documents are not recognized --- .../src/com/intellij/html/impl/util/MicrodataUtil.java | 10 ++-------- .../reference/impl/providers/URIReferenceProvider.java | 4 ++-- xml/impl/src/com/intellij/xml/util/HtmlUtil.java | 7 +++++++ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/xml/impl/src/com/intellij/html/impl/util/MicrodataUtil.java b/xml/impl/src/com/intellij/html/impl/util/MicrodataUtil.java index 78fb7255d147..6435a1dd67e9 100644 --- a/xml/impl/src/com/intellij/html/impl/util/MicrodataUtil.java +++ b/xml/impl/src/com/intellij/html/impl/util/MicrodataUtil.java @@ -37,6 +37,7 @@ import com.intellij.psi.xml.XmlFile; import com.intellij.psi.xml.XmlTag; import com.intellij.util.PairFunction; import com.intellij.util.text.StringTokenizer; +import com.intellij.xml.util.HtmlUtil; import gnu.trove.THashMap; import gnu.trove.THashSet; import org.jetbrains.annotations.Nls; @@ -56,9 +57,6 @@ public class MicrodataUtil { public static final String ITEM_PROP = "itemprop"; public static final String ITEM_ID = "itemid"; - @NonNls private static final String HTTP = "http://"; - @NonNls private static final String HTTPS = "https://"; - public static boolean hasScopeTag(@Nullable XmlTag tag) { return findScopeTag(tag) != null; } @@ -130,7 +128,7 @@ public class MicrodataUtil { @Nullable @Override public PsiReference fun(String token, Integer offset) { - if (isUrl(token)) { + if (HtmlUtil.hasHtmlPrefix(token)) { final TextRange range = TextRange.from(offset, token.length()); final URLReference urlReference = new URLReference(element, range, true); return new URIReferenceProvider.DependentNSReference(element, range, urlReference) { @@ -167,10 +165,6 @@ public class MicrodataUtil { return result.toArray(new PsiReference[result.size()]); } - private static boolean isUrl(String url) { - return url.startsWith(HTTP) || url.startsWith(HTTPS); - } - @Nullable public static String getStripedAttributeValue(@Nullable XmlTag tag, @Nls String attributeName) { String value = tag != null ? tag.getAttributeValue(attributeName) : null; diff --git a/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/URIReferenceProvider.java b/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/URIReferenceProvider.java index 23ab5613fe7b..25e048c3db2d 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/URIReferenceProvider.java +++ b/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/URIReferenceProvider.java @@ -34,6 +34,7 @@ import com.intellij.psi.xml.XmlAttribute; import com.intellij.util.ArrayUtil; import com.intellij.util.ProcessingContext; import com.intellij.util.containers.ContainerUtil; +import com.intellij.xml.util.HtmlUtil; import com.intellij.xml.util.XmlUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -62,7 +63,6 @@ public class URIReferenceProvider extends PsiReferenceProvider { return true; } }; - @NonNls private static final String HTTP = "http://"; @NonNls private static final String URN = "urn:"; @NonNls private static final String FILE = "file:"; @NonNls private static final String CLASSPATH = "classpath:/"; @@ -162,7 +162,7 @@ public class URIReferenceProvider extends PsiReferenceProvider { } static boolean isUrlText(final String s, Project project) { - final boolean surelyUrl = s.startsWith(HTTP) || s.startsWith(URN); + final boolean surelyUrl = HtmlUtil.hasHtmlPrefix(s) || s.startsWith(URN); if (surelyUrl) return surelyUrl; int protocolIndex = s.indexOf(":/"); if (protocolIndex > 1 && !s.regionMatches(0,"classpath",0,protocolIndex)) return true; diff --git a/xml/impl/src/com/intellij/xml/util/HtmlUtil.java b/xml/impl/src/com/intellij/xml/util/HtmlUtil.java index 86252c1d22f1..a52b879d90d4 100644 --- a/xml/impl/src/com/intellij/xml/util/HtmlUtil.java +++ b/xml/impl/src/com/intellij/xml/util/HtmlUtil.java @@ -597,6 +597,13 @@ public class HtmlUtil { return isHtmlFile(file) || file.getViewProvider() instanceof TemplateLanguageFileViewProvider; } + public static boolean hasHtmlPrefix(@NotNull String url) { + return url.startsWith("http://") || + url.startsWith("https://") || + url.startsWith("//") || //Protocol-relative URL + url.startsWith("ftp://"); + } + public static boolean isHtmlFile(PsiElement element) { Language language = element.getLanguage(); return language == HTMLLanguage.INSTANCE || language == XHTMLLanguage.INSTANCE; From 8f87ec22d6634891867b46faa026edb04457a198 Mon Sep 17 00:00:00 2001 From: anna Date: Thu, 11 Apr 2013 09:30:31 +0200 Subject: [PATCH 03/31] schema prefix inplace rename: do not choose current reference as element is the whole tag -> all subtags references could be treated as current --- .../intellij/xml/refactoring/SchemaPrefixRenameHandler.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xml/impl/src/com/intellij/xml/refactoring/SchemaPrefixRenameHandler.java b/xml/impl/src/com/intellij/xml/refactoring/SchemaPrefixRenameHandler.java index 4e478dd6ba79..bc4ba667afa4 100644 --- a/xml/impl/src/com/intellij/xml/refactoring/SchemaPrefixRenameHandler.java +++ b/xml/impl/src/com/intellij/xml/refactoring/SchemaPrefixRenameHandler.java @@ -64,6 +64,10 @@ public class SchemaPrefixRenameHandler extends VariableInplaceRenameHandler { @Override protected void addReferenceAtCaret(Collection refs) {} + @Override + protected boolean isReferenceAtCaret(PsiElement selectedElement, PsiReference ref) { + return false; + } }; } } From 2e940f681e003a6db40fc6cadbd606b57bf14e8b Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Wed, 10 Apr 2013 20:12:09 +0400 Subject: [PATCH 04/31] cleanup --- .../vcs/changes/VcsDirtyScopeImpl.java | 41 +++++++++++++------ 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsDirtyScopeImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsDirtyScopeImpl.java index 316341cfc2cc..6b18210173ed 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsDirtyScopeImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsDirtyScopeImpl.java @@ -102,10 +102,12 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope { }; } + @Override public Collection getAffectedContentRoots() { return myAffectedContentRoots; } + @Override public Collection getAffectedContentRootsWithCheck() { if (myVcs.allowsNestedRoots()) { final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(myVcs.getProject()); @@ -114,7 +116,7 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope { final Set result = new HashSet(myAffectedContentRoots); for (VirtualFile root : roots) { for (VirtualFile dir : myDirtyDirectoriesRecursively.keySet()) { - if (VfsUtil.isAncestor(dir, root, true)) { + if (VfsUtilCore.isAncestor(dir, root, true)) { result.add(root); } } @@ -124,14 +126,17 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope { return myAffectedContentRoots; } + @Override public Project getProject() { return myProject; } + @Override public AbstractVcs getVcs() { return myVcs; } + @Override public Set getDirtyFiles() { final THashSet result = new THashSet(); for (THashSet paths : myDirtyFiles.values()) { @@ -150,6 +155,7 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope { return result; } + @Override public Set getDirtyFilesNoExpand() { final THashSet paths = new THashSet(); for (THashSet filePaths : myDirtyFiles.values()) { @@ -158,6 +164,7 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope { return paths; } + @Override public Set getRecursivelyDirtyDirectories() { THashSet result = new THashSet(); for(THashSet dirsByRoot: myDirtyDirectoriesRecursively.values()) { @@ -172,7 +179,7 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope { for (FilePath dir : dirsByRoot) { final VirtualFile dirVf = dir.getVirtualFile(); if (dirVf != null) { - if (VfsUtil.isAncestor(dirVf, vf, false)) { + if (VfsUtilCore.isAncestor(dirVf, vf, false)) { return true; } } @@ -193,6 +200,7 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope { public void addDirtyData(final Collection dirs, final Collection files) { ApplicationManager.getApplication().runReadAction(new Runnable() { + @Override public void run() { final HashSet newFiles = new HashSet(files); newFiles.removeAll(dirs); // if the same dir is added recursively and not recursively, prefer recursive mark @@ -233,15 +241,15 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope { }, new PairProcessor() { @Override public boolean process(FileOrDir parent, FileOrDir child) { - if (! parent.myRecursive) {// if under non-recursive dirty dir, generally do not remove child with one exception... - if (! child.myRecursive && ! child.myPath.isDirectory()) { - if (Comparing.equal(child.myPath.getParentPath(), parent.myPath)) { - return true; // only if dir non-recursively + non-recursive file child -> can be truncated to dir only - } - } + if (parent.myRecursive) { + return true; + } + // if under non-recursive dirty dir, generally do not remove child with one exception... + if (child.myRecursive || child.myPath.isDirectory()) { return false; } - return true; + // only if dir non-recursively + non-recursive file child -> can be truncated to dir only + return Comparing.equal(child.myPath.getParentPath(), parent.myPath); } }); set.retainAll(newCollection); @@ -287,8 +295,10 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope { * * @param newcomer a new directory to add */ + @Override public void addDirtyDirRecursively(final FilePath newcomer) { ApplicationManager.getApplication().runReadAction(new Runnable() { + @Override public void run() { final VirtualFile vcsRoot = myVcsManager.getVcsRootFor(newcomer); if (vcsRoot == null) return; @@ -340,8 +350,10 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope { * * @param newcomer a file or directory added to the dirty scope. */ + @Override public void addDirtyFile(final FilePath newcomer) { ApplicationManager.getApplication().runReadAction(new Runnable() { + @Override public void run() { final VirtualFile vcsRoot = myVcsManager.getVcsRootFor(newcomer); myAffectedContentRoots.add(vcsRoot); @@ -368,7 +380,7 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope { iterator.remove(); } } - } else if (dirtyFiles.size() > 0) { + } else if (!dirtyFiles.isEmpty()) { VirtualFile parent = newcomer.getVirtualFileParent(); if (parent != null && dirtyFiles.contains(new FilePathImpl(parent))) { return; @@ -380,6 +392,7 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope { }); } + @Override public void iterate(final Processor iterator) { if (myProject.isDisposed()) return; @@ -459,6 +472,7 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope { @Override public boolean belongsTo(final FilePath path, final Consumer vcsConsumer) { return ApplicationManager.getApplication().runReadAction(new Computable() { + @Override public Boolean compute() { if (myProject.isDisposed()) return Boolean.FALSE; final VcsRoot rootObject = myVcsManager.getVcsRootObjectFor(path); @@ -487,7 +501,7 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope { } } - if (myDirtyFiles.size() > 0) { + if (!myDirtyFiles.isEmpty()) { FilePath parent; VirtualFile vParent = path.getVirtualFileParent(); if (vParent != null && vParent.isValid()) { @@ -521,7 +535,7 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope { @Override @NonNls public String toString() { @NonNls StringBuilder result = new StringBuilder("VcsDirtyScope["); - if (myDirtyFiles.size() > 0) { + if (!myDirtyFiles.isEmpty()) { result.append(" files="); for (THashSet paths : myDirtyFiles.values()) { for (FilePath file : paths) { @@ -529,7 +543,7 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope { } } } - if (myDirtyDirectoriesRecursively.size() > 0) { + if (!myDirtyDirectoriesRecursively.isEmpty()) { result.append(" dirs="); for(THashSet dirsByRoot: myDirtyDirectoriesRecursively.values()) { for(FilePath file: dirsByRoot) { @@ -559,6 +573,7 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope { return myWasEverythingDirty; } + @Override public void setWasEverythingDirty(boolean wasEverythingDirty) { myWasEverythingDirty = wasEverythingDirty; } From 40d696eae3e895cd83f5c691075a63c99c14043c Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Thu, 11 Apr 2013 12:01:25 +0400 Subject: [PATCH 05/31] disabled plugin nafig --- plugins/google-app-engine/testSource/META-INF/plugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/google-app-engine/testSource/META-INF/plugin.xml b/plugins/google-app-engine/testSource/META-INF/plugin.xml index 01deb890064a..2edf3e7f982d 100644 --- a/plugins/google-app-engine/testSource/META-INF/plugin.xml +++ b/plugins/google-app-engine/testSource/META-INF/plugin.xml @@ -4,5 +4,5 @@ This fake plugin descriptor is used to run tests - + From 9dadba3a2ab286f04317116f2d9ad549d4e9eb54 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Wed, 10 Apr 2013 21:11:30 +0400 Subject: [PATCH 06/31] [git] IDEA-104846 Fix pushing new branch without new commits The bug was introduce in b200615c when we stopped showing last 5 commits for new branches, and began to show only those commits which will be actually pushed. To avoid the problem check for "nothing to push" (0 commits) only in the standard case, when the branch is pushed to its tracked branch. --- plugins/git4idea/src/git4idea/push/GitPusher.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/git4idea/src/git4idea/push/GitPusher.java b/plugins/git4idea/src/git4idea/push/GitPusher.java index e56d15c1b6c4..fd06e8c149d4 100644 --- a/plugins/git4idea/src/git4idea/push/GitPusher.java +++ b/plugins/git4idea/src/git4idea/push/GitPusher.java @@ -239,7 +239,12 @@ public final class GitPusher { GitCommitsByRepoAndBranch commits = pushInfo.getCommits(); for (GitRepository repository : commits.getRepositories()) { - if (commits.get(repository).getAllCommits().size() == 0) { // don't push repositories where there is nothing to push. Note that when a branch is created, several recent commits are stored in the pushInfo. + GitCommitsByBranch commitsForRepo = commits.get(repository); + GitLocalBranch sourceBranch = pushInfo.getPushSpecs().get(repository).getSource(); + if (commitsForRepo.get(sourceBranch).getType() == GitPushBranchInfo.Type.STANDARD && + commitsForRepo.getAllCommits().size() == 0) { + // don't push repositories where there is nothing to push. + // however, do push if new branch is created, even without commits continue; } GitPushRepoResult repoResult = pushRepository(pushInfo, commits, repository); From 6c454ea868df19a2adce54be80c1907c51cb61e2 Mon Sep 17 00:00:00 2001 From: "Kirill.Likhodedov" Date: Thu, 11 Apr 2013 14:29:35 +0400 Subject: [PATCH 07/31] [git tests] Fix method names for older Groovy versions --- .../git4idea/config/GitExecutableDetectorWindowsTest.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/git4idea/tests/git4idea/config/GitExecutableDetectorWindowsTest.groovy b/plugins/git4idea/tests/git4idea/config/GitExecutableDetectorWindowsTest.groovy index caa27dd14891..e6a97f32621b 100644 --- a/plugins/git4idea/tests/git4idea/config/GitExecutableDetectorWindowsTest.groovy +++ b/plugins/git4idea/tests/git4idea/config/GitExecutableDetectorWindowsTest.groovy @@ -89,7 +89,7 @@ class GitExecutableDetectorWindowsTest { } @Test - void "1_8_0 Prefer cmd/git_cmd over cmd/git_exe and bin/git_exe"() { + void "1_8_0 Prefer cmd_git_cmd over cmd_git_exe and bin_git_exe"() { fs "C:/Program Files (x86)/Git_1.8/bin/git.exe", "C:/Program Files (x86)/Git_1.8/cmd/git.cmd", "C:/Program Files (x86)/Git_1.8/cmd/git.exe" @@ -126,7 +126,7 @@ class GitExecutableDetectorWindowsTest { } @Test - void "Program not found, try git.exe"() { + void "Program not found try git_exe"() { CAN_RUN = [ "git.exe" ] assertExecutable "git.exe" } From 2a2f5244c8dff0546d0d9fcb86db860c1319f930 Mon Sep 17 00:00:00 2001 From: "Kirill.Likhodedov" Date: Thu, 11 Apr 2013 14:30:58 +0400 Subject: [PATCH 08/31] [git tests] Fix git tests on Windows: convert line separators where needed --- plugins/git4idea/test-stepdefs/git4idea/GeneralStepdefs.java | 3 +-- .../test-stepdefs/git4idea/GitCherryPickStepdefs.java | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/git4idea/test-stepdefs/git4idea/GeneralStepdefs.java b/plugins/git4idea/test-stepdefs/git4idea/GeneralStepdefs.java index b4d00413d88a..5195f40abc23 100644 --- a/plugins/git4idea/test-stepdefs/git4idea/GeneralStepdefs.java +++ b/plugins/git4idea/test-stepdefs/git4idea/GeneralStepdefs.java @@ -77,8 +77,7 @@ public class GeneralStepdefs { private static void assertNotificationContent(String expected, String actual) { expected = virtualCommits.replaceVirtualHashes(expected); - assertEquals("Notification content is incorrect", expected, adjustNotificationContent(actual)); - + assertEquals("Notification content is incorrect", StringUtil.convertLineSeparators(expected), StringUtil.convertLineSeparators(adjustNotificationContent(actual))); } private static String adjustNotificationContent(String content) { diff --git a/plugins/git4idea/test-stepdefs/git4idea/GitCherryPickStepdefs.java b/plugins/git4idea/test-stepdefs/git4idea/GitCherryPickStepdefs.java index 2e15959c36a3..2df9eb2880d4 100644 --- a/plugins/git4idea/test-stepdefs/git4idea/GitCherryPickStepdefs.java +++ b/plugins/git4idea/test-stepdefs/git4idea/GitCherryPickStepdefs.java @@ -19,6 +19,7 @@ import com.google.common.base.Function; import com.google.common.collect.Collections2; import com.intellij.dvcs.test.MockVcsHelper; import com.intellij.dvcs.test.MockVirtualFile; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vcs.FilePathImpl; import com.intellij.openapi.vcs.changes.Change; import com.intellij.openapi.vcs.changes.LocalChangeList; @@ -163,8 +164,8 @@ public class GitCherryPickStepdefs { List actualMessages = Arrays.asList(output.split(RECORD_SEPARATOR)); for (int i = 0; i < expectedMessages.size(); i++) { - String expectedMessage = expectedMessages.get(i).trim(); - String actualMessage = actualMessages.get(i).trim(); + String expectedMessage = StringUtil.convertLineSeparators(expectedMessages.get(i).trim()); + String actualMessage = StringUtil.convertLineSeparators(actualMessages.get(i).trim()); if (!fullBody) { // the subject (%s) somehow contains both "fix #1" and "cherry-picked from " in a single line // which is probably Git misbehavior, so let's compare without taking line breaks and spaces into consideration From cd05afcae79e7daf9698b006d5aeb5617b4c10f1 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Thu, 11 Apr 2013 14:38:04 +0400 Subject: [PATCH 09/31] revert pointless change that broke refresh of breakpoint icons --- .../ui/breakpoints/BreakpointWithHighlighter.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java index c4b242756dc4..7ff853b401eb 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java @@ -433,7 +433,7 @@ public abstract class BreakpointWithHighlighter extends Breakpoint { } private void setupGutterRenderer(@NotNull RangeHighlighter highlighter) { - MyGutterIconRenderer renderer = new MyGutterIconRenderer(this); + MyGutterIconRenderer renderer = new MyGutterIconRenderer(getIcon(), getDescription()); highlighter.setGutterIconRenderer(renderer); } @@ -597,21 +597,23 @@ public abstract class BreakpointWithHighlighter extends Breakpoint { } private class MyGutterIconRenderer extends GutterIconRenderer { - private BreakpointWithHighlighter myBreakpoint; + private final Icon myIcon; + private final String myDescription; - public MyGutterIconRenderer(BreakpointWithHighlighter breakpoint) { - myBreakpoint = breakpoint; + public MyGutterIconRenderer(@NotNull Icon icon, @NotNull String description) { + myIcon = icon; + myDescription = description; } @Override @NotNull public Icon getIcon() { - return myBreakpoint.getIcon(); + return myIcon; } @Override public String getTooltipText() { - return myBreakpoint.getDescription(); + return myDescription; } @Override From acc6248f1ce8c875325dfb227765ad712b0b4841 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Thu, 11 Apr 2013 14:49:32 +0400 Subject: [PATCH 10/31] [tests] Better message if command execution failed because of timeout --- .../dvcs/testFramework/com/intellij/dvcs/test/Executor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/dvcs/testFramework/com/intellij/dvcs/test/Executor.java b/platform/dvcs/testFramework/com/intellij/dvcs/test/Executor.java index 6e16ed855927..a736f4bf2de3 100644 --- a/platform/dvcs/testFramework/com/intellij/dvcs/test/Executor.java +++ b/platform/dvcs/testFramework/com/intellij/dvcs/test/Executor.java @@ -137,7 +137,7 @@ public class Executor { CapturingProcessHandler handler = new CapturingProcessHandler(clientProcess, CharsetToolkit.getDefaultSystemCharset()); ProcessOutput result = handler.runProcess(30*1000); if (result.isTimeout()) { - throw new RuntimeException("Timeout waiting for Git execution"); + throw new RuntimeException("Timeout waiting for the command execution. Command: " + StringUtil.join(params, " ")); } if (result.getExitCode() != 0) { From 5c228fc614c8f83a181309024c2240558ea6eb2e Mon Sep 17 00:00:00 2001 From: Max Medvedev Date: Wed, 10 Apr 2013 12:29:34 +0400 Subject: [PATCH 11/31] IDEA-102328 Resolve inner classes in subclasses --- ...necessaryQualifiedReferenceInspection.java | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/confusing/UnnecessaryQualifiedReferenceInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/confusing/UnnecessaryQualifiedReferenceInspection.java index d4a4adfb0b22..6553ab8b2ead 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/confusing/UnnecessaryQualifiedReferenceInspection.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/confusing/UnnecessaryQualifiedReferenceInspection.java @@ -57,7 +57,7 @@ public class UnnecessaryQualifiedReferenceInspection extends BaseInspection { public void visitCodeReferenceElement(GrCodeReferenceElement refElement) { super.visitCodeReferenceElement(refElement); - if (canBeReplacedWithImport(refElement)) { + if (canBeSimplified(refElement)) { registerError(refElement); } } @@ -66,7 +66,7 @@ public class UnnecessaryQualifiedReferenceInspection extends BaseInspection { public void visitReferenceExpression(GrReferenceExpression referenceExpression) { super.visitReferenceExpression(referenceExpression); - if (canBeReplacedWithImport(referenceExpression) || isQualifiedStaticMethodWithUnnecessaryQualifier(referenceExpression)) { + if (canBeSimplified(referenceExpression) || isQualifiedStaticMethodWithUnnecessaryQualifier(referenceExpression)) { registerError(referenceExpression); } } @@ -138,7 +138,7 @@ public class UnnecessaryQualifiedReferenceInspection extends BaseInspection { return true; } - private static boolean canBeReplacedWithImport(PsiElement element) { + private static boolean canBeSimplified(PsiElement element) { if (element instanceof GrCodeReferenceElement) { if (PsiTreeUtil.getParentOfType(element, GrImportStatement.class, GrPackageDefinition.class) != null) return false; } @@ -155,22 +155,25 @@ public class UnnecessaryQualifiedReferenceInspection extends BaseInspection { final PsiElement resolved = ref.resolve(); if (!(resolved instanceof PsiClass)) return false; - if (((PsiClass)resolved).getContainingClass() != null && - !CodeStyleSettingsManager.getSettings(resolved.getProject()).getCustomSettings(GroovyCodeStyleSettings.class).INSERT_INNER_CLASS_IMPORTS) { - return false; - } final String name = ((PsiClass)resolved).getName(); if (name == null) return false; final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(element.getProject()); final GrReferenceExpression shortedRef = factory.createReferenceExpressionFromText(name, element); - final GroovyResolveResult resolveResult = shortedRef.advancedResolve(); - if (resolveResult.getElement() == null || !resolveResult.isAccessible() || !resolveResult.isStaticsOK()) { + + if (element.getManager().areElementsEquivalent(resolved, resolveResult.getElement())) { return true; } - if (element.getManager().areElementsEquivalent(resolved, resolveResult.getElement())) { + + final PsiClass containingClass = ((PsiClass)resolved).getContainingClass(); + if (containingClass != null && + !CodeStyleSettingsManager.getSettings(resolved.getProject()).getCustomSettings(GroovyCodeStyleSettings.class).INSERT_INNER_CLASS_IMPORTS) { + return false; + } + + if (resolveResult.getElement() == null || !resolveResult.isAccessible() || !resolveResult.isStaticsOK()) { return true; } From 5d759e951872e0886ddb9a276242ba4fdbba55cf Mon Sep 17 00:00:00 2001 From: Max Medvedev Date: Wed, 10 Apr 2013 16:02:08 +0400 Subject: [PATCH 12/31] IDEA-102328 resolve inner classes in subclasses --- .../groovy/lang/GrReferenceAdjuster.java | 11 +++++---- .../groovy/lang/psi/util/GrClassImplUtil.java | 24 ++++++++++++------- .../lang/resolve/GroovyResolveTestCase.groovy | 22 ++++++++--------- .../lang/resolve/ResolveClassTest.groovy | 10 +++++++- .../InnerClassOfClassInSubClass1.groovy | 7 ++++++ .../InnerClassOfInterface.groovy | 11 +++++++++ 6 files changed, 59 insertions(+), 26 deletions(-) create mode 100644 plugins/groovy/testdata/resolve/class/innerClassOfClassInSubClass1/InnerClassOfClassInSubClass1.groovy create mode 100644 plugins/groovy/testdata/resolve/class/innerClassOfInterface/InnerClassOfInterface.groovy diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/GrReferenceAdjuster.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/GrReferenceAdjuster.java index 154bead8a31f..a55caf899c58 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/GrReferenceAdjuster.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/GrReferenceAdjuster.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 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. @@ -126,7 +126,7 @@ public class GrReferenceAdjuster { if (resolved instanceof PsiClass) { final PsiClass clazz = (PsiClass)resolved; final String qName = clazz.getQualifiedName(); - if (qName != null && addImports && checkIsInnerClass(clazz) && mayInsertImport(ref)) { + if (qName != null && addImports && checkIsInnerClass(clazz, ref) && mayInsertImport(ref)) { final GroovyFileBase file = (GroovyFileBase)ref.getContainingFile(); final GrImportStatement added = file.addImportForClass(clazz); if (copy.isReferenceTo(resolved)) return true; @@ -137,10 +137,11 @@ public class GrReferenceAdjuster { return false; } - private static boolean checkIsInnerClass(@NotNull PsiClass resolved) { + private static boolean checkIsInnerClass(@NotNull PsiClass resolved, GrQualifiedReference ref) { final PsiClass containingClass = resolved.getContainingClass(); - return containingClass == null || CodeStyleSettingsManager.getSettings(resolved.getProject()) - .getCustomSettings(GroovyCodeStyleSettings.class).INSERT_INNER_CLASS_IMPORTS; + return containingClass == null || + PsiTreeUtil.isAncestor(containingClass, ref, true) || + CodeStyleSettingsManager.getSettings(resolved.getProject()).getCustomSettings(GroovyCodeStyleSettings.class).INSERT_INNER_CLASS_IMPORTS; } @Nullable diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrClassImplUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrClassImplUtil.java index 83566b9e4baf..6f0428fea243 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrClassImplUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrClassImplUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 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. @@ -276,7 +276,7 @@ public class GrClassImplUtil { public static boolean processDeclarations(@NotNull GrTypeDefinition grType, @NotNull PsiScopeProcessor processor, @NotNull ResolveState state, - PsiElement lastParent, + @Nullable PsiElement lastParent, @NotNull PsiElement place) { for (final PsiTypeParameter typeParameter : grType.getTypeParameters()) { if (!ResolveUtil.processElement(processor, typeParameter, state)) return false; @@ -356,7 +356,7 @@ public class GrClassImplUtil { final GrTypeDefinitionBody body = grType.getBody(); if (body != null) { if (classHint == null || classHint.shouldProcess(ClassHint.ResolveKind.CLASS)) { - for (PsiClass innerClass : getInnerClassesForResolve(grType, lastParent)) { + for (PsiClass innerClass : getInnerClassesForResolve(grType, lastParent, place)) { final String innerClassName = innerClass.getName(); if (nameHint != null && !innerClassName.equals(nameHint.getName(state))) { continue; @@ -373,26 +373,32 @@ public class GrClassImplUtil { return true; } - private static List getInnerClassesForResolve(final GrTypeDefinition grType, PsiElement lastParent) { - if (lastParent instanceof GrReferenceList) { + @NotNull + private static List getInnerClassesForResolve(@NotNull final GrTypeDefinition grType, + @Nullable final PsiElement lastParent, + @NotNull final PsiElement place) { + if (lastParent instanceof GrReferenceList || PsiTreeUtil.getParentOfType(place, GrReferenceList.class) != null) { return Arrays.asList(grType.getInnerClasses()); } - + List classes = RecursionManager.doPreventingRecursion(grType, true, new Computable>() { @Override public List compute() { List result = new ArrayList(); for (CandidateInfo info : CollectClassMembersUtil.getAllInnerClasses(grType, false).values()) { - ContainerUtil.addIfNotNull(result, (PsiClass)info.getElement()); + final PsiClass inner = (PsiClass)info.getElement(); + if (lastParent == null || !inner.getContainingClass().isInterface()) { + ContainerUtil.addIfNotNull(result, inner); + } } return result; } }); - + if (classes == null) { return Arrays.asList(grType.getInnerClasses()); } - + return classes; } diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/GroovyResolveTestCase.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/GroovyResolveTestCase.groovy index 9d81015c9f65..6407c317daae 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/GroovyResolveTestCase.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/GroovyResolveTestCase.groovy @@ -1,17 +1,17 @@ /* - * Copyright 2000-2007 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 + * Copyright 2000-2013 JetBrains s.r.o. * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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 * - * 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. + * 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.lang.resolve; @@ -82,7 +82,7 @@ public abstract class GroovyResolveTestCase extends LightGroovyTestCase { } @Nullable - protected T resolve(String fileName, Class type = null) { + protected T resolve(String fileName = getTestName(false) + ".groovy", Class type = null) { PsiReference ref = configureByFile(getTestName(true) + "/" + fileName); assertNotNull(ref) final resolved = ref.resolve() diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolveClassTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolveClassTest.groovy index f4841dc363d8..59c670e48ab2 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolveClassTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolveClassTest.groovy @@ -110,7 +110,9 @@ public class ResolveClassTest extends GroovyResolveTestCase { public void testInnerEnum() throws Throwable { doTest(); } public void testInnerClass()throws Throwable {doTest();} public void testInnerClassInSubclass()throws Throwable {doTest();} - public void testInnerClassUsageInsideOuterSubclass() throws Throwable{doTest();} + public void testInnerClassUsageInsideOuterSubclass() throws Throwable { doTest() } + public void testInnerClassOfInterface() { assertNull(resolve()) } + public void testInnerClassOfClassInSubClass1() { assertNull(resolve()) } public void testAliasedImportVsImplicitImport() throws Exception { PsiReference ref = configureByFile("aliasedImportVsImplicitImport/Test.groovy"); @@ -145,6 +147,12 @@ public class ResolveClassTest extends GroovyResolveTestCase { assertNotNull(resolved); } + public void testQualifiedRefToInnerClass() { + myFixture.addFileToProject('A.groovy', 'class A {class Bb {}}') + final PsiReference ref = configureByText('b.groovy', 'A.Bb b = new A.Bb()') + assertNotNull(ref.resolve()) + } + public void testClassVsPropertyGetter() { doTest(); } diff --git a/plugins/groovy/testdata/resolve/class/innerClassOfClassInSubClass1/InnerClassOfClassInSubClass1.groovy b/plugins/groovy/testdata/resolve/class/innerClassOfClassInSubClass1/InnerClassOfClassInSubClass1.groovy new file mode 100644 index 000000000000..2936bea1c0b0 --- /dev/null +++ b/plugins/groovy/testdata/resolve/class/innerClassOfClassInSubClass1/InnerClassOfClassInSubClass1.groovy @@ -0,0 +1,7 @@ +class A { + static class BB {} +} + +class C extends A { + class D extends BB {} +} \ No newline at end of file diff --git a/plugins/groovy/testdata/resolve/class/innerClassOfInterface/InnerClassOfInterface.groovy b/plugins/groovy/testdata/resolve/class/innerClassOfInterface/InnerClassOfInterface.groovy new file mode 100644 index 000000000000..9d1226a23961 --- /dev/null +++ b/plugins/groovy/testdata/resolve/class/innerClassOfInterface/InnerClassOfInterface.groovy @@ -0,0 +1,11 @@ +public interface IMappingPolicy { + enum PolicyResult {DontImport, UseUndefined, UseAbsent, UseSpecified, UseNull } + + class PolicyResultData {} +} + +class S implements IMappingPolicy { + def onUnmappedMasterData() { + return new PolicyResultData() + } +} \ No newline at end of file From e20b6160abc46ad1b1708e96793e547c9754535a Mon Sep 17 00:00:00 2001 From: Max Medvedev Date: Wed, 10 Apr 2013 16:10:15 +0400 Subject: [PATCH 13/31] IDEA-104786 "Convert To Java" refuses to convert groovy file --- .../convertToJava/ConvertToJavaHandler.java | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ConvertToJavaHandler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ConvertToJavaHandler.java index b2c4cd8c3766..8e5abecf10d9 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ConvertToJavaHandler.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ConvertToJavaHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 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. @@ -22,13 +22,15 @@ import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; -import com.intellij.refactoring.HelpID; import com.intellij.refactoring.RefactoringActionHandler; import com.intellij.refactoring.util.CommonRefactoringUtil; +import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.plugins.groovy.lang.psi.GroovyFile; import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringBundle; +import java.util.Set; + /** * @author Maxim.Medvedev */ @@ -50,16 +52,24 @@ public class ConvertToJavaHandler implements RefactoringActionHandler { } private static void invokeInner(Project project, PsiElement[] elements, Editor editor) { + Set files = ContainerUtil.newHashSet(); + for (PsiElement element : elements) { - if (!(element instanceof GroovyFile)) { + if (!(element instanceof PsiFile)) { + element = element.getContainingFile(); + } + + if (element instanceof GroovyFile) { + files.add((GroovyFile)element); + } + else { if (!ApplicationManager.getApplication().isUnitTestMode()) { - CommonRefactoringUtil.showErrorHint(project, editor, GroovyRefactoringBundle.message("convert.to.java.can.work.only.with.groovy"), REFACTORING_NAME, HelpID.EXTRACT_METHOD); + CommonRefactoringUtil.showErrorHint(project, editor, GroovyRefactoringBundle.message("convert.to.java.can.work.only.with.groovy"), REFACTORING_NAME, null); return; } } } - GroovyFile[] files = new GroovyFile[elements.length]; - System.arraycopy(elements, 0, files, 0, elements.length); - new ConvertToJavaProcessor(project, files).run(); + + new ConvertToJavaProcessor(project, files.toArray(new GroovyFile[files.size()])).run(); } } From 7619b3423d6fd757283e09a7d0c895853f7112b1 Mon Sep 17 00:00:00 2001 From: Max Medvedev Date: Wed, 10 Apr 2013 16:11:24 +0400 Subject: [PATCH 14/31] git rid refExpr resolve results --- .../findUsages/GroovyFindUsagesProvider.java | 5 ++--- .../GroovyDocumentationProvider.java | 20 ------------------ .../CompleteReferenceExpression.java | 7 +------ .../GrReferenceExpressionImpl.java | 21 ++++--------------- .../resolve/processors/ResolverProcessor.java | 2 -- .../convertToJava/ExpressionGenerator.java | 2 +- 6 files changed, 8 insertions(+), 49 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GroovyFindUsagesProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GroovyFindUsagesProvider.java index b4c3ac89490d..b2047ef8fe38 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GroovyFindUsagesProvider.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GroovyFindUsagesProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 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. @@ -24,7 +24,6 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrLabeledStatement; import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable; import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock; -import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression; import org.jetbrains.plugins.groovy.refactoring.rename.PropertyForRename; /** @@ -59,7 +58,7 @@ public class GroovyFindUsagesProvider implements FindUsagesProvider { if (element instanceof PsiMethod) return "method"; if (element instanceof PsiField) return "field"; if (element instanceof PsiParameter) return "parameter"; - if (element instanceof PsiVariable || element instanceof GrReferenceExpression) return "variable"; + if (element instanceof PsiVariable) return "variable"; if (element instanceof GrLabeledStatement) return "label"; if (element instanceof PropertyForRename) return "property"; if (element instanceof GrClosableBlock) return "closure"; diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/documentation/GroovyDocumentationProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/documentation/GroovyDocumentationProvider.java index 059792bc988d..b7bf71027300 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/documentation/GroovyDocumentationProvider.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/documentation/GroovyDocumentationProvider.java @@ -54,8 +54,6 @@ import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult; import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifier; import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable; import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariableDeclaration; -import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrAssignmentExpression; -import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression; import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression; import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter; import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition; @@ -108,24 +106,6 @@ public class GroovyDocumentationProvider implements CodeDocumentationProvider, E } return buffer.toString(); } - else if (element instanceof GrReferenceExpression) { - GrReferenceExpression refExpr = (GrReferenceExpression)element; - StringBuilder buffer = new StringBuilder(); - PsiType type = null; - if (refExpr.getParent() instanceof GrAssignmentExpression) { - GrAssignmentExpression assignment = (GrAssignmentExpression)refExpr.getParent(); - if (refExpr.equals(assignment.getLValue())) { - GrExpression rvalue = assignment.getRValue(); - if (rvalue != null) { - type = rvalue.getType(); - } - } - } - appendTypeString(buffer, type, originalElement); - buffer.append(" "); - buffer.append(refExpr.getReferenceName()); - return buffer.toString(); - } else if (element instanceof PsiMethod) { StringBuilder buffer = new StringBuilder(); PsiMethod method = (PsiMethod)element; diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/CompleteReferenceExpression.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/CompleteReferenceExpression.java index 50647784792f..689ec76325b2 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/CompleteReferenceExpression.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/CompleteReferenceExpression.java @@ -360,7 +360,6 @@ public class CompleteReferenceExpression { private final boolean myFieldPointerOperator; private final boolean myMethodPointerOperator; private final boolean myIsMap; - private Set myNonDeclaredVars = new com.intellij.util.containers.HashSet(); private final SubstitutorComputer mySubstitutorComputer; protected CompleteReferenceProcessor(GrReferenceExpression place, Consumer consumer, @NotNull PrefixMatcher matcher, CompletionParameters parameters) { @@ -390,7 +389,7 @@ public class CompleteReferenceExpression { } @Override - public boolean execute(@NotNull PsiElement element, ResolveState state) { + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { if (element instanceof PsiMethod && ((PsiMethod)element).isConstructor()) return true; if (element instanceof PsiNamedElement) { @@ -427,10 +426,6 @@ public class CompleteReferenceExpression { if (element instanceof PsiVariable && !myMatcher.prefixMatches(((PsiVariable)element).getName())) { return; } - if (element instanceof GrReferenceExpression) { - String name = ((GrReferenceExpression)element).getReferenceName(); - if (!myNonDeclaredVars.add(name)) return; - } if (element instanceof GrReflectedMethod) { element = ((GrReflectedMethod)element).getBaseMethod(); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrReferenceExpressionImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrReferenceExpressionImpl.java index 5b591e836bba..0d8307d7983e 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrReferenceExpressionImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrReferenceExpressionImpl.java @@ -54,7 +54,10 @@ import org.jetbrains.plugins.groovy.lang.psi.api.SpreadState; import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField; import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable; import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock; -import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.*; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrApplicationStatement; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrMethodCall; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression; import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrMethodCallExpression; import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement; import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeArgumentList; @@ -599,22 +602,6 @@ public class GrReferenceExpressionImpl extends GrReferenceElementImpl Date: Thu, 11 Apr 2013 09:19:27 +0400 Subject: [PATCH 15/31] IDEA-104408 groovy-all has different CommandLineParser --- .../jetbrains/plugins/groovy/config/GroovyConfigUtils.java | 3 +++ .../plugins/groovy/console/DefaultGroovyShellRunner.java | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyConfigUtils.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyConfigUtils.java index b25325585764..4ae4c901d0f2 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyConfigUtils.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyConfigUtils.java @@ -81,6 +81,9 @@ public abstract class GroovyConfigUtils extends AbstractConfigUtils { if (groovyJarVersion == null) { groovyJarVersion = getSDKJarVersion(path + "/embeddable", GROOVY_ALL_JAR_PATTERN, MANIFEST_PATH); } + if (groovyJarVersion == null) { + groovyJarVersion = getSDKJarVersion(path, GROOVY_ALL_JAR_PATTERN, MANIFEST_PATH); + } return groovyJarVersion == null ? UNDEFINED_VERSION : groovyJarVersion; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/console/DefaultGroovyShellRunner.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/console/DefaultGroovyShellRunner.java index dd6cc8974372..c87093360dd6 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/console/DefaultGroovyShellRunner.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/console/DefaultGroovyShellRunner.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 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. @@ -82,7 +82,8 @@ public class DefaultGroovyShellRunner extends GroovyShellRunner { private static boolean hasGroovyAll(Module module) { GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module); JavaPsiFacade facade = JavaPsiFacade.getInstance(module.getProject()); - return facade.findClass("org.apache.commons.cli.CommandLineParser", scope) != null && + return (facade.findClass("org.apache.commons.cli.CommandLineParser", scope) != null || + facade.findClass("groovyjarjarcommonscli.CommandLineParser", scope) != null) && facade.findClass("groovy.ui.GroovyMain", scope) != null; } From 2949e92b9b46240c5f08a9e5eaa8c85883dfa07a Mon Sep 17 00:00:00 2001 From: Max Medvedev Date: Thu, 11 Apr 2013 14:14:01 +0400 Subject: [PATCH 16/31] IDEA-103974 stricter pattern for groovy-all.jar name --- .../groovy/config/GroovyConfigUtils.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyConfigUtils.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyConfigUtils.java index 4ae4c901d0f2..b5020be884e4 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyConfigUtils.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyConfigUtils.java @@ -19,7 +19,7 @@ package org.jetbrains.plugins.groovy.config; import com.intellij.openapi.application.AccessToken; import com.intellij.openapi.application.WriteAction; import com.intellij.openapi.module.Module; -import com.intellij.openapi.module.ModuleUtil; +import com.intellij.openapi.module.ModuleUtilCore; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.*; import com.intellij.openapi.roots.libraries.Library; @@ -45,7 +45,7 @@ import java.util.regex.Pattern; * @author ilyas */ public abstract class GroovyConfigUtils extends AbstractConfigUtils { - @NonNls public static final Pattern GROOVY_ALL_JAR_PATTERN = Pattern.compile("groovy-all-(.*)\\.jar"); + @NonNls public static final Pattern GROOVY_ALL_JAR_PATTERN = Pattern.compile("groovy-all-(\\d.*)\\.jar"); private static GroovyConfigUtils myGroovyConfigUtils; @NonNls public static final String GROOVY_JAR_PATTERN_NOVERSION = "groovy\\.jar"; @@ -109,7 +109,7 @@ public abstract class GroovyConfigUtils extends AbstractConfigUtils { } public boolean isVersionAtLeast(PsiElement psiElement, String version, boolean unknownResult) { - Module module = ModuleUtil.findModuleForPsiElement(psiElement); + Module module = ModuleUtilCore.findModuleForPsiElement(psiElement); if (module == null) return unknownResult; final String sdkVersion = getSDKVersion(module); if (sdkVersion == null) return unknownResult; @@ -118,7 +118,7 @@ public abstract class GroovyConfigUtils extends AbstractConfigUtils { @NotNull public String getSDKVersion(PsiElement psiElement) { - final Module module = ModuleUtil.findModuleForPsiElement(psiElement); + final Module module = ModuleUtilCore.findModuleForPsiElement(psiElement); if (module == null) { return NO_VERSION; } @@ -131,13 +131,10 @@ public abstract class GroovyConfigUtils extends AbstractConfigUtils { public boolean isSDKHome(VirtualFile file) { if (file != null && file.isDirectory()) { final String path = file.getPath(); - if (GroovyUtils.getFilesInDirectoryByPattern(path + "/lib", GROOVY_JAR_PATTERN).length > 0) { - return true; - } - if (GroovyUtils.getFilesInDirectoryByPattern(path + "/lib", GROOVY_JAR_PATTERN_NOVERSION).length > 0) { - return true; - } - if (GroovyUtils.getFilesInDirectoryByPattern(path + "/embeddable", GROOVY_ALL_JAR_PATTERN).length > 0) { + if (GroovyUtils.getFilesInDirectoryByPattern(path + "/lib", GROOVY_JAR_PATTERN).length > 0 || + GroovyUtils.getFilesInDirectoryByPattern(path + "/lib", GROOVY_JAR_PATTERN_NOVERSION).length > 0 || + GroovyUtils.getFilesInDirectoryByPattern(path + "/embeddable", GROOVY_ALL_JAR_PATTERN).length > 0 || + GroovyUtils.getFilesInDirectoryByPattern(path, GROOVY_JAR_PATTERN).length > 0) { return true; } } From 176d346c0b864dd9b6a407e4e12da1422b56b8bb Mon Sep 17 00:00:00 2001 From: Sergey Evdokimov Date: Wed, 27 Mar 2013 10:56:31 +0400 Subject: [PATCH 17/31] Minor code change: optimization. --- .../util/src/com/intellij/util/ArrayUtil.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/platform/util/src/com/intellij/util/ArrayUtil.java b/platform/util/src/com/intellij/util/ArrayUtil.java index 3f1470ad9a56..40e3f84ede22 100644 --- a/platform/util/src/com/intellij/util/ArrayUtil.java +++ b/platform/util/src/com/intellij/util/ArrayUtil.java @@ -685,6 +685,21 @@ public class ArrayUtil extends ArrayUtilRt { return indexOf(objects, o) >= 0; } + public static boolean contains(@Nullable final String s, final String... strings) { + if (s == null) { + for (String str : strings) { + if (str == null) return true; + } + } + else { + for (String str : strings) { + if (s.equals(str)) return true; + } + } + + return false; + } + @NotNull public static int[] newIntArray(int count) { return count == 0 ? EMPTY_INT_ARRAY : new int[count]; From aa5ce7b95374baccf691bd00d544a43145a33b4d Mon Sep 17 00:00:00 2001 From: Sergey Evdokimov Date: Thu, 11 Apr 2013 15:20:31 +0400 Subject: [PATCH 18/31] IDEA-103600 UNDO error: Whenever I entered ctrl+z, this always worked. Since the last 2 EAP versions it is problematic --- .../encoding/EncodingProjectManagerImpl.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/encoding/EncodingProjectManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/vfs/encoding/EncodingProjectManagerImpl.java index 495d72e63178..826028cdd21b 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/encoding/EncodingProjectManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/encoding/EncodingProjectManagerImpl.java @@ -210,17 +210,22 @@ public class EncodingProjectManagerImpl extends EncodingProjectManager { @Override public void setEncoding(@Nullable final VirtualFile virtualFileOrDir, @Nullable final Charset charset) { + Charset oldCharset; + if (charset == null) { - myMapping.remove(virtualFileOrDir); + oldCharset = myMapping.remove(virtualFileOrDir); } else { - myMapping.put(virtualFileOrDir, charset); + oldCharset = myMapping.put(virtualFileOrDir, charset); } - myModificationCount++; - if (virtualFileOrDir != null) { - virtualFileOrDir.setCharset(virtualFileOrDir.getBOM() == null ? charset : null); + + if (!Comparing.equal(oldCharset, charset)) { + myModificationCount++; + if (virtualFileOrDir != null) { + virtualFileOrDir.setCharset(virtualFileOrDir.getBOM() == null ? charset : null); + } + reloadAllFilesUnder(virtualFileOrDir); } - reloadAllFilesUnder(virtualFileOrDir); } private static void clearAndReload(@NotNull VirtualFile virtualFileOrDir) { From f791e0526fdc84b9f572f9415b3e44effa3306d2 Mon Sep 17 00:00:00 2001 From: anna Date: Thu, 11 Apr 2013 10:49:40 +0200 Subject: [PATCH 19/31] implicit select all/unselect all for import projects step (IDEA-103677) --- .../SelectImportedProjectsStep.java | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/java/idea-ui/src/com/intellij/projectImport/SelectImportedProjectsStep.java b/java/idea-ui/src/com/intellij/projectImport/SelectImportedProjectsStep.java index 83d068599aaf..0d3cbb2f7d66 100644 --- a/java/idea-ui/src/com/intellij/projectImport/SelectImportedProjectsStep.java +++ b/java/idea-ui/src/com/intellij/projectImport/SelectImportedProjectsStep.java @@ -18,7 +18,9 @@ package com.intellij.projectImport; import com.intellij.ide.IdeBundle; import com.intellij.ide.util.ElementsChooser; import com.intellij.ide.util.projectWizard.WizardContext; +import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.options.ConfigurationException; +import com.intellij.refactoring.RefactoringBundle; import com.intellij.ui.IdeBorderFactory; import com.intellij.uiDesigner.core.GridConstraints; import com.intellij.uiDesigner.core.GridLayoutManager; @@ -48,14 +50,33 @@ public abstract class SelectImportedProjectsStep extends ProjectImportWizardS } }; - panel = new JPanel(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel = new JPanel(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); panel.add(fileChooser, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null)); + + final AnAction selectAllAction = new AnAction(RefactoringBundle.message("select.all.button")) { + @Override + public void actionPerformed(AnActionEvent e) { + fileChooser.setAllElementsMarked(true); + } + }; + final AnAction unselectAllAction = new AnAction(RefactoringBundle.message("unselect.all.button")) { + @Override + public void actionPerformed(AnActionEvent e) { + fileChooser.setAllElementsMarked(false); + } + }; + final JComponent actionToolbar = + ActionManager.getInstance().createButtonToolbar(ActionPlaces.UNKNOWN, new DefaultActionGroup(selectAllAction, unselectAllAction)); + panel.add(actionToolbar, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK, null, null, null)); + openModuleSettingsCheckBox = new JCheckBox(IdeBundle.message("project.import.show.settings.after")); - panel.add(openModuleSettingsCheckBox, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_SOUTH, GridConstraints.FILL_HORIZONTAL, + panel.add(openModuleSettingsCheckBox, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_SOUTH, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null)); } From 42763f92751f10d99e06bdc1be9718e918207558 Mon Sep 17 00:00:00 2001 From: anna Date: Thu, 11 Apr 2013 12:14:01 +0200 Subject: [PATCH 20/31] IDEA-105101 Java: bad code is green: cyclic annotation element types (JLS 9.6.1. Annotation Type Elements) --- .../analysis/AnnotationsHighlightUtil.java | 18 ++++++++++++- .../pingPongAnnotationTypesDependencies.java | 27 +++++++++++++++++++ .../annotations/wrongPlace.java | 2 +- .../daemon/AnnotationsHighlightingTest.java | 2 ++ 4 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/annotations/pingPongAnnotationTypesDependencies.java diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/AnnotationsHighlightUtil.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/AnnotationsHighlightUtil.java index 69398342cff4..169dc01ca02a 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/AnnotationsHighlightUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/AnnotationsHighlightUtil.java @@ -442,13 +442,29 @@ public class AnnotationsHighlightUtil { public static HighlightInfo checkCyclicMemberType(PsiTypeElement typeElement, PsiClass aClass) { LOG.assertTrue(aClass.isAnnotationType()); PsiType type = typeElement.getType(); - if (type instanceof PsiClassType && ((PsiClassType)type).resolve() == aClass) { + final Set checked = new HashSet(); + if (cyclicDependencies(aClass, type, checked)) { String description = JavaErrorMessages.message("annotation.cyclic.element.type"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(typeElement).descriptionAndTooltip(description).create(); } return null; } + private static boolean cyclicDependencies(PsiClass aClass, PsiType type, Set checked) { + final PsiClass resolvedClass = PsiUtil.resolveClassInType(type); + if (resolvedClass != null && resolvedClass.isAnnotationType()) { + if (aClass == resolvedClass) { + return true; + } + if (!checked.add(resolvedClass) || !resolvedClass.getManager().isInProject(resolvedClass)) return false; + final PsiMethod[] methods = resolvedClass.getMethods(); + for (PsiMethod method : methods) { + if (cyclicDependencies(aClass, method.getReturnType(), checked)) return true; + } + } + return false; + } + @Nullable public static HighlightInfo checkAnnotationDeclaration(final PsiElement parent, final PsiReferenceList list) { if (PsiUtil.isAnnotationMethod(parent)) { diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/annotations/pingPongAnnotationTypesDependencies.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/annotations/pingPongAnnotationTypesDependencies.java new file mode 100644 index 000000000000..138abc231085 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/annotations/pingPongAnnotationTypesDependencies.java @@ -0,0 +1,27 @@ +@interface A1 { + B1 value(); +} + +@interface B1 { + A1 value(); +} + +@interface C1 { + A1 value(); +} + +@interface D1 { + D1 value(); +} + +enum E1 { + E_1; + + @F(E_1) + void foo() { + } +} + +@interface F { + E1 value(); +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/annotations/wrongPlace.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/annotations/wrongPlace.java index 46f198986c17..ab1d2f0273e0 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/annotations/wrongPlace.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/annotations/wrongPlace.java @@ -1,7 +1,7 @@ import java.util.Collection; @interface Anno { - Anno[] nested() default {}; + Anno[] nested() default {}; } abstract class C { diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AnnotationsHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AnnotationsHighlightingTest.java index 2ce170b980be..c006315a9d79 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AnnotationsHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AnnotationsHighlightingTest.java @@ -46,6 +46,8 @@ public class AnnotationsHighlightingTest extends LightDaemonAnalyzerTestCase { public void testTypeAnnotations() { doTest8(false); } public void testRepeatable() { doTest8(false); } + public void testPingPongAnnotationTypesDependencies() { doTest(false);} + private void doTest(boolean checkWarnings) { setLanguageLevel(LanguageLevel.JDK_1_7); doTest(BASE_PATH + "/" + getTestName(true) + ".java", checkWarnings, false); From 2eb25bff4e39c15b1123f1f61a43577e5e78263e Mon Sep 17 00:00:00 2001 From: anna Date: Thu, 11 Apr 2013 12:46:08 +0200 Subject: [PATCH 21/31] disable override object/annotation methods in annotation interface --- .../generation/OverrideImplementExploreUtil.java | 1 + .../overrideImplement/beforeInAnnotationType.java | 3 +++ .../intellij/codeInsight/OverrideImplementTest.java | 11 +++++++++++ 3 files changed, 15 insertions(+) create mode 100644 java/java-tests/testData/codeInsight/overrideImplement/beforeInAnnotationType.java diff --git a/java/java-psi-impl/src/com/intellij/codeInsight/generation/OverrideImplementExploreUtil.java b/java/java-psi-impl/src/com/intellij/codeInsight/generation/OverrideImplementExploreUtil.java index 52e9ab691092..a29a0c561287 100644 --- a/java/java-psi-impl/src/com/intellij/codeInsight/generation/OverrideImplementExploreUtil.java +++ b/java/java-psi-impl/src/com/intellij/codeInsight/generation/OverrideImplementExploreUtil.java @@ -30,6 +30,7 @@ public class OverrideImplementExploreUtil { @NotNull public static Collection getMethodSignaturesToOverride(@NotNull PsiClass aClass) { + if (aClass.isInterface()) return Collections.emptySet(); return getMapToOverrideImplement(aClass, false).keySet(); } diff --git a/java/java-tests/testData/codeInsight/overrideImplement/beforeInAnnotationType.java b/java/java-tests/testData/codeInsight/overrideImplement/beforeInAnnotationType.java new file mode 100644 index 000000000000..d1045a1ff6db --- /dev/null +++ b/java/java-tests/testData/codeInsight/overrideImplement/beforeInAnnotationType.java @@ -0,0 +1,3 @@ +@interface ff{ + +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/OverrideImplementTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/OverrideImplementTest.java index a5be3591b236..3ed1526c4433 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/OverrideImplementTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/OverrideImplementTest.java @@ -15,6 +15,7 @@ */ package com.intellij.codeInsight; +import com.intellij.codeInsight.generation.JavaOverrideMethodsHandler; import com.intellij.codeInsight.generation.OverrideImplementUtil; import com.intellij.codeInsight.generation.PsiMethodMember; import com.intellij.codeInsight.intention.impl.ImplementAbstractMethodHandler; @@ -129,6 +130,16 @@ public class OverrideImplementTest extends LightCodeInsightTestCase { checkResultByFile(BASE_DIR + "after" + name + ".java"); } + public void testInAnnotationType() { + String name = getTestName(false); + configureByFile(BASE_DIR + "before" + name + ".java"); + int offset = getEditor().getCaretModel().getOffset(); + PsiElement context = getFile().findElementAt(offset); + final PsiClass aClass = PsiTreeUtil.getParentOfType(context, PsiClass.class); + assertTrue(aClass != null && aClass.isAnnotationType()); + assertFalse(new JavaOverrideMethodsHandler().isValidFor(getEditor(), getFile())); + } + private void doTest(boolean copyJavadoc) { doTest(copyJavadoc, null); } private void doTest8(boolean copyJavadoc, @Nullable Boolean toImplement) { From f622b3c704db63a8748ae9c2833347ef1ea6a149 Mon Sep 17 00:00:00 2001 From: anna Date: Thu, 11 Apr 2013 13:14:41 +0200 Subject: [PATCH 22/31] annotation interfaces: highlight methods which override public/protected methods of Object/Annotation (9.6.1. Annotation Type Elements) --- .../analysis/AnnotationsHighlightUtil.java | 18 ++++++++++++++++++ .../impl/analysis/HighlightVisitorImpl.java | 1 + .../annotations/clashMethods.java | 9 +++++++++ .../daemon/AnnotationsHighlightingTest.java | 1 + 4 files changed, 29 insertions(+) create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/annotations/clashMethods.java diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/AnnotationsHighlightUtil.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/AnnotationsHighlightUtil.java index 169dc01ca02a..cf292d39c67a 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/AnnotationsHighlightUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/AnnotationsHighlightUtil.java @@ -465,6 +465,24 @@ public class AnnotationsHighlightUtil { return false; } + public static HighlightInfo checkClashesWithSuperMethods(@NotNull PsiAnnotationMethod psiMethod) { + final PsiIdentifier nameIdentifier = psiMethod.getNameIdentifier(); + if (nameIdentifier != null) { + final PsiMethod[] methods = psiMethod.findDeepestSuperMethods(); + for (PsiMethod method : methods) { + final PsiClass containingClass = method.getContainingClass(); + if (containingClass != null) { + final String qualifiedName = containingClass.getQualifiedName(); + if (CommonClassNames.JAVA_LANG_OBJECT.equals(qualifiedName) || CommonClassNames.JAVA_LANG_ANNOTATION_ANNOTATION.equals(qualifiedName)) { + return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(nameIdentifier).descriptionAndTooltip( + "@interface member clashes with '" + HighlightUtil.formatMethod(method) + "' in " + HighlightUtil.formatClass(containingClass)).create(); + } + } + } + } + return null; + } + @Nullable public static HighlightInfo checkAnnotationDeclaration(final PsiElement parent, final PsiReferenceList list) { if (PsiUtil.isAnnotationMethod(parent)) { diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java index 9e6f8a85cedb..44b5431e8e08 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java @@ -217,6 +217,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh myHolder.add(AnnotationsHighlightUtil.checkValidAnnotationType(method.getReturnTypeElement())); myHolder.add(AnnotationsHighlightUtil.checkCyclicMemberType(method.getReturnTypeElement(), method.getContainingClass())); + myHolder.add(AnnotationsHighlightUtil.checkClashesWithSuperMethods(method)); } @Override public void visitArrayInitializerExpression(PsiArrayInitializerExpression expression) { diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/annotations/clashMethods.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/annotations/clashMethods.java new file mode 100644 index 000000000000..e15d63d6d873 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/annotations/clashMethods.java @@ -0,0 +1,9 @@ +@interface A1 { + String toString(); + Class annotationType(); + int value(); + boolean equals(); + void finalize(); + void registerNatives(); +} + diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AnnotationsHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AnnotationsHighlightingTest.java index c006315a9d79..1868d2196d7c 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AnnotationsHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AnnotationsHighlightingTest.java @@ -47,6 +47,7 @@ public class AnnotationsHighlightingTest extends LightDaemonAnalyzerTestCase { public void testRepeatable() { doTest8(false); } public void testPingPongAnnotationTypesDependencies() { doTest(false);} + public void testClashMethods() { doTest(false);} private void doTest(boolean checkWarnings) { setLanguageLevel(LanguageLevel.JDK_1_7); From 13b105b94b28ad2f655b3d28aad413272b268ed2 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Thu, 11 Apr 2013 15:34:50 +0400 Subject: [PATCH 23/31] compiler statistics (IDEA-94093 Need statistics for new make) --- .../CompilerSettingsUsageCollector.java | 62 +++++++++++++++++++ resources/src/idea/RichPlatformPlugin.xml | 1 + 2 files changed, 63 insertions(+) create mode 100644 java/compiler/impl/src/com/intellij/compiler/CompilerSettingsUsageCollector.java diff --git a/java/compiler/impl/src/com/intellij/compiler/CompilerSettingsUsageCollector.java b/java/compiler/impl/src/com/intellij/compiler/CompilerSettingsUsageCollector.java new file mode 100644 index 000000000000..06bf055246c3 --- /dev/null +++ b/java/compiler/impl/src/com/intellij/compiler/CompilerSettingsUsageCollector.java @@ -0,0 +1,62 @@ +/* + * Copyright 2000-2013 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.compiler; + +import com.intellij.internal.statistic.CollectUsagesException; +import com.intellij.internal.statistic.UsagesCollector; +import com.intellij.internal.statistic.beans.GroupDescriptor; +import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.openapi.project.Project; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +/** + * @author Eugene Zhuravlev + * Date: 4/11/13 + */ +public class CompilerSettingsUsageCollector extends UsagesCollector{ + public static final String GROUP_ID = "compiler"; + + @NotNull + @Override + public Set getUsages(@Nullable Project project) throws CollectUsagesException { + final CompilerWorkspaceConfiguration wsConfig = CompilerWorkspaceConfiguration.getInstance(project); + if (!wsConfig.useOutOfProcessBuild()) { + return Collections.emptySet(); + } + + final Set result = new HashSet(); + result.add(new UsageDescriptor("external_build", 1)); + if (wsConfig.MAKE_PROJECT_ON_SAVE) { + result.add(new UsageDescriptor("auto_make", 1)); + } + if (wsConfig.PARALLEL_COMPILATION) { + result.add(new UsageDescriptor("compile_parallel", 1)); + } + + return result; + } + + @NotNull + @Override + public GroupDescriptor getGroupId() { + return GroupDescriptor.create(GROUP_ID); + } +} diff --git a/resources/src/idea/RichPlatformPlugin.xml b/resources/src/idea/RichPlatformPlugin.xml index 1d37d6ffb460..d08976ae0770 100644 --- a/resources/src/idea/RichPlatformPlugin.xml +++ b/resources/src/idea/RichPlatformPlugin.xml @@ -327,6 +327,7 @@ + From e3416d24f6ebfc2e3d883ceccb95e823247aa324 Mon Sep 17 00:00:00 2001 From: nik Date: Thu, 11 Apr 2013 15:58:28 +0400 Subject: [PATCH 24/31] external build: fix composing classpath for plugins registered in tests --- .../server/impl/CompileServerClasspathManager.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/server/impl/CompileServerClasspathManager.java b/java/compiler/impl/src/com/intellij/compiler/server/impl/CompileServerClasspathManager.java index 91c001d7517a..e1474b9f770f 100644 --- a/java/compiler/impl/src/com/intellij/compiler/server/impl/CompileServerClasspathManager.java +++ b/java/compiler/impl/src/com/intellij/compiler/server/impl/CompileServerClasspathManager.java @@ -85,7 +85,11 @@ public class CompileServerClasspathManager { else { //development mode: add directory out/classes/production/ to classpath, assuming that jar-name is equal to module name final String moduleName = FileUtil.getNameWithoutExtension(PathUtil.getFileName(relativePath)); - final File dir = new File(baseFile.getParentFile(), moduleName); + File baseOutputDir = baseFile.getParentFile(); + if (baseOutputDir.getName().equals("test")) { + baseOutputDir = new File(baseOutputDir.getParentFile(), "production"); + } + final File dir = new File(baseOutputDir, moduleName); if (dir.exists()) { classpath.add(dir.getPath()); } @@ -98,12 +102,13 @@ public class CompileServerClasspathManager { classpath.add(libraryFile.getPath()); } else { - LOG.error("Cannot add plugin '" + plugin.getName() + "' to external compiler classpath: " + + LOG.error("Cannot add " + relativePath + " from plugin '" + plugin.getName() + "' to external compiler classpath: " + "library " + libraryFile.getAbsolutePath() + " not found"); } } else { - LOG.error("Cannot add plugin '" + plugin.getName() + "' to external compiler classpath: home directory of plugin not found"); + LOG.error("Cannot add " + relativePath + " from plugin '" + plugin.getName() + + "' to external compiler classpath: home directory of plugin not found"); } } } From 9a96106d5ca08e64aff1275ddffc6217421f7063 Mon Sep 17 00:00:00 2001 From: nik Date: Thu, 11 Apr 2013 15:59:12 +0400 Subject: [PATCH 25/31] App Engine plugin reenabled in tests and removed from ultimate tests to avoid duplication --- plugins/google-app-engine/testSource/META-INF/plugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/google-app-engine/testSource/META-INF/plugin.xml b/plugins/google-app-engine/testSource/META-INF/plugin.xml index 2edf3e7f982d..01deb890064a 100644 --- a/plugins/google-app-engine/testSource/META-INF/plugin.xml +++ b/plugins/google-app-engine/testSource/META-INF/plugin.xml @@ -4,5 +4,5 @@ This fake plugin descriptor is used to run tests - + From e6815b7785c53fa5b956e3c031b295eeaf36ff75 Mon Sep 17 00:00:00 2001 From: anna Date: Thu, 11 Apr 2013 14:00:59 +0200 Subject: [PATCH 26/31] EA-45645 - NPE: FindDialog.updateReplaceVisibility --- platform/lang-impl/src/com/intellij/find/impl/FindDialog.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/find/impl/FindDialog.java b/platform/lang-impl/src/com/intellij/find/impl/FindDialog.java index a6c156efd303..df4a26241af1 100644 --- a/platform/lang-impl/src/com/intellij/find/impl/FindDialog.java +++ b/platform/lang-impl/src/com/intellij/find/impl/FindDialog.java @@ -221,7 +221,9 @@ public class FindDialog extends DialogWrapper { private void updateReplaceVisibility() { myReplacePrompt.setVisible(myModel.isReplaceState()); myReplaceComboBox.setVisible(myModel.isReplaceState()); - myCbToSkipResultsWhenOneUsage.setVisible(myModel.isReplaceState()); + if (myCbToSkipResultsWhenOneUsage != null) { + myCbToSkipResultsWhenOneUsage.setVisible(myModel.isReplaceState()); + } myCbPreserveCase.setVisible(myModel.isReplaceState()); } From 5eaef9a5f1ae1393e80b2b475f1c91532ded0c90 Mon Sep 17 00:00:00 2001 From: Sergey Evdokimov Date: Thu, 11 Apr 2013 16:44:19 +0400 Subject: [PATCH 27/31] IDEA-103234 No way to override systemPropertyVariables values in run configuration VM Options --- .../idea/maven/execution/MavenJUnitPatcher.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenJUnitPatcher.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenJUnitPatcher.java index 26255aba8665..c00e6daa4c37 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenJUnitPatcher.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenJUnitPatcher.java @@ -60,12 +60,16 @@ public class MavenJUnitPatcher extends JUnitPatcher { Element systemPropertyVariables = config.getChild("systemPropertyVariables"); if (systemPropertyVariables != null) { - for (Element element : (List)systemPropertyVariables.getChildren()) { - String propertyName = element.getName(); - String value = element.getValue(); + List propertiesDefinitions = (List)systemPropertyVariables.getChildren(); - javaParameters.getVMParametersList().addProperty(propertyName, value); + String[] params = new String[propertiesDefinitions.size()]; + + int i = 0; + for (Element element : propertiesDefinitions) { + params[i++] = "-D" + element.getName() + "=" + element.getValue(); } + + javaParameters.getVMParametersList().prependAll(params); } Element environmentVariables = config.getChild("environmentVariables"); From 00d59d913f65f72913b70e60a0c8096edeb701ba Mon Sep 17 00:00:00 2001 From: Sergey Evdokimov Date: Thu, 11 Apr 2013 16:55:08 +0400 Subject: [PATCH 28/31] Bug fix: don't forget to call expandMacros(parameter) --- .../intellij/execution/configurations/ParametersList.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/platform/platform-api/src/com/intellij/execution/configurations/ParametersList.java b/platform/platform-api/src/com/intellij/execution/configurations/ParametersList.java index b53801f7f6d1..a313922a5e0b 100644 --- a/platform/platform-api/src/com/intellij/execution/configurations/ParametersList.java +++ b/platform/platform-api/src/com/intellij/execution/configurations/ParametersList.java @@ -226,11 +226,14 @@ public class ParametersList implements Cloneable { } public void addAll(final String... parameters) { - ContainerUtil.addAll(myParameters, parameters); + addAll(Arrays.asList(parameters)); } public void addAll(final List parameters) { - myParameters.addAll(parameters); + // Don't use myParameters.addAll(parameters) , it does not call expandMacros(parameter) + for (String parameter : parameters) { + add(parameter); + } } @Override From 3c4fa1c70374aa61f5a9df03088061fd7ec04316 Mon Sep 17 00:00:00 2001 From: Sergey Evdokimov Date: Thu, 11 Apr 2013 16:56:02 +0400 Subject: [PATCH 29/31] Optimization of ParametersList.prependAll() --- .../intellij/execution/configurations/ParametersList.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/platform/platform-api/src/com/intellij/execution/configurations/ParametersList.java b/platform/platform-api/src/com/intellij/execution/configurations/ParametersList.java index a313922a5e0b..87ad2361c067 100644 --- a/platform/platform-api/src/com/intellij/execution/configurations/ParametersList.java +++ b/platform/platform-api/src/com/intellij/execution/configurations/ParametersList.java @@ -107,9 +107,8 @@ public class ParametersList implements Cloneable { } public void prependAll(@NonNls final String... parameter) { - for (int i = parameter.length - 1; i >= 0; i--) { - addAt(0, parameter[i]); - } + addAll(parameter); + Collections.rotate(myParameters, parameter.length); } public void addParametersString(final String parameters) { From 94bc2d77ac8305827adb7b1885ed4d9310c0d2b9 Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Thu, 11 Apr 2013 15:30:24 +0200 Subject: [PATCH 30/31] Settings dialog renamed to Preferences (IDEA-104903) +review CR-IC @nicity @kb --- .../src/com/intellij/ide/IdeBundle.java | 17 +++++++++++++++++ .../options/InitialConfigurationDialog.form | 4 ++-- .../options/InitialConfigurationDialog.java | 4 ++++ .../src/com/intellij/ide/BrowserUtil.java | 7 +++++-- .../ide/actions/ShowSettingsAction.java | 9 +++++++++ .../options/newEditor/OptionsEditorDialog.java | 3 ++- .../src/messages/ActionsBundle.properties | 4 ---- .../src/messages/IdeBundle.properties | 11 ++++++++++- .../src/idea/PlatformActions.xml | 2 +- .../org/jetbrains/idea/svn/SvnBundle.properties | 2 +- 10 files changed, 51 insertions(+), 12 deletions(-) diff --git a/platform/core-api/src/com/intellij/ide/IdeBundle.java b/platform/core-api/src/com/intellij/ide/IdeBundle.java index d604862e8a64..92d43beb579a 100644 --- a/platform/core-api/src/com/intellij/ide/IdeBundle.java +++ b/platform/core-api/src/com/intellij/ide/IdeBundle.java @@ -17,6 +17,7 @@ package com.intellij.ide; import com.intellij.CommonBundle; +import com.intellij.openapi.util.SystemInfo; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.PropertyKey; @@ -39,6 +40,22 @@ public class IdeBundle { return CommonBundle.message(getBundle(), key, params); } + public static String settingsTitle() { + return SystemInfo.isMac ? message("title.settings.mac") : message("title.settings"); + } + + public static String settingsAction() { + return SystemInfo.isMac ? message("action.settings.mac") : message("action.settings"); + } + + public static String settingsActionDescription() { + return SystemInfo.isMac ? message("action.settings.description.mac") : message("action.settings.description"); + } + + public static String settingsActionPath() { + return SystemInfo.isMac ? message("action.settings.path.mac") : message("action.settings.path"); + } + private static ResourceBundle getBundle() { ResourceBundle bundle = null; if (ourBundle != null) bundle = ourBundle.get(); diff --git a/platform/lang-impl/src/com/intellij/application/options/InitialConfigurationDialog.form b/platform/lang-impl/src/com/intellij/application/options/InitialConfigurationDialog.form index d1350397f7fd..72ce18ca8a96 100644 --- a/platform/lang-impl/src/com/intellij/application/options/InitialConfigurationDialog.form +++ b/platform/lang-impl/src/com/intellij/application/options/InitialConfigurationDialog.form @@ -131,13 +131,13 @@ - + - + diff --git a/platform/lang-impl/src/com/intellij/application/options/InitialConfigurationDialog.java b/platform/lang-impl/src/com/intellij/application/options/InitialConfigurationDialog.java index 896f3d6b75ab..21742ade3ed1 100644 --- a/platform/lang-impl/src/com/intellij/application/options/InitialConfigurationDialog.java +++ b/platform/lang-impl/src/com/intellij/application/options/InitialConfigurationDialog.java @@ -20,6 +20,7 @@ import com.intellij.application.options.colors.NewColorAndFontPanel; import com.intellij.application.options.colors.SimpleEditorPreview; import com.intellij.icons.AllIcons; import com.intellij.ide.DataManager; +import com.intellij.ide.IdeBundle; import com.intellij.ide.actions.CreateDesktopEntryAction; import com.intellij.ide.actions.CreateLauncherScriptAction; import com.intellij.ide.todo.TodoConfiguration; @@ -76,6 +77,7 @@ public class InitialConfigurationDialog extends DialogWrapper { private JCheckBox myGlobalEntryCheckBox; private JPanel myCreateEntryPanel; private ComboBox myAppearanceComboBox; + private JLabel myPreferencesLabel; private String myColorSettingsPage; private SimpleEditorPreview myPreviewEditor; private ColorAndFontOptions myPreviewOptions; @@ -177,6 +179,8 @@ public class InitialConfigurationDialog extends DialogWrapper { myGlobalEntryCheckBox.setSelected(!PathManager.getHomePath().startsWith("/home")); } + myPreferencesLabel.setText("You can use "+ IdeBundle.settingsActionPath() + " to configure any of these settings later."); + Disposer.register(myDisposable, new Disposable() { @Override public void dispose() { diff --git a/platform/platform-api/src/com/intellij/ide/BrowserUtil.java b/platform/platform-api/src/com/intellij/ide/BrowserUtil.java index b058fd0f8a59..8d16b045ea7e 100644 --- a/platform/platform-api/src/com/intellij/ide/BrowserUtil.java +++ b/platform/platform-api/src/com/intellij/ide/BrowserUtil.java @@ -51,8 +51,10 @@ import java.lang.reflect.InvocationTargetException; import java.net.MalformedURLException; import java.net.URI; import java.net.URL; -import java.util.*; +import java.util.Arrays; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.zip.ZipEntry; @@ -178,7 +180,8 @@ public class BrowserUtil { String browserPath = getGeneralSettingsInstance().getBrowserPath(); if (StringUtil.isEmptyOrSpaces(browserPath)) { - showErrorMessage(IdeBundle.message("error.please.specify.path.to.web.browser"), IdeBundle.message("title.browser.not.found")); + showErrorMessage(IdeBundle.message("error.please.specify.path.to.web.browser", IdeBundle.settingsActionPath()), + IdeBundle.message("title.browser.not.found")); return; } diff --git a/platform/platform-impl/src/com/intellij/ide/actions/ShowSettingsAction.java b/platform/platform-impl/src/com/intellij/ide/actions/ShowSettingsAction.java index 30459584327b..53ed30f2249e 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/ShowSettingsAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/ShowSettingsAction.java @@ -15,6 +15,8 @@ */ package com.intellij.ide.actions; +import com.intellij.icons.AllIcons; +import com.intellij.ide.IdeBundle; import com.intellij.openapi.actionSystem.ActionPlaces; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; @@ -31,12 +33,19 @@ import com.intellij.openapi.util.SystemInfo; import javax.swing.*; public class ShowSettingsAction extends AnAction implements DumbAware { + public ShowSettingsAction() { + super(IdeBundle.settingsAction(), IdeBundle.settingsActionDescription(), AllIcons.General.Settings); + } + @Override public void update(AnActionEvent e) { if (SystemInfo.isMac && e.getPlace().equals(ActionPlaces.MAIN_MENU)) { // It's called from Preferences in App menu. e.getPresentation().setVisible(false); } + if (e.getPlace().equals(ActionPlaces.WELCOME_SCREEN)) { + e.getPresentation().setText(IdeBundle.settingsTitle()); + } } public void actionPerformed(AnActionEvent e) { diff --git a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsEditorDialog.java b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsEditorDialog.java index f814ab2edd1a..64dbe628309a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsEditorDialog.java +++ b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsEditorDialog.java @@ -16,6 +16,7 @@ package com.intellij.openapi.options.newEditor; import com.intellij.CommonBundle; +import com.intellij.ide.IdeBundle; import com.intellij.ide.ui.search.SearchUtil; import com.intellij.ide.util.PropertiesComponent; import com.intellij.openapi.actionSystem.DataProvider; @@ -67,7 +68,7 @@ public class OptionsEditorDialog extends DialogWrapper implements DataProvider{ myGroups = groups; myPreselected = preselected; - setTitle("Settings"); + setTitle(IdeBundle.settingsTitle()); init(); } diff --git a/platform/platform-resources-en/src/messages/ActionsBundle.properties b/platform/platform-resources-en/src/messages/ActionsBundle.properties index f00453bde6fc..91e1c3b170c2 100644 --- a/platform/platform-resources-en/src/messages/ActionsBundle.properties +++ b/platform/platform-resources-en/src/messages/ActionsBundle.properties @@ -247,8 +247,6 @@ group.reopen.mac.text=Open _Recent group.$LRU.description=List of recently opened projects action.CloseProject.text=Close Pro_ject action.CloseProject.description=Close current project -action.ShowSettings.text=Se_ttings... -action.ShowSettings.description=Configure application settings action.ShowProjectStructureSettings.text=Project Structure... action.ShowProjectStructureSettings.description=Configure project structure action.TemplateProjectProperties.text=Def_ault Settings... @@ -1162,8 +1160,6 @@ action.WelcomeScreen.CreateNewProject.description=Start the \"New Project\" Wiza action.WelcomeScreen.ImportProject.text=Import Project action.WelcomeScreen.ImportProject.description=Create {0} project structure for directory with existing sources or convert existing project model. action.WelcomeScreen.JetBrainsTV.IDEA.text=JetBrains TV -action.WelcomeScreen.Settings.text=Settings -action.WelcomeScreen.Settings.description=Edit Settings action.WelcomeScreen.Plugins.text=Plugins action.WelcomeScreen.Plugins.description=Manage installed plugins and download new ones from repository action.WelcomeScreen.Configure.Import.text=Import Settings diff --git a/platform/platform-resources-en/src/messages/IdeBundle.properties b/platform/platform-resources-en/src/messages/IdeBundle.properties index 27ae01421fe9..e0c4999c79f8 100644 --- a/platform/platform-resources-en/src/messages/IdeBundle.properties +++ b/platform/platform-resources-en/src/messages/IdeBundle.properties @@ -1,7 +1,16 @@ +title.settings=Settings +title.settings.mac=Preferences +action.settings=Se_ttings... +action.settings.mac=Preferences... +action.settings.description=Edit application settings +action.settings.description.mac=Edit application preferences +action.settings.path=File | Settings +action.settings.path.mac=Preferences + title.cannot.start.browser=Cannot start browser error.malformed.url=Malformed url: {0} error.cannot.start.browser=Cannot start browser: {0} -error.please.specify.path.to.web.browser=Please specify a path to web browser in File | Settings | Web Browsers +error.please.specify.path.to.web.browser=Please specify a path to web browser in {0} | Web Browsers title.browser.not.found=Browser Not Found title.browser.path.not.found=Browser Path Not Found action.sort.alphabetically=Sort Alphabetically diff --git a/platform/platform-resources/src/idea/PlatformActions.xml b/platform/platform-resources/src/idea/PlatformActions.xml index 57ce347c1314..564effde7c92 100644 --- a/platform/platform-resources/src/idea/PlatformActions.xml +++ b/platform/platform-resources/src/idea/PlatformActions.xml @@ -153,7 +153,7 @@ - + diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnBundle.properties b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnBundle.properties index b86ae6f4b00e..45fe521b35e9 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnBundle.properties +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnBundle.properties @@ -218,7 +218,7 @@ radio.configure.change.auto.15format=1.&5 format radio.configure.change.auto.16format=1.&6 format radio.configure.change.auto.17format=1.&7 format -label.where.svn.format.settings.text=To change above setting later, visit 'File | Settings | Version Control' +label.where.svn.format.settings.text=To change above setting later, visit '{0} | Version Control' label.where.svn.format.can.be.changed.text=''Version Control | Subversion | {0}'' dialog.upgrade.wcopy.format.title=Subversion Working Copy Format From 678f6cd3c88a7b8d29e58e2cb1c6d89f28d49003 Mon Sep 17 00:00:00 2001 From: anna Date: Thu, 11 Apr 2013 15:35:54 +0200 Subject: [PATCH 31/31] rely on module name restored after module file rename (IDEA-104333) --- .../projectView/impl/RenameModuleHandler.java | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/RenameModuleHandler.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/RenameModuleHandler.java index 6028841e6a02..9dbe49f0c949 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/RenameModuleHandler.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/RenameModuleHandler.java @@ -22,10 +22,6 @@ import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.LangDataKeys; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.CommandProcessor; -import com.intellij.openapi.command.undo.BasicUndoableAction; -import com.intellij.openapi.command.undo.UndoManager; -import com.intellij.openapi.command.undo.UndoableAction; -import com.intellij.openapi.command.undo.UnexpectedUndoException; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.module.ModifiableModuleModel; @@ -105,24 +101,6 @@ public class RenameModuleHandler implements RenameHandler, TitledHandler { CommandProcessor.getInstance().executeCommand(myProject, new Runnable() { @Override public void run() { - UndoableAction action = new BasicUndoableAction() { - @Override - public void undo() throws UnexpectedUndoException { - final ModifiableModuleModel modifiableModel = renameModule(oldName); - if (modifiableModel != null) { - modifiableModel.commit(); - } - } - - @Override - public void redo() throws UnexpectedUndoException { - final ModifiableModuleModel modifiableModel = renameModule(inputString); - if (modifiableModel != null) { - modifiableModel.commit(); - } - } - }; - UndoManager.getInstance(myProject).undoableActionPerformed(action); ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() {