Now the Editor correctly parses the preprocessor directives and greys out the second directive
Currently, the Editor's syntax highlight is not related to the CodeCompletion plugin.
You mentioned code is inside the CodeCompletion plugin, but the editor highlight is related to Scintilla control.
Yes, I were pointing out that visually things were correct, but functionally not.
The workaround simply makes the parser treat the LLVM compiler as it would the GCC compiler, i.e.,
it triggers the AddCompilerPredefinedMacrosGCC code path which is to retrieve the compiler's predefined macros by
invoking it with " -E -dM -x c++ %s nul"
(Caveat : this only works with the LLVM compiler as it responds the same to the parameters as GCC would.)
Having the predefined macros solves 1)having the incorrect info in tooltips and 2)Find declaration misleading you to an inactive declaration.
Thanks for the explanation.
I think the correct way to fix such issue is adding some special if condition for "llvm" compiler.
In this code:
bool NativeParser::AddCompilerPredefinedMacros(cbProject* project, ParserBase* parser)
{
if (!parser)
return false;
if (!parser->Options().wantPreprocessor)
return false;
TRACE(_T("NativeParser::AddCompilerPredefinedMacros: Enter"));
// Default compiler is used for for single file parser (non project)
wxString compilerId = project ? project->GetCompilerID() : CompilerFactory::GetDefaultCompilerID();
wxString defs;
// gcc
if (compilerId.Contains(_T("gcc")))
{
if ( !AddCompilerPredefinedMacrosGCC(compilerId, project, defs, parser) )
return false;
}
// vc
else if (compilerId.StartsWith(_T("msvc")))
{
if ( !AddCompilerPredefinedMacrosVC(compilerId, defs, parser) )
return false;
}
TRACE(_T("NativeParser::AddCompilerPredefinedMacros: Add compiler predefined preprocessor macros:\n%s"), defs.wx_str());
parser->AddPredefinedMacros(defs);
TRACE(_T("NativeParser::AddCompilerPredefinedMacros: Leave"));
if ( defs.IsEmpty() )
return false;
return true;
}
We can fetch a special command for llvm compiler.
One last thing - on the Editor side (Scintilla) doesn't take into account that when working with LLVM on Windows it has _MSC_EXTENSIONS defined by default
which results in visually having large sections of code grey'd out (#if defined(_MSC_EXTENSIONS) ... #endif) but that's small beans as
CodeCompetion still parses it correctly and has the right information in tooltips and Find declaration points to the right places.
Regards
Scintilla doesn't have the symbols in global scope, which means it only parse the current h/cpp file.
The best idea is to let the CodeCompletion plugin to supply a symbol list for the Scintilla, I have implemented that feature years ago, that need changes in scintilla source code.
Maybe, search the forum will gives the related discussion. :)