本文整理匯總了Java中com.intellij.openapi.vfs.VfsUtil.getPath方法的典型用法代碼示例。如果您正苦於以下問題:Java VfsUtil.getPath方法的具體用法?Java VfsUtil.getPath怎麽用?Java VfsUtil.getPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.openapi.vfs.VfsUtil
的用法示例。
在下文中一共展示了VfsUtil.getPath方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: runOrApplyMavenProjectFileTemplate
import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
public static void runOrApplyMavenProjectFileTemplate(Project project,
VirtualFile file,
@NotNull MavenId projectId,
MavenId parentId,
VirtualFile parentFile,
boolean interactive) throws IOException {
Properties properties = new Properties();
Properties conditions = new Properties();
properties.setProperty("GROUP_ID", projectId.getGroupId());
properties.setProperty("ARTIFACT_ID", projectId.getArtifactId());
properties.setProperty("VERSION", projectId.getVersion());
if (parentId != null) {
conditions.setProperty("HAS_PARENT", "true");
properties.setProperty("PARENT_GROUP_ID", parentId.getGroupId());
properties.setProperty("PARENT_ARTIFACT_ID", parentId.getArtifactId());
properties.setProperty("PARENT_VERSION", parentId.getVersion());
if (parentFile != null) {
VirtualFile modulePath = file.getParent();
VirtualFile parentModulePath = parentFile.getParent();
if (!Comparing.equal(modulePath.getParent(), parentModulePath)) {
String relativePath = VfsUtil.getPath(file, parentModulePath, '/');
if (relativePath != null) {
if (relativePath.endsWith("/")) relativePath = relativePath.substring(0, relativePath.length() - 1);
conditions.setProperty("HAS_RELATIVE_PATH", "true");
properties.setProperty("PARENT_RELATIVE_PATH", relativePath);
}
}
}
}
runOrApplyFileTemplate(project, file, MavenFileTemplateGroupFactory.MAVEN_PROJECT_XML_TEMPLATE, properties, conditions, interactive);
}
示例2: compatibleGetPath
import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
@Nullable
private static String compatibleGetPath(VirtualFile file, VirtualFile virtualFile) {
try {
return VfsUtil.getPath(file, virtualFile, File.separatorChar);
} catch (Exception e) {
// ensure compatibility between 5.0.2 and 5.0.3+ as there are different exception signatures of VfsUtil.getPath()
throw new Error(e);
}
}