Code::Blocks
SVN r11506
|
NativeParser class is just like a manager class to control Parser objects. More...
#include <nativeparser.h>
Public Member Functions | |
NativeParser () | |
Constructor. More... | |
~NativeParser () | |
Destructor. More... | |
ParserBase & | GetParser () |
return a reference to the currently active Parser object More... | |
ParserBase * | GetParserByProject (cbProject *project) |
return the Parser pointer corresponding to the input C::B project More... | |
ParserBase * | GetParserByFilename (const wxString &filename) |
return the Parser pointer associated with the input file If a file belongs to several Parser objects, the first found Parser will returned. More... | |
cbProject * | GetProjectByParser (ParserBase *parser) |
return the C::B project associated with Parser pointer More... | |
cbProject * | GetProjectByFilename (const wxString &filename) |
return the C::B project containing the filename The function first try to match the filename in the active project, next to match other projects opened, If the file exists in several projects, the first matched project will be returned. More... | |
cbProject * | GetProjectByEditor (cbEditor *editor) |
return the C::B project containing the cbEditor pointer More... | |
cbProject * | GetCurrentProject () |
Get current project by active editor or just return active project. More... | |
bool | IsParserPerWorkspace () const |
Return true if use one Parser per whole workspace. More... | |
bool | Done () |
Return true if all the parser's batch-parse stages are finished, otherwise return false. More... | |
wxImageList * | GetImageList () |
Used to support Symbol browser and codecompletion UI Image list is used to initialize the symbol browser tree node image. More... | |
int | GetTokenKindImage (const Token *token) |
Returns the image assigned to a specific token for a symbol browser. More... | |
wxArrayString | GetAllPathsByFilename (const wxString &filename) |
Get the implementation file path if the input is a header file. More... | |
ParserBase * | CreateParser (cbProject *project) |
Dynamically allocate a Parser object for the input C::B project, note that while create a new Parser object, the DoFullParsing() function will be called, which collect the macro definitions, and start the batch parsing from the thread pool. More... | |
bool | DeleteParser (cbProject *project) |
delete the Parser object for the input project More... | |
bool | ReparseFile (cbProject *project, const wxString &filename) |
Single file re-parse. More... | |
bool | AddFileToParser (cbProject *project, const wxString &filename, ParserBase *parser=nullptr) |
New file was added to the C::B project, so this will cause a re-parse on the new added file. More... | |
bool | RemoveFileFromParser (cbProject *project, const wxString &filename) |
remove a file from C::B project and Parser More... | |
void | RereadParserOptions () |
when user changes the CC option, we should re-read the option More... | |
void | ReparseCurrentProject () |
re-parse the active Parser (the project associated with m_Parser member variable More... | |
void | ReparseSelectedProject () |
re-parse the project select by context menu in projects management panel More... | |
size_t | MarkItemsByAI (ccSearchData *searchData, TokenIdxSet &result, bool reallyUseAI=true, bool isPrefix=true, bool caseSensitive=false, int caretPos=-1) |
collect tokens where a code suggestion list can be shown More... | |
size_t | MarkItemsByAI (TokenIdxSet &result, bool reallyUseAI=true, bool isPrefix=true, bool caseSensitive=false, int caretPos=-1) |
the same as before, but we don't specify the searchData information, so it will use the active editor and current caret information. More... | |
int | GetCallTips (wxArrayString &items, int &typedCommas, cbEditor *ed, int pos=wxNOT_FOUND) |
Call tips are tips when you are typing function arguments these tips information could be: the prototypes information of the current function, the type information of the variable. More... | |
wxArrayString & | GetProjectSearchDirs (cbProject *project) |
project search path is used for auto completion for #include <> More... | |
ClassBrowser * | GetClassBrowser () const |
return active class browser pointer More... | |
void | CreateClassBrowser () |
create the class browser More... | |
void | RemoveClassBrowser (bool appShutDown=false) |
remove the class browser More... | |
void | UpdateClassBrowser () |
update the class browser tree More... | |
Static Public Member Functions | |
static void | AddPaths (wxArrayString &dirs, const wxString &path, bool hasExt) |
Add the paths to path array, and this will be used in GetAllPathsByFilename() function. More... | |
Protected Member Functions | |
bool | DoFullParsing (cbProject *project, ParserBase *parser) |
When a Parser is created, we need a full parsing stage including: 1, parse the priority header files firstly. More... | |
bool | SwitchParser (cbProject *project, ParserBase *parser) |
Switch parser object according the current active editor and filename. More... | |
void | SetParser (ParserBase *parser) |
Set a new Parser as the active Parser Set the active parser pointer (m_Parser member variable) update the ClassBrowser's Parser pointer re-fresh the symbol browser tree. More... | |
void | ClearParsers () |
Clear all Parser object. More... | |
void | RemoveObsoleteParsers () |
Remove all the obsolete Parser object if the number exceeds the limited number (can be set in the CC's option), then all the obsolete parser will be removed. More... | |
std::pair< cbProject *, ParserBase * > | GetParserInfoByCurrentEditor () |
Get cbProject and Parser pointer, according to the current active editor. More... | |
void | SetTokenKindImage (int kind, const wxBitmap &bitmap, const wxBitmap &mask=wxNullBitmap) |
Used to support Symbol browser and codecompletion UI Image list is used to initialize the symbol browser tree node image. More... | |
void | SetTokenKindImage (int kind, const wxBitmap &bitmap, const wxColour &maskColour) |
void | SetTokenKindImage (int kind, const wxIcon &icon) |
void | SetCBViewMode (const BrowserViewMode &mode) |
set the class browser view mode More... | |
Private Types | |
typedef std::pair< cbProject *, ParserBase * > | ProjectParserPair |
typedef std::list< ProjectParserPair > | ParserList |
Private Types inherited from NativeParserBase | |
enum | ParserTokenType { pttUndefined = 0, pttSearchText, pttClass, pttNamespace, pttFunction } |
divide a statement to several pieces(parser component), each component has a type member More... | |
enum | OperatorType { otOperatorUndefined = 0, otOperatorSquare, otOperatorParentheses, otOperatorPointer, otOperatorStar } |
the delimiter separating two Parser Component, See ParserComponent struct for more details More... | |
Private Member Functions | |
void | OnProjectLoadingHook (cbProject *project, TiXmlElement *elem, bool loading) |
Read or Write project' CC options when a C::B project is loading or saving user can set those settings in Menu->Project->Properties->C/C++ parser options panel. More... | |
size_t | AI (TokenIdxSet &result, ccSearchData *searchData, const wxString &lineText=wxEmptyString, bool isPrefix=false, bool caseSensitive=false, TokenIdxSet *search_scope=0, int caretPos=-1) |
Start an Artificial Intelligence search algorithm to gather all the matching tokens. More... | |
size_t | FindCurrentFunctionToken (ccSearchData *searchData, TokenIdxSet &result, int caretPos=-1) |
return all the tokens matching the current function(hopefully, just one) More... | |
int | FindCurrentFunctionStart (ccSearchData *searchData, wxString *nameSpace=0L, wxString *procName=0L, int *functionIndex=0L, int caretPos=-1) |
returns the position where the current function scope starts. More... | |
bool | LastAISearchWasGlobal () const |
used in CodeCompletion suggestion list to boost the performance, we use a caches More... | |
const wxString & | LastAIGlobalSearch () const |
The same as above. More... | |
bool | ParseUsingNamespace (ccSearchData *searchData, TokenIdxSet &search_scope, int caretPos=-1) |
collect the using namespace directive in the editor specified by searchData More... | |
bool | ParseBufferForUsingNamespace (const wxString &buffer, TokenIdxSet &search_scope, bool bufferSkipBlocks=true) |
collect the using namespace directive in the buffer specified by searchData More... | |
bool | ParseFunctionArguments (ccSearchData *searchData, int caretPos=-1) |
collect function argument, add them to the token tree (as temporary tokens) More... | |
bool | ParseLocalBlock (ccSearchData *searchData, TokenIdxSet &search_scope, int caretPos=-1) |
parses from the start of function up to the cursor, this is used to collect local variables. More... | |
bool | AddCompilerDirs (cbProject *project, ParserBase *parser) |
collect the header file search directories, those dirs include: 1, project's base dir, e.g. More... | |
bool | AddCompilerPredefinedMacros (cbProject *project, ParserBase *parser) |
collect compiler specific predefined preprocessor definition, this is usually run a special compiler command, like GCC -dM for gcc. More... | |
bool | AddCompilerPredefinedMacrosGCC (const wxString &compilerId, cbProject *project, wxString &defs, ParserBase *parser) |
collect GCC compiler predefined preprocessor definition More... | |
wxString | GetCompilerStandardGCC (Compiler *compiler, cbProject *project) |
lookup GCC compiler -std=XXX option More... | |
wxString | GetCompilerUsingStandardGCC (const wxArrayString &compilerOptions) |
lookup GCC compiler -std=XXX option for specific GCC options More... | |
bool | AddCompilerPredefinedMacrosVC (const wxString &compilerId, wxString &defs, ParserBase *parser) |
collect VC compiler predefined preprocessor definition More... | |
bool | AddProjectDefinedMacros (cbProject *project, ParserBase *parser) |
collect project (user) defined preprocessor definition, such as for wxWidgets project, the macro may have "#define wxUSE_UNICODE" defined in its project file. More... | |
void | AddCompilerIncludeDirsToParser (const Compiler *compiler, ParserBase *parser) |
Add compiler include directories (from search paths) to a parser. More... | |
const wxArrayString & | GetGCCCompilerDirs (const wxString &cpp_compiler) |
Collect the default compiler include file search paths. More... | |
void | AddGCCCompilerDirs (const wxString &masterPath, const wxString &compilerCpp, ParserBase *parser) |
Add the collected default GCC compiler include search paths to a parser. More... | |
void | AddIncludeDirsToParser (const wxArrayString &dirs, const wxString &base, ParserBase *parser) |
Add a list of directories to the parser's search directories, normalise to "base" path, if "base" is not empty. More... | |
void | OnParserStart (wxCommandEvent &event) |
Event handler when the batch parse starts, print some log information. More... | |
void | OnParserEnd (wxCommandEvent &event) |
Event handler when the batch parse finishes, print some log information, check whether the active editor belong to the current parser, if not, do a parser switch. More... | |
void | OnParsingOneByOneTimer (wxTimerEvent &event) |
If use one parser per whole workspace, we need parse all project one by one, E.g. More... | |
void | OnEditorActivated (EditorBase *editor) |
Event handler when an editor activate, NONE project is handled here. More... | |
void | OnEditorClosed (EditorBase *editor) |
Event handler when an editor closed, if it is the last editor belong to NONE project, then the NONE Parser will be removed. More... | |
void | InitCCSearchVariables () |
Init cc search member variables. More... | |
bool | AddProjectToParser (cbProject *project) |
Add one project to the common parser in one parser for the whole workspace mode. More... | |
bool | RemoveProjectFromParser (cbProject *project) |
Remove cbp from the common parser, this only happens in one parser for whole workspace mode when a parser is removed from the workspace, we should remove the project from the parser. More... | |
Private Member Functions inherited from NativeParserBase | |
NativeParserBase () | |
Constructor. More... | |
virtual | ~NativeParserBase () |
Destructor. More... | |
void | Reset () |
Init cc search member variables. More... | |
size_t | FindAIMatches (TokenTree *tree, std::queue< ParserComponent > components, TokenIdxSet &result, int parentTokenIdx=-1, bool isPrefix=false, bool caseSensitive=false, bool use_inheritance=true, short int kindMask=0xFFFF, TokenIdxSet *search_scope=0) |
Artificial Intelligence Matching. More... | |
void | FindCurrentFunctionScope (TokenTree *tree, const TokenIdxSet &procResult, TokenIdxSet &scopeResult) |
if the expression return the container tokens, which are the parent of the expression. More... | |
void | CleanupSearchScope (TokenTree *tree, TokenIdxSet *searchScope) |
remove all the container tokens in the token index set. More... | |
void | GetCallTipHighlight (const wxString &calltip, int *start, int *end, int typedCommas) |
Returns the start and end of the call-tip highlight region. More... | |
int | FindFunctionOpenParenthesis (const wxString &calltip) |
Finds the position of the opening parenthesis marking the beginning of the params. More... | |
wxString | GetCCToken (wxString &line, ParserTokenType &tokenType, OperatorType &tokenOperatorType) |
helper function to split the statement More... | |
unsigned int | FindCCTokenStart (const wxString &line) |
helper function to split the statement More... | |
wxString | GetNextCCToken (const wxString &line, unsigned int &startAt, OperatorType &tokenOperatorType) |
helper function to read the next CCToken, begin from the startAt, this point to a non-space character, and fetch the beginning identifier More... | |
void | RemoveLastFunctionChildren (TokenTree *tree, int &lastFuncTokenIdx) |
Remove the last function's children, when doing codecompletion in a function body, the function body up to the caret position was parsed, and the local variables defined in the function were recorded as the function's children. More... | |
size_t | BreakUpComponents (const wxString &actual, std::queue< ParserComponent > &components) |
break a statement to several ParserComponents, and store them in a queue. More... | |
size_t | ResolveExpression (TokenTree *tree, std::queue< ParserComponent > components, const TokenIdxSet &searchScope, TokenIdxSet &result, bool caseSense=true, bool isPrefix=false) |
A statement(expression) is expressed by a ParserComponent queue We do a match from the left of the queue one by one. More... | |
void | ResolveOperator (TokenTree *tree, const OperatorType &tokenOperatorType, const TokenIdxSet &tokens, const TokenIdxSet &searchScope, TokenIdxSet &result) |
used to solve the overloaded operator functions return type More... | |
size_t | ResolveActualType (TokenTree *tree, wxString searchText, const TokenIdxSet &searchScope, TokenIdxSet &result) |
Get the Type information of the searchText string. More... | |
void | ResolveTemplateMap (TokenTree *tree, const wxString &searchStr, const TokenIdxSet &actualTypeScope, TokenIdxSet &initialScope) |
resolve template map [formal parameter] to [actual parameter] More... | |
void | AddTemplateAlias (TokenTree *tree, const int &id, const TokenIdxSet &actualTypeScope, TokenIdxSet &initialScope) |
add template parameter, get the actual parameter from the formal parameter list More... | |
size_t | GenerateResultSet (TokenTree *tree, const wxString &target, int parentIdx, TokenIdxSet &result, bool caseSens=true, bool isPrefix=false, short int kindMask=0xFFFF) |
Generate the matching results under the Parent Token index set. More... | |
size_t | GenerateResultSet (TokenTree *tree, const wxString &target, const TokenIdxSet &ptrParentID, TokenIdxSet &result, bool caseSens=true, bool isPrefix=false, short int kindMask=0xFFFF) |
This function is just like the one above, especially that it use a single parent Token id, not the parent id set in previous one. More... | |
bool | IsAllocator (TokenTree *tree, const int &id) |
Test if token with this id is allocator class. More... | |
bool | DependsOnAllocator (TokenTree *tree, const int &id) |
Test if token with this id depends on allocator class. More... | |
void | CollectSearchScopes (const TokenIdxSet &searchScope, TokenIdxSet &actualTypeScope, TokenTree *tree) |
Collect search scopes, add the searchScopes's parent scope. More... | |
int | GetTokenFromCurrentLine (TokenTree *tree, const TokenIdxSet &tokens, size_t curLine, const wxString &file) |
used to get the correct token index in current line, e.g. More... | |
void | ComputeCallTip (TokenTree *tree, const TokenIdxSet &tokens, wxArrayString &items) |
call tips are tips when you are entering some functions, such as you have a class definition More... | |
bool | PrettyPrintToken (TokenTree *tree, const Token *token, wxString &result, bool isRoot=true) |
For ComputeCallTip() No critical section needed in this recursive function! All functions that call this recursive function, should already entered a critical section. More... | |
Private Attributes | |
ParserList | m_ParserList |
a list holing all the cbp->parser pairs, if in one parser per project mode, there are many many pairs in this list. More... | |
ParserBase * | m_TempParser |
a temp parser object pointer More... | |
ParserBase * | m_Parser |
active parser object pointer More... | |
wxTimer | m_TimerParsingOneByOne |
a delay timer to parser every project in sequence More... | |
ClassBrowser * | m_ClassBrowser |
symbol browser window More... | |
bool | m_ClassBrowserIsFloating |
if true, which means m_ClassBrowser is floating (not docked) More... | |
ProjectSearchDirsMap | m_ProjectSearchDirsMap |
a map: project pointer -> C/C++ parser search paths for this project, this is the per-project code completion search-dirs. More... | |
int | m_HookId |
project loader hook ID More... | |
wxImageList * | m_ImageList |
Images for class browser. More... | |
wxArrayString | m_StandaloneFiles |
all the files which opened, but does not belong to any cbp More... | |
bool | m_ParserPerWorkspace |
if true, which means the parser hold tokens of the whole workspace's project, if false then one parser per a cbp More... | |
std::set< cbProject * > | m_ParsedProjects |
only used when m_ParserPerWorkspace is true, and holds all the cbps for the common parser More... | |
wxString | m_LastAIGlobalSearch |
same case like above, it holds the search string More... | |
bool | m_LastAISearchWasGlobal |
true if the phrase for code-completion is empty or partial text (i.e. no . -> or :: operators) More... | |
cbStyledTextCtrl * | m_LastControl |
wxString | m_LastFile |
int | m_LastFunctionIndex |
int | m_LastFuncTokenIdx |
saved the function token's index, for remove all local variable More... | |
int | m_LastLine |
wxString | m_LastNamespace |
wxString | m_LastPROC |
int | m_LastResult |
Friends | |
class | CodeCompletion |
Additional Inherited Members | |
Static Private Member Functions inherited from NativeParserBase | |
static int | CountCommas (const wxString &lineText, int start) |
static bool | InsideToken (int startAt, const wxString &line) |
check whether the line[startAt] point to the identifier More... | |
static int | BeginOfToken (int startAt, const wxString &line) |
go to the first character of the identifier, e.g More... | |
static int | BeforeToken (int startAt, const wxString &line) |
static bool | IsOperatorEnd (int startAt, const wxString &line) |
check startAt is at some character like: More... | |
static bool | IsOperatorPointer (int startAt, const wxString &line) |
static bool | IsOperatorBegin (int startAt, const wxString &line) |
check if startAt point to "->" or "::" operator More... | |
static bool | IsOperatorDot (int startAt, const wxString &line) |
check whether line[startAt] is a dot character More... | |
static int | BeforeWhitespace (int startAt, const wxString &line) |
move to the char before whitespace and tabs, e.g. More... | |
static int | AfterWhitespace (int startAt, const wxString &line) |
search from left to right, move the cursor to the first character after the space More... | |
static bool | IsOpeningBracket (int startAt, const wxString &line) |
Test whether the current character is a '(' or '['. More... | |
static bool | IsClosingBracket (int startAt, const wxString &line) |
check the current char (line[startAt]) is either ')' or ']' More... | |
NativeParser class is just like a manager class to control Parser objects.
Normally, Each C::B Project (cbp) will have an associated Parser object. In another mode, all C::B project belong to a C::B workspace share a single Parser object. Nativeparser will manage all the Parser objects.
Definition at line 55 of file nativeparser.h.
|
private |
Definition at line 459 of file nativeparser.h.
|
private |
Definition at line 458 of file nativeparser.h.
NativeParser::NativeParser | ( | ) |
Constructor.
Definition at line 130 of file nativeparser.cpp.
References _T, wxImageList::Add(), cbLoadBitmap(), Manager::Get(), Manager::GetConfigManager(), ConfigManager::GetDataFolder(), ParserCommon::idParserEnd, ParserCommon::idParserStart, idTimerParsingOneByOne, m_HookId, m_ImageList, m_Parser, m_ParserPerWorkspace, m_TempParser, OnParserEnd(), OnParserStart(), OnParsingOneByOneTimer(), OnProjectLoadingHook(), ConfigManager::ReadBool(), ProjectLoaderHooks::RegisterHook(), wxBITMAP_TYPE_PNG, and wxEVT_TIMER.
NativeParser::~NativeParser | ( | ) |
Destructor.
Definition at line 244 of file nativeparser.cpp.
References ClearParsers(), Delete(), ParserCommon::idParserEnd, ParserCommon::idParserStart, idTimerParsingOneByOne, m_HookId, m_ImageList, m_TempParser, OnParserEnd(), OnParserStart(), OnParsingOneByOneTimer(), RemoveClassBrowser(), ProjectLoaderHooks::UnregisterHook(), and wxEVT_TIMER.
|
private |
collect the header file search directories, those dirs include: 1, project's base dir, e.g.
if you cbp file was c:/bbb/aaa.cbp, then c:/bbb is added. 2, project's setting search dirs, for a wx project, then c:/wxWidgets2.8.12/include is added. 3, a project may has some targets, so add search dirs for those targets 4, compiler's own search path, like: c:/mingw/include
Definition at line 1884 of file nativeparser.cpp.
References _T, AddCompilerIncludeDirsToParser(), ParserBase::AddIncludeDir(), AddIncludeDirsToParser(), CCLogger::DebugLog(), CCLogger::Get(), CompileTargetBase::GetBasePath(), cbProject::GetBuildTarget(), cbProject::GetBuildTargetsCount(), Compiler::GetCommandGenerator(), CompilerFactory::GetCompiler(), CompileTargetBase::GetCompilerID(), CompilerFactory::GetDefaultCompiler(), CompileOptionsBase::GetIncludeDirs(), ParserBase::Options(), ParserOptions::platformCheck, CompileOptionsBase::SupportsCurrentPlatform(), and TRACE.
Referenced by AddProjectToParser(), and DoFullParsing().
|
private |
Add compiler include directories (from search paths) to a parser.
Definition at line 2298 of file nativeparser.cpp.
References _T, AddGCCCompilerDirs(), AddIncludeDirsToParser(), wxString::Contains(), CompilerPrograms::CPP, Compiler::GetID(), CompileOptionsBase::GetIncludeDirs(), Compiler::GetMasterPath(), Compiler::GetPrograms(), ParserBase::Options(), ParserOptions::platformCheck, CompileOptionsBase::SupportsCurrentPlatform(), and wxEmptyString.
Referenced by AddCompilerDirs().
|
private |
collect compiler specific predefined preprocessor definition, this is usually run a special compiler command, like GCC -dM for gcc.
Definition at line 1969 of file nativeparser.cpp.
References _T, AddCompilerPredefinedMacrosGCC(), AddCompilerPredefinedMacrosVC(), ParserBase::AddPredefinedMacros(), wxString::Contains(), CompileTargetBase::GetCompilerID(), CompilerFactory::GetDefaultCompilerID(), wxString::IsEmpty(), ParserBase::Options(), wxString::StartsWith(), TRACE, ParserOptions::wantPreprocessor, and wxString::wx_str().
Referenced by AddProjectToParser(), and DoFullParsing().
|
private |
collect GCC compiler predefined preprocessor definition
Definition at line 2006 of file nativeparser.cpp.
References _T, CompilerPrograms::CPP, CCLogger::DebugLog(), wxFileName::FileExists(), wxString::Format(), CCLogger::Get(), Manager::Get(), CompilerFactory::GetCompiler(), GetCompilerStandardGCC(), Manager::GetMacrosManager(), Compiler::GetMasterPath(), Compiler::GetPrograms(), Manager::IsAppShuttingDown(), ParserBase::Options(), ParserOptions::platformCheck, MacrosManager::ReplaceMacros(), CompileOptionsBase::SupportsCurrentPlatform(), TRACE, wxString::wx_str(), wxEXEC_NODISABLE, wxEXEC_SYNC, and wxExecute().
Referenced by AddCompilerPredefinedMacros().
|
private |
collect VC compiler predefined preprocessor definition
Definition at line 2115 of file nativeparser.cpp.
References _T, CompilerPrograms::C, wxString::Contains(), wxFileName::FileExists(), wxString::Find(), Manager::Get(), CompilerFactory::GetCompiler(), Manager::GetMacrosManager(), Compiler::GetMasterPath(), Compiler::GetPrograms(), Manager::IsAppShuttingDown(), wxArrayString::IsEmpty(), wxString::IsSameAs(), wxString::Length(), wxString::Mid(), ParserBase::Options(), ParserOptions::platformCheck, MacrosManager::ReplaceMacros(), CompileOptionsBase::SupportsCurrentPlatform(), TRACE, wxEXEC_NODISABLE, wxEXEC_SYNC, wxExecute(), and wxNOT_FOUND.
Referenced by AddCompilerPredefinedMacros().
bool NativeParser::AddFileToParser | ( | cbProject * | project, |
const wxString & | filename, | ||
ParserBase * | parser = nullptr |
||
) |
New file was added to the C::B project, so this will cause a re-parse on the new added file.
project | C::B project |
filename | filename with full path in the C::B project |
Definition at line 664 of file nativeparser.cpp.
References _T, ParserBase::AddFile(), ParserCommon::FileType(), ParserCommon::ftOther, GetParserByProject(), TRACE, and ParserBase::UpdateParsingProject().
Referenced by AddProjectToParser(), and OnEditorActivated().
|
private |
Add the collected default GCC compiler include search paths to a parser.
Definition at line 2408 of file nativeparser.cpp.
References _T, ParserBase::AddIncludeDir(), wxFileName::AppendDir(), Manager::Get(), wxArrayString::GetCount(), wxFileName::GetFullPath(), GetGCCCompilerDirs(), Manager::GetMacrosManager(), MacrosManager::ReplaceMacros(), wxFileName::SetPath(), TRACE, and wxEmptyString.
Referenced by AddCompilerIncludeDirsToParser().
|
private |
Add a list of directories to the parser's search directories, normalise to "base" path, if "base" is not empty.
Replaces macros.
Definition at line 2425 of file nativeparser.cpp.
References _T, ParserBase::AddIncludeDir(), CCLogger::DebugLog(), F(), CCLogger::Get(), Manager::Get(), wxArrayString::GetCount(), wxFileName::GetFullPath(), Manager::GetMacrosManager(), wxString::IsEmpty(), NormalizePath(), MacrosManager::ReplaceMacros(), TRACE, and wxString::wx_str().
Referenced by AddCompilerDirs(), AddCompilerIncludeDirsToParser(), and DoFullParsing().
|
static |
Add the paths to path array, and this will be used in GetAllPathsByFilename() function.
internally, all the folder paths were recorded in UNIX format.
dirs | the target dir collection |
path | the new added path |
hasExt | the file path has extensions, such as C:/aaa/bbb.cpp |
Definition at line 542 of file nativeparser.cpp.
References _T, wxArrayString::Add(), wxString::BeforeLast(), wxArrayString::Index(), UnixFilename(), and wxNOT_FOUND.
Referenced by GetAllPathsByFilename().
|
private |
collect project (user) defined preprocessor definition, such as for wxWidgets project, the macro may have "#define wxUSE_UNICODE" defined in its project file.
Definition at line 2218 of file nativeparser.cpp.
References _T, wxArrayString::Add(), ParserBase::AddPredefinedMacros(), wxString::Contains(), wxString::Find(), Manager::Get(), cbProject::GetActiveBuildTarget(), cbProject::GetBuildTarget(), CompileTargetBase::GetCompilerID(), CompileOptionsBase::GetCompilerOptions(), wxArrayString::GetCount(), cbProject::GetExpandedVirtualBuildTargetGroup(), Manager::GetMacrosManager(), wxString::IsEmpty(), wxString::Length(), NULL, ParserBase::Options(), ParserOptions::platformCheck, MacrosManager::ReplaceMacros(), wxString::Right(), wxString::StartsWith(), CompileOptionsBase::SupportsCurrentPlatform(), TRACE, wxString::wx_str(), wxEmptyString, and wxNOT_FOUND.
Referenced by AddProjectToParser(), and DoFullParsing().
|
private |
Add one project to the common parser in one parser for the whole workspace mode.
Definition at line 2705 of file nativeparser.cpp.
References _(), _T, wxArrayString::Add(), AddCompilerDirs(), AddCompilerPredefinedMacros(), AddFileToParser(), ParserBase::AddIncludeDir(), AddProjectDefinedMacros(), CCLogger::DebugLog(), F(), ProjectFile::file, FileTypeOf(), ftHeader, ftSource, ftTemplateSource, CCLogger::Get(), Manager::Get(), EditorManager::GetActiveEditor(), Manager::GetEditorManager(), EditorBase::GetFilename(), cbProject::GetFilesList(), wxFileName::GetFullPath(), GetParserByProject(), CompileTargetBase::GetTitle(), CCLogger::Log(), m_ParsedProjects, m_StandaloneFiles, ProjectFile::relativeFilename, ParserBase::UpdateParsingProject(), and wxString::wx_str().
Referenced by OnParsingOneByOneTimer().
|
private |
Start an Artificial Intelligence search algorithm to gather all the matching tokens.
The actual AI is in FindAIMatches() below.
result | output parameter. |
searchData | cbEditor information. |
lineText | current statement. |
isPrefix | if true, then the result contains all the tokens whose name is a prefix of current lineText. |
caseSensitive | true is case sensitive is enabled on the match. |
search_scope | it is the "parent token" where we match the "search-key". |
caretPos | use current caret position if it is -1. |
Definition at line 1321 of file nativeparser.cpp.
References _T, NativeParserBase::BreakUpComponents(), NativeParserBase::CleanupSearchScope(), wxString::Clear(), ccSearchData::control, CCLogger::DebugLog(), F(), NativeParserBase::FindCurrentFunctionScope(), FindCurrentFunctionToken(), CCLogger::Get(), wxScintilla::GetCurrentPos(), wxScintilla::GetLength(), wxScintilla::GetTextRange(), ParserBase::GetTokenTree(), wxString::IsEmpty(), wxScintilla::LineFromPosition(), m_LastAIGlobalSearch, m_LastAISearchWasGlobal, m_Parser, wxScintilla::PositionFromLine(), NativeParserBase::ResolveExpression(), s_DebugSmartSense, TRACE, wxString::Trim(), and wxString::wx_str().
Referenced by MarkItemsByAI().
|
protected |
Clear all Parser object.
Definition at line 1161 of file nativeparser.cpp.
References _T, DeleteParser(), m_ParsedProjects, m_ParserList, m_ParserPerWorkspace, and TRACE.
Referenced by RereadParserOptions(), and ~NativeParser().
void NativeParser::CreateClassBrowser | ( | ) |
create the class browser
Definition at line 968 of file nativeparser.cpp.
References _(), _T, cbAuiNotebook::AddPage(), cbEVT_ADD_DOCK_WINDOW, CodeBlocksDockEvent::desiredSize, CodeBlocksDockEvent::dockSide, CodeBlocksDockEvent::dsRight, CodeBlocksDockEvent::floatingSize, Manager::Get(), Manager::GetConfigManager(), cbProjectManagerUI::GetNotebook(), Manager::GetProjectManager(), ProjectManager::GetUI(), CodeBlocksDockEvent::hideable, m_ClassBrowser, m_ClassBrowserIsFloating, m_Parser, CodeBlocksDockEvent::minimumSize, CodeBlocksDockEvent::name, Manager::ProcessEvent(), CodeBlocksDockEvent::pWindow, ConfigManager::ReadBool(), wxSize::Set(), ClassBrowser::SetParser(), CodeBlocksDockEvent::shown, CodeBlocksDockEvent::title, TRACE, and ClassBrowser::UpdateSash().
Referenced by RereadParserOptions().
ParserBase * NativeParser::CreateParser | ( | cbProject * | project | ) |
Dynamically allocate a Parser object for the input C::B project, note that while create a new Parser object, the DoFullParsing() function will be called, which collect the macro definitions, and start the batch parsing from the thread pool.
project | C::B project |
Definition at line 554 of file nativeparser.cpp.
References _(), _T, CCLogger::DebugLog(), DoFullParsing(), F(), CCLogger::Get(), GetParserByProject(), CompileTargetBase::GetTitle(), CCLogger::Log(), m_ParsedProjects, m_Parser, m_ParserList, m_ParserPerWorkspace, m_TempParser, RemoveObsoleteParsers(), SetParser(), TRACE, and wxString::wx_str().
Referenced by OnEditorActivated(), OnParsingOneByOneTimer(), ReparseCurrentProject(), ReparseSelectedProject(), and RereadParserOptions().
bool NativeParser::DeleteParser | ( | cbProject * | project | ) |
delete the Parser object for the input project
project | C::B project. |
Definition at line 594 of file nativeparser.cpp.
References _(), _T, CCLogger::DebugLog(), F(), CCLogger::Get(), CompileTargetBase::GetTitle(), CCLogger::Log(), m_ParsedProjects, m_Parser, m_ParserList, m_ParserPerWorkspace, m_TempParser, RemoveProjectFromParser(), SetParser(), and wxString::wx_str().
Referenced by ClearParsers(), OnEditorActivated(), OnEditorClosed(), RemoveObsoleteParsers(), ReparseCurrentProject(), and ReparseSelectedProject().
|
protected |
When a Parser is created, we need a full parsing stage including: 1, parse the priority header files firstly.
2, parse all the other project files.
Definition at line 1054 of file nativeparser.cpp.
References _T, ParserBase::AddBatchParse(), AddCompilerDirs(), AddCompilerPredefinedMacros(), AddIncludeDirsToParser(), AddProjectDefinedMacros(), CCLogger::DebugLog(), F(), ProjectFile::file, ParserCommon::FileType(), ParserCommon::ftSource, CCLogger::Get(), CompileTargetBase::GetBasePath(), cbProject::GetFilesList(), wxFileName::GetFullPath(), GetProjectSearchDirs(), CompileTargetBase::GetTitle(), ParserBase::Options(), ParserOptions::platformCheck, ProjectFile::relativeFilename, CompileOptionsBase::SupportsCurrentPlatform(), TRACE, and wxString::wx_str().
Referenced by CreateParser().
bool NativeParser::Done | ( | ) |
Return true if all the parser's batch-parse stages are finished, otherwise return false.
Definition at line 350 of file nativeparser.cpp.
References _T, m_ParserList, and TRACE.
|
private |
returns the position where the current function scope starts.
optionally, returns the function's namespace (ends in double-colon ::), name and token
[in] | searchData | search data struct pointer |
[out] | nameSpace | get the namespace modifier |
[out] | procName | get the function name |
[out] | functionToken | get the token of current function |
caretPos | caret position in cbEditor |
Definition at line 1454 of file nativeparser.cpp.
References _T, TokenTree::at(), CC_LOCKER_TRACK_TT_MTX_LOCK, CC_LOCKER_TRACK_TT_MTX_UNLOCK, ccSearchData::control, CCLogger::DebugLog(), Token::DisplayName(), F(), ccSearchData::file, ParserBase::FindTokensInFile(), CCLogger::Get(), wxScintilla::GetCharAt(), wxScintilla::GetCurrentPos(), wxScintilla::GetLength(), wxScintilla::GetModify(), Token::GetNamespace(), NativeParserBase::GetTokenFromCurrentLine(), ParserBase::GetTokenTree(), wxScintilla::LineFromPosition(), Token::m_ImplLine, Token::m_Index, m_LastControl, m_LastFile, m_LastFunctionIndex, m_LastLine, m_LastNamespace, m_LastPROC, m_LastResult, Token::m_Name, m_Parser, Token::m_TokenKind, wxScintilla::PositionFromLine(), s_DebugSmartSense, s_TokenTreeMutex, tkAnyFunction, tkClass, TRACE, and wxString::wx_str().
Referenced by FindCurrentFunctionToken(), and ParseLocalBlock().
|
private |
return all the tokens matching the current function(hopefully, just one)
editor | editor pointer |
result | output result containing all the Token index |
caretPos | -1 if the current caret position is used. |
Definition at line 1405 of file nativeparser.cpp.
References NativeParserBase::BreakUpComponents(), CC_LOCKER_TRACK_TT_MTX_LOCK, CC_LOCKER_TRACK_TT_MTX_UNLOCK, NativeParserBase::FindAIMatches(), FindCurrentFunctionStart(), NativeParserBase::GenerateResultSet(), ParserBase::GetTokenTree(), wxString::IsEmpty(), m_Parser, wxString::RemoveLast(), s_TokenTreeMutex, tkAnyFunction, tkClass, tkNamespace, and tkTypedef.
Referenced by AI(), and ParseFunctionArguments().
wxArrayString NativeParser::GetAllPathsByFilename | ( | const wxString & | filename | ) |
Get the implementation file path if the input is a header file.
or Get the header file path if the input is an implementation file. Both the implementation file and header file can be in different directories.
filename | input filename |
Definition at line 465 of file nativeparser.cpp.
References _T, AddPaths(), wxFileName::AppendDir(), CCLogger::DebugLog(), wxFileName::DirExists(), F(), CCLogger::Get(), cbProject::GetCommonTopLevelPath(), wxArrayString::GetCount(), GetCurrentProject(), wxFileName::GetExt(), wxFileName::GetFullPath(), wxFileName::GetName(), wxFileName::GetPath(), GetProjectByParser(), wxFileName::HasExt(), wxArrayString::IsEmpty(), wxDir::IsOpened(), IsParserPerWorkspace(), m_Parser, wxString::StartsWith(), TRACE, wxDir::Traverse(), wxDIR_DIRS, wxDIR_FILES, wxEmptyString, and wxT.
Referenced by ClassBrowserBuilderThread::Init().
int NativeParser::GetCallTips | ( | wxArrayString & | items, |
int & | typedCommas, | ||
cbEditor * | ed, | ||
int | pos = wxNOT_FOUND |
||
) |
Call tips are tips when you are typing function arguments these tips information could be: the prototypes information of the current function, the type information of the variable.
Here are the basic algorithm
if you have a function declaration like this: int fun(int a, float b, char c); when user are typing code, the caret is located here fun(arg1, arg2| ^end ^ begin we first do a backward search, should find the "fun" as the function name and later return the string "int fun(int a, float b, char c)" as the call tip typedCommas is 1, since one argument is already typed.
[out] | items | array to store the tip results. |
typedCommas | how much comma characters the user has typed in the current line before the cursor. | |
ed | the editor | |
pos | the location of the caret, if not supplied, the current caret is used |
Definition at line 883 of file nativeparser.cpp.
References _T, wxArrayString::Add(), wxArrayString::Clear(), NativeParserBase::ComputeCallTip(), ccSearchData::control, ParserBase::Done(), wxScintilla::GetCharAt(), cbEditor::GetControl(), wxScintilla::GetCurrentPos(), EditorBase::GetFilename(), wxScintilla::GetStyleAt(), wxScintilla::GetTextRange(), ParserBase::GetTokenTree(), cbStyledTextCtrl::IsCharacter(), cbStyledTextCtrl::IsComment(), wxString::IsEmpty(), cbStyledTextCtrl::IsString(), m_Parser, MarkItemsByAI(), wxArrayString::Sort(), TRACE, wxScintilla::WordEndPosition(), wxScintilla::WordStartPosition(), wxString::wx_str(), wxNOT_FOUND, wxSCI_INVALID_POSITION, and wxT.
|
inline |
return active class browser pointer
Definition at line 235 of file nativeparser.h.
References wxNullBitmap.
lookup GCC compiler -std=XXX option
Definition at line 2071 of file nativeparser.cpp.
References cbProject::GetBuildTarget(), cbProject::GetBuildTargetsCount(), CompileOptionsBase::GetCompilerOptions(), GetCompilerUsingStandardGCC(), and wxString::IsEmpty().
Referenced by AddCompilerPredefinedMacrosGCC().
|
private |
lookup GCC compiler -std=XXX option for specific GCC options
Definition at line 2100 of file nativeparser.cpp.
References _T, CCLogger::DebugLog(), wxString::Format(), CCLogger::Get(), and wxString::wx_str().
Referenced by GetCompilerStandardGCC().
cbProject * NativeParser::GetCurrentProject | ( | ) |
Get current project by active editor or just return active project.
Definition at line 341 of file nativeparser.cpp.
References Manager::Get(), ProjectManager::GetActiveProject(), EditorManager::GetBuiltinActiveEditor(), Manager::GetEditorManager(), GetProjectByEditor(), and Manager::GetProjectManager().
Referenced by GetAllPathsByFilename(), ClassBrowser::OnJumpTo(), ClassBrowser::OnTreeItemDoubleClick(), ReparseCurrentProject(), RereadParserOptions(), and ClassBrowser::UpdateClassBrowserView().
|
private |
Collect the default compiler include file search paths.
called by AddCompilerDirs() function
Definition at line 2319 of file nativeparser.cpp.
References _T, CCLogger::DebugLog(), wxFileName::DirExists(), CCLogger::Get(), wxArrayString::GetCount(), wxFileName::GetPath(), wxFileName::GetVolume(), Manager::IsAppShuttingDown(), wxArrayString::IsEmpty(), wxString::MakeUpper(), wxFileName::Normalize(), wxFileName::SetVolume(), wxString::StartsWith(), TRACE, wxEmptyString, wxEXEC_NODISABLE, wxEXEC_SYNC, wxExecute(), and wxFileExists().
Referenced by AddGCCCompilerDirs().
|
inline |
Used to support Symbol browser and codecompletion UI Image list is used to initialize the symbol browser tree node image.
Definition at line 113 of file nativeparser.h.
References wxNOT_FOUND.
Referenced by ClassBrowserBuilderThread::BuildTree().
|
inline |
return a reference to the currently active Parser object
Definition at line 65 of file nativeparser.h.
Referenced by ClassBrowserBuilderThread::CreateSpecialFolders(), CodeRefactoring::GetSymbolUnderCursor(), ClassBrowserBuilderThread::Init(), DocumentationHelper::OnDocumentationLink(), CodeRefactoring::Parse(), and CodeRefactoring::VerifyResult().
ParserBase * NativeParser::GetParserByFilename | ( | const wxString & | filename | ) |
return the Parser pointer associated with the input file If a file belongs to several Parser objects, the first found Parser will returned.
filename | filename with full path. |
Definition at line 277 of file nativeparser.cpp.
References GetParserByProject(), and GetProjectByFilename().
ParserBase * NativeParser::GetParserByProject | ( | cbProject * | project | ) |
return the Parser pointer corresponding to the input C::B project
project | input C::B project pointer |
Definition at line 256 of file nativeparser.cpp.
References _T, m_ParsedProjects, m_ParserList, m_ParserPerWorkspace, and TRACE.
Referenced by AddFileToParser(), AddProjectToParser(), CreateParser(), GetParserByFilename(), GetParserInfoByCurrentEditor(), GetProjectByFilename(), OnEditorActivated(), RemoveFileFromParser(), RemoveProjectFromParser(), ReparseFile(), and SwitchParser().
|
protected |
Get cbProject and Parser pointer, according to the current active editor.
Definition at line 1220 of file nativeparser.cpp.
References Manager::Get(), EditorManager::GetBuiltinActiveEditor(), Manager::GetEditorManager(), GetParserByProject(), and GetProjectByEditor().
Referenced by OnParserEnd(), OnParserStart(), OnParsingOneByOneTimer(), and RemoveObsoleteParsers().
return the C::B project containing the cbEditor pointer
editor | Any valid cbEditor pointer |
Definition at line 331 of file nativeparser.cpp.
References EditorBase::GetFilename(), ProjectFile::GetParentProject(), GetProjectByFilename(), and cbEditor::GetProjectFile().
Referenced by CodeRefactoring::DoRenameSymbols(), GetCurrentProject(), GetParserInfoByCurrentEditor(), OnEditorActivated(), and CodeRefactoring::Parse().
return the C::B project containing the filename The function first try to match the filename in the active project, next to match other projects opened, If the file exists in several projects, the first matched project will be returned.
filename | input filename |
Definition at line 295 of file nativeparser.cpp.
References _T, Manager::Get(), ProjectManager::GetActiveProject(), cbProject::GetFileByFilename(), GetParserByProject(), Manager::GetProjectManager(), ProjectManager::GetProjects(), ParserBase::IsFileParsed(), TRACE, and wxString::wx_str().
Referenced by GetParserByFilename(), and GetProjectByEditor().
cbProject * NativeParser::GetProjectByParser | ( | ParserBase * | parser | ) |
return the C::B project associated with Parser pointer
parser | Parser pointer |
Definition at line 283 of file nativeparser.cpp.
References _T, m_ParserList, NULL, and TRACE.
Referenced by GetAllPathsByFilename(), ClassBrowser::OnJumpTo(), ClassBrowser::OnTreeItemDoubleClick(), and ClassBrowser::UpdateClassBrowserView().
wxArrayString & NativeParser::GetProjectSearchDirs | ( | cbProject * | project | ) |
project search path is used for auto completion for #include <>
Definition at line 958 of file nativeparser.cpp.
References m_ProjectSearchDirsMap.
Referenced by DoFullParsing(), CCOptionsProjectDlg::OnApply(), and OnProjectLoadingHook().
int NativeParser::GetTokenKindImage | ( | const Token * | token | ) |
Returns the image assigned to a specific token for a symbol browser.
Definition at line 365 of file nativeparser.cpp.
References Token::m_Scope, Token::m_TokenKind, PARSER_IMG_CLASS, PARSER_IMG_CLASS_PRIVATE, PARSER_IMG_CLASS_PROTECTED, PARSER_IMG_CLASS_PUBLIC, PARSER_IMG_CTOR_PRIVATE, PARSER_IMG_CTOR_PROTECTED, PARSER_IMG_CTOR_PUBLIC, PARSER_IMG_DTOR_PRIVATE, PARSER_IMG_DTOR_PROTECTED, PARSER_IMG_DTOR_PUBLIC, PARSER_IMG_ENUM, PARSER_IMG_ENUM_PRIVATE, PARSER_IMG_ENUM_PROTECTED, PARSER_IMG_ENUM_PUBLIC, PARSER_IMG_ENUMERATOR, PARSER_IMG_FUNC_PRIVATE, PARSER_IMG_FUNC_PROTECTED, PARSER_IMG_FUNC_PUBLIC, PARSER_IMG_MACRO_DEF, PARSER_IMG_MACRO_USE, PARSER_IMG_MACRO_USE_PRIVATE, PARSER_IMG_MACRO_USE_PROTECTED, PARSER_IMG_MACRO_USE_PUBLIC, PARSER_IMG_NAMESPACE, PARSER_IMG_NONE, PARSER_IMG_TYPEDEF, PARSER_IMG_TYPEDEF_PRIVATE, PARSER_IMG_TYPEDEF_PROTECTED, PARSER_IMG_TYPEDEF_PUBLIC, PARSER_IMG_VAR_PRIVATE, PARSER_IMG_VAR_PROTECTED, PARSER_IMG_VAR_PUBLIC, tkAnyContainer, tkAnyFunction, tkClass, tkConstructor, tkDestructor, tkEnum, tkEnumerator, tkFunction, tkMacroDef, tkMacroUse, tkNamespace, tkTypedef, tkUndefined, tkVariable, tsPrivate, tsProtected, tsPublic, and tsUndefined.
Referenced by ClassBrowserBuilderThread::AddNodes().
|
private |
Init cc search member variables.
Definition at line 2692 of file nativeparser.cpp.
References wxString::Clear(), m_LastControl, m_LastFile, m_LastFunctionIndex, m_LastLine, m_LastNamespace, m_LastPROC, m_LastResult, and NativeParserBase::Reset().
Referenced by SetParser().
|
inline |
Return true if use one Parser per whole workspace.
Definition at line 105 of file nativeparser.h.
Referenced by GetAllPathsByFilename(), ClassBrowser::OnJumpTo(), ClassBrowser::OnTreeItemDoubleClick(), ClassBrowser::OnViewScope(), ClassBrowser::SetParser(), and ClassBrowser::UpdateClassBrowserView().
|
inlineprivate |
The same as above.
Definition at line 343 of file nativeparser.h.
References CodeCompletion::OnEditorActivated(), CodeCompletion::OnEditorClosed(), CodeCompletion::OnParserEnd(), and CodeCompletion::OnParserStart().
|
inlineprivate |
used in CodeCompletion suggestion list to boost the performance, we use a caches
Definition at line 340 of file nativeparser.h.
size_t NativeParser::MarkItemsByAI | ( | ccSearchData * | searchData, |
TokenIdxSet & | result, | ||
bool | reallyUseAI = true , |
||
bool | isPrefix = true , |
||
bool | caseSensitive = false , |
||
int | caretPos = -1 |
||
) |
collect tokens where a code suggestion list can be shown
[in] | searchData | search location, the place where the caret locates |
[out] | result | containing all matching result token indexes |
reallyUseAI | true means the context scope information should be considered, false if only do a plain word match | |
isPrefix | partially match which result all the Tokens' name with the same prefix, otherwise use full-text match | |
caseSensitive | case sensitive or not | |
caretPos | Where the current caret locates, -1 means we use the current caret position. |
Definition at line 802 of file nativeparser.cpp.
References _(), _T, AI(), CC_LOCKER_TRACK_TT_MTX_LOCK, CC_LOCKER_TRACK_TT_MTX_UNLOCK, TokenTree::Clear(), CCLogger::DebugLog(), ParserBase::Done(), CCLogger::Get(), ParserBase::GetTempTokenTree(), ParserBase::GetTokenTree(), m_LastFuncTokenIdx, m_Parser, ParserBase::NotDoneReason(), ParseFunctionArguments(), ParseLocalBlock(), ParseUsingNamespace(), NativeParserBase::RemoveLastFunctionChildren(), s_TokenTreeMutex, TokenTree::size(), TRACE, and wxEmptyString.
Referenced by GetCallTips(), MarkItemsByAI(), CodeRefactoring::Parse(), and CodeRefactoring::VerifyResult().
size_t NativeParser::MarkItemsByAI | ( | TokenIdxSet & | result, |
bool | reallyUseAI = true , |
||
bool | isPrefix = true , |
||
bool | caseSensitive = false , |
||
int | caretPos = -1 |
||
) |
the same as before, but we don't specify the searchData information, so it will use the active editor and current caret information.
Definition at line 861 of file nativeparser.cpp.
References _T, ccSearchData::control, CCLogger::DebugLog(), F(), CCLogger::Get(), Manager::Get(), EditorManager::GetBuiltinActiveEditor(), cbEditor::GetControl(), Manager::GetEditorManager(), EditorBase::GetFilename(), MarkItemsByAI(), s_DebugSmartSense, and TRACE.
|
private |
Event handler when an editor activate, NONE project is handled here.
Definition at line 2612 of file nativeparser.cpp.
References _T, wxArrayString::Add(), AddFileToParser(), ParserBase::AddIncludeDir(), bdfFile, bdfProject, ParserBase::ClassBrowserOptions(), CreateParser(), CCLogger::DebugLog(), DeleteParser(), BrowserOptions::displayFilter, wxFile::Exists(), ParserCommon::FileType(), ParserCommon::ftOther, CCLogger::Get(), Manager::Get(), EditorManager::GetBuiltinEditor(), Manager::GetEditorManager(), EditorBase::GetFilename(), GetParserByProject(), wxFileName::GetPath(), GetProjectByEditor(), wxArrayString::Index(), wxArrayString::IsEmpty(), ParserBase::IsFileParsed(), m_ClassBrowser, m_Parser, m_ParserPerWorkspace, m_StandaloneFiles, m_TempParser, NULL, wxArrayString::RemoveAt(), RemoveFileFromParser(), SwitchParser(), ClassBrowser::UpdateClassBrowserView(), and wxNOT_FOUND.
|
private |
Event handler when an editor closed, if it is the last editor belong to NONE project, then the NONE Parser will be removed.
Definition at line 2677 of file nativeparser.cpp.
References DeleteParser(), EditorBase::GetFilename(), wxArrayString::Index(), wxArrayString::IsEmpty(), m_StandaloneFiles, NULL, wxArrayString::RemoveAt(), RemoveFileFromParser(), and wxNOT_FOUND.
|
private |
Event handler when the batch parse finishes, print some log information, check whether the active editor belong to the current parser, if not, do a parser switch.
Definition at line 2493 of file nativeparser.cpp.
References _(), _T, CCLogger::DebugLog(), F(), CCLogger::Get(), GetParserInfoByCurrentEditor(), CompileTargetBase::GetTitle(), CCLogger::Log(), m_Parser, m_TimerParsingOneByOne, ParserCommon::ptAddFileToParser, ParserCommon::ptCreateParser, ParserCommon::ptReparseFile, ParserCommon::ptUndefined, wxTimer::Start(), SwitchParser(), TRACE, UpdateClassBrowser(), wxString::wx_str(), and wxTIMER_ONE_SHOT.
Referenced by NativeParser(), and ~NativeParser().
|
private |
Event handler when the batch parse starts, print some log information.
Definition at line 2447 of file nativeparser.cpp.
References _(), _T, CCLogger::DebugLog(), F(), CCLogger::Get(), GetParserInfoByCurrentEditor(), CompileTargetBase::GetTitle(), m_Parser, ParserCommon::ptAddFileToParser, ParserCommon::ptCreateParser, ParserCommon::ptReparseFile, ParserCommon::ptUndefined, SwitchParser(), TRACE, and wxString::wx_str().
Referenced by NativeParser(), and ~NativeParser().
|
private |
If use one parser per whole workspace, we need parse all project one by one, E.g.
If a workspace contains A.cbp, B.cbp and C.cbp, and we are in the mode of one parser for the whole workspace, we first parse A.cbp, after that we should continue to parse B.cbp. When finishing parsing B.cbp, we need the timer again to parse the C.cbp. If we are in the mode of one parser for one project, then after parsing A.cbp, the timer is kicked, so there is a chance to parse the B.cbp or C.cbp, but only when user opened some file of B.cbp or C.cbp when the timer event arrived.
Definition at line 2550 of file nativeparser.cpp.
References _T, AddProjectToParser(), CreateParser(), CCLogger::DebugLog(), CCLogger::Get(), Manager::Get(), ProjectManager::GetActiveProject(), EditorManager::GetBuiltinActiveEditor(), Manager::GetEditorManager(), GetParserInfoByCurrentEditor(), Manager::GetProjectManager(), ProjectManager::GetProjects(), CCLogger::Log(), m_ParsedProjects, m_Parser, m_ParserPerWorkspace, SwitchParser(), and TRACE.
Referenced by NativeParser(), and ~NativeParser().
|
private |
Read or Write project' CC options when a C::B project is loading or saving user can set those settings in Menu->Project->Properties->C/C++ parser options panel.
project | which project we are handling |
elem | parent node of the project xml file (cbp) containing addtinal information |
loading | true if the project is loading |
Definition at line 1268 of file nativeparser.cpp.
References wxArrayString::Add(), cbC2U(), cbU2C(), wxArrayString::GetCount(), GetProjectSearchDirs(), wxArrayString::Index(), and wxNOT_FOUND.
Referenced by NativeParser().
|
private |
collect the using namespace directive in the buffer specified by searchData
buffer | code to parse |
search_scope | resulting tokens collection |
bufferSkipBlocks | skip brace sets { } |
Definition at line 1579 of file nativeparser.cpp.
References _T, TokenTree::at(), NativeParserBase::BreakUpComponents(), CC_LOCKER_TRACK_TT_MTX_LOCK, CC_LOCKER_TRACK_TT_MTX_UNLOCK, NativeParserBase::ParserComponent::component, CCLogger::DebugLog(), F(), CCLogger::Get(), wxArrayString::GetCount(), Token::GetNamespace(), ParserBase::GetTokenTree(), Token::m_Name, m_Parser, ParserBase::ParseBufferForUsingNamespace(), s_DebugSmartSense, s_TokenTreeMutex, tkNamespace, TokenTree::TokenExists(), and wxString::wx_str().
Referenced by ParseLocalBlock(), and ParseUsingNamespace().
|
private |
collect function argument, add them to the token tree (as temporary tokens)
searchData | search location |
caretPos | caret position, if not specified, we use the current caret position |
Definition at line 1623 of file nativeparser.cpp.
References _T, TokenTree::at(), CC_LOCKER_TRACK_TT_MTX_LOCK, CC_LOCKER_TRACK_TT_MTX_UNLOCK, ccSearchData::control, CCLogger::DebugLog(), F(), ccSearchData::file, FindCurrentFunctionToken(), CCLogger::Get(), wxScintilla::GetCurrentPos(), wxScintilla::GetLength(), ParserBase::GetTokenTree(), wxString::IsEmpty(), wxScintilla::LineFromPosition(), Token::m_Args, Token::m_ImplLine, Token::m_ImplLineEnd, Token::m_Index, Token::m_Name, m_Parser, wxString::Matches(), ParserBase::ParseBuffer(), wxScintilla::PositionFromLine(), wxString::Remove(), wxString::RemoveLast(), wxString::Replace(), s_DebugSmartSense, s_TokenTreeMutex, TRACE, wxString::Trim(), and wxString::wx_str().
Referenced by MarkItemsByAI().
|
private |
parses from the start of function up to the cursor, this is used to collect local variables.
searchData | search location |
search_scope | resulting tokens collection of local using namespace |
caretPos | caret position, if not specified, we use the current caret position |
Definition at line 1721 of file nativeparser.cpp.
References _T, TokenTree::at(), wxScintilla::BraceMatch(), CC_LOCKER_TRACK_TT_MTX_LOCK, CC_LOCKER_TRACK_TT_MTX_UNLOCK, ccSearchData::control, CCLogger::DebugLog(), Token::DisplayName(), F(), ccSearchData::file, FindCurrentFunctionStart(), wxString::Format(), CCLogger::Get(), wxScintilla::GetCharAt(), wxScintilla::GetCurrentPos(), wxScintilla::GetLength(), wxScintilla::GetLineEndPosition(), wxScintilla::GetStyleAt(), wxScintilla::GetTextRange(), ParserBase::GetTokenTree(), cbStyledTextCtrl::IsCharacter(), cbStyledTextCtrl::IsComment(), wxString::IsEmpty(), cbStyledTextCtrl::IsString(), wxScintilla::LineFromPosition(), Token::m_ImplLineStart, Token::m_Index, Token::m_IsTemp, m_LastFuncTokenIdx, Token::m_Name, Token::m_ParentIndex, m_Parser, Token::m_TokenKind, ParserBase::ParseBuffer(), ParseBufferForUsingNamespace(), wxString::Prepend(), s_DebugSmartSense, s_TokenTreeMutex, TokenTree::size(), tkAnyFunction, TRACE, wxString::Trim(), wxScintilla::WordEndPosition(), wxScintilla::WordStartPosition(), wxString::wx_str(), wxIsspace(), and wxT.
Referenced by MarkItemsByAI().
|
private |
collect the using namespace directive in the editor specified by searchData
searchData | search location |
search_scope | resulting tokens collection |
caretPos | caret position, if not specified, we use the current caret position |
Definition at line 1563 of file nativeparser.cpp.
References _T, ccSearchData::control, CCLogger::DebugLog(), CCLogger::Get(), wxScintilla::GetCurrentPos(), wxScintilla::GetLength(), wxScintilla::GetTextRange(), ParseBufferForUsingNamespace(), s_DebugSmartSense, and TRACE.
Referenced by MarkItemsByAI().
void NativeParser::RemoveClassBrowser | ( | bool | appShutDown = false | ) |
remove the class browser
Definition at line 1016 of file nativeparser.cpp.
References _T, cbEVT_REMOVE_DOCK_WINDOW, Manager::Get(), cbProjectManagerUI::GetNotebook(), wxAuiNotebook::GetPageIndex(), Manager::GetProjectManager(), ProjectManager::GetUI(), m_ClassBrowser, m_ClassBrowserIsFloating, NULL, Manager::ProcessEvent(), CodeBlocksDockEvent::pWindow, cbAuiNotebook::RemovePage(), and TRACE.
Referenced by RereadParserOptions(), and ~NativeParser().
remove a file from C::B project and Parser
project | C::B project |
filename | filename with full patch in the C::B project |
Definition at line 684 of file nativeparser.cpp.
References _T, GetParserByProject(), ParserBase::RemoveFile(), and TRACE.
Referenced by OnEditorActivated(), OnEditorClosed(), and RemoveProjectFromParser().
|
protected |
Remove all the obsolete Parser object if the number exceeds the limited number (can be set in the CC's option), then all the obsolete parser will be removed.
Definition at line 1177 of file nativeparser.cpp.
References _(), _T, wxArrayString::Add(), CCLogger::DebugLog(), DeleteParser(), F(), CCLogger::Get(), Manager::Get(), Manager::GetConfigManager(), wxArrayString::GetCount(), GetParserInfoByCurrentEditor(), CCLogger::Log(), m_ParserList, ConfigManager::ReadInt(), and TRACE.
Referenced by CreateParser(), and RereadParserOptions().
|
private |
Remove cbp from the common parser, this only happens in one parser for whole workspace mode when a parser is removed from the workspace, we should remove the project from the parser.
Definition at line 2791 of file nativeparser.cpp.
References _(), _T, CCLogger::DebugLog(), F(), ProjectFile::file, ParserCommon::FileType(), ParserCommon::ftOther, CCLogger::Get(), cbProject::GetFilesList(), wxFileName::GetFullPath(), GetParserByProject(), CompileTargetBase::GetTitle(), CCLogger::Log(), m_ParsedProjects, ProjectFile::relativeFilename, RemoveFileFromParser(), and wxString::wx_str().
Referenced by DeleteParser().
void NativeParser::ReparseCurrentProject | ( | ) |
re-parse the active Parser (the project associated with m_Parser member variable
Definition at line 762 of file nativeparser.cpp.
References _T, CreateParser(), DeleteParser(), GetCurrentProject(), and TRACE.
Referenced by ClassBrowser::OnForceReparse().
Single file re-parse.
This was happening when you add a single file to project, or a file was modified. the main logic of this function call is: 1, once this function is called, the file will be marked as "need to be reparsed" in the token tree, and a timer(reparse timer) is started. 2, on reparse timer hit, we collect all the files marked as "need to be reparsed" from the token tree, remove them from the token tree, and call AddParse() to add parsing job, this will ticket the On batch timer 3, when on batch timer hit, it see there are some parsing jobs to do (m_BatchParseFiles is not empty), then it will run a thread job ParserThreadedTask 4, Once the ParserThreadedTask is running, it will create all the Parserthreads and run them in the thread pool
project | C::B project |
filename | filename with full path in the C::B project |
Definition at line 647 of file nativeparser.cpp.
References _T, ParserCommon::FileType(), ParserCommon::ftOther, GetParserByProject(), ParserBase::Reparse(), TRACE, and ParserBase::UpdateParsingProject().
void NativeParser::ReparseSelectedProject | ( | ) |
re-parse the project select by context menu in projects management panel
Definition at line 773 of file nativeparser.cpp.
References _T, CreateParser(), DeleteParser(), FileTreeData::ftdkProject, Manager::Get(), wxTreeCtrl::GetItemData(), FileTreeData::GetKind(), FileTreeData::GetProject(), Manager::GetProjectManager(), cbProjectManagerUI::GetTree(), cbProjectManagerUI::GetTreeSelection(), ProjectManager::GetUI(), wxTreeItemId::IsOk(), and TRACE.
void NativeParser::RereadParserOptions | ( | ) |
when user changes the CC option, we should re-read the option
Definition at line 695 of file nativeparser.cpp.
References _(), _T, cbMessageBox(), ClearParsers(), CreateClassBrowser(), CreateParser(), ParserOptions::followGlobalIncludes, ParserOptions::followLocalIncludes, Manager::Get(), Manager::GetConfigManager(), GetCurrentProject(), m_ClassBrowser, m_ClassBrowserIsFloating, m_Parser, m_ParserPerWorkspace, m_TempParser, ParserBase::Options(), ParserOptions::parseComplexMacros, ParserOptions::platformCheck, ConfigManager::ReadBool(), ParserBase::ReadOptions(), RemoveClassBrowser(), RemoveObsoleteParsers(), UpdateClassBrowser(), ParserOptions::wantPreprocessor, wxICON_QUESTION, wxID_YES, and wxYES_NO.
Referenced by CCOptionsDlg::OnApply().
|
protected |
set the class browser view mode
Definition at line 1262 of file nativeparser.cpp.
References bvmInheritance, ParserBase::ClassBrowserOptions(), m_Parser, BrowserOptions::showInheritance, and UpdateClassBrowser().
|
protected |
Set a new Parser as the active Parser Set the active parser pointer (m_Parser member variable) update the ClassBrowser's Parser pointer re-fresh the symbol browser tree.
if we did switch the parser, we also need to remove the temporary tokens of the old parser.
Definition at line 1140 of file nativeparser.cpp.
References ParserBase::GetTokenTree(), InitCCSearchVariables(), m_ClassBrowser, m_LastFuncTokenIdx, m_Parser, NativeParserBase::RemoveLastFunctionChildren(), and ClassBrowser::SetParser().
Referenced by CreateParser(), DeleteParser(), and SwitchParser().
|
protected |
Used to support Symbol browser and codecompletion UI Image list is used to initialize the symbol browser tree node image.
Definition at line 1235 of file nativeparser.cpp.
References m_ImageList, PARSER_IMG_MAX, and wxImageList::Replace().
|
protected |
|
protected |
Definition at line 1255 of file nativeparser.cpp.
References m_ImageList, PARSER_IMG_MAX, and wxImageList::Replace().
|
protected |
Switch parser object according the current active editor and filename.
Definition at line 1120 of file nativeparser.cpp.
References _(), _T, CCLogger::DebugLog(), F(), CCLogger::Get(), GetParserByProject(), CompileTargetBase::GetTitle(), CCLogger::Log(), m_Parser, SetParser(), TRACE, and wxString::wx_str().
Referenced by OnEditorActivated(), OnParserEnd(), OnParserStart(), and OnParsingOneByOneTimer().
void NativeParser::UpdateClassBrowser | ( | ) |
update the class browser tree
Definition at line 1039 of file nativeparser.cpp.
References _T, ParserBase::Done(), Manager::IsAppShuttingDown(), m_ClassBrowser, m_Parser, m_TempParser, TRACE, and ClassBrowser::UpdateClassBrowserView().
Referenced by OnParserEnd(), RereadParserOptions(), and SetCBViewMode().
|
friend |
Definition at line 287 of file nativeparser.h.
|
private |
symbol browser window
Definition at line 474 of file nativeparser.h.
Referenced by CreateClassBrowser(), OnEditorActivated(), RemoveClassBrowser(), RereadParserOptions(), SetParser(), and UpdateClassBrowser().
|
private |
if true, which means m_ClassBrowser is floating (not docked)
Definition at line 476 of file nativeparser.h.
Referenced by CreateClassBrowser(), RemoveClassBrowser(), and RereadParserOptions().
|
private |
project loader hook ID
Definition at line 482 of file nativeparser.h.
Referenced by NativeParser(), and ~NativeParser().
|
private |
Images for class browser.
Definition at line 483 of file nativeparser.h.
Referenced by NativeParser(), SetTokenKindImage(), and ~NativeParser().
|
private |
same case like above, it holds the search string
Definition at line 495 of file nativeparser.h.
Referenced by AI().
|
private |
true if the phrase for code-completion is empty or partial text (i.e. no . -> or :: operators)
Definition at line 496 of file nativeparser.h.
Referenced by AI().
|
private |
Definition at line 497 of file nativeparser.h.
Referenced by FindCurrentFunctionStart(), and InitCCSearchVariables().
|
private |
Definition at line 498 of file nativeparser.h.
Referenced by FindCurrentFunctionStart(), and InitCCSearchVariables().
|
private |
Definition at line 499 of file nativeparser.h.
Referenced by FindCurrentFunctionStart(), and InitCCSearchVariables().
|
private |
saved the function token's index, for remove all local variable
Definition at line 500 of file nativeparser.h.
Referenced by MarkItemsByAI(), ParseLocalBlock(), and SetParser().
|
private |
Definition at line 501 of file nativeparser.h.
Referenced by FindCurrentFunctionStart(), and InitCCSearchVariables().
|
private |
Definition at line 502 of file nativeparser.h.
Referenced by FindCurrentFunctionStart(), and InitCCSearchVariables().
|
private |
Definition at line 503 of file nativeparser.h.
Referenced by FindCurrentFunctionStart(), and InitCCSearchVariables().
|
private |
Definition at line 504 of file nativeparser.h.
Referenced by FindCurrentFunctionStart(), and InitCCSearchVariables().
|
private |
only used when m_ParserPerWorkspace is true, and holds all the cbps for the common parser
Definition at line 492 of file nativeparser.h.
Referenced by AddProjectToParser(), ClearParsers(), CreateParser(), DeleteParser(), GetParserByProject(), OnParsingOneByOneTimer(), and RemoveProjectFromParser().
|
private |
active parser object pointer
Definition at line 469 of file nativeparser.h.
Referenced by AI(), CreateClassBrowser(), CreateParser(), DeleteParser(), FindCurrentFunctionStart(), FindCurrentFunctionToken(), GetAllPathsByFilename(), GetCallTips(), MarkItemsByAI(), NativeParser(), OnEditorActivated(), OnParserEnd(), OnParserStart(), OnParsingOneByOneTimer(), ParseBufferForUsingNamespace(), ParseFunctionArguments(), ParseLocalBlock(), RereadParserOptions(), SetCBViewMode(), SetParser(), SwitchParser(), and UpdateClassBrowser().
|
private |
a list holing all the cbp->parser pairs, if in one parser per project mode, there are many many pairs in this list.
In one parser per workspace mode, there is only one pair, and the m_ParserList.begin()->second is the common parser for all the projects in workspace.
Definition at line 465 of file nativeparser.h.
Referenced by ClearParsers(), CreateParser(), DeleteParser(), Done(), GetParserByProject(), GetProjectByParser(), and RemoveObsoleteParsers().
|
private |
if true, which means the parser hold tokens of the whole workspace's project, if false then one parser per a cbp
Definition at line 490 of file nativeparser.h.
Referenced by ClearParsers(), CreateParser(), DeleteParser(), GetParserByProject(), NativeParser(), OnEditorActivated(), OnParsingOneByOneTimer(), and RereadParserOptions().
|
private |
a map: project pointer -> C/C++ parser search paths for this project, this is the per-project code completion search-dirs.
Definition at line 481 of file nativeparser.h.
Referenced by GetProjectSearchDirs().
|
private |
all the files which opened, but does not belong to any cbp
Definition at line 486 of file nativeparser.h.
Referenced by AddProjectToParser(), OnEditorActivated(), and OnEditorClosed().
|
private |
a temp parser object pointer
Definition at line 467 of file nativeparser.h.
Referenced by CreateParser(), DeleteParser(), NativeParser(), OnEditorActivated(), RereadParserOptions(), UpdateClassBrowser(), and ~NativeParser().
|
private |
a delay timer to parser every project in sequence
Definition at line 472 of file nativeparser.h.
Referenced by OnParserEnd().