-
Notifications
You must be signed in to change notification settings - Fork 26
Creating cross file autocompletion
A logic that lets you autocomplete symbols that were defined in a different file/package than the one you are currently editing. Since analyzing files and extracting symbols that are exported is a time-consuming task, this cannot be done on each invocation of an autocompletion. Therefore, files are indexed with a so-called FileBasedIndex. The index is stored in an optimized way and as long as files are not touched can be retrieved without re-indexing the files again.
Several things need to be clarified to build a consistent set-up:
- In the files you are currently editing
- What should be suggested for completion? Only symbols that are exported from other packages?
- Do you need to import a package in the second argument of
BeginPackage
to make the symbols from this file available in your code? - How do one consistently extracts which packages are imported in the current file and how is the file determined in which the package code can be found?
- In the files that are indexed
- How exactly are exported symbols and their
Context
determined? Usually, one starts a package and afterBeginPackage
all exported symbols are given with their::usage
before the implementation follows after thePrivate`
context is opened. Unfortunately, many different other forms are possible. What do we support? - What are we doing with files that don't use the usual
BeginPackage
,Begin
template? - How do we define which files are indexed? So far all
*.m
files are searched but a more sophisticated search scope is required.
- How exactly are exported symbols and their
I have implemented an indexer and simple logic that goes through the top-level of the file extracting all symbols with an ::usage
message. Furthermore, an action exists that can be activated through the menu to show all found exported symbols in all files that can be used to test which symbols are found.