summaryrefslogtreecommitdiff
path: root/plugins/groovy
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/groovy')
-rw-r--r--plugins/groovy/groovy-psi/src/resources/groovyInjections.xml9
-rw-r--r--plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/GroovyBuilder.java24
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyDebuggerSettings.java43
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyDebuggerSettingsConfigurable.java97
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyHotSwapConfigurableUi.form (renamed from plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyDebuggerSettingsConfigurable.form)3
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyHotSwapConfigurableUi.java50
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovySteppingConfigurable.java37
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyReferenceCopyPasteProcessor.java2
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/GroovySdkWizardStepBase.java6
-rw-r--r--plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyCompilerTest.groovy43
-rw-r--r--plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyCompilerTestCase.java8
-rw-r--r--plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/optimizeImports/OptimizeImportsTest.groovy3
12 files changed, 165 insertions, 160 deletions
diff --git a/plugins/groovy/groovy-psi/src/resources/groovyInjections.xml b/plugins/groovy/groovy-psi/src/resources/groovyInjections.xml
index dcb426aa135f..910d211476f6 100644
--- a/plugins/groovy/groovy-psi/src/resources/groovyInjections.xml
+++ b/plugins/groovy/groovy-psi/src/resources/groovyInjections.xml
@@ -50,4 +50,13 @@
<display-name>RegExp</display-name>
<place><![CDATA[groovyLiteralExpression().regExpOperatorArgument()]]></place>
</injection>
+ <injection language="encoding-reference" injector-id="java">
+ <display-name>Charset Name</display-name>
+ <place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("getBytes").withParameters("java.lang.String").definedInClass("groovy.lang.GString"))]]></place>
+ <place><![CDATA[psiParameter().ofMethod(1, psiMethod().withName("newPrintWriter").withParameters("java.io.File", "java.lang.String").definedInClass("org.codehaus.groovy.runtime.DefaultGroovyMethods"))]]></place>
+ <place><![CDATA[psiParameter().ofMethod(1, psiMethod().withName("newReader").withParameters("java.io.File", "java.lang.String").definedInClass("org.codehaus.groovy.runtime.DefaultGroovyMethods"))]]></place>
+ <place><![CDATA[psiParameter().ofMethod(1, psiMethod().withName("newReader").withParameters("java.io.InputStream", "java.lang.String").definedInClass("org.codehaus.groovy.runtime.DefaultGroovyMethods"))]]></place>
+ <place><![CDATA[psiParameter().ofMethod(1, psiMethod().withName("newWriter").withParameters("java.io.File", "java.lang.String").definedInClass("org.codehaus.groovy.runtime.DefaultGroovyMethods"))]]></place>
+ <place><![CDATA[psiParameter().ofMethod(1, psiMethod().withName("newWriter").withParameters("java.io.File", "java.lang.String", "boolean").definedInClass("org.codehaus.groovy.runtime.DefaultGroovyMethods"))]]></place>
+ </injection>
</component>
diff --git a/plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/GroovyBuilder.java b/plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/GroovyBuilder.java
index 855deba56575..03e3b544b5ed 100644
--- a/plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/GroovyBuilder.java
+++ b/plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/GroovyBuilder.java
@@ -18,6 +18,7 @@ package org.jetbrains.jps.incremental.groovy;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Key;
+import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
@@ -58,6 +59,8 @@ import org.jetbrains.jps.model.library.sdk.JpsSdk;
import org.jetbrains.jps.service.JpsServiceManager;
import org.jetbrains.jps.service.SharedThreadPool;
import org.jetbrains.org.objectweb.asm.ClassReader;
+import org.jetbrains.org.objectweb.asm.ClassVisitor;
+import org.jetbrains.org.objectweb.asm.Opcodes;
import java.io.File;
import java.io.IOException;
@@ -434,9 +437,14 @@ public class GroovyBuilder extends ModuleLevelBuilder {
final String sourcePath = FileUtil.toSystemIndependentName(item.sourcePath);
final String outputPath = FileUtil.toSystemIndependentName(item.outputPath);
final File outputFile = new File(outputPath);
- outputConsumer.registerOutputFile(target, outputFile, Collections.singleton(sourcePath));
+ final File srcFile = new File(sourcePath);
try {
- callback.associate(outputPath, sourcePath, new ClassReader(FileUtil.loadFileBytes(outputFile)));
+ final byte[] bytes = FileUtil.loadFileBytes(outputFile);
+ outputConsumer.registerCompiledClass(
+ target,
+ new CompiledClass(outputFile, srcFile, readClassName(bytes), new BinaryContent(bytes))
+ );
+ callback.associate(outputPath, sourcePath, new ClassReader(bytes));
}
catch (Throwable e) {
// need this to make sure that unexpected errors in, for example, ASM will not ruin the compilation
@@ -446,7 +454,7 @@ public class GroovyBuilder extends ModuleLevelBuilder {
myBuilderName, BuildMessage.Kind.WARNING, message + "\n" + CompilerMessage.getTextFromThrowable(e), sourcePath)
);
}
- successfullyCompiledFiles.add(new File(sourcePath));
+ successfullyCompiledFiles.add(srcFile);
}
}
}
@@ -454,6 +462,16 @@ public class GroovyBuilder extends ModuleLevelBuilder {
return JavaBuilderUtil.updateMappings(context, delta, dirtyFilesHolder, chunk, toCompile, successfullyCompiledFiles);
}
+ private static String readClassName(byte[] classBytes) throws IOException{
+ final Ref<String> nameRef = Ref.create(null);
+ new ClassReader(classBytes).accept(new ClassVisitor(Opcodes.ASM5) {
+ public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
+ nameRef.set(name.replace('/', '.'));
+ }
+ }, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
+ return nameRef.get();
+ }
+
private static Collection<String> generateClasspath(CompileContext context, ModuleChunk chunk) {
final Set<String> cp = new LinkedHashSet<String>();
//groovy_rt.jar
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyDebuggerSettings.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyDebuggerSettings.java
index 273fd4cb8531..c2538426a871 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyDebuggerSettings.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyDebuggerSettings.java
@@ -19,23 +19,31 @@ import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.openapi.components.StoragePathMacros;
import com.intellij.openapi.options.Configurable;
+import com.intellij.openapi.options.SimpleConfigurable;
+import com.intellij.openapi.util.Getter;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.util.xmlb.XmlSerializerUtil;
+import com.intellij.xdebugger.settings.DebuggerSettingsCategory;
import com.intellij.xdebugger.settings.XDebuggerSettings;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.groovy.GroovyBundle;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import static java.util.Collections.singletonList;
/**
* @author ilyas
*/
@State(
- name = "GroovyDebuggerSettings",
- storages = {
+ name = "GroovyDebuggerSettings",
+ storages = {
@Storage(
- file = StoragePathMacros.APP_CONFIG + "/groovy_debug.xml"
+ file = StoragePathMacros.APP_CONFIG + "/groovy_debug.xml"
)}
)
-public class GroovyDebuggerSettings extends XDebuggerSettings<GroovyDebuggerSettings> {
+public class GroovyDebuggerSettings extends XDebuggerSettings<GroovyDebuggerSettings> implements Getter<GroovyDebuggerSettings> {
public Boolean DEBUG_DISABLE_SPECIFIC_GROOVY_METHODS = true;
public boolean ENABLE_GROOVY_HOTSWAP = Registry.is("enable.groovy.hotswap");
@@ -43,19 +51,19 @@ public class GroovyDebuggerSettings extends XDebuggerSettings<GroovyDebuggerSett
super("groovy_debugger");
}
- @Override
@NotNull
- public Configurable createConfigurable() {
- return new GroovyDebuggerSettingsConfigurable(this);
- }
-
- @Nullable
+ @SuppressWarnings("EnumSwitchStatementWhichMissesCases")
@Override
- public Configurable createConfigurable(@NotNull Category category) {
- if (category == Category.STEPPING) {
- return new GroovySteppingConfigurable();
+ public Collection<? extends Configurable> createConfigurables(@NotNull DebuggerSettingsCategory category) {
+ switch (category) {
+ case STEPPING:
+ return singletonList(SimpleConfigurable.create("reference.idesettings.debugger.groovy", GroovyBundle.message("groovy.debug.caption"),
+ "reference.idesettings.debugger.groovy", GroovySteppingConfigurableUi.class, this));
+ case HOTSWAP:
+ return singletonList(SimpleConfigurable.create("reference.idesettings.debugger.groovy", GroovyBundle.message("groovy.debug.caption"),
+ "reference.idesettings.debugger.groovy", GroovyHotSwapConfigurableUi.class, this));
}
- return null;
+ return Collections.emptyList();
}
@Override
@@ -71,4 +79,9 @@ public class GroovyDebuggerSettings extends XDebuggerSettings<GroovyDebuggerSett
public static GroovyDebuggerSettings getInstance() {
return getInstance(GroovyDebuggerSettings.class);
}
+
+ @Override
+ public GroovyDebuggerSettings get() {
+ return this;
+ }
} \ No newline at end of file
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyDebuggerSettingsConfigurable.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyDebuggerSettingsConfigurable.java
deleted file mode 100644
index 8f143d9a5fd1..000000000000
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyDebuggerSettingsConfigurable.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright 2000-2014 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jetbrains.plugins.groovy.debugger;
-
-import com.intellij.openapi.options.ConfigurationException;
-import com.intellij.openapi.options.SearchableConfigurable;
-import org.jetbrains.annotations.Nls;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.plugins.groovy.GroovyBundle;
-
-import javax.swing.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-/**
- * @author ilyas
- */
-public class GroovyDebuggerSettingsConfigurable implements SearchableConfigurable {
- private JPanel myPanel;
- private JCheckBox myEnableHotSwap;
- private boolean isModified = false;
- private final GroovyDebuggerSettings mySettings;
-
- public GroovyDebuggerSettingsConfigurable(final GroovyDebuggerSettings settings) {
- mySettings = settings;
-
- myEnableHotSwap.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(final ActionEvent e) {
- isModified = mySettings.ENABLE_GROOVY_HOTSWAP != myEnableHotSwap.isSelected();
- }
- });
- }
-
- @Override
- @Nls
- public String getDisplayName() {
- return GroovyBundle.message("groovy.debug.caption");
- }
-
- @Override
- @NotNull
- public String getHelpTopic() {
- return "reference.idesettings.debugger.groovy";
- }
-
- @Override
- @NotNull
- public String getId() {
- return getHelpTopic();
- }
-
- @Override
- public Runnable enableSearch(String option) {
- return null;
- }
-
- @Override
- public JComponent createComponent() {
- return myPanel;
- }
-
- @Override
- public boolean isModified() {
- return isModified;
- }
-
- @Override
- public void apply() throws ConfigurationException {
- if (isModified) {
- mySettings.ENABLE_GROOVY_HOTSWAP = myEnableHotSwap.isSelected();
- }
- isModified = false;
- }
-
- @Override
- public void reset() {
- myEnableHotSwap.setSelected(mySettings.ENABLE_GROOVY_HOTSWAP);
- }
-
- @Override
- public void disposeUIResources() {
- }
-}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyDebuggerSettingsConfigurable.form b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyHotSwapConfigurableUi.form
index 171170b00571..cbe2154a9d31 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyDebuggerSettingsConfigurable.form
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyHotSwapConfigurableUi.form
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.plugins.groovy.debugger.GroovyDebuggerSettingsConfigurable">
+<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.plugins.groovy.debugger.GroovyHotSwapConfigurableUi">
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
@@ -19,6 +19,7 @@
</constraints>
<properties>
<componentStyle value="SMALL"/>
+ <fontColor value="BRIGHTER"/>
<text value="May cause serialization issues in the debugged application"/>
</properties>
</component>
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyHotSwapConfigurableUi.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyHotSwapConfigurableUi.java
new file mode 100644
index 000000000000..400d344bb156
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyHotSwapConfigurableUi.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.debugger;
+
+import com.intellij.openapi.options.ConfigurableUi;
+import org.jetbrains.annotations.NotNull;
+
+import javax.swing.*;
+
+/**
+ * @author ilyas
+ */
+class GroovyHotSwapConfigurableUi implements ConfigurableUi<GroovyDebuggerSettings> {
+ private JPanel myPanel;
+ private JCheckBox myEnableHotSwap;
+
+ @NotNull
+ @Override
+ public JComponent getComponent() {
+ return myPanel;
+ }
+
+ @Override
+ public boolean isModified(@NotNull GroovyDebuggerSettings settings) {
+ return settings.ENABLE_GROOVY_HOTSWAP != myEnableHotSwap.isSelected();
+ }
+
+ @Override
+ public void apply(@NotNull GroovyDebuggerSettings settings) {
+ settings.ENABLE_GROOVY_HOTSWAP = myEnableHotSwap.isSelected();
+ }
+
+ @Override
+ public void reset(@NotNull GroovyDebuggerSettings settings) {
+ myEnableHotSwap.setSelected(settings.ENABLE_GROOVY_HOTSWAP);
+ }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovySteppingConfigurable.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovySteppingConfigurable.java
deleted file mode 100644
index 0e5d99552d47..000000000000
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovySteppingConfigurable.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package org.jetbrains.plugins.groovy.debugger;
-
-import com.intellij.openapi.options.ConfigurableBase;
-import org.jetbrains.annotations.Nls;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.jetbrains.plugins.groovy.GroovyBundle;
-
-class GroovySteppingConfigurable extends ConfigurableBase<GroovySteppingConfigurableUi, GroovyDebuggerSettings> {
- @Override
- protected GroovyDebuggerSettings getSettings() {
- return GroovyDebuggerSettings.getInstance();
- }
-
- @Override
- protected GroovySteppingConfigurableUi createUi() {
- return new GroovySteppingConfigurableUi();
- }
-
- @NotNull
- @Override
- public String getId() {
- return "debugger.stepping.groovy";
- }
-
- @Nls
- @Override
- public String getDisplayName() {
- return GroovyBundle.message("groovy.debug.caption");
- }
-
- @Nullable
- @Override
- public String getHelpTopic() {
- return "reference.idesettings.debugger.groovy";
- }
-} \ No newline at end of file
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyReferenceCopyPasteProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyReferenceCopyPasteProcessor.java
index 63784b58f298..d4b67e1540bf 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyReferenceCopyPasteProcessor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyReferenceCopyPasteProcessor.java
@@ -97,7 +97,7 @@ public class GroovyReferenceCopyPasteProcessor extends CopyPasteReferenceProcess
}
else {
if (reference instanceof GrReferenceExpression) {
- PsiElement referent = reference.resolve();
+ PsiElement referent = resolveReferenceIgnoreOverriding(reference);
if (!(referent instanceof PsiNamedElement)
|| !data.staticMemberName.equals(((PsiNamedElement)referent).getName())
|| !(referent instanceof PsiMember)
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/GroovySdkWizardStepBase.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/GroovySdkWizardStepBase.java
index 84b96c39fd78..19649574c2bc 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/GroovySdkWizardStepBase.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/GroovySdkWizardStepBase.java
@@ -23,7 +23,6 @@ import com.intellij.ide.util.projectWizard.ModuleWizardStep;
import com.intellij.ide.util.projectWizard.WizardContext;
import com.intellij.ide.wizard.CommitStepException;
import com.intellij.openapi.module.Module;
-import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer;
@@ -51,8 +50,9 @@ public abstract class GroovySdkWizardStepBase extends ModuleWizardStep {
public GroovySdkWizardStepBase(@Nullable final MvcFramework framework, WizardContext wizardContext, String basePath) {
myBasePath = basePath;
- final Project project = wizardContext.getProject();
- myLibrariesContainer = LibrariesContainerFactory.createContainer(project);
+ myLibrariesContainer = wizardContext.getModulesProvider() == null
+ ? LibrariesContainerFactory.createContainer(wizardContext.getProject())
+ : LibrariesContainerFactory.createContainer(wizardContext, wizardContext.getModulesProvider());
myFramework = framework;
}
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyCompilerTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyCompilerTest.groovy
index 2b5933fb4d31..d6363fb560db 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyCompilerTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyCompilerTest.groovy
@@ -18,16 +18,28 @@ package org.jetbrains.plugins.groovy.compiler
import com.intellij.compiler.CompilerConfiguration
import com.intellij.compiler.CompilerConfigurationImpl
+import com.intellij.execution.executors.DefaultRunExecutor
+import com.intellij.execution.impl.DefaultJavaProgramRunner
+import com.intellij.execution.process.ProcessAdapter
+import com.intellij.execution.process.ProcessEvent
+import com.intellij.execution.process.ProcessHandler
+import com.intellij.execution.process.ProcessOutputTypes
+import com.intellij.execution.runners.ProgramRunner
import com.intellij.openapi.application.ApplicationManager
+import com.intellij.openapi.application.PathManager
import com.intellij.openapi.compiler.CompilerMessage
import com.intellij.openapi.compiler.CompilerMessageCategory
import com.intellij.openapi.compiler.options.ExcludeEntryDescription
import com.intellij.openapi.compiler.options.ExcludedEntriesConfiguration
import com.intellij.openapi.module.Module
import com.intellij.openapi.roots.ModuleRootModificationUtil
+import com.intellij.openapi.util.Key
+import com.intellij.openapi.util.Ref
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.PsiFile
+import com.intellij.testFramework.PsiTestUtil
import com.intellij.testFramework.TestLoggerFactory
+import org.jetbrains.annotations.NotNull
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile
/**
@@ -822,4 +834,35 @@ class AppTest {
def messages = make()
assert messages.find { it.message.contains("Cannot compile Groovy files: no Groovy library is defined for module 'dependent'") }
}
+
+ public void testGroovyOutputIsInstrumented() {
+ myFixture.addFileToProject("Bar.groovy",
+ "import org.jetbrains.annotations.NotNull; " +
+ "public class Bar {" +
+ "void xxx(@NotNull String param) { println param }\n" +
+ "static void main(String[] args) { new Bar().xxx(null) }"+
+ "}"
+ );
+
+ File annotations = new File(PathManager.getJarPathForClass(NotNull.class));
+ PsiTestUtil.addLibrary(myModule, "annotations", annotations.getParent(), annotations.getName());
+
+ assertEmpty(make());
+
+ final Ref<Boolean> exceptionFound = Ref.create(Boolean.FALSE);
+ ProcessHandler process = runProcess("Bar", myModule, DefaultRunExecutor.class, new ProcessAdapter() {
+ @Override
+ public void onTextAvailable(ProcessEvent event, Key outputType) {
+ if (ProcessOutputTypes.SYSTEM != outputType) {
+ if (!exceptionFound.get()) {
+ exceptionFound.set(event.getText().contains("java.lang.IllegalArgumentException: Argument for @NotNull parameter 'param' of Bar.xxx must not be null"));
+ }
+ }
+ }
+ }, ProgramRunner.PROGRAM_RUNNER_EP.findExtension(DefaultJavaProgramRunner.class));
+ process.waitFor();
+
+ assertTrue(exceptionFound.get());
+ }
+
}
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyCompilerTestCase.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyCompilerTestCase.java
index 7cbf9a9d665b..28b2e26949ad 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyCompilerTestCase.java
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyCompilerTestCase.java
@@ -44,6 +44,7 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.intellij.testFramework.CompilerTester;
import com.intellij.testFramework.IdeaTestUtil;
+import com.intellij.testFramework.PlatformTestUtil;
import com.intellij.testFramework.PsiTestUtil;
import com.intellij.testFramework.builders.JavaModuleFixtureBuilder;
import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase;
@@ -80,6 +81,13 @@ public abstract class GroovyCompilerTestCase extends JavaCodeInsightFixtureTestC
super.tuneFixture(moduleBuilder);
}
+ @Override
+ protected void runTest() throws Throwable {
+ if (PlatformTestUtil.COVERAGE_ENABLED_BUILD) return;
+
+ super.runTest();
+ }
+
protected static void addGroovyLibrary(final Module to) {
File jar = GroovyFacetUtil.getBundledGroovyJar();
PsiTestUtil.addLibrary(to, "groovy", jar.getParent(), jar.getName());
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/optimizeImports/OptimizeImportsTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/optimizeImports/OptimizeImportsTest.groovy
index 223927107763..ce323a17d5d9 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/optimizeImports/OptimizeImportsTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/optimizeImports/OptimizeImportsTest.groovy
@@ -15,11 +15,9 @@
*/
package org.jetbrains.plugins.groovy.refactoring.optimizeImports
-
import com.intellij.codeInsight.CodeInsightSettings
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.command.CommandProcessor
-import com.intellij.openapi.fileEditor.impl.TrailingSpacesStripper
import com.intellij.psi.codeStyle.CodeStyleSettings
import com.intellij.psi.codeStyle.CodeStyleSettingsManager
import com.intellij.psi.impl.source.PostprocessReformattingAspect
@@ -195,7 +193,6 @@ class Fooxx <caret>{
doOptimizeImports();
PostprocessReformattingAspect.getInstance(getProject()).doPostponedFormatting();
- TrailingSpacesStripper.stripIfNotCurrentLine(myFixture.getEditor().getDocument(), false);
myFixture.checkResultByFile(getTestName(false) + "_after.groovy");
}
finally {