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

Commit0df786b

Browse files
vasily-kirichenkoKevinRansom
authored andcommitted
Fix arguments completion (#2981)
* add RQA attribute for some DUs* fix argument completion in constructors if there are spaces between class name and parens
1 parent9535c7a commit0df786b

File tree

3 files changed

+59
-49
lines changed

3 files changed

+59
-49
lines changed

‎src/fsharp/vs/ServiceUntypedParse.fs‎

Lines changed: 54 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,25 @@ module internal SourceFileImpl =
4646

4747
typeCompletionPath= string list* string option// plid * residue
4848

49+
[<RequireQualifiedAccess>]
4950
typeInheritanceOrigin=
5051
| Class
5152
| Interface
5253
| Unknown
5354

55+
[<RequireQualifiedAccess>]
5456
typeInheritanceContext=
5557
| Class
5658
| Interface
5759
| Unknown
5860

61+
[<RequireQualifiedAccess>]
5962
typeRecordContext=
6063
| CopyOnUpdateofrange*CompletionPath// range of copy-expr + current field
6164
| Constructorofstring// typename
6265
| NewofCompletionPath
6366

67+
[<RequireQualifiedAccess>]
6468
typeCompletionContext=
6569
// completion context cannot be determined due to errors
6670
| Invalid
@@ -391,6 +395,7 @@ type FSharpParseFileResults(errors : FSharpErrorInfo[], input : Ast.ParsedInput
391395

392396
typeModuleKind={ IsAutoOpen:bool; HasModuleSuffix:bool}
393397

398+
[<RequireQualifiedAccess>]
394399
typeEntityKind=
395400
| Attribute
396401
| Type
@@ -994,7 +999,7 @@ module UntypedParseImpl =
994999

9951000
letGetCompletionContextForInheritSynMember((ComponentInfo(synAttributes,_,_,_,_,_,_,_)),typeDefnKind:SynTypeDefnKind,completionPath)=
9961001

997-
letsuccess k= Some(Inherit(k, completionPath))
1002+
letsuccess k= Some(CompletionContext.Inherit(k, completionPath))
9981003

9991004
// if kind is specified - take it
10001005
// if kind is non-specified
@@ -1003,22 +1008,22 @@ module UntypedParseImpl =
10031008
match typeDefnKindwith
10041009
| TyconClass->
10051010
match synAttributeswith
1006-
| Class| Unknown-> success Class
1011+
| Class| Unknown-> successInheritanceContext.Class
10071012
|_-> Some CompletionContext.Invalid// non-matching attributes
10081013
| TyconInterface->
10091014
match synAttributeswith
1010-
| Interface| Unknown-> success Interface
1015+
| Interface| Unknown-> successInheritanceContext.Interface
10111016
|_-> Some CompletionContext.Invalid// non-matching attributes
10121017
| TyconStruct->
10131018
// display nothing for structs
10141019
Some CompletionContext.Invalid
10151020
| TyconUnspecified->
10161021
match synAttributeswith
1017-
| Class-> success Class
1018-
| Interface-> success Interface
1022+
| Class-> successInheritanceContext.Class
1023+
| Interface-> successInheritanceContext.Interface
10191024
| Unknown->
10201025
// user do not specify kind explicitly or via attributes
1021-
success Unknown
1026+
successInheritanceContext.Unknown
10221027
|_->
10231028
// unable to uniquely detect kind from the attributes - return invalid context
10241029
Some CompletionContext.Invalid
@@ -1074,16 +1079,16 @@ module UntypedParseImpl =
10741079
|(SynExpr.New(_, SynType.App(SynType.LongIdent typeName,_,_,_, mGreaterThan,_,_), arg,_))->
10751080
// new A<_>()
10761081
Some(endOfClosingTokenOrLastIdent mGreaterThan typeName, findSetters arg)
1077-
|(SynExpr.App(ExprAtomicFlag.Atomic,false, SynExpr.Ident id, arg,_))->
1082+
|(SynExpr.App(_,false, SynExpr.Ident id, arg,_))->
10781083
// A()
10791084
Some(id.idRange.End, findSetters arg)
1080-
|(SynExpr.App(ExprAtomicFlag.Atomic,false, SynExpr.TypeApp(SynExpr.Ident id,_,_,_, mGreaterThan,_,_), arg,_))->
1085+
|(SynExpr.App(_,false, SynExpr.TypeApp(SynExpr.Ident id,_,_,_, mGreaterThan,_,_), arg,_))->
10811086
// A<_>()
10821087
Some(endOfClosingTokenOrIdent mGreaterThan id, findSetters arg)
1083-
|(SynExpr.App(ExprAtomicFlag.Atomic,false, SynExpr.LongIdent(_, lid,_,_), arg,_))->
1088+
|(SynExpr.App(_,false, SynExpr.LongIdent(_, lid,_,_), arg,_))->
10841089
// A.B()
10851090
Some(endOfLastIdent lid, findSetters arg)
1086-
|(SynExpr.App(ExprAtomicFlag.Atomic,false, SynExpr.TypeApp(SynExpr.LongIdent(_, lid,_,_),_,_,_, mGreaterThan,_,_), arg,_))->
1091+
|(SynExpr.App(_,false, SynExpr.TypeApp(SynExpr.LongIdent(_, lid,_,_),_,_,_, mGreaterThan,_,_), arg,_))->
10871092
// A.B<_>()
10881093
Some(endOfClosingTokenOrLastIdent mGreaterThan lid, findSetters arg)
10891094
|_-> None
@@ -1120,40 +1125,41 @@ module UntypedParseImpl =
11201125
letwalker=
11211126
{
11221127
new AstTraversal.AstVisitorBase<_>()with
1123-
memberthis.VisitExpr(path,traverseSynExpr,defaultTraverse,expr)=
1128+
member__.VisitExpr(path,_,defaultTraverse,expr)=
1129+
11241130
if isInRhsOfRangeOp paththen
11251131
match defaultTraverse exprwith
1126-
| None-> Some(CompletionContext.RangeOperator)// nothing was found - report that we were in the context of range operator
1132+
| None-> Some CompletionContext.RangeOperator// nothing was found - report that we were in the context of range operator
11271133
| x-> x// ok, we found something - return it
11281134
else
1129-
match exprwith
1130-
// new A($)
1131-
| SynExpr.Const(SynConst.Unit, m)when rangeContainsPos m pos->
1132-
match pathwith
1133-
| TS.Expr(NewObjectOrMethodCall args)::_->
1134-
Some(CompletionContext.ParameterList args)
1135-
|_->
1136-
defaultTraverse expr
1137-
// new (... A$)
1138-
| SynExpr.Ident idwhen id.idRange.End= pos->
1139-
match pathwith
1140-
| PartOfParameterList None args->
1141-
Some(CompletionContext.ParameterList args)
1142-
|_->
1143-
defaultTraverse expr
1144-
// new (A$ = 1)
1145-
// new (A = 1,$)
1146-
| Setter idwhen id.idRange.End= pos|| rangeBeforePos expr.Range pos->
1147-
letprecedingArgument=if id.idRange.End= posthen Noneelse Some expr
1148-
match pathwith
1149-
| PartOfParameterList precedingArgument args->
1150-
Some(CompletionContext.ParameterList args)
1151-
|_->
1152-
defaultTraverse expr
1153-
1154-
|_-> defaultTraverse expr
1155-
1156-
memberthis.VisitRecordField(path,copyOpt,field)=
1135+
match exprwith
1136+
// new A($)
1137+
| SynExpr.Const(SynConst.Unit, m)when rangeContainsPos m pos->
1138+
match pathwith
1139+
| TS.Expr(NewObjectOrMethodCall args)::_->
1140+
Some(CompletionContext.ParameterList args)
1141+
|_->
1142+
defaultTraverse expr
1143+
// new (... A$)
1144+
| SynExpr.Ident idwhen id.idRange.End= pos->
1145+
match pathwith
1146+
| PartOfParameterList None args->
1147+
Some(CompletionContext.ParameterList args)
1148+
|_->
1149+
defaultTraverse expr
1150+
// new (A$ = 1)
1151+
// new (A = 1,$)
1152+
| Setter idwhen id.idRange.End= pos|| rangeBeforePos expr.Range pos->
1153+
letprecedingArgument=if id.idRange.End= posthen Noneelse Some expr
1154+
match pathwith
1155+
| PartOfParameterList precedingArgument args->
1156+
Some(CompletionContext.ParameterList args)
1157+
|_->
1158+
defaultTraverse expr
1159+
1160+
|_-> defaultTraverse expr
1161+
1162+
member__.VisitRecordField(path,copyOpt,field)=
11571163
letcontextFromTreePath completionPath=
11581164
// detect records usage in constructor
11591165
match pathwith
@@ -1177,15 +1183,15 @@ module UntypedParseImpl =
11771183
| None-> contextFromTreePath([], None)
11781184
Some(CompletionContext.RecordField recordContext)
11791185

1180-
memberthis.VisitInheritSynMemberDefn(componentInfo,typeDefnKind,synType,_members,_range)=
1186+
member__.VisitInheritSynMemberDefn(componentInfo,typeDefnKind,synType,_members,_range)=
11811187
match synTypewith
11821188
| SynType.LongIdent lidwd->
11831189
match parseLid lidwdwith
11841190
| Some(completionPath)-> GetCompletionContextForInheritSynMember(componentInfo, typeDefnKind, completionPath)
11851191
| None-> Some(CompletionContext.Invalid)// A $ .B -> no completion list
11861192
|_-> None
11871193

1188-
memberthis.VisitBinding(defaultTraverse,(Binding(headPat= headPat)as synBinding))=
1194+
member__.VisitBinding(defaultTraverse,(Binding(headPat= headPat)as synBinding))=
11891195

11901196
letvisitParam=function
11911197
| SynPat.Named(range= range)when rangeContainsPos range pos->
@@ -1215,11 +1221,11 @@ module UntypedParseImpl =
12151221
|_-> defaultTraverse synBinding
12161222
|_-> defaultTraverse synBinding
12171223

1218-
memberthis.VisitHashDirective(range)=
1224+
member__.VisitHashDirective(range)=
12191225
if rangeContainsPos range posthen Some CompletionContext.Invalid
12201226
else None
12211227

1222-
memberthis.VisitModuleOrNamespace(SynModuleOrNamespace(longId= idents))=
1228+
member__.VisitModuleOrNamespace(SynModuleOrNamespace(longId= idents))=
12231229
match List.tryLast identswith
12241230
| Some lastIdentwhen pos.Line= lastIdent.idRange.EndLine->
12251231
letstringBetweenModuleNameAndPos= lineStr.[lastIdent.idRange.EndColumn..pos.Column-1]
@@ -1228,24 +1234,24 @@ module UntypedParseImpl =
12281234
else None
12291235
|_-> None
12301236

1231-
memberthis.VisitComponentInfo(ComponentInfo(range= range))=
1237+
member__.VisitComponentInfo(ComponentInfo(range= range))=
12321238
if rangeContainsPos range posthen Some CompletionContext.Invalid
12331239
else None
12341240

1235-
memberthis.VisitLetOrUse(bindings,range)=
1241+
member__.VisitLetOrUse(bindings,range)=
12361242
match bindingswith
12371243
|[]when range.StartLine= pos.Line-> Some CompletionContext.Invalid
12381244
|_-> None
12391245

1240-
memberthis.VisitSimplePats(pats)=
1246+
member__.VisitSimplePats(pats)=
12411247
pats|> List.tryPick(fun pat->
12421248
match patwith
12431249
| SynSimplePat.Id(range= range)
12441250
| SynSimplePat.Typed(SynSimplePat.Id(range= range),_,_)when rangeContainsPos range pos->
12451251
Some CompletionContext.Invalid
12461252
|_-> None)
12471253

1248-
memberthis.VisitModuleDecl(defaultTraverse,decl)=
1254+
member__.VisitModuleDecl(defaultTraverse,decl)=
12491255
match declwith
12501256
| SynModuleDecl.Open(_, m)->
12511257
// in theory, this means we're "in an open"

‎src/fsharp/vs/ServiceUntypedParse.fsi‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,19 @@ module internal SourceFile =
5454

5555
typeinternalCompletionPath= string list* string option// plid * residue
5656

57+
[<RequireQualifiedAccess>]
5758
typeinternalInheritanceContext=
5859
| Class
5960
| Interface
6061
| Unknown
6162

63+
[<RequireQualifiedAccess>]
6264
typeinternalRecordContext=
6365
| CopyOnUpdateofrange*CompletionPath// range
6466
| Constructorofstring// typename
6567
| NewofCompletionPath
6668

69+
[<RequireQualifiedAccess>]
6770
typeinternalCompletionContext=
6871
// completion context cannot be determined due to errors
6972
| Invalid
@@ -80,6 +83,7 @@ type internal CompletionContext =
8083

8184
typeinternalModuleKind={ IsAutoOpen:bool; HasModuleSuffix:bool}
8285

86+
[<RequireQualifiedAccess>]
8387
typeinternalEntityKind=
8488
| Attribute
8589
| Type

‎src/fsharp/vs/service.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ type TypeCheckInfo
806806
GetEnvironmentLookupResolutionsAtPosition(mkPos line loc, plid, filterCtors,false)
807807
|> FilterRelevantItemsBy getItem None(getItem>> GetBaseClassCandidates)
808808
|> Option.map toCompletionItems
809-
809+
810810
// Completion at 'interface ..."
811811
| Some(CompletionContext.Inherit(InheritanceContext.Interface,(plid,_)))->
812812
GetEnvironmentLookupResolutionsAtPosition(mkPos line loc, plid, filterCtors,false)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp