本文整理汇总了Java中com.intellij.openapi.vfs.VfsUtilCore.isAncestor方法的典型用法代码示例。如果您正苦于以下问题:Java VfsUtilCore.isAncestor方法的具体用法?Java VfsUtilCore.isAncestor怎么用?Java VfsUtilCore.isAncestor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.vfs.VfsUtilCore
的用法示例。
在下文中一共展示了VfsUtilCore.isAncestor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRelativePath
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
@Nullable
public static String getRelativePath(@NotNull VirtualFile virtualFile,
@NotNull ProjectFileIndex index,
final boolean useFQName,
VirtualFile projectBaseDir) {
final VirtualFile contentRootForFile = index.getContentRootForFile(virtualFile);
if (contentRootForFile != null) {
return VfsUtilCore.getRelativePath(virtualFile, contentRootForFile, '/');
}
final Module module = index.getModuleForFile(virtualFile);
if (module != null) {
if (projectBaseDir != null) {
if (VfsUtilCore.isAncestor(projectBaseDir, virtualFile, false)){
final String projectRelativePath = VfsUtilCore.getRelativePath(virtualFile, projectBaseDir, '/');
return useFQName ? projectRelativePath : projectRelativePath.substring(projectRelativePath.indexOf('/') + 1);
}
}
return virtualFile.getPath();
} else {
return getLibRelativePath(virtualFile, index);
}
}
示例2: processIncluded
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
public static void processIncluded(final ContentEntry contentEntry, final Set<VirtualFile> included) {
if (included.isEmpty()) return;
final Set<VirtualFile> parents = new HashSet<VirtualFile>();
for (VirtualFile file : included) {
if (Comparing.equal(file, contentEntry.getFile())) return;
final VirtualFile parent = file.getParent();
if (parent == null || parents.contains(parent)) continue;
parents.add(parent);
for (VirtualFile toExclude : parent.getChildren()) { // if it will ever dead-loop on symlink blame anna.kozlova
boolean toExcludeSibling = true;
for (VirtualFile includeRoot : included) {
if (VfsUtilCore.isAncestor(toExclude, includeRoot, false)) {
toExcludeSibling = false;
}
}
if (toExcludeSibling) {
contentEntry.addExcludeFolder(toExclude);
}
}
}
processIncluded(contentEntry, parents);
}
示例3: contains
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
@Override
public boolean contains(@NotNull VirtualFile file) {
Module module = getValue();
if (module == null || module.isDisposed()) return false;
final VirtualFile testee;
if (file.getFileSystem() instanceof JarFileSystem) {
testee = JarFileSystem.getInstance().getVirtualFileForJar(file);
if (testee == null) return false;
}
else {
testee = file;
}
for (VirtualFile root : ModuleRootManager.getInstance(module).getContentRoots()) {
if (VfsUtilCore.isAncestor(root, testee, false)) return true;
}
return false;
}
示例4: getPackage
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
@Nullable
public PsiPackage getPackage(PsiDirectory dir) {
final VirtualFile file = dir.getVirtualFile();
for (VirtualFile root : myClasspath) {
if (VfsUtilCore.isAncestor(root, file, false)) {
String relativePath = FileUtil.getRelativePath(root.getPath(), file.getPath(), '/');
if (relativePath == null) continue;
return new PsiPackageImpl(myPsiManager, relativePath.replace('/', '.'));
}
}
return null;
}
示例5: getBaseAndroidContentRoot
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
@Nullable
private static VirtualFile getBaseAndroidContentRoot(@NotNull Module module) {
final AndroidFacet facet = AndroidFacet.getInstance(module);
final VirtualFile manifestFile = facet != null ? AndroidRootUtil.getManifestFile(facet) : null;
final VirtualFile[] contentRoots = ModuleRootManager.getInstance(module).getContentRoots();
if (manifestFile != null) {
for (VirtualFile contentRoot : contentRoots) {
if (VfsUtilCore.isAncestor(contentRoot, manifestFile, true)) {
return contentRoot;
}
}
}
return contentRoots.length > 0 ? contentRoots[0] : null;
}
示例6: getAdditionalResolveScope
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
@Override
public SearchScope getAdditionalResolveScope(@NotNull VirtualFile file, Project project) {
String fileExtension = file.getExtension();
if (GroovyFileType.DEFAULT_EXTENSION.equals(fileExtension)) {
GradleClassFinder gradleClassFinder = Extensions.findExtension(PsiElementFinder.EP_NAME, project, GradleClassFinder.class);
final List<VirtualFile> roots = gradleClassFinder.getClassRoots();
for (VirtualFile root : roots) {
if (VfsUtilCore.isAncestor(root, file, true)) {
return NonClasspathDirectoriesScope.compose(roots);
}
}
}
return null;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:GradleBuildClasspathResolveScopeEnlarger.java
示例7: findRoot
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
@Nullable
private VirtualFile findRoot(Library library) {
for (VirtualFile classesRoot : library.getFiles(OrderRootType.CLASSES)) {
if (VfsUtilCore.isAncestor(classesRoot, myClassFile, true)) {
return classesRoot;
}
}
return null;
}
示例8: isSameSupposedUrl
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
private static <T extends RootUrlPair> boolean isSameSupposedUrl(@NotNull T child, @NotNull T parent) {
boolean result = false;
if (VfsUtilCore.isAncestor(parent.getVirtualFile(), child.getVirtualFile(), true)) {
String relativePath = VfsUtilCore.getRelativePath(child.getVirtualFile(), parent.getVirtualFile(), '/');
// get child's supposed and real urls
final String supposed = getSupposedUrl(parent.getUrl(), relativePath);
if (supposed.equals(child.getUrl())) {
result = true;
}
}
return result;
}
示例9: shouldRunEnhancerFor
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
public boolean shouldRunEnhancerFor(@NotNull VirtualFile file) {
for (String path : getConfiguration().getFilesToEnhance()) {
final VirtualFile toEnhance = LocalFileSystem.getInstance().findFileByPath(path);
if (toEnhance != null && VfsUtilCore.isAncestor(toEnhance, file, false)) {
return true;
}
}
return false;
}
示例10: writeClasspath
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
@NotNull
public Element writeClasspath(@Nullable Element oldRoot, @NotNull ModuleRootModel model) {
Element classpathElement = new Element(EclipseXml.CLASSPATH_TAG);
if (oldRoot != null) {
for (Element oldChild : oldRoot.getChildren(EclipseXml.CLASSPATHENTRY_TAG)) {
String oldKind = oldChild.getAttributeValue(EclipseXml.KIND_ATTR);
String oldPath = oldChild.getAttributeValue(EclipseXml.PATH_ATTR);
myOldEntries.put(oldKind + getJREKey(oldPath), oldChild);
}
}
for (OrderEntry orderEntry : model.getOrderEntries()) {
createClasspathEntry(orderEntry, classpathElement, model);
}
String outputPath = "bin";
final String compilerOutputUrl = model.getModuleExtension(CompilerModuleExtension.class).getCompilerOutputUrl();
final EclipseModuleManager eclipseModuleManager = EclipseModuleManagerImpl.getInstance(model.getModule());
final String linkedPath = eclipseModuleManager.getEclipseLinkedVarPath(compilerOutputUrl);
if (linkedPath != null) {
outputPath = linkedPath;
}
else {
VirtualFile contentRoot = EPathUtil.getContentRoot(model);
VirtualFile output = model.getModuleExtension(CompilerModuleExtension.class).getCompilerOutputPath();
if (contentRoot != null && output != null && VfsUtilCore.isAncestor(contentRoot, output, false)) {
outputPath = EPathUtil.collapse2EclipsePath(output.getUrl(), model);
}
else if (output == null && compilerOutputUrl != null) {
outputPath = EPathUtil.collapse2EclipsePath(compilerOutputUrl, model);
}
}
for (String support : eclipseModuleManager.getUsedCons()) {
addOrderEntry(EclipseXml.CON_KIND, support, classpathElement, eclipseModuleManager.getSrcPlace(support));
}
setAttributeIfAbsent(addOrderEntry(EclipseXml.OUTPUT_KIND, outputPath, classpathElement), EclipseXml.PATH_ATTR, EclipseXml.BIN_DIR);
return classpathElement;
}
示例11: appendChildrenTo
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
@Override
protected void appendChildrenTo(@NotNull final Collection<ConvenientNode> children) {
Project project = getObject();
VirtualFile[] roots = ProjectRootManager.getInstance(project).getContentRoots();
NextRoot:
for (VirtualFile root : roots) {
for (VirtualFile candidate : roots) {
if (VfsUtilCore.isAncestor(candidate, root, true)) continue NextRoot;
}
if (myFilter.accept(root)) {
children.add(new FileNode(root, project, myFilter));
}
}
}
示例12: collapse2eclipsePathRelative2Module
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
@Nullable
private static String collapse2eclipsePathRelative2Module(VirtualFile file, Module module) {
final VirtualFile[] contentRoots = ModuleRootManager.getInstance(module).getContentRoots();
for (VirtualFile otherRoot : contentRoots) {
if (VfsUtilCore.isAncestor(otherRoot, file, false)) {
return "/" + module.getName() + "/" + VfsUtilCore.getRelativePath(file, otherRoot, '/');
}
}
return null;
}
示例13: contains
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
@Override
public boolean contains(@NotNull VirtualFile file) {
for (PsiDirectory psiDirectory : getValue()) {
final VirtualFile folder = psiDirectory.getVirtualFile();
if (VfsUtilCore.isAncestor(folder, file, true)) {
return true;
}
}
return false;
}
示例14: inEnglish
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
/**
* Returns true if the given element is in an XML file that is in an English resource.
* Manifest files are considered to be in English, as are resources in base folders
* (unless a locale is explicitly defined on the root element)
*/
private static boolean inEnglish(PsiElement element) {
XmlFile file = PsiTreeUtil.getParentOfType(element, XmlFile.class);
if (file != null) {
String name = file.getName();
if (name.equals(ANDROID_MANIFEST_XML)) {
return true;
} else if (name.equals("generated.xml")) {
// Android Studio Workaround for issue https://code.google.com/p/android/issues/detail?id=76715
// If this a generated file like this:
// ${project}/${module}/build/generated/res/generated/{test?}/${flavors}/${build-type}/values/generated.xml
// ? If so, skip it.
AndroidFacet facet = AndroidFacet.getInstance(file);
VirtualFile virtualFile = file.getVirtualFile();
if (facet != null && facet.isGradleProject() && virtualFile != null) {
IdeaAndroidProject project = facet.getIdeaAndroidProject();
if (project != null) {
VirtualFile buildFolder = VfsUtil.findFileByIoFile(project.getDelegate().getBuildFolder(), false);
if (buildFolder != null && VfsUtilCore.isAncestor(buildFolder, virtualFile, false)) {
return false;
}
}
}
}
PsiDirectory dir = file.getParent();
if (dir != null) {
String locale = LintUtils.getLocaleAndRegion(dir.getName());
if (locale == null) {
locale = getToolsLocale(file);
}
return locale == null || locale.startsWith("en") || locale.equals("b+en") || locale.startsWith("b+en+");
}
}
return false;
}
示例15: someChildContainsFile
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
public boolean someChildContainsFile(final VirtualFile file, boolean optimizeByCheckingFileRootsFirst) {
VirtualFile parent = file.getParent();
boolean mayContain = false;
if (optimizeByCheckingFileRootsFirst && parent != null) {
Collection<VirtualFile> roots = getRoots();
for (VirtualFile eachRoot : roots) {
if (parent.equals(eachRoot.getParent())) {
mayContain = true;
break;
}
if (VfsUtilCore.isAncestor(eachRoot, file, true)) {
mayContain = true;
break;
}
}
} else {
mayContain = true;
}
if (!mayContain) {
return false;
}
Collection<? extends AbstractTreeNode> kids = getChildren();
for (final AbstractTreeNode kid : kids) {
ProjectViewNode node = (ProjectViewNode)kid;
if (node.contains(file)) return true;
}
return false;
}