本文整理汇总了Java中com.intellij.openapi.vfs.VirtualFile.getCanonicalPath方法的典型用法代码示例。如果您正苦于以下问题:Java VirtualFile.getCanonicalPath方法的具体用法?Java VirtualFile.getCanonicalPath怎么用?Java VirtualFile.getCanonicalPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.vfs.VirtualFile
的用法示例。
在下文中一共展示了VirtualFile.getCanonicalPath方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findFileModules
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@NotNull
public static List<PsiFile> findFileModules(@NotNull Project project, String extension, @NotNull String name, boolean exact) {
ArrayList<PsiFile> result = new ArrayList<>();
Bucklescript bucklescript = BucklescriptProjectComponent.getInstance(project);
PsiManager psiManager = PsiManager.getInstance(project);
Collection<VirtualFile> files = FilenameIndex.getAllFilesByExt(project, extension);
for (VirtualFile vFile : files) {
String canonicalPath = vFile.getCanonicalPath();
if (bucklescript.isDependency(canonicalPath)) {
FileBase file = (FileBase) psiManager.findFile(vFile);
if (file != null) {
String fileModuleName = file.asModuleName();
boolean found = exact ? fileModuleName.equals(name) : fileModuleName.startsWith(name);
if (found) {
result.add(file);
}
}
}
}
return result;
}
示例2: getProjectForFile
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
/**
* Look through all open projects and see if git head symlink file is contained in it.
*/
private Project getProjectForFile(VirtualFile gitHeadFile) {
//
for (Project project : ProjectManager.getInstance().getOpenProjects()) {
try {
VirtualFile[] contentRootArray = ProjectRootManager.getInstance(project).getContentRoots();
for (VirtualFile virtualFile : contentRootArray) {
String expectedLoc = virtualFile.getCanonicalPath() + "/.git/HEAD";
if (expectedLoc.equals(gitHeadFile.getCanonicalPath())) {
return project;
}
}
} catch (Exception e) {
// ignore
}
}
return null;
}
示例3: getBinaryPath
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@Nullable
public static String getBinaryPath(Project project, String binary) {
if (binary == null) {
return null;
}
if (new File(binary).isAbsolute()) {
return binary;
}
VirtualFile baseDir = Platform.findBaseRoot(project);
VirtualFile absoluteBinary = baseDir.findFileByRelativePath(binary);
return absoluteBinary == null ? null : absoluteBinary.getCanonicalPath();
}
示例4: getPropertyValue
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
public static String getPropertyValue(String key, boolean isOptional) {
if (key == null) {
return "";
}
VirtualFile baseDir = ProjectManager.getInstance().getOpenProjects()[0].getBaseDir();
if (baseDir == null || !baseDir.isDirectory()) {
System.out.println("Base dir not exist");
return "";
}
Properties properties = new Properties();
String value = null;
try {
VirtualFile crowdinProperties = baseDir.findChild(PROPERTIES_FILE);
if (crowdinProperties == null) {
showInformationMessage("File '" + PROPERTIES_FILE + "' with Crowdin plugin configuration doesn't exist in project root directory");
LOGGER.info("File '" + PROPERTIES_FILE + "' with Crowdin plugin configuration doesn't exist in project root directory");
return "";
}
InputStream in = new FileInputStream(crowdinProperties.getCanonicalPath());
properties.load(in);
in.close();
} catch (Exception e) {
e.printStackTrace();
}
if (properties != null && properties.get(key) != null) {
value = properties.get(key).toString();
} else if (!isOptional) {
showInformationMessage("Check does property '" + key + "' exist in your configuration file '" + PROPERTIES_FILE + "'");
LOGGER.info("Check does property '" + key + "' exist in your configuration file '" + PROPERTIES_FILE + "'");
}
return value;
}
示例5: isTemplateFile
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
public static boolean isTemplateFile(VirtualFile vFile) {
return vFile != null && vFile.getCanonicalPath() != null &&
vFile.getCanonicalPath().replace('\\', '/').startsWith(CptUtil.getTemplatesPath().getAbsolutePath().replace('\\', '/'));
}