本文整理汇总了Java中com.intellij.psi.PsiFileSystemItem.getParent方法的典型用法代码示例。如果您正苦于以下问题:Java PsiFileSystemItem.getParent方法的具体用法?Java PsiFileSystemItem.getParent怎么用?Java PsiFileSystemItem.getParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.PsiFileSystemItem
的用法示例。
在下文中一共展示了PsiFileSystemItem.getParent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fileMatchesPathPrefix
import com.intellij.psi.PsiFileSystemItem; //导入方法依赖的package包/类
private static boolean fileMatchesPathPrefix(@Nullable final PsiFileSystemItem file, @NotNull final List<String> pathPrefix) {
if (file == null) return false;
final List<String> contextParts = new ArrayList<String>();
PsiFileSystemItem parentFile = file;
PsiFileSystemItem parent;
while ((parent = parentFile.getParent()) != null) {
if (parent.getName().length() > 0) contextParts.add(0, parent.getName().toLowerCase());
parentFile = parent;
}
final String path = StringUtil.join(contextParts, "/");
int nextIndex = 0;
for (@NonNls final String s : pathPrefix) {
if ((nextIndex = path.indexOf(s.toLowerCase(), nextIndex)) == -1) return false;
}
return true;
}
示例2: calcPropertyValue
import com.intellij.psi.PsiFileSystemItem; //导入方法依赖的package包/类
@Nullable
protected final String calcPropertyValue(String propertyName) {
final PsiFileSystemItem fsItem = getFile().getValue();
if (fsItem != null) {
final PsiFileSystemItem parent = fsItem.getParent();
if (parent != null) {
final VirtualFile vFile = parent.getVirtualFile();
if (vFile != null) {
return FileUtil.toSystemDependentName(vFile.getPath());
}
}
}
// according to the doc, defaulting to project's current dir
final String projectBasedirPath = getContextAntProject().getProjectBasedirPath();
if (projectBasedirPath == null) {
return null;
}
return FileUtil.toSystemDependentName(projectBasedirPath);
}
示例3: getContexts
import com.intellij.psi.PsiFileSystemItem; //导入方法依赖的package包/类
@Override
@NotNull
public Collection<PsiFileSystemItem> getContexts(final Project project, @NotNull final VirtualFile file) {
final PsiFileSystemItem item = getPsiFileSystemItem(project, file);
if (item != null) {
final PsiFileSystemItem parent = item.getParent();
if (parent != null) {
return Collections.singleton(parent);
}
}
return Collections.emptyList();
}
示例4: getPathComponents
import com.intellij.psi.PsiFileSystemItem; //导入方法依赖的package包/类
static PsiFileSystemItem[] getPathComponents(PsiFileSystemItem file) {
LinkedList<PsiFileSystemItem> componentsList = new LinkedList<PsiFileSystemItem>();
while (file != null) {
componentsList.addFirst(file);
file = file.getParent();
}
return componentsList.toArray(new PsiFileSystemItem[componentsList.size()]);
}
示例5: getRelativePathFromAncestor
import com.intellij.psi.PsiFileSystemItem; //导入方法依赖的package包/类
@Nullable
public static String getRelativePathFromAncestor(PsiFileSystemItem file, PsiFileSystemItem ancestor) {
int length = 0;
PsiFileSystemItem parent = file;
while (true) {
if (parent == null) return null;
if (parent.equals(ancestor)) break;
if (length > 0) {
length++;
}
length += parent.getName().length();
parent = parent.getParent();
}
char[] chars = new char[length];
int index = chars.length;
parent = file;
while (true) {
if (parent.equals(ancestor)) break;
if (index < length) {
chars[--index] = '/';
}
String name = parent.getName();
for (int i = name.length() - 1; i >= 0; i--) {
chars[--index] = name.charAt(i);
}
parent = parent.getParent();
}
return StringFactory.createShared(chars);
}
示例6: getContainerText
import com.intellij.psi.PsiFileSystemItem; //导入方法依赖的package包/类
@Override
protected String getContainerText(PsiFileSystemItem element, String name) {
PsiFileSystemItem parent = element.getParent();
final PsiDirectory psiDirectory = parent instanceof PsiDirectory ? (PsiDirectory)parent : null;
if (psiDirectory == null) return null;
final VirtualFile virtualFile = psiDirectory.getVirtualFile();
final String relativePath = getRelativePath(virtualFile, element.getProject());
if (relativePath == null) return "( " + File.separator + " )";
String path =
FilePathSplittingPolicy.SPLIT_BY_SEPARATOR.getOptimalTextForComponent(name + " ", new File(relativePath), this, myMaxWidth);
return "(" + path + ")";
}