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

Java JavaExecutionUtil类代码示例

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

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



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

示例1: executeConfiguration

import com.intellij.execution.JavaExecutionUtil; //导入依赖的package包/类
public void executeConfiguration(Project project, ModuleBasedConfiguration appCon) {
    if (noProjectsAreOpen()) {
        logger.warn("No open projects found, can't execute the project.");
        return;
    }
    logger.info("Starting to build execution environment.");
    RunManager runManager = RunManager.getInstance(project);
    Executor executor = DefaultRunExecutor.getRunExecutorInstance();
    RunnerAndConfigurationSettingsImpl selectedConfiguration =
            getApplicationRunnerAndConfigurationSettings(runManager, appCon);
    ProgramRunner runner = getRunner(executor, selectedConfiguration);
    logger.info("Creating ExecutionEnvironment.");
    ExecutionEnvironment environment =
            new ExecutionEnvironment(
                    new DefaultRunExecutor(), runner, selectedConfiguration, project);
    try {
        logger.info("Executing project.");
        runner.execute(environment);
    } catch (ExecutionException e1) {
        JavaExecutionUtil.showExecutionErrorMessage(e1, "Error", project);
    }
}
 
开发者ID:testmycode,项目名称:tmc-intellij,代码行数:23,代码来源:ProjectExecutor.java


示例2: isConfigurationFromContext

import com.intellij.execution.JavaExecutionUtil; //导入依赖的package包/类
@Override
public boolean isConfigurationFromContext(T appConfiguration, ConfigurationContext context) {
  final PsiElement location = context.getPsiLocation();
  final PsiClass aClass = ApplicationConfigurationType.getMainClass(location);
  if (aClass != null && Comparing.equal(JavaExecutionUtil.getRuntimeQualifiedName(aClass), appConfiguration.MAIN_CLASS_NAME)) {
    final PsiMethod method = PsiTreeUtil.getParentOfType(location, PsiMethod.class, false);
    if (method != null && TestFrameworks.getInstance().isTestMethod(method)) {
      return false;
    }

    final Module configurationModule = appConfiguration.getConfigurationModule().getModule();
    if (Comparing.equal(context.getModule(), configurationModule)) return true;

    ApplicationConfiguration template =
      (ApplicationConfiguration)context.getRunManager().getConfigurationTemplate(getConfigurationFactory()).getConfiguration();
    final Module predefinedModule = template.getConfigurationModule().getModule();
    if (Comparing.equal(predefinedModule, configurationModule)) {
      return true;
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:ApplicationConfigurationProducer.java


示例3: ClassPackageAccessor

import com.intellij.execution.JavaExecutionUtil; //导入依赖的package包/类
public ClassPackageAccessor(final RefactoringListeners.Accessor<PsiClass> accessor) {
  myAccessor = accessor;
  PsiClass aClass = myAccessor.getPsiElement();
  aClass = (PsiClass)aClass.getOriginalElement();
  myContainingPackage = JavaDirectoryService.getInstance().getPackage(aClass.getContainingFile().getContainingDirectory());
  myModule = JavaExecutionUtil.findModule(aClass);
  final String classQName = aClass.getQualifiedName();
  final String classPackageQName = myContainingPackage.getQualifiedName();
  if (classQName.startsWith(classPackageQName)) {
    final String inpackageName = classQName.substring(classPackageQName.length());
    if (StringUtil.startsWithChar(inpackageName, '.')) {
      myInpackageName = inpackageName.substring(1);
    }
    else {
      myInpackageName = inpackageName;
    }
  }
  else {
    myInpackageName = null;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:RefactoringListeners.java


示例4: isConfigurationFromContext

import com.intellij.execution.JavaExecutionUtil; //导入依赖的package包/类
@Override
public boolean isConfigurationFromContext(JavaScratchConfiguration configuration, ConfigurationContext context) {
  final PsiElement location = context.getPsiLocation();
  final PsiClass aClass = ApplicationConfigurationType.getMainClass(location);
  if (aClass != null && Comparing.equal(JavaExecutionUtil.getRuntimeQualifiedName(aClass), configuration.MAIN_CLASS_NAME)) {
    // for scratches it is enough to check that the configuration is associated with the same scratch file
    final VirtualFile scratchFile = configuration.getScratchVirtualFile();
    if (scratchFile != null) {
      final PsiFile containingFile = aClass.getContainingFile();
      if (containingFile != null && scratchFile.equals(containingFile.getVirtualFile())) {
        return true;
      }
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:JavaScratchConfigurationProducer.java


示例5: isClassInProductionSources

import com.intellij.execution.JavaExecutionUtil; //导入依赖的package包/类
@Nullable("null if class not found")
public static Boolean isClassInProductionSources(@NotNull String mainClassName, @NotNull Module module) {
  final PsiClass psiClass = JavaExecutionUtil.findMainClass(module, mainClassName);
  if (psiClass == null) {
    return null;
  }
  final PsiFile psiFile = psiClass.getContainingFile();
  if (psiFile == null) return null;
  final VirtualFile virtualFile = psiFile.getVirtualFile();
  if (virtualFile == null) return null;
  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);
  }
  final List<OrderEntry> entriesForFile = fileIndex.getOrderEntriesForFile(virtualFile);
  for (OrderEntry entry : entriesForFile) {
    if (entry instanceof ExportableOrderEntry && ((ExportableOrderEntry)entry).getScope() == DependencyScope.TEST) {
      return false;
    }
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:JavaParametersUtil.java


示例6: isAppletClass

import com.intellij.execution.JavaExecutionUtil; //导入依赖的package包/类
private static boolean isAppletClass(final PsiClass aClass, final PsiManager manager) {
  if (!PsiClassUtil.isRunnableClass(aClass, true)) return false;

  final Module module = JavaExecutionUtil.findModule(aClass);
  final GlobalSearchScope scope = module != null
                            ? GlobalSearchScope.moduleWithLibrariesScope(module)
                            : GlobalSearchScope.projectScope(manager.getProject());
  PsiClass appletClass = JavaPsiFacade.getInstance(manager.getProject()).findClass("java.applet.Applet", scope);
  if (appletClass != null) {
    if (aClass.isInheritor(appletClass, true)) return true;
  }
  appletClass = JavaPsiFacade.getInstance(manager.getProject()).findClass("javax.swing.JApplet", scope);
  if (appletClass != null) {
    if (aClass.isInheritor(appletClass, true)) return true;
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:AppletConfigurationProducer.java


示例7: getActivityClass

import com.intellij.execution.JavaExecutionUtil; //导入依赖的package包/类
@Nullable
private static PsiClass getActivityClass(Location location, ConfigurationContext context) {
  final Module module = context.getModule();
  if (module == null) return null;
  location = JavaExecutionUtil.stepIntoSingleClass(location);
  if (location == null) {
    return null;
  }
  PsiElement element = location.getPsiElement();
  JavaPsiFacade facade = JavaPsiFacade.getInstance(element.getProject());
  GlobalSearchScope scope = module.getModuleWithDependenciesAndLibrariesScope(true);
  PsiClass activityClass = facade.findClass(AndroidUtils.ACTIVITY_BASE_CLASS_NAME, scope);
  if (activityClass == null) return null;

  PsiClass elementClass = PsiTreeUtil.getParentOfType(element, PsiClass.class, false);
  while (elementClass != null) {
    if (elementClass.isInheritor(activityClass, true)) {
      return elementClass;
    }
    elementClass = PsiTreeUtil.getParentOfType(elementClass, PsiClass.class);
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:AndroidConfigurationProducer.java


示例8: getRefactoringElementListener

import com.intellij.execution.JavaExecutionUtil; //导入依赖的package包/类
@Override
@Nullable
public RefactoringElementListener getRefactoringElementListener(PsiElement element) {
  return RefactoringListeners.getClassOrPackageListener(element, new RefactoringListeners.Accessor<PsiClass>() {
    @Override
    public void setName(String qualifiedName) {
      ACTIVITY_CLASS = qualifiedName;
    }

    @Nullable
    @Override
    public PsiClass getPsiElement() {
      return getConfigurationModule().findClass(ACTIVITY_CLASS);
    }

    @Override
    public void setPsiElement(PsiClass psiClass) {
      ACTIVITY_CLASS = JavaExecutionUtil.getRuntimeQualifiedName(psiClass);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:AndroidRunConfiguration.java


示例9: selectListenerClass

import com.intellij.execution.JavaExecutionUtil; //导入依赖的package包/类
@Nullable
protected String selectListenerClass() {
  GlobalSearchScope searchScope = getSearchScope(config.getModules());
  if (searchScope == null) {
    searchScope = GlobalSearchScope.allScope(project);
  }
  final TestListenerFilter filter = new TestListenerFilter(searchScope, project);

  TreeClassChooser chooser = TreeClassChooserFactory.getInstance(project)
    .createWithInnerClassesScopeChooser("Choose Listener Class", filter.getScope(), filter, null);
  chooser.showDialog();
  PsiClass psiclass = chooser.getSelected();
  if (psiclass == null) {
    return null;
  }
  else {
    return JavaExecutionUtil.getRuntimeQualifiedName(psiclass);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:TestNGConfigurationEditor.java


示例10: isConfiguredByElement

import com.intellij.execution.JavaExecutionUtil; //导入依赖的package包/类
@Override
public boolean isConfiguredByElement(final JUnitConfiguration configuration,
                                     PsiClass testClass,
                                     PsiMethod testMethod,
                                     PsiPackage testPackage,
                                     PsiDirectory testDir) {

  if (testClass == null) {
    return false;
  }
  if (testMethod != null) {
    // 'test class' configuration is not equal to the 'test method' configuration!
    return false;
  }
  return Comparing.equal(JavaExecutionUtil.getRuntimeQualifiedName(testClass), configuration.getPersistentData().getMainClassName());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:TestClass.java


示例11: checkConfiguration

import com.intellij.execution.JavaExecutionUtil; //导入依赖的package包/类
@Override
public void checkConfiguration() throws RuntimeConfigurationException {
  final JUnitConfiguration.Data data = getConfiguration().getPersistentData();
  final Set<String> patterns = data.getPatterns();
  if (patterns.isEmpty()) {
    throw new RuntimeConfigurationWarning("No pattern selected");
  }
  final GlobalSearchScope searchScope = GlobalSearchScope.allScope(getConfiguration().getProject());
  for (String pattern : patterns) {
    final String className = pattern.contains(",") ? StringUtil.getPackageName(pattern, ',') : pattern;
    final PsiClass psiClass = JavaExecutionUtil.findMainClass(getConfiguration().getProject(), className, searchScope);
    if (psiClass != null && !JUnitUtil.isTestClass(psiClass)) {
      throw new RuntimeConfigurationWarning("Class " + className + " not a test");
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:TestsPattern.java


示例12: createConfiguration

import com.intellij.execution.JavaExecutionUtil; //导入依赖的package包/类
@Nullable
private RunnerAndConfigurationSettings createConfiguration(@Nullable final PsiClass aClass) {
  if (aClass == null) return null;

  final Project project = aClass.getProject();
  RunnerAndConfigurationSettings settings = RunManagerEx.getInstanceEx(project).createConfiguration("", getConfigurationFactory());
  final GroovyScriptRunConfiguration configuration = (GroovyScriptRunConfiguration)settings.getConfiguration();
  final PsiFile file = aClass.getContainingFile().getOriginalFile();
  final PsiDirectory dir = file.getContainingDirectory();
  if (dir != null) {
    configuration.setWorkDir(dir.getVirtualFile().getPath());
  }
  final VirtualFile vFile = file.getVirtualFile();
  if (vFile == null) return null;
  String path = ScriptFileUtil.getScriptFilePath(vFile);
  configuration.setScriptPath(path);
  RunConfigurationModule module = configuration.getConfigurationModule();

  String name = GroovyRunnerUtil.getConfigurationName(aClass, module);
  configuration.setName(StringUtil.isEmpty(name) ? vFile.getName() : name);
  configuration.setModule(JavaExecutionUtil.findModule(aClass));
  return settings;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:GroovyScriptRunConfigurationProducer.java


示例13: findClass

import com.intellij.execution.JavaExecutionUtil; //导入依赖的package包/类
@Override
protected PsiClass findClass(String className) {
  final Set<Module> modules = ApplicationManager.getApplication().runReadAction(new Computable<Set<Module>>() {
    @Override
    public Set<Module> compute() {
      return ArtifactUtil.getModulesIncludedInArtifacts(Collections.singletonList(myArtifact), getProject());
    }
  });
  for (Module module : modules) {
    final PsiClass aClass = JavaExecutionUtil.findMainClass(getProject(), className, GlobalSearchScope.moduleScope(module));
    if (aClass != null) {
      return aClass;
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:JavaFxApplicationClassBrowser.java


示例14: getMainClass

import com.intellij.execution.JavaExecutionUtil; //导入依赖的package包/类
@Nullable
private static PsiClass getMainClass(ConfigurationContext context) {
  Location location = context.getLocation();
  if (location == null) {
    return null;
  }
  location = JavaExecutionUtil.stepIntoSingleClass(location);
  if (location == null) {
    return null;
  }
  PsiElement element = location.getPsiElement();
  if (!element.isPhysical()) {
    return null;
  }
  return ApplicationConfigurationType.getMainClass(element);
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:17,代码来源:BlazeJavaMainClassRunConfigurationProducer.java


示例15: getTestClass

import com.intellij.execution.JavaExecutionUtil; //导入依赖的package包/类
@Nullable
private static ScClass getTestClass(ConfigurationContext context) {
  Location<?> location = context.getLocation();
  if (location == null) {
    return null;
  }
  location = JavaExecutionUtil.stepIntoSingleClass(location);
  if (location == null) {
    return null;
  }
  if (!SmRunnerUtils.getSelectedSmRunnerTreeElements(context).isEmpty()) {
    // handled by a different producer
    return null;
  }
  return getTestClass(location);
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:17,代码来源:BlazeScalaTestClassConfigurationProducer.java


示例16: getMainObject

import com.intellij.execution.JavaExecutionUtil; //导入依赖的package包/类
@Nullable
private static ScObject getMainObject(ConfigurationContext context) {
  Location location = context.getLocation();
  if (location == null) {
    return null;
  }
  location = JavaExecutionUtil.stepIntoSingleClass(context.getLocation());
  if (location == null) {
    return null;
  }
  PsiElement element = location.getPsiElement();
  if (!(element.getContainingFile() instanceof ScalaFile)) {
    return null;
  }
  if (!element.isPhysical()) {
    return null;
  }
  return getMainObjectFromElement(element);
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:20,代码来源:BlazeScalaMainClassRunConfigurationProducer.java


示例17: isValidMainClass

import com.intellij.execution.JavaExecutionUtil; //导入依赖的package包/类
public static boolean isValidMainClass(@Nullable final Module module, @Nullable final String className) {
  if(module == null || className == null) {
    return false;
  }

  final DefracFacet facet = DefracFacet.getInstance(module);

  if(facet == null) {
    return false;
  }

  if(facet.getPlatform().isAndroid()) {
    final PsiClass psiClass = JavaPsiFacade.getInstance(module.getProject()).findClass(className, module.getModuleScope());

    return psiClass != null && findActivityClass(module, psiClass) != null;
  }

  return JavaExecutionUtil.findMainClass(module.getProject(), className, module.getModuleScope()) != null;
}
 
开发者ID:defrac,项目名称:defrac-plugin-intellij,代码行数:20,代码来源:DefracRunUtil.java


示例18: isConfigurationFromContext

import com.intellij.execution.JavaExecutionUtil; //导入依赖的package包/类
@Override
public boolean isConfigurationFromContext(ApplicationConfiguration appConfiguration, ConfigurationContext context) {
  final PsiClass aClass = ApplicationConfigurationType.getMainClass(context.getPsiLocation());
  if (aClass != null && Comparing.equal(JavaExecutionUtil.getRuntimeQualifiedName(aClass), appConfiguration.MAIN_CLASS_NAME)) {
    final Module configurationModule = appConfiguration.getConfigurationModule().getModule();
    if (Comparing.equal(context.getModule(), configurationModule)) return true;

    ApplicationConfiguration template = (ApplicationConfiguration)context.getRunManager()
      .getConfigurationTemplate(getConfigurationFactory())
      .getConfiguration();
    final Module predefinedModule = template.getConfigurationModule().getModule();
    if (Comparing.equal(predefinedModule, configurationModule)) {
      return true;
    }
  }
  return false;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:ApplicationConfigurationProducer.java


示例19: showDialog

import com.intellij.execution.JavaExecutionUtil; //导入依赖的package包/类
@Nullable
protected String showDialog() {
  final ClassFilter.ClassFilterWithScope classFilter;
  try {
    classFilter = getFilter();
  }
  catch (NoFilterException e) {
    final MessagesEx.MessageInfo info = e.getMessageInfo();
    info.showNow();
    return null;
  }
  final TreeClassChooser dialog = createClassChooser(classFilter);
  configureDialog(dialog);
  dialog.showDialog();
  final PsiClass psiClass = dialog.getSelected();
  if (psiClass == null) return null;
  onClassChoosen(psiClass);
  return JavaExecutionUtil.getRuntimeQualifiedName(psiClass);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:ClassBrowser.java


示例20: getClasspathType

import com.intellij.execution.JavaExecutionUtil; //导入依赖的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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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