Java 类com.intellij.psi.search.PsiFileSystemItemProcessor 实例源码

项目:intellij-ce-playground    文件:PsiDirectoryImpl.java   
@Override
public boolean processChildren(PsiElementProcessor<PsiFileSystemItem> processor) {
  checkValid();
  ProgressIndicatorProvider.checkCanceled();

  for (VirtualFile vFile : myFile.getChildren()) {
    boolean isDir = vFile.isDirectory();
    if (processor instanceof PsiFileSystemItemProcessor && !((PsiFileSystemItemProcessor)processor).acceptItem(vFile.getName(), isDir)) {
      continue;
    }

    PsiFileSystemItem item = isDir ? myManager.findDirectory(vFile) : myManager.findFile(vFile);
    if (item != null && !processor.execute(item)) {
      return false;
    }
  }

  return true;
}
项目:intellij-ce-playground    文件:DefaultNavBarExtension.java   
private static boolean processChildren(final PsiFileSystemItem object, final Processor<Object> processor) {
  return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
    @Override
    public Boolean compute() {
      return object.processChildren(new PsiFileSystemItemProcessor() {
        @Override
        public boolean acceptItem(String name, boolean isDirectory) {
          return true;
        }

        @Override
        public boolean execute(@NotNull PsiFileSystemItem element) {
          return processor.process(element);
        }
      });
    }
  });
}
项目:tools-idea    文件:PsiDirectoryImpl.java   
@Override
public boolean processChildren(PsiElementProcessor<PsiFileSystemItem> processor) {
  checkValid();
  ProgressIndicatorProvider.checkCanceled();

  for (VirtualFile vFile : myFile.getChildren()) {
    boolean isDir = vFile.isDirectory();
    if (processor instanceof PsiFileSystemItemProcessor &&
        !((PsiFileSystemItemProcessor)processor).acceptItem(vFile.getName(), isDir)) {
      continue;
    }
    if (isDir) {
      PsiDirectory dir = myManager.findDirectory(vFile);
      if (dir != null) {
        if (!processor.execute(dir)) return false;
      }
    }
    else {
      PsiFile file = myManager.findFile(vFile);
      if (file != null) {
        if (!processor.execute(file)) return false;
      }
    }
  }
  return true;
}
项目:consulo    文件:PsiDirectoryImpl.java   
@Override
public boolean processChildren(PsiElementProcessor<PsiFileSystemItem> processor) {
  checkValid();
  ProgressIndicatorProvider.checkCanceled();

  for (VirtualFile vFile : myFile.getChildren()) {
    boolean isDir = vFile.isDirectory();
    if (processor instanceof PsiFileSystemItemProcessor &&
        !((PsiFileSystemItemProcessor)processor).acceptItem(vFile.getName(), isDir)) {
      continue;
    }
    if (isDir) {
      PsiDirectory dir = myManager.findDirectory(vFile);
      if (dir != null) {
        if (!processor.execute(dir)) return false;
      }
    }
    else {
      PsiFile file = myManager.findFile(vFile);
      if (file != null) {
        if (!processor.execute(file)) return false;
      }
    }
  }
  return true;
}
项目:consulo    文件:DefaultNavBarExtension.java   
private static boolean processChildren(final PsiFileSystemItem object, final Processor<Object> processor) {
  return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
    @Override
    public Boolean compute() {
      return object.processChildren(new PsiFileSystemItemProcessor() {
        @Override
        public boolean acceptItem(String name, boolean isDirectory) {
          return true;
        }

        @Override
        public boolean execute(@Nonnull PsiFileSystemItem element) {
          return processor.process(element);
        }
      });
    }
  });
}
项目:intellij-ce-playground    文件:SyntheticFileSystemItem.java   
protected static boolean processFileSystemItem(PsiElementProcessor<PsiFileSystemItem> processor, PsiFileSystemItem element) {
  if (processor instanceof PsiFileSystemItemProcessor && !((PsiFileSystemItemProcessor)processor).acceptItem(element.getName(), true)) {
    return true;
  }

  return processor.execute(element);
}
项目:tools-idea    文件:SyntheticFileSystemItem.java   
protected static boolean processFileSystemItem(PsiElementProcessor<PsiFileSystemItem> processor, PsiFileSystemItem element) {
  if (processor instanceof PsiFileSystemItemProcessor && !((PsiFileSystemItemProcessor)processor).acceptItem(element.getName(), true)) {
    return true;
  }

  return processor.execute(element);
}
项目:consulo    文件:SyntheticFileSystemItem.java   
protected static boolean processFileSystemItem(PsiElementProcessor<PsiFileSystemItem> processor, PsiFileSystemItem element) {
  if (processor instanceof PsiFileSystemItemProcessor && !((PsiFileSystemItemProcessor)processor).acceptItem(element.getName(), true)) {
    return true;
  }

  return processor.execute(element);
}
项目:intellij-ce-playground    文件:FileReference.java   
protected static void processVariants(final PsiFileSystemItem context, final PsiFileSystemItemProcessor processor) {
  context.processChildren(processor);
}
项目:tools-idea    文件:FileReference.java   
protected void innerResolveInContext(@NotNull final String text,
                                     @NotNull PsiFileSystemItem context,
                                     final Collection<ResolveResult> result,
                                     final boolean caseSensitive) {
  if (isAllowedEmptyPath(text) || ".".equals(text) || "/".equals(text)) {
    result.add(new PsiElementResolveResult(context));
  }
  else if ("..".equals(text)) {
    final PsiFileSystemItem resolved = context.getParent();
    if (resolved != null) {
      result.add(new PsiElementResolveResult(resolved));
    }
  }
  else {
    final int separatorIndex = text.indexOf('/');
    if (separatorIndex >= 0) {
      final List<ResolveResult> resolvedContexts = new ArrayList<ResolveResult>();
      if (separatorIndex == 0 /*starts with slash*/ && "/".equals(context.getName())) {
        resolvedContexts.add(new PsiElementResolveResult(context));
      }
      else {
        innerResolveInContext(text.substring(0, separatorIndex), context, resolvedContexts, caseSensitive);
      }
      final String restOfText = text.substring(separatorIndex + 1);
      for (ResolveResult contextVariant : resolvedContexts) {
        final PsiFileSystemItem item = (PsiFileSystemItem)contextVariant.getElement();
        if (item != null) {
          innerResolveInContext(restOfText, item, result, caseSensitive);
        }
      }
    }
    else {
      final String decoded = decode(text);
      if (decoded != null) {

        if (context instanceof PackagePrefixFileSystemItem) {
          context = ((PackagePrefixFileSystemItem)context).getDirectory();
        }

        if (context instanceof PsiDirectory && caseSensitivityApplies((PsiDirectory)context, caseSensitive)) {
          // optimization: do not load all children into VFS
          PsiDirectory directory = (PsiDirectory)context;
          PsiFileSystemItem child = directory.findFile(decoded);
          if (child == null) child = directory.findSubdirectory(decoded);
          if (child != null) {
            result.add(new PsiElementResolveResult(getOriginalFile(child)));
          }
        }
        else {
          processVariants(context, new PsiFileSystemItemProcessor() {
            @Override
            public boolean acceptItem(String name, boolean isDirectory) {
              return caseSensitive ? decoded.equals(name) : decoded.compareToIgnoreCase(name) == 0;
            }

            @Override
            public boolean execute(@NotNull PsiFileSystemItem element) {
              result.add(new PsiElementResolveResult(getOriginalFile(element)));
              return true;
            }
          });
        }
      }
    }
  }
}
项目:tools-idea    文件:FileReference.java   
protected static void processVariants(final PsiFileSystemItem context, final PsiFileSystemItemProcessor processor) {
  context.processChildren(processor);
}
项目:consulo    文件:FileReference.java   
protected static void processVariants(final PsiFileSystemItem context, final PsiFileSystemItemProcessor processor) {
  context.processChildren(processor);
}