提交 6e8515fc 编写于 作者: V Vasily Kirichenko 提交者: Will Smith

do not simplify open statements (#4068)

上级 bc9f2a16
......@@ -1223,6 +1223,8 @@ type ItemOccurence =
| Implemented
/// Result gets suppressed over this text range
| RelatedText
/// This is a usage of a module or namespace name in open statement
| Open
type OpenDeclaration =
{ LongId: Ident list
......
......@@ -246,6 +246,7 @@ type internal ItemOccurence =
| Pattern
| Implemented
| RelatedText
| Open
/// Check for equality, up to signature matching
val ItemsAreEffectivelyEqual : TcGlobals -> Item -> Item -> bool
......
......@@ -466,7 +466,7 @@ let OpenModulesOrNamespaces tcSink g amap scopem root env mvvs openDeclaration =
loop acc rest
for item, range in loop [] (List.rev openDeclaration.LongId) do
CallNameResolutionSink tcSink (range, env.NameEnv, item, item, emptyTyparInst, ItemOccurence.Use, env.DisplayEnv, env.eAccessRights)
CallNameResolutionSink tcSink (range, env.NameEnv, item, item, emptyTyparInst, ItemOccurence.Open, env.DisplayEnv, env.eAccessRights)
env
let AddRootModuleOrNamespaceRefs g amap m env modrefs =
......
......@@ -2281,11 +2281,11 @@ type FSharpSymbolUse(g:TcGlobals, denv: DisplayEnv, symbol:FSharpSymbol, itemOcc
member __.Symbol = symbol
member __.DisplayContext = FSharpDisplayContext(fun _ -> denv)
member x.IsDefinition = x.IsFromDefinition
member __.IsFromDefinition = (match itemOcc with ItemOccurence.Binding -> true | _ -> false)
member __.IsFromPattern = (match itemOcc with ItemOccurence.Pattern -> true | _ -> false)
member __.IsFromType = (match itemOcc with ItemOccurence.UseInType -> true | _ -> false)
member __.IsFromAttribute = (match itemOcc with ItemOccurence.UseInAttribute -> true | _ -> false)
member __.IsFromDispatchSlotImplementation = (match itemOcc with ItemOccurence.Implemented -> true | _ -> false)
member __.IsFromDefinition = itemOcc = ItemOccurence.Binding
member __.IsFromPattern = itemOcc = ItemOccurence.Pattern
member __.IsFromType = itemOcc = ItemOccurence.UseInType
member __.IsFromAttribute = itemOcc = ItemOccurence.UseInAttribute
member __.IsFromDispatchSlotImplementation = itemOcc = ItemOccurence.Implemented
member __.IsFromComputationExpression =
match symbol.Item, itemOcc with
// 'seq' in 'seq { ... }' gets colored as keywords
......@@ -2293,7 +2293,7 @@ type FSharpSymbolUse(g:TcGlobals, denv: DisplayEnv, symbol:FSharpSymbol, itemOcc
// custom builders, custom operations get colored as keywords
| (Item.CustomBuilder _ | Item.CustomOperation _), ItemOccurence.Use -> true
| _ -> false
member __.IsFromOpenStatement = itemOcc = ItemOccurence.Open
member __.FileName = range.FileName
member __.Range = Range.toZ range
member __.RangeAlternate = range
......
......@@ -1125,6 +1125,9 @@ type internal FSharpSymbolUse =
/// Indicates if the reference is either a builder or a custom operation in a computation expression
member IsFromComputationExpression : bool
/// Indicates if the reference is in open statement
member IsFromOpenStatement : bool
/// The file name the reference occurs in
member FileName: string
......
......@@ -66,6 +66,7 @@ type internal SimplifyNameDiagnosticAnalyzer() =
let mutable result = ResizeArray()
let symbolUses =
symbolUses
|> Array.filter (fun symbolUse -> not symbolUse.IsFromOpenStatement)
|> Array.Parallel.map (fun symbolUse ->
let lineStr = sourceText.Lines.[Line.toZ symbolUse.RangeAlternate.StartLine].ToString()
// for `System.DateTime.Now` it returns ([|"System"; "DateTime"|], "Now")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册