From c193f37ac6c6ca04381cd69f85e2ea2605de6f74 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Thu, 9 Apr 2015 14:11:01 -0700 Subject: [PATCH] Add support for highlighting written references differently than read references. --- src/EditorFeatures/Core/EditorFeatures.csproj | 2 + .../Core/EditorFeaturesResources.Designer.cs | 9 +++ .../Core/EditorFeaturesResources.resx | 3 + .../AbstractDocumentHighlightsService.cs | 13 ++-- .../IDocumentHighlightsService.cs | 13 +++- ...hlightingViewTaggerProvider.TagProducer.cs | 16 ++++- .../WrittenReferenceHighlightTag.cs | 18 +++++ .../WrittenReferenceHighlightTagDefinition.cs | 25 +++++++ .../AbstractReferenceHighlightingTests.vb | 23 +++---- .../CSharpReferenceHighlightingTests.vb | 65 ++++++++++++------- ...CrossLanguageReferenceHighlightingTests.vb | 2 +- .../VisualBasicReferenceHighlightingTests.vb | 39 ++++++++--- .../DelegateInvokeMethodReferenceFinder.cs | 3 +- .../Finders/AbstractReferenceFinder.cs | 5 +- .../Finders/PropertySymbolReferenceFinder.cs | 2 +- .../Portable/FindSymbols/ReferenceLocation.cs | 8 ++- 16 files changed, 183 insertions(+), 63 deletions(-) create mode 100644 src/EditorFeatures/Core/Implementation/ReferenceHighlighting/WrittenReferenceHighlightTag.cs create mode 100644 src/EditorFeatures/Core/Implementation/ReferenceHighlighting/WrittenReferenceHighlightTagDefinition.cs diff --git a/src/EditorFeatures/Core/EditorFeatures.csproj b/src/EditorFeatures/Core/EditorFeatures.csproj index f28fde0c095..002f9bcff83 100644 --- a/src/EditorFeatures/Core/EditorFeatures.csproj +++ b/src/EditorFeatures/Core/EditorFeatures.csproj @@ -578,6 +578,8 @@ + + diff --git a/src/EditorFeatures/Core/EditorFeaturesResources.Designer.cs b/src/EditorFeatures/Core/EditorFeaturesResources.Designer.cs index 0e7a16f70a3..dc3890d2018 100644 --- a/src/EditorFeatures/Core/EditorFeaturesResources.Designer.cs +++ b/src/EditorFeatures/Core/EditorFeaturesResources.Designer.cs @@ -1069,6 +1069,15 @@ internal class EditorFeaturesResources { } } + /// + /// Looks up a localized string similar to Highlighted Written Reference. + /// + internal static string HighlightedWrittenReference { + get { + return ResourceManager.GetString("HighlightedWrittenReference", resourceCulture); + } + } + /// /// Looks up a localized string similar to Implemented By. /// diff --git a/src/EditorFeatures/Core/EditorFeaturesResources.resx b/src/EditorFeatures/Core/EditorFeaturesResources.resx index e855b045dcd..1fdbcf19457 100644 --- a/src/EditorFeatures/Core/EditorFeaturesResources.resx +++ b/src/EditorFeatures/Core/EditorFeaturesResources.resx @@ -730,4 +730,7 @@ Do you want to proceed? The rename tracking session was cancelled and is no longer available. + + Highlighted Written Reference + \ No newline at end of file diff --git a/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/AbstractDocumentHighlightsService.cs b/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/AbstractDocumentHighlightsService.cs index c3110b1d06f..12229fcb57e 100644 --- a/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/AbstractDocumentHighlightsService.cs +++ b/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/AbstractDocumentHighlightsService.cs @@ -134,7 +134,7 @@ private bool ShouldConsiderSymbol(ISymbol symbol) symbol.Locations.Length > 0) { // For alias symbol we want to get the tag only for the alias definition, not the target symbol's definition. - await AddLocationSpan(symbol.Locations.First(), solution, spanSet, tagMap, true, cancellationToken).ConfigureAwait(false); + await AddLocationSpan(symbol.Locations.First(), solution, spanSet, tagMap, HighlightSpanKind.Definition, cancellationToken).ConfigureAwait(false); addAllDefinitions = false; } @@ -147,21 +147,22 @@ private bool ShouldConsiderSymbol(ISymbol symbol) { if (location.IsInSource && documentToSearch.Contains(solution.GetDocument(location.SourceTree))) { - await AddLocationSpan(location, solution, spanSet, tagMap, true, cancellationToken).ConfigureAwait(false); + await AddLocationSpan(location, solution, spanSet, tagMap, HighlightSpanKind.Definition, cancellationToken).ConfigureAwait(false); } } } foreach (var referenceLocation in reference.Locations) { - await AddLocationSpan(referenceLocation.Location, solution, spanSet, tagMap, false, cancellationToken).ConfigureAwait(false); + var referenceKind = referenceLocation.IsWrittenTo ? HighlightSpanKind.WrittenReference : HighlightSpanKind.ReadReference; + await AddLocationSpan(referenceLocation.Location, solution, spanSet, tagMap, referenceKind, cancellationToken).ConfigureAwait(false); } } // Add additional references foreach (var location in additionalReferences) { - await AddLocationSpan(location, solution, spanSet, tagMap, false, cancellationToken).ConfigureAwait(false); + await AddLocationSpan(location, solution, spanSet, tagMap, HighlightSpanKind.ReadReference, cancellationToken).ConfigureAwait(false); } var list = new List(tagMap.Count); @@ -205,13 +206,13 @@ private static bool ShouldIncludeDefinition(ISymbol symbol) return true; } - private async Task AddLocationSpan(Location location, Solution solution, HashSet> spanSet, MultiDictionary tagList, bool isDefinition, CancellationToken cancellationToken) + private async Task AddLocationSpan(Location location, Solution solution, HashSet> spanSet, MultiDictionary tagList, HighlightSpanKind kind, CancellationToken cancellationToken) { var span = await GetLocationSpanAsync(solution, location, cancellationToken).ConfigureAwait(false); if (span != null && !spanSet.Contains(span.Value)) { spanSet.Add(span.Value); - tagList.Add(span.Value.Item1, new HighlightSpan(span.Value.Item2, isDefinition)); + tagList.Add(span.Value.Item1, new HighlightSpan(span.Value.Item2, kind)); } } diff --git a/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/IDocumentHighlightsService.cs b/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/IDocumentHighlightsService.cs index 37e8718dcbe..f69677ebb22 100644 --- a/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/IDocumentHighlightsService.cs +++ b/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/IDocumentHighlightsService.cs @@ -11,15 +11,22 @@ namespace Microsoft.CodeAnalysis.Editor { + internal enum HighlightSpanKind + { + Definition, + ReadReference, + WrittenReference, + } + internal struct HighlightSpan { public TextSpan TextSpan { get; } - public bool IsDefinition { get; } + public HighlightSpanKind Kind { get; } - public HighlightSpan(TextSpan textSpan, bool isDefinition) : this() + public HighlightSpan(TextSpan textSpan, HighlightSpanKind kind) : this() { this.TextSpan = textSpan; - this.IsDefinition = isDefinition; + this.Kind = kind; } } diff --git a/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/ReferenceHighlightingViewTaggerProvider.TagProducer.cs b/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/ReferenceHighlightingViewTaggerProvider.TagProducer.cs index 8438d6ca096..9a132ce5d90 100644 --- a/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/ReferenceHighlightingViewTaggerProvider.TagProducer.cs +++ b/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/ReferenceHighlightingViewTaggerProvider.TagProducer.cs @@ -122,11 +122,25 @@ public void Dispose() foreach (var span in documentHighlights.HighlightSpans) { - var tag = span.IsDefinition ? (AbstractNavigatableReferenceHighlightingTag)DefinitionHighlightTag.Instance : ReferenceHighlightTag.Instance; + var tag = GetTag(span); tags.Add(new TagSpan( textSnapshot.GetSpan(Span.FromBounds(span.TextSpan.Start, span.TextSpan.End)), tag)); } } + + private static AbstractNavigatableReferenceHighlightingTag GetTag(HighlightSpan span) + { + switch (span.Kind) + { + case HighlightSpanKind.WrittenReference: + return WrittenReferenceHighlightTag.Instance; + case HighlightSpanKind.Definition: + return DefinitionHighlightTag.Instance; + case HighlightSpanKind.ReadReference: + default: + return ReferenceHighlightTag.Instance; + } + } } } } diff --git a/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/WrittenReferenceHighlightTag.cs b/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/WrittenReferenceHighlightTag.cs new file mode 100644 index 00000000000..5580e70192f --- /dev/null +++ b/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/WrittenReferenceHighlightTag.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.CodeAnalysis.Editor.Shared.Tagging; + +namespace Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting +{ + internal class WrittenReferenceHighlightTag : AbstractNavigatableReferenceHighlightingTag + { + internal const string TagId = "MarkerFormatDefinition/HighlightedWrittenReference"; + + public static readonly WrittenReferenceHighlightTag Instance = new WrittenReferenceHighlightTag(); + + private WrittenReferenceHighlightTag() + : base(TagId) + { + } + } +} diff --git a/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/WrittenReferenceHighlightTagDefinition.cs b/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/WrittenReferenceHighlightTagDefinition.cs new file mode 100644 index 00000000000..4c05409b96a --- /dev/null +++ b/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/WrittenReferenceHighlightTagDefinition.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.Composition; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; +using Microsoft.VisualStudio.Text.Classification; +using Microsoft.VisualStudio.Utilities; + +namespace Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting +{ + [Export(typeof(EditorFormatDefinition))] + [Name(WrittenReferenceHighlightTag.TagId)] + [UserVisible(true)] + internal class WrittenReferenceHighlightTagDefinition : MarkerFormatDefinition + { + public WrittenReferenceHighlightTagDefinition() + { + // NOTE: This is the same color used by the editor for reference highlighting + this.BackgroundColor = Color.FromRgb(219, 224, 204); + this.DisplayName = EditorFeaturesResources.HighlightedWrittenReference; + } + } +} diff --git a/src/EditorFeatures/Test2/ReferenceHighlighting/AbstractReferenceHighlightingTests.vb b/src/EditorFeatures/Test2/ReferenceHighlighting/AbstractReferenceHighlightingTests.vb index f86bd52d09b..282dd36a6ae 100644 --- a/src/EditorFeatures/Test2/ReferenceHighlighting/AbstractReferenceHighlightingTests.vb +++ b/src/EditorFeatures/Test2/ReferenceHighlighting/AbstractReferenceHighlightingTests.vb @@ -31,29 +31,22 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.ReferenceHighlighting workspace, document, cancellationToken:=Nothing).Result Order By tag.Span.Start - Let spanType = If(tag.Tag.Type = DefinitionHighlightTag.TagId, "Definition", "Reference") - Select spanType + ": " + tag.Span.Span.ToTextSpan().ToString() + Let spanType = If(tag.Tag.Type = DefinitionHighlightTag.TagId, "Definition", + If(tag.Tag.Type = WrittenReferenceHighlightTag.TagId, "WrittenReference", "Reference")) + Select spanType + ":" + tag.Span.Span.ToTextSpan().ToString() - Dim expectedDefinitionSpans As New List(Of Tuple(Of String, TextSpan)) + Dim expectedTags As New List(Of String) For Each hostDocument In workspace.Documents - If hostDocument.AnnotatedSpans.ContainsKey("Definition") Then - For Each definitionSpan In hostDocument.AnnotatedSpans("Definition") - expectedDefinitionSpans.Add(Tuple.Create("Definition", definitionSpan)) + For Each nameAndSpans In hostDocument.AnnotatedSpans + For Each span In nameAndSpans.Value + expectedTags.Add(nameAndSpans.Key + ":" + span.ToString()) Next - End If + Next Next - Dim expectedReferenceSpans = workspace.Documents.SelectMany(Function(d) d.SelectedSpans).Select(Function(s) Tuple.Create("Reference", s)) - - Dim expectedTags = From span In expectedDefinitionSpans.Concat(expectedReferenceSpans) - Order By span.Item2.Start - Select span.Item1 + ": " + span.Item2.ToString() - AssertEx.Equal(expectedTags, producedTags) End Using End Sub - End Class - End Namespace diff --git a/src/EditorFeatures/Test2/ReferenceHighlighting/CSharpReferenceHighlightingTests.vb b/src/EditorFeatures/Test2/ReferenceHighlighting/CSharpReferenceHighlightingTests.vb index b75f65c85e8..4fba2b01c4d 100644 --- a/src/EditorFeatures/Test2/ReferenceHighlighting/CSharpReferenceHighlightingTests.vb +++ b/src/EditorFeatures/Test2/ReferenceHighlighting/CSharpReferenceHighlightingTests.vb @@ -48,7 +48,7 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.ReferenceHighlighting { } - [|$$Script|].M(); + {|Reference:$$Script|}.M(); ) @@ -64,7 +64,7 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.ReferenceHighlighting { {|Definition:Foo|}() { - [|var|] x = new [|Foo|](); + {|Reference:var|} x = new {|Reference:Foo|}(); } } @@ -83,7 +83,7 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.ReferenceHighlighting { void Blah() { - var x = new [|$$Foo|](); + var x = new {|Reference:$$Foo|}(); } } @@ -106,7 +106,7 @@ class {|Definition:Program|} { static void Main(string[] args) { - new List<[|Program$$|]>(); + new List<{|Reference:Program$$|}>(); } }]]> @@ -153,7 +153,7 @@ namespace X { public void M() { - $$[|Q|].Directory.Exists(""); + $${|Reference:Q|}.Directory.Exists(""); } } } @@ -178,7 +178,7 @@ namespace X { public void M() { - [|Q|].Directory.Exists(""); + {|Reference:Q|}.Directory.Exists(""); } } } @@ -198,12 +198,12 @@ namespace X namespace X { - using Q = System.$$[|IO|]; + using Q = System.$${|Reference:IO|}; Class B { public void M() { - [|Q|].Directory.Exists(""); + {|Reference:Q|}.Directory.Exists(""); } } } @@ -227,7 +227,7 @@ namespace N { using $${|Definition:C|} = A; // select C class A { } - class B : [|C|] { } + class B : {|Reference:C|} { } }]]> @@ -247,10 +247,10 @@ class C { void F() { - $$[|var|] i = 1; - [|int|] j = 0; + $${|Reference:var|} i = 1; + {|Reference:int|} j = 0; double d; - [|int|] k = 1; + {|Reference:int|} k = 1; } } @@ -271,10 +271,10 @@ class C { void F() { - [|var|] i = 1; - $$[|int|] j = 0; + {|Reference:var|} i = 1; + $${|Reference:int|} j = 0; double d; - [|int|] k = 1; + {|Reference:int|} k = 1; } } @@ -297,10 +297,10 @@ class C { void F() { - $$[|var|] i = new [|List|](); + $${|Reference:var|} i = new {|Reference:List|}(); int j = 0; double d; - [|var|] k = new [|List|](); + {|Reference:var|} k = new {|Reference:List|}(); } } ]]> @@ -438,8 +438,8 @@ class A { B b = new B(); dynamic d = 1.5f; - b.[|Boo|](1); //Line 4 - b.$$[|Boo|](d); //Line 5 + b.{|Reference:Boo|}(1); //Line 4 + b.$${|Reference:Boo|}(d); //Line 5 b.Boo("d"); //Line 6 } } @@ -463,7 +463,7 @@ class C { get { - return this[[|i|]]; + return this[{|Reference:i|}]; } } } @@ -486,7 +486,7 @@ class C { var $${|Definition:a|} = "Hello"; var b = "World"; - var c = $"{[|a|]}, {b}!"; + var c = $"{ {|Reference:a|} }, {b}!"; } } @@ -508,7 +508,28 @@ class C { var a = "Hello"; var $${|Definition:b|} = "World"; - var c = $"{a}, {[|b|]}!"; + var c = $"{a}, { {|Reference:b|} }!"; + } +} + + + + + VerifyHighlights(input) + End Sub + + + Public Sub TestWrittenReference() + Dim input = + + + +class C +{ + void M() + { + var $${|Definition:b|} = "Hello"; + {|WrittenReference:b|} = "World"; } } diff --git a/src/EditorFeatures/Test2/ReferenceHighlighting/CrossLanguageReferenceHighlightingTests.vb b/src/EditorFeatures/Test2/ReferenceHighlighting/CrossLanguageReferenceHighlightingTests.vb index 9826dbc3351..0a5d4680f13 100644 --- a/src/EditorFeatures/Test2/ReferenceHighlighting/CrossLanguageReferenceHighlightingTests.vb +++ b/src/EditorFeatures/Test2/ReferenceHighlighting/CrossLanguageReferenceHighlightingTests.vb @@ -15,7 +15,7 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.ReferenceHighlighting { void Blah() { - [|$$Console|].WriteLine(); + {|Reference:$$Console|}.WriteLine(); } } diff --git a/src/EditorFeatures/Test2/ReferenceHighlighting/VisualBasicReferenceHighlightingTests.vb b/src/EditorFeatures/Test2/ReferenceHighlighting/VisualBasicReferenceHighlightingTests.vb index 638bdb15753..734d531c776 100644 --- a/src/EditorFeatures/Test2/ReferenceHighlighting/VisualBasicReferenceHighlightingTests.vb +++ b/src/EditorFeatures/Test2/ReferenceHighlighting/VisualBasicReferenceHighlightingTests.vb @@ -28,8 +28,8 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.ReferenceHighlighting Class {|Definition:$$Foo|} Public Sub {|Definition:New|}() - Dim x = New [|Foo|]() - Dim y As New [|Foo|]() + Dim x = New {|Reference:Foo|}() + Dim y As New {|Reference:Foo|}() End Sub End Class @@ -47,8 +47,8 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.ReferenceHighlighting Class {|Definition:Foo|} Public Sub Blah() - Dim x = New [|$$Foo|]() - Dim y As New [|Foo|]() + Dim x = New {|Reference:$$Foo|}() + Dim y As New {|Reference:Foo|}() End Sub End Class @@ -71,7 +71,7 @@ End Interface Class C Implements I - Public Sub Bar() Implements I.[|Foo|] + Public Sub Bar() Implements I.{|Reference:Foo|} End Sub End Class @@ -94,7 +94,7 @@ End Interface Class C Implements I - Public Sub Bar() Implements I.[|$$Foo|] + Public Sub Bar() Implements I.{|Reference:$$Foo|} End Sub End Class @@ -117,7 +117,7 @@ End Interface Class C Implements I - Public Sub {|Definition:Foo|}() Implements I.[|$$Foo|] + Public Sub {|Definition:Foo|}() Implements I.{|Reference:$$Foo|} End Sub End Class @@ -151,8 +151,8 @@ End Class Module M Sub Main - [|$$Global|].M.Main() - [|Global|].M.Main() + {|Reference:$$Global|}.M.Main() + {|Reference:Global|}.M.Main() End Sub End Module @@ -218,7 +218,7 @@ End Class Class C Default Public Property Foo($${|Definition:x|} As Integer) As Integer Get - Return [|x|] + Return {|Reference:x|} End Get Set(value As Integer) @@ -231,5 +231,24 @@ End Class VerifyHighlights(input) End Sub + + + Public Sub TestWrittenReference() + Dim input = + + + +Class Foo + Public Sub New() + Dim {|Definition:$$x|} As Integer + {|WrittenReference:x|} = 0 + End Sub +End Class + + + + + VerifyHighlights(input) + End Sub End Class End Namespace diff --git a/src/Features/Core/ChangeSignature/DelegateInvokeMethodReferenceFinder.cs b/src/Features/Core/ChangeSignature/DelegateInvokeMethodReferenceFinder.cs index bda166cbe90..2f20d7927b2 100644 --- a/src/Features/Core/ChangeSignature/DelegateInvokeMethodReferenceFinder.cs +++ b/src/Features/Core/ChangeSignature/DelegateInvokeMethodReferenceFinder.cs @@ -98,7 +98,8 @@ protected override bool CanFind(IMethodSymbol symbol) var invocations = nodes.Where(n => syntaxFactsService.IsInvocationExpression(n)) .Where(e => semanticModel.GetSymbolInfo(e, cancellationToken).Symbol.OriginalDefinition == methodSymbol); - return invocations.Concat(convertedAnonymousFunctions).Select(e => new ReferenceLocation(document, null, e.GetLocation(), isImplicit: false, candidateReason: CandidateReason.None)); + return invocations.Concat(convertedAnonymousFunctions).Select( + e => new ReferenceLocation(document, null, e.GetLocation(), isImplicit: false, isWrittenTo: false, candidateReason: CandidateReason.None)); } } } diff --git a/src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/AbstractReferenceFinder.cs b/src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/AbstractReferenceFinder.cs index 628af6c0af1..f0c89f13f71 100644 --- a/src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/AbstractReferenceFinder.cs +++ b/src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/AbstractReferenceFinder.cs @@ -515,7 +515,8 @@ protected static bool IdentifiersMatch(ISyntaxFactsService syntaxFacts, string n var alias = FindReferenceCache.GetAliasInfo(semanticFacts, semanticModel, token, cancellationToken); var location = token.GetLocation(); - locations.Add(new ReferenceLocation(document, alias, location, isImplicit: false, candidateReason: match.Item2)); + var isWrittemTo = semanticFacts.IsWrittenTo(semanticModel, token.Parent, cancellationToken); + locations.Add(new ReferenceLocation(document, alias, location, isImplicit: false, isWrittenTo: isWrittemTo, candidateReason: match.Item2)); } } } @@ -731,7 +732,7 @@ protected Task> FindDocumentsWithForEachStatementsAsync(Pr { var location = node.GetFirstToken().GetLocation(); locations.Add(new ReferenceLocation( - document, alias: null, location: location, isImplicit: true, candidateReason: CandidateReason.None)); + document, alias: null, location: location, isImplicit: true, isWrittenTo: false, candidateReason: CandidateReason.None)); } } diff --git a/src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/PropertySymbolReferenceFinder.cs b/src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/PropertySymbolReferenceFinder.cs index fa58704eccd..6fb8a06d228 100644 --- a/src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/PropertySymbolReferenceFinder.cs +++ b/src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/PropertySymbolReferenceFinder.cs @@ -156,7 +156,7 @@ private static bool IsForEachProperty(IPropertySymbol symbol) if (nodeToBeReferenced != null) { var location = nodeToBeReferenced.SyntaxTree.GetLocation(new TextSpan(nodeToBeReferenced.SpanStart, 0)); - locations.Add(new ReferenceLocation(document, null, location, isImplicit: false, candidateReason: match.Item2)); + locations.Add(new ReferenceLocation(document, null, location, isImplicit: false, isWrittenTo: false, candidateReason: match.Item2)); } } } diff --git a/src/Workspaces/Core/Portable/FindSymbols/ReferenceLocation.cs b/src/Workspaces/Core/Portable/FindSymbols/ReferenceLocation.cs index 53c71b0c290..e6ac0a7f0c5 100644 --- a/src/Workspaces/Core/Portable/FindSymbols/ReferenceLocation.cs +++ b/src/Workspaces/Core/Portable/FindSymbols/ReferenceLocation.cs @@ -36,15 +36,21 @@ public struct ReferenceLocation : IComparable, IEquatable public bool IsImplicit { get; } + /// + /// Inidicates if this is a location where the reference is written to. + /// + internal bool IsWrittenTo { get; } + public CandidateReason CandidateReason { get; } - internal ReferenceLocation(Document document, IAliasSymbol alias, Location location, bool isImplicit, CandidateReason candidateReason) + internal ReferenceLocation(Document document, IAliasSymbol alias, Location location, bool isImplicit, bool isWrittenTo, CandidateReason candidateReason) : this() { this.Document = document; this.Alias = alias; this.Location = location; this.IsImplicit = isImplicit; + this.IsWrittenTo = isWrittenTo; this.CandidateReason = candidateReason; } -- GitLab