当前位置: 首页>>代码示例>>Java>>正文


Java ConfigurationContext类代码示例

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


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

示例1: setupConfigurationFromContext

import com.intellij.execution.actions.ConfigurationContext; //导入依赖的package包/类
@Override
protected boolean setupConfigurationFromContext(AppleScriptRunConfiguration configuration, ConfigurationContext context, Ref<PsiElement> sourceElement) {
  PsiElement elem = context.getPsiLocation();
  PsiFile file = elem != null ? elem.getContainingFile() : null;
  if (file == null) return false;
  boolean shouldSetUp = file.getFileType() == AppleScriptFileType.INSTANCE;
  VirtualFile vFile = file.getVirtualFile();
  String scriptPath = vFile != null ? file.getVirtualFile().getPath() : null;
  if (scriptPath != null) {
    configuration.setScriptPath(scriptPath);
    String[] parts = scriptPath.split("/");
    if (parts.length > 0) {
      configuration.setName(parts[parts.length - 1]);
    }
  }
  return shouldSetUp;
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:18,代码来源:AppleScriptConfigurationProducer.java

示例2: setupConfigurationFromContext

import com.intellij.execution.actions.ConfigurationContext; //导入依赖的package包/类
@Override
protected boolean setupConfigurationFromContext(MuleConfiguration muleConfiguration, ConfigurationContext configurationContext, Ref<PsiElement> ref)
{
    final Location location = configurationContext.getLocation();
    if (location != null)
    {
        final boolean muleFile = MuleConfigUtils.isMuleFile(location.getPsiElement().getContainingFile());
        final Module module = configurationContext.getModule();
        if (muleFile && module != null)
        {
            muleConfiguration.setModule(module);
            muleConfiguration.setName(StringUtils.capitalize(module.getName()));
            return true;
        }
    }
    return false;
}
 
开发者ID:machaval,项目名称:mule-intellij-plugins,代码行数:18,代码来源:MuleApplicationConfigurationProducer.java

示例3: isConfigurationFromContext

import com.intellij.execution.actions.ConfigurationContext; //导入依赖的package包/类
@Override
public boolean isConfigurationFromContext(WeaveConfiguration muleConfiguration, ConfigurationContext configurationContext)
{
    final Module module = configurationContext.getModule();
    final PsiFile containingFile = configurationContext.getPsiLocation().getContainingFile();
    if (containingFile == null)
    {
        return false;
    }
    final String canonicalPath = containingFile.getVirtualFile().getCanonicalPath();
    final String weaveFile = muleConfiguration.getWeaveFile();
    if (weaveFile == null)
    {
        return false;
    }
    return module != null && module.equals(muleConfiguration.getModule()) && weaveFile.equals(canonicalPath);
}
 
开发者ID:machaval,项目名称:mule-intellij-plugins,代码行数:18,代码来源:WeaveConfigurationProducer.java

示例4: setupConfigurationFromContext

import com.intellij.execution.actions.ConfigurationContext; //导入依赖的package包/类
@Override
protected boolean setupConfigurationFromContext(TesterTestMethodRunConfiguration runConfiguration, ConfigurationContext context, Ref<PsiElement> ref) {
    PsiElement element = context.getPsiLocation();
    Method method = PhpPsiUtil.getParentByCondition(element, parent -> parent instanceof Method);

    if (method != null && isValid(method)) {
        VirtualFile file = method.getContainingFile().getVirtualFile();
        ref.set(method);

        if (!FileTypeManager.getInstance().isFileOfType(file, ScratchFileType.INSTANCE)) {
            VirtualFile root = ProjectRootManager.getInstance(element.getProject()).getFileIndex().getContentRootForFile(file);
            if (root == null) {
                return false;
            }
        }

        PhpScriptRunConfiguration.Settings settings = runConfiguration.getSettings();
        settings.setPath(file.getPresentableUrl());
        runConfiguration.setMethod(method);
        runConfiguration.setName(runConfiguration.suggestedName());
        return true;
    }

    return false;
}
 
开发者ID:jiripudil,项目名称:intellij-nette-tester,代码行数:26,代码来源:TesterTestMethodRunConfigurationProducer.java

示例5: isConfigurationFromContext

import com.intellij.execution.actions.ConfigurationContext; //导入依赖的package包/类
@Override
public boolean isConfigurationFromContext(TesterTestMethodRunConfiguration runConfiguration, ConfigurationContext context) {
    PsiElement element = context.getPsiLocation();
    Method method = PhpPsiUtil.getParentByCondition(element, parent -> parent instanceof Method);

    if (method != null && isValid(method)) {
        VirtualFile containingVirtualFile = method.getContainingFile().getVirtualFile();
        PhpScriptRunConfiguration.Settings settings = runConfiguration.getSettings();
        String path = settings.getPath();

        if (path != null) {
            VirtualFile configurationFile = LocalFileSystem.getInstance().findFileByPath(path);
            if (configurationFile != null) {
                return StringUtil.equals(containingVirtualFile.getPath(), configurationFile.getPath())
                    && runConfiguration.isMethod(method);
            }
        }
    }

    return false;
}
 
开发者ID:jiripudil,项目名称:intellij-nette-tester,代码行数:22,代码来源:TesterTestMethodRunConfigurationProducer.java

示例6: setupConfigurationFromContext

import com.intellij.execution.actions.ConfigurationContext; //导入依赖的package包/类
/**
 * Return true if it is relevant to display a MigrationRunConfiguration.
 *
 * As a side-effect, modify the basic PythonRunConfiguration with the
 * relevant script name and parameters.
 *
 * @param configuration The run configuration to setup.
 * @param context The context within which this is considered to be run.
 * @param sourceElement The source element at the caret.
 * @return A boolean signifying whether this configuration is relevant.
 */
@Override
protected boolean setupConfigurationFromContext(PythonRunConfiguration configuration,
                                                ConfigurationContext context,
                                                Ref<PsiElement> sourceElement) {
    VirtualFile managePyFile = MigrationUtils.getManagePyFile(context.getProject());
    if (managePyFile == null) return false;

    String params = MigrationUtils.generateScriptParameters(context);
    if (params == null) return false;

    configuration.setName(params);
    configuration.setScriptName(managePyFile.getPath());
    configuration.setScriptParameters(params);

    return true;
}
 
开发者ID:chornsby,项目名称:django-migrations-pycharm-plugin,代码行数:28,代码来源:MigrationRunConfigurationProducer.java

示例7: testProducedFromPsiDirectory

import com.intellij.execution.actions.ConfigurationContext; //导入依赖的package包/类
@Test
public void testProducedFromPsiDirectory() {
  PsiDirectory directory =
      workspace.createPsiDirectory(new WorkspacePath("java/com/google/test"));
  workspace.createPsiFile(
      new WorkspacePath("java/com/google/test/BUILD"), "java_test(name='unit_tests'");

  ConfigurationContext context = createContextFromPsi(directory);
  List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext();
  assertThat(configurations).hasSize(1);

  ConfigurationFromContext fromContext = configurations.get(0);
  assertThat(fromContext.isProducedBy(AllInPackageBlazeConfigurationProducer.class)).isTrue();
  assertThat(fromContext.getConfiguration()).isInstanceOf(BlazeCommandRunConfiguration.class);

  BlazeCommandRunConfiguration config =
      (BlazeCommandRunConfiguration) fromContext.getConfiguration();
  assertThat(config.getTarget())
      .isEqualTo(TargetExpression.fromStringSafe("//java/com/google/test/...:all"));
  assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST);
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:22,代码来源:AllInPackageBlazeConfigurationProducerTest.java

示例8: testNotProducedFromDirectoryWithoutTests

import com.intellij.execution.actions.ConfigurationContext; //导入依赖的package包/类
@Test
public void testNotProducedFromDirectoryWithoutTests() {
  MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot);
  builder.setTargetMap(
      TargetMapBuilder.builder()
          .addTarget(
              TargetIdeInfo.builder()
                  .setKind("java_test")
                  .setLabel("//java/com/google/test:TestClass")
                  .addSource(sourceRoot("java/com/google/test/TestClass.java"))
                  .build())
          .build());
  registerProjectService(
      BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build()));

  PsiDirectory directory =
      workspace.createPsiDirectory(new WorkspacePath("java/com/google/test"));

  ConfigurationContext context = createContextFromPsi(directory);
  assertThat(
          new MultipleJavaClassesTestConfigurationProducer()
              .createConfigurationFromContext(context))
      .isNull();
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:25,代码来源:MultipleJavaClassesTestConfigurationProducerTest.java

示例9: getIndirectlySelectedMethod

import com.intellij.execution.actions.ConfigurationContext; //导入依赖的package包/类
/**
 * Get a test method which is considered selected in the given context, belonging to a
 * non-abstract class. The context location may be the method itself, or anywhere inside the
 * method.
 *
 * @param context The context to search for a test method in.
 * @return A test method, or null if none are found.
 */
@Nullable
public static PsiMethod getIndirectlySelectedMethod(@NotNull ConfigurationContext context) {
  final Location<?> contextLocation = context.getLocation();
  if (contextLocation == null) {
    return null;
  }
  Iterator<Location<PsiMethod>> locationIterator =
      contextLocation.getAncestors(PsiMethod.class, false);
  while (locationIterator.hasNext()) {
    Location<PsiMethod> methodLocation = locationIterator.next();
    if (JUnitUtil.isTestMethod(methodLocation)) {
      return methodLocation.getPsiElement();
    }
  }
  return null;
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:25,代码来源:TestMethodSelectionUtil.java

示例10: setupConfigurationModule

import com.intellij.execution.actions.ConfigurationContext; //导入依赖的package包/类
protected boolean setupConfigurationModule(@Nullable ConfigurationContext context, ModuleBasedConfiguration configuration) {
  if (context != null) {
    final RunnerAndConfigurationSettings template =
      ((RunManagerImpl)context.getRunManager()).getConfigurationTemplate(getConfigurationFactory());
    final Module contextModule = context.getModule();
    final Module predefinedModule = ((ModuleBasedConfiguration)template.getConfiguration()).getConfigurationModule().getModule();
    if (predefinedModule != null) {
      configuration.setModule(predefinedModule);
      return true;
    }
    final Module module = findModule(configuration, contextModule);
    if (module != null) {
      configuration.setModule(module);
      return true;
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:JavaRuntimeConfigurationProducerBase.java

示例11: getTestFilter

import com.intellij.execution.actions.ConfigurationContext; //导入依赖的package包/类
private static Optional<String> getTestFilter(ConfigurationContext context) {
  RunConfiguration base = context.getOriginalConfiguration(null);
  if (!(base instanceof BlazeCommandRunConfiguration)) {
    return Optional.empty();
  }
  TargetExpression target = ((BlazeCommandRunConfiguration) base).getTarget();
  if (target == null) {
    return Optional.empty();
  }
  List<Location<?>> selectedElements = SmRunnerUtils.getSelectedSmRunnerTreeElements(context);
  if (selectedElements.isEmpty()) {
    return null;
  }
  Optional<BlazeTestEventsHandler> testEventsHandler =
      BlazeTestEventsHandler.getHandlerForTarget(context.getProject(), target);
  return testEventsHandler.map(
      handler -> handler.getTestFilter(context.getProject(), selectedElements));
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:19,代码来源:BlazeFilterExistingRunConfigurationProducer.java

示例12: checkPatterns

import com.intellij.execution.actions.ConfigurationContext; //导入依赖的package包/类
public PsiElement checkPatterns(ConfigurationContext context, LinkedHashSet<String> classes) {
  PsiElement[] result;
  final DataContext dataContext = context.getDataContext();
  if (TestsUIUtil.isMultipleSelectionImpossible(dataContext)) {
    return null;
  }
  final PsiElement[] locationElements = collectLocationElements(classes, dataContext);
  PsiElementProcessor.CollectElements<PsiElement> processor = new PsiElementProcessor.CollectElements<PsiElement>();
  if (locationElements != null) {
    collectTestMembers(locationElements, false, true, processor);
    result = processor.toArray();
  }
  else if (collectContextElements(dataContext, true, true, classes, processor)) {
    result = processor.toArray();
  }
  else {
    return null;
  }
  if (result.length <= 1) {
    return null;
  }
  return result[0];
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:AbstractPatternBasedConfigurationProducer.java

示例13: getTestClass

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

示例14: doSetupConfigFromContext

import com.intellij.execution.actions.ConfigurationContext; //导入依赖的package包/类
@Override
protected boolean doSetupConfigFromContext(
    BlazeCommandRunConfiguration configuration,
    ConfigurationContext context,
    Ref<PsiElement> sourceElement) {
  PsiFile file = getMainFile(context);
  if (file == null) {
    return false;
  }
  TargetInfo binaryTarget = getTargetLabel(file);
  if (binaryTarget == null) {
    return false;
  }
  configuration.setTargetInfo(binaryTarget);
  sourceElement.set(file);

  BlazeCommandRunConfigurationCommonState handlerState =
      configuration.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
  if (handlerState == null) {
    return false;
  }
  handlerState.getCommandState().setCommand(BlazeCommandName.RUN);
  configuration.setGeneratedName();
  return true;
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:26,代码来源:BlazeGoBinaryConfigurationProducer.java

示例15: doIsConfigFromContext

import com.intellij.execution.actions.ConfigurationContext; //导入依赖的package包/类
@Override
protected boolean doIsConfigFromContext(
    BlazeCommandRunConfiguration configuration, ConfigurationContext context) {

  PsiDirectory dir = getTestDirectory(context);
  if (dir == null) {
    return false;
  }
  WorkspaceRoot root = WorkspaceRoot.fromProject(context.getProject());
  WorkspacePath packagePath = getWorkspaceRelativeDirectoryPath(root, dir);
  if (packagePath == null) {
    return false;
  }
  BlazeCommandRunConfigurationCommonState handlerState =
      configuration.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
  if (handlerState == null) {
    return false;
  }
  return Objects.equals(handlerState.getCommandState().getCommand(), BlazeCommandName.TEST)
      && Objects.equals(
          configuration.getTarget(), TargetExpression.allFromPackageRecursive(packagePath));
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:23,代码来源:AllInPackageBlazeConfigurationProducer.java


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