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


Java ConfigurationContext.getLocation方法代码示例

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


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

示例1: 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

示例2: isConfigurationFromContext

import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
@Override
public boolean isConfigurationFromContext(AndroidRunConfiguration configuration, ConfigurationContext context) {
  final Location location = context.getLocation();

  if (location == null) {
    return false;
  }
  final PsiClass activity = getActivityClass(location, context);

  if (activity == null) {
    return false;
  }
  final String activityName = activity.getQualifiedName();

  if (activityName == null) {
    return false;
  }
  final Module contextModule = AndroidUtils.getAndroidModule(context);
  final Module confModule = configuration.getConfigurationModule().getModule();
  return Comparing.equal(contextModule, confModule) && activityName.equals(configuration.ACTIVITY_CLASS);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:AndroidConfigurationProducer.java

示例3: setupConfigurationFromContext

import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
@Override
protected boolean setupConfigurationFromContext(JUnitConfiguration configuration,
                                                ConfigurationContext context,
                                                Ref<PsiElement> sourceElement) {
  final LinkedHashSet<String> classes = new LinkedHashSet<String>();
  final PsiElement element = checkPatterns(context, classes);
  if (element == null) {
    return false;
  }
  sourceElement.set(element);
  final JUnitConfiguration.Data data = configuration.getPersistentData();
  data.setPatterns(classes);
  data.TEST_OBJECT = JUnitConfiguration.TEST_PATTERN;
  data.setScope(setupPackageConfiguration(context, configuration, data.getScope()));
  configuration.setGeneratedName();
  final Location contextLocation = context.getLocation();
  if (contextLocation instanceof PsiMemberParameterizedLocation) {
    final String paramSetName = ((PsiMemberParameterizedLocation)contextLocation).getParamSetName();
    if (paramSetName != null) {
      configuration.setProgramParameters(paramSetName);
    }
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:PatternConfigurationProducer.java

示例4: 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

示例5: getMainObject

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

示例6: getTestPath

import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
@Nullable
private static String getTestPath(@NotNull ConfigurationContext context) {
  Location location = context.getLocation();
  if (location == null) {
    return null;
  }
  VirtualFile file = location.getVirtualFile();
  if (file == null) {
    return null;
  }
  VirtualFile taskDir = StudyUtils.getTaskDir(file);
  if (taskDir == null) {
    return null;
  }

  Task task = StudyUtils.getTask(location.getProject(), taskDir);
  if (task == null) {
    return null;
  }
  String testsFileName = PyEduPluginConfigurator.getSubtaskTestsFileName(task instanceof TaskWithSubtasks ?
                                                                     ((TaskWithSubtasks)task).getActiveSubtaskIndex() : 0);
  String taskDirPath = FileUtil.toSystemDependentName(taskDir.getPath());
  String testsPath = taskDir.findChild(EduNames.SRC) != null ?
                     FileUtil.join(taskDirPath, EduNames.SRC, testsFileName) :
                     FileUtil.join(taskDirPath, testsFileName);
  String filePath = FileUtil.toSystemDependentName(file.getPath());
  return filePath.equals(testsPath) ? testsPath : null;
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:29,代码来源:PyCCRunTestsConfigurationProducer.java

示例7: generateScriptParameters

import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
/**
 * Generate the script parameters to pass into a PythonRunConfiguration.
 *
 * @param context The context for which to generate parameters.
 * @return The calculated script parameters or null.
 */
@Nullable
public static String generateScriptParameters(ConfigurationContext context) {
    Location location = context.getLocation();
    if (location == null) return null;

    VirtualFile migrationFile = location.getVirtualFile();
    if (migrationFile == null || !canPerformAction(migrationFile)) return null;

    String appName = getAppName(migrationFile);
    String migrationName = getMigrationName(migrationFile);

    return "migrate " + appName + " " + migrationName;
}
 
开发者ID:chornsby,项目名称:django-migrations-pycharm-plugin,代码行数:20,代码来源:MigrationUtils.java

示例8: selectedPsiElement

import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
/**
 * The single selected {@link PsiElement}. Returns null if we're in a SM runner tree UI context
 * (handled by a different producer).
 */
@Nullable
private static PsiElement selectedPsiElement(ConfigurationContext context) {
  List<Location<?>> selectedTestUiElements =
      SmRunnerUtils.getSelectedSmRunnerTreeElements(context);
  if (!selectedTestUiElements.isEmpty()) {
    return null;
  }
  Location<?> location = context.getLocation();
  return location != null ? location.getPsiElement() : null;
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:15,代码来源:BlazePyTestConfigurationProducer.java

示例9: getSingleJUnitTestClass

import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
/**
 * Returns the {@link TestLocation} corresponding to the single selected JUnit test class, or
 * {@code null} if something else is selected.
 */
@Nullable
private TestLocation getSingleJUnitTestClass(ConfigurationContext context) {
  Location<?> location = context.getLocation();
  if (location == null) {
    return null;
  }
  location = JavaExecutionUtil.stepIntoSingleClass(location);
  if (location == null) {
    return null;
  }

  // check for contexts handled by a different producer
  if (!SmRunnerUtils.getSelectedSmRunnerTreeElements(context).isEmpty()) {
    return null;
  }
  if (JUnitConfigurationUtil.isMultipleElementsSelected(context)) {
    return null;
  }
  if (JavaTestCaseIdentifier.isAnyTestCase(context)) {
    return null;
  }

  PsiClass testClass = JUnitUtil.getTestClass(location);
  if (testClass == null || testClass.hasModifierProperty(PsiModifier.ABSTRACT)) {
    return null;
  }

  TestSize testSize = TestSizeAnnotationMap.getTestSize(testClass);
  TargetInfo target = RunUtil.targetForTestClass(testClass, testSize);
  return target != null ? new TestLocation(testClass, target) : null;
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:36,代码来源:BlazeJavaTestClassConfigurationProducer.java

示例10: setupConfigurationFromContext

import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
@Override
protected boolean setupConfigurationFromContext(AbstractPythonTestRunConfiguration configuration,
                                                ConfigurationContext context,
                                                Ref<PsiElement> sourceElement) {
  if (context == null) return false;
  final Location location = context.getLocation();
  if (location == null || !isAvailable(location)) return false;
  PsiElement element = location.getPsiElement();
  if (element instanceof PsiWhiteSpace) {
    element = PyUtil.findNonWhitespaceAtOffset(element.getContainingFile(), element.getTextOffset());
  }

  if (PythonUnitTestRunnableScriptFilter.isIfNameMain(location)) return false;
  final Module module = location.getModule();
  if (!isPythonModule(module)) return false;

  if (element instanceof PsiDirectory) {
    return setupConfigurationFromFolder((PsiDirectory)element, configuration);
  }

  final PyFunction pyFunction = PsiTreeUtil.getParentOfType(element, PyFunction.class, false);
  if (pyFunction != null && isTestFunction(pyFunction, configuration)) {
    return setupConfigurationFromFunction(pyFunction, configuration);
  }
  final PyClass pyClass = PsiTreeUtil.getParentOfType(element, PyClass.class, false);
  if (pyClass != null && isTestClass(pyClass, configuration)) {
    return setupConfigurationFromClass(pyClass, configuration);
  }
  if (element == null) return false;
  final PsiFile file = element.getContainingFile();
  if (file instanceof PyFile && isTestFile((PyFile)file)) {
    return setupConfigurationFromFile((PyFile)file, configuration);
  }

  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:PythonTestConfigurationProducer.java

示例11: isConfigurationFromContext

import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
@Override
public boolean isConfigurationFromContext(AbstractPythonTestRunConfiguration configuration, ConfigurationContext context) {
  final Location location = context.getLocation();
  if (location == null) return false;
  if (!(configuration instanceof PyTestRunConfiguration)) return false;
  final PsiElement element = location.getPsiElement();

  final PsiFileSystemItem file = element instanceof PsiDirectory ? (PsiDirectory)element : element.getContainingFile();
  if (file == null) return false;
  final VirtualFile virtualFile = file.getVirtualFile();
  if (virtualFile == null) return false;

  if (file instanceof PyFile || file instanceof PsiDirectory) {
    final List<PyStatement> testCases = PyTestUtil.getPyTestCasesFromFile(file);
    if (testCases.isEmpty()) return false;
  } else return false;

  final Sdk sdk = PythonSdkType.findPythonSdk(context.getModule());
  if (sdk == null) return false;
  final String keywords = getKeywords(element, sdk);
  final String scriptName = ((PyTestRunConfiguration)configuration).getTestToRun();
  final String workingDirectory = configuration.getWorkingDirectory();
  final String path = virtualFile.getPath();
  final boolean isTestFileEquals = scriptName.equals(path) ||
                                   path.equals(new File(workingDirectory, scriptName).getAbsolutePath());

  final String configurationKeywords = ((PyTestRunConfiguration)configuration).getKeywords();
  return isTestFileEquals && (configurationKeywords.equals(keywords) ||
                              StringUtil.isEmptyOrSpaces(((PyTestRunConfiguration)configuration).getKeywords()) && keywords == null);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:PyTestConfigurationProducer.java

示例12: doSetupConfigFromContext

import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
@Override
protected boolean doSetupConfigFromContext(
    BlazeCommandRunConfiguration configuration,
    ConfigurationContext context,
    Ref<PsiElement> sourceElement) {

  Location<?> location = context.getLocation();
  if (location == null) {
    return false;
  }
  PsiElement element = location.getPsiElement();
  PsiFile file = element.getContainingFile();
  if (!(file instanceof PyFile)) {
    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,代码行数:32,代码来源:BlazePyBinaryConfigurationProducer.java

示例13: isConfigurationFromContext

import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
@Override
public boolean isConfigurationFromContext(PythonRunConfiguration configuration, ConfigurationContext context) {
  final Location location = context.getLocation();
  if (location == null) return false;
  final PsiFile script = location.getPsiElement().getContainingFile();
  if (!isAvailable(location, script)) return false;
  final VirtualFile virtualFile = script.getVirtualFile();
  if (virtualFile == null) return false;
  if (virtualFile instanceof LightVirtualFile) return false;
  final String workingDirectory = configuration.getWorkingDirectory();
  final String scriptName = configuration.getScriptName();
  final String path = virtualFile.getPath();
  return scriptName.equals(path) || path.equals(new File(workingDirectory, scriptName).getAbsolutePath());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:PythonRunConfigurationProducer.java

示例14: update

import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
@Override
public void update(@NotNull AnActionEvent e) {
  final Presentation presentation = e.getPresentation();
  if (!CCProjectService.setCCActionAvailable(e)) {
    presentation.setEnabledAndVisible(false);
    return;
  }

  presentation.setEnabledAndVisible(false);

  final ConfigurationContext context = ConfigurationContext.getFromContext(e.getDataContext());
  Location location = context.getLocation();
  if (location == null) {
    return;
  }
  PsiElement psiElement = location.getPsiElement();
  PsiFile psiFile = psiElement.getContainingFile();
  Project project = e.getProject();
  if (project == null || psiFile == null) {
    return;
  }
  TaskFile taskFile = CCProjectService.getInstance(project).getTaskFile(psiFile.getVirtualFile());
  if (taskFile == null) {
    return;
  }
  if (psiFile.getName().contains(".answer")) {
    presentation.setEnabledAndVisible(true);
    presentation.setText("Run tests from '" + FileUtil.getNameWithoutExtension(psiFile.getName()) + "'");
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:CCRunTestsAction.java

示例15: setupConfigurationFromContext

import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
@Override
protected boolean setupConfigurationFromContext(AndroidRunConfiguration configuration,
                                                ConfigurationContext context,
                                                Ref<PsiElement> sourceElement) {
  final Location location = context.getLocation();

  if (location == null) {
    return false;
  }
  final PsiClass activity = getActivityClass(location, context);

  if (activity == null) {
    return false;
  }
  final String activityName = activity.getQualifiedName();

  if (activityName == null) {
    return false;
  }
  sourceElement.set(activity);

  configuration.ACTIVITY_CLASS = activityName;
  configuration.MODE = AndroidRunConfiguration.LAUNCH_SPECIFIC_ACTIVITY;
  configuration.setName(JavaExecutionUtil.getPresentableClassName(configuration.ACTIVITY_CLASS));
  setupConfigurationModule(context, configuration);

  final TargetSelectionMode targetSelectionMode = AndroidUtils
    .getDefaultTargetSelectionMode(context.getModule(), AndroidRunConfigurationType.getInstance(),
                                   AndroidTestRunConfigurationType.getInstance());
  if (targetSelectionMode != null) {
    configuration.setTargetSelectionMode(targetSelectionMode);
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:AndroidConfigurationProducer.java


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