本文整理汇总了Java中com.intellij.ide.projectView.impl.ProjectRootsUtil.isSourceRoot方法的典型用法代码示例。如果您正苦于以下问题:Java ProjectRootsUtil.isSourceRoot方法的具体用法?Java ProjectRootsUtil.isSourceRoot怎么用?Java ProjectRootsUtil.isSourceRoot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.ide.projectView.impl.ProjectRootsUtil
的用法示例。
在下文中一共展示了ProjectRootsUtil.isSourceRoot方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLocationString
import com.intellij.ide.projectView.impl.ProjectRootsUtil; //导入方法依赖的package包/类
@Nullable
@RequiredReadAction
public static String getLocationString(@Nonnull PsiDirectory psiDirectory) {
PsiPackage aPackage = PsiPackageManager.getInstance(psiDirectory.getProject()).findAnyPackage(psiDirectory);
if (ProjectRootsUtil.isSourceRoot(psiDirectory) && aPackage != null) {
return aPackage.getQualifiedName();
}
final VirtualFile directory = psiDirectory.getVirtualFile();
final VirtualFile contentRootForFile = ProjectRootManager.getInstance(psiDirectory.getProject()).getFileIndex().getContentRootForFile(directory);
if (Comparing.equal(contentRootForFile, psiDirectory)) {
return PathUtil.toPresentableUrl(directory.getUrl());
}
return null;
}
示例2: getNodeName
import com.intellij.ide.projectView.impl.ProjectRootsUtil; //导入方法依赖的package包/类
@Nonnull
@RequiredReadAction
public static String getNodeName(ViewSettings settings, Object parentValue, @Nonnull PsiDirectory directory) {
Project project = directory.getProject();
PsiPackage aPackage = PsiPackageManager.getInstance(project).findAnyPackage(directory);
String name = directory.getName();
VirtualFile dirFile = directory.getVirtualFile();
if (dirFile.getFileSystem() instanceof ArchiveFileSystem && dirFile.getParent() == null) {
VirtualFile virtualFileForArchive = ArchiveVfsUtil.getVirtualFileForArchive(dirFile);
if (virtualFileForArchive != null) {
name = virtualFileForArchive.getName();
}
}
PsiPackage parentPackage;
if (!ProjectRootsUtil.isSourceRoot(directory) && aPackage != null && !aPackage.getQualifiedName().isEmpty() &&
parentValue instanceof PsiDirectory) {
parentPackage = PsiPackageManager.getInstance(project).findAnyPackage(((PsiDirectory)parentValue));
}
else if (ProjectRootsUtil.isSourceRoot(directory) && aPackage != null) { //package prefix
aPackage = null;
parentPackage = null;
}
else {
parentPackage = null;
}
return TreeViewUtil.getNodeName(settings, aPackage, parentPackage, name, isShowFQName(project, settings, parentValue, directory));
}