com.intellij.ide.util.gotoByName.GotoFileModel Java Examples

The following examples show how to use com.intellij.ide.util.gotoByName.GotoFileModel. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FileSearchEverywhereContributor.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public ListCellRenderer<Object> getElementsRenderer() {
  //noinspection unchecked
  return new SERenderer() {
    @Nonnull
    @Override
    protected ItemMatchers getItemMatchers(@Nonnull JList list, @Nonnull Object value) {
      ItemMatchers defaultMatchers = super.getItemMatchers(list, value);
      if (!(value instanceof PsiFileSystemItem) || myModelForRenderer == null) {
        return defaultMatchers;
      }

      return GotoFileModel.convertToFileItemMatchers(defaultMatchers, (PsiFileSystemItem)value, myModelForRenderer);
    }
  };
}
 
Example #2
Source File: DirectoryPathMatcher.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
private static List<Pair<VirtualFile, String>> getProjectRoots(GotoFileModel model) {
  Set<VirtualFile> roots = new HashSet<>();
  for (Module module : ModuleManager.getInstance(model.getProject()).getModules()) {
    Collections.addAll(roots, ModuleRootManager.getInstance(module).getContentRoots());
    for (OrderEntry entry : ModuleRootManager.getInstance(module).getOrderEntries()) {
      if (entry instanceof OrderEntryWithTracking) {
        Collections.addAll(roots, entry.getFiles(OrderRootType.CLASSES));
        Collections.addAll(roots, entry.getFiles(OrderRootType.SOURCES));
      }
    }
  }
  return roots.stream().map(root -> {
    VirtualFile top = model.getTopLevelRoot(root);
    return top != null ? top : root;
  }).distinct().map(r -> Pair.create(r, StringUtil.notNullize(model.getFullName(r)))).collect(Collectors.toList());
}
 
Example #3
Source File: FileSearchEverywhereContributor.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
protected FilteringGotoByModel<FileType> createModel(@Nonnull Project project) {
  GotoFileModel model = new GotoFileModel(project);
  if (myFilter != null) {
    model.setFilterItems(myFilter.getSelectedElements());
  }
  return model;
}
 
Example #4
Source File: DirectoryPathMatcher.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
static DirectoryPathMatcher root(@Nonnull GotoFileModel model, @Nonnull String pattern) {
  DirectoryPathMatcher matcher = new DirectoryPathMatcher(model, null, "");
  for (int i = 0; i < pattern.length(); i++) {
    matcher = matcher.appendChar(pattern.charAt(i));
    if (matcher == null) return null;
  }
  return matcher;
}
 
Example #5
Source File: SendProjectFileAction2.java    From SmartIM4IntelliJ with Apache License 2.0 4 votes vote down vote up
@Override protected void gotoActionPerformed(AnActionEvent anActionEvent) {
    Project project = anActionEvent.getData(CommonDataKeys.PROJECT);
    ChooseByNameModel model = new GotoFileModel(project);
    showNavigationPopup(anActionEvent, model, new Callback(), false);
}
 
Example #6
Source File: PantsIntegrationTestCase.java    From intellij-pants-plugin with Apache License 2.0 4 votes vote down vote up
protected void assertGotoFileContains(String filename) {
  final GotoFileModel gotoFileModel = new GotoFileModel(myProject);
  assertTrue(ArrayUtil.contains(filename, gotoFileModel.getNames(false)));
}
 
Example #7
Source File: FileSearchEverywhereContributor.java    From consulo with Apache License 2.0 4 votes vote down vote up
public FileSearchEverywhereContributor(@Nullable Project project, @Nullable PsiElement context) {
  super(project, context);
  myModelForRenderer = project == null ? null : new GotoFileModel(project);
  myFilter = project == null ? null : createFileTypeFilter(project);
}
 
Example #8
Source File: GotoFileAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
GotoFileFilter(final ChooseByNamePopup popup, GotoFileModel model, final Project project) {
  super(popup, model, GotoFileConfiguration.getInstance(project), project);
}
 
Example #9
Source File: DirectoryPathMatcher.java    From consulo with Apache License 2.0 4 votes vote down vote up
private DirectoryPathMatcher(@Nonnull GotoFileModel model, @Nullable List<Pair<VirtualFile, String>> files, @Nonnull String pattern) {
  myModel = model;
  myFiles = files;
  dirPattern = pattern;
}