func()

in src/scip-lib/registry/partial_registry.go [169:211]


func (p *partialScipRegistry) References(sourceURI uri.URI, pos protocol.Position) ([]protocol.Location, error) {
	doc, err := p.Index.LoadDocument(p.uriToRelativePath(sourceURI))
	if err != nil {
		p.logger.Errorf("failed to load document %s: %s", sourceURI, err)
		return nil, err
	}
	if doc == nil {
		return nil, nil
	}

	sourceOccurrence := utils.GetOccurrenceForPosition(doc.Occurrences, pos)
	if sourceOccurrence == nil {
		return nil, nil
	}

	// Get all references to this symbol across all documents
	locations := make([]protocol.Location, 0)

	// For local symbols, only search in current document
	if scip.IsLocalSymbol(sourceOccurrence.Symbol) {
		for _, occ := range doc.Occurrences {
			if occ.Symbol == sourceOccurrence.Symbol {
				locations = append(locations, *mapper.ScipOccurrenceToLocation(sourceURI, occ))
			}
		}
		return locations, nil
	}

	// For global symbols, search all documents
	occurrences, err := p.Index.References(sourceOccurrence.Symbol)
	if err != nil {
		p.logger.Errorf("failed to get references for %s: %s", sourceOccurrence.Symbol, err)
		return nil, err
	}

	for relDocPath, occs := range occurrences {
		for _, occ := range occs {
			locations = append(locations, *mapper.ScipOccurrenceToLocation(uri.File(filepath.Join(p.WorkspaceRoot, relDocPath)), occ))
		}
	}

	return locations, nil
}