const maxSymbols … // WorkspaceSymbols matches symbols across all views using the given query, // according to the match semantics parameterized by matcherType and style. // // The workspace symbol method is defined in the spec as follows: // // The workspace symbol request is sent from the client to the server to // list project-wide symbols matching the query string. // // It is unclear what "project-wide" means here, but given the parameters of // workspace/symbol do not include any workspace identifier, then it has to be // assumed that "project-wide" means "across all workspaces". Hence why // WorkspaceSymbols receives the views []View. // // However, it then becomes unclear what it would mean to call WorkspaceSymbols // with a different configured SymbolMatcher per View. Therefore we assume that // Session level configuration will define the SymbolMatcher to be used for the // WorkspaceSymbols method. func WorkspaceSymbols(ctx context.Context, matcher settings.SymbolMatcher, style settings.SymbolStyle, snapshots []*cache.Snapshot, query string) ([]protocol.SymbolInformation, error) { … } type matcherFunc … type symbolizer … func fullyQualifiedSymbolMatch(space []string, name string, pkg *metadata.Package, matcher matcherFunc) ([]string, float64) { … } func dynamicSymbolMatch(space []string, name string, pkg *metadata.Package, matcher matcherFunc) ([]string, float64) { … } func packageSymbolMatch(space []string, name string, pkg *metadata.Package, matcher matcherFunc) ([]string, float64) { … } func buildMatcher(matcher settings.SymbolMatcher, query string) matcherFunc { … } func newFuzzyMatcher(query string) matcherFunc { … } // parseQuery parses a field-separated symbol query, extracting the special // characters listed below, and returns a matcherFunc corresponding to the AND // of all field queries. // // Special characters: // // ^ match exact prefix // $ match exact suffix // ' match exact // // In all three of these special queries, matches are 'smart-cased', meaning // they are case sensitive if the symbol query contains any upper-case // characters, and case insensitive otherwise. func parseQuery(q string, newMatcher func(string) matcherFunc) matcherFunc { … } func matchExact(exact string) matcherFunc { … } // smartCase returns a matcherFunc that is case-sensitive if q contains any // upper-case characters, and case-insensitive otherwise. func smartCase(q string, m matcherFunc) matcherFunc { … } type comboMatcher … func (c comboMatcher) match(chunks []string) (int, float64) { … } // collectSymbols calls snapshot.Symbols to walk the syntax trees of // all files in the views' current snapshots, and returns a sorted, // scored list of symbols that best match the parameters. // // How it matches symbols is parameterized by two interfaces: // - A matcherFunc determines how well a string symbol matches a query. It // returns a non-negative score indicating the quality of the match. A score // of zero indicates no match. // - A symbolizer determines how we extract the symbol for an object. This // enables the 'symbolStyle' configuration option. func collectSymbols(ctx context.Context, snapshots []*cache.Snapshot, matcherType settings.SymbolMatcher, symbolizer symbolizer, query string) ([]protocol.SymbolInformation, error) { … } type symbolFile … // matchFile scans a symbol file and adds matching symbols to the store. func matchFile(store *symbolStore, symbolizer symbolizer, matcher matcherFunc, roots []string, i symbolFile) { … } type symbolStore … // store inserts si into the sorted results, if si has a high enough score. func (sc *symbolStore) store(si symbolInformation) { … } func (sc *symbolStore) tooLow(score float64) bool { … } func (sc *symbolStore) results() []protocol.SymbolInformation { … } type symbolInformation … // asProtocolSymbolInformation converts s to a protocol.SymbolInformation value. // // TODO: work out how to handle tags if/when they are needed. func (s symbolInformation) asProtocolSymbolInformation() protocol.SymbolInformation { … }