Repository: dotnet/roslyn
File: src/Features/Core/Portable/DocumentHighlighting/AbstractDocumentHighlightsService.cs (C#)

Code before:
                    case MethodKind.PropertySet:
                    case MethodKind.EventAdd:
                    case MethodKind.EventRaise:
                    case MethodKind.EventRemove:
                        return false;

                    default:
                        return true;
                }

            default:
                return true;
        }
    }

    private async Task<ImmutableArray<DocumentHighlights>> FilterAndCreateSpansAsync(
        ImmutableArray<ReferencedSymbol> references, Document startingDocument,
        IImmutableSet<Document> documentsToSearch, ISymbol symbol,
        FindReferencesSearchOptions options, CancellationToken cancellationToken)
    {
        var solution = startingDocument.Project.Solution;
        references = references.FilterToItemsToShow(options);
        references = references.FilterNonMatchingMethodNames(solution, symbol);
        references = references.FilterToAliasMatches(symbol as IAliasSymbol);

        using var _ = ArrayBuilder<Location>.GetInstance(out var additionalReferences);

        foreach (var currentDocument in documentsToSearch)
        {
            // 'documentsToSearch' may contain documents from languages other than our own
            // (for example cshtml files when we're searching the cs document).  Since we're
            // delegating to a virtual method for this language type, we have to make sure
            // we only process the document if it's also our language.
            if (currentDocument.Project.Language == startingDocument.Project.Language)
            {
                additionalReferences.AddRange(await GetAdditionalReferencesAsync(currentDocument, symbol, cancellationToken).ConfigureAwait(false));
            }
        }

        return await CreateSpansAsync(
            solution, symbol, references, additionalReferences,
            documentsToSearch, cancellationToken).ConfigureAwait(false);
    }

    protected virtual Task<ImmutableArray<Location>> GetAdditionalReferencesAsync(
        Document document, ISymbol symbol, CancellationToken cancellationToken)
    {
        return SpecializedTasks.EmptyImmutableArray<Location>();
    }

    private static async Task<ImmutableArray<DocumentHighlights>> CreateSpansAsync(

Review comment (suggestion):
@copilot i can't actually figure out why this code existed.  to lower risk, let's return it.  However, in the WhereAsArray, we should keep the definition if it's for the symbol we're highlighting *or* if it's the corresponding partial-part for it.

Code after:
                    case MethodKind.PropertySet:
                    case MethodKind.EventAdd:
                    case MethodKind.EventRaise:
                    case MethodKind.EventRemove:
                        return false;

                    default:
                        return true;
                }

            default:
                return true;
        }
    }

    private async Task<ImmutableArray<DocumentHighlights>> FilterAndCreateSpansAsync(
        ImmutableArray<ReferencedSymbol> references, Document startingDocument,
        IImmutableSet<Document> documentsToSearch, ISymbol symbol,
        FindReferencesSearchOptions options, CancellationToken cancellationToken)
    {
        var solution = startingDocument.Project.Solution;
        references = references.FilterToItemsToShow(options);
        references = references.FilterNonMatchingMethodNames(solution, symbol);
        references = references.FilterToAliasMatches(symbol as IAliasSymbol);

        if (symbol is IMethodSymbol { MethodKind: MethodKind.Constructor } constructor)
        {
            var constructorParts1 = constructor.OriginalDefinition.GetAllMethodSymbolsOfPartialParts();
            references = references.WhereAsArray(r =>
            {
                var constructorParts2 = ((IMethodSymbol)r.Definition).GetAllMethodSymbolsOfPartialParts();
                return constructorParts1.Intersect(constructorParts2).Any();
            });
        }

        using var _ = ArrayBuilder<Location>.GetInstance(out var additionalReferences);

        foreach (var currentDocument in documentsToSearch)
        {
            // 'documentsToSearch' may contain documents from languages other than our own
            // (for example cshtml files when we're searching the cs document).  Since we're
            // delegating to a virtual method for this language type, we have to make sure
            // we only process the document if it's also our language.
            if (currentDocument.Project.Language == startingDocument.Project.Language)
            {
                additionalReferences.AddRange(await GetAdditionalReferencesAsync(currentDocument, symbol, cancellationToken).ConfigureAwait(false));
            }
        }

        return await CreateSpansAsync(
            solution, symbol, references, additionalReferences,