本文整理汇总了Java中com.intellij.execution.Location.getVirtualFile方法的典型用法代码示例。如果您正苦于以下问题:Java Location.getVirtualFile方法的具体用法?Java Location.getVirtualFile怎么用?Java Location.getVirtualFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.execution.Location
的用法示例。
在下文中一共展示了Location.getVirtualFile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTestSpec
import com.intellij.execution.Location; //导入方法依赖的package包/类
public String getTestSpec(Location location) {
PsiElement element = location.getPsiElement();
PyClass pyClass = PsiTreeUtil.getParentOfType(element, PyClass.class, false);
PyFunction pyFunction = PsiTreeUtil.getParentOfType(element, PyFunction.class, false);
final VirtualFile virtualFile = location.getVirtualFile();
if (virtualFile != null) {
String path = virtualFile.getCanonicalPath();
if (pyClass != null) {
path += "::" + pyClass.getName();
}
if (pyFunction != null) {
path += "::" + pyFunction.getName();
}
return path;
}
return null;
}
示例2: getTestPath
import com.intellij.execution.Location; //导入方法依赖的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;
}
示例3: generateScriptParameters
import com.intellij.execution.Location; //导入方法依赖的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;
}
示例4: getJarFileFromContext
import com.intellij.execution.Location; //导入方法依赖的package包/类
@Nullable
private static VirtualFile getJarFileFromContext(ConfigurationContext context) {
Location location = context.getLocation();
if (location == null) return null;
VirtualFile file = location.getVirtualFile();
return file != null && FileUtilRt.extensionEquals(file.getName(), "jar") ? file : null;
}
示例5: setupConfigurationFromContext
import com.intellij.execution.Location; //导入方法依赖的package包/类
@Override
protected boolean setupConfigurationFromContext(JavaScratchConfiguration configuration, ConfigurationContext context, Ref<PsiElement> sourceElement) {
final Location location = context.getLocation();
if (location != null) {
final VirtualFile vFile = location.getVirtualFile();
if (vFile instanceof VirtualFileWithId && vFile.getFileType() == ScratchFileType.INSTANCE) {
final PsiFile psiFile = location.getPsiElement().getContainingFile();
if (psiFile != null && psiFile.getLanguage() == JavaLanguage.INSTANCE) {
configuration.SCRATCH_FILE_ID = ((VirtualFileWithId)vFile).getId();
return super.setupConfigurationFromContext(configuration, context, sourceElement);
}
}
}
return false;
}