This class is not thread-safe.
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private Map | allBindings
A map of all bindings created, keyed on their qnames. |
| private AstCache | astCache
Manages a store of serialized ASTs. |
| public Builtins | builtins
Manages the built-in modules -- that is, modules from the standard Python library that are implemented in C and consequently have no Python source. |
| public String | |
| public Set | failedModules
When resolving imports we look in various possible locations. |
| public Scope | globaltable
The top-level (builtin) scope. |
| public static Indexer | idx
The global indexer instance. |
| private int | |
| private Map | locations
A map of references to their referenced bindings. |
| private Logger | |
| public Scope | moduleTable
A scope containing bindings for all modules currently loaded by the indexer. |
| private int | |
| private int | |
| private int | |
| private int | |
| private int | |
| public Map | |
| public List | |
| public Map | problems
Diagnostics. |
| public String | |
| private Map | unresolvedModules
This set tracks module imports that could not be resolved. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | |
| public void | |
| public void | |
| public boolean | |
| public void | |
| public void | clearModuleTable()
Clears the module table, discarding all resolved ASTs (modules) and their scope information. |
| private void | |
| private int | |
| private void | |
| public void | enableAggressiveAssertions(boolean enable)
Configures whether the indexer should abort with an exception when it encounters an internal error or unexpected program state. |
| public void | |
| public void | |
| public List | Returns: a list of entries constituting the file outline. Returns an empty list if the indexer hasn't indexed that path.the file for which to build the outline path)Create an outline for a file in the index. |
| private AstCache | |
| public NModule | |
| public NModule | |
| public Map | |
| public NModuleType | |
| pack-priv NModuleType | |
| public List | getDiagnosticsForFile(String file)
Returns the list, possibly empty but never |
| pack-priv List | |
| public List | |
| public List | getLoadPath()
Returns the module search path -- the project directory followed by any
paths that were added by |
| public Logger | |
| public NModuleType | getModuleForFile(String
absolute file path file)Returns (loading/resolving if necessary) the module for a given source path. |
| pack-priv List | |
| public String | |
| public void | handleException(String
descriptive message; ok to be msg, Throwable cause)nullIf aggressive assertions are enabled, propagates the passed
|
| public void | |
| private boolean | |
| public boolean | |
| public NModuleType | |
| public NModuleType | Returns: null if path could not be loadedthe absolute path to the file or directory.
If it is a directory, it is suffixed with "__init__.py", and
only that file is loaded from the directory. path, boolean true to skip loading ancestor packagesLoad, parse and analyze a source file given its absolute path. |
| public void | loadFileRecursive(String fullname)
Load all Python source files recursively if the given fullname is a directory; otherwise just load a file. |
| public NModuleType | loadModule(String
a module name. Can be a relative path to a directory or a file (without the
extension) or a possibly-qualified module name. If it is a module name, cannot
contain leading dots. modname)This method searches the module path for the module |
| private void | |
| public NModuleType | loadString(String
a path for reporting/caching purposes. The filename
component is used to construct the module qualified name. path, String contents)Loads a module from a string containing the module contents. |
| public void | |
| public NBinding | |
| public NType | |
| public int | |
| private NModuleType | |
| private NModuleType | parseAndResolve(String
the filename file, String optional file contents. If contents)null, loads the
file contents from disk.Parse a file or string and return its module parse tree. |
| private String | |
| private String | |
| public NBinding | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | ready()
Performs final indexing-building passes, including marking references to undeclared variables. |
| public void | recordUnresolvedModule(String
module qname, e.g. "org.foo.bar" qname, String the file where the unresolved import occurred file)Reports a failed module or submodule resolution. |
| public void | |
| public void | |
| public void | reportFailedAssertion(String
a descriptive message about the problem msg)Signals a failed assertion about the state of the indexer or index. |
| public void | |
| public void | |
| public void | |
| public void | |
| public String | |
| public void | updateLocation(Ref node, NBinding b)
Add |
| public void |
| aggressiveAssertions | back to summary |
|---|---|
| private boolean aggressiveAssertions | |
| allBindings | back to summary |
|---|---|
| private Map<String, NBinding> allBindings A map of all bindings created, keyed on their qnames. | |
| astCache | back to summary |
|---|---|
| private AstCache astCache Manages a store of serialized ASTs. ANTLR parsing is one of the slower and more expensive phases of indexing; reusing parse trees can help with resource utilization when indexing several projects (or re-indexing one project). | |
| builtins | back to summary |
|---|---|
| public Builtins builtins Manages the built-in modules -- that is, modules from the standard Python library that are implemented in C and consequently have no Python source. | |
| currentFile | back to summary |
|---|---|
| public String currentFile | |
| failedModules | back to summary |
|---|---|
| public Set<String> failedModules When resolving imports we look in various possible locations. This set keeps track of modules we attempted but didn't find. | |
| globaltable | back to summary |
|---|---|
| public Scope globaltable The top-level (builtin) scope. | |
| idx | back to summary |
|---|---|
| public static Indexer idx The global indexer instance. Provides convenient access to global resources, as well as easy cleanup of resources after the index is built. | |
| loadedFiles | back to summary |
|---|---|
| private int loadedFiles | |
| locations | back to summary |
|---|---|
| private Map<Ref, List<NBinding>> locations A map of references to their referenced bindings. Most nodes will refer to a single binding, and few ever refer to more than two. One situation in which a multiple reference can occur is the an attribute of a union type. For instance:
class A:
def foo(self): pass
class B:
def foo(self): pass
if some_condition:
var = A()
else
var = B()
var.foo() # foo here refers to both A.foo and B.foo
| |
| logger | back to summary |
|---|---|
| private Logger logger | |
| moduleTable | back to summary |
|---|---|
| public Scope moduleTable A scope containing bindings for all modules currently loaded by the indexer. | |
| nloc | back to summary |
|---|---|
| private int nloc | |
| nparsing | back to summary |
|---|---|
| private int nparsing | |
| nprob | back to summary |
|---|---|
| private int nprob | |
| nunbound | back to summary |
|---|---|
| private int nunbound | |
| nunknown | back to summary |
|---|---|
| private int nunknown | |
| parseErrs | back to summary |
|---|---|
| public Map<String, List<Diagnostic>> parseErrs | |
| path | back to summary |
|---|---|
| public List<String> path | |
| problems | back to summary |
|---|---|
| public Map<String, List<Diagnostic>> problems Diagnostics. | |
| projDir | back to summary |
|---|---|
| public String projDir | |
| unresolvedModules | back to summary |
|---|---|
| private Map<String, Set<String>> unresolvedModules This set tracks module imports that could not be resolved. | |
| Indexer | back to summary |
|---|---|
| public Indexer() | |
| addFileErr | back to summary |
|---|---|
| pack-priv void addFileErr(String file, int beg, int end, String msg) | |
| addPath | back to summary |
|---|---|
| public void addPath(String p) throws IOException Adds the specified absolute path to the module search path. | |
| addPaths | back to summary |
|---|---|
| public void addPaths(List<String> p) throws IOException Adds the specified absolute paths to the module search path. | |
| aggressiveAssertionsEnabled | back to summary |
|---|---|
| public boolean aggressiveAssertionsEnabled() | |
| clearAstCache | back to summary |
|---|---|
| public void clearAstCache() Clears the AST cache (to free up memory). Subsequent calls to
| |
| clearModuleTable | back to summary |
|---|---|
| public void clearModuleTable() Clears the module table, discarding all resolved ASTs (modules) and their scope information. | |
| convertCallToNew | back to summary |
|---|---|
| private void convertCallToNew(Ref ref, List<NBinding> bindings) | |
| countDefs | back to summary |
|---|---|
| private int countDefs(List<NBinding> bindings) | |
| duplicateBindingFailure | back to summary |
|---|---|
| private void duplicateBindingFailure(NBinding newb, NBinding oldb) | |
| enableAggressiveAssertions | back to summary |
|---|---|
| public void enableAggressiveAssertions(boolean enable) Configures whether the indexer should abort with an exception when it encounters an internal error or unexpected program state. Normally the indexer attempts to continue indexing, on the assumption that having an index with mostly good data is better than having no index at all. Enabling aggressive assertions is useful for debugging the indexer. | |
| fine | back to summary |
|---|---|
| public void fine(String msg) | |
| finer | back to summary |
|---|---|
| public void finer(String msg) | |
| generateOutline | back to summary |
|---|---|
| public List Create an outline for a file in the index. | |
| getAstCache | back to summary |
|---|---|
| private AstCache getAstCache() throws Exception | |
| getAstForFile | back to summary |
|---|---|
| public NModule getAstForFile(String file) throws Exception Returns the syntax tree for
| |
| getAstForFile | back to summary |
|---|---|
| public NModule getAstForFile(String file, String contents) throws Exception Returns the syntax tree for
| |
| getBindings | back to summary |
|---|---|
| public Map Returns the mutable set of all bindings collected, keyed on their qnames. | |
| getBuiltinModule | back to summary |
|---|---|
| public NModuleType getBuiltinModule(String qname) throws Exception | |
| getCachedModule | back to summary |
|---|---|
| pack-priv NModuleType getCachedModule(String file) | |
| getDiagnosticsForFile | back to summary |
|---|---|
| public List Returns the list, possibly empty but never | |
| getFileErrs | back to summary |
|---|---|
| pack-priv List | |
| getLoadedFiles | back to summary |
|---|---|
| public List | |
| getLoadPath | back to summary |
|---|---|
| public List Returns the module search path -- the project directory followed by any
paths that were added by | |
| getLogger | back to summary |
|---|---|
| public Logger getLogger() | |
| getModuleForFile | back to summary |
|---|---|
| public NModuleType getModuleForFile(String file) throws Exception Returns (loading/resolving if necessary) the module for a given source path.
| |
| getParseErrs | back to summary |
|---|---|
| pack-priv List | |
| getStatusReport | back to summary |
|---|---|
| public String getStatusReport() Report resolution rate and other statistics data. | |
| handleException | back to summary |
|---|---|
| public void handleException(String msg, Throwable cause) If aggressive assertions are enabled, propagates the passed
| |
| info | back to summary |
|---|---|
| public void info(String msg) | |
| isInLoadPath | back to summary |
|---|---|
| private boolean isInLoadPath(File dir) | |
| isLibFile | back to summary |
|---|---|
| public boolean isLibFile(String file) | |
| loadFile | back to summary |
|---|---|
| public NModuleType loadFile(String path) throws Exception Loads a file and all its ancestor packages.
| |
| loadFile | back to summary |
|---|---|
| public NModuleType loadFile(String path, boolean skipChain) throws Exception Load, parse and analyze a source file given its absolute path. By default, loads the entire ancestor package chain.
| |
| loadFileRecursive | back to summary |
|---|---|
| public void loadFileRecursive(String fullname) throws Exception Load all Python source files recursively if the given fullname is a directory; otherwise just load a file. Looks at file extension to determine whether to load a given file. | |
| loadModule | back to summary |
|---|---|
| public NModuleType loadModule(String modname) throws Exception This method searches the module path for the module The mechanisms for importing modules are in general statically undecidable. We make a reasonable effort to follow the most common lookup rules.
| |
| loadParentPackage | back to summary |
|---|---|
| private void loadParentPackage(String file) throws Exception When we load a module, load all its parent packages, top-down. This is in part because Python does it anyway, and in part so that you can click on all parent package components in import statements. We load whole ancestor chain top-down, as does Python. | |
| loadString | back to summary |
|---|---|
| public NModuleType loadString(String path, String contents) throws Exception Loads a module from a string containing the module contents. Idempotent: looks in the module cache first. Used for simple unit tests.
| |
| log | back to summary |
|---|---|
| public void log(Level level, String msg) | |
| lookupQname | back to summary |
|---|---|
| public NBinding lookupQname(String qname) Return the binding for | |
| lookupQnameType | back to summary |
|---|---|
| public NType lookupQnameType(String qname) Return the type for
| |
| numFilesLoaded | back to summary |
|---|---|
| public int numFilesLoaded() | |
| parseAndResolve | back to summary |
|---|---|
| private NModuleType parseAndResolve(String file) throws Exception | |
| parseAndResolve | back to summary |
|---|---|
| private NModuleType parseAndResolve(String file, String contents) throws Exception Parse a file or string and return its module parse tree.
| |
| percent | back to summary |
|---|---|
| private String percent(int num, int total) | |
| printBindings | back to summary |
|---|---|
| private String printBindings() | |
| putBinding | back to summary |
|---|---|
| public NBinding putBinding(NBinding b) | |
| putLocation | back to summary |
|---|---|
| public void putLocation(NNode node, NBinding b) Add a reference to binding | |
| putLocation | back to summary |
|---|---|
| public void putLocation(Ref ref, NBinding b) | |
| putProblem | back to summary |
|---|---|
| public void putProblem(NNode loc, String msg) | |
| putProblem | back to summary |
|---|---|
| public void putProblem(String file, int beg, int end, String msg) | |
| ready | back to summary |
|---|---|
| public void ready() Performs final indexing-building passes, including marking references to undeclared variables. Caller should invoke this method after loading all files. | |
| recordUnresolvedModule | back to summary |
|---|---|
| public void recordUnresolvedModule(String qname, String file) Reports a failed module or submodule resolution. | |
| release | back to summary |
|---|---|
| public void release() Releases all resources for the current indexer. | |
| removeBinding | back to summary |
|---|---|
| public void removeBinding(NBinding b) | |
| reportFailedAssertion | back to summary |
|---|---|
| public void reportFailedAssertion(String msg) Signals a failed assertion about the state of the indexer or index.
If aggressive assertions are enabled, throws an
| |
| setLogger | back to summary |
|---|---|
| public void setLogger(Logger logger) | |
| setPath | back to summary |
|---|---|
| public void setPath(List<String> path) throws IOException Sets the module search path to the specified list of absolute paths. | |
| setProjectDir | back to summary |
|---|---|
| public void setProjectDir(String cd) throws IOException | |
| severe | back to summary |
|---|---|
| public void severe(String msg) | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |
| updateLocation | back to summary |
|---|---|
| public void updateLocation(Ref node, NBinding b) Add | |
| warn | back to summary |
|---|---|
| public void warn(String msg) | |