Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development
Code completion using LSP and clangd
ollydbg:
--- Quote from: Pecan on September 16, 2022, 07:26:36 pm ---Is there a better method for inserting a entry into a map?
--- End quote ---
I'm not fully understand the code logic, but do you really need a map? When a key is added, it's value is always "true".
I mean a std::set<cbEditor*> is better than std::map<cbEditor*,bool> ?
Pecan:
--- Quote from: ollydbg on September 17, 2022, 02:45:36 pm ---I'm not fully understand the code logic, but do you really need a map? When a key is added, it's value is always "true".
I mean a std::set<cbEditor*> is better than std::map<cbEditor*,bool> ?
--- End quote ---
Thanks, I learned a long time ago that other eyes reviewing code can make it better.
Direct link to newer patch
Miguel Gimenez:
Patch for ticket #1168 applied in r12899, thank you.
ollydbg:
The msys2 project now has clangd 15.0 for mingw64 targets.
ollydbg:
I have a question:
LSP_ParseSemanticTokens(), what does this function used for?
I see this code:
--- Code: ---// ----------------------------------------------------------------------------
void Parser::OnLSP_RequestedSemanticTokensResponse(wxCommandEvent& event) //(ph 2021/03/12)
// ----------------------------------------------------------------------------
{
if (GetIsShuttingDown()) return;
// This is a callback after requesting textDocument/Symbol (request done at end of OnLSP_RequestedSymbolsResponse() )
// Currently, we allow SemanticTokens for the BuiltinActiveEditor only,
// ----------------------------------------------------------------------------
/// GetClientData() contains ptr to json object
/// DONT free it! The return to OnLSP_Event() will free it as a unique_ptr
// ----------------------------------------------------------------------------
json* pJson = (json*)event.GetClientData();
wxString idStr = event.GetString();
wxString URI = idStr.AfterFirst(STX);
if (URI.Contains(STX))
URI = URI.BeforeFirst(STX); //filename
wxString uriFilename = fileUtils.FilePathFromURI(URI); //(ph 2021/12/21)
cbEditor* pEditor = nullptr;
cbProject* pProject = nullptr;
EditorManager* pEdMgr = Manager::Get()->GetEditorManager();
EditorBase* pEdBase = pEdMgr->IsOpen(uriFilename);
if (pEdBase)
{
pEditor = pEdMgr->GetBuiltinActiveEditor();
if (not pEditor or (pEditor->GetFilename() != uriFilename))
return;
ProjectFile* pProjectFile = pEditor->GetProjectFile();
if (pProjectFile) pProject = pProjectFile->GetParentProject();
if ( (not pProjectFile) or (not pProject) ) return;
ParserBase* pParser = GetParseManager()->GetParserByProject(pProject);
if (not pParser)
return;
}
else return;
if (not pProject) pProject = Manager::Get()->GetProjectManager()->GetActiveProject();
ProcessLanguageClient* pClient = GetLSPClient();
// Queue the the json data to OnLSP_ParseDocumentSymbols() event, passing it the json pointer
// The json data will be placed in a queue to be processed during OnIdle() events. //(ph 2021/09/11)
wxCommandEvent symEvent(wxEVT_COMMAND_MENU_SELECTED, XRCID("textDocument/semanticTokens"));
symEvent.SetString(uriFilename);
symEvent.SetClientData(pJson);
LSP_ParseSemanticTokens(symEvent); //Call directly
--- End code ---
The last line:
LSP_ParseSemanticTokens(symEvent); //Call directly
This use the our old-CC's parsing code, for example
--- Code: ---// ----------------------------------------------------------------------------
Token* LSP_SymbolsParser::DoHandleClass(EClassType ct, int lineNumber, int lastLineNumber, int endCol) //(ph 2021/05/15)
// ----------------------------------------------------------------------------
{
// need to force the tokenizer _not_ skip anything
// as we 're manually parsing class decls
// don't forget to reset that if you add any early exit condition!
TokenizerState oldState = m_Tokenizer.GetState();
m_Tokenizer.SetState(tsNormal);
--- End code ---
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version