• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CantRunException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.execution.CantRunException的典型用法代码示例。如果您正苦于以下问题:Java CantRunException类的具体用法?Java CantRunException怎么用?Java CantRunException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CantRunException类属于com.intellij.execution包,在下文中一共展示了CantRunException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: configureByModule

import com.intellij.execution.CantRunException; //导入依赖的package包/类
public void configureByModule(final Module module,
                              @MagicConstant(valuesFromClass = JavaParameters.class) 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;
  }

  setDefaultCharset(module.getProject());
  configureEnumerator(OrderEnumerator.orderEntries(module).runtimeOnly().recursively(), classPathType, jdk).collectPaths(getClassPath());
  configureJavaLibraryPath(OrderEnumerator.orderEntries(module).recursively());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:JavaParameters.java


示例2: doTestMethodConfiguration

import com.intellij.execution.CantRunException; //导入依赖的package包/类
private void doTestMethodConfiguration(PsiClass aClass, PsiMethod... expectedMethods) throws CantRunException {
  final TestNGConfiguration configuration =
    new TestNGConfiguration("testOne", getProject(), TestNGConfigurationType.getInstance().getConfigurationFactories()[0]);
  final TestData data = configuration.getPersistantData();
  data.TEST_OBJECT = TestType.METHOD.getType();
  data.METHOD_NAME = "testOne";
  data.setScope(TestSearchScope.SINGLE_MODULE);
  configuration.setModule(data.setMainClass(aClass));

  final TestNGTestObject testObject = TestNGTestObject.fromConfig(configuration);
  assertNotNull(testObject);
  final LinkedHashMap<PsiClass, Map<PsiMethod, List<String>>> classes = new LinkedHashMap<PsiClass, Map<PsiMethod, List<String>>>();
  testObject.fillTestObjects(classes);
  assertContainsElements(classes.keySet(), aClass);
  final Map<PsiMethod, List<String>> methods = classes.get(aClass);
  assertContainsElements(methods.keySet(), expectedMethods);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:DetectClassesToRunTest.java


示例3: doTestPackageConfiguration

import com.intellij.execution.CantRunException; //导入依赖的package包/类
private void doTestPackageConfiguration(PsiClass... containingClasses) throws CantRunException {
  final TestNGConfiguration configuration =
    new TestNGConfiguration("p", getProject(), TestNGConfigurationType.getInstance().getConfigurationFactories()[0]);
  final TestData data = configuration.getPersistantData();
  data.TEST_OBJECT = TestType.PACKAGE.getType();
  data.PACKAGE_NAME = "p";
  data.setScope(TestSearchScope.WHOLE_PROJECT);

  final TestNGTestObject testObject = TestNGTestObject.fromConfig(configuration);
  assertNotNull(testObject);
  final LinkedHashMap<PsiClass, Map<PsiMethod, List<String>>> classes = new LinkedHashMap<PsiClass, Map<PsiMethod, List<String>>>();
  testObject.fillTestObjects(classes);
  assertContainsElements(classes.keySet(), containingClasses);

  for (PsiClass psiClass : containingClasses) {
    assertEmpty(classes.get(psiClass).keySet());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:DetectClassesToRunTest.java


示例4: fillTestObjects

import com.intellij.execution.CantRunException; //导入依赖的package包/类
@Override
public void fillTestObjects(Map<PsiClass, Map<PsiMethod, List<String>>> classes)
  throws CantRunException {
  final TestData data = myConfig.getPersistantData();
  //for a group, we include all classes
  final SourceScope sourceScope = data.getScope().getSourceScope(myConfig);
  final TestClassFilter classFilter =
    new TestClassFilter(sourceScope != null ? sourceScope.getGlobalSearchScope() : GlobalSearchScope.allScope(myConfig.getProject()),
                        myConfig.getProject(), true, true);
  PsiClass[] testClasses = TestNGUtil.getAllTestClasses(classFilter, false);
  if (testClasses != null) {
    for (PsiClass c : testClasses) {
      classes.put(c, new LinkedHashMap<PsiMethod, List<String>>());
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:TestNGTestGroup.java


示例5: fillTestObjects

import com.intellij.execution.CantRunException; //导入依赖的package包/类
@Override
public void fillTestObjects(Map<PsiClass, Map<PsiMethod, List<String>>> classes) throws CantRunException {
  final String packageName = myConfig.getPersistantData().getPackageName();
  PsiPackage psiPackage = ApplicationManager.getApplication().runReadAction(
    new Computable<PsiPackage>() {
      @Nullable
      public PsiPackage compute() {
        return JavaPsiFacade.getInstance(myConfig.getProject()).findPackage(packageName);
      }
    }
  );
  if (psiPackage == null) {
    throw CantRunException.packageNotFound(packageName);
  }
  else {
    TestSearchScope scope = myConfig.getPersistantData().getScope();
    //TODO we should narrow this down by module really, if that's what's specified
    TestClassFilter projectFilter =
      new TestClassFilter(scope.getSourceScope(myConfig).getGlobalSearchScope(), myConfig.getProject(), true, true);
    TestClassFilter filter = projectFilter.intersectionWith(PackageScope.packageScope(psiPackage, true));
    calculateDependencies(null, classes, getSearchScope(), TestNGUtil.getAllTestClasses(filter, false));
    if (classes.size() == 0) {
      throw new CantRunException("No tests found in the package \"" + packageName + '\"');
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:TestNGTestPackage.java


示例6: fillTestObjects

import com.intellij.execution.CantRunException; //导入依赖的package包/类
@Override
public void fillTestObjects(Map<PsiClass, Map<PsiMethod, List<String>>> classes)
  throws CantRunException {
  final TestData data = myConfig.getPersistantData();
  //it's a class
  final PsiClass psiClass = ApplicationManager.getApplication().runReadAction(
    new Computable<PsiClass>() {
      @Nullable
      public PsiClass compute() {
        return ClassUtil.findPsiClass(PsiManager.getInstance(myConfig.getProject()), data.getMainClassName().replace('/', '.'), null, true, getSearchScope());
      }
    }
  );
  if (psiClass == null) {
    throw new CantRunException("No tests found in the class \"" + data.getMainClassName() + '\"');
  }
  if (null == ApplicationManager.getApplication().runReadAction(new Computable<String>() {
    @Nullable
    public String compute() {
      return psiClass.getQualifiedName();
    }
  })) {
    throw new CantRunException("Cannot test anonymous or local class \"" + data.getMainClassName() + '\"');
  }
  calculateDependencies(null, classes, getSearchScope(), psiClass);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:TestNGTestClass.java


示例7: configureCommandLine

import com.intellij.execution.CantRunException; //导入依赖的package包/类
@Override
public void configureCommandLine(JavaParameters params, @Nullable Module module, boolean tests, VirtualFile script, GroovyScriptRunConfiguration configuration) throws CantRunException {
  configureGenericGroovyRunner(params, module, "groovy.ui.GroovyMain", false, tests);

  //addClasspathFromRootModel(module, tests, params, true);

  params.getVMParametersList().addParametersString(configuration.getVMParameters());

  addScriptEncodingSettings(params, script, module);

  if (configuration.isDebugEnabled()) {
    params.getProgramParametersList().add("--debug");
  }

  String path = ScriptFileUtil.getLocalFilePath(StringUtil.notNullize(configuration.getScriptPath()));
  params.getProgramParametersList().add(FileUtil.toSystemDependentName(path));
  params.getProgramParametersList().addParametersString(configuration.getScriptParameters());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:DefaultGroovyScriptRunner.java


示例8: configureByModule

import com.intellij.execution.CantRunException; //导入依赖的package包/类
public void configureByModule(final Module module,
                              @MagicConstant(valuesFromClass = JavaParameters.class) 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;
  }

  setDefaultCharset(module.getProject());
  configureEnumerator(OrderEnumerator.orderEntries(module).runtimeOnly().recursively(), classPathType, jdk).collectPaths(getClassPath());
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:JavaParameters.java


示例9: getClasspathType

import com.intellij.execution.CantRunException; //导入依赖的package包/类
public static int getClasspathType(final RunConfigurationModule configurationModule, final String mainClassName,
                                   final boolean classMustHaveSource) throws CantRunException {
  final Module module = configurationModule.getModule();
  if (module == null) throw CantRunException.noModuleConfigured(configurationModule.getModuleName());
  final PsiClass psiClass = JavaExecutionUtil.findMainClass(module, mainClassName);
  if (psiClass == null) {
    if (!classMustHaveSource) return JavaParameters.JDK_AND_CLASSES_AND_TESTS;
    throw CantRunException.classNotFound(mainClassName, module);
  }
  final PsiFile psiFile = psiClass.getContainingFile();
  if (psiFile == null) throw CantRunException.classNotFound(mainClassName, module);
  final VirtualFile virtualFile = psiFile.getVirtualFile();
  if (virtualFile == null) throw CantRunException.classNotFound(mainClassName, module);
  Module classModule = psiClass.isValid() ? ModuleUtilCore.findModuleForPsiElement(psiClass) : null;
  if (classModule == null) classModule = module;
  ModuleFileIndex fileIndex = ModuleRootManager.getInstance(classModule).getFileIndex();
  if (fileIndex.isInSourceContent(virtualFile)) {
    return fileIndex.
      isInTestSourceContent(virtualFile) ? JavaParameters.JDK_AND_CLASSES_AND_TESTS : JavaParameters.JDK_AND_CLASSES;
  }
  final List<OrderEntry> entriesForFile = fileIndex.getOrderEntriesForFile(virtualFile);
  for (OrderEntry entry : entriesForFile) {
    if (entry instanceof ExportableOrderEntry && ((ExportableOrderEntry)entry).getScope() == DependencyScope.TEST) return JavaParameters.JDK_AND_CLASSES_AND_TESTS;
  }
  return JavaParameters.JDK_AND_CLASSES;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:27,代码来源:JavaParametersUtil.java


示例10: getPackage

import com.intellij.execution.CantRunException; //导入依赖的package包/类
@Override
protected PsiPackage getPackage(JUnitConfiguration.Data data) throws CantRunException {
  final String dirName = data.getDirName();
  final VirtualFile file = LocalFileSystem.getInstance().findFileByPath(FileUtil.toSystemIndependentName(dirName));
  if (file == null) {
    throw new CantRunException("Directory \'" + dirName + "\' is not found");
  }
  final PsiDirectory directory = PsiManager.getInstance(myProject).findDirectory(file);
  if (directory == null) {
    throw new CantRunException("Directory \'" + dirName + "\' is not found");
  }
  final PsiPackage aPackage = JavaDirectoryService.getInstance().getPackage(directory);
  if (aPackage == null) {
    throw new CantRunException("Package not found in directory");
  }
  return aPackage;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:TestDirectory.java


示例11: getClassPathFromRootModel

import com.intellij.execution.CantRunException; //导入依赖的package包/类
@Nullable
public static PathsList getClassPathFromRootModel(Module module, boolean isTests, JavaParameters params, boolean allowDuplication)
  throws CantRunException {
  if (module == null) {
    return null;
  }

  final JavaParameters tmp = new JavaParameters();
  tmp.configureByModule(module, isTests ? JavaParameters.CLASSES_AND_TESTS : JavaParameters.CLASSES_ONLY);
  if (tmp.getClassPath().getVirtualFiles().isEmpty()) {
    return null;
  }

  Set<VirtualFile> core = new HashSet<VirtualFile>(params.getClassPath().getVirtualFiles());

  PathsList nonCore = new PathsList();
  for (VirtualFile virtualFile : tmp.getClassPath().getVirtualFiles()) {
    if (allowDuplication || !core.contains(virtualFile)) {
      nonCore.add(virtualFile);
    }
  }
  return nonCore;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:24,代码来源:GroovyScriptRunner.java


示例12: configureCommandLine

import com.intellij.execution.CantRunException; //导入依赖的package包/类
@Override
public void configureCommandLine(JavaParameters params, @Nullable Module module, boolean tests, VirtualFile script, GroovyScriptRunConfiguration configuration) throws CantRunException {
  configureGenericGroovyRunner(params, module, "groovy.ui.GroovyMain", false);

  addClasspathFromRootModel(module, tests, params, true);

  params.getVMParametersList().addParametersString(configuration.getVMParameters());

  addScriptEncodingSettings(params, script, module);

  if (configuration.isDebugEnabled()) {
    params.getProgramParametersList().add("--debug");
  }

  params.getProgramParametersList().add(FileUtil.toSystemDependentName(configuration.getScriptPath()));
  params.getProgramParametersList().addParametersString(configuration.getScriptParameters());
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:DefaultGroovyScriptRunner.java


示例13: generateRunnerClasspathEntries

import com.intellij.execution.CantRunException; //导入依赖的package包/类
public String generateRunnerClasspathEntries(XQueryRunConfiguration configuration) throws CantRunException {
    XQueryDataSourceConfiguration dataSourceConfiguration = getDataSourceConfiguration(configuration);
    validate(dataSourceConfiguration);
    List<String> pluginJarsEntries = new ArrayList<String>();
    pluginJarsEntries.add(INTELLIJ_XQUERY_RT_JAR);
    pluginJarsEntries.add(DBGP_INTERFACES_JAR);
    pluginJarsEntries.add(NETTY);
    addXqjApiJarsIfNeeded(dataSourceConfiguration, pluginJarsEntries);
    if (!dataSourceConfiguration.USER_DEFINED_LIBRARY_ENABLED) {
        pluginJarsEntries.addAll(dataSourceConfiguration.TYPE.getClasspathEntries());
    }
    Set<String> classPathEntries = getPluginInternalJarEntries(getPluginPath(), pluginJarsEntries);
    if (dataSourceConfiguration.USER_DEFINED_LIBRARY_ENABLED) {
        classPathEntries.addAll(dataSourceConfiguration.USER_DEFINED_LIBRARY_PATHS);
    }
    return separateEntriesWithPathSeparator(classPathEntries);
}
 
开发者ID:ligasgr,项目名称:intellij-xquery,代码行数:18,代码来源:XQueryRunnerClasspathEntryGenerator.java


示例14: getClasspathEntryFileIfExists

import com.intellij.execution.CantRunException; //导入依赖的package包/类
private File getClasspathEntryFileIfExists(File pluginPath, String jarName) throws CantRunException {
    File libraryDirectory = new File(pluginPath, "lib");
    File[] files = libraryDirectory.listFiles(new FilenameFilter() {
        @Override
        public boolean accept(File dir, String name) {
            return name.matches(jarName);
        }
    });
    if (files.length > 1) {
        throw new CantRunException("There should be just one matching library for " + jarName + ", found: " + files.length);
    }
    File rtJarFile = files.length == 1 ? files[0] : new File(libraryDirectory, jarName);
    if (rtJarFile.exists()) return rtJarFile;
    File classesDirectory = new File(pluginPath, "classes");
    if (classesDirectory.exists()) return classesDirectory;
    if (isTestRun(pluginPath)) {
        return pluginPath;
    } else {
        throw new CantRunException("Runtime classes not found");
    }
}
 
开发者ID:ligasgr,项目名称:intellij-xquery,代码行数:22,代码来源:XQueryRunnerClasspathEntryGenerator.java


示例15: getValidJdkToRunModule

import com.intellij.execution.CantRunException; //导入依赖的package包/类
private Sdk getValidJdkToRunModule(final Module module) throws CantRunException {
    Sdk jdk = getJdkToRunModule(module);
    String currentRunningJavaHome = getCurrentRunningJavaHome();
    if (jdk == null) {
        if (currentRunningJavaHome != null) {
            jdk = createAlternativeJdk(currentRunningJavaHome);
        } else {
            throw CantRunException.noJdkForModule(module);
        }
    }
    final VirtualFile homeDirectory = jdk.getHomeDirectory();
    if (homeDirectory == null || !homeDirectory.isValid()) {
        throw CantRunException.jdkMisconfigured(jdk, module);
    }
    return jdk;
}
 
开发者ID:ligasgr,项目名称:intellij-xquery,代码行数:17,代码来源:XQueryRunProfileState.java


示例16: getClasspathType

import com.intellij.execution.CantRunException; //导入依赖的package包/类
@MagicConstant(valuesFromClass = OwnJavaParameters.class)
public static int getClasspathType(final RunConfigurationModule configurationModule,
		final String mainClassName,
		final boolean classMustHaveSource,
		final boolean includeProvidedDependencies) throws CantRunException
{
	final Module module = configurationModule.getModule();
	if(module == null)
	{
		throw CantRunException.noModuleConfigured(configurationModule.getModuleName());
	}
	Boolean inProduction = isClassInProductionSources(mainClassName, module);
	if(inProduction == null)
	{
		if(!classMustHaveSource)
		{
			return OwnJavaParameters.JDK_AND_CLASSES_AND_TESTS;
		}
		throw CantRunException.classNotFound(mainClassName, module);
	}

	return inProduction ? (includeProvidedDependencies ? OwnJavaParameters.JDK_AND_CLASSES_AND_PROVIDED : OwnJavaParameters.JDK_AND_CLASSES) : OwnJavaParameters.JDK_AND_CLASSES_AND_TESTS;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:24,代码来源:JavaParametersUtil.java


示例17: createAlternativeJdk

import com.intellij.execution.CantRunException; //导入依赖的package包/类
private static Sdk createAlternativeJdk(@NotNull String jreHome) throws CantRunException
{
	final Sdk configuredJdk = SdkTable.getInstance().findSdk(jreHome);
	if(configuredJdk != null)
	{
		return configuredJdk;
	}

	if(!OwnJdkUtil.checkForJre(jreHome))
	{
		throw new CantRunException(JavaExecutionBundle.message("jre.path.is.not.valid.jre.home.error.message", jreHome));
	}

	final JavaSdk javaSdk = JavaSdk.getInstance();
	return javaSdk.createJdk(ObjectUtil.notNull(javaSdk.getVersionString(jreHome), ""), jreHome);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:17,代码来源:JavaParametersUtil.java


示例18: setupJVMCommandLine

import com.intellij.execution.CantRunException; //导入依赖的package包/类
public static GeneralCommandLine setupJVMCommandLine(@NotNull OwnSimpleJavaParameters javaParameters) throws CantRunException
{
	Sdk jdk = javaParameters.getJdk();
	if(jdk == null)
	{
		throw new CantRunException(ExecutionBundle.message("run.configuration.error.no.jdk.specified"));
	}
	SdkTypeId type = jdk.getSdkType();
	if(!(type instanceof JavaSdkType))
	{
		throw new CantRunException(ExecutionBundle.message("run.configuration.error.no.jdk.specified"));
	}

	GeneralCommandLine commandLine = new GeneralCommandLine();
	((JavaSdkType) type).setupCommandLine(commandLine, jdk);
	String exePath = commandLine.getExePath();
	if(exePath == null)
	{
		throw new CantRunException(ExecutionBundle.message("run.configuration.cannot.find.vm.executable"));
	}

	setupCommandLine(commandLine, javaParameters);
	return commandLine;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:25,代码来源:OwnJdkUtil.java


示例19: getMainClassParams

import com.intellij.execution.CantRunException; //导入依赖的package包/类
private static List<String> getMainClassParams(OwnSimpleJavaParameters javaParameters) throws CantRunException
{
	String mainClass = javaParameters.getMainClass();
	String moduleName = javaParameters.getModuleName();
	String jarPath = javaParameters.getJarPath();
	if(mainClass != null && moduleName != null)
	{
		return Arrays.asList("-m", moduleName + '/' + mainClass);
	}
	else if(mainClass != null)
	{
		return Collections.singletonList(mainClass);
	}
	else if(jarPath != null)
	{
		return Arrays.asList("-jar", jarPath);
	}
	else
	{
		throw new CantRunException(ExecutionBundle.message("main.class.is.not.specified.error.message"));
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:23,代码来源:OwnJdkUtil.java


示例20: configureByModule

import com.intellij.execution.CantRunException; //导入依赖的package包/类
public void configureByModule(final Module module, @MagicConstant(valuesFromClass = OwnJavaParameters.class) int classPathType, @Nullable Sdk jdk) throws CantRunException
{
	if((classPathType & JDK_ONLY) != 0)
	{
		if(jdk == null)
		{
			throw CantRunException.noJdkConfigured();
		}
		setJdk(jdk);
	}

	if((classPathType & CLASSES_ONLY) == 0)
	{
		return;
	}

	setDefaultCharset(module.getProject());
	configureEnumerator(OrderEnumerator.orderEntries(module).recursively(), classPathType, jdk).collectPaths(getClassPath());
	configureJavaLibraryPath(OrderEnumerator.orderEntries(module).recursively());
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:21,代码来源:OwnJavaParameters.java



注:本文中的com.intellij.execution.CantRunException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GlyphPage类代码示例发布时间:2022-05-22
下一篇:
Java OFTableFeaturePropNextTables类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap