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

Commitebceae4

Browse files
vasily-kirichenkoTIHan
authored andcommitted
Fix Go to Definition for recursive types (#5050)
* do not strip type abbreviation in go to definitionfix go to definition for recursively declared types* fix a typo* fix typos* Update branch with latest Go to Definition changes
1 parenteb0be3f commitebceae4

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

‎src/fsharp/service/service.fs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,9 @@ type TypeCheckInfo
12081208
//Item.Value(vref)
12091209
None
12101210

1211-
| Item.Types(_,[AppTy g(tr,_)])whennot tr.IsLocalRef->
1211+
| Item.Types(_, TType_app(tr,_)::_)when tr.IsLocalRef&& tr.IsTypeAbbrev-> None
1212+
1213+
| Item.Types(_,[ AppTy g(tr,_)])whennot tr.IsLocalRef->
12121214
match tr.TypeReprInfo, tr.PublicPathwith
12131215
| TILObjectRepr(TILObjectReprData(ILScopeRef.Assembly assref,_,_)), Some(PubPath parts)->
12141216
letfullName= parts|> String.concat"."

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -204,16 +204,21 @@ type internal GoToDefinition(checker: FSharpChecker, projectInfoManager: FSharpP
204204
return! rangeToNavigableItem(fsSymbolUse.RangeAlternate, targetDocument)
205205
}
206206

207-
/// Use the targetSymbol to find the first instance of its presence in the provided source file.
208-
memberprivate__.FindSymbolDeclarationInFile(targetSymbolUse:FSharpSymbolUse,filePath:string,source:string,options:FSharpProjectOptions,fileVersion:int)=
207+
/// if the symbol is defined in the given file, return its declaration location, otherwise use the targetSymbol to find the first
208+
/// instance of its presence in the provided source file. The first case is needed to return proper declaration location for
209+
/// recursive type definitions, where the first its usage may not be the declaration.
210+
member__.FindSymbolDeclarationInFile(targetSymbolUse:FSharpSymbolUse,filePath:string,source:string,options:FSharpProjectOptions,fileVersion:int)=
209211
asyncMaybe{
210-
let!_,checkFileAnswer= checker.ParseAndCheckFileInProject(filePath, fileVersion, source, options, userOpName=userOpName)|> liftAsync
211-
match checkFileAnswerwith
212-
| FSharpCheckFileAnswer.Aborted->return! None
213-
| FSharpCheckFileAnswer.Succeeded checkFileResults->
214-
let!symbolUses= checkFileResults.GetUsesOfSymbolInFile targetSymbolUse.Symbol|> liftAsync
215-
let!implSymbol= symbolUses|> Array.tryHead
216-
return implSymbol.RangeAlternate
212+
match targetSymbolUse.Symbol.DeclarationLocationwith
213+
| Some declwhen decl.FileName= filePath->return decl
214+
|_->
215+
let!_,checkFileAnswer= checker.ParseAndCheckFileInProject(filePath, fileVersion, source, options, userOpName= userOpName)|> liftAsync
216+
match checkFileAnswerwith
217+
| FSharpCheckFileAnswer.Aborted->return! None
218+
| FSharpCheckFileAnswer.Succeeded checkFileResults->
219+
let!symbolUses= checkFileResults.GetUsesOfSymbolInFile targetSymbolUse.Symbol|> liftAsync
220+
let!implSymbol= symbolUses|> Array.tryHead
221+
return implSymbol.RangeAlternate
217222
}
218223

219224
memberprivatethis.FindDefinitionAtPosition(originDocument:Document,position:int)=

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp