mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
execution-openapi
This commit is contained in:
@@ -0,0 +1,169 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module relativePaths="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="openapi" />
|
||||
<orderEntry type="module" module-name="resources" />
|
||||
<orderEntry type="module" module-name="resources_eng" />
|
||||
<orderEntry type="module" module-name="xdebugger-api" exported="" />
|
||||
<orderEntry type="module" module-name="idea_rt" />
|
||||
</component>
|
||||
<component name="copyright">
|
||||
<Base>
|
||||
<setting name="state" value="0" />
|
||||
</Base>
|
||||
<LanguageOptions name="HTML">
|
||||
<option name="templateOptions">
|
||||
<value>
|
||||
<option name="block" value="true" />
|
||||
<option name="separateBefore" value="false" />
|
||||
<option name="separateAfter" value="false" />
|
||||
<option name="prefixLines" value="true" />
|
||||
<option name="lenBefore" value="80" />
|
||||
<option name="lenAfter" value="80" />
|
||||
<option name="box" value="false" />
|
||||
<option name="filler" value=" " />
|
||||
</value>
|
||||
</option>
|
||||
<option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
|
||||
<option name="keyword" value="Copyright" />
|
||||
<option name="fileTypeOverride" value="2" />
|
||||
<option name="relativeBefore" value="true" />
|
||||
<option name="addBlankAfter" value="true" />
|
||||
<option name="fileLocation" value="1" />
|
||||
<option name="useAlternate" value="false" />
|
||||
</LanguageOptions>
|
||||
<LanguageOptions name="JAVA">
|
||||
<option name="templateOptions">
|
||||
<value>
|
||||
<option name="block" value="true" />
|
||||
<option name="separateBefore" value="false" />
|
||||
<option name="separateAfter" value="false" />
|
||||
<option name="prefixLines" value="true" />
|
||||
<option name="lenBefore" value="80" />
|
||||
<option name="lenAfter" value="80" />
|
||||
<option name="box" value="false" />
|
||||
<option name="filler" value=" " />
|
||||
</value>
|
||||
</option>
|
||||
<option name="notice" value="/* * Copyright (c) &#36;today.year Your Corporation. All Rights Reserved. */" />
|
||||
<option name="keyword" value="Copyright" />
|
||||
<option name="fileTypeOverride" value="2" />
|
||||
<option name="relativeBefore" value="true" />
|
||||
<option name="addBlankAfter" value="true" />
|
||||
<option name="fileLocation" value="1" />
|
||||
<option name="useAlternate" value="false" />
|
||||
</LanguageOptions>
|
||||
<LanguageOptions name="JSP">
|
||||
<option name="templateOptions">
|
||||
<value>
|
||||
<option name="block" value="true" />
|
||||
<option name="separateBefore" value="false" />
|
||||
<option name="separateAfter" value="false" />
|
||||
<option name="prefixLines" value="true" />
|
||||
<option name="lenBefore" value="80" />
|
||||
<option name="lenAfter" value="80" />
|
||||
<option name="box" value="false" />
|
||||
<option name="filler" value=" " />
|
||||
</value>
|
||||
</option>
|
||||
<option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
|
||||
<option name="keyword" value="Copyright" />
|
||||
<option name="fileTypeOverride" value="2" />
|
||||
<option name="relativeBefore" value="true" />
|
||||
<option name="addBlankAfter" value="true" />
|
||||
<option name="fileLocation" value="1" />
|
||||
<option name="useAlternate" value="false" />
|
||||
</LanguageOptions>
|
||||
<LanguageOptions name="JavaScript">
|
||||
<option name="templateOptions">
|
||||
<value>
|
||||
<option name="block" value="true" />
|
||||
<option name="separateBefore" value="false" />
|
||||
<option name="separateAfter" value="false" />
|
||||
<option name="prefixLines" value="true" />
|
||||
<option name="lenBefore" value="80" />
|
||||
<option name="lenAfter" value="80" />
|
||||
<option name="box" value="false" />
|
||||
<option name="filler" value=" " />
|
||||
</value>
|
||||
</option>
|
||||
<option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
|
||||
<option name="keyword" value="Copyright" />
|
||||
<option name="fileTypeOverride" value="2" />
|
||||
<option name="relativeBefore" value="true" />
|
||||
<option name="addBlankAfter" value="true" />
|
||||
<option name="fileLocation" value="1" />
|
||||
<option name="useAlternate" value="false" />
|
||||
</LanguageOptions>
|
||||
<LanguageOptions name="Properties">
|
||||
<option name="templateOptions">
|
||||
<value>
|
||||
<option name="block" value="true" />
|
||||
<option name="separateBefore" value="false" />
|
||||
<option name="separateAfter" value="false" />
|
||||
<option name="prefixLines" value="true" />
|
||||
<option name="lenBefore" value="80" />
|
||||
<option name="lenAfter" value="80" />
|
||||
<option name="box" value="false" />
|
||||
<option name="filler" value=" " />
|
||||
</value>
|
||||
</option>
|
||||
<option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
|
||||
<option name="keyword" value="Copyright" />
|
||||
<option name="fileTypeOverride" value="2" />
|
||||
<option name="relativeBefore" value="true" />
|
||||
<option name="addBlankAfter" value="true" />
|
||||
<option name="fileLocation" value="1" />
|
||||
<option name="useAlternate" value="false" />
|
||||
</LanguageOptions>
|
||||
<LanguageOptions name="XML">
|
||||
<option name="templateOptions">
|
||||
<value>
|
||||
<option name="block" value="true" />
|
||||
<option name="separateBefore" value="false" />
|
||||
<option name="separateAfter" value="false" />
|
||||
<option name="prefixLines" value="true" />
|
||||
<option name="lenBefore" value="80" />
|
||||
<option name="lenAfter" value="80" />
|
||||
<option name="box" value="false" />
|
||||
<option name="filler" value=" " />
|
||||
</value>
|
||||
</option>
|
||||
<option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
|
||||
<option name="keyword" value="Copyright" />
|
||||
<option name="fileTypeOverride" value="2" />
|
||||
<option name="relativeBefore" value="true" />
|
||||
<option name="addBlankAfter" value="true" />
|
||||
<option name="fileLocation" value="1" />
|
||||
<option name="useAlternate" value="false" />
|
||||
</LanguageOptions>
|
||||
<LanguageOptions name="__TEMPLATE__">
|
||||
<option name="templateOptions">
|
||||
<value>
|
||||
<option name="block" value="true" />
|
||||
<option name="separateBefore" value="false" />
|
||||
<option name="separateAfter" value="false" />
|
||||
<option name="prefixLines" value="true" />
|
||||
<option name="lenBefore" value="80" />
|
||||
<option name="lenAfter" value="80" />
|
||||
<option name="box" value="false" />
|
||||
<option name="filler" value=" " />
|
||||
</value>
|
||||
</option>
|
||||
<option name="notice" value="Copyright 2000-&#36;{today.year} 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." />
|
||||
<option name="keyword" value="Copyright" />
|
||||
<option name="fileTypeOverride" value="4" />
|
||||
<option name="relativeBefore" value="true" />
|
||||
<option name="addBlankAfter" value="true" />
|
||||
<option name="fileLocation" value="1" />
|
||||
<option name="useAlternate" value="false" />
|
||||
</LanguageOptions>
|
||||
</component>
|
||||
</module>
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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.execution;
|
||||
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CantRunException extends ExecutionException {
|
||||
public CantRunException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public static CantRunException noModuleConfigured(final String moduleName) {
|
||||
if (moduleName.trim().length() == 0) {
|
||||
return new CantRunException(ExecutionBundle.message("no.module.defined.error.message"));
|
||||
}
|
||||
return new CantRunException(ExecutionBundle.message("module.does.not.exist.error.message", moduleName));
|
||||
}
|
||||
|
||||
public static CantRunException noJdkForModule(@NotNull final Module module) {
|
||||
return new CantRunException(ExecutionBundle.message("no.jdk.for.module.error.message", module.getName()));
|
||||
}
|
||||
|
||||
public static CantRunException jdkMisconfigured(@NotNull final Sdk jdk, @NotNull final Module module) {
|
||||
return new CantRunException(ExecutionBundle.message("jdk.is.bad.configured.error.message", jdk.getName()));
|
||||
}
|
||||
|
||||
public static CantRunException classNotFound(@NotNull final String className, @NotNull final Module module) {
|
||||
return new CantRunException(ExecutionBundle.message("class.not.found.in.module.error.message", className, module.getName()));
|
||||
}
|
||||
|
||||
public static CantRunException packageNotFound(final String packageName) {
|
||||
return new CantRunException(ExecutionBundle.message("package.not.found.error.message", packageName));
|
||||
}
|
||||
|
||||
public static CantRunException noJdkConfigured(final String jdkName) {
|
||||
if (jdkName != null) {
|
||||
return new CantRunException(ExecutionBundle.message("jdk.not.configured.error.message", jdkName));
|
||||
}
|
||||
return new CantRunException(ExecutionBundle.message("project.has.no.jdk.error.message"));
|
||||
}
|
||||
|
||||
public static CantRunException badModuleDependencies() {
|
||||
return new CantRunException(ExecutionBundle.message("some.modules.has.circular.dependency.error.message"));
|
||||
}
|
||||
|
||||
public static CantRunException noJdkConfigured() {
|
||||
return new CantRunException(ExecutionBundle.message("project.has.no.jdk.configured.error.message"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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.execution;
|
||||
|
||||
import com.intellij.execution.configurations.JavaParameters;
|
||||
import com.intellij.openapi.extensions.PluginAware;
|
||||
import com.intellij.openapi.extensions.PluginDescriptor;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* User: anna
|
||||
* Date: Mar 4, 2005
|
||||
*/
|
||||
public abstract class JUnitPatcher implements PluginAware {
|
||||
private PluginDescriptor myPlugin;
|
||||
|
||||
/**
|
||||
* Called by the framework. Allows to identify the plugin that provided this extension.
|
||||
* @param plugin
|
||||
*/
|
||||
public void setPluginDescriptor(PluginDescriptor plugin) {
|
||||
myPlugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return plugin that provided this particular extension
|
||||
*/
|
||||
public PluginDescriptor getPluginDescriptor() {
|
||||
return myPlugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated override {@link #patchJavaParameters(Module, JavaParameters)} instead
|
||||
*/
|
||||
public void patchJavaParameters(JavaParameters javaParameters) {
|
||||
}
|
||||
|
||||
public void patchJavaParameters(@Nullable Module module, JavaParameters javaParameters) {
|
||||
patchJavaParameters(javaParameters);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
package com.intellij.execution;
|
||||
|
||||
import com.intellij.execution.configurations.*;
|
||||
import com.intellij.execution.executors.DefaultRunExecutor;
|
||||
import com.intellij.execution.filters.Filter;
|
||||
import com.intellij.execution.filters.TextConsoleBuilder;
|
||||
import com.intellij.execution.filters.TextConsoleBuilderFactory;
|
||||
import com.intellij.execution.runners.ProgramRunner;
|
||||
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.execution.util.ExecutionErrorDialog;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiClassUtil;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author spleaner
|
||||
*/
|
||||
public class JavaExecutionUtil {
|
||||
private JavaExecutionUtil() {
|
||||
}
|
||||
|
||||
public static boolean executeRun(@NotNull final Project project, String contentName,
|
||||
final DataContext dataContext) throws ExecutionException {
|
||||
return executeRun(project, contentName, dataContext, null);
|
||||
}
|
||||
|
||||
public static boolean executeRun(@NotNull final Project project, String contentName, DataContext dataContext, Filter[] filters) throws ExecutionException {
|
||||
final JavaParameters cmdLine = JavaParameters.JAVA_PARAMETERS.getData(dataContext);
|
||||
final DefaultRunProfile profile = new DefaultRunProfile(project, cmdLine, contentName, filters);
|
||||
final ProgramRunner runner = RunnerRegistry.getInstance().getRunner(DefaultRunExecutor.EXECUTOR_ID, profile);
|
||||
if (runner != null) {
|
||||
runner.execute(DefaultRunExecutor.getRunExecutorInstance(), new ExecutionEnvironment(profile, dataContext));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final class DefaultRunProfile implements RunProfile {
|
||||
private final JavaParameters myParameters;
|
||||
private final String myContentName;
|
||||
private final Filter[] myFilters;
|
||||
private final Project myProject;
|
||||
|
||||
public DefaultRunProfile(final Project project, final JavaParameters parameters, String contentName, Filter[] filters) {
|
||||
myProject = project;
|
||||
myParameters = parameters;
|
||||
myContentName = contentName;
|
||||
myFilters = filters;
|
||||
}
|
||||
|
||||
public RunProfileState getState(@NotNull final Executor executor, @NotNull final ExecutionEnvironment env) throws ExecutionException {
|
||||
final JavaCommandLineState state = new JavaCommandLineState(env) {
|
||||
protected JavaParameters createJavaParameters() {
|
||||
return myParameters;
|
||||
}
|
||||
};
|
||||
final TextConsoleBuilder builder = TextConsoleBuilderFactory.getInstance().createBuilder(myProject);
|
||||
if (myFilters != null) {
|
||||
for (final Filter myFilter : myFilters) {
|
||||
builder.addFilter(myFilter);
|
||||
}
|
||||
}
|
||||
state.setConsoleBuilder(builder);
|
||||
return state;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return myContentName;
|
||||
}
|
||||
|
||||
public void checkConfiguration() {}
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getRuntimeQualifiedName(final PsiClass aClass) {
|
||||
final PsiClass containingClass = aClass.getContainingClass();
|
||||
if (containingClass != null) {
|
||||
final String parentName = getRuntimeQualifiedName(containingClass);
|
||||
return parentName + "$" + aClass.getName();
|
||||
}
|
||||
else {
|
||||
return aClass.getQualifiedName();
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getPresentableClassName(final String rtClassName, final JavaRunConfigurationModule configurationModule) {
|
||||
final PsiClass psiClass = configurationModule.findClass(rtClassName);
|
||||
if (psiClass != null) {
|
||||
return psiClass.getName();
|
||||
}
|
||||
final int lastDot = rtClassName.lastIndexOf('.');
|
||||
if (lastDot == -1 || lastDot == rtClassName.length() - 1) {
|
||||
return rtClassName;
|
||||
}
|
||||
return rtClassName.substring(lastDot + 1, rtClassName.length());
|
||||
}
|
||||
|
||||
public static Module findModule(@NotNull final PsiClass psiClass) {
|
||||
return ModuleUtil.findModuleForPsiElement(psiClass);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiClass findMainClass(final Module module, final String mainClassName) {
|
||||
final PsiManager psiManager = PsiManager.getInstance(module.getProject());
|
||||
return JavaPsiFacade.getInstance(psiManager.getProject())
|
||||
.findClass(mainClassName.replace('$', '.'), GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module));
|
||||
}
|
||||
|
||||
|
||||
public static boolean isNewName(final String name) {
|
||||
return name == null || name.startsWith(ExecutionBundle.message("run.configuration.unnamed.name.prefix"));
|
||||
}
|
||||
|
||||
public static Location stepIntoSingleClass(final Location location) {
|
||||
PsiElement element = location.getPsiElement();
|
||||
if (!(element instanceof PsiClassOwner)) {
|
||||
if (PsiTreeUtil.getParentOfType(element, PsiClass.class) != null) return location;
|
||||
element = PsiTreeUtil.getParentOfType(element, PsiClassOwner.class);
|
||||
if (element == null) return location;
|
||||
}
|
||||
final PsiClassOwner psiFile = (PsiClassOwner)element;
|
||||
final PsiClass[] classes = psiFile.getClasses();
|
||||
if (classes.length != 1) return location;
|
||||
return PsiLocation.fromPsiElement(classes[0]);
|
||||
}
|
||||
|
||||
public static String getShortClassName(final String fqName) {
|
||||
if (fqName == null) return "";
|
||||
final int dotIndex = fqName.lastIndexOf('.');
|
||||
if (dotIndex == fqName.length() - 1) return "";
|
||||
if (dotIndex < 0) return fqName;
|
||||
return fqName.substring(dotIndex + 1, fqName.length());
|
||||
}
|
||||
|
||||
public static void showExecutionErrorMessage(final ExecutionException e, final String title, final Project project) {
|
||||
ExecutionErrorDialog.show(e, title, project);
|
||||
}
|
||||
|
||||
public static boolean isRunnableClass(final PsiClass aClass) {
|
||||
return PsiClassUtil.isRunnableClass(aClass, true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.intellij.execution;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.JavaPsiFacade;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author spleaner
|
||||
*/
|
||||
public class PsiClassLocationUtil {
|
||||
private PsiClassLocationUtil() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Location<PsiClass> fromClassQualifiedName(final Project project, final String qualifiedName) {
|
||||
final PsiClass psiClass =
|
||||
JavaPsiFacade.getInstance(project).findClass(qualifiedName.replace('$', '.'), GlobalSearchScope.allScope(project));
|
||||
return psiClass != null ? new PsiLocation<PsiClass>(project, psiClass) : null;
|
||||
}
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* @author max
|
||||
*/
|
||||
package com.intellij.execution.configurations;
|
||||
|
||||
import com.intellij.execution.CantRunException;
|
||||
import com.intellij.execution.ExecutionBundle;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
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.util.Computable;
|
||||
|
||||
public class CommandLineBuilder {
|
||||
private static final Logger LOG = Logger.getInstance("#" + CommandLineBuilder.class.getName());
|
||||
|
||||
public static GeneralCommandLine createFromJavaParameters(final SimpleJavaParameters javaParameters) throws CantRunException {
|
||||
return createFromJavaParameters(javaParameters, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* In order to avoid too long cmd problem dynamic classpath can be used
|
||||
* @param dynamicClasspath whether system properties and project settings will be able to cause using dynamic classpath. If false,
|
||||
* classpath will always be passed through the command line.
|
||||
*/
|
||||
public static GeneralCommandLine createFromJavaParameters(final SimpleJavaParameters javaParameters, final Project project, final boolean dynamicClasspath) throws CantRunException {
|
||||
return createFromJavaParameters(javaParameters, dynamicClasspath && JdkUtil.useDynamicClasspath(project));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param javaParameters parameters
|
||||
* @param forceDynamicClasspath whether dynamic classpath will be used for this execution, to prevent problems caused by too long command line
|
||||
* @return command line
|
||||
* @throws CantRunException if there are problems with JDK setup
|
||||
*/
|
||||
public static GeneralCommandLine createFromJavaParameters(final SimpleJavaParameters javaParameters, final boolean forceDynamicClasspath) throws CantRunException {
|
||||
try {
|
||||
return ApplicationManager.getApplication().runReadAction(new Computable<GeneralCommandLine>() {
|
||||
public GeneralCommandLine compute() {
|
||||
try {
|
||||
final Sdk jdk = javaParameters.getJdk();
|
||||
if(jdk == null) {
|
||||
throw new CantRunException(ExecutionBundle.message("run.configuration.error.no.jdk.specified"));
|
||||
}
|
||||
|
||||
final SdkType sdkType = jdk.getSdkType();
|
||||
if (!(sdkType instanceof JavaSdkType)) {
|
||||
throw new CantRunException(ExecutionBundle.message("run.configuration.error.no.jdk.specified"));
|
||||
}
|
||||
|
||||
final String exePath = ((JavaSdkType)sdkType).getVMExecutablePath(jdk);
|
||||
if(exePath == null) {
|
||||
throw new CantRunException(ExecutionBundle.message("run.configuration.cannot.find.vm.executable"));
|
||||
}
|
||||
if (javaParameters.getMainClass() == null) {
|
||||
throw new CantRunException(ExecutionBundle.message("main.class.is.not.specified.error.message"));
|
||||
}
|
||||
|
||||
return JdkUtil.setupJVMCommandLine(exePath, javaParameters, forceDynamicClasspath);
|
||||
}
|
||||
catch (CantRunException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
if(e.getCause() instanceof CantRunException)
|
||||
throw (CantRunException)e.getCause();
|
||||
else
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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.execution.configurations;
|
||||
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiModifier;
|
||||
import com.intellij.psi.util.PsiMethodUtil;
|
||||
|
||||
/**
|
||||
* User: anna
|
||||
* Date: Jan 26, 2005
|
||||
*/
|
||||
public class ConfigurationUtil {
|
||||
public static final Condition<PsiClass> PUBLIC_INSTANTIATABLE_CLASS = new Condition<PsiClass>() {
|
||||
public boolean value(final PsiClass psiClass) {
|
||||
return MAIN_CLASS.value(psiClass) &&
|
||||
psiClass.hasModifierProperty(PsiModifier.PUBLIC) &&
|
||||
!psiClass.hasModifierProperty(PsiModifier.ABSTRACT);
|
||||
}
|
||||
};
|
||||
public static final Condition<PsiClass> MAIN_CLASS = PsiMethodUtil.MAIN_CLASS;
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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.execution.configurations;
|
||||
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
public interface DebuggingRunnerData {
|
||||
@NonNls String DEBUGGER_RUNNER_ID = "Debug";
|
||||
|
||||
/**
|
||||
* @return a string denoting debug port. In case of socket transport this is a number, in case of shared memory transport this is a string
|
||||
*/
|
||||
String getDebugPort();
|
||||
|
||||
void setDebugPort(String port);
|
||||
|
||||
boolean isRemote();
|
||||
|
||||
void setLocal(boolean isLocal);
|
||||
}
|
||||
@@ -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.execution.configurations;
|
||||
|
||||
import com.intellij.execution.ExecutionException;
|
||||
|
||||
public interface JavaCommandLine extends RunProfileState {
|
||||
JavaParameters getJavaParameters() throws ExecutionException;
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.execution.configurations;
|
||||
|
||||
import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.execution.process.OSProcessHandler;
|
||||
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
public abstract class JavaCommandLineState extends CommandLineState implements JavaCommandLine{
|
||||
private JavaParameters myParams;
|
||||
|
||||
protected JavaCommandLineState(@NotNull final ExecutionEnvironment environment) {
|
||||
super(environment);
|
||||
}
|
||||
|
||||
public JavaParameters getJavaParameters() throws ExecutionException {
|
||||
if (myParams == null) {
|
||||
myParams = createJavaParameters();
|
||||
}
|
||||
return myParams;
|
||||
}
|
||||
|
||||
protected OSProcessHandler startProcess() throws ExecutionException {
|
||||
return JavaCommandLineStateUtil.startProcess(createCommandLine());
|
||||
}
|
||||
|
||||
protected abstract JavaParameters createJavaParameters() throws ExecutionException;
|
||||
|
||||
protected GeneralCommandLine createCommandLine() throws ExecutionException {
|
||||
return CommandLineBuilder.createFromJavaParameters(getJavaParameters(), PlatformDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext()), true);
|
||||
}
|
||||
|
||||
public boolean shouldAddJavaProgramRunnerActions() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.intellij.execution.configurations;
|
||||
|
||||
import com.intellij.execution.process.DefaultJavaProcessHandler;
|
||||
import com.intellij.execution.process.OSProcessHandler;
|
||||
import com.intellij.execution.process.ProcessTerminatedListener;
|
||||
import com.intellij.execution.ExecutionException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author spleaner
|
||||
*/
|
||||
public class JavaCommandLineStateUtil {
|
||||
private JavaCommandLineStateUtil() {
|
||||
}
|
||||
|
||||
public static OSProcessHandler startProcess(@NotNull final GeneralCommandLine commandLine) throws ExecutionException {
|
||||
final DefaultJavaProcessHandler processHandler = new DefaultJavaProcessHandler(commandLine);
|
||||
ProcessTerminatedListener.attach(processHandler);
|
||||
return processHandler;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* 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.execution.configurations;
|
||||
|
||||
import com.intellij.execution.CantRunException;
|
||||
import com.intellij.execution.ExecutionBundle;
|
||||
import com.intellij.openapi.actionSystem.DataKey;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.roots.ProjectClasspathTraversing;
|
||||
import com.intellij.openapi.roots.ProjectRootsTraversing;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.encoding.EncodingProjectManager;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
public class JavaParameters extends SimpleJavaParameters {
|
||||
public static final DataKey<JavaParameters> JAVA_PARAMETERS = DataKey.create("javaParameters");
|
||||
|
||||
public String getJdkPath() throws CantRunException {
|
||||
final Sdk jdk = getJdk();
|
||||
if(jdk == null) {
|
||||
throw new CantRunException(ExecutionBundle.message("no.jdk.specified..error.message"));
|
||||
}
|
||||
|
||||
final String jdkHome = jdk.getHomeDirectory().getPresentableUrl();
|
||||
if(jdkHome == null || jdkHome.length() == 0) {
|
||||
throw new CantRunException(ExecutionBundle.message("home.directory.not.specified.for.jdk.error.message"));
|
||||
}
|
||||
return jdkHome;
|
||||
}
|
||||
|
||||
public static final int JDK_ONLY = 0x1;
|
||||
public static final int CLASSES_ONLY = 0x2;
|
||||
private static final int TESTS_ONLY = 0x4;
|
||||
public static final int JDK_AND_CLASSES = JDK_ONLY | CLASSES_ONLY;
|
||||
public static final int JDK_AND_CLASSES_AND_TESTS = JDK_ONLY | CLASSES_ONLY | TESTS_ONLY;
|
||||
|
||||
public void configureByModule(final Module module, final int classPathType, final Sdk jdk) throws CantRunException {
|
||||
if ((classPathType & JDK_ONLY) != 0) {
|
||||
if (jdk == null) {
|
||||
throw CantRunException.noJdkConfigured();
|
||||
}
|
||||
setJdk(jdk);
|
||||
}
|
||||
|
||||
if((classPathType & CLASSES_ONLY) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Charset encoding = EncodingProjectManager.getInstance(module.getProject()).getDefaultCharset();
|
||||
if (encoding != null) {
|
||||
setCharset(encoding);
|
||||
}
|
||||
ProjectRootsTraversing.collectRoots(module, (classPathType & TESTS_ONLY) != 0 ? ProjectClasspathTraversing.FULL_CLASSPATH_RECURSIVE : ProjectClasspathTraversing.FULL_CLASSPATH_WITHOUT_TESTS, getClassPath());
|
||||
}
|
||||
|
||||
public void configureByModule(final Module module, final int classPathType) throws CantRunException {
|
||||
configureByModule(module, classPathType, getModuleJdk(module));
|
||||
}
|
||||
|
||||
public static Sdk getModuleJdk(final Module module) throws CantRunException {
|
||||
final Sdk jdk = ModuleRootManager.getInstance(module).getSdk();
|
||||
if (jdk == null) {
|
||||
throw CantRunException.noJdkForModule(module);
|
||||
}
|
||||
final VirtualFile homeDirectory = jdk.getHomeDirectory();
|
||||
if (homeDirectory == null || !homeDirectory.isValid()) {
|
||||
throw CantRunException.jdkMisconfigured(jdk, module);
|
||||
}
|
||||
return jdk;
|
||||
}
|
||||
|
||||
public void configureByProject(final Project project, final int classPathType, final Sdk jdk ) throws CantRunException {
|
||||
if ((classPathType & JDK_ONLY) != 0) {
|
||||
if (jdk == null) {
|
||||
throw CantRunException.noJdkConfigured();
|
||||
}
|
||||
setJdk(jdk);
|
||||
}
|
||||
|
||||
if ((classPathType & CLASSES_ONLY) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
ProjectRootsTraversing.collectRoots(project, (classPathType & TESTS_ONLY) != 0 ? ProjectClasspathTraversing.FULL_CLASSPATH_RECURSIVE : ProjectClasspathTraversing.FULL_CLASSPATH_WITHOUT_TESTS, getClassPath());
|
||||
}
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
package com.intellij.execution.configurations;
|
||||
|
||||
import com.intellij.execution.ExecutionBundle;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.module.ModuleUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.JavaPsiFacade;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author spleaner
|
||||
*/
|
||||
public class JavaRunConfigurationModule extends RunConfigurationModule {
|
||||
|
||||
private final boolean myClassesInLibraries;
|
||||
|
||||
public JavaRunConfigurationModule(final Project project, final boolean classesInLibs) {
|
||||
super(project);
|
||||
|
||||
myClassesInLibraries = classesInLibs;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PsiClass findClass(final String qualifiedName) {
|
||||
if (qualifiedName == null) return null;
|
||||
final Module module = getModule();
|
||||
final GlobalSearchScope scope;
|
||||
if (module != null) {
|
||||
scope = myClassesInLibraries ? GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module)
|
||||
: GlobalSearchScope.moduleWithDependenciesScope(module);
|
||||
}
|
||||
else {
|
||||
scope = myClassesInLibraries ? GlobalSearchScope.allScope(getProject()) : GlobalSearchScope.projectScope(getProject());
|
||||
}
|
||||
return JavaPsiFacade.getInstance(getProject()).findClass(qualifiedName.replace('$', '.'), scope);
|
||||
}
|
||||
|
||||
public static Collection<Module> getModulesForClass(@NotNull final Project project, final String className) {
|
||||
if (project.isDefault()) return Arrays.asList(ModuleManager.getInstance(project).getModules());
|
||||
PsiDocumentManager.getInstance(project).commitAllDocuments();
|
||||
final PsiClass[] possibleClasses = JavaPsiFacade.getInstance(project).findClasses(className, GlobalSearchScope.projectScope(project));
|
||||
|
||||
final Set<Module> modules = new THashSet<Module>();
|
||||
for (PsiClass aClass : possibleClasses) {
|
||||
Module module = ModuleUtil.findModuleForPsiElement(aClass);
|
||||
if (module != null) {
|
||||
modules.add(module);
|
||||
}
|
||||
}
|
||||
if (modules.isEmpty()) {
|
||||
return Arrays.asList(ModuleManager.getInstance(project).getModules());
|
||||
}
|
||||
else {
|
||||
return ModuleUtil.collectModulesDependsOn(modules);
|
||||
}
|
||||
}
|
||||
|
||||
public PsiClass findNotNullClass(final String className) throws RuntimeConfigurationWarning {
|
||||
final PsiClass psiClass = findClass(className);
|
||||
if (psiClass == null) {
|
||||
throw new RuntimeConfigurationWarning(
|
||||
ExecutionBundle.message("class.not.found.in.module.error.message", className, getModuleName()));
|
||||
}
|
||||
return psiClass;
|
||||
}
|
||||
|
||||
public PsiClass checkModuleAndClassName(final String className, final String expectedClassMessage) throws RuntimeConfigurationException {
|
||||
checkForWarning();
|
||||
return checkClassName(className, expectedClassMessage);
|
||||
}
|
||||
|
||||
|
||||
public PsiClass checkClassName(final String className, final String errorMessage) throws RuntimeConfigurationException {
|
||||
if (className == null || className.length() == 0) {
|
||||
throw new RuntimeConfigurationError(errorMessage);
|
||||
}
|
||||
return findNotNullClass(className);
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* 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.execution.configurations;
|
||||
|
||||
public interface PatchedRunnableState extends RunnableState{
|
||||
RunnerSettings getPatcher();
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.intellij.execution.configurations;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.refactoring.listeners.RefactoringElementListener;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author spleaner
|
||||
*/
|
||||
public interface RefactoringListenerProvider {
|
||||
|
||||
@Nullable
|
||||
RefactoringElementListener getRefactoringElementListener(final PsiElement element);
|
||||
|
||||
}
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* 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.execution.configurations;
|
||||
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
public class RemoteConnection {
|
||||
private boolean myUseSockets;
|
||||
private boolean myServerMode;
|
||||
private String myHostName;
|
||||
private String myAddress;
|
||||
@NonNls public static final String ONTHROW = ",onthrow=<FQ exception class name>";
|
||||
@NonNls public static final String ONUNCAUGHT = ",onuncaught=<y/n>";
|
||||
|
||||
public RemoteConnection(boolean useSockets, String hostName, String address, boolean serverMode) {
|
||||
myUseSockets = useSockets;
|
||||
myServerMode = serverMode;
|
||||
myHostName = hostName;
|
||||
myAddress = address;
|
||||
}
|
||||
|
||||
public boolean isUseSockets() {
|
||||
return myUseSockets;
|
||||
}
|
||||
|
||||
public boolean isServerMode() {
|
||||
return myServerMode;
|
||||
}
|
||||
|
||||
public String getHostName() {
|
||||
return myHostName;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return myAddress;
|
||||
}
|
||||
|
||||
|
||||
public void setUseSockets(boolean useSockets) {
|
||||
myUseSockets = useSockets;
|
||||
}
|
||||
|
||||
public void setServerMode(boolean serverMode) {
|
||||
myServerMode = serverMode;
|
||||
}
|
||||
|
||||
public void setHostName(String hostName) {
|
||||
myHostName = hostName;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
myAddress = address;
|
||||
}
|
||||
|
||||
public String getLaunchCommandLine() {
|
||||
final String address = getAddress();
|
||||
final boolean shmem = !isUseSockets();
|
||||
final boolean serverMode = isServerMode();
|
||||
|
||||
@NonNls String result;
|
||||
if (shmem) {
|
||||
if (serverMode) {
|
||||
result = "-Xdebug -Xrunjdwp:transport=dt_shmem,server=n,address=" +
|
||||
((address.length() > 0)? address : "...") +
|
||||
ONTHROW + ",suspend=y" + ONUNCAUGHT;
|
||||
}
|
||||
else {
|
||||
result = "-Xdebug -Xrunjdwp:transport=dt_shmem,server=y,suspend=n,address=" +
|
||||
((address.length() > 0)? address : "...");
|
||||
}
|
||||
}
|
||||
else { // socket transport
|
||||
int p = -1;
|
||||
try {
|
||||
p = Integer.parseInt(address);
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
}
|
||||
if (serverMode) {
|
||||
result = "-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=" +
|
||||
((p == -1)? "..." : Integer.toString(p)) +
|
||||
ONTHROW + ",suspend=y" + ONUNCAUGHT;
|
||||
}
|
||||
else {
|
||||
result = "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=" +
|
||||
((p == -1)? "..." : Integer.toString(p));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* 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.execution.configurations;
|
||||
|
||||
public interface RemoteState extends RunProfileState {
|
||||
RemoteConnection getRemoteConnection();
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<html><body bgcolor="white">
|
||||
Provides interfaces for defining run configurations.
|
||||
</body></html>
|
||||
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* 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.execution.filters;
|
||||
|
||||
import com.intellij.openapi.editor.colors.CodeInsightColors;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.JavaPsiFacade;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class ExceptionFilter implements Filter, DumbAware {
|
||||
private final Project myProject;
|
||||
@NonNls private static final String AT = "at";
|
||||
private static final String AT_PREFIX = AT + " ";
|
||||
private static final String STANDALONE_AT = " " + AT + " ";
|
||||
private static final TextAttributes HYPERLINK_ATTRIBUTES = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(CodeInsightColors.HYPERLINK_ATTRIBUTES);
|
||||
|
||||
public ExceptionFilter(@NotNull final Project project) {
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
public Result applyFilter(final String line, final int textEndOffset) {
|
||||
int atIndex;
|
||||
if (line.startsWith(AT_PREFIX)){
|
||||
atIndex = 0;
|
||||
}
|
||||
else{
|
||||
atIndex = line.indexOf(STANDALONE_AT);
|
||||
if (atIndex < 0) {
|
||||
atIndex = line.indexOf(AT_PREFIX);
|
||||
}
|
||||
if (atIndex < 0) return null;
|
||||
}
|
||||
|
||||
final int lparenthIndex = line.indexOf('(', atIndex);
|
||||
if (lparenthIndex < 0) return null;
|
||||
final int lastDotIndex = line.lastIndexOf('.', lparenthIndex);
|
||||
if (lastDotIndex < 0 || lastDotIndex < atIndex) return null;
|
||||
String className = line.substring(atIndex + AT.length() + 1, lastDotIndex).trim();
|
||||
final int dollarIndex = className.indexOf('$');
|
||||
if (dollarIndex >= 0){
|
||||
className = className.substring(0, dollarIndex);
|
||||
}
|
||||
|
||||
//String methodName = text.substring(lastDotIndex + 1, lparenthIndex).trim();
|
||||
|
||||
final int rparenthIndex = line.indexOf(')', lparenthIndex);
|
||||
if (rparenthIndex < 0) return null;
|
||||
|
||||
final String fileAndLine = line.substring(lparenthIndex + 1, rparenthIndex).trim();
|
||||
|
||||
final int colonIndex = fileAndLine.lastIndexOf(':');
|
||||
if (colonIndex < 0) return null;
|
||||
|
||||
final String lineString = fileAndLine.substring(colonIndex + 1);
|
||||
try{
|
||||
final int lineNumber = Integer.parseInt(lineString);
|
||||
final PsiManager manager = PsiManager.getInstance(myProject);
|
||||
PsiClass aClass = JavaPsiFacade.getInstance(manager.getProject()).findClass(className, GlobalSearchScope.allScope(myProject));
|
||||
if (aClass == null) return null;
|
||||
final PsiFile file = (PsiFile) aClass.getContainingFile().getNavigationElement();
|
||||
if (file == null) return null;
|
||||
|
||||
/*
|
||||
IDEADEV-4976: Some scramblers put something like SourceFile mock instead of real class name.
|
||||
final String filePath = fileAndLine.substring(0, colonIndex).replace('/', File.separatorChar);
|
||||
final int slashIndex = filePath.lastIndexOf(File.separatorChar);
|
||||
final String shortFileName = slashIndex < 0 ? filePath : filePath.substring(slashIndex + 1);
|
||||
if (!file.getName().equalsIgnoreCase(shortFileName)) return null;
|
||||
*/
|
||||
|
||||
final int textStartOffset = textEndOffset - line.length();
|
||||
final int highlightStartOffset = textStartOffset + lparenthIndex + 1;
|
||||
final int highlightEndOffset = textStartOffset + rparenthIndex;
|
||||
VirtualFile virtualFile = file.getVirtualFile();
|
||||
final OpenFileHyperlinkInfo info = new OpenFileHyperlinkInfo(myProject, virtualFile, lineNumber - 1);
|
||||
TextAttributes attributes = HYPERLINK_ATTRIBUTES.clone();
|
||||
if (!ProjectRootManager.getInstance(myProject).getFileIndex().isInContent(virtualFile)) {
|
||||
Color color = UIUtil.getTextInactiveTextColor();
|
||||
attributes.setForegroundColor(color);
|
||||
attributes.setEffectColor(color);
|
||||
}
|
||||
return new Result(highlightStartOffset, highlightEndOffset, info, attributes);
|
||||
}
|
||||
catch(NumberFormatException e){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<html><body bgcolor="white">
|
||||
Provides interfaces for defining filters which perform highlighting and add hyperlinks to the
|
||||
text printed by the programs started from IDEA and displayed in the IDEA console view.
|
||||
</body></html>
|
||||
@@ -0,0 +1,21 @@
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<html><body bgcolor="white">
|
||||
Provides interfaces for running programs from within IDEA and for defining and working
|
||||
with run configurations.
|
||||
</body></html>
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.execution.process;
|
||||
|
||||
import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.execution.configurations.CommandLineBuilder;
|
||||
import com.intellij.execution.configurations.GeneralCommandLine;
|
||||
import com.intellij.execution.configurations.JavaParameters;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
public class DefaultJavaProcessHandler extends OSProcessHandler {
|
||||
private final Charset myCharset;
|
||||
|
||||
public DefaultJavaProcessHandler(final JavaParameters javaParameters) throws ExecutionException {
|
||||
this(CommandLineBuilder.createFromJavaParameters(javaParameters));
|
||||
}
|
||||
|
||||
public DefaultJavaProcessHandler(final GeneralCommandLine commandLine) throws ExecutionException {
|
||||
this(commandLine.createProcess(), commandLine.getCommandLineString(), commandLine.getCharset());
|
||||
}
|
||||
|
||||
public DefaultJavaProcessHandler(final Process process, final String commandLine, @NotNull final Charset charset) {
|
||||
super(process, commandLine);
|
||||
myCharset = charset;
|
||||
}
|
||||
|
||||
public Charset getCharset() {
|
||||
return myCharset;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<html><body bgcolor="white">
|
||||
Provides interfaces for interacting with processes started from within IDEA.
|
||||
</body></html>
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.intellij.execution.runners;
|
||||
|
||||
import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.execution.configurations.JavaParameters;
|
||||
import com.intellij.execution.configurations.RunnerSettings;
|
||||
import com.intellij.openapi.util.JDOMExternalizable;
|
||||
|
||||
/**
|
||||
* @author spleaner
|
||||
*/
|
||||
public abstract class JavaPatchableProgramRunner<Settings extends JDOMExternalizable> extends GenericProgramRunner<Settings> {
|
||||
|
||||
public abstract void patch(JavaParameters javaParameters, RunnerSettings settings, final boolean beforeExecution) throws ExecutionException;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.execution.runners;
|
||||
|
||||
import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.execution.configurations.JavaCommandLine;
|
||||
import com.intellij.execution.process.ProcessHandler;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
|
||||
public abstract class ProcessProxyFactory {
|
||||
public static ProcessProxyFactory getInstance() {
|
||||
return ServiceManager.getService(ProcessProxyFactory.class);
|
||||
}
|
||||
|
||||
|
||||
public abstract ProcessProxy createCommandLineProxy(JavaCommandLine javaCmdLine) throws ExecutionException;
|
||||
|
||||
public abstract ProcessProxy getAttachedProxy(ProcessHandler processHandler);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<html><body bgcolor="white">
|
||||
Provides interfaces for interacting with the "Run" tool window and the console view
|
||||
displayed in that tool window.
|
||||
</body></html>
|
||||
Reference in New Issue
Block a user