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

Commit30c9bcf

Browse files
Vasily KirichenkoVasily Kirichenko
Vasily Kirichenko
authored and
Vasily Kirichenko
committed
store TcResolutions.CapturedEnvs indexed by line
1 parentc8e4e82 commit30c9bcf

File tree

3 files changed

+28
-14
lines changed

3 files changed

+28
-14
lines changed

‎src/fsharp/NameResolution.fs‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,14 +1351,14 @@ type CapturedNameResolution(p:pos, i:Item, io:ItemOccurence, de:DisplayEnv, nre:
13511351

13521352
/// Represents container for all name resolutions that were met so far when typechecking some particular file
13531353
typeTcResolutions
1354-
(capturedEnvs: ResizeArray<range* NameResolutionEnv* AccessorDomain>,
1354+
(capturedEnvsByLine: ResizeArray<ResizeArray<range* NameResolutionEnv* AccessorDomain>>,
13551355
capturedExprTypes: ResizeArray<pos* TType* DisplayEnv* NameResolutionEnv* AccessorDomain* range>,
13561356
capturedNameResolutions: ResizeArray<CapturedNameResolution>,
13571357
capturedMethodGroupResolutions: ResizeArray<CapturedNameResolution>)=
13581358

13591359
static letempty= TcResolutions(ResizeArray(0),ResizeArray(0),ResizeArray(0),ResizeArray(0))
13601360

1361-
memberthis.CapturedEnvs=capturedEnvs
1361+
memberthis.CapturedEnvsByLine=capturedEnvsByLine
13621362
memberthis.CapturedExpressionTypings= capturedExprTypes
13631363
memberthis.CapturedNameResolutions= capturedNameResolutions
13641364
memberthis.CapturedMethodGroupResolutions= capturedMethodGroupResolutions
@@ -1383,7 +1383,7 @@ type TcSymbolUses(g, capturedNameResolutions : ResizeArray<CapturedNameResolutio
13831383

13841384
/// An accumulator for the results being emitted into the tcSink.
13851385
typeTcResultsSinkImpl(g,?source: string)=
1386-
letcapturedEnvs= ResizeArray<_>()
1386+
letcapturedEnvsByLine= ResizeArray<ResizeArray<range* NameResolutionEnv* AccessorDomain>>()
13871387
letcapturedExprTypings= ResizeArray<_>()
13881388
letcapturedNameResolutions= ResizeArray<_>()
13891389
letcapturedFormatSpecifierLocations= ResizeArray<_>()
@@ -1396,15 +1396,18 @@ type TcResultsSinkImpl(g, ?source: string) =
13961396
letallowedRange(m:range)=not m.IsSynthetic
13971397

13981398
memberthis.GetResolutions()=
1399-
TcResolutions(capturedEnvs, capturedExprTypings, capturedNameResolutions, capturedMethodGroupResolutions)
1399+
TcResolutions(capturedEnvsByLine, capturedExprTypings, capturedNameResolutions, capturedMethodGroupResolutions)
14001400

14011401
memberthis.GetSymbolUses()=
14021402
TcSymbolUses(g, capturedNameResolutions, capturedFormatSpecifierLocations.ToArray())
14031403

14041404
interface ITypecheckResultsSinkwith
1405-
membersink.NotifyEnvWithScope(m,nenv,ad)=
1406-
if allowedRange mthen
1407-
capturedEnvs.Add((m,nenv,ad))
1405+
membersink.NotifyEnvWithScope(m,nenv,ad)=
1406+
if allowedRange mthen
1407+
for iin capturedEnvsByLine.Count..m.EndLinedo
1408+
capturedEnvsByLine.Add(ResizeArray())
1409+
for linein m.StartLine..m.EndLinedo
1410+
capturedEnvsByLine.[line].Add(m, nenv, ad)
14081411

14091412
membersink.NotifyExprHasType(endPos,ty,denv,nenv,ad,m)=
14101413
if allowedRange mthen

‎src/fsharp/NameResolution.fsi‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,9 @@ type internal CapturedNameResolution =
219219
[<Class>]
220220
type internal TcResolutions=
221221

222-
/// Name resolution environmentsfor every interesting region in the file. These regions may
223-
/// overlap, in which case the smallest region applicable should be used.
224-
memberCapturedEnvs:ResizeArray<range*NameResolutionEnv*AccessorDomain>
222+
/// Name resolution environmentsindexed by line number.
223+
///Regions mayoverlap, in which case the smallest region applicable should be used.
224+
memberCapturedEnvsByLine:ResizeArray<ResizeArray<range* NameResolutionEnv* AccessorDomain>>
225225

226226
/// Information of exact types found for expressions, that can be to the left of a dot.
227227
/// typ - the inferred type for an expression

‎src/fsharp/vs/service.fs‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -518,12 +518,18 @@ type TypeCheckInfo
518518
letncenv=new NameResolver(g,amap,infoReader,NameResolution.FakeInstantiationGenerator)
519519

520520
/// Find the most precise naming environment for the given line and column
521-
letGetBestEnvForPos cursorPos=
521+
letGetBestEnvForPos(cursorPos:pos)=
522522

523+
letgetEnvsOnLine line=
524+
if line<0then ResizeArray()
525+
elif line> sResolutions.CapturedEnvsByLine.Count-1then ResizeArray()
526+
else sResolutions.CapturedEnvsByLine.[line]
527+
528+
letenvsOnLine= getEnvsOnLine cursorPos.Line
523529
letbestSoFar= ref None
524530

525531
// Find the most deeply nested enclosing scope that contains given position
526-
sResolutions.CapturedEnvs|> ResizeArray.iter(fun(possm,env,ad)->
532+
envsOnLine|> ResizeArray.iter(fun(possm,env,ad)->
527533
if rangeContainsPos possm cursorPosthen
528534
match!bestSoFarwith
529535
| Some(bestm,_,_)->
@@ -540,9 +546,14 @@ type TypeCheckInfo
540546
// We guarantee to only refine to a more nested environment. It may not be strictly
541547
// the right environment, but will alwauys be at least as rich
542548

543-
letbestAlmostIncludedSoFar= ref None
549+
letbestAlmostIncludedSoFar= ref None
550+
551+
letevnsOnLineAndPreviousLine=
552+
letenvs= getEnvsOnLine(cursorPos.Line-1)
553+
envs.AddRange(envsOnLine)
554+
envs
544555

545-
sResolutions.CapturedEnvs|> ResizeArray.iter(fun(possm,env,ad)->
556+
evnsOnLineAndPreviousLine|> ResizeArray.iter(fun(possm,env,ad)->
546557
// take only ranges that strictly do not include cursorPos (all ranges that touch cursorPos were processed during 'Strict Inclusion' part)
547558
if rangeBeforePos possm cursorPos&&not(posEq possm.End cursorPos)then
548559
letcontained=

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp