From fb8f1c697a45fcd69cf7919d3c3be98fd7cee62d Mon Sep 17 00:00:00 2001 From: Varun Gandhi Date: Wed, 20 Jul 2022 12:12:27 +0800 Subject: [PATCH] fix: Don't emit SymbolInformation for local defs. --- scip_indexer/SCIPIndexer.cc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/scip_indexer/SCIPIndexer.cc b/scip_indexer/SCIPIndexer.cc index b6e1ca99a4..6768128285 100644 --- a/scip_indexer/SCIPIndexer.cc +++ b/scip_indexer/SCIPIndexer.cc @@ -423,12 +423,14 @@ class SCIPState { private: absl::Status saveDefinitionImpl(const core::GlobalState &gs, core::FileRef file, const string &symbolString, - core::Loc occLoc) { + core::Loc occLoc, bool isLocal) { ENFORCE(!symbolString.empty()); occLoc = trimColonColonPrefix(gs, occLoc); - scip::SymbolInformation symbolInfo; - symbolInfo.set_symbol(symbolString); - this->symbolMap[file].push_back(symbolInfo); + if (!isLocal) { + scip::SymbolInformation symbolInfo; + symbolInfo.set_symbol(symbolString); + this->symbolMap[file].push_back(symbolInfo); + } scip::Occurrence occurrence; occurrence.set_symbol(symbolString); @@ -496,7 +498,8 @@ class SCIPState { if (this->cacheOccurrence(gs, file, occ, scip::SymbolRole::Definition)) { return absl::OkStatus(); } - return this->saveDefinitionImpl(gs, file, occ.toString(gs, file), core::Loc(file, occ.offsets)); + return this->saveDefinitionImpl(gs, file, occ.toString(gs, file), core::Loc(file, occ.offsets), + /*isLocal*/ true); } // Save definition when you have a sorbet Symbol. @@ -518,7 +521,7 @@ class SCIPState { auto occLoc = loc.has_value() ? core::Loc(file, loc.value()) : symRef.symbolLoc(gs); - return this->saveDefinitionImpl(gs, file, symbolString, occLoc); + return this->saveDefinitionImpl(gs, file, symbolString, occLoc, /*isLocal*/ false); } absl::Status saveReference(const core::GlobalState &gs, core::FileRef file, OwnedLocal occ, int32_t symbol_roles) {