本文整理汇总了Java中com.intellij.psi.PsiDirectory.getVirtualFile方法的典型用法代码示例。如果您正苦于以下问题:Java PsiDirectory.getVirtualFile方法的具体用法?Java PsiDirectory.getVirtualFile怎么用?Java PsiDirectory.getVirtualFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.PsiDirectory
的用法示例。
在下文中一共展示了PsiDirectory.getVirtualFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findContainingExtension
import com.intellij.psi.PsiDirectory; //导入方法依赖的package包/类
/**
* Traverses the given directories and returns the first valid
* extension definition that's applicable.
*
* @param directories List of directories to analyze
*/
public static TYPO3ExtensionDefinition findContainingExtension(PsiDirectory[] directories) {
for (PsiDirectory directory : directories) {
VirtualDirectoryImpl virtualFile = (VirtualDirectoryImpl) directory.getVirtualFile();
while (!isExtensionRootDirectory(virtualFile)) {
if (virtualFile.getParent() == null) {
return null;
}
virtualFile = virtualFile.getParent();
}
TYPO3ExtensionDefinition extensionDefinition = ExtensionDefinitionFactory.fromDirectory(virtualFile);
if (extensionDefinition != null) {
return extensionDefinition;
}
}
return null;
}
示例2: actionPerformed
import com.intellij.psi.PsiDirectory; //导入方法依赖的package包/类
public void actionPerformed(final AnActionEvent e) {
DataContext dataContext = e.getDataContext();
final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
if (view == null) return;
final PsiDirectory[] directories = view.getDirectories();
PsiDirectory currentDirectory = directories.length > 0 ? directories[0] : null;
final Project project = e.getData(CommonDataKeys.PROJECT);
if (project == null) return;
VirtualFile directoryFile = currentDirectory != null ? currentDirectory.getVirtualFile() : project.getBaseDir();
openLoadDirectoryDialog(project, directoryFile, null);
}
示例3: isValidFilePath
import com.intellij.psi.PsiDirectory; //导入方法依赖的package包/类
protected String isValidFilePath(@NotNull String fullFilePath, @NotNull PsiDirectory baseDirectory) {
String filePath = StringUtil.replace(
fullFilePath,
File.separator,
"/"
);
if(filePath.length() == 0) {
return PhpBundle.message(
"validation.file.not.valid.name",
fullFilePath);
} else {
List<String> split = StringUtil.split(filePath, "/");
if(split.size() == 0) {
return PhpBundle.message(
"validation.file.not.valid.name",
fullFilePath);
} else {
for (String aSplit : split) {
if (!PhpNameUtil.isValidFileName(aSplit)) {
return PhpBundle.message(
"validation.file.not.valid.name",
fullFilePath);
}
}
VirtualFile baseDirectoryFile = baseDirectory.getVirtualFile();
VirtualFile fileByRelativePath = baseDirectoryFile.findFileByRelativePath(
PhpNameUtil.trimStart(
filePath,
'/')
);
if (fileByRelativePath != null) {
return PhpBundle.message(
"validation.file.already.exists",
fullFilePath);
} else {
return null;
}
}
}
}