本文整理汇总了Java中com.intellij.execution.actions.ConfigurationContext.getPsiLocation方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationContext.getPsiLocation方法的具体用法?Java ConfigurationContext.getPsiLocation怎么用?Java ConfigurationContext.getPsiLocation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.execution.actions.ConfigurationContext
的用法示例。
在下文中一共展示了ConfigurationContext.getPsiLocation方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: 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
示例3: 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
示例4: setupConfigurationFromContext
import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
@Override
protected boolean setupConfigurationFromContext(TesterRunConfiguration runConfiguration, ConfigurationContext configurationContext, Ref<PsiElement> ref) {
PsiElement location = configurationContext.getPsiLocation();
if (location instanceof PsiDirectory) {
PsiDirectory directory = (PsiDirectory) location;
runConfiguration.getSettings().setTestScope(directory.getVirtualFile().getPresentableUrl());
runConfiguration.setGeneratedName(runConfiguration.suggestedName());
ref.set(directory);
return true;
}
if (location instanceof PhpFile) {
PhpFile phpFile = (PhpFile) location;
PhpClass testClass = PhpPsiUtil.findClass(phpFile, TesterUtil::isTestClass);
if (testClass == null) {
return false;
}
runConfiguration.getSettings().setTestScope(phpFile.getVirtualFile().getPresentableUrl());
runConfiguration.setGeneratedName(runConfiguration.suggestedName());
ref.set(phpFile);
return true;
}
return false;
}
示例5: isConfigurationFromContext
import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的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;
}
示例6: isConfigurationFromContext
import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的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;
}
示例7: setupConfigurationFromContext
import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
@Override
protected boolean setupConfigurationFromContext(TestNGConfiguration configuration,
ConfigurationContext context,
Ref<PsiElement> sourceElement) {
final PsiElement element = context.getPsiLocation();
PsiPackage aPackage = JavaRuntimeConfigurationProducerBase.checkPackage(element);
if (aPackage == null) {
return false;
}
final Location location = context.getLocation();
if (location == null) {
return false;
}
if (!LocationUtil.isJarAttached(location, aPackage, TestNGUtil.TEST_ANNOTATION_FQN)) {
return false;
}
final TestData data = configuration.data;
data.PACKAGE_NAME = aPackage.getQualifiedName();
data.TEST_OBJECT = TestType.PACKAGE.getType();
data.setScope(setupPackageConfiguration(context, configuration, data.getScope()));
configuration.setGeneratedName();
sourceElement.set(aPackage);
return true;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:AbstractTestNGPackageConfigurationProducer.java
示例8: setupConfigurationFromContext
import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
@Override
protected boolean setupConfigurationFromContext(TestNGConfiguration configuration,
ConfigurationContext context,
Ref<PsiElement> sourceElement) {
final PsiElement element = context.getPsiLocation();
final PsiFile containingFile = element != null ? element.getContainingFile() : null;
if (containingFile == null) return false;
final VirtualFile virtualFile = containingFile.getVirtualFile();
if (virtualFile == null || !virtualFile.isValid()) return false;
if (!TestNGUtil.isTestngXML(virtualFile)) return false;
RunnerAndConfigurationSettings settings = cloneTemplateConfiguration(context);
setupConfigurationModule(context, configuration);
final Module originalModule = configuration.getConfigurationModule().getModule();
configuration.getPersistantData().SUITE_NAME = virtualFile.getPath();
configuration.getPersistantData().TEST_OBJECT = TestType.SUITE.getType();
configuration.restoreOriginalModule(originalModule);
configuration.setGeneratedName();
settings.setName(configuration.getName());
sourceElement.set(containingFile);
return true;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:AbstractTestNGSuiteConfigurationProducer.java
示例9: setupConfigurationFromContext
import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
@Override
protected boolean setupConfigurationFromContext(JUnitConfiguration configuration,
ConfigurationContext context,
Ref<PsiElement> sourceElement) {
final Project project = configuration.getProject();
final PsiElement element = context.getPsiLocation();
if (!(element instanceof PsiDirectory)) return false;
final PsiPackage aPackage = JavaRuntimeConfigurationProducerBase.checkPackage(element);
if (aPackage == null) return false;
final VirtualFile virtualFile = ((PsiDirectory)element).getVirtualFile();
final Module module = ModuleUtilCore.findModuleForFile(virtualFile, project);
if (module == null) return false;
if (!ModuleRootManager.getInstance(module).getFileIndex().isInTestSourceContent(virtualFile)) return false;
int testRootCount = ModuleRootManager.getInstance(module).getSourceRoots(JavaSourceRootType.TEST_SOURCE).size();
if (testRootCount < 2) return false;
if (!LocationUtil.isJarAttached(context.getLocation(), aPackage, JUnitUtil.TESTCASE_CLASS)) return false;
setupConfigurationModule(context, configuration);
final JUnitConfiguration.Data data = configuration.getPersistentData();
data.setDirName(virtualFile.getPath());
data.TEST_OBJECT = JUnitConfiguration.TEST_DIRECTORY;
configuration.setGeneratedName();
return true;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:AbstractAllInDirectoryConfigurationProducer.java
示例10: isConfigurationFromContext
import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
@Override
public boolean isConfigurationFromContext(AppleScriptRunConfiguration configuration, ConfigurationContext context) {
PsiElement elem = context.getPsiLocation();
PsiFile file = elem != null ? elem.getContainingFile() : null;
if (file == null) return false;
VirtualFile currentFile = file.getVirtualFile();
boolean isSameFile = false;
if (currentFile != null) {
isSameFile = currentFile.getPath().equals(configuration.getScriptPath());
}
return isSameFile;
}
示例11: isConfigurationFromContext
import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
@Override
public boolean isConfigurationFromContext(TesterRunConfiguration runConfiguration, ConfigurationContext configurationContext) {
PsiElement location = configurationContext.getPsiLocation();
if (location instanceof PsiDirectory) {
PsiDirectory directory = (PsiDirectory) location;
return runConfiguration.getSettings().getTestScope().equals(directory.getVirtualFile().getPresentableUrl());
}
if (location instanceof PhpFile) {
PhpFile file = (PhpFile) location;
return runConfiguration.getSettings().getTestScope().equals(file.getVirtualFile().getPresentableUrl());
}
return false;
}
示例12: getTestDirectory
import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
@Nullable
private static PsiDirectory getTestDirectory(ConfigurationContext context) {
WorkspaceRoot root = WorkspaceRoot.fromProject(context.getProject());
PsiElement location = context.getPsiLocation();
if (!(location instanceof PsiDirectory)) {
return null;
}
PsiDirectory dir = (PsiDirectory) location;
return isInWorkspace(root, dir) && BlazePackage.hasBlazePackageChild(dir) ? dir : null;
}
示例13: getTestMethod
import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
private static PsiMethod getTestMethod(ConfigurationContext context) {
PsiElement psi = context.getPsiLocation();
if (psi instanceof PsiMethod
&& AnnotationUtil.isAnnotated((PsiMethod) psi, JUnitUtil.TEST_ANNOTATION, false)) {
return (PsiMethod) psi;
}
List<PsiMethod> selectedMethods = TestMethodSelectionUtil.getSelectedMethods(context);
return selectedMethods != null && selectedMethods.size() == 1 ? selectedMethods.get(0) : null;
}
示例14: setupConfigurationFromContext
import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
@Override
protected boolean setupConfigurationFromContext(TestNGConfiguration configuration,
ConfigurationContext context,
Ref<PsiElement> sourceElement) {
if (RunConfigurationProducer.getInstance(AbstractTestNGPatternConfigurationProducer.class).isMultipleElementsSelected(context)) {
return false;
}
final Location contextLocation = context.getLocation();
setupConfigurationParamName(configuration, contextLocation);
PsiClass psiClass = null;
PsiElement element = context.getPsiLocation();
while (element != null) {
if (element instanceof PsiClass && isTestNGClass((PsiClass)element)) {
psiClass = (PsiClass)element;
break;
}
else if (element instanceof PsiMember) {
psiClass = ((PsiMember)element).getContainingClass();
if (isTestNGClass(psiClass)) {
break;
}
}
else if (element instanceof PsiClassOwner) {
final PsiClass[] classes = ((PsiClassOwner)element).getClasses();
if (classes.length == 1) {
psiClass = classes[0];
break;
}
}
element = element.getParent();
}
if (!isTestNGClass(psiClass)) return false;
myPsiElement = psiClass;
final Project project = context.getProject();
RunnerAndConfigurationSettings settings = cloneTemplateConfiguration(context);
setupConfigurationModule(context, configuration);
final Module originalModule = configuration.getConfigurationModule().getModule();
configuration.setClassConfiguration(psiClass);
PsiMethod method = PsiTreeUtil.getParentOfType(context.getPsiLocation(), PsiMethod.class, false);
while (method != null) {
if (TestNGUtil.hasTest(method)) {
configuration.setMethodConfiguration(PsiLocation.fromPsiElement(project, method));
myPsiElement = method;
}
method = PsiTreeUtil.getParentOfType(method, PsiMethod.class);
}
configuration.restoreOriginalModule(originalModule);
settings.setName(configuration.getName());
sourceElement.set(myPsiElement);
return true;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:57,代码来源:AbstractTestNGInClassConfigurationProducer.java