当前位置: 首页>>代码示例>>Java>>正文


Java PsiFileSystemItem.getParent方法代码示例

本文整理汇总了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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:FilePathCompletionContributor.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:AntDomDirname.java

示例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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:NullFileReferenceHelper.java

示例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()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:PsiFileSystemItemUtil.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:PsiFileSystemItemUtil.java

示例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 + ")";
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:GotoFileCellRenderer.java


注:本文中的com.intellij.psi.PsiFileSystemItem.getParent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。