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

Commitd9077c7

Browse files
vasily-kirichenkoKevinRansom
authored andcommitted
Do not suggest already opened namespaces and modules in "Add Open" code fix (dotnet#2515)
* do not suggest already opened namespaces and modules in "Add Open" code fix* check if we can obtain symbol via GetSymbolAtLocation* Revert "do not suggest already opened namespaces and modules in "Add Open" code fix"This reverts commita085f39.Conflicts:vsintegration/src/FSharp.Editor/CodeFix/AddOpenCodeFixProvider.fs
1 parent38eb9bb commitd9077c7

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

‎vsintegration/src/FSharp.Editor/CodeFix/AddOpenCodeFixProvider.fs‎

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,22 @@ type internal FSharpAddOpenCodeFixProvider
145145

146146
override__.RegisterCodeFixesAsync context:Task=
147147
asyncMaybe{
148-
let!options= projectInfoManager.TryGetOptionsForEditingDocumentOrProject context.Document
148+
letdocument= context.Document
149+
let!options= projectInfoManager.TryGetOptionsForEditingDocumentOrProject document
149150
let!sourceText= context.Document.GetTextAsync(context.CancellationToken)
150-
let!_,parsedInput,checkResults= checker.ParseAndCheckDocument(context.Document, options, allowStaleResults=true, sourceText= sourceText)
151+
let!_,parsedInput,checkResults= checker.ParseAndCheckDocument(document, options, allowStaleResults=true, sourceText= sourceText)
152+
letline= sourceText.Lines.GetLineFromPosition(context.Span.End)
153+
letlinePos= sourceText.Lines.GetLinePosition(context.Span.End)
154+
letdefines= CompilerEnvironment.GetCompilationDefinesForEditing(document.Name, options.OtherOptions|> Seq.toList)
151155

156+
let!symbol=
157+
asyncMaybe{
158+
let!lexerSymbol= CommonHelpers.getSymbolAtPosition(document.Id, sourceText, context.Span.End, document.FilePath, defines, SymbolLookupKind.Greedy)
159+
return! checkResults.GetSymbolUseAtLocation(Line.fromZ linePos.Line, lexerSymbol.Ident.idRange.EndColumn, line.ToString(), lexerSymbol.FullIsland)
160+
}|> liftAsync
161+
162+
do! Option.guard symbol.IsNone
163+
152164
letunresolvedIdentRange=
153165
letstartLinePos= sourceText.Lines.GetLinePosition context.Span.Start
154166
letstartPos= Pos.fromZ startLinePos.Line startLinePos.Character
@@ -163,14 +175,14 @@ type internal FSharpAddOpenCodeFixProvider
163175
|> List.collect(fun e->
164176
[yield e.TopRequireQualifiedAccessParent, e.AutoOpenParent, e.Namespace, e.CleanedIdents
165177
if isAttributethen
166-
letlastIdent= e.CleanedIdents.[e.CleanedIdents.Length-1]
167-
if lastIdent.EndsWith"Attribute"&& e.Kind LookupType.Precise= EntityKind.Attributethen
168-
yield
169-
e.TopRequireQualifiedAccessParent,
170-
e.AutoOpenParent,
171-
e.Namespace,
172-
e.CleanedIdents
173-
|> Array.replace(e.CleanedIdents.Length-1)(lastIdent.Substring(0, lastIdent.Length-9))])
178+
letlastIdent= e.CleanedIdents.[e.CleanedIdents.Length-1]
179+
if lastIdent.EndsWith"Attribute"&& e.Kind LookupType.Precise= EntityKind.Attributethen
180+
yield
181+
e.TopRequireQualifiedAccessParent,
182+
e.AutoOpenParent,
183+
e.Namespace,
184+
e.CleanedIdents
185+
|> Array.replace(e.CleanedIdents.Length-1)(lastIdent.Substring(0, lastIdent.Length-9))])
174186

175187
letlongIdent= ParsedInput.getLongIdentAt parsedInput unresolvedIdentRange.End
176188

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ type internal FSharpGoToDefinitionService
4444
asyncMaybe{
4545
lettextLine= sourceText.Lines.GetLineFromPosition(position)
4646
lettextLinePos= sourceText.Lines.GetLinePosition(position)
47-
letfcsTextLineNumber=textLinePos.Line+1// Roslyn line numbers are zero-based, FSharp.Compiler.Service line numbers are 1-based
47+
letfcsTextLineNumber= Line.fromZ textLinePos.Line
4848
let!symbol= CommonHelpers.getSymbolAtPosition(documentKey, sourceText, position, filePath, defines, SymbolLookupKind.Greedy)
4949
let!_,_,checkFileResults= checker.ParseAndCheckDocument(filePath, textVersionHash, sourceText.ToString(), options, allowStaleResults=true)
5050
let!declarations= checkFileResults.GetDeclarationLocationAlternate(fcsTextLineNumber, symbol.Ident.idRange.EndColumn, textLine.ToString(), symbol.FullIsland,false)|> liftAsync

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp