You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@netbeans.apache.org by Emilian Bold <em...@gmail.com> on 2017/09/30 20:10:08 UTC

[Code review] Go to File - folder search

Hello,

I'm trying to add to Navigate | Go to File... the options of also
searching the file path, not just the file name.

This is useful when you know the package and part of the name or when
you have the same file in multiple packages and want to quickly filter
somehow.

There's also an issue about this
https://netbeans.org/bugzilla/show_bug.cgi?id=222697 since 2012!

My work so far is on this branch
https://github.com/emilianbold/incubator-netbeans/tree/emi-goto-file-folder-search-222697

A prototype demo video is at https://vimeo.com/235834852

I have a few unknowns here.

org.netbeans.modules.jumpto.file.Worker uses 3 'strategies':

* PROVIDER, via ProviderStrategy

ProviderStrategy needs a FileProvider to do the actual searching via
computeFiles(Context context, Result result). Only cnd.gotodeclaration
seems to implement this.

I seems to me I should not worry about ProviderStrategy.

* INDEX, via IndexStrategy

This is OK. At index-level (see FileIndexer) I'm adding the path in an
index pair. Then I use that in IndexStrategy.

* FS, via FSStrategy

FSStrategy seems less important because most relevant files (.java,
etc) will be indexed. Still, it does cover project.xml and other
non-indexed files. My code seems to work with the existing NameMatcher
by just toggling based on a flag:

> matcher.accept(request.isSearchByFolders() ? file.getPath() : file.getNameExt())


Finally, there's the matter of the UI. I have added a new checkbox now
"Search by Folders" but I don't really see it as necessary.

It might be better to just expect a forward slash (/) in the search
text and toggle the flag based on that! No file name has a '/' on any
usual filesystem so it can't match anything.

Plus, it would seem odd to me to match the whole patch based on a
regexp and not have a part for the folder and a separate part for the
file. (I mean `*name*.xml` would match folders with `name` in it plus
files with `name`).

Feedback welcome!

--emi