hoshi-lang dev
Yet another programming language
Loading...
Searching...
No Matches
ProjectIndex Class Reference

#include <projectIndex.h>

Classes

struct  IndexedModule
 

Public Member Functions

 ProjectIndex ()
 
void setSearchPaths (const std::vector< std::string > &paths)
 
void addSearchPath (const std::string &path)
 
const std::vector< std::string > & getSearchPaths () const
 
std::string resolveModule (const std::string &importPath, const std::string &relativeToFile)
 
void indexModule (const std::string &absolutePath)
 
const yoi::vec< Symbol > * getModuleSymbols (const std::string &absolutePath)
 Get symbols for a specific module.
 
void getAllSymbols (yoi::vec< Symbol > &out)
 Collect all symbols from all indexed modules into flat list.
 
const yoi::vec< Symbol > & indexAndGet (const std::string &absolutePath)
 Parse and index a module, then return its symbols.
 
void invalidateModule (const std::string &absolutePath)
 Clear a module from the cache (e.g., when it changes on disk).
 

Private Member Functions

std::string tryResolve (const std::string &searchDir, const std::string &importPath)
 
void parseAndIndex (const std::string &absolutePath, const std::wstring &text, IndexedModule &mod)
 

Private Attributes

std::vector< std::string > searchPaths
 
std::map< std::string, IndexedModulemodules
 

Detailed Description

Definition at line 18 of file projectIndex.h.

Constructor & Destructor Documentation

◆ ProjectIndex()

Definition at line 19 of file projectIndex.cpp.

Member Function Documentation

◆ addSearchPath()

void addSearchPath ( const std::string &  path)

Definition at line 25 of file projectIndex.cpp.

References ProjectIndex::searchPaths.

Referenced by LspServer::handleInitialize().

Here is the caller graph for this function:

◆ getAllSymbols()

void getAllSymbols ( yoi::vec< Symbol > &  out)

Collect all symbols from all indexed modules into flat list.

Definition at line 152 of file projectIndex.cpp.

References ProjectIndex::modules, Symbol::sourceFile, and yoi::string2wstring().

Referenced by CompletionProvider::completionsForType(), CompletionProvider::completionsForTypeNameFromModules(), HoverProvider::hoverOnSymbol(), and CompletionProvider::resolveModuleCompletionsFromText().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getModuleSymbols()

const yoi::vec< Symbol > * getModuleSymbols ( const std::string &  absolutePath)

Get symbols for a specific module.

Definition at line 146 of file projectIndex.cpp.

References ProjectIndex::modules.

◆ getSearchPaths()

const std::vector< std::string > & getSearchPaths ( ) const
inline

Definition at line 24 of file projectIndex.h.

References ProjectIndex::searchPaths.

Referenced by lsp::moduleSearchRoots().

Here is the caller graph for this function:

◆ indexAndGet()

const yoi::vec< Symbol > & indexAndGet ( const std::string &  absolutePath)

Parse and index a module, then return its symbols.

Definition at line 167 of file projectIndex.cpp.

References ProjectIndex::indexModule(), and ProjectIndex::modules.

Referenced by CompletionProvider::completionsForTypeNameFromModules(), HoverProvider::hoverOnSymbol(), DocumentStore::resolveAndIndexImports(), and CompletionProvider::resolveModuleCompletionsFromText().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ indexModule()

void indexModule ( const std::string &  absolutePath)

Parse and index a module file at an absolute path. Does nothing if the module is already indexed.

Definition at line 92 of file projectIndex.cpp.

References __lsp_builtin_module, ProjectIndex::modules, ProjectIndex::parseAndIndex(), yoi::string2wstring(), and ProjectIndex::IndexedModule::text.

Referenced by ProjectIndex::indexAndGet().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ invalidateModule()

void invalidateModule ( const std::string &  absolutePath)

Clear a module from the cache (e.g., when it changes on disk).

Definition at line 177 of file projectIndex.cpp.

References yoi::finalizeAST(), and ProjectIndex::modules.

Here is the call graph for this function:

◆ parseAndIndex()

void parseAndIndex ( const std::string &  absolutePath,
const std::wstring &  text,
IndexedModule mod 
)
private

Definition at line 123 of file projectIndex.cpp.

References yoi::__current_file_path, ProjectIndex::IndexedModule::ast, SymbolExtractor::extract(), yoi::parse(), lexer::scan(), yoi::set_current_file_path(), yoi::string2wstring(), and ProjectIndex::IndexedModule::symbols.

Referenced by ProjectIndex::indexModule().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resolveModule()

std::string resolveModule ( const std::string &  importPath,
const std::string &  relativeToFile 
)

Resolve an import path string to an absolute file path.

Parameters
importPathThe path string from use/import statement (e.g. "lib/math")
relativeToFileAbsolute path of the file containing the import (for local search dirs)
Returns
Resolved absolute path, or empty string if not found

Definition at line 29 of file projectIndex.cpp.

References ProjectIndex::searchPaths, and ProjectIndex::tryResolve().

Referenced by DefinitionProvider::provide(), DocumentStore::resolveAndIndexImports(), and CompletionProvider::resolveModuleCompletionsFromText().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setSearchPaths()

void setSearchPaths ( const std::vector< std::string > &  paths)

Definition at line 21 of file projectIndex.cpp.

References ProjectIndex::searchPaths.

◆ tryResolve()

std::string tryResolve ( const std::string &  searchDir,
const std::string &  importPath 
)
private

Definition at line 60 of file projectIndex.cpp.

Referenced by ProjectIndex::resolveModule().

Here is the caller graph for this function:

Member Data Documentation

◆ modules

◆ searchPaths

std::vector<std::string> searchPaths
private

The documentation for this class was generated from the following files: