chore: Document tech debt wrt multiple doc traversals (#64006)

This commit is contained in:
Varun Gandhi 2024-07-23 21:19:20 +08:00 committed by GitHub
parent 49b9b10468
commit d93c0fdf90
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -260,6 +260,14 @@ func symbolHoverText(symbol *scip.SymbolInformation) []string {
return symbol.Documentation
}
// TODO(id: doc-N-traversals): Internally, these four methods all compute the same
// exact raw data, and then they throw away most of the data. For example, the definition
// extraction logic will waste cycles by getting information about implementations.
//
// Additionally, AFAICT, each function will do a separate read of the document
// from the database and unmarshal it. This means that for the ref panel,
// we will unmarshal the same Protobuf document at least four times. :facepalm:
func (s *store) ExtractDefinitionLocationsFromPosition(ctx context.Context, locationKey LocationKey) (_ []shared.Location, _ []string, err error) {
return s.extractLocationsFromPosition(ctx, extractDefinitionRanges, symbolExtractDefault, s.operations.getDefinitionLocations, locationKey)
}
@ -314,8 +322,9 @@ func symbolExtractPrototype(document *scip.Document, symbolName string) (symbols
return symbols
}
//
//
// TODO(id: doc-N-traversals): Since this API is used in a limited number of ways,
// take some basic 'strategy' enums and implement the logic for extraction here
// so we can avoid multiple document traversals.
func (s *store) extractLocationsFromPosition(
ctx context.Context,