Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static EvaluateException createEvaluateException(String reason) {
private static LocalizeValue reason(Throwable th) {
if (th instanceof InvalidTypeException) {
String originalReason = th.getMessage();
return LocalizeValue.join(JavaDebuggerLocalize.evaluationErrorTypeMismatch(), LocalizeValue.ofNullable(originalReason));
return LocalizeValue.join(JavaDebuggerLocalize.evaluationErrorTypeMismatch(), LocalizeValue.space(), LocalizeValue.ofNullable(originalReason));
}
else if (th instanceof AbsentInformationException) {
return JavaDebuggerLocalize.evaluationErrorDebugInfoUnavailable();
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import com.intellij.java.language.psi.JavaPsiFacade;
import com.intellij.java.language.psi.PsiJavaPackage;
import consulo.application.Application;
import consulo.component.extension.Extensions;
import consulo.component.macro.PathMacroUtil;
import consulo.content.bundle.Sdk;
import consulo.disposer.Disposer;
Expand Down Expand Up @@ -162,14 +161,14 @@ protected GeneralCommandLine createCommandLine() throws ExecutionException {
@Nonnull
@Override
public ExecutionResult execute(@Nonnull Executor executor, @Nonnull ProgramRunner runner) throws ExecutionException {
final RunnerSettings runnerSettings = getRunnerSettings();
RunnerSettings runnerSettings = getRunnerSettings();

final SMTRunnerConsoleProperties testConsoleProperties = getConfiguration().createTestConsoleProperties(executor);
SMTRunnerConsoleProperties testConsoleProperties = getConfiguration().createTestConsoleProperties(executor);
testConsoleProperties.setIdBasedTestTree(isIdBasedTestTree());
testConsoleProperties.setIfUndefined(TestConsoleProperties.HIDE_PASSED_TESTS, false);

final BaseTestsOutputConsoleView consoleView = SMTestRunnerConnectionUtil.createConsole(getFrameworkName(), testConsoleProperties);
final SMTestRunnerResultsForm viewer = ((SMTRunnerConsoleView)consoleView).getResultsViewer();
BaseTestsOutputConsoleView consoleView = SMTestRunnerConnectionUtil.createConsole(getFrameworkName(), testConsoleProperties);
SMTestRunnerResultsForm viewer = ((SMTRunnerConsoleView)consoleView).getResultsViewer();
Disposer.register(getConfiguration().getProject(), consoleView);

final ProcessHandler handler = createHandler(executor);
Expand All @@ -187,7 +186,7 @@ public ExecutionResult execute(@Nonnull Executor executor, @Nonnull ProgramRunne
@Override
public void startNotified(@Nonnull ProcessEvent event) {
if (getConfiguration().isSaveOutputToFile()) {
final File file = OutputFileUtil.getOutputFile(getConfiguration());
File file = OutputFileUtil.getOutputFile(getConfiguration());
root.setOutputFilePath(file != null ? file.getAbsolutePath() : null);
}
}
Expand All @@ -209,7 +208,7 @@ public void processTerminated(@Nonnull ProcessEvent event) {
LOG.assertTrue(rerunFailedTestsAction != null);
rerunFailedTestsAction.setModelProvider(() -> viewer);

final DefaultExecutionResult result = new DefaultExecutionResult(consoleView, handler);
DefaultExecutionResult result = new DefaultExecutionResult(consoleView, handler);
result.setRestartActions(rerunFailedTestsAction, new ToggleAutoTestAction() {
@Override
public boolean isDelayApplicable() {
Expand All @@ -230,14 +229,14 @@ public AbstractAutoTestManager getAutoTestManager(Project project) {

@Override
protected OwnJavaParameters createJavaParameters() throws ExecutionException {
final OwnJavaParameters javaParameters = new OwnJavaParameters();
OwnJavaParameters javaParameters = new OwnJavaParameters();
Project project = getConfiguration().getProject();
final Module module = getConfiguration().getConfigurationModule().getModule();
Module module = getConfiguration().getConfigurationModule().getModule();

Sdk jdk = module == null ? null : ModuleUtilCore.getSdk(module, JavaModuleExtension.class);
javaParameters.setJdk(jdk);

final String parameters = getConfiguration().getProgramParameters();
String parameters = getConfiguration().getProgramParameters();
getConfiguration().setProgramParameters(null);
try {
JavaParametersUtil.configureConfiguration(javaParameters, getConfiguration());
Expand All @@ -248,7 +247,7 @@ protected OwnJavaParameters createJavaParameters() throws ExecutionException {
javaParameters.getClassPath().addFirst(JavaSdkUtil.getJavaRtJarPath());
configureClasspath(javaParameters);

final JavaTestPatcher[] patchers = JavaTestPatcher.EP_NAME.getExtensions();
JavaTestPatcher[] patchers = JavaTestPatcher.EP_NAME.getExtensions();
for (JavaTestPatcher patcher : patchers) {
patcher.patchJavaParameters(module, javaParameters);
}
Expand Down Expand Up @@ -291,37 +290,41 @@ public ServerSocket getForkSocket() {
}

private boolean isExecutorDisabledInForkedMode() {
final RunnerSettings settings = getRunnerSettings();
RunnerSettings settings = getRunnerSettings();
return settings != null && !(settings instanceof GenericDebuggerRunnerSettings);
}

protected void appendForkInfo(Executor executor) throws ExecutionException {
final String forkMode = getForkMode();
String forkMode = getForkMode();
if (Comparing.strEqual(forkMode, "none")) {
if (forkPerModule()) {
if (isExecutorDisabledInForkedMode()) {
final String actionName = executor.getStartActionText().map(Presentation.NO_MNEMONIC).get();
throw new CantRunException("'" + actionName + "' is disabled when per-module working directory is configured.<br/>" + "Please specify single working directory, or change test " +
"scope to single module.");
String actionName = executor.getStartActionText().map(Presentation.NO_MNEMONIC).get();
throw new CantRunException(
"'" + actionName + "' is disabled when per-module working directory is configured.<br/>" +
"Please specify single working directory, or change test scope to single module."
);
}
}
else {
return;
}
}
else if (isExecutorDisabledInForkedMode()) {
final String actionName = executor.getStartActionText().toLowerCase().map(Presentation.NO_MNEMONIC).get();
throw new CantRunException(actionName + " is disabled in fork mode.<br/>Please change fork mode to &lt;none&gt; to " + actionName + ".");
String actionName = executor.getStartActionText().toLowerCase().map(Presentation.NO_MNEMONIC).get();
throw new CantRunException(
actionName + " is disabled in fork mode.<br/>Please change fork mode to &lt;none&gt; to " + actionName + "."
);
}

final OwnJavaParameters javaParameters = getJavaParameters();
final Sdk jdk = javaParameters.getJdk();
OwnJavaParameters javaParameters = getJavaParameters();
Sdk jdk = javaParameters.getJdk();
if (jdk == null) {
throw new ExecutionException(ExecutionLocalize.runConfigurationErrorNoJdkSpecified().get());
}

try {
final File tempFile = FileUtil.createTempFile("command.line", "", true);
File tempFile = FileUtil.createTempFile("command.line", "", true);
try (PrintWriter writer = new PrintWriter(tempFile, CharsetToolkit.UTF8)) {
if (forkPerModule()) {
writer.println("use classpath jar");
Expand Down Expand Up @@ -354,11 +357,11 @@ else if (isExecutorDisabledInForkedMode()) {
protected abstract void passForkMode(String forkMode, File tempFile, OwnJavaParameters parameters) throws ExecutionException;

protected void collectListeners(OwnJavaParameters javaParameters, StringBuilder buf, Class epName, String delimiter) {
final T configuration = getConfiguration();
final Object[] listeners = Application.get().getExtensionPoint(epName).getExtensions();
for (final Object listener : listeners) {
T configuration = getConfiguration();
Object[] listeners = Application.get().getExtensionPoint(epName).getExtensions();
for (Object listener : listeners) {
boolean enabled = true;
for (RunConfigurationExtension ext : Extensions.getExtensions(RunConfigurationExtension.EP_NAME)) {
for (RunConfigurationExtension ext : RunConfigurationExtension.EP_NAME.getExtensions()) {
if (ext.isListenerDisabled(configuration, listener, getRunnerSettings())) {
enabled = false;
break;
Expand All @@ -368,19 +371,19 @@ protected void collectListeners(OwnJavaParameters javaParameters, StringBuilder
if (buf.length() > 0) {
buf.append(delimiter);
}
final Class classListener = listener.getClass();
Class classListener = listener.getClass();
buf.append(classListener.getName());
javaParameters.getClassPath().add(ClassPathUtil.getJarPathForClass(classListener));
}
}
}

protected void configureClasspath(final OwnJavaParameters javaParameters) throws CantRunException {
protected void configureClasspath(OwnJavaParameters javaParameters) throws CantRunException {
configureRTClasspath(javaParameters);
RunConfigurationModule module = getConfiguration().getConfigurationModule();
final String alternativeJreName =
String alternativeJreName =
getConfiguration().isAlternativeJrePathEnabled() ? getConfiguration().getAlternativeJrePath() : null;
final int pathType = OwnJavaParameters.JDK_AND_CLASSES_AND_TESTS;
int pathType = OwnJavaParameters.JDK_AND_CLASSES_AND_TESTS;
if (configureByModule(module.getModule())) {
JavaParametersUtil.configureModule(module, javaParameters, pathType, alternativeJreName);
}
Expand All @@ -399,18 +402,18 @@ protected void createServerSocket(OwnJavaParameters javaParameters) {
}
}

protected boolean spansMultipleModules(final String qualifiedName) {
protected boolean spansMultipleModules(String qualifiedName) {
if (qualifiedName != null) {
final Project project = getConfiguration().getProject();
final PsiJavaPackage aPackage = JavaPsiFacade.getInstance(project).findPackage(qualifiedName);
Project project = getConfiguration().getProject();
PsiJavaPackage aPackage = JavaPsiFacade.getInstance(project).findPackage(qualifiedName);
if (aPackage != null) {
final TestSearchScope scope = getScope();
TestSearchScope scope = getScope();
if (scope != null) {
final SourceScope sourceScope = scope.getSourceScope(getConfiguration());
SourceScope sourceScope = scope.getSourceScope(getConfiguration());
if (sourceScope != null) {
final GlobalSearchScope configurationSearchScope =
GlobalSearchScope configurationSearchScope =
GlobalSearchScopesCore.projectTestScope(project).intersectWith(sourceScope.getGlobalSearchScope());
final PsiDirectory[] directories = aPackage.getDirectories(configurationSearchScope);
PsiDirectory[] directories = aPackage.getDirectories(configurationSearchScope);
return Arrays.stream(directories)
.map(dir -> ModuleUtilCore.findModuleForFile(dir.getVirtualFile(), project))
.filter(Objects::nonNull)
Expand All @@ -427,9 +430,10 @@ protected boolean spansMultipleModules(final String qualifiedName) {
* Configuration based on package which spans multiple modules
*/
protected boolean forkPerModule() {
final String workingDirectory = getConfiguration().getWorkingDirectory();
return getScope() != TestSearchScope.SINGLE_MODULE && ("$" + PathMacroUtil.MODULE_DIR_MACRO_NAME + "$").equals(workingDirectory) && spansMultipleModules(
getConfiguration().getPackage());
String workingDirectory = getConfiguration().getWorkingDirectory();
return getScope() != TestSearchScope.SINGLE_MODULE
&& ("$" + PathMacroUtil.MODULE_DIR_MACRO_NAME + "$").equals(workingDirectory)
&& spansMultipleModules(getConfiguration().getPackage());
}

protected void createTempFiles(OwnJavaParameters javaParameters) {
Expand All @@ -445,13 +449,10 @@ protected void createTempFiles(OwnJavaParameters javaParameters) {
}
}

protected void writeClassesPerModule(
String packageName,
OwnJavaParameters javaParameters,
Map<Module, List<String>> perModule
) throws FileNotFoundException, UnsupportedEncodingException, CantRunException {
protected void writeClassesPerModule(String packageName, OwnJavaParameters javaParameters, Map<Module, List<String>> perModule)
throws FileNotFoundException, UnsupportedEncodingException, CantRunException {
if (perModule != null) {
final String classpath = getScope() == TestSearchScope.WHOLE_PROJECT ? null : javaParameters.getClassPath().getPathsString();
String classpath = getScope() == TestSearchScope.WHOLE_PROJECT ? null : javaParameters.getClassPath().getPathsString();

try (PrintWriter wWriter = new PrintWriter(myWorkingDirsFile, CharsetToolkit.UTF8)) {
wWriter.println(packageName);
Expand All @@ -460,7 +461,7 @@ protected void writeClassesPerModule(
wWriter.println(module.getName());

if (classpath == null) {
final OwnJavaParameters parameters = new OwnJavaParameters();
OwnJavaParameters parameters = new OwnJavaParameters();
parameters.getClassPath().add(JavaSdkUtil.getJavaRtJarPath());
configureRTClasspath(parameters);
JavaParametersUtil.configureModule(
Expand All @@ -476,7 +477,7 @@ protected void writeClassesPerModule(
wWriter.println(classpath);
}

final List<String> classNames = perModule.get(module);
List<String> classNames = perModule.get(module);
wWriter.println(classNames.size());
for (String className : classNames) {
wWriter.println(className);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* Created by IntelliJ IDEA.
* User: yole
* Date: 31.01.2007
* Time: 13:56:12
*/
package com.intellij.java.execution.impl;

import consulo.annotation.component.ComponentScope;
import consulo.annotation.component.ExtensionAPI;
import consulo.component.extension.ExtensionPointName;
import consulo.component.extension.Extensions;
import consulo.execution.configuration.RunConfigurationBase;
import consulo.execution.configuration.RunConfigurationExtensionBase;
import consulo.execution.configuration.RunnerSettings;
Expand All @@ -38,13 +30,17 @@

import jakarta.annotation.Nullable;

/*
* @author yole
* @since 2007-01-31
*/
@ExtensionAPI(ComponentScope.APPLICATION)
public abstract class RunConfigurationExtension extends RunConfigurationExtensionBase<RunConfigurationBase> {
public static final ExtensionPointName<RunConfigurationExtension> EP_NAME = ExtensionPointName.create(RunConfigurationExtension.class);

public abstract <T extends RunConfigurationBase> void updateJavaParameters(
final T configuration,
final OwnJavaParameters params,
T configuration,
OwnJavaParameters params,
RunnerSettings runnerSettings
) throws ExecutionException;

Expand Down Expand Up @@ -88,7 +84,7 @@ public static RefactoringElementListener wrapRefactoringElementListener(
RunConfigurationBase runConfigurationBase,
RefactoringElementListener listener
) {
for (RunConfigurationExtension extension : Extensions.getExtensions(EP_NAME)) {
for (RunConfigurationExtension extension : EP_NAME.getExtensions()) {
listener = extension.wrapElementListener(element, runConfigurationBase, listener);
}
return listener;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
public abstract class BaseJavaApplicationCommandLineState<T extends RunConfigurationBase & CommonJavaRunConfigurationParameters> extends JavaCommandLineState {
protected final T myConfiguration;

public BaseJavaApplicationCommandLineState(ExecutionEnvironment environment, @Nonnull final T configuration) {
public BaseJavaApplicationCommandLineState(ExecutionEnvironment environment, @Nonnull T configuration) {
super(environment);
myConfiguration = configuration;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
public interface CustomPropertyScopeProvider {
ExtensionPointName<CustomPropertyScopeProvider> EP_NAME = ExtensionPointName.create(CustomPropertyScopeProvider.class);

SearchScope getScope(final Project project);
SearchScope getScope(Project project);
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
public interface JavaMainMethodProvider {
ExtensionPointName<JavaMainMethodProvider> EP_NAME = ExtensionPointName.create(JavaMainMethodProvider.class);

boolean isApplicable(final PsiClass clazz);
boolean isApplicable(PsiClass clazz);

boolean hasMainMethod(final PsiClass clazz);
boolean hasMainMethod(PsiClass clazz);

PsiMethod findMainInClass(final PsiClass clazz);
PsiMethod findMainInClass(PsiClass clazz);
}
Loading
Loading