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

Commit1558a9f

Browse files
committed
Reuse SymbolEnv for file type check info
1 parent5c4bf16 commit1558a9f

File tree

4 files changed

+22
-15
lines changed

4 files changed

+22
-15
lines changed

‎src/fsharp/fsi/fsi.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,7 @@ type internal FsiDynamicCompiler
11781178
| Item.Value vref->
11791179
letoptValue= newState.ilxGenerator.LookupGeneratedValue(valuePrinter.GetEvaluationContext(newState.emEnv), vref.Deref)
11801180
match optValuewith
1181-
| Some(res, typ)-> Some(FsiValue(res, typ, FSharpType(tcGlobals, newState.tcState.Ccu, newState.tcState.CcuSig, newState.tcImports, vref.Type)))
1181+
| Some(res, typ)-> Some(FsiValue(res, typ, FSharpType(cenv, vref.Type)))
11821182
| None-> None
11831183
|_-> None
11841184

‎src/fsharp/service/service.fs‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ type TypeCheckInfo
183183
letamap= tcImports.GetImportMap()
184184
letinfoReader=new InfoReader(g,amap)
185185
letncenv=new NameResolver(g,amap,infoReader,NameResolution.FakeInstantiationGenerator)
186+
letcenv= SymbolEnv(g, thisCcu, Some ccuSigForFile, tcImports, amap, infoReader)
186187

187188
/// Find the most precise naming environment for the given line and column
188189
letGetBestEnvForPos cursorPos=
@@ -938,7 +939,6 @@ type TypeCheckInfo
938939
match GetDeclItemsForNamesAtPosition(ctok, parseResultsOpt, Some partialName.QualifyingIdents, Some partialName.PartialIdent, partialName.LastDotPos, line, lineStr, partialName.EndColumn+1, ResolveTypeNamesToCtors, ResolveOverloads.Yes, getAllEntities, hasTextChangedSinceLastTypecheck)with
939940
| None-> FSharpDeclarationListInfo.Empty
940941
| Some(items, denv, ctx, m)->
941-
letcenv= SymbolEnv(g, thisCcu, Some ccuSigForFile, tcImports)
942942
letitems=if isInterfaceFilethen items|> List.filter(fun x-> IsValidSignatureFileItem x.Item)else items
943943
letgetAccessibility item= FSharpSymbol.GetAccessibility(FSharpSymbol.Create(cenv, item))
944944
letcurrentNamespaceOrModule=
@@ -1011,16 +1011,15 @@ type TypeCheckInfo
10111011

10121012
items|> List.filter(fun(nm,items)->not(isOpItem(nm,items))&&not(isFSharpList nm))
10131013

1014-
letcenv= SymbolEnv(g, thisCcu, Some ccuSigForFile, tcImports)
10151014
letitems=
10161015
// Filter out duplicate names
10171016
items|> List.map(fun(_nm,itemsWithSameName)->
10181017
match itemsWithSameNamewith
10191018
|[]-> failwith"Unexpected empty bag"
10201019
| items->
1021-
items|> List.map(fun item->
1022-
letsymbol= FSharpSymbol.Create(cenv, item.Item)
1023-
FSharpSymbolUse(g, denv, symbol, ItemOccurence.Use, m)))
1020+
items
1021+
|> List.map(fun item->letsymbol= FSharpSymbol.Create(cenv, item.Item)
1022+
FSharpSymbolUse(g, denv, symbol, ItemOccurence.Use, m)))
10241023

10251024
//end filtering
10261025
items)
@@ -1134,7 +1133,6 @@ type TypeCheckInfo
11341133
match GetDeclItemsForNamesAtPosition(ctok, None,Some(names), None, None,line, lineStr, colAtEndOfNames, ResolveTypeNamesToCtors, ResolveOverloads.No,(fun()->[]),fun _->false)with
11351134
| None| Some([],_,_,_)-> None
11361135
| Some(items, denv,_, m)->
1137-
letcenv= SymbolEnv(g, thisCcu, Some ccuSigForFile, tcImports)
11381136
letallItems= items|> List.collect(fun item-> SymbolHelpers.FlattenItems g m item.Item)
11391137
letsymbols= allItems|> List.map(fun item-> FSharpSymbol.Create(cenv, item))
11401138
Some(symbols, denv, m)
@@ -1250,7 +1248,7 @@ type TypeCheckInfo
12501248
match GetDeclItemsForNamesAtPosition(ctok, None,Some(names), None, None, line, lineStr, colAtEndOfNames, ResolveTypeNamesToCtors, ResolveOverloads.Yes,(fun()->[]),fun _->false)with
12511249
| None| Some([],_,_,_)-> None
12521250
| Some(item::_, denv,_, m)->
1253-
letsymbol= FSharpSymbol.Create(g, thisCcu, ccuSigForFile, tcImports, item.Item)
1251+
letsymbol= FSharpSymbol.Create(cenv, item.Item)
12541252
Some(symbol, denv, m)
12551253
)
12561254
(fun msg->
@@ -1402,6 +1400,8 @@ type TypeCheckInfo
14021400
/// All open declarations in the file, including auto open modules
14031401
member__.OpenDeclarations= openDeclarations
14041402

1403+
member__.SymbolEnv= cenv
1404+
14051405
override__.ToString()="TypeCheckInfo("+ mainInputFileName+")"
14061406

14071407
typeFSharpParsingOptions=
@@ -2084,7 +2084,7 @@ type FSharpCheckFileResults(filename: string, errors: FSharpErrorInfo[], scopeOp
20842084
threadSafeOp
20852085
(fun()->[||])
20862086
(fun scope->
2087-
letcenv=SymbolEnv(scope.TcGlobals, scope.ThisCcu, Some scope.CcuSigForFile, scope.TcImports)
2087+
letcenv= scope.SymbolEnv
20882088
[|for symbolUsein scope.ScopeSymbolUses.AllUsesOfSymbolsdo
20892089
if symbolUse.ItemOccurence<> ItemOccurence.RelatedTextthen
20902090
letsymbol= FSharpSymbol.Create(cenv, symbolUse.Item)
@@ -2129,7 +2129,7 @@ type FSharpCheckFileResults(filename: string, errors: FSharpErrorInfo[], scopeOp
21292129
memberinfo.OpenDeclarations=
21302130
scopeOptX
21312131
|> Option.map(fun scope->
2132-
letcenv=SymbolEnv(scope.TcGlobals, scope.ThisCcu, Some scope.CcuSigForFile, scope.TcImports)
2132+
letcenv= scope.SymbolEnv
21332133
scope.OpenDeclarations|> Array.map(fun x-> FSharpOpenDeclaration(x.LongId, x.Range,(x.Modules|> List.map(fun x-> FSharpEntity(cenv, x))), x.AppliedScope, x.IsOwnNamespace)))
21342134
|> Option.defaultValue[||]
21352135

‎src/fsharp/symbols/Symbols.fs‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,13 @@ type FSharpAccessibility(a:Accessibility, ?isProtected) =
4949
letmangledTextOfCompPath(CompPath(scoref,path))= getNameOfScopeRef scoref+"/"+ textOfPath(List.map fst path)
5050
String.concat";"(List.map mangledTextOfCompPath paths)
5151

52-
typeSymbolEnv(g:TcGlobals,thisCcu: CcuThunk,thisCcuTyp: ModuleOrNamespaceType option,tcImports: TcImports)=
53-
letamapV= tcImports.GetImportMap()
54-
letinfoReaderV= InfoReader(g, amapV)
52+
typeSymbolEnv(g: TcGlobals,thisCcu: CcuThunk,thisCcuTyp: ModuleOrNamespaceType option,tcImports: TcImports,amapV: Import.ImportMap,infoReaderV: InfoReader)=
53+
54+
new(g: TcGlobals, thisCcu: CcuThunk, thisCcuTyp: ModuleOrNamespaceType option, tcImports: TcImports)=
55+
letamap= tcImports.GetImportMap()
56+
letinfoReader= InfoReader(g, amap)
57+
SymbolEnv(g, thisCcu, thisCcuTyp, tcImports, amap, infoReader)
58+
5559
member__.g= g
5660
member__.amap= amapV
5761
member__.thisCcu= thisCcu

‎src/fsharp/symbols/Symbols.fsi‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ open System.Collections.Generic
66
openMicrosoft.FSharp.Compiler
77
openMicrosoft.FSharp.Compiler.AccessibilityLogic
88
openMicrosoft.FSharp.Compiler.CompileOps
9+
openMicrosoft.FSharp.Compiler.Import
10+
openMicrosoft.FSharp.Compiler.InfoReader
911
openMicrosoft.FSharp.Compiler.Range
1012
openMicrosoft.FSharp.Compiler.Ast
1113
openMicrosoft.FSharp.Compiler.Tast
@@ -14,8 +16,9 @@ open Microsoft.FSharp.Compiler.NameResolution
1416

1517
// Implementation details used by other code in the compiler
1618
typeinternalSymbolEnv=
17-
new: TcGlobals* thisCcu:CcuThunk* thisCcuTyp: ModuleOrNamespaceType option* tcImports: TcImports-> SymbolEnv
18-
memberamap:Import.ImportMap
19+
new: TcGlobals* thisCcu:CcuThunk* thisCcuTyp: ModuleOrNamespaceType option* tcImports: TcImports-> SymbolEnv
20+
new: TcGlobals* thisCcu:CcuThunk* thisCcuTyp: ModuleOrNamespaceType option* tcImports: TcImports* amap: ImportMap* infoReader: InfoReader-> SymbolEnv
21+
memberamap:ImportMap
1922
memberg:TcGlobals
2023

2124
/// Indicates the accessibility of a symbol, as seen by the F# language

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp