Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf8e579f

Browse files
vasily-kirichenkoKevinRansom
authored andcommitted
Fix find all references (dotnet#2167)
* add glyph for declarations in Find All References result window* fixed: ColorizationService may return duplicated spans which caused FindReferencesService to crash* remove #nowarn "1182"* fixed: FindReferencesService does not work on external symbols
1 parentc2821eb commitf8e579f

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

‎vsintegration/src/FSharp.Editor/Classification/ColorizationService.fs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ type internal FSharpColorizationService
4040
let!options= projectInfoManager.TryGetOptionsForEditingDocumentOrProject(document)
4141
let!sourceText= document.GetTextAsync(cancellationToken)
4242
let!_,checkResults= checkerProvider.Checker.ParseAndCheckDocument(document, options, sourceText)
43-
44-
for(range, tokenColorKind)in checkResults.GetExtraColorizationsAlternate()do
43+
// it's crucial to not return duplicated or overlapping `ClassifiedSpan`s because Find Usages service crashes.
44+
letcolorizationData= checkResults.GetExtraColorizationsAlternate()|> Array.distinctBy fst
45+
for(range, tokenColorKind)in colorizationDatado
4546
letspan= CommonHelpers.fixupSpan(sourceText, CommonRoslynHelpers.FSharpRangeToTextSpan(sourceText, range))
4647
if textSpan.Contains(span.Start)|| textSpan.Contains(span.End-1)|| span.Contains(textSpan)then
4748
result.Add(ClassifiedSpan(span, CommonHelpers.compilerTokenToRoslynToken(tokenColorKind)))

‎vsintegration/src/FSharp.Editor/Navigation/FindReferencesService.fs‎

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ open Microsoft.CodeAnalysis.Editor.Host
1414
openMicrosoft.CodeAnalysis.Navigation
1515
openMicrosoft.CodeAnalysis.FindSymbols
1616
openMicrosoft.CodeAnalysis.FindReferences
17+
openMicrosoft.CodeAnalysis.Completion
1718

1819
openMicrosoft.VisualStudio.FSharp.LanguageService
1920

@@ -62,31 +63,32 @@ type internal FSharpFindReferencesService
6263
let!symbol= CommonHelpers.getSymbolAtPosition(document.Id, sourceText, position, document.FilePath, defines, SymbolLookupKind.Fuzzy)
6364
let!symbolUse= checkFileResults.GetSymbolUseAtLocation(lineNumber, symbol.RightColumn, textLine,[symbol.Text])
6465
let!declaration= checkFileResults.GetDeclarationLocationAlternate(lineNumber, symbol.RightColumn, textLine,[symbol.Text],false)|> liftAsync
66+
lettags= GlyphTags.GetTags(CommonRoslynHelpers.GetGlyphForSymbol symbolUse.Symbol)
6567

6668
letdeclarationRange=
6769
match declarationwith
6870
| FSharpFindDeclResult.DeclFound range-> Some range
6971
|_-> None
7072

71-
let!declarationSpans=
72-
match declarationRangewith
73-
| Some range-> rangeToDocumentSpans(document.Project.Solution, range, context.CancellationToken)|> liftAsync
74-
| None-> async.Return None
75-
76-
letdefinitionItems=
77-
match declarationSpanswith
78-
|[]->
79-
[ DefinitionItem.CreateNonNavigableItem(
80-
ImmutableArray<string>.Empty,
81-
[TaggedText(TextTags.Text, symbolUse.Symbol.FullName)].ToImmutableArray(),
82-
[TaggedText(TextTags.Assembly, symbolUse.Symbol.Assembly.SimpleName)].ToImmutableArray())]
83-
|_->
84-
declarationSpans
85-
|> List.map(fun span->
86-
DefinitionItem.Create(
87-
ImmutableArray<string>.Empty,
88-
[TaggedText(TextTags.Text,symbolUse.Symbol.FullName)].ToImmutableArray(),
89-
span))
73+
let!definitionItems=
74+
async{
75+
let!declarationSpans=
76+
match declarationRangewith
77+
| Some range-> rangeToDocumentSpans(document.Project.Solution, range, context.CancellationToken)
78+
| None-> async.Return[]
79+
80+
return
81+
match declarationSpanswith
82+
|[]->
83+
[ DefinitionItem.CreateNonNavigableItem(
84+
tags,
85+
ImmutableArray.Create(TaggedText(TextTags.Text, symbol.Text)),
86+
ImmutableArray.Create(TaggedText(TextTags.Assembly, symbolUse.Symbol.Assembly.SimpleName)))]
87+
|_->
88+
declarationSpans
89+
|> List.map(fun span->
90+
DefinitionItem.Create(tags, ImmutableArray.Create(TaggedText(TextTags.Text,symbol.Text)),span))
91+
}|> liftAsync
9092

9193
for definitionItemin definitionItemsdo
9294
do! context.OnDefinitionFoundAsync(definitionItem)|> Async.AwaitTask|> liftAsync

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp