34 #include <tinyxml/tinyxml.h> 49 #define CC_NATIVEPARSER_DEBUG_OUTPUT 0 51 #if defined (CC_GLOBAL_DEBUG_OUTPUT) 52 #if CC_GLOBAL_DEBUG_OUTPUT == 1 53 #undef CC_NATIVEPARSER_DEBUG_OUTPUT 54 #define CC_NATIVEPARSER_DEBUG_OUTPUT 1 55 #elif CC_GLOBAL_DEBUG_OUTPUT == 2 56 #undef CC_NATIVEPARSER_DEBUG_OUTPUT 57 #define CC_NATIVEPARSER_DEBUG_OUTPUT 2 61 #if CC_NATIVEPARSER_DEBUG_OUTPUT == 1 62 #define TRACE(format, args...) \ 63 CCLogger::Get()->DebugLog(F(format, ##args)) 64 #define TRACE2(format, args...) 65 #elif CC_NATIVEPARSER_DEBUG_OUTPUT == 2 66 #define TRACE(format, args...) \ 69 if (g_EnableDebugTrace) \ 70 CCLogger::Get()->DebugLog(F(format, ##args)); \ 73 #define TRACE2(format, args...) \ 74 CCLogger::Get()->DebugLog(F(format, ##args)) 76 #define TRACE(format, args...) 77 #define TRACE2(format, args...) 133 m_ClassBrowserIsFloating(false),
135 m_ParserPerWorkspace(false),
136 m_LastAISearchWasGlobal(false),
138 m_LastFunctionIndex(-1),
139 m_LastFuncTokenIdx(-1),
268 if (it->first == project)
273 TRACE(
_T(
"NativeParser::GetParserByProject(): Returning nullptr."));
287 if (it->second == parser)
291 TRACE(
_T(
"NativeParser::GetProjectByParser(): Returning NULL."));
297 TRACE(
_T(
"NativeParser::GetProjectByFilename(): %s"), filename.
wx_str());
304 || activeProject->GetFileByFilename(filename,
false,
true) )
306 return activeProject;
311 for (
size_t i = 0; i < projs->GetCount(); ++i)
314 if (!project || project == activeProject)
355 if (!it->second->Done())
361 TRACE(
_T(
"NativeParser::Done(): %s"), done ?
_T(
"true"):
_T(
"false"));
467 TRACE(
_T(
"NativeParser::GetAllPathsByFilename(): Enter"));
501 wxDir priorityDir(priorityPath);
506 CCLogger::Get()->
DebugLog(
_T(
"NativeParser::GetAllPathsByFilename(): Traversing '") + priorityPath +
_T(
"' for: ") + filespec);
508 if (priorityPathSub.
GetCount() == 1)
516 wxDir prjDir(prjPath);
522 CCLogger::Get()->
DebugLog(
_T(
"NativeParser::GetAllPathsByFilename(): Traversing '") + priorityPath +
wxT(
" - ") + prjPath +
_T(
"' for: ") + filespec);
532 for (
size_t i=0; i<files.
GetCount(); i++)
538 TRACE(
_T(
"NativeParser::GetAllPathsByFilename(): Leave"));
566 TRACE(
_T(
"NativeParser::CreateParser(): Calling DoFullParsing()"));
582 m_ParserList.push_back(std::make_pair(project, parser));
585 wxString log(
F(
_(
"NativeParser::CreateParser(): Finish creating a new parser for project '%s'"), prj.
wx_str()));
603 if (it->first == project)
614 bool removeProjectFromParser =
false;
620 wxString log(
F(
_(
"NativeParser::DeleteParser(): Deleting parser for project '%s'!"), prj.
wx_str()));
640 if (removeProjectFromParser)
659 TRACE(
_T(
"NativeParser::ReparseFile(): Calling Parser::Reparse()"));
661 return parser->
Reparse(filename);
679 TRACE(
_T(
"NativeParser::AddFileToParser(): Calling Parser::AddFile()"));
681 return parser->
AddFile(filename, project);
690 TRACE(
_T(
"NativeParser::RemoveFileFromParser(): Calling Parser::RemoveFile()"));
698 #if wxCHECK_VERSION(3, 0, 0) 699 bool useSymbolBrowser =
false;
701 bool useSymbolBrowser = cfg->
ReadBool(
_T(
"/use_symbols_browser"),
true);
702 #endif // wxCHECK_VERSION 704 if (useSymbolBrowser)
723 const bool parserPerWorkspace = cfg->
ReadBool(
_T(
"/parser_per_workspace"),
false);
735 bool reparse =
false;
745 if (
cbMessageBox(
_(
"You changed some class parser options. Do you want to " 746 "reparse your projects now, using the new options?"),
767 TRACE(
_T(
"NativeParser::ReparseCurrentProject(): Calling DeleteParser() and CreateParser()"));
780 if (!treeItem.
IsOk())
792 TRACE(
_T(
"NativeParser::ReparseSelectedProject(): Calling DeleteParser() and CreateParser()"));
813 wxString msg(
_(
"The Parser is still parsing files."));
819 TRACE(
_T(
"NativeParser::MarkItemsByAI_2()"));
849 for (
size_t i = 0; i < tree->
size(); ++i)
854 return result.size();
858 return AI(result, searchData,
wxEmptyString, isPrefix, caseSensitive, &search_scope, caretPos);
878 TRACE(
_T(
"NativeParser::MarkItemsByAI_1()"));
880 return MarkItemsByAI(&searchData, result, reallyUseAI, isPrefix, caseSensitive, caretPos);
891 items.
Add(
wxT(
"Parsing at the moment..."));
895 TRACE(
_T(
"NativeParser::GetCallTips()"));
914 else if (ch ==
_T(
','))
919 else if (ch ==
_T(
')'))
921 else if (ch ==
_T(
'('))
952 typedCommas = commas;
953 TRACE(
_T(
"NativeParser::GetCallTips(): typedCommas=%d"), typedCommas);
960 ProjectSearchDirsMap::iterator it;
970 #if wxCHECK_VERSION(3, 0, 0) 972 #endif // wxCHECK_VERSION 978 TRACE(
_T(
"NativeParser::CreateClassBrowser(): Enter"));
989 evt.
name =
_T(
"SymbolsBrowser");
990 evt.
title =
_(
"Symbols browser");
1013 TRACE(
_T(
"NativeParser::CreateClassBrowser(): Leave"));
1021 TRACE(
_T(
"NativeParser::RemoveClassBrowser()"));
1044 TRACE(
_T(
"NativeParser::UpdateClassBrowser()"));
1059 TRACE(
_T(
"NativeParser::DoFullParsing(): Enter"));
1085 for (FilesList::const_iterator fl_it = project->
GetFilesList().begin();
1106 if (!localSources.empty())
1108 CCLogger::Get()->
DebugLog(
F(
_T(
"NativeParser::DoFullParsing(): Added %lu source file(s) for project '%s' to batch-parser..."),
1109 static_cast<unsigned long>( localSources.size()), prj.
wx_str()));
1115 TRACE(
_T(
"NativeParser::DoFullParsing(): Leave"));
1124 TRACE(
_T(
"NativeParser::SwitchParser(): No need to / cannot switch."));
1128 TRACE(
_T(
"NativeParser::SwitchParser()"));
1163 TRACE(
_T(
"NativeParser::ClearParsers()"));
1179 TRACE(
_T(
"NativeParser::RemoveObsoleteParsers(): Enter"));
1182 const size_t maxParsers = cfg->
ReadInt(
_T(
"/max_parsers"), 5);
1188 bool deleted =
false;
1191 if (it->second == info.second)
1194 wxString prj = (it->first ? it->first->GetTitle() :
_T(
"*NONE*"));
1200 removedProjectNames.
Add(prj);
1210 for (
size_t i = 0; i < removedProjectNames.
GetCount(); ++i)
1212 wxString log(
F(
_(
"NativeParser::RemoveObsoleteParsers():Removed obsolete parser of '%s'"), removedProjectNames[i].wx_str()));
1217 TRACE(
_T(
"NativeParser::RemoveObsoleteParsers(): Leave"));
1222 std::pair<cbProject*, ParserBase*> info(
nullptr,
nullptr);
1275 TiXmlElement* CCConf = elem->FirstChildElement(
"code_completion");
1278 TiXmlElement* pathsElem = CCConf->FirstChildElement(
"search_path");
1281 if (pathsElem->Attribute(
"add"))
1288 pathsElem = pathsElem->NextSiblingElement(
"search_path");
1302 TiXmlElement* node = elem->FirstChildElement(
"code_completion");
1304 node = elem->InsertEndChild(TiXmlElement(
"code_completion"))->ToElement();
1308 for (
size_t i = 0; i < pdirs.
GetCount(); ++i)
1310 TiXmlElement* path = node->InsertEndChild(TiXmlElement(
"search_path"))->ToElement();
1311 if (path) path->SetAttribute(
"add",
cbU2C(pdirs[i]));
1353 TRACE(
_T(
"NativeParser::AI()"));
1376 search_scope = &scope_result;
1380 for (TokenIdxSet::const_iterator tis_it = scope_result.begin(); tis_it != scope_result.end(); ++tis_it)
1381 search_scope->insert(*tis_it);
1388 std::queue<ParserComponent> components;
1392 if (!components.empty())
1395 ResolveExpression(tree, components, *search_scope, result, caseSensitive, isPrefix);
1400 return result.size();
1423 std::queue<ParserComponent> ns;
1437 if (scope_result.empty())
1438 scope_result.insert(-1);
1442 for (TokenIdxSet::const_iterator tis_it = scope_result.begin(); tis_it != scope_result.end(); ++tis_it)
1450 return result.size();
1470 TRACE(
_T(
"NativeParser::FindCurrentFunctionStart()"));
1482 CCLogger::Get()->
DebugLog(
F(
_T(
"FindCurrentFunctionStart() Cached namespace='%s', cached proc='%s' (returning %d)"),
1500 CCLogger::Get()->
DebugLog(
F(
_T(
"FindCurrentFunctionStart() Found %lu results"), static_cast<unsigned long>(num_results)));
1507 const Token* token = tree->
at(idx);
1524 while (m_LastResult < searchData->control->GetTextLength())
1544 if (functionIndex) *functionIndex = token->
m_Index;
1567 TRACE(
_T(
"NativeParser::ParseUsingNamespace()"));
1588 for (
size_t i = 0; i < ns.
GetCount(); ++i)
1590 std::queue<ParserComponent> components;
1594 while (!components.empty())
1610 const Token* token = tree->
at(parentIdx);
1615 search_scope.insert(parentIdx);
1627 TRACE(
_T(
"NativeParser::ParseFunctionArguments()"));
1637 CCLogger::Get()->
DebugLog(
_T(
"ParseFunctionArguments() Could not determine current function's namespace..."));
1638 TRACE(
_T(
"ParseFunctionArguments() Could not determine current function's namespace..."));
1645 bool locked =
false;
1646 for (TokenIdxSet::const_iterator tis_it = proc_result.begin(); tis_it != proc_result.end(); ++tis_it)
1658 const Token* token = tree->
at(*tis_it);
1662 if (curLine < token->m_ImplLineStart || curLine > token->
m_ImplLineEnd)
1667 TRACE(
_T(
"ParseFunctionArguments() + Function match: ") + token->
m_Name);
1688 if (textLength == -1)
1693 while (paraPos < textLength && searchData->control->GetCharAt(paraPos++) != _T(
'('))
1695 while (paraPos < textLength && searchData->control->GetCharAt(paraPos++) < _T(
' '))
1725 TRACE(
_T(
"NativeParser::ParseLocalBlock()"));
1730 if (parentIdx != -1)
1736 const Token* parent = tree->
at(parentIdx);
1751 if (blockStart != -1)
1757 const int pos = (caretPos == -1 ? stc->
GetCurrentPos() : caretPos);
1760 if (blockEnd < 0 || blockEnd > stc->
GetLength())
1770 if (blockStart >= blockEnd)
1771 blockStart = blockEnd;
1776 int scanPos = blockEnd;
1777 for (
int curPos = pos; curPos > blockStart; --curPos)
1788 const int scopeStart = stc->
BraceMatch(curPos);
1789 if (scopeStart < blockStart)
1794 if (startLn < endLn)
1796 scanPos = scopeStart + 1;
1797 curPos = scopeStart;
1800 int prevCharIdx = scopeStart - 1;
1801 for (; prevCharIdx > blockStart; --prevCharIdx)
1810 const int paramStart = stc->
BraceMatch(prevCharIdx);
1811 if (paramStart < blockStart)
1813 for (prevCharIdx = paramStart - 1; prevCharIdx > blockStart; --prevCharIdx)
1822 if (text ==
wxT(
"for"))
1824 else if (text ==
wxT(
"if") || text ==
wxT(
"while") || text ==
wxT(
"catch"))
1830 if (startLn < endLn)
1858 for (
size_t i = 0; i < tree->
size(); ++i)
1860 const Token* token = tree->
at(i);
1889 TRACE(
_T(
"NativeParser::AddCompilerDirs(): Enter"));
1895 TRACE(
_T(
"NativeParser::AddCompilerDirs(): Leave"));
1902 TRACE(
_T(
"NativeParser::AddCompilerDirs(): Adding project base dir to parser: ") + base);
1906 cb::shared_ptr<CompilerCommandGenerator> generator(compiler ? compiler->
GetCommandGenerator(project) :
nullptr);
1918 memset(Compilers, 0,
sizeof(
Compiler*) * nCompilers);
1925 if (!target)
continue;
1931 if (compiler && generator)
1943 Compilers[nCompilers] = tgtCompiler;
1954 Compilers[nCompilers++] = compiler;
1958 for (
int idxCompiler = 0; idxCompiler < nCompilers; ++idxCompiler)
1964 delete [] Compilers;
1965 TRACE(
_T(
"NativeParser::AddCompilerDirs(): Leave"));
1977 TRACE(
_T(
"NativeParser::AddCompilerPredefinedMacros(): Enter"));
1996 TRACE(
_T(
"NativeParser::AddCompilerPredefinedMacros(): Add compiler predefined preprocessor macros:\n%s"), defs.
wx_str());
1999 TRACE(
_T(
"NativeParser::AddCompilerPredefinedMacros(): Leave"));
2014 TRACE(
_T(
"NativeParser::AddCompilerPredefinedMacrosGCC: Not supported on current platform!"));
2028 static std::map<wxString, wxString> gccDefsMap;
2029 if (gccDefsMap[cpp_compiler].IsEmpty())
2031 static bool reentry =
false;
2048 TRACE(
_T(
"NativeParser::AddCompilerPredefinedMacrosGCC: wxExecute failed!"));
2058 wxString& gccDefs = gccDefsMap[cpp_compiler];
2059 for (
size_t i = 0; i < output.Count(); ++i)
2060 gccDefs += output[i] +
_T(
"\n");
2062 CCLogger::Get()->
DebugLog(
_T(
"NativeParser::AddCompilerPredefinedMacrosGCC: Caching predefined macros for compiler '")
2063 + cpp_compiler +
_T(
"':\n") + gccDefs);
2066 defs = gccDefsMap[cpp_compiler];
2076 if (standard.
IsEmpty() && project)
2103 for (wxArrayString::size_type i=0; i<compilerOptions.Count(); ++i)
2105 if (compilerOptions[i].StartsWith(
_T(
"-std=")))
2107 standard = compilerOptions[i];
2118 static bool firstExecute =
true;
2126 firstExecute =
false;
2133 TRACE(
_T(
"NativeParser::AddCompilerPredefinedMacrosVC: Not supported on current platform!"));
2147 static bool reentry =
false;
2159 TRACE(
_T(
"NativeParser::AddCompilerPredefinedMacrosVC: wxExecute failed!"));
2171 TRACE(
_T(
"NativeParser::AddCompilerPredefinedMacrosVC: Can't get pre-defined macros for MSVC."));
2175 wxString compilerVersionInfo = error[0];
2177 int pos = compilerVersionInfo.
Find(tmp);
2184 defs +=
_T(
"#define _WIN32")
_T(
"\n");
2186 defs +=
_T(
"#define _WIN64")
_T(
"\n");
2189 tmp =
_T(
"Compiler Version ");
2190 pos = compilerVersionInfo.
Find(tmp);
2198 ver[pos] = ver[pos + 1];
2199 ver[pos + 1] =
_T(
'0');
2200 defs +=
_T(
"#define _MSC_VER ") + ver;
2226 TRACE(
_T(
"NativeParser::AddProjectDefinedMacros(): Enter"));
2231 defineCompilerSwitch =
_T(
"-D");
2233 defineCompilerSwitch =
_T(
"/D");
2235 if (defineCompilerSwitch.
IsEmpty())
2253 for (
size_t i = 0; i < targetOpts.
GetCount(); ++i)
2254 opts.
Add(targetOpts[i]);
2259 for (
size_t i = 0; i < targets.
GetCount(); ++i)
2268 for (
size_t j = 0; j < targetOpts.
GetCount(); ++j)
2269 opts.
Add(targetOpts[j]);
2274 for (
size_t i = 0; i < opts.
GetCount(); ++i)
2282 int pos = def.
Find(
_T(
'='));
2286 defs +=
_T(
"#define ") + def +
_T(
"\n");
2289 TRACE(
_T(
"Add project and current build target defined preprocessor macros:\n%s"), defs.
wx_str());
2291 TRACE(
_T(
"NativeParser::AddProjectDefinedMacros(): Leave"));
2300 if (!compiler || !parser)
return;
2323 static std::map<wxString, wxArrayString> dirs;
2325 cached_result = dirs[cpp_compiler];
2326 if ( !cached_result.
IsEmpty() )
2327 return cached_result;
2331 CCLogger::Get()->
DebugLog(
_T(
"NativeParser::GetGCCCompilerDirs(): Cannot get compiler dirs due to invalid compiler: ") + cpp_compiler);
2332 return cached_result;
2338 return cached_result;
2340 TRACE(
_T(
"NativeParser::GetGCCCompilerDirs(): Enter"));
2355 wxString Command = platform::windows ? (cpp_compiler +
_T(
" -v -E -x c++ nul"))
2356 : (cpp_compiler +
_T(
" -v -E -x c++ /dev/null"));
2358 static bool reentry_protection =
false;
2359 if (reentry_protection)
2360 return cached_result;
2361 reentry_protection =
true;
2367 TRACE(
_T(
"NativeParser::GetGCCCompilerDirs(): GetGCCCompilerDirs::wxExecute failed!"));
2368 reentry_protection =
false;
2369 return cached_result;
2371 reentry_protection =
false;
2376 return cached_result;
2382 for (
size_t idxCount = 0; idxCount < Errors.
GetCount(); ++idxCount)
2384 wxString path = Errors[idxCount].Trim(
true).Trim(
false);
2389 path = Errors[++idxCount].Trim(
true).Trim(
false);
2399 dirs[cpp_compiler].Add(fname.
GetPath());
2404 TRACE(
_T(
"NativeParser::GetGCCCompilerDirs(): Leave"));
2405 return dirs[cpp_compiler];
2411 wxString masterPathNoMacros(masterPath);
2413 fn.
SetPath(masterPathNoMacros);
2417 TRACE(
_T(
"NativeParser::AddGCCCompilerDirs(): Adding %lu cached gcc dirs to parser..."), static_cast<unsigned long>(gccDirs.
GetCount()));
2418 for (
size_t i=0; i<gccDirs.
GetCount(); ++i)
2421 TRACE(
_T(
"NativeParser::AddGCCCompilerDirs(): Adding cached compiler dir to parser: ") + gccDirs[i]);
2427 for (
unsigned int i = 0; i < dirs.
GetCount(); ++i)
2437 TRACE(
_T(
"NativeParser::AddIncludeDirsToParser(): Adding directory to parser: ") + fn.
GetFullPath());
2449 TRACE(
_T(
"NativeParser::OnParserStart(): Enter"));
2461 if (info.second &&
m_Parser != info.second)
2463 CCLogger::Get()->
DebugLog(
_T(
"NativeParser::OnParserStart(): Start switch from OnParserStart::ptCreateParser"));
2478 if (event.GetString().IsEmpty())
2490 TRACE(
_T(
"NativeParser::OnParserStart(): Leave"));
2495 TRACE(
_T(
"NativeParser::OnParserEnd(): Enter"));
2506 wxString log(
F(
_(
"NativeParser::OnParserEnd(): Project '%s' parsing stage done!"), prj.
wx_str()));
2519 if (info.second && info.second !=
m_Parser)
2535 if (!event.GetString().IsEmpty())
2542 TRACE(
_T(
"NativeParser::OnParserEnd(): Starting m_TimerParsingOneByOne."));
2547 TRACE(
_T(
"NativeParser::OnParserEnd(): Leave"));
2552 TRACE(
_T(
"NativeParser::OnParsingOneByOneTimer(): Enter"));
2562 CCLogger::Get()->
DebugLog(
_T(
"NativeParser::OnParsingOneByOneTimer(): Add foreign active editor to current active project's parser."));
2572 CCLogger::Get()->
DebugLog(
_T(
"NativeParser::OnParsingOneByOneTimer(): Add new (un-parsed) active project to parser."));
2581 for (
size_t i = 0; i < projs->GetCount(); ++i)
2589 CCLogger::Get()->
Log(
_T(
"NativeParser::OnParsingOneByOneTimer(): nothing need to parse in this project, try next project."));
2593 CCLogger::Get()->
DebugLog(
_T(
"NativeParser::OnParsingOneByOneTimer(): Add additional (next) project to parser."));
2600 else if (info.first && !info.second)
2603 if (info.second && info.second !=
m_Parser)
2605 CCLogger::Get()->
DebugLog(
_T(
"NativeParser::OnParsingOneByOneTimer(): Start switch from OnParsingOneByOneTimer"));
2609 TRACE(
_T(
"NativeParser::OnParsingOneByOneTimer(): Leave"));
2726 wxString log(
F(
_(
"NativeParser::AddProjectToParser(): Add project (%s) to parser"), prj.
wx_str()));
2730 bool needParseMacros =
false;
2738 needParseMacros =
true;
2744 if(!needParseMacros)
2745 needParseMacros =
true;
2750 size_t fileCount = 0;
2751 for (FilesList::const_iterator fl_it = project->
GetFilesList().begin(); fl_it != project->
GetFilesList().end(); ++fl_it)
2760 for (FilesList::const_iterator fl_it = project->
GetFilesList().begin(); fl_it != project->
GetFilesList().end(); ++fl_it)
2770 CCLogger::Get()->
DebugLog(
F(
_(
"NativeParser::AddProjectToParser(): Done adding %lu files of project (%s) to parser."), static_cast<unsigned long>(fileCount), prj.
wx_str()));
2773 return ((fileCount>0) || needParseMacros);
2808 for (FilesList::const_iterator fl_it = project->
GetFilesList().begin(); fl_it != project->
GetFilesList().end(); ++fl_it)
ProjectFile * GetFileByFilename(const wxString &filename, bool isRelative=true, bool isUnixFilename=false)
Access a file of the project.
wxString name
Dock's name. Must be unique. If empty, a unique name will be assigned.
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...
#define PARSER_IMG_NAMESPACE
wxString F(const wxChar *msg,...)
sprintf-like function
virtual BrowserOptions & ClassBrowserOptions()
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.
Search location combination, a pointer to cbStyledTextCtrl and a filename is enough.
#define PARSER_IMG_CTOR_PRIVATE
#define TRACE(format, args...)
destructor class member function
int TokenExists(const wxString &name, int parent, short int kindMask)
query tokens by names
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 brow...
ParserBase * GetParserByProject(cbProject *project)
return the Parser pointer corresponding to the input C::B project
void AddCompilerIncludeDirsToParser(const Compiler *compiler, ParserBase *parser)
Add compiler include directories (from search paths) to a parser.
BrowserViewMode
Symbol browser tree showing option.
bool AddPage(wxWindow *page, const wxString &caption, bool select=false, const wxBitmap &bitmap=wxNullBitmap)
Add Page.
int m_ParentIndex
Parent Token index.
#define PARSER_IMG_CTOR_PROTECTED
bool Matches(const wxString &mask) const
bool m_ClassBrowserIsFloating
if true, which means m_ClassBrowser is floating (not docked)
int WordEndPosition(int pos, bool onlyWordCharacters)
Get position of end of word.
void SetParser(ParserBase *parser)
Set a new Parser as the active Parser Set the active parser pointer (m_Parser member variable) update...
constructor class member function
bool ParseUsingNamespace(ccSearchData *searchData, TokenIdxSet &search_scope, int caretPos=-1)
collect the using namespace directive in the editor specified by searchData
wxArrayString GetAllPathsByFilename(const wxString &filename)
Get the implementation file path if the input is a header file.
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 qu...
void UpdateSash()
update the position sash bar between top tree and the bottom tree, the position (percentage) of the t...
int idTimerParsingOneByOne
event id for the sequence project parsing timer
Setting of the Parser, some of them will be passed down to ParserThreadOptions.
virtual const wxString & GetMasterPath() const
Get the compiler's master path (must contain "bin", "include" and "lib")
ParserBase * GetParserByFilename(const wxString &filename)
return the Parser pointer associated with the input file If a file belongs to several Parser objects...
wxString relativeFilename
The relative (to the project) filename of this file.
wxString title
Dock's title.
ProjectSearchDirsMap m_ProjectSearchDirsMap
a map: project pointer -> C/C++ parser search paths for this project, this is the per-project code co...
bool wxIsspace(const wxUniChar &c)
void Delete(std::vector< T > &s)
bool ReparseFile(cbProject *project, const wxString &filename)
Single file re-parse.
ConfigManager * GetConfigManager(const wxString &name_space) const
int ReadInt(const wxString &name, int defaultVal=0)
static Manager * Get()
Use Manager::Get() to get a pointer to its instance Manager::Get() is guaranteed to never return an i...
void Log(const wxString &msg)
wxString m_Name
Token's name, it can be searched in the TokenTree.
ClassBrowser * m_ClassBrowser
symbol browser window
bool RemovePage(size_t page)
Remove Page.
#define PARSER_IMG_MACRO_DEF
unsigned int m_ImplLine
function implementation line index
std::pair< cbProject *, ParserBase * > GetParserInfoByCurrentEditor()
Get cbProject and Parser pointer, according to the current active editor.
void ReparseSelectedProject()
re-parse the project select by context menu in projects management panel
typedef, note typedefs are stored as classes inheriting from the typedef'd type, this takes advantage...
static bool IsAppShuttingDown()
#define PARSER_IMG_ENUM_PUBLIC
cbStyledTextCtrl * control
#define PARSER_IMG_TYPEDEF
const wxArrayString & GetGCCCompilerDirs(const wxString &cpp_compiler)
Collect the default compiler include file search paths.
#define PARSER_IMG_FUNC_PROTECTED
DLLIMPORT wxBitmap cbLoadBitmap(const wxString &filename, wxBitmapType bitmapType=wxBITMAP_TYPE_PNG)
This function loads a bitmap from disk.
container like tokens, those tokens can have children tokens
virtual FilesList & GetFilesList()
Provides an easy way to iterate all the files belonging in this target.
bool wxFileExists(const wxString &filename)
wxWindow * pWindow
The window to dock.
wxFileName file
The full filename of this file.
static Compiler * GetDefaultCompiler()
void UpdateClassBrowser()
update the class browser tree
void SetVolume(const wxString &volume)
wxDirTraverseResult OnFile(const wxString &filename) override
#define PARSER_IMG_MACRO_USE_PUBLIC
EVTIMPORT const wxEventType cbEVT_ADD_DOCK_WINDOW
void CleanupSearchScope(TokenTree *tree, TokenIdxSet *searchScope)
remove all the container tokens in the token index set.
bool ReadBool(const wxString &name, bool defaultVal=false)
int Index(const wxString &sz, bool bCase=true, bool bFromEnd=false) const
void OnParsingOneByOneTimer(wxTimerEvent &event)
If use one parser per whole workspace, we need parse all project one by one, E.g. ...
void FindCurrentFunctionScope(TokenTree *tree, const TokenIdxSet &procResult, TokenIdxSet &scopeResult)
if the expression return the container tokens, which are the parent of the expression.
wxString m_LastAIGlobalSearch
same case like above, it holds the search string
bool ParseBufferForUsingNamespace(const wxString &buffer, TokenIdxSet &search_scope, bool bufferSkipBlocks=true)
collect the using namespace directive in the buffer specified by searchData
DLLIMPORT bool NormalizePath(wxFileName &f, const wxString &base)
virtual bool AddFile(cb_unused const wxString &filename, cb_unused cbProject *project, cb_unused bool isLocal=true)
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...
size_t BreakUpComponents(const wxString &actual, std::queue< ParserComponent > &components)
break a statement to several ParserComponents, and store them in a queue.
#define PARSER_IMG_MACRO_USE
a container class to hold all the Tokens getting from parsing stage
Event used to request from the main app to add a window to the docking system.
bool showInheritance
whether the base class or derive class information is shown as a child node default: false ...
virtual const wxArrayString & GetCompilerOptions() const
unsigned int m_ImplLineStart
if token is impl, opening brace line
bool Done()
Return true if all the parser's batch-parse stages are finished, otherwise return false...
static Compiler * GetCompiler(size_t index)
void UpdateClassBrowserView(bool checkHeaderSwap=false)
update or refresh the symbol browser trees
static const wxString & GetDefaultCompilerID()
#define PARSER_IMG_CTOR_PUBLIC
wxSize minimumSize
The minimum allowed size.
int m_LastFuncTokenIdx
saved the function token's index, for remove all local variable
wxString BeforeLast(wxUniChar ch, wxString *rest=NULL) const
size_t size()
total size of std::vector<Token*>
int m_Index
current Token index in the tree, it is index of the std::vector<Token*>, so use the index...
cbProject * GetProjectByEditor(cbEditor *editor)
return the C::B project containing the cbEditor pointer
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.
cbProjectManagerUI & GetUI()
std::list< wxString > StringList
unsigned int m_ImplLineEnd
if token is impl, closing brace line
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.
void OnEditorActivated(EditorBase *editor)
Event handler when an editor activate, NONE project is handled here.
#define PARSER_IMG_DTOR_PROTECTED
DLLIMPORT FileType FileTypeOf(const wxString &filename)
virtual bool RemoveFile(cb_unused const wxString &filename)
virtual wxTreeItemData * GetItemData(const wxTreeItemId &item) const
wxString GetNamespace() const
get a literal string presentation of the namespace.
virtual ParserOptions & Options()
wxString & Remove(size_t pos)
DLLIMPORT HookFunctorBase * UnregisterHook(int id, bool deleteHook=true)
Unregister a previously registered project loading/saving hook.
#define PARSER_IMG_FUNC_PRIVATE
bool RemoveFileFromParser(cbProject *project, const wxString &filename)
remove a file from C::B project and Parser
#define PARSER_IMG_MACRO_USE_PRIVATE
cbProject * GetCurrentProject()
Get current project by active editor or just return active project.
bool m_IsTemp
local (automatic) variable
TokenScope m_Scope
public? private? protected?
virtual bool Start(int milliseconds=-1, bool oneShot=wxTIMER_CONTINUOUS)
void SetPath(const wxString &path, wxPathFormat format=wxPATH_NATIVE)
wxString DisplayName() const
a short simple string to show the token information, this usually generate for show the tip message w...
#define PARSER_IMG_CLASS_PRIVATE
Represents a file in a Code::Blocks project.
DockSide dockSide
The side to dock it.
TokenTree * GetTempTokenTree()
wxSize floatingSize
The desired floating size.
EFileType FileType(const wxString &filename, bool force_refresh=false)
return a file type, which can be either header files or implementation files or other files ...
void DebugLog(const wxString &msg)
int GetLineEndPosition(int line) const
Get the position after the last visible characters on a line.
bool AddCompilerDirs(cbProject *project, ParserBase *parser)
collect the header file search directories, those dirs include: 1, project's base dir...
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.
void Reset()
Init cc search member variables.
void RemoveClassBrowser(bool appShutDown=false)
remove the class browser
void Set(int width, int height)
int WordStartPosition(int pos, bool onlyWordCharacters)
Get position of start of word.
EditorManager * GetEditorManager() const
DLLIMPORT const wxWX2MBbuf cbU2C(const wxString &str)
Return multibyte (C string) representation of the string.
#define PARSER_IMG_VAR_PROTECTED
void ClearParsers()
Clear all Parser object.
EVTIMPORT const wxEventType cbEVT_REMOVE_DOCK_WINDOW
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
cbProject * GetProjectByParser(ParserBase *parser)
return the C::B project associated with Parser pointer
wxUSE_UNICODE_dependent wxChar
size_t Traverse(wxDirTraverser &sink, const wxString &filespec=wxEmptyString, int flags=wxDIR_DEFAULT) const
ProjectManager * GetProjectManager() const
Functions returning pointers to the respective sub-manager instances.
const wxString & GetID() const
Get this compiler's unique ID.
bool AddProjectToParser(cbProject *project)
Add one project to the common parser in one parser for the whole workspace mode.
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.
void OnParserEnd(wxCommandEvent &event)
Event handler when the batch parse finishes, print some log information, check whether the active edi...
bool Contains(const wxString &str) const
bool m_LastAISearchWasGlobal
true if the phrase for code-completion is empty or partial text (i.e. no . -> or :: operators) ...
virtual bool Reparse(cb_unused const wxString &filename, cb_unused bool isLocal=true)
virtual const wxString & GetFilename() const
Get the editor's filename (if applicable).
DLLIMPORT wxString UnixFilename(const wxString &filename, wxPathFormat format=wxPATH_NATIVE)
bool AppendDir(const wxString &dir)
Represents a Code::Blocks project.
const wxString & GetActiveBuildTarget() const
EditorBase * GetActiveEditor()
#define PARSER_IMG_DTOR_PUBLIC
a symbol found in the parsed files, it can be many kinds, such as a variable, a class and so on...
wxString & RemoveLast(size_t n=1)
cbStyledTextCtrl * GetControl() const
Returns a pointer to the underlying cbStyledTextCtrl object (which itself is the wxWindows implementa...
std::set< int, std::less< int > > TokenIdxSet
wxArrayString m_StandaloneFiles
all the files which opened, but does not belong to any cbp
display symbols of current file
bool m_ParserPerWorkspace
if true, which means the parser hold tokens of the whole workspace's project, if false then one parse...
DLLIMPORT wxString cbC2U(const char *str)
Return str as a proper unicode-compatible string.
virtual const wxString & GetTitle() const
Read the target's title.
wxImageList * m_ImageList
Images for class browser.
virtual void AddPredefinedMacros(cb_unused const wxString &defs)
bool ParseFunctionArguments(ccSearchData *searchData, int caretPos=-1)
collect function argument, add them to the token tree (as temporary tokens)
#define PARSER_IMG_CLASS_PUBLIC
wxString GetCompilerStandardGCC(Compiler *compiler, cbProject *project)
lookup GCC compiler -std=XXX option
virtual void AddBatchParse(cb_unused const StringList &filenames)
size_t Replace(const wxString &strOld, const wxString &strNew, bool replaceAll=true)
size_t FindTokensInFile(const wxString &filename, TokenIdxSet &result, short int kindMask)
EFileType
the enum type of the file type
~NativeParser()
Destructor.
wxString GetVolume() const
bool GetModify() const
Is the document different from when it was last saved?
cbEditor * GetBuiltinActiveEditor()
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.
virtual bool IsFileParsed(cb_unused const wxString &filename)
bool IsSameAs(const wxString &s, bool caseSensitive=true) const
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.
bool IsCharacter(int style)
Is style classified as character for current language?
virtual wxString NotDoneReason()
virtual cbTreeCtrl * GetTree()=0
Retrieve a pointer to the project manager's tree (GUI).
virtual const CompilerPrograms & GetPrograms() const
Get the compiler's programs.
Base class that all "editors" should inherit from.
int GetCurrentPos() const
Returns the position of the caret.
cbProject * GetActiveProject()
Retrieve the active project.
bool IsString(int style)
Is style classified as string for current language?
bool Replace(int index, const wxBitmap &bitmap, const wxBitmap &mask=wxNullBitmap)
int GetLength() const
Returns the number of bytes in the document.
virtual wxString GetBasePath() const
Read the target's base path, e.g. if GetFilename() returns "/usr/local/bin/xxx", base path will retur...
DLLIMPORT int RegisterHook(HookFunctorBase *functor)
Register a project loading/saving hook.
bool wantPreprocessor
case sensitive in MarkItemsByAI
NativeParser()
Constructor.
static void AddPaths(wxArrayString &dirs, const wxString &path, bool hasExt)
Add the paths to path array, and this will be used in GetAllPathsByFilename() function.
#define PARSER_IMG_TYPEDEF_PUBLIC
#define CC_LOCKER_TRACK_TT_MTX_UNLOCK(M)
const wxStringCharType * wx_str() const
void ReparseCurrentProject()
re-parse the active Parser (the project associated with m_Parser member variable
void AddIncludeDir(const wxString &dir)
add a directory to the Parser's include path database
#define PARSER_IMG_CLASS_PROTECTED
wxString Right(size_t count) const
bool s_DebugSmartSense
if this option is enabled, there will be many log messages when doing semantic match ...
ParserBase * CreateParser(cbProject *project)
Dynamically allocate a Parser object for the input C::B project, note that while create a new Parser ...
wxTimer m_TimerParsingOneByOne
a delay timer to parser every project in sequence
symbol browser panel is shown in the Management panel besides projects browser panel.
MacrosManager * GetMacrosManager() const
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 ...
const wxString & _(const wxString &string)
wxString GetCompilerUsingStandardGCC(const wxArrayString &compilerOptions)
lookup GCC compiler -std=XXX option for specific GCC options
wxString & Trim(bool fromRight=true)
void ReplaceMacros(wxString &buffer, ProjectBuildTarget *target=nullptr, bool subrequest=false)
cbEditor * GetBuiltinEditor(EditorBase *eb)
wxString m_Args
If it is a function Token, then this value is function arguments, e.g.
cbStyledTextCtrl * m_LastControl
void InitCCSearchVariables()
Init cc search member variables.
int GetBuildTargetsCount()
bool followGlobalIncludes
parse XXX.h in directive #include "XXX.h"
#define CC_LOCKER_TRACK_TT_MTX_LOCK(M)
virtual const wxArrayString & GetIncludeDirs() const
cbProject * GetProjectByFilename(const wxString &filename)
return the C::B project containing the filename The function first try to match the filename in the a...
bool SwitchParser(cbProject *project, ParserBase *parser)
Switch parser object according the current active editor and filename.
void RereadParserOptions()
when user changes the CC option, we should re-read the option
int BraceMatch(int pos, int maxReStyle=0)
Find the position of a matching brace or wxSCI_INVALID_POSITION if no match.
int PositionFromLine(int line) const
Retrieve the position at the start of a line.
static wxString GetDataFolder(bool global=true)
wxArrayString GetExpandedVirtualBuildTargetGroup(const wxString &alias) const
Access a virtual build target's expanded group of build targets.
ProjectBuildTarget * GetBuildTarget(int index)
Access a build target.
static bool Exists(const wxString &filename)
Abstract base class for compilers.
BrowserDisplayFilter displayFilter
token filter option
int GetPageIndex(wxWindow *page_wnd) const
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...
#define PARSER_IMG_VAR_PRIVATE
std::set< cbProject * > m_ParsedProjects
only used when m_ParserPerWorkspace is true, and holds all the cbps for the common parser ...
#define PARSER_IMG_ENUMERATOR
bool hideable
If true, the dock will be allowed to be closed by the user.
int GetCharAt(int pos) const
Returns the character byte at the position.
cbProject * GetProject() const
wxString GetPath(int flags=wxPATH_GET_VOLUME, wxPathFormat format=wxPATH_NATIVE) const
virtual const wxString & GetCompilerID() const
Read the target's compiler.
ParserBase * m_TempParser
a temp parser object pointer
non of the above three status, this means our Parser has finish all the jobs, and it is in idle mode ...
void OnParserStart(wxCommandEvent &event)
Event handler when the batch parse starts, print some log information.
some files are changed by the user, so we are parsing the changed files
FileTreeDataKind GetKind() const
#define wxSCI_INVALID_POSITION
virtual cbAuiNotebook * GetNotebook()=0
TokenKind m_TokenKind
See TokenKind class.
void SetCBViewMode(const BrowserViewMode &mode)
set the class browser view mode
bool ProcessEvent(CodeBlocksEvent &event)
wxString GetCommonTopLevelPath() const
wxDirTraverseResult OnDir(const wxString &dirname) override
virtual bool ParseBufferForUsingNamespace(cb_unused const wxString &buffer, cb_unused wxArrayString &result, cb_unused bool bufferSkipBlocks=true)
wxString & Prepend(const wxString &str)
general function, not constructor nor destructor
#define PARSER_IMG_FUNC_PUBLIC
int GetStyleAt(int pos) const
Returns the style byte at the position.
bool parseComplexMacros
reparse the active editor while editing
a long statement can be divided to a ParserComponent chain.
size_t Add(const wxString &str, size_t copies=1)
cbProject * GetParentProject()
ParserBase * m_Parser
active parser object pointer
bool StartsWith(const wxString &prefix, wxString *rest=NULL) const
size_t FindCurrentFunctionToken(ccSearchData *searchData, TokenIdxSet &result, int caretPos=-1)
return all the tokens matching the current function(hopefully, just one)
void CreateClassBrowser()
create the class browser
Represents a Code::Blocks project build target.
int LineFromPosition(int pos) const
Retrieve the line containing a position.
bool Normalize(int flags=wxPATH_NORM_ALL, const wxString &cwd=wxEmptyString, wxPathFormat format=wxPATH_NATIVE)
void Sort(bool reverseOrder=false)
int Add(const wxBitmap &bitmap, const wxBitmap &mask=wxNullBitmap)
bool shown
If true, initially shown.
#define PARSER_IMG_TYPEDEF_PROTECTED
int Find(wxUniChar ch, bool fromEnd=false) const
#define PARSER_IMG_DTOR_PRIVATE
ProjectFile * GetProjectFile() const
Read the ProjectFile pointer associated with this editor.
virtual TokenTree * GetTokenTree() const
bool DoFullParsing(cbProject *project, ParserBase *parser)
When a Parser is created, we need a full parsing stage including: 1, parse the priority header files ...
int GetTokenKindImage(const Token *token)
Returns the image assigned to a specific token for a symbol browser.
ProjectsArray * GetProjects()
Retrieve an array of all the opened projects.
the Parser object is newly created, and we are parsing the predefined macro buffer, the source files, and finally mark the project's tokens as local
bool AddCompilerPredefinedMacros(cbProject *project, ParserBase *parser)
collect compiler specific predefined preprocessor definition, this is usually run a special compiler ...
int m_HookId
project loader hook ID
Functor class for use as a project loading/saving hook.
macro definition, such as: #define AAA(x,y) f(x,y), where AAA is a token of tkMacroDef ...
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 setting...
void RemoveAt(size_t nIndex, size_t count=1)
the user has add some files to the cbproject, so we are parsing the new added files ...
ParserList m_ParserList
a list holing all the cbp->parser pairs, if in one parser per project mode, there are many many pairs...
ParserDirTraverser(const wxString &excludePath, wxArrayString &files)
virtual void ReadOptions()
read Parser options from configure file
#define PARSER_IMG_ENUM_PRIVATE
#define PARSER_IMG_ENUM_PROTECTED
bool DeleteParser(cbProject *project)
delete the Parser object for the input project
wxSize desiredSize
The desired size.
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.
bool AddCompilerPredefinedMacrosGCC(const wxString &compilerId, cbProject *project, wxString &defs, ParserBase *parser)
collect GCC compiler predefined preprocessor definition
bool RemoveProjectFromParser(cbProject *project)
Remove cbp from the common parser, this only happens in one parser for whole workspace mode when a pa...
wxString GetFullPath(wxPathFormat format=wxPATH_NATIVE) const
bool IsParserPerWorkspace() const
Return true if use one Parser per whole workspace.
Abstract base hook functor interface.
void AddGCCCompilerDirs(const wxString &masterPath, const wxString &compilerCpp, ParserBase *parser)
Add the collected default GCC compiler include search paths to a parser.
#define PARSER_IMG_MACRO_USE_PROTECTED
const wxString & m_ExcludeDir
static wxString Format(const wxString &format,...)
#define PARSER_IMG_VAR_PUBLIC
wxString Mid(size_t first, size_t nCount=wxString::npos) const
virtual bool UpdateParsingProject(cb_unused cbProject *project)
void RemoveObsoleteParsers()
Remove all the obsolete Parser object if the number exceeds the limited number (can be set in the CC'...
DLLIMPORT int cbMessageBox(const wxString &message, const wxString &caption=wxEmptyString, int style=wxOK, wxWindow *parent=NULL, int x=-1, int y=-1)
wxMessageBox wrapper.
#define PARSER_IMG_TYPEDEF_PRIVATE
bool AddCompilerPredefinedMacrosVC(const wxString &compilerId, wxString &defs, ParserBase *parser)
collect VC compiler predefined preprocessor definition
virtual bool ParseBuffer(const wxString &buffer, bool isLocal, bool bufferSkipBlocks=false, bool isTemp=false, const wxString &filename=wxEmptyString, int parentIdx=-1, int initLine=0)
wxArrayString & GetProjectSearchDirs(cbProject *project)
project search path is used for auto completion for #include <>
virtual wxTreeItemId GetTreeSelection()=0
Get the selection of the project manager's tree (GUI).
long wxExecute(const wxString &command, int flags=wxEXEC_ASYNC, wxProcess *callback=NULL, const wxExecuteEnv *env=NULL)
void SetParser(ParserBase *parser)
Set the Parser object associated with the class browser.
the usage of the macro, for example: AAA(1,2)
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 protot...
virtual CompilerCommandGenerator * GetCommandGenerator(cbProject *project)
This is to be overridden, if compiler needs to alter the default command line generation.
Parser class holds all the tokens of a C::B project.