本文整理汇总了Java中com.intellij.execution.actions.ConfigurationContext.getDataContext方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationContext.getDataContext方法的具体用法?Java ConfigurationContext.getDataContext怎么用?Java ConfigurationContext.getDataContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.execution.actions.ConfigurationContext
的用法示例。
在下文中一共展示了ConfigurationContext.getDataContext方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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
示例2: getDirectlySelectedMethods
import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
/**
* Get all test methods directly selected in the given context. This includes, for example,
* methods selected from the Structure panel. It does not include methods the context location is
* inside of. Note that methods may belong to different classes (possible if methods are selected
* from the Project panel with "Show Members" checked), and methods in abstract classes are not
* returned.
*
* @param context The context to get selected test methods from.
* @param allMustMatch If true, will return null if any selected elements are not test methods.
* @return A list of test methods (possibly empty), or null if:
* <ul>
* <li>There is no selection
* <li>{@code allMustMatch} is true, but elements other than test methods are selected
* </ul>
*/
@Nullable
public static List<PsiMethod> getDirectlySelectedMethods(
@NotNull ConfigurationContext context, boolean allMustMatch) {
final DataContext dataContext = context.getDataContext();
PsiElement[] elements = LangDataKeys.PSI_ELEMENT_ARRAY.getData(dataContext);
if (elements == null) {
return null;
}
List<PsiMethod> methods = new ArrayList<>();
for (PsiElement element : elements) {
if (element instanceof PsiMethod) {
PsiMethod method = (PsiMethod) element;
if (JUnitUtil.isTestMethod(PsiLocation.fromPsiElement(method))) {
methods.add(method);
} else if (allMustMatch) {
return null;
}
} else if (allMustMatch) {
return null;
}
}
return methods;
}
示例3: isMultipleElementsSelected
import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
public boolean isMultipleElementsSelected(ConfigurationContext context) {
final DataContext dataContext = context.getDataContext();
if (TestsUIUtil.isMultipleSelectionImpossible(dataContext)) return false;
final LinkedHashSet<String> classes = new LinkedHashSet<String>();
final PsiElementProcessor.CollectElementsWithLimit<PsiElement> processor = new PsiElementProcessor.CollectElementsWithLimit<PsiElement>(2);
final PsiElement[] locationElements = collectLocationElements(classes, dataContext);
if (locationElements != null) {
collectTestMembers(locationElements, false, false, processor);
}
else {
collectContextElements(dataContext, false, false, classes, processor);
}
return processor.getCollection().size() > 1;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:AbstractPatternBasedConfigurationProducer.java
示例4: isConfiguredFromContext
import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
public boolean isConfiguredFromContext(ConfigurationContext context, Set<String> patterns) {
final LinkedHashSet<String> classes = new LinkedHashSet<String>();
final DataContext dataContext = context.getDataContext();
if (TestsUIUtil.isMultipleSelectionImpossible(dataContext)) {
return false;
}
final PsiElement[] locationElements = collectLocationElements(classes, dataContext);
if (locationElements == null) {
collectContextElements(dataContext, true, false, classes, new PsiElementProcessor.CollectElements<PsiElement>());
}
if (Comparing.equal(classes, patterns)) {
return true;
}
return false;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:AbstractPatternBasedConfigurationProducer.java
示例5: isMultipleElementsSelected
import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
public static boolean isMultipleElementsSelected(ConfigurationContext context) {
final DataContext dataContext = context.getDataContext();
if (TestsUIUtil.isMultipleSelectionImpossible(dataContext)) {
return false;
}
final PsiElementProcessor.CollectElementsWithLimit<PsiElement> processor =
new PsiElementProcessor.CollectElementsWithLimit<PsiElement>(2);
final PsiElement[] locationElements = collectLocationElements(dataContext);
if (locationElements != null) {
collectTestMembers(locationElements, false, false, processor);
} else {
collectContextElements(dataContext, false, false, processor);
}
return processor.getCollection().size() > 1;
}
示例6: selectedTestClasses
import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
private static Set<PsiClass> selectedTestClasses(ConfigurationContext context) {
DataContext dataContext = context.getDataContext();
PsiElement[] elements = LangDataKeys.PSI_ELEMENT_ARRAY.getData(dataContext);
if (elements == null) {
return ImmutableSet.of();
}
return Arrays.stream(elements)
.map(JUnitUtil::getTestClass)
.filter(Objects::nonNull)
.filter(testClass -> !testClass.hasModifierProperty(PsiModifier.ABSTRACT))
.collect(Collectors.toSet());
}