本文整理匯總了Java中com.intellij.openapi.vfs.VfsUtil.isAncestor方法的典型用法代碼示例。如果您正苦於以下問題:Java VfsUtil.isAncestor方法的具體用法?Java VfsUtil.isAncestor怎麽用?Java VfsUtil.isAncestor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.openapi.vfs.VfsUtil
的用法示例。
在下文中一共展示了VfsUtil.isAncestor方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createPackageDirectoryInSourceRoot
import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
public static PsiDirectory createPackageDirectoryInSourceRoot(PackageWrapper aPackage, final VirtualFile sourceRoot)
throws IncorrectOperationException {
final PsiDirectory[] directories = aPackage.getDirectories();
for (PsiDirectory directory : directories) {
if (VfsUtil.isAncestor(sourceRoot, directory.getVirtualFile(), false)) {
return directory;
}
}
String qNameToCreate = qNameToCreateInSourceRoot(aPackage, sourceRoot);
final String[] shortNames = qNameToCreate.split("\\.");
PsiDirectory current = aPackage.getManager().findDirectory(sourceRoot);
LOG.assertTrue(current != null);
for (String shortName : shortNames) {
PsiDirectory subdirectory = current.findSubdirectory(shortName);
if (subdirectory == null) {
subdirectory = current.createSubdirectory(shortName);
}
current = subdirectory;
}
return current;
}
示例2: removeFrameworkStuff
import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
private PathsList removeFrameworkStuff(Module module, List<VirtualFile> rootFiles) {
final List<File> toExclude = getImplicitClasspathRoots(module);
if (LOG.isDebugEnabled()) {
LOG.debug("Before removing framework stuff: " + rootFiles);
LOG.debug("Implicit roots:" + toExclude);
}
PathsList scriptClassPath = new PathsList();
eachRoot:
for (VirtualFile file : rootFiles) {
for (final File excluded : toExclude) {
if (VfsUtil.isAncestor(excluded, VfsUtil.virtualToIoFile(file), false)) {
continue eachRoot;
}
}
scriptClassPath.add(file);
}
return scriptClassPath;
}
示例3: testGeneration
import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
@Test
public void testGeneration() throws Exception {
for (int i = 0; i < 100; i++) {
final File f = new File(myClientRoot, "f" + i + ".txt");
f.createNewFile();
}
myWorkingCopyDir.refresh(false, true);
myChangeListManager.ensureUpToDate(false);
final List<VirtualFile> unversionedFiles = ((ChangeListManagerImpl)myChangeListManager).getUnversionedFiles();
final Pattern pattern = Pattern.compile("f([0-9])+\\.txt");
int cnt = 0;
for (VirtualFile unversionedFile : unversionedFiles) {
if (VfsUtil.isAncestor(myWorkingCopyDir, unversionedFile, true)) {
++ cnt;
Assert.assertTrue(pattern.matcher(unversionedFile.getName()).matches());
}
}
Assert.assertEquals(100, cnt);
}
示例4: findLogicalRoot
import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
@Override
@Nullable
public LogicalRoot findLogicalRoot(@NotNull final VirtualFile file) {
final Module module = ModuleUtil.findModuleForFile(file, myProject);
if (module == null) return null;
LogicalRoot result = null;
final List<LogicalRoot> list = getLogicalRoots(module);
for (final LogicalRoot root : list) {
final VirtualFile rootFile = root.getVirtualFile();
if (rootFile != null && VfsUtil.isAncestor(rootFile, file, false)) {
result = root;
break;
}
}
return result;
}
示例5: isExcluded
import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
public boolean isExcluded(VirtualFile file) {
for (final VirtualFile excludedFile : myExcludedFiles) {
if (VfsUtil.isAncestor(excludedFile, file, false)) {
return true;
}
}
if (myProject == null || !isIgnoredByVcs(file)) {
return false;
}
for (VirtualFile includedFile : myIncludedFiles) {
if (VfsUtil.isAncestor(includedFile, file, false)) {
return false;
}
}
return true;
}
示例6: include
import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
private void include(VirtualFile selectedFile) {
myExcludedFiles.remove(selectedFile);
if (myProject == null) {
return;
}
if (!isIgnoredByVcs(selectedFile)) {
return;
}
final VirtualFile parent = selectedFile.getParent();
if (parent != null && isIgnoredByVcs(parent)) {
return;
}
for (final VirtualFile excludedFile : myExcludedFiles) {
if (VfsUtil.isAncestor(excludedFile, selectedFile, true)) {
return;
}
}
myIncludedFiles.add(selectedFile);
}
示例7: process
import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
public void process(final FilePath path) {
FilePath current = path;
while (current != null) {
VirtualFile vf = current.getVirtualFile();
if (vf == null) {
vf = LocalFileSystem.getInstance().refreshAndFindFileByPath(current.getPath());
}
if (vf == null) {
return;
}
if (! VfsUtil.isAncestor(myRoot, vf, true)) return;
myToBeAdded.add(current);
current = current.getParentPath();
}
}
示例8: getStateImpl
import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
private TreeNodeState getStateImpl(final StateWorker stateWorker) {
if (stateWorker.getVf() == null) return TreeNodeState.CLEAR;
final TreeNodeState stateSelf = myState.get(stateWorker.getVf());
if (stateSelf != null) return stateSelf;
final Ref<TreeNodeState> result = new Ref<TreeNodeState>();
stateWorker.iterateParents(myState, new PairProcessor<VirtualFile, TreeNodeState>() {
@Override
public boolean process(VirtualFile virtualFile, TreeNodeState state) {
if (state != null) {
if (TreeNodeState.SELECTED.equals(state) || TreeNodeState.HAVE_SELECTED_ABOVE.equals(state)) {
result.set(myState.putAndPass(stateWorker.getVf(), TreeNodeState.HAVE_SELECTED_ABOVE));
}
return false; // exit
}
return true;
}
});
if (! result.isNull()) return result.get();
for (VirtualFile selected : myState.getSelected()) {
if (VfsUtil.isAncestor(stateWorker.getVf(), selected, true)) {
return myState.putAndPass(stateWorker.getVf(), TreeNodeState.HAVE_SELECTED_BELOW);
}
}
return TreeNodeState.CLEAR;
}
示例9: findPackageDirectoryInSourceRoot
import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
@Nullable
public static PsiDirectory findPackageDirectoryInSourceRoot(PackageWrapper aPackage, final VirtualFile sourceRoot) {
final PsiDirectory[] directories = aPackage.getDirectories();
for (PsiDirectory directory : directories) {
if (VfsUtil.isAncestor(sourceRoot, directory.getVirtualFile(), false)) {
return directory;
}
}
String qNameToCreate;
try {
qNameToCreate = qNameToCreateInSourceRoot(aPackage, sourceRoot);
}
catch (IncorrectOperationException e) {
return null;
}
final String[] shortNames = qNameToCreate.split("\\.");
PsiDirectory current = aPackage.getManager().findDirectory(sourceRoot);
LOG.assertTrue(current != null);
for (String shortName : shortNames) {
PsiDirectory subdirectory = current.findSubdirectory(shortName);
if (subdirectory == null) {
return null;
}
current = subdirectory;
}
return current;
}
示例10: getContentRootName
import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
private String getContentRootName(final VirtualFile baseDir, final String dirName) {
if (baseDir != null) {
if (!Comparing.equal(myVDirectory, baseDir)) {
if (VfsUtil.isAncestor(baseDir, myVDirectory, false)) {
return VfsUtilCore.getRelativePath(myVDirectory, baseDir, '/');
}
else {
return myVDirectory.getPresentableUrl();
}
}
} else {
return myVDirectory.getPresentableUrl();
}
return dirName;
}
示例11: removeDescendants
import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
private void removeDescendants(VirtualFile file, VirtualFilePointerContainer container) {
for (VirtualFile virtualFile : container.getFiles()) {
if (VfsUtil.isAncestor(file, virtualFile, false)) {
container.remove(myPointerManager.create(virtualFile, this, null));
}
}
}
示例12: isUnder
import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
private static boolean isUnder(VirtualFile file, final VirtualFilePointerContainer container) {
for (VirtualFile excludedFile : container.getFiles()) {
if (VfsUtil.isAncestor(excludedFile, file, false)) {
return true;
}
}
return false;
}
示例13: getBranchForFile
import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
@Nullable
public String getBranchForFile(final VirtualFile file) {
final VirtualFile floor = myMap.floorKey(file);
if (floor == null) return null;
final SortedMap<VirtualFile, Pair<Boolean, String>> floorMap = myMap.headMap(floor);
for (VirtualFile parent : floorMap.keySet()) {
if (VfsUtil.isAncestor(parent, file, false)) {
return floorMap.get(parent).getSecond();
}
}
return null;
}
示例14: ok
import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
private boolean ok(final File vf) {
for (File root : myRoots) {
if (VfsUtil.isAncestor(root, vf, false)) {
return true;
}
}
return false;
}
示例15: buildDirectoryList
import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
public static void buildDirectoryList(PackageWrapper aPackage,
List<VirtualFile> contentSourceRoots,
LinkedHashSet<PsiDirectory> targetDirectories,
Map<PsiDirectory, String> relativePathsToCreate) {
sourceRoots:
for (VirtualFile root : contentSourceRoots) {
final PsiDirectory[] directories = aPackage.getDirectories();
for (PsiDirectory directory : directories) {
if (VfsUtil.isAncestor(root, directory.getVirtualFile(), false)) {
targetDirectories.add(directory);
continue sourceRoots;
}
}
String qNameToCreate;
try {
qNameToCreate = RefactoringUtil.qNameToCreateInSourceRoot(aPackage, root);
}
catch (IncorrectOperationException e) {
continue sourceRoots;
}
PsiDirectory currentDirectory = aPackage.getManager().findDirectory(root);
if (currentDirectory == null) continue;
final String[] shortNames = qNameToCreate.split("\\.");
for (int j = 0; j < shortNames.length; j++) {
String shortName = shortNames[j];
final PsiDirectory subdirectory = currentDirectory.findSubdirectory(shortName);
if (subdirectory == null) {
targetDirectories.add(currentDirectory);
final StringBuffer postfix = new StringBuffer();
for (int k = j; k < shortNames.length; k++) {
String name = shortNames[k];
postfix.append(File.separatorChar);
postfix.append(name);
}
relativePathsToCreate.put(currentDirectory, postfix.toString());
continue sourceRoots;
}
else {
currentDirectory = subdirectory;
}
}
}
LOG.assertTrue(targetDirectories.size() <= contentSourceRoots.size());
LOG.assertTrue(relativePathsToCreate.size() <= contentSourceRoots.size());
}