Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
fsharp
提交
1126e23d
F
fsharp
项目概览
dotNET Platform
/
fsharp
12 个月 前同步成功
通知
0
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
fsharp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
1126e23d
编写于
5月 07, 2022
作者:
F
Florian Verdonck
提交者:
GitHub
5月 07, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Replace LongIdentWithDots with SynLongIdent. (#13103)
上级
01e5bbb5
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
52 addition
and
53 deletion
+52
-53
src/fsharp/CheckComputationExpressions.fs
src/fsharp/CheckComputationExpressions.fs
+1
-1
src/fsharp/CheckDeclarations.fs
src/fsharp/CheckDeclarations.fs
+5
-5
src/fsharp/CheckExpressions.fs
src/fsharp/CheckExpressions.fs
+17
-17
src/fsharp/SyntaxTreeOps.fs
src/fsharp/SyntaxTreeOps.fs
+3
-3
src/fsharp/service/ServiceInterfaceStubGenerator.fs
src/fsharp/service/ServiceInterfaceStubGenerator.fs
+2
-2
src/fsharp/service/ServiceNavigation.fs
src/fsharp/service/ServiceNavigation.fs
+4
-4
src/fsharp/service/ServiceParamInfoLocations.fs
src/fsharp/service/ServiceParamInfoLocations.fs
+7
-8
src/fsharp/service/ServiceParsedInputOps.fs
src/fsharp/service/ServiceParsedInputOps.fs
+12
-12
src/fsharp/symbols/Symbols.fs
src/fsharp/symbols/Symbols.fs
+1
-1
未找到文件。
src/fsharp/CheckComputationExpressions.fs
浏览文件 @
1126e23d
...
...
@@ -1232,7 +1232,7 @@ let TcComputationExpression (cenv: cenv) env (overallTy: OverallTy) tpenv (mWhol
// 'use! pat = e1 in e2' --> build.Bind(e1, (function _argN -> match _argN with pat -> build.Using(x, (fun _argN -> match _argN with pat -> e2))))
|
SynExpr
.
LetOrUseBang
(
bindDebugPoint
=
spBind
;
isUse
=
true
;
isFromSource
=
isFromSource
;
pat
=
SynPat
.
Named
(
ident
=
SynIdent
(
id
,_);
isThisVal
=
false
)
as
pat
;
rhs
=
rhsExpr
;
andBangs
=[];
body
=
innerComp
)
|
SynExpr
.
LetOrUseBang
(
bindDebugPoint
=
spBind
;
isUse
=
true
;
isFromSource
=
isFromSource
;
pat
=
SynPat
.
LongIdent
(
longDotId
=
LongIdentWithDots
([
id
]
,
_))
as
pat
;
rhs
=
rhsExpr
;
andBangs
=[];
body
=
innerComp
)
->
|
SynExpr
.
LetOrUseBang
(
bindDebugPoint
=
spBind
;
isUse
=
true
;
isFromSource
=
isFromSource
;
pat
=
SynPat
.
LongIdent
(
longDotId
=
SynLongIdent
([
id
],
_
,
_))
as
pat
;
rhs
=
rhsExpr
;
andBangs
=[];
body
=
innerComp
)
->
let
mBind
=
match
spBind
with
DebugPointAtBinding
.
Yes
m
->
m
|
_
->
rhsExpr
.
Range
if
isQuery
then
error
(
Error
(
FSComp
.
SR
.
tcBindMayNotBeUsedInQueries
()
,
mBind
))
...
...
src/fsharp/CheckDeclarations.fs
浏览文件 @
1126e23d
...
...
@@ -3182,7 +3182,7 @@ module EstablishTypeDefinitionCores =
let
private
(|
TyconCoreAbbrevThatIsReallyAUnion
|_|)
(
hasMeasureAttr
,
envinner
:
TcEnv
,
id
:
Ident
)
synTyconRepr
=
match
synTyconRepr
with
|
SynTypeDefnSimpleRepr
.
TypeAbbrev
(_,
StripParenTypes
(
SynType
.
LongIdent
(
LongIdentWithDots
([
unionCaseName
]
,
_))),
m
)
|
SynTypeDefnSimpleRepr
.
TypeAbbrev
(_,
StripParenTypes
(
SynType
.
LongIdent
(
SynLongIdent
([
unionCaseName
],
_
,
_))),
m
)
when
(
not
hasMeasureAttr
&&
(
isNil
(
LookupTypeNameInEnvNoArity
OpenQualified
unionCaseName
.
idText
envinner
.
NameEnv
)
||
...
...
@@ -3531,9 +3531,9 @@ module EstablishTypeDefinitionCores =
/// Get the items on the r.h.s. of a 'type X = ABC<...>' definition
let
private
TcTyconDefnCore_GetGenerateDeclaration_Rhs
(
StripParenTypes
rhsType
)
=
match
rhsType
with
|
SynType
.
App
(
StripParenTypes
(
SynType
.
LongIdent
(
LongIdentWithDots
(
tc
,
_))),
_,
args
,
_
commas
,
_,
_
postfix
,
m
)
->
Some
(
tc
,
args
,
m
)
|
SynType
.
LongIdent
(
LongIdentWithDots
(
tc
,
_)
as
lidwd
)
->
Some
(
tc
,
[]
,
lidwd
.
Range
)
|
SynType
.
LongIdentApp
(
StripParenTypes
(
SynType
.
LongIdent
(
LongIdentWithDots
(
tc
,
_))),
LongIdentWithDots
(
longId
,
_),
_,
args
,
_
commas
,
_,
m
)
->
Some
(
tc
@
longId
,
args
,
m
)
|
SynType
.
App
(
StripParenTypes
(
SynType
.
LongIdent
(
SynLongIdent
(
tc
,
_
,
_))),
_,
args
,
_
commas
,
_,
_
postfix
,
m
)
->
Some
(
tc
,
args
,
m
)
|
SynType
.
LongIdent
(
SynLongIdent
(
tc
,
_
,
_)
as
lidwd
)
->
Some
(
tc
,
[]
,
lidwd
.
Range
)
|
SynType
.
LongIdentApp
(
StripParenTypes
(
SynType
.
LongIdent
(
SynLongIdent
(
tc
,
_,
_))),
SynLongIdent
(
longId
,
_
,
_),
_,
args
,
_
commas
,
_,
m
)
->
Some
(
tc
@
longId
,
args
,
m
)
|
_
->
None
/// Check whether 'type X = ABC<...>' is a generative provided type definition
...
...
@@ -5071,7 +5071,7 @@ module TcDeclarations =
memberFlags
.
MemberKind
=
SynMemberKind
.
Constructor
&&
// REVIEW: This is a syntactic approximation
(
match
valSpfn
.
SynType
,
valSpfn
.
SynInfo
.
CurriedArgInfos
with
|
StripParenTypes
(
SynType
.
Fun
(
StripParenTypes
(
SynType
.
LongIdent
(
LongIdentWithDots
([
id
]
,
_))),
_,
_)),
[[_]]
when
id
.
idText
=
"unit"
->
true
|
StripParenTypes
(
SynType
.
Fun
(
StripParenTypes
(
SynType
.
LongIdent
(
SynLongIdent
([
id
],
_
,
_))),
_,
_)),
[[_]]
when
id
.
idText
=
"unit"
->
true
|
_
->
false
)
|
_
->
false
)
...
...
src/fsharp/CheckExpressions.fs
浏览文件 @
1126e23d
...
...
@@ -2474,7 +2474,7 @@ module BindingNormalization =
// of available items, to the point that you can't even define a function with the same name as an existing union case.
match pat with
| SynPat.FromParseError(p, _) -> normPattern p
| SynPat.LongIdent (
LongIdentWithDots(longId
, _), _, toolId, tyargs, SynArgPats.Pats args, vis, m) ->
| SynPat.LongIdent (
SynLongIdent(longId, _
, _), _, toolId, tyargs, SynArgPats.Pats args, vis, m) ->
let typars = match tyargs with None -> inferredTyparDecls | Some typars -> typars
match memberFlagsOpt with
| None ->
...
...
@@ -3152,12 +3152,12 @@ let (|SimpleEqualsExpr|_|) expr =
/// Detect a named argument at a callsite
let TryGetNamedArg expr =
match expr with
| SimpleEqualsExpr(LongOrSingleIdent(isOpt,
LongIdentWithDots([a]
, _), None, _), b) -> Some(isOpt, a, b)
| SimpleEqualsExpr(LongOrSingleIdent(isOpt,
SynLongIdent([a], _
, _), None, _), b) -> Some(isOpt, a, b)
| _ -> None
let inline IsNamedArg expr =
match expr with
| SimpleEqualsExpr(LongOrSingleIdent(_,
LongIdentWithDots([_]
, _), None, _), _) -> true
| SimpleEqualsExpr(LongOrSingleIdent(_,
SynLongIdent([_], _
, _), None, _), _) -> true
| _ -> false
/// Get the method arguments at a callsite, taking into account named and optional arguments
...
...
@@ -4316,11 +4316,11 @@ and TcTypeOrMeasure optKind cenv newOk checkCxs occ env (tpenv: UnscopedTyparEnv
let g = cenv.g
match ty with
| SynType.LongIdent(
LongIdentWithDots([]
, _)) ->
| SynType.LongIdent(
SynLongIdent([], _
, _)) ->
// special case when type name is absent - i.e. empty inherit part in type declaration
g.obj_ty, tpenv
| SynType.LongIdent(
LongIdentWithDots(tc
, _) as lidwd) ->
| SynType.LongIdent(
SynLongIdent(tc, _
, _) as lidwd) ->
let m = lidwd.Range
let ad = env.eAccessRights
let tinstEnclosing, tcref = ForceRaise(ResolveTypeLongIdent cenv.tcSink cenv.nameResolver occ OpenQualified env.NameEnv ad tc TypeNameResolutionStaticArgsInfo.DefiniteEmpty PermitDirectReferenceToGeneratedType.No)
...
...
@@ -4336,7 +4336,7 @@ and TcTypeOrMeasure optKind cenv newOk checkCxs occ env (tpenv: UnscopedTyparEnv
| _, TyparKind.Type ->
TcTypeApp cenv newOk checkCxs occ env tpenv m tcref tinstEnclosing []
| SynType.App (StripParenTypes (SynType.LongIdent(
LongIdentWithDots(tc
, _))), _, args, _commas, _, postfix, m) ->
| SynType.App (StripParenTypes (SynType.LongIdent(
SynLongIdent(tc, _
, _))), _, args, _commas, _, postfix, m) ->
let ad = env.eAccessRights
let tinstEnclosing, tcref =
...
...
@@ -4367,7 +4367,7 @@ and TcTypeOrMeasure optKind cenv newOk checkCxs occ env (tpenv: UnscopedTyparEnv
errorR(Error(FSComp.SR.tcUnitsOfMeasureInvalidInTypeConstructor(), m))
NewErrorType (), tpenv
| SynType.LongIdentApp (ltyp,
LongIdentWithDots(longId
, _), _, args, _commas, _, m) ->
| SynType.LongIdentApp (ltyp,
SynLongIdent(longId, _
, _), _, args, _commas, _, m) ->
let ad = env.eAccessRights
let ltyp, tpenv = TcType cenv newOk checkCxs occ env tpenv ltyp
match ltyp with
...
...
@@ -4631,7 +4631,7 @@ and TcStaticConstantParameter cenv (env: TcEnv) tpenv kind (StripParenTypes v) i
and CrackStaticConstantArgs cenv env tpenv (staticParameters: Tainted<ProvidedParameterInfo>[], args: SynType list, container, containerName, m) =
let args =
args |> List.map (function
| StripParenTypes (SynType.StaticConstantNamed(StripParenTypes (SynType.LongIdent(
LongIdentWithDots([id]
, _))), v, _)) -> Some id, v
| StripParenTypes (SynType.StaticConstantNamed(StripParenTypes (SynType.LongIdent(
SynLongIdent([id], _
, _))), v, _)) -> Some id, v
| v -> None, v)
let unnamedArgs = args |> Seq.takeWhile (fst >> Option.isNone) |> Seq.toArray |> Array.map snd
...
...
@@ -5197,7 +5197,7 @@ and IsNameOf (cenv: cenv) (env: TcEnv) ad m (id: Ident) =
/// Check a long identifier in a pattern
and TcPatLongIdent warnOnUpper cenv env ad topValInfo vFlags (tpenv, names, takenNames) ty (longDotId, tyargs, args, vis, m) =
let (
LongIdentWithDots(longId
, _)) = longDotId
let (
SynLongIdent(longId, _
, _)) = longDotId
if tyargs.IsSome then errorR(Error(FSComp.SR.tcInvalidTypeArgumentUsage(), m))
...
...
@@ -5688,7 +5688,7 @@ and TcExprThen cenv (overallTy: OverallTy) env tpenv isArg synExpr delayed =
// e1.id1
// e1.id1.id2
// etc.
| SynExpr.DotGet (e1, _,
LongIdentWithDots(longId
, _), _) ->
| SynExpr.DotGet (e1, _,
SynLongIdent(longId, _
, _), _) ->
TcNonControlFlowExpr env <| fun env ->
TcExprThen cenv overallTy env tpenv false e1 ((DelayedDotLookup (longId, synExpr.RangeWithoutAnyExtraDot)) :: delayed)
...
...
@@ -6407,7 +6407,7 @@ and TcExprStaticOptimization cenv overallTy env tpenv (constraints, e2, e3, m) =
/// e1.longId <- e2
and TcExprDotSet cenv overallTy env tpenv (e1, lidwd, e2, mStmt) =
let (
LongIdentWithDots(longId
, _)) = lidwd
let (
SynLongIdent(longId, _
, _)) = lidwd
if lidwd.ThereIsAnExtraDotAtTheEnd then
// just drop rhs on the floor
...
...
@@ -6419,7 +6419,7 @@ and TcExprDotSet cenv overallTy env tpenv (e1, lidwd, e2, mStmt) =
/// e1.longId(e2) <- e3, very rarely used named property setters
and TcExprDotNamedIndexedPropertySet cenv overallTy env tpenv (e1, lidwd, e2, e3, mStmt) =
let (
LongIdentWithDots(longId
, _)) = lidwd
let (
SynLongIdent(longId, _
, _)) = lidwd
if lidwd.ThereIsAnExtraDotAtTheEnd then
// just drop rhs on the floor
let mExprAndDotLookup = unionRanges e1.Range (rangeOfLid longId)
...
...
@@ -8253,7 +8253,7 @@ and TcNameOfExpr cenv env tpenv (synArg: SynExpr) =
let m = cleanSynArg.Range
let rec check overallTyOpt resultOpt expr (delayed: DelayedItem list) =
match expr with
| LongOrSingleIdent (false,
LongIdentWithDots(longId
, _), _, _) ->
| LongOrSingleIdent (false,
SynLongIdent(longId, _
, _), _, _) ->
let ad = env.eAccessRights
let result = defaultArg resultOpt (List.last longId)
...
...
@@ -8333,7 +8333,7 @@ and TcNameOfExpr cenv env tpenv (synArg: SynExpr) =
check overallTyOpt resultOpt hd (DelayedTypeApp(types, m, m) :: delayed)
// expr.ID allowed
| SynExpr.DotGet (hd, _,
LongIdentWithDots(longId
, _), _) ->
| SynExpr.DotGet (hd, _,
SynLongIdent(longId, _
, _), _) ->
let result = defaultArg resultOpt (List.last longId)
check overallTyOpt (Some result) hd ((DelayedDotLookup (longId, expr.RangeWithoutAnyExtraDot)) :: delayed)
...
...
@@ -8489,7 +8489,7 @@ and GetLongIdentTypeNameInfo delayed =
| _ ->
TypeNameResolutionInfo.Default
and TcLongIdentThen cenv (overallTy: OverallTy) env tpenv (
LongIdentWithDots(longId
, _)) delayed =
and TcLongIdentThen cenv (overallTy: OverallTy) env tpenv (
SynLongIdent(longId, _
, _)) delayed =
let ad = env.eAccessRights
let typeNameResInfo = GetLongIdentTypeNameInfo delayed
...
...
@@ -10114,7 +10114,7 @@ and CheckRecursiveBindingIds binds =
match b with
| SynPat.Named(SynIdent(id,_), _, _, _)
| SynPat.As(_, SynPat.Named(SynIdent(id,_), _, _, _), _)
| SynPat.LongIdent(longDotId=
LongIdentWithDots([id]
, _)) -> id.idText
| SynPat.LongIdent(longDotId=
SynLongIdent([id], _
, _)) -> id.idText
| _ -> ""
if nm <> "" && not (hashOfBinds.Add nm) then
error(Duplicate("value", nm, m))
...
...
@@ -10641,7 +10641,7 @@ and TcAttributeEx canFail cenv (env: TcEnv) attrTgt attrEx (synAttr: SynAttribut
let g = cenv.g
let (
LongIdentWithDots(tycon
, _)) = synAttr.TypeName
let (
SynLongIdent(tycon, _
, _)) = synAttr.TypeName
let arg = synAttr.ArgExpr
let targetIndicator = synAttr.Target
let isAppliedToGetterOrSetter = synAttr.AppliesToGetterAndSetter
...
...
src/fsharp/SyntaxTreeOps.fs
浏览文件 @
1126e23d
...
...
@@ -67,7 +67,7 @@ let (|LongOrSingleIdent|_|) inp =
let
(|
SingleIdent
|_|)
inp
=
match
inp
with
|
SynExpr
.
LongIdent
(
false
,
LongIdentWithDots
([
id
]
,
_),
None
,
_)
->
Some
id
|
SynExpr
.
LongIdent
(
false
,
SynLongIdent
([
id
],
_
,
_),
None
,
_)
->
Some
id
|
SynExpr
.
Ident
id
->
Some
id
|
_
->
None
...
...
@@ -171,7 +171,7 @@ let mkSynPatMaybeVar lidwd vis m = SynPat.LongIdent (lidwd, None, None, None, S
/// Extract the argument for patterns corresponding to the declaration of 'new ... = ...'
let
(|
SynPatForConstructorDecl
|_|)
x
=
match
x
with
|
SynPat
.
LongIdent
(
longDotId
=
LongIdentWithDots
([_]
,
_);
argPats
=
SynArgPats
.
Pats
[
arg
])
->
Some
arg
|
SynPat
.
LongIdent
(
longDotId
=
SynLongIdent
([_],
_
,
_);
argPats
=
SynArgPats
.
Pats
[
arg
])
->
Some
arg
|
_
->
None
/// Recognize the '()' in 'new()'
...
...
@@ -225,7 +225,7 @@ let rec SimplePatOfPat (synArgNameGenerator: SynArgNameGenerator) p =
let
m
=
p
.
Range
let
isCompGen
,
altNameRefCell
,
id
,
item
=
match
p
with
|
SynPat
.
LongIdent
(
longDotId
=
LongIdentWithDots
([
id
]
,
_);
typarDecls
=
None
;
argPats
=
SynArgPats
.
Pats
[]
;
accessibility
=
None
)
->
|
SynPat
.
LongIdent
(
longDotId
=
SynLongIdent
([
id
],
_
,
_);
typarDecls
=
None
;
argPats
=
SynArgPats
.
Pats
[]
;
accessibility
=
None
)
->
// The pattern is 'V' or some other capitalized identifier.
// It may be a real variable, in which case we want to maintain its name.
// But it may also be a nullary union case or some other identifier.
...
...
src/fsharp/service/ServiceInterfaceStubGenerator.fs
浏览文件 @
1126e23d
...
...
@@ -125,7 +125,7 @@ type InterfaceData =
Some
(
"'"
+
s
.
idText
)
|
TyparStaticReq
.
HeadType
->
Some
(
"^"
+
s
.
idText
)
|
SynType
.
LongIdent
(
LongIdentWithDots
(
xs
,
_))
->
|
SynType
.
LongIdent
(
SynLongIdent
(
xs
,
_
,
_))
->
xs
|>
Seq
.
map
(
fun
x
->
x
.
idText
)
|>
String
.
concat
"."
|>
Some
|
SynType
.
App
(
t
,
_,
ts
,
_,
_,
isPostfix
,
_)
->
match
t
,
ts
with
...
...
@@ -503,7 +503,7 @@ module InterfaceStubGenerator =
GetInterfaceMembers
entity
|>
Seq
.
isEmpty
let
internal
(|
LongIdentPattern
|_|)
=
function
|
SynPat
.
LongIdent
(
longDotId
=
LongIdentWithDots
(
xs
,
_))
->
|
SynPat
.
LongIdent
(
longDotId
=
SynLongIdent
(
xs
,
_
,
_))
->
// let (name, range) = xs |> List.map (fun x -> x.idText, x.idRange) |> List.last
let
last
=
List
.
last
xs
Some
(
last
.
idText
,
last
.
idRange
)
...
...
src/fsharp/service/ServiceNavigation.fs
浏览文件 @
1126e23d
...
...
@@ -142,7 +142,7 @@ module NavigationImpl =
|
_
->
synExpr
.
Range
match
synPat
,
memberOpt
with
|
SynPat
.
LongIdent
(
longDotId
=
LongIdentWithDots
(
lid
,_);
accessibility
=
access
),
Some
(
flags
)
when
isMember
->
|
SynPat
.
LongIdent
(
longDotId
=
SynLongIdent
(
lid
,_
,_);
accessibility
=
access
),
Some
(
flags
)
when
isMember
->
let
icon
,
kind
=
match
flags
.
MemberKind
with
|
SynMemberKind
.
ClassConstructor
...
...
@@ -158,7 +158,7 @@ module NavigationImpl =
|
hd
::
_
->
(
lid
,
hd
.
idRange
)
|
_
->
(
lid
,
m
)
[
createMemberLid
(
lidShow
,
kind
,
icon
,
unionRanges
rangeMerge
m
,
enclosingEntityKind
,
isAbstract
,
access
)
]
|
SynPat
.
LongIdent
(
longDotId
=
LongIdentWithDots
(
lid
,_);
accessibility
=
access
),
_
->
|
SynPat
.
LongIdent
(
longDotId
=
SynLongIdent
(
lid
,_
,_);
accessibility
=
access
),
_
->
[
createMemberLid
(
lid
,
NavigationItemKind
.
Field
,
FSharpGlyph
.
Field
,
unionRanges
(
List
.
head
lid
).
idRange
m
,
enclosingEntityKind
,
isAbstract
,
access
)
]
|
SynPat
.
Named
(
SynIdent
(
id
,_),
_,
access
,
_),
_
|
SynPat
.
As
(_,
SynPat
.
Named
(
SynIdent
(
id
,_),
_,
access
,
_),
_),
_
->
let
glyph
=
if
isMember
then
FSharpGlyph
.
Method
else
FSharpGlyph
.
Field
...
...
@@ -574,10 +574,10 @@ module NavigateTo =
|
_
->
NavigableItemKind
.
ModuleValue
match
headPat
with
|
SynPat
.
LongIdent
(
longDotId
=
LongIdentWithDots
([_;
id
],
_))
->
|
SynPat
.
LongIdent
(
longDotId
=
SynLongIdent
([_;
id
],
_,
_))
->
// instance members
addIdent
kind
id
false
container
|
SynPat
.
LongIdent
(
longDotId
=
LongIdentWithDots
([
id
],
_))
->
|
SynPat
.
LongIdent
(
longDotId
=
SynLongIdent
([
id
],
_,
_))
->
// functions
addIdent
kind
id
false
container
|
SynPat
.
Named
(
SynIdent
(
id
,_),
_,
_,
_)
|
SynPat
.
As
(_,
SynPat
.
Named
(
SynIdent
(
id
,_),
_,
_,
_),
_)
->
...
...
src/fsharp/service/ServiceParamInfoLocations.fs
浏览文件 @
1126e23d
...
...
@@ -6,7 +6,6 @@ open FSharp.Compiler.Text
open
FSharp
.
Compiler
.
Text
.
Position
open
FSharp
.
Compiler
.
Text
.
Range
open
FSharp
.
Compiler
.
Syntax
open
FSharp
.
Compiler
.
SyntaxTrivia
open
FSharp
.
Compiler
.
SyntaxTreeOps
type
TupledArgumentLocation
=
{
IsNamedArgument
:
bool
;
ArgumentRange
:
range
}
...
...
@@ -61,8 +60,8 @@ module internal ParameterLocationsImpl =
match
synExpr
with
|
SynExpr
.
Ident
id
->
Some
([
id
.
idText
],
id
.
idRange
)
|
SynExpr
.
LongIdent
(_,
SynLongIdent
([
id
],
[]
,
[
Some
_
]),
_,
_)
->
Some
([
id
.
idText
],
id
.
idRange
)
|
SynExpr
.
LongIdent
(_,
LongIdentWithDots
(
lid
,
_),
_,
lidRange
)
|
SynExpr
.
DotGet
(_,
_,
LongIdentWithDots
(
lid
,
_),
lidRange
)
->
Some
(
pathOfLid
lid
,
lidRange
)
|
SynExpr
.
LongIdent
(_,
SynLongIdent
(
lid
,
_
,
_),
_,
lidRange
)
|
SynExpr
.
DotGet
(_,
_,
SynLongIdent
(
lid
,
_
,
_),
lidRange
)
->
Some
(
pathOfLid
lid
,
lidRange
)
|
SynExpr
.
TypeApp
(
synExpr
,
_,
_
synTypeList
,
_
commas
,
_,
_,
_
range
)
->
digOutIdentFromFuncExpr
synExpr
|
SynExpr
.
Paren
(
expr
=
expr
)
->
digOutIdentFromFuncExpr
expr
|
_
->
None
...
...
@@ -73,8 +72,8 @@ module internal ParameterLocationsImpl =
let
digOutIdentFromStaticArg
(
StripParenTypes
synType
)
=
match
synType
with
|
SynType
.
StaticConstantNamed
(
SynType
.
LongIdent
(
LongIdentWithDots
([
id
]
,
_)),
_,
_)
->
Some
id
.
idText
|
SynType
.
LongIdent
(
LongIdentWithDots
([
id
]
,
_))
->
Some
id
.
idText
// NOTE: again, not a static constant, but may be a prefix of a Named in incomplete code
|
SynType
.
StaticConstantNamed
(
SynType
.
LongIdent
(
SynLongIdent
([
id
],
_
,
_)),
_,
_)
->
Some
id
.
idText
|
SynType
.
LongIdent
(
SynLongIdent
([
id
],
_
,
_))
->
Some
id
.
idText
// NOTE: again, not a static constant, but may be a prefix of a Named in incomplete code
|
_
->
None
let
getNamedParamName
e
=
...
...
@@ -90,13 +89,13 @@ module internal ParameterLocationsImpl =
|
SynExpr
.
App
(
ExprAtomicFlag
.
NonAtomic
,
_,
SynExpr
.
App
(
ExprAtomicFlag
.
NonAtomic
,
true
,
SynExpr
.
LongIdent
(
longDotId
=
SynLongIdent
(
id
=
[
op
])),
SynExpr
.
LongIdent
(
true
(*isOptional*)
,
LongIdentWithDots
([
n
]
,
_),
_
ref
,
_
lidrange
),
_
range
),
SynExpr
.
LongIdent
(
true
(*isOptional*)
,
SynLongIdent
([
n
],
_
,
_),
_
ref
,
_
lidrange
),
_
range
),
_,
_)
when
op
.
idText
=
"op_Equality"
->
Some
n
.
idText
|
_
->
None
let
getTypeName
synType
=
match
synType
with
|
SynType
.
LongIdent
(
LongIdentWithDots
(
ids
,
_))
->
ids
|>
pathOfLid
|
SynType
.
LongIdent
(
SynLongIdent
(
ids
,
_
,
_))
->
ids
|>
pathOfLid
|
_
->
[
""
]
// TODO type name for other cases, see also unit test named "ParameterInfo.LocationOfParams.AfterQuicklyTyping.CallConstructorViaLongId.Bug94333"
let
handleSingleArg
traverseSynExpr
(
pos
,
synExpr
,
parenRange
,
rpRangeOpt
:
_
option
)
=
...
...
@@ -171,7 +170,7 @@ module internal ParameterLocationsImpl =
let
(|
StaticParameters
|_|)
pos
(
StripParenTypes
synType
)
=
match
synType
with
|
SynType
.
App
(
StripParenTypes
(
SynType
.
LongIdent
(
LongIdentWithDots
(
lid
,
_)
as
lidwd
)),
Some
(
openm
),
args
,
commas
,
closemOpt
,
_
pf
,
wholem
)
->
|
SynType
.
App
(
StripParenTypes
(
SynType
.
LongIdent
(
SynLongIdent
(
lid
,
_
,
_)
as
lidwd
)),
Some
(
openm
),
args
,
commas
,
closemOpt
,
_
pf
,
wholem
)
->
let
lidm
=
lidwd
.
Range
let
betweenTheBrackets
=
mkRange
wholem
.
FileName
openm
.
Start
wholem
.
End
if
SyntaxTraversal
.
rangeContainsPosEdgesExclusive
betweenTheBrackets
pos
&&
args
|>
List
.
forall
isStaticArg
then
...
...
src/fsharp/service/ServiceParsedInputOps.fs
浏览文件 @
1126e23d
...
...
@@ -218,16 +218,16 @@ module ParsedInput =
match
expr
with
|
SynExpr
.
LongIdent
(
longDotId
=
SynLongIdent
([
id
],
[]
,
[
Some
_]))
->
defaultTraverse
(
SynExpr
.
Ident
(
id
))
|
SynExpr
.
LongIdent
(_,
LongIdentWithDots
(
longIdent
,
_),
_
altNameRefCell
,
_
range
)
->
|
SynExpr
.
LongIdent
(_,
SynLongIdent
(
longIdent
,
_
,
_),
_
altNameRefCell
,
_
range
)
->
let
_,
r
=
CheckLongIdent
longIdent
Some
r
|
SynExpr
.
LongIdentSet
(
LongIdentWithDots
(
longIdent
,
_),
synExpr
,
_
range
)
->
|
SynExpr
.
LongIdentSet
(
SynLongIdent
(
longIdent
,
_
,
_),
synExpr
,
_
range
)
->
if
SyntaxTraversal
.
rangeContainsPosLeftEdgeInclusive
synExpr
.
Range
pos
then
traverseSynExpr
synExpr
else
let
_,
r
=
CheckLongIdent
longIdent
Some
r
|
SynExpr
.
DotGet
(
synExpr
,
_
dotm
,
LongIdentWithDots
(
longIdent
,
_),
_
range
)
->
|
SynExpr
.
DotGet
(
synExpr
,
_
dotm
,
SynLongIdent
(
longIdent
,
_
,
_),
_
range
)
->
if
SyntaxTraversal
.
rangeContainsPosLeftEdgeInclusive
synExpr
.
Range
pos
then
traverseSynExpr
synExpr
else
...
...
@@ -244,7 +244,7 @@ module ParsedInput =
traverseSynExpr
synExpr2
else
Some
range
|
SynExpr
.
DotSet
(
synExpr
,
LongIdentWithDots
(
longIdent
,
_),
synExpr2
,
_
range
)
->
|
SynExpr
.
DotSet
(
synExpr
,
SynLongIdent
(
longIdent
,
_
,
_),
synExpr2
,
_
range
)
->
if
SyntaxTraversal
.
rangeContainsPosLeftEdgeInclusive
synExpr
.
Range
pos
then
traverseSynExpr
synExpr
elif
SyntaxTraversal
.
rangeContainsPosLeftEdgeInclusive
synExpr2
.
Range
pos
then
...
...
@@ -260,7 +260,7 @@ module ParsedInput =
// ---- synExpr.Range has this value
// ------ we want this value
Some
(
unionRanges
synExpr
.
Range
r
)
|
SynExpr
.
DotNamedIndexedPropertySet
(
synExpr
,
LongIdentWithDots
(
longIdent
,
_),
synExpr2
,
synExpr3
,
_
range
)
->
|
SynExpr
.
DotNamedIndexedPropertySet
(
synExpr
,
SynLongIdent
(
longIdent
,
_
,
_),
synExpr2
,
synExpr3
,
_
range
)
->
if
SyntaxTraversal
.
rangeContainsPosLeftEdgeInclusive
synExpr
.
Range
pos
then
traverseSynExpr
synExpr
elif
SyntaxTraversal
.
rangeContainsPosLeftEdgeInclusive
synExpr2
.
Range
pos
then
...
...
@@ -311,9 +311,9 @@ module ParsedInput =
match
expr
with
|
SynExpr
.
Paren
(
e
,
_,
_,
_)
when
foundCandidate
->
TryGetExpression
foundCandidate
e
|
SynExpr
.
LongIdent
(_
isOptional
,
LongIdentWithDots
(
lid
,
_),
_
altNameRefCell
,
_
m
)
->
|
SynExpr
.
LongIdent
(_
isOptional
,
SynLongIdent
(
lid
,
_
,
_),
_
altNameRefCell
,
_
m
)
->
getLidParts
lid
|>
Some
|
SynExpr
.
DotGet
(
leftPart
,
_,
LongIdentWithDots
(
lid
,
_),
_)
when
(
rangeContainsPos
(
rangeOfLid
lid
)
pos
)
||
foundCandidate
->
|
SynExpr
.
DotGet
(
leftPart
,
_,
SynLongIdent
(
lid
,
_
,
_),
_)
when
(
rangeContainsPos
(
rangeOfLid
lid
)
pos
)
||
foundCandidate
->
// requested position is at the lid part of the DotGet
// process left part and append result to the result of processing lid
let
leftPartResult
=
TryGetExpression
true
leftPart
...
...
@@ -373,7 +373,7 @@ module ParsedInput =
// the cursor location.
None
else
let
rec
traverseLidOrElse
(
optExprIfLeftOfLongId
:
SynExpr
option
)
(
LongIdentWithDots
(
lid
,
dots
)
as
lidwd
)
=
let
rec
traverseLidOrElse
(
optExprIfLeftOfLongId
:
SynExpr
option
)
(
SynLongIdent
(
lid
,
dots
,
_
)
as
lidwd
)
=
let
resultIfLeftOfLongId
=
match
optExprIfLeftOfLongId
with
|
None
->
None
...
...
@@ -560,7 +560,7 @@ module ParsedInput =
match
expr
with
|
SynExpr
.
LongIdent
(_,
SynLongIdent
([
ident
],
_,
[
Some
_]),
_,
_)
->
ifPosInRange
ident
.
idRange
(
fun
_
->
Some
(
EntityKind
.
FunctionOrValue
false
))
|
SynExpr
.
LongIdent
(_,
LongIdentWithDots
(_,
dotRanges
),
_,
r
)
->
|
SynExpr
.
LongIdent
(_,
SynLongIdent
(_,
dotRanges
,
_
),
_,
r
)
->
match
dotRanges
with
|
[]
when
isPosInRange
r
->
parentKind
|>
Option
.
orElseWith
(
fun
()
->
Some
(
EntityKind
.
FunctionOrValue
false
))
|
firstDotRange
::
_
->
...
...
@@ -752,7 +752,7 @@ module ParsedInput =
|
Some
EntityKind
.
Attribute
->
Some
CompletionContext
.
AttributeApplication
|
_
->
let
parseLid
(
LongIdentWithDots
(
lid
,
dots
))
=
let
parseLid
(
SynLongIdent
(
lid
,
dots
,
_
))
=
let
rec
collect
plid
(
parts
:
Ident
list
)
(
dots
:
range
list
)
=
match
parts
,
dots
with
|
[]
,
_
->
Some
(
plid
,
None
)
...
...
@@ -788,7 +788,7 @@ module ParsedInput =
let
(|
Class
|
Interface
|
Struct
|
Unknown
|
Invalid
|)
synAttributes
=
let
(|
SynAttr
|_|)
name
(
attr
:
SynAttribute
)
=
match
attr
with
|
{
TypeName
=
LongIdentWithDots
([
x
]
,
_)}
when
x
.
idText
=
name
->
Some
()
|
{
TypeName
=
SynLongIdent
([
x
],
_
,
_)}
when
x
.
idText
=
name
->
Some
()
|
_
->
None
let
rec
getKind
isClass
isInterface
isStruct
=
...
...
@@ -1255,7 +1255,7 @@ module ParsedInput =
for
ident
in
longIdent
do
identsByEndPos
[
ident
.
idRange
.
End
]
<-
longIdent
let
addLongIdentWithDots
(
LongIdentWithDots
(
longIdent
,
lids
)
as
value
)
=
let
addLongIdentWithDots
(
SynLongIdent
(
longIdent
,
lids
,
_
)
as
value
)
=
match
longIdent
with
|
[]
->
()
|
[_]
as
idents
->
identsByEndPos
[
value
.
Range
.
End
]
<-
idents
...
...
src/fsharp/symbols/Symbols.fs
浏览文件 @
1126e23d
...
...
@@ -2794,7 +2794,7 @@ type FSharpOpenDeclaration(target: SynOpenDeclTarget, range: range option, modul
|
SynOpenDeclTarget
.
Type
(
synType
,
_)
->
let
rec
get
ty
=
match
ty
with
|
SynType
.
LongIdent
(
LongIdentWithDots
(
lid
,
_))
->
lid
|
SynType
.
LongIdent
(
SynLongIdent
(
lid
,
_
,
_))
->
lid
|
SynType
.
App
(
ty2
,
_,
_,
_,
_,
_,
_)
->
get
ty2
|
SynType
.
LongIdentApp
(
ty2
,
_,
_,
_,
_,
_,
_)
->
get
ty2
|
SynType
.
Paren
(
ty2
,
_)
->
get
ty2
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录