From 5949a15e9f4eb4aa67128df91c553fc1b67eed1c Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Mon, 5 Apr 2010 14:20:36 +0400 Subject: [PATCH 01/16] cleanup --- .../command/impl/UndoRedoStacksHolder.java | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoRedoStacksHolder.java b/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoRedoStacksHolder.java index 5f5e169a6271..d74b150d1720 100644 --- a/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoRedoStacksHolder.java +++ b/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoRedoStacksHolder.java @@ -40,16 +40,7 @@ class UndoRedoStacksHolder { myUndo = isUndo; } - public LinkedList getStack(Document d) { - return getStack(createReferenceOrGetOriginal(d)); - } - - private static DocumentReference createReferenceOrGetOriginal(Document d) { - Document original = UndoManagerImpl.getOriginal(d); - return DocumentReferenceManager.getInstance().create(original); - } - - public LinkedList getStack(@NotNull DocumentReference r) { + private LinkedList getStack(@NotNull DocumentReference r) { return r.getFile() != null ? doGetStackForFile(r) : doGetStackForDocument(r); } @@ -161,15 +152,15 @@ class UndoRedoStacksHolder { public void clearStacks(boolean clearGlobal, Set affectedDocuments) { if (clearGlobal) myGlobalStack.clear(); - for (DocumentReference each : affectedDocuments) { - List stack = getStack(each); + for (DocumentReference ref : affectedDocuments) { + List stack = getStack(ref); stack.clear(); - if (each.getFile() != null) { - myDocumentStacks.remove(each); + if (ref.getFile() != null) { + myDocumentStacks.remove(ref); } else { - Document d = each.getDocument(); + Document d = ref.getDocument(); d.putUserData(STACK_IN_DOCUMENT_KEY, null); myDocumentsWithStacks.remove(d); } From 26370bdffb31ff41b0e02f7739c94b6a6724563b Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Mon, 5 Apr 2010 14:56:07 +0400 Subject: [PATCH 02/16] documents leak fixed --- .../vfs/encoding/EncodingManagerImpl.java | 41 +++++++++++++++---- .../testFramework/LightPlatformTestCase.java | 6 +++ 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/encoding/EncodingManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/vfs/encoding/EncodingManagerImpl.java index 16ec5be2d307..e58ed35a9032 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/encoding/EncodingManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/encoding/EncodingManagerImpl.java @@ -23,6 +23,7 @@ package com.intellij.openapi.vfs.encoding; import com.intellij.openapi.Disposable; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.components.PersistentStateComponent; import com.intellij.openapi.components.State; import com.intellij.openapi.components.Storage; @@ -71,23 +72,47 @@ public class EncodingManagerImpl extends EncodingManager implements PersistentSt private final Queue myChangedDocuments = new ConcurrentLinkedQueue(); private final Runnable myEncodingUpdateRunnable = new Runnable() { public void run() { - Document document = myChangedDocuments.poll(); - if (document == null) return; - VirtualFile virtualFile = FileDocumentManager.getInstance().getFile(document); - if (virtualFile == null) return; - Project project = guessProject(virtualFile); - if (project != null && project.isDisposed()) return; - Charset charset = LoadTextUtil.charsetFromContentOrNull(project, virtualFile, document.getText()); - document.putUserData(CACHED_CHARSET_FROM_CONTENT, charset); + for (int i=0; i<50;i++) { + if (!pollAndHandleDocument()) return; + } + // requeue myself to handle the tail of the queue in next request + addCacheEncodingAlarm(); } }; + private boolean pollAndHandleDocument() { + final Document document = myChangedDocuments.poll(); + if (document == null) return false; + ApplicationManager.getApplication().runReadAction(new Runnable(){ + public void run() { + VirtualFile virtualFile = FileDocumentManager.getInstance().getFile(document); + if (virtualFile == null) return; + Project project = guessProject(virtualFile); + if (project != null && project.isDisposed()) return; + Charset charset = LoadTextUtil.charsetFromContentOrNull(project, virtualFile, document.getText()); + document.putUserData(CACHED_CHARSET_FROM_CONTENT, charset); + } + }); + return true; + } + public void dispose() { updateEncodingFromContent.cancelAllRequests(); + drainDocumentQueue(); + } + + public void drainDocumentQueue() { + while (pollAndHandleDocument()) { + // loop until empty + } } public void updateEncodingFromContent(Document document) { myChangedDocuments.offer(document); + addCacheEncodingAlarm(); + } + + private void addCacheEncodingAlarm() { updateEncodingFromContent.cancelAllRequests(); updateEncodingFromContent.addRequest(myEncodingUpdateRunnable, 400); } diff --git a/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java b/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java index bb51060993f7..0e1863ddff05 100644 --- a/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java @@ -61,6 +61,8 @@ import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileManager; +import com.intellij.openapi.vfs.encoding.EncodingManager; +import com.intellij.openapi.vfs.encoding.EncodingManagerImpl; import com.intellij.openapi.vfs.newvfs.ManagingFS; import com.intellij.openapi.vfs.newvfs.persistent.PersistentFS; import com.intellij.profile.codeInspection.InspectionProfileManager; @@ -411,10 +413,14 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da e.printStackTrace(); } } + EncodingManager encodingManager = EncodingManager.getInstance(); + if (encodingManager instanceof EncodingManagerImpl) ((EncodingManagerImpl)encodingManager).drainDocumentQueue(); + FileDocumentManager manager = FileDocumentManager.getInstance(); if (manager instanceof FileDocumentManagerImpl) { ((FileDocumentManagerImpl)manager).dropAllUnsavedDocuments(); } + ApplicationManager.getApplication().runWriteAction(EmptyRunnable.getInstance()); // Flash posponed formatting if any. manager.saveAllDocuments(); } From cc28af14aea709fe6ba6c89d0f9afc657f7d6f96 Mon Sep 17 00:00:00 2001 From: nik Date: Thu, 1 Apr 2010 15:59:23 +0400 Subject: [PATCH 03/16] IDEA-47033: Support updating a deployed WebSphere application --- .../impl/compiler/IncrementalArtifactsCompiler.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/compiler/IncrementalArtifactsCompiler.java b/java/compiler/impl/src/com/intellij/packaging/impl/compiler/IncrementalArtifactsCompiler.java index bed30dbcba13..9a322302d56c 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/compiler/IncrementalArtifactsCompiler.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/compiler/IncrementalArtifactsCompiler.java @@ -70,6 +70,7 @@ import java.util.*; */ public class IncrementalArtifactsCompiler implements PackagingCompiler { private static final Logger LOG = Logger.getInstance("#com.intellij.packaging.impl.compiler.IncrementalArtifactsCompiler"); + private static final Key> WRITTEN_PATHS_KEY = Key.create("artifacts_written_paths"); private static final Key> FILES_TO_DELETE_KEY = Key.create("artifacts_files_to_delete"); private static final Key> AFFECTED_ARTIFACTS = Key.create("affected_artifacts"); private static final Key BUILDER_CONTEXT_KEY = Key.create("artifacts_builder_context"); @@ -212,6 +213,7 @@ public class IncrementalArtifactsCompiler implements PackagingCompiler { }.execute(); removeInvalidItems(processedItems); updateOutputCache(context.getProject(), processedItems); + context.putUserData(WRITTEN_PATHS_KEY, writtenPaths); return processedItems.toArray(new ProcessingItem[processedItems.size()]); } @@ -325,6 +327,11 @@ public class IncrementalArtifactsCompiler implements PackagingCompiler { return compileContext.getUserData(AFFECTED_ARTIFACTS); } + @Nullable + public static Set getWrittenPaths(@NotNull CompileContext context) { + return context.getUserData(WRITTEN_PATHS_KEY); + } + @NotNull public String getDescription() { return "Artifacts Packaging Compiler"; From 6b86f5c132b965b0f0828c65ee1160b1079ae123 Mon Sep 17 00:00:00 2001 From: nik Date: Fri, 2 Apr 2010 09:27:46 +0400 Subject: [PATCH 04/16] IDEA-53280: Could not remove modules from project --- .../projectRoot/daemon/ModuleProjectStructureElement.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/ModuleProjectStructureElement.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/ModuleProjectStructureElement.java index 7bf2e1e263dd..e2b35d0477be 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/ModuleProjectStructureElement.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/ModuleProjectStructureElement.java @@ -8,6 +8,7 @@ import com.intellij.openapi.roots.*; import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.roots.ui.configuration.ModuleEditor; import com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext; +import com.intellij.util.ArrayUtil; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -32,6 +33,10 @@ public class ModuleProjectStructureElement extends ProjectStructureElement { public void check(ProjectStructureProblemsHolder problemsHolder) { final ModifiableModuleModel moduleModel = myContext.getModulesConfigurator().getModuleModel(); final Module[] all = moduleModel.getModules(); + if (!ArrayUtil.contains(myModule, all)) { + return;//module has been deleted + } + for (Module each : all) { if (each != myModule && myContext.getRealName(each).equals(myContext.getRealName(myModule))) { problemsHolder.registerError(ProjectBundle.message("project.roots.module.duplicate.name.message")); From 90936ed38f868a8006894dbf7d79ce27c15b1b8a Mon Sep 17 00:00:00 2001 From: peter Date: Mon, 5 Apr 2010 16:23:28 +0400 Subject: [PATCH 05/16] an intention to download @Grab-defined Groovy dependencies, as a separate plugin --- plugins/groovy/grape/grape-rt.iml | 13 ++ plugins/groovy/grape/grape.iml | 18 ++ .../GrabDependencies/description.html | 1 + .../plugins/groovy/grape/GrapeRunner.java | 40 ++++ plugins/groovy/grape/src/META-INF/plugin.xml | 18 ++ .../groovy/grape/GrabDependencies.java | 218 ++++++++++++++++++ .../runner/DefaultGroovyScriptRunner.java | 31 +-- .../runner/GroovyScriptRunConfiguration.java | 30 +-- 8 files changed, 343 insertions(+), 26 deletions(-) create mode 100644 plugins/groovy/grape/grape-rt.iml create mode 100644 plugins/groovy/grape/grape.iml create mode 100644 plugins/groovy/grape/resources/intentionDescriptions/GrabDependencies/description.html create mode 100644 plugins/groovy/grape/rt/src/org/jetbrains/plugins/groovy/grape/GrapeRunner.java create mode 100644 plugins/groovy/grape/src/META-INF/plugin.xml create mode 100644 plugins/groovy/grape/src/org/jetbrains/plugins/groovy/grape/GrabDependencies.java diff --git a/plugins/groovy/grape/grape-rt.iml b/plugins/groovy/grape/grape-rt.iml new file mode 100644 index 000000000000..a24fe4731851 --- /dev/null +++ b/plugins/groovy/grape/grape-rt.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/plugins/groovy/grape/grape.iml b/plugins/groovy/grape/grape.iml new file mode 100644 index 000000000000..73ea14e036bf --- /dev/null +++ b/plugins/groovy/grape/grape.iml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/plugins/groovy/grape/resources/intentionDescriptions/GrabDependencies/description.html b/plugins/groovy/grape/resources/intentionDescriptions/GrabDependencies/description.html new file mode 100644 index 000000000000..b7b71fca3d68 --- /dev/null +++ b/plugins/groovy/grape/resources/intentionDescriptions/GrabDependencies/description.html @@ -0,0 +1 @@ +Add the dependency defined by @Grab annotation to the project \ No newline at end of file diff --git a/plugins/groovy/grape/rt/src/org/jetbrains/plugins/groovy/grape/GrapeRunner.java b/plugins/groovy/grape/rt/src/org/jetbrains/plugins/groovy/grape/GrapeRunner.java new file mode 100644 index 000000000000..39cc770d181e --- /dev/null +++ b/plugins/groovy/grape/rt/src/org/jetbrains/plugins/groovy/grape/GrapeRunner.java @@ -0,0 +1,40 @@ +package org.jetbrains.plugins.groovy.grape; + +import groovy.lang.GroovyShell; +import org.codehaus.groovy.control.CompilationFailedException; + +import java.io.File; +import java.net.URL; + +/** + * @author peter + */ +public class GrapeRunner { + public static final String URL_PREFIX = "URL:"; + + private GrapeRunner() { + } + + public static void main(String[] args) { + final File file = new File(args[0]); + if (!file.exists()) { + return; + } + + final GroovyShell shell = new GroovyShell(); + try { + shell.parse(file); + } + catch (CompilationFailedException ignored) { + //should fail, we're not compiling, we're just resolving Grab dependencies + } + catch (Throwable e) { + e.printStackTrace(); + } + + for (URL url : shell.getClassLoader().getURLs()) { + System.out.println(URL_PREFIX + url); + } + } + +} diff --git a/plugins/groovy/grape/src/META-INF/plugin.xml b/plugins/groovy/grape/src/META-INF/plugin.xml new file mode 100644 index 000000000000..b8fa5622ebc4 --- /dev/null +++ b/plugins/groovy/grape/src/META-INF/plugin.xml @@ -0,0 +1,18 @@ + + org.intellij.groovy.grape + Groovy Grape support + Managing Grape-defined dependencies + 0.1 + + JetBrains Inc. + org.intellij.groovy + + + + org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle + intention.category.groovy + org.jetbrains.plugins.groovy.grape.GrabDependencies + + + + diff --git a/plugins/groovy/grape/src/org/jetbrains/plugins/groovy/grape/GrabDependencies.java b/plugins/groovy/grape/src/org/jetbrains/plugins/groovy/grape/GrabDependencies.java new file mode 100644 index 000000000000..c41775277184 --- /dev/null +++ b/plugins/groovy/grape/src/org/jetbrains/plugins/groovy/grape/GrabDependencies.java @@ -0,0 +1,218 @@ +package org.jetbrains.plugins.groovy.grape; + +import com.intellij.codeInsight.intention.IntentionAction; +import com.intellij.execution.CantRunException; +import com.intellij.execution.ExecutionException; +import com.intellij.execution.configurations.GeneralCommandLine; +import com.intellij.execution.configurations.JavaParameters; +import com.intellij.execution.process.DefaultJavaProcessHandler; +import com.intellij.execution.process.ProcessOutputTypes; +import com.intellij.notification.Notification; +import com.intellij.notification.NotificationDisplayType; +import com.intellij.notification.NotificationType; +import com.intellij.notification.Notifications; +import com.intellij.openapi.application.Result; +import com.intellij.openapi.application.WriteAction; +import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.module.Module; +import com.intellij.openapi.module.ModuleUtil; +import com.intellij.openapi.progress.ProgressIndicator; +import com.intellij.openapi.progress.ProgressManager; +import com.intellij.openapi.progress.Task; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.projectRoots.JavaSdkType; +import com.intellij.openapi.projectRoots.JdkUtil; +import com.intellij.openapi.projectRoots.Sdk; +import com.intellij.openapi.projectRoots.SdkType; +import com.intellij.openapi.roots.ModifiableRootModel; +import com.intellij.openapi.roots.ModuleRootManager; +import com.intellij.openapi.roots.OrderRootType; +import com.intellij.openapi.roots.libraries.Library; +import com.intellij.openapi.roots.libraries.LibraryTable; +import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.util.Key; +import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.openapi.vfs.JarFileSystem; +import com.intellij.openapi.vfs.LocalFileSystem; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.psi.PsiFile; +import com.intellij.psi.util.PsiTreeUtil; +import com.intellij.util.IncorrectOperationException; +import com.intellij.util.PathUtil; +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation; +import org.jetbrains.plugins.groovy.runner.DefaultGroovyScriptRunner; +import org.jetbrains.plugins.groovy.runner.GroovyScriptRunConfiguration; + +import java.io.File; +import java.net.MalformedURLException; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; + +/** + * @author peter + */ +public class GrabDependencies implements IntentionAction { + private static final Logger LOG = Logger.getInstance("#org.jetbrains.plugins.groovy.grape.GrabDependencies"); + + @NotNull + public String getText() { + return "Grab the artifacts"; + } + + @NotNull + public String getFamilyName() { + return "Grab"; + } + + public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { + final GrAnnotation anno = PsiTreeUtil.findElementOfClassAtOffset(file, editor.getCaretModel().getOffset(), GrAnnotation.class, false); + if (anno == null) { + return false; + } + + final String qname = anno.getQualifiedName(); + if (qname == null || !(qname.startsWith("groovy.lang.Grab") || "groovy.lang.Grapes".equals(qname))) { + return false; + } + + final Module module = ModuleUtil.findModuleForPsiElement(file); + if (module == null) { + return false; + } + + return file.getOriginalFile().getVirtualFile() != null; + } + + public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + final Module module = ModuleUtil.findModuleForPsiElement(file); + assert module != null; + + final VirtualFile vfile = file.getOriginalFile().getVirtualFile(); + assert vfile != null; + + final JavaParameters javaParameters = GroovyScriptRunConfiguration.createJavaParametersWithSdk(module); + try { + //debug + //javaParameters.getVMParametersList().add("-Xdebug"); javaParameters.getVMParametersList().add("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5239"); + + final boolean tests = ModuleRootManager.getInstance(module).getFileIndex().isInTestSourceContent(vfile); + DefaultGroovyScriptRunner.configureGenericGroovyRunner(javaParameters, module, tests, "org.jetbrains.plugins.groovy.grape.GrapeRunner"); + + javaParameters.getProgramParametersList().add("--classpath"); + javaParameters.getProgramParametersList().add(PathUtil.getJarPathForClass(GrapeRunner.class)); + + javaParameters.getProgramParametersList().add(FileUtil.toSystemDependentName(vfile.getPath())); + + } + catch (CantRunException e) { + Messages.showErrorDialog(e.getMessage(), "Can't run Groovyc"); + return; + } + + final Sdk sdk = ModuleRootManager.getInstance(module).getSdk(); + assert sdk != null; + SdkType sdkType = sdk.getSdkType(); + assert sdkType instanceof JavaSdkType; + final String exePath = ((JavaSdkType)sdkType).getVMExecutablePath(sdk); + + try { + final GrapeProcessHandler handler = new GrapeProcessHandler(JdkUtil.setupJVMCommandLine(exePath, javaParameters, true), module); + ProgressManager.getInstance().run(new Task.Backgroundable(project, "Processing @Grab annotations") { + @Override + public void run(@NotNull ProgressIndicator indicator) { + handler.startNotify(); + handler.waitFor(); + } + }); + + } + catch (ExecutionException e) { + LOG.error(e); + } + + } + + public boolean startInWriteAction() { + return false; + } + + private static class GrapeProcessHandler extends DefaultJavaProcessHandler { + private final StringBuilder myStdOut = new StringBuilder(); + private final StringBuilder myStdErr = new StringBuilder(); + private final Module myModule; + + public GrapeProcessHandler(GeneralCommandLine commandLine, Module module) throws ExecutionException { + super(commandLine); + myModule = module; + } + + @Override + public void notifyTextAvailable(String text, Key outputType) { + text = StringUtil.convertLineSeparators(text); + if (LOG.isDebugEnabled()) { + LOG.debug(outputType + text); + } + if (outputType == ProcessOutputTypes.STDOUT) { + myStdOut.append(text); + } + else if (outputType == ProcessOutputTypes.STDERR) { + myStdErr.append(text); + } + } + + private void addGrapeDependencies(List jars) { + final ModifiableRootModel model = ModuleRootManager.getInstance(myModule).getModifiableModel(); + final LibraryTable.ModifiableModel tableModel = model.getModuleLibraryTable().getModifiableModel(); + for (VirtualFile jar : jars) { + final VirtualFile jarRoot = JarFileSystem.getInstance().getJarRootForLocalFile(jar); + if (jarRoot != null) { + final Library.ModifiableModel libModel = tableModel.createLibrary("Grab:" + jar.getName()).getModifiableModel(); + libModel.addRoot(jarRoot, OrderRootType.CLASSES); + libModel.commit(); + } + } + tableModel.commit(); + model.commit(); + } + + @Override + protected void notifyProcessTerminated(int exitCode) { + super.notifyProcessTerminated(exitCode); + final List jars = new ArrayList(); + for (String line : myStdOut.toString().split("\n")) { + if (line.startsWith(GrapeRunner.URL_PREFIX)) { + try { + final URL url = new URL(line.substring(GrapeRunner.URL_PREFIX.length())); + final File libFile = new File(url.toURI()); + if (libFile.exists() && libFile.getName().endsWith(".jar")) { + final VirtualFile vfile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(libFile); + ContainerUtil.addIfNotNull(vfile, jars); + } + } + catch (MalformedURLException e) { + LOG.error(e); + } + catch (URISyntaxException e) { + LOG.error(e); + } + } + } + new WriteAction() { + protected void run(Result result) throws Throwable { + final String title = jars.size() + " dependencies added"; + final String descr = myStdOut.toString().replaceAll("\n", "
") + "

" + myStdErr.toString().replaceAll("\n", "
"); + Notifications.Bus.notify(new Notification("Grape", title, descr, NotificationType.INFORMATION), NotificationDisplayType.BALLOON, myModule.getProject()); + if (!jars.isEmpty()) { + addGrapeDependencies(jars); + } + } + }.execute(); + } + } +} \ No newline at end of file diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/DefaultGroovyScriptRunner.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/DefaultGroovyScriptRunner.java index 94232dd3a7ee..774cd6f1c03c 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/DefaultGroovyScriptRunner.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/DefaultGroovyScriptRunner.java @@ -66,6 +66,23 @@ public class DefaultGroovyScriptRunner extends GroovyScriptRunner { @Override public void configureCommandLine(JavaParameters params, @Nullable Module module, boolean tests, VirtualFile script, GroovyScriptRunConfiguration configuration) throws CantRunException { + configureGenericGroovyRunner(params, module, tests, "groovy.ui.GroovyMain"); + + addClasspathFromRootModel(module, tests, params); + + params.getVMParametersList().addParametersString(configuration.vmParams); + + params.getProgramParametersList().add(FileUtil.toSystemDependentName(configuration.scriptPath)); + params.getProgramParametersList().addParametersString(configuration.scriptParams); + + addScriptEncodingSettings(params, script, module); + + if (configuration.isDebugEnabled) { + params.getProgramParametersList().add("--debug"); + } + } + + public static void configureGenericGroovyRunner(JavaParameters params, Module module, boolean tests, String mainClass) throws CantRunException { assert module != null; final VirtualFile groovyJar = findGroovyJar(module); if (groovyJar != null) { @@ -80,25 +97,13 @@ public class DefaultGroovyScriptRunner extends GroovyScriptRunner { final String confPath = getConfPath(groovyHome); params.getVMParametersList().add("-Dgroovy.starter.conf=" + confPath); - params.getVMParametersList().addParametersString(configuration.vmParams); params.setMainClass("org.codehaus.groovy.tools.GroovyStarter"); params.getProgramParametersList().add("--conf"); params.getProgramParametersList().add(confPath); - addClasspathFromRootModel(module, tests, params); - params.getProgramParametersList().add("--main"); - params.getProgramParametersList().add("groovy.ui.GroovyMain"); - - params.getProgramParametersList().add(FileUtil.toSystemDependentName(configuration.scriptPath)); - params.getProgramParametersList().addParametersString(configuration.scriptParams); - - addScriptEncodingSettings(params, script, module); - - if (configuration.isDebugEnabled) { - params.getProgramParametersList().add("--debug"); - } + params.getProgramParametersList().add(mainClass); } private static void addScriptEncodingSettings(final JavaParameters params, final VirtualFile scriptFile, Module module) { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyScriptRunConfiguration.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyScriptRunConfiguration.java index 5034cb7eefe0..ad0b1e7df128 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyScriptRunConfiguration.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyScriptRunConfiguration.java @@ -172,20 +172,8 @@ public class GroovyScriptRunConfiguration extends ModuleBasedConfiguration Date: Mon, 5 Apr 2010 16:37:04 +0400 Subject: [PATCH 06/16] since the next maia eap --- plugins/groovy/grape/src/META-INF/plugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/groovy/grape/src/META-INF/plugin.xml b/plugins/groovy/grape/src/META-INF/plugin.xml index b8fa5622ebc4..8b9df9c1612a 100644 --- a/plugins/groovy/grape/src/META-INF/plugin.xml +++ b/plugins/groovy/grape/src/META-INF/plugin.xml @@ -3,7 +3,7 @@ Groovy Grape support Managing Grape-defined dependencies 0.1 - + JetBrains Inc. org.intellij.groovy From 4b1849ba213852cd6e83ebefb25f48f1c84d3d5a Mon Sep 17 00:00:00 2001 From: Constantine Plotnikov Date: Mon, 5 Apr 2010 17:05:38 +0400 Subject: [PATCH 07/16] git4idea: Changed text for merge and rebase strategies in update option panel --- .../git4idea/src/git4idea/i18n/GitBundle.properties | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/git4idea/src/git4idea/i18n/GitBundle.properties b/plugins/git4idea/src/git4idea/i18n/GitBundle.properties index e6dcbda90f8b..e5b1c6cd35ca 100644 --- a/plugins/git4idea/src/git4idea/i18n/GitBundle.properties +++ b/plugins/git4idea/src/git4idea/i18n/GitBundle.properties @@ -437,11 +437,11 @@ update.options.save.shelve.tooltip=Use IDEA Shelve (the files will be restored w update.options.save.stash=Using S&tash update.options.save.stash.tooltip=Use 'git stash' to save changes (the files will be restored when update finishes) update.options.type.default=Branch &Default -update.options.type.default.tooltip=Use branch default update type for all updated vcs roots -update.options.type.merge=Force &Merge -update.options.type.merge.tooltip=Force merge update strategy -update.options.type.rebase=Force &Rebase -update.options.type.rebase.tooltip=Force rebase update strategy +update.options.type.default.tooltip=Use branch default update strategy for all updated git vcs roots +update.options.type.merge=&Merge +update.options.type.merge.tooltip=Use merge update strategy for all git vcs roots +update.options.type.rebase=&Rebase +update.options.type.rebase.tooltip=Use rebase update strategy for all git vcs roots update.options.type=Update Type update.rebase.no.change.cancel=Cancel Update update.rebase.no.change.retry=Retry Continue From 75dcad0b68de2b8c79318569853973bd534e5ebf Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Mon, 5 Apr 2010 15:17:06 +0200 Subject: [PATCH 08/16] rename static import properties --- .../src/com/siyeh/InspectionGadgetsBundle.properties | 4 ++-- .../src/com/siyeh/ig/imports/StaticImportInspection.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties b/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties index df1b738df96e..defcc79c8a61 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties +++ b/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties @@ -1761,5 +1761,5 @@ remove.try.finally.block.quickfix=Remove try-finally block remove.finally.block.quickfix=Remove finally block remove.leading.zero.to.make.decimal.quickfix=Remove leading zero to make decimal convert.octal.literal.to.decimal.literal.quickfix=Convert octal literal to decimal literal -ignore.single.field.static.imports=Ignore single &field static imports -ignore.single.method.static.imports=Ignore single &method static imports +ignore.single.field.static.imports.option=Ignore single &field static imports +ignore.single.method.static.imports.option=Ignore single &method static imports diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/imports/StaticImportInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/imports/StaticImportInspection.java index 2cd3216a05bf..2278b4316a7e 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/imports/StaticImportInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/imports/StaticImportInspection.java @@ -60,10 +60,10 @@ public class StaticImportInspection extends BaseInspection { final MultipleCheckboxOptionsPanel panel = new MultipleCheckboxOptionsPanel(this); panel.addCheckbox(InspectionGadgetsBundle.message( - "ignore.single.field.static.imports"), + "ignore.single.field.static.imports.option"), "ignoreSingleFieldImports"); panel.addCheckbox(InspectionGadgetsBundle.message( - "ignore.single.method.static.imports"), + "ignore.single.method.static.imports.option"), "ignoreSingeMethodImports"); return panel; } From 440183c8e4a75beafdab1a7ec75563cf82c47ec2 Mon Sep 17 00:00:00 2001 From: Oleg Shpynov Date: Mon, 5 Apr 2010 17:25:45 +0400 Subject: [PATCH 09/16] Generalizing --- .../codeInsight/dataflow/DFAEngine.java | 20 +++++++-------- .../codeInsight/dataflow/DfaInstance.java | 4 +-- .../codeInsight/dataflow/Semilattice.java | 6 ++--- .../dataflow/{ => map}/DFAMap.java | 3 ++- .../dataflow/map/DFAMapEngine.java | 25 +++++++++++++++++++ .../dataflow/map/DfaMapInstance.java | 21 ++++++++++++++++ .../dataflow/map/MapSemilattice.java | 22 ++++++++++++++++ 7 files changed, 84 insertions(+), 17 deletions(-) rename platform/lang-impl/src/com/intellij/codeInsight/dataflow/{ => map}/DFAMap.java (97%) create mode 100644 platform/lang-impl/src/com/intellij/codeInsight/dataflow/map/DFAMapEngine.java create mode 100644 platform/lang-impl/src/com/intellij/codeInsight/dataflow/map/DfaMapInstance.java create mode 100644 platform/lang-impl/src/com/intellij/codeInsight/dataflow/map/MapSemilattice.java diff --git a/platform/lang-impl/src/com/intellij/codeInsight/dataflow/DFAEngine.java b/platform/lang-impl/src/com/intellij/codeInsight/dataflow/DFAEngine.java index 65908b8d7466..6967dbfefaca 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/dataflow/DFAEngine.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/dataflow/DFAEngine.java @@ -39,18 +39,18 @@ public class DFAEngine { } - public List> performDFA() { - final ArrayList> info = new ArrayList>(myFlow.length); + public List performDFA() { + final ArrayList info = new ArrayList(myFlow.length); return performDFA(info); } - public List> performDFA(final List> info) { + public List performDFA(final List info) { if (LOG.isDebugEnabled()){ LOG.debug("Perfoming DFA\n" + "Instance: " + myDfa + " Semilattice: " + mySemilattice); } // initializing dfa - final DFAMap initial = myDfa.initial(); + final E initial = myDfa.initial(); for (int i = 0; i < myFlow.length; i++) { info.add(i, initial); } @@ -104,12 +104,12 @@ public class DFAEngine { } final int currentNumber = currentInstruction.num(); - final DFAMap oldE = info.get(currentNumber); - final DFAMap joinedE = join(currentInstruction, info); - final DFAMap newE = myDfa.fun(joinedE, currentInstruction); + final E oldE = info.get(currentNumber); + final E joinedE = join(currentInstruction, info); + final E newE = myDfa.fun(joinedE, currentInstruction); if (!mySemilattice.eq(newE, oldE)) { if (LOG.isDebugEnabled()){ - LOG.debug("Number: " + currentNumber + " old: " + oldE.keySet() + " new: " + newE.keySet()); + LOG.debug("Number: " + currentNumber + " old: " + oldE.toString() + " new: " + newE.toString()); } info.set(currentNumber, newE); for (Instruction next : getNext(currentInstruction)) { @@ -148,9 +148,9 @@ public class DFAEngine { return allPred * 2; } - private DFAMap join(final Instruction instruction, final List> info) { + private E join(final Instruction instruction, final List info) { final Iterable prev = myDfa.isForward() ? instruction.allPred() : instruction.allSucc(); - final ArrayList> prevInfos = new ArrayList>(); + final ArrayList prevInfos = new ArrayList(); for (Instruction i : prev) { prevInfos.add(info.get(i.num())); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/dataflow/DfaInstance.java b/platform/lang-impl/src/com/intellij/codeInsight/dataflow/DfaInstance.java index ce618834fe4b..894e54d0af5b 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/dataflow/DfaInstance.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/dataflow/DfaInstance.java @@ -21,10 +21,10 @@ public interface DfaInstance { // Please ensure that E has correctly implemented equals method // Invariant: fun must create new instance of DFAMap if modifies it - DFAMap fun(DFAMap e, Instruction instruction); + E fun(E e, Instruction instruction); @NotNull - DFAMap initial(); + E initial(); boolean isForward(); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/dataflow/Semilattice.java b/platform/lang-impl/src/com/intellij/codeInsight/dataflow/Semilattice.java index 199ea50bd62d..0b1e89a7eaeb 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/dataflow/Semilattice.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/dataflow/Semilattice.java @@ -17,9 +17,7 @@ package com.intellij.codeInsight.dataflow; import java.util.ArrayList; public interface Semilattice { - // Invariant: join can return unmodified ins(0) or empty DFAMap - // DfaInstance must create new one before modifying - DFAMap join(ArrayList> ins); + E join(ArrayList ins); - boolean eq(DFAMap e1, DFAMap e2); + boolean eq(E e1, E e2); } \ No newline at end of file diff --git a/platform/lang-impl/src/com/intellij/codeInsight/dataflow/DFAMap.java b/platform/lang-impl/src/com/intellij/codeInsight/dataflow/map/DFAMap.java similarity index 97% rename from platform/lang-impl/src/com/intellij/codeInsight/dataflow/DFAMap.java rename to platform/lang-impl/src/com/intellij/codeInsight/dataflow/map/DFAMap.java index 148a5942c3ec..9f7e1078ded4 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/dataflow/DFAMap.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/dataflow/map/DFAMap.java @@ -1,5 +1,6 @@ -package com.intellij.codeInsight.dataflow; +package com.intellij.codeInsight.dataflow.map; +import com.intellij.codeInsight.dataflow.SetUtil; import org.jetbrains.annotations.Nullable; import java.util.*; diff --git a/platform/lang-impl/src/com/intellij/codeInsight/dataflow/map/DFAMapEngine.java b/platform/lang-impl/src/com/intellij/codeInsight/dataflow/map/DFAMapEngine.java new file mode 100644 index 000000000000..d10c588a9bf2 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/codeInsight/dataflow/map/DFAMapEngine.java @@ -0,0 +1,25 @@ +/* + * Copyright 2000-2010 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInsight.dataflow.map; + +import com.intellij.codeInsight.controlflow.Instruction; +import com.intellij.codeInsight.dataflow.DFAEngine; + +public class DFAMapEngine extends DFAEngine>{ + public DFAMapEngine(final Instruction[] flow, final DfaMapInstance dfa, final MapSemilattice dfaMapSemilattice) { + super(flow, dfa, dfaMapSemilattice); + } +} \ No newline at end of file diff --git a/platform/lang-impl/src/com/intellij/codeInsight/dataflow/map/DfaMapInstance.java b/platform/lang-impl/src/com/intellij/codeInsight/dataflow/map/DfaMapInstance.java new file mode 100644 index 000000000000..e6bc73381c10 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/codeInsight/dataflow/map/DfaMapInstance.java @@ -0,0 +1,21 @@ +/* + * Copyright 2000-2010 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInsight.dataflow.map; + +import com.intellij.codeInsight.dataflow.DfaInstance; + +public interface DfaMapInstance extends DfaInstance> { +} \ No newline at end of file diff --git a/platform/lang-impl/src/com/intellij/codeInsight/dataflow/map/MapSemilattice.java b/platform/lang-impl/src/com/intellij/codeInsight/dataflow/map/MapSemilattice.java new file mode 100644 index 000000000000..fb3547b7d698 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/codeInsight/dataflow/map/MapSemilattice.java @@ -0,0 +1,22 @@ +/* + * 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 + * + * 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.codeInsight.dataflow.map; + +import com.intellij.codeInsight.dataflow.Semilattice; + +public interface MapSemilattice extends Semilattice>{ + // Invariant: join can return unmodified ins(0) or empty DFAMap + // DfaInstance must create new one before modifying +} \ No newline at end of file From 992ef7c2165cf2743e08d0c5a728beebd89b97ce Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Mon, 5 Apr 2010 15:26:53 +0200 Subject: [PATCH 10/16] IDEA-53385 ("Non-boolean method name must not start with question" doesn't know Boolean) and added option to ignore Boolean methods again --- .../siyeh/InspectionGadgetsBundle.properties | 1 + ...NameMayNotStartWithQuestionInspection.java | 98 +++++++++++++------ ...onBooleanNameMustNotStartWithQuestion.form | 48 --------- 3 files changed, 67 insertions(+), 80 deletions(-) delete mode 100644 plugins/InspectionGadgets/src/com/siyeh/ig/naming/NonBooleanNameMustNotStartWithQuestion.form diff --git a/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties b/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties index defcc79c8a61..0a2176e0369c 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties +++ b/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties @@ -1763,3 +1763,4 @@ remove.leading.zero.to.make.decimal.quickfix=Remove leading zero to make decimal convert.octal.literal.to.decimal.literal.quickfix=Convert octal literal to decimal literal ignore.single.field.static.imports.option=Ignore single &field static imports ignore.single.method.static.imports.option=Ignore single &method static imports +ignore.methods.with.boolean.return.type.option=ignore methods with Boolean return type diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/NonBooleanMethodNameMayNotStartWithQuestionInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/NonBooleanMethodNameMayNotStartWithQuestionInspection.java index bba21404f217..042aaa2a5894 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/NonBooleanMethodNameMayNotStartWithQuestionInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/NonBooleanMethodNameMayNotStartWithQuestionInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Dave Griffith, Bas Leijdekkers + * Copyright 2003-2010 Dave Griffith, Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,15 +25,17 @@ import com.siyeh.ig.BaseInspectionVisitor; import com.siyeh.ig.InspectionGadgetsFix; import com.siyeh.ig.fixes.RenameFix; import com.siyeh.ig.psiutils.LibraryUtil; -import com.siyeh.ig.ui.AddAction; -import com.siyeh.ig.ui.IGTable; -import com.siyeh.ig.ui.ListWrappingTableModel; -import com.siyeh.ig.ui.RemoveAction; +import com.siyeh.ig.ui.*; import org.jdom.Element; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; -import javax.swing.*; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; import java.util.ArrayList; import java.util.List; @@ -45,47 +47,99 @@ public class NonBooleanMethodNameMayNotStartWithQuestionInspection "is,can,has,should,could,will,shall,check,contains,equals," + "startsWith,endsWith"; + @SuppressWarnings({"PublicField"}) + public boolean ignoreBooleanMethods = true; + List questionList = new ArrayList(32); public NonBooleanMethodNameMayNotStartWithQuestionInspection(){ parseString(questionString, questionList); } + @Override @NotNull public String getDisplayName(){ return InspectionGadgetsBundle.message( "non.boolean.method.name.must.not.start.with.question.display.name"); } + @Override @NotNull public String buildErrorString(Object... infos){ return InspectionGadgetsBundle.message( "non.boolean.method.name.must.not.start.with.question.problem.descriptor"); } + @Override public void readSettings(Element element) throws InvalidDataException{ super.readSettings(element); parseString(questionString, questionList); } + @Override public void writeSettings(Element element) throws WriteExternalException{ questionString = formatString(questionList); super.writeSettings(element); } + @Override public JComponent createOptionsPanel(){ - final Form form = new Form(); - return form.getContentPanel(); + final JPanel panel = new JPanel(new GridBagLayout()); + final IGTable table = + new IGTable(new ListWrappingTableModel(questionList, + InspectionGadgetsBundle.message( + "boolean.method.name.must.start.with.question.table.column.name"))); + final JScrollPane scrollPane = new JScrollPane(table); + + final GridBagConstraints constraints = new GridBagConstraints(); + constraints.gridx = 0; + constraints.gridy = 0; + constraints.gridheight = 3; + constraints.weightx = 1.0; + constraints.weighty = 1.0; + constraints.fill = GridBagConstraints.BOTH; + panel.add(scrollPane, constraints); + + final JButton addButton = new JButton(new AddAction(table)); + constraints.gridx = 1; + constraints.gridheight = 1; + constraints.weightx = 0.0; + constraints.weighty = 0.0; + constraints.fill = GridBagConstraints.HORIZONTAL; + panel.add(addButton, constraints); + + final JButton removeButton = new JButton(new RemoveAction(table)); + constraints.gridy = 1; + panel.add(removeButton, constraints); + + final BlankFiller filler = new BlankFiller(); + constraints.gridy = 2; + constraints.weighty = 1.0; + panel.add(filler, constraints); + + final CheckBox checkBox = + new CheckBox(InspectionGadgetsBundle.message( + "ignore.methods.with.boolean.return.type.option"), + this, "ignoreBooleanMethods"); + constraints.gridy = 3; + constraints.gridx = 0; + constraints.gridwidth = 2; + constraints.weighty = 0.0; + panel.add(checkBox, constraints); + return panel; } + @Override protected InspectionGadgetsFix buildFix(Object... infos){ return new RenameFix(); } + @Override protected boolean buildQuickFixesOnlyForOnTheFlyErrors(){ return true; } + @Override public BaseInspectionVisitor buildVisitor(){ return new NonBooleanMethodNameMayNotStartWithQuestionVisitor(); } @@ -99,6 +153,10 @@ public class NonBooleanMethodNameMayNotStartWithQuestionInspection if(returnType == null || returnType.equals(PsiType.BOOLEAN)){ return; } + if(ignoreBooleanMethods && returnType.equalsToText( + "java.lang.Boolean")){ + return; + } final String name = method.getName(); boolean startsWithQuestionWord = false; for(String question : questionList){ @@ -121,28 +179,4 @@ public class NonBooleanMethodNameMayNotStartWithQuestionInspection registerMethodError(method); } } - - private class Form{ - - JPanel contentPanel; - JButton addButton; - JButton removeButton; - IGTable table; - - Form(){ - super(); - addButton.setAction(new AddAction(table)); - removeButton.setAction(new RemoveAction(table)); - } - - private void createUIComponents(){ - table = new IGTable(new ListWrappingTableModel(questionList, - InspectionGadgetsBundle.message( - "boolean.method.name.must.start.with.question.table.column.name"))); - } - - public JComponent getContentPanel(){ - return contentPanel; - } - } } \ No newline at end of file diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/NonBooleanNameMustNotStartWithQuestion.form b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/NonBooleanNameMustNotStartWithQuestion.form deleted file mode 100644 index 19792463c197..000000000000 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/NonBooleanNameMustNotStartWithQuestion.form +++ /dev/null @@ -1,48 +0,0 @@ - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
From c86899e9da2d16bd1061980cd1a1425f4ca14898 Mon Sep 17 00:00:00 2001 From: peter Date: Mon, 5 Apr 2010 17:50:53 +0400 Subject: [PATCH 11/16] IDEA-53369 Groovy Editor -> Map Keys In Parenthetical Expressions All Considered Identical --- .../groovy/annotator/GroovyAnnotator.java | 49 +++++++------------ .../groovy/lang/GroovyHighlightingTest.java | 2 + .../highlighting/DuplicateMapKeys.groovy | 2 + 3 files changed, 23 insertions(+), 30 deletions(-) create mode 100644 plugins/groovy/testdata/highlighting/DuplicateMapKeys.groovy diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java index d114ec046a7d..601ba52d8a88 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java @@ -33,6 +33,7 @@ import com.intellij.psi.infos.CandidateInfo; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.util.ArrayUtil; import com.intellij.util.IncorrectOperationException; +import com.intellij.util.containers.MultiMap; import gnu.trove.THashSet; import gnu.trove.TObjectHashingStrategy; import org.jetbrains.annotations.NotNull; @@ -365,31 +366,28 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator { @Override public void visitListOrMap(GrListOrMap listOrMap) { - final Map> map = DuplicatesUtil.factorDuplicates(listOrMap.getNamedArguments(), new TObjectHashingStrategy() { - public int computeHashCode(GrNamedArgument arg) { - final GrArgumentLabel label = arg.getLabel(); - if (label == null) return 0; + MultiMap map = new MultiMap(); + + for (GrNamedArgument element : listOrMap.getNamedArguments()) { + final GrArgumentLabel label = element.getLabel(); + if (label != null) { final String name = label.getName(); - if (name == null) return 0; - return name.hashCode(); - } - - public boolean equals(GrNamedArgument arg1, GrNamedArgument arg2) { - final GrArgumentLabel label1 = arg1.getLabel(); - final GrArgumentLabel label2 = arg2.getLabel(); - if (label1 == null || label2 == null) { - return label1 == null && label2 == null; + if (name != null) { + map.putValue(name, element); } - final String name1 = label1.getName(); - final String name2 = label2.getName(); - if (name1 == null || name2 == null) { - return name1 == null && name2 == null; - } - return name1.equals(name2); } - }); + } - processDuplicates(map, myHolder); + for (String key : map.keySet()) { + final Collection arguments = map.get(key); + if (arguments.size() > 1) { + final List args = new ArrayList(arguments); + for (int i = 1; i < args.size(); i++) { + GrNamedArgument namedArgument = args.get(i); + myHolder.createWarningAnnotation(namedArgument.getLabel(), GroovyBundle.message("duplicate.element.in.the.map")); + } + } + } } @Override @@ -734,15 +732,6 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator { } } - protected static void processDuplicates(Map> map, AnnotationHolder holder) { - for (List args : map.values()) { - for (int i = 1; i < args.size(); i++) { - GrNamedArgument namedArgument = args.get(i); - holder.createWarningAnnotation(namedArgument, GroovyBundle.message("duplicate.element.in.the.map")); - } - } - } - private static void registerAbstractMethodFix(Annotation annotation, GrMethod method, boolean makeClassAbstract) { if (method.getBlock() == null) { annotation.registerFix(new AddMethodBodyFix(method)); diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.java index 3cf292ba7117..7083e7fef480 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.java +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.java @@ -224,6 +224,8 @@ public class GroovyHighlightingTest extends LightCodeInsightFixtureTestCase { public void testSuperConstructorInvocation() throws Exception {doTest();} + public void testDuplicateMapKeys() throws Exception {doTest();} + public void testIndexPropertyAccess() throws Exception { doTest(); } diff --git a/plugins/groovy/testdata/highlighting/DuplicateMapKeys.groovy b/plugins/groovy/testdata/highlighting/DuplicateMapKeys.groovy new file mode 100644 index 000000000000..ea162db4a8fa --- /dev/null +++ b/plugins/groovy/testdata/highlighting/DuplicateMapKeys.groovy @@ -0,0 +1,2 @@ +x = [ (person.firstNameKey):person.firstName, (person.lastNameKey):person.lastName ] +x = [2:1, 2:2] \ No newline at end of file From 09eeb6ca0b0ff9de545587e60824c2829acbe64a Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Mon, 5 Apr 2010 14:49:38 +0400 Subject: [PATCH 12/16] Maven: more assertions in test --- .../idea/maven/compiler/ResourceFilteringTest.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ResourceFilteringTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ResourceFilteringTest.java index b74f4ad4e4ca..1ee0218e2355 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ResourceFilteringTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ResourceFilteringTest.java @@ -15,11 +15,14 @@ */ package org.jetbrains.idea.maven.compiler; +import com.intellij.compiler.CompilerConfiguration; import com.intellij.compiler.CompilerManagerImpl; import com.intellij.compiler.CompilerWorkspaceConfiguration; import com.intellij.compiler.impl.ModuleCompileScope; import com.intellij.compiler.impl.TranslatingCompilerFilesMonitor; import com.intellij.openapi.compiler.*; +import com.intellij.openapi.fileTypes.FileTypeManager; +import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.module.Module; import com.intellij.openapi.roots.ProjectRootManager; import com.intellij.openapi.util.io.FileUtil; @@ -824,6 +827,9 @@ public class ResourceFilteringTest extends MavenImportingTestCase { } public void testDoNotFilterButCopyBigFiles() throws Exception { + assertFalse(CompilerConfiguration.getInstance(myProject).isResourceFile("file.xyz")); + assertEquals(FileTypeManager.getInstance().getFileTypeByFileName("file.xyz"), StdFileTypes.UNKNOWN); + createProjectSubFile("resources/file.xyz").setBinaryContent(new byte[1024 * 1024 * 20]); importProject("test" + From 26b1ba726f7abdf3414a9c3e143423fd4d2d9792 Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Mon, 5 Apr 2010 17:11:34 +0400 Subject: [PATCH 13/16] Maven: disabling some buttons for non-maven projects (IDEA-46413) --- .../project/actions/DownloadActionGroup.java | 30 +++++++++++++++++++ .../actions/MavenProjectsManagerAction.java | 5 ++++ .../maven/project/actions/ReimportAction.java | 6 ++++ .../src/main/resources/META-INF/plugin.xml | 3 +- 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/DownloadActionGroup.java diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/DownloadActionGroup.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/DownloadActionGroup.java new file mode 100644 index 000000000000..f4f43364f1ad --- /dev/null +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/DownloadActionGroup.java @@ -0,0 +1,30 @@ +/* + * Copyright 2000-2010 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.maven.project.actions; + +import com.intellij.openapi.actionSystem.ActionGroup; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.DefaultActionGroup; +import org.jetbrains.idea.maven.utils.actions.MavenActionUtil; + +public class DownloadActionGroup extends DefaultActionGroup { + @Override + public void update(AnActionEvent e) { + super.update(e); + if (MavenActionUtil.getProject(e.getDataContext()) == null) return; + e.getPresentation().setEnabled(MavenActionUtil.getProjectsManager(e.getDataContext()).isMavenizedProject()); + } +} diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/MavenProjectsManagerAction.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/MavenProjectsManagerAction.java index 24288ad3ccfb..5626ef504af3 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/MavenProjectsManagerAction.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/MavenProjectsManagerAction.java @@ -26,5 +26,10 @@ public abstract class MavenProjectsManagerAction extends MavenAction { perform(MavenActionUtil.getProjectsManager(e.getDataContext())); } + @Override + protected boolean isAvailable(AnActionEvent e) { + return super.isAvailable(e) && MavenActionUtil.getProjectsManager(e.getDataContext()).isMavenizedProject(); + } + protected abstract void perform(MavenProjectsManager manager); } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/ReimportAction.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/ReimportAction.java index d7c80f0b6a5e..b40c7f0a4ff3 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/ReimportAction.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/ReimportAction.java @@ -15,9 +15,15 @@ */ package org.jetbrains.idea.maven.project.actions; +import com.intellij.openapi.actionSystem.AnActionEvent; import org.jetbrains.idea.maven.project.MavenProjectsManager; public class ReimportAction extends MavenProjectsManagerAction { + @Override + protected boolean isAvailable(AnActionEvent e) { + return true; + } + @Override protected void perform(MavenProjectsManager manager) { manager.forceUpdateAllProjectsOrFindAllAvailablePomFiles(); diff --git a/plugins/maven/src/main/resources/META-INF/plugin.xml b/plugins/maven/src/main/resources/META-INF/plugin.xml index e63770130d0d..34bedb046eae 100644 --- a/plugins/maven/src/main/resources/META-INF/plugin.xml +++ b/plugins/maven/src/main/resources/META-INF/plugin.xml @@ -293,7 +293,8 @@ - + From a349dc35cdc196b8215ccd3a098643fb171051f2 Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Mon, 5 Apr 2010 17:20:47 +0400 Subject: [PATCH 14/16] Maven: do not set 'exported' flag on Maven deps (IDEA-53170) --- .../maven/importing/MavenModuleImporter.java | 5 +- .../importing/MavenRootModelAdapter.java | 5 +- .../project/actions/DownloadActionGroup.java | 2 +- .../idea/maven/MavenImportingTestCase.java | 2 +- .../importing/DependenciesImportingTest.java | 80 +------------------ 5 files changed, 9 insertions(+), 85 deletions(-) diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenModuleImporter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenModuleImporter.java index 61cbe9521080..0161d147559a 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenModuleImporter.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenModuleImporter.java @@ -107,14 +107,13 @@ public class MavenModuleImporter { private void configDependencies() { for (MavenArtifact artifact : myMavenProject.getDependencies()) { - boolean isExportable = artifact.isExportable(); DependencyScope scope = selectScope(artifact.getScope()); MavenProject depProject = myMavenTree.findProject(artifact.getMavenId()); if (depProject != null) { - myRootModelAdapter.addModuleDependency(myMavenProjectToModuleName.get(depProject), isExportable, scope); + myRootModelAdapter.addModuleDependency(myMavenProjectToModuleName.get(depProject), scope); } else if (myMavenProject.isSupportedDependency(artifact)) { - myRootModelAdapter.addLibraryDependency(artifact, isExportable, scope, myModifiableModelsProvider, myMavenProject); + myRootModelAdapter.addLibraryDependency(artifact, scope, myModifiableModelsProvider, myMavenProject); } } } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenRootModelAdapter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenRootModelAdapter.java index 8cb89ef664cb..5ebda0447bf8 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenRootModelAdapter.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenRootModelAdapter.java @@ -194,7 +194,7 @@ public class MavenRootModelAdapter { return new Path(path); } - public void addModuleDependency(String moduleName, boolean isExportable, DependencyScope scope) { + public void addModuleDependency(String moduleName, DependencyScope scope) { Module m = findModuleByName(moduleName); ModuleOrderEntry e; @@ -205,7 +205,6 @@ public class MavenRootModelAdapter { e = myRootModel.addInvalidModuleEntry(moduleName); } - e.setExported(isExportable); e.setScope(scope); } @@ -215,7 +214,6 @@ public class MavenRootModelAdapter { } public void addLibraryDependency(MavenArtifact artifact, - boolean isExportable, DependencyScope scope, MavenModifiableModelsProvider provider, MavenProject project) { @@ -234,7 +232,6 @@ public class MavenRootModelAdapter { } LibraryOrderEntry e = myRootModel.addLibraryEntry(library); - e.setExported(isExportable); e.setScope(scope); } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/DownloadActionGroup.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/DownloadActionGroup.java index f4f43364f1ad..22080c8fe162 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/DownloadActionGroup.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/DownloadActionGroup.java @@ -24,7 +24,7 @@ public class DownloadActionGroup extends DefaultActionGroup { @Override public void update(AnActionEvent e) { super.update(e); - if (MavenActionUtil.getProject(e.getDataContext()) == null) return; + if (MavenActionUtil.getProject(e.getDataContext()) == null) return; // todo: remove this when kirill fixes the problem e.getPresentation().setEnabled(MavenActionUtil.getProjectsManager(e.getDataContext()).isMavenizedProject()); } } diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenImportingTestCase.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenImportingTestCase.java index 2d7316c664b4..e1570464176c 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenImportingTestCase.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenImportingTestCase.java @@ -199,7 +199,7 @@ public abstract class MavenImportingTestCase extends MavenTestCase { assertModuleDeps(moduleName, LibraryOrderEntry.class, expectedDeps); } - protected void assertExportedModuleDeps(String moduleName, String... expectedDeps) { + protected void assertExportedDeps(String moduleName, String... expectedDeps) { final List actual = new ArrayList(); getRootManager(moduleName).processOrder(new RootPolicy() { diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/DependenciesImportingTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/DependenciesImportingTest.java index b4c00b7f36ed..0fa9553d59e7 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/DependenciesImportingTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/DependenciesImportingTest.java @@ -21,7 +21,6 @@ import com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable; import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.roots.libraries.LibraryTable; import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar; -import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.idea.maven.MavenImportingTestCase; @@ -527,30 +526,7 @@ public class DependenciesImportingTest extends MavenImportingTestCase { assertModuleModuleDepScope("m1", "m4", DependencyScope.TEST); } - public void testOptionalLibraryDependencyIsNotExportable() throws Exception { - importProject("test" + - "project" + - "1" + - - "" + - " " + - " group" + - " lib1" + - " 1" + - " " + - " " + - " group" + - " lib2" + - " 1" + - " true" + - " " + - ""); - - assertModules("project"); - assertExportedModuleDeps("project", "Maven: group:lib1:1"); - } - - public void testOptionalModuleDependencyIsNotExportable() throws Exception { + public void testDependenciesAreNotExported() throws Exception { createProjectPom("test" + "project" + "pom" + @@ -572,10 +548,9 @@ public class DependenciesImportingTest extends MavenImportingTestCase { " 1" + " " + " " + - " test" + - " m3" + + " lib" + + " lib" + " 1" + - " true" + " " + ""); @@ -583,55 +558,8 @@ public class DependenciesImportingTest extends MavenImportingTestCase { "m2" + "1"); - createModulePom("m3", "test" + - "m3" + - "1"); - importProject(); - - assertExportedModuleDeps("m1", "m2"); - } - - public void testOnlyCompileAndRuntimeDependenciesAreExported() throws Exception { - importProject("test" + - "project" + - "1" + - - "" + - " " + - " test" + - " compile" + - " compile" + - " 1" + - " " + - " " + - " test" + - " runtime" + - " runtime" + - " 1" + - " " + - " " + - " test" + - " test" + - " test" + - " 1" + - " " + - " " + - " test" + - " provided" + - " provided" + - " 1" + - " " + - " " + - " test" + - " system" + - " system" + - " ${java.home}/lib/tools.jar" + - " 1" + - " " + - ""); - - assertExportedModuleDeps("project", "Maven: test:compile:1", "Maven: test:runtime:1"); + assertExportedDeps("m1"); } public void testTransitiveDependencies() throws Exception { From bdf09134485818ea9a26eaa810844262505f126a Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Mon, 5 Apr 2010 18:18:59 +0400 Subject: [PATCH 15/16] Actions: null project in DataContext when creating toolbars (on behalf of Kirillka) --- .../actionSystem/impl/ActionToolbarImpl.java | 51 ++++++++++--------- .../project/actions/DownloadActionGroup.java | 1 - .../maven/utils/actions/MavenActionGroup.java | 4 +- .../maven/utils/actions/MavenActionUtil.java | 3 +- .../utils/actions/MavenToggleAction.java | 2 +- 5 files changed, 32 insertions(+), 29 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java index 4fa570d010d9..e6a1008a7943 100644 --- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java @@ -36,6 +36,7 @@ import com.intellij.openapi.ui.popup.*; import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.IconLoader; +import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.ui.awt.RelativePoint; import com.intellij.ui.awt.RelativeRectangle; import com.intellij.util.ui.UIUtil; @@ -717,37 +718,41 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar { public void updateActionsImmediately() { ApplicationManager.getApplication().assertIsDispatchThread(); - myNewVisibleActions.clear(); - final DataContext dataContext = getDataContext(); + IdeFocusManager.getInstance(null).doWhenFocusSettlesDown(new Runnable() { + public void run() { + myNewVisibleActions.clear(); + final DataContext dataContext = getDataContext(); - Utils.expandActionGroup(myActionGroup, myNewVisibleActions, myPresentationFactory, dataContext, myPlace, myActionManager); + Utils.expandActionGroup(myActionGroup, myNewVisibleActions, myPresentationFactory, dataContext, myPlace, myActionManager); - if (!myNewVisibleActions.equals(myVisibleActions)) { - // should rebuild UI + if (!myNewVisibleActions.equals(myVisibleActions)) { + // should rebuild UI - final boolean changeBarVisibility = myNewVisibleActions.isEmpty() || myVisibleActions.isEmpty(); + final boolean changeBarVisibility = myNewVisibleActions.isEmpty() || myVisibleActions.isEmpty(); - final ArrayList temp = myVisibleActions; - myVisibleActions = myNewVisibleActions; - myNewVisibleActions = temp; + final ArrayList temp = myVisibleActions; + myVisibleActions = myNewVisibleActions; + myNewVisibleActions = temp; - removeAll(); - mySecondaryActions.removeAll(); - mySecondaryActionsButton = null; - fillToolBar(myVisibleActions, getLayoutPolicy() == AUTO_LAYOUT_POLICY && myOrientation == SwingConstants.HORIZONTAL); + removeAll(); + mySecondaryActions.removeAll(); + mySecondaryActionsButton = null; + fillToolBar(myVisibleActions, getLayoutPolicy() == AUTO_LAYOUT_POLICY && myOrientation == SwingConstants.HORIZONTAL); - if (changeBarVisibility) { - revalidate(); - } - else { - final Container parent = getParent(); - if (parent != null) { - parent.invalidate(); - parent.validate(); + if (changeBarVisibility) { + revalidate(); + } + else { + final Container parent = getParent(); + if (parent != null) { + parent.invalidate(); + parent.validate(); + } + } + repaint(); } } - repaint(); - } + }); } public void setTargetComponent(final JComponent component) { diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/DownloadActionGroup.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/DownloadActionGroup.java index 22080c8fe162..d23364e0df28 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/DownloadActionGroup.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/DownloadActionGroup.java @@ -24,7 +24,6 @@ public class DownloadActionGroup extends DefaultActionGroup { @Override public void update(AnActionEvent e) { super.update(e); - if (MavenActionUtil.getProject(e.getDataContext()) == null) return; // todo: remove this when kirill fixes the problem e.getPresentation().setEnabled(MavenActionUtil.getProjectsManager(e.getDataContext()).isMavenizedProject()); } } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenActionGroup.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenActionGroup.java index 861217b18b3e..999f62d4012d 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenActionGroup.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenActionGroup.java @@ -29,8 +29,6 @@ public class MavenActionGroup extends DefaultActionGroup { } protected boolean isAvailable(AnActionEvent e) { - final DataContext context = e.getDataContext(); - if (MavenActionUtil.getProject(context) == null) return false; - return !MavenActionUtil.getMavenProjects(context).isEmpty(); + return !MavenActionUtil.getMavenProjects(e.getDataContext()).isEmpty(); } } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenActionUtil.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenActionUtil.java index c8554cfcd71c..26114abaefb3 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenActionUtil.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenActionUtil.java @@ -21,6 +21,7 @@ import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.maven.project.MavenProject; import org.jetbrains.idea.maven.project.MavenProjectsManager; @@ -33,7 +34,7 @@ public class MavenActionUtil { private MavenActionUtil() { } - @Nullable + @NotNull public static Project getProject(DataContext context) { return PlatformDataKeys.PROJECT.getData(context); } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenToggleAction.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenToggleAction.java index 46bc9e2bcf10..09ad1d396c53 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenToggleAction.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenToggleAction.java @@ -27,7 +27,7 @@ public abstract class MavenToggleAction extends ToggleAction implements DumbAwar } protected boolean isAvailable(AnActionEvent e) { - return MavenActionUtil.getProject(e.getDataContext()) != null; + return true; } public final boolean isSelected(AnActionEvent e) { From b14939b868fca335ac33b9443272b832d08cc8c9 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Mon, 5 Apr 2010 17:05:28 +0200 Subject: [PATCH 16/16] IDEA-20936 (BooleanMethodDoesNotStartWithQuestionWord: add option for suppressing in @Interface) --- .../siyeh/InspectionGadgetsBundle.properties | 3 +- ...ooleanMethodNameMustStartWithQuestion.form | 49 -------- ...odNameMustStartWithQuestionInspection.java | 119 +++++++++++++----- ...NameMayNotStartWithQuestionInspection.java | 2 +- 4 files changed, 89 insertions(+), 84 deletions(-) delete mode 100644 plugins/InspectionGadgets/src/com/siyeh/ig/naming/BooleanMethodNameMustStartWithQuestion.form diff --git a/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties b/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties index 0a2176e0369c..75ac24687559 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties +++ b/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties @@ -1763,4 +1763,5 @@ remove.leading.zero.to.make.decimal.quickfix=Remove leading zero to make decimal convert.octal.literal.to.decimal.literal.quickfix=Convert octal literal to decimal literal ignore.single.field.static.imports.option=Ignore single &field static imports ignore.single.method.static.imports.option=Ignore single &method static imports -ignore.methods.with.boolean.return.type.option=ignore methods with Boolean return type +ignore.methods.with.boolean.return.type.option=Ignore methods with &Boolean return type +ignore.boolean.methods.in.an.interface.option=Ignore boolean methods in an @&interface diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/BooleanMethodNameMustStartWithQuestion.form b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/BooleanMethodNameMustStartWithQuestion.form deleted file mode 100644 index a17199c50fa3..000000000000 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/BooleanMethodNameMustStartWithQuestion.form +++ /dev/null @@ -1,49 +0,0 @@ - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/BooleanMethodNameMustStartWithQuestionInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/BooleanMethodNameMustStartWithQuestionInspection.java index 96e9adcc2326..e3d223cee746 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/BooleanMethodNameMustStartWithQuestionInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/BooleanMethodNameMustStartWithQuestionInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Dave Griffith, Bas Leijdekkers + * Copyright 2003-2010 Dave Griffith, Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ package com.siyeh.ig.naming; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.WriteExternalException; +import com.intellij.psi.PsiClass; import com.intellij.psi.PsiMethod; import com.intellij.psi.PsiType; import com.siyeh.InspectionGadgetsBundle; @@ -25,21 +26,29 @@ import com.siyeh.ig.BaseInspectionVisitor; import com.siyeh.ig.InspectionGadgetsFix; import com.siyeh.ig.fixes.RenameFix; import com.siyeh.ig.psiutils.LibraryUtil; -import com.siyeh.ig.ui.AddAction; -import com.siyeh.ig.ui.IGTable; -import com.siyeh.ig.ui.ListWrappingTableModel; -import com.siyeh.ig.ui.RemoveAction; +import com.siyeh.ig.ui.*; import org.jdom.Element; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; -import javax.swing.*; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; import java.util.ArrayList; import java.util.List; public class BooleanMethodNameMustStartWithQuestionInspection extends BaseInspection{ + @SuppressWarnings({"PublicField"}) + public boolean ignoreBooleanMethods = false; + + @SuppressWarnings({"PublicField"}) + public boolean ignoreInAnnotationInterface = true; + /** @noinspection PublicField*/ @NonNls public String questionString = "is,can,has,should,could,will,shall,check,contains,equals,add," + @@ -51,41 +60,97 @@ public class BooleanMethodNameMustStartWithQuestionInspection parseString(questionString, questionList); } + @Override @NotNull public String getDisplayName(){ return InspectionGadgetsBundle.message( "boolean.method.name.must.start.with.question.display.name"); } + @Override @NotNull public String buildErrorString(Object... infos){ return InspectionGadgetsBundle.message( "boolean.method.name.must.start.with.question.problem.descriptor"); } + @Override public void readSettings(Element element) throws InvalidDataException{ super.readSettings(element); parseString(questionString, questionList); } + @Override public void writeSettings(Element element) throws WriteExternalException{ questionString = formatString(questionList); super.writeSettings(element); } + @Override public JComponent createOptionsPanel(){ - final Form form = new Form(); - return form.getContentPanel(); + final JPanel panel = new JPanel(new GridBagLayout()); + final IGTable table = + new IGTable(new ListWrappingTableModel(questionList, + InspectionGadgetsBundle.message( + "boolean.method.name.must.start.with.question.table.column.name"))); + final JScrollPane scrollPane = new JScrollPane(table); + + final GridBagConstraints constraints = new GridBagConstraints(); + constraints.gridx = 0; + constraints.gridy = 0; + constraints.gridheight = 3; + constraints.weightx = 1.0; + constraints.weighty = 1.0; + constraints.fill = GridBagConstraints.BOTH; + panel.add(scrollPane, constraints); + + final JButton addButton = new JButton(new AddAction(table)); + constraints.gridx = 1; + constraints.gridheight = 1; + constraints.weightx = 0.0; + constraints.weighty = 0.0; + constraints.fill = GridBagConstraints.HORIZONTAL; + panel.add(addButton, constraints); + + final JButton removeButton = new JButton(new RemoveAction(table)); + constraints.gridy = 1; + panel.add(removeButton, constraints); + + final BlankFiller filler = new BlankFiller(); + constraints.gridy = 2; + constraints.weighty = 1.0; + panel.add(filler, constraints); + + final CheckBox checkBox1 = + new CheckBox(InspectionGadgetsBundle.message( + "ignore.methods.with.boolean.return.type.option"), + this, "ignoreBooleanMethods"); + constraints.gridy = 3; + constraints.gridx = 0; + constraints.gridwidth = 2; + constraints.weighty = 0.0; + panel.add(checkBox1, constraints); + + final CheckBox checkBox2 = + new CheckBox(InspectionGadgetsBundle.message( + "ignore.boolean.methods.in.an.interface.option"), + this, "ignoreInAnnotationInterface"); + constraints.gridy = 4; + panel.add(checkBox2, constraints); + return panel; } + @Override protected InspectionGadgetsFix buildFix(Object... infos){ return new RenameFix(); } + @Override protected boolean buildQuickFixesOnlyForOnTheFlyErrors(){ return true; } + @Override public BaseInspectionVisitor buildVisitor(){ return new BooleanMethodNameMustStartWithQuestionVisitor(); } @@ -95,8 +160,20 @@ public class BooleanMethodNameMustStartWithQuestionInspection @Override public void visitMethod(@NotNull PsiMethod method){ final PsiType returnType = method.getReturnType(); - if(returnType == null || !returnType.equals(PsiType.BOOLEAN)){ + if(returnType == null){ return; + } else if(!returnType.equals(PsiType.BOOLEAN)){ + if (ignoreBooleanMethods || + !returnType.equalsToText("java.lang.Boolean")) { + return; + } + } + if (ignoreInAnnotationInterface) { + final PsiClass containingClass = method.getContainingClass(); + if (containingClass != null && + containingClass.isAnnotationType()) { + return; + } } final String name = method.getName(); for(String question : questionList){ @@ -110,28 +187,4 @@ public class BooleanMethodNameMustStartWithQuestionInspection registerMethodError(method); } } - - private class Form{ - - JPanel contentPanel; - JButton addButton; - JButton removeButton; - IGTable table; - - Form(){ - super(); - addButton.setAction(new AddAction(table)); - removeButton.setAction(new RemoveAction(table)); - } - - private void createUIComponents(){ - table = new IGTable(new ListWrappingTableModel(questionList, - InspectionGadgetsBundle.message( - "boolean.method.name.must.start.with.question.table.column.name"))); - } - - public JComponent getContentPanel(){ - return contentPanel; - } - } } \ No newline at end of file diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/NonBooleanMethodNameMayNotStartWithQuestionInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/NonBooleanMethodNameMayNotStartWithQuestionInspection.java index 042aaa2a5894..99f368ab9a90 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/NonBooleanMethodNameMayNotStartWithQuestionInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/NonBooleanMethodNameMayNotStartWithQuestionInspection.java @@ -48,7 +48,7 @@ public class NonBooleanMethodNameMayNotStartWithQuestionInspection "startsWith,endsWith"; @SuppressWarnings({"PublicField"}) - public boolean ignoreBooleanMethods = true; + public boolean ignoreBooleanMethods = false; List questionList = new ArrayList(32);