@@ -1063,7 +1063,7 @@ type internal TypeCheckInfo
10631063 |> Option.defaultValue completions
10641064
10651065 /// Gets all methods that a type can override, but has not yet done so.
1066- let GetOverridableMethods pos ctx ( typeNameRange : range ) spacesBeforeOverrideKeyword hasThis isStatic =
1066+ let GetOverridableMethods pos ctx ( typeNameRange : range ) newlineIndentCount hasThis isStatic genBodyForOverriddenMeth =
10671067 let checkImplementedSlotDeclareType ty slots =
10681068 slots
10691069 |> Option.map ( List.exists ( fun ( TSlotSig ( declaringType = ty2 )) -> typeEquiv g ty ty2))
@@ -1111,17 +1111,20 @@ type internal TypeCheckInfo
11111111 let ( nenv , ad ), m = GetBestEnvForPos pos
11121112 let denv = nenv.DisplayEnv
11131113
1114+ /// Check if the method is abstract, return "raise (NotImplementedException())" if it is abstract, otherwise return the given body
11141115 let checkMethAbstractAndGetImplementBody ( meth : MethInfo ) implementBody =
1115- if meth.IsAbstract then
1116+ if not genBodyForOverriddenMeth then
1117+ String.Empty
1118+ elif meth.IsAbstract then
11161119 if nenv.DisplayEnv.openTopPathsSorted.Force() |> List.contains [ " System" ] then
11171120 " raise (NotImplementedException())"
11181121 else
11191122 " raise (System.NotImplementedException())"
11201123 else
11211124 implementBody
11221125
1123- let newlineIndent =
1124- Environment.NewLine + String.make ( spacesBeforeOverrideKeyword + 4 ) ' '
1126+ let newlineIndentCount = max 1 newlineIndentCount
1127+ let newlineIndent = Environment.NewLine + String.make newlineIndentCount ' '
11251128
11261129 let getOverridableMethods superTy ( overriddenMethods : MethInfo list ) overriddenProperties =
11271130 // Do not check a method with same name twice
@@ -1197,12 +1200,6 @@ type internal TypeCheckInfo
11971200
11981201 let this = if hasThis || prop.IsStatic then String.Empty else " this."
11991202
1200- let getterWithBody =
1201- if String.IsNullOrWhiteSpace getterWithBody then
1202- String.Empty
1203- else
1204- getterWithBody + newlineIndent
1205-
12061203 let name = $" {prop.DisplayName} with {getter}{keywordAnd}{setter}"
12071204
12081205 let textInCode =
@@ -1211,6 +1208,10 @@ type internal TypeCheckInfo
12111208 + newlineIndent
12121209 + " with "
12131210 + getterWithBody
1211+ + ( if String.IsNullOrEmpty keywordAnd then
1212+ String.Empty
1213+ else
1214+ newlineIndent)
12141215 + keywordAnd
12151216 + setterWithBody
12161217
@@ -1721,7 +1722,8 @@ type internal TypeCheckInfo
17211722 filterCtors ,
17221723 resolveOverloads ,
17231724 completionContextAtPos : ( pos * CompletionContext option ) option ,
1724- getAllSymbols : unit -> AssemblySymbol list
1725+ getAllSymbols : unit -> AssemblySymbol list ,
1726+ genBodyForOverriddenMeth
17251727 ) : ( CompletionItem list * DisplayEnv * CompletionContext option * range ) option =
17261728
17271729 let loc =
@@ -1957,8 +1959,22 @@ type internal TypeCheckInfo
19571959 getDeclaredItemsNotInRangeOpWithAllSymbols ()
19581960 |> Option.bind ( FilterRelevantItemsBy getItem2 None IsPatternCandidate)
19591961
1960- | Some( CompletionContext.MethodOverride( ctx, enclosingTypeNameRange, spacesBeforeOverrideKeyword, hasThis, isStatic)) ->
1961- GetOverridableMethods pos ctx enclosingTypeNameRange spacesBeforeOverrideKeyword hasThis isStatic
1962+ | Some( CompletionContext.MethodOverride( ctx,
1963+ enclosingTypeNameRange,
1964+ spacesBeforeOverrideKeyword,
1965+ hasThis,
1966+ isStatic,
1967+ spacesBeforeEnclosingDefinition)) ->
1968+ let indent = max 1 ( spacesBeforeOverrideKeyword - spacesBeforeEnclosingDefinition)
1969+
1970+ GetOverridableMethods
1971+ pos
1972+ ctx
1973+ enclosingTypeNameRange
1974+ ( spacesBeforeOverrideKeyword + indent)
1975+ hasThis
1976+ isStatic
1977+ genBodyForOverriddenMeth
19621978
19631979 // Other completions
19641980 | cc ->
@@ -2025,7 +2041,16 @@ type internal TypeCheckInfo
20252041 scope.IsRelativeNameResolvable( cursorPos, plid, symbol.Item)
20262042
20272043 /// Get the auto-complete items at a location
2028- member _.GetDeclarations ( parseResultsOpt , line , lineStr , partialName , completionContextAtPos , getAllEntities ) =
2044+ member _.GetDeclarations
2045+ (
2046+ parseResultsOpt ,
2047+ line ,
2048+ lineStr ,
2049+ partialName ,
2050+ completionContextAtPos ,
2051+ getAllEntities ,
2052+ genBodyForOverriddenMeth
2053+ ) =
20292054 let isSigFile = SourceFileImpl.IsSignatureFile mainInputFileName
20302055
20312056 DiagnosticsScope.Protect
@@ -2044,7 +2069,8 @@ type internal TypeCheckInfo
20442069 ResolveTypeNamesToCtors,
20452070 ResolveOverloads.Yes,
20462071 completionContextAtPos,
2047- getAllEntities
2072+ getAllEntities,
2073+ genBodyForOverriddenMeth
20482074 )
20492075
20502076 match declItemsOpt with
@@ -2085,7 +2111,7 @@ type internal TypeCheckInfo
20852111 DeclarationListInfo.Error msg)
20862112
20872113 /// Get the symbols for auto-complete items at a location
2088- member _.GetDeclarationListSymbols ( parseResultsOpt , line , lineStr , partialName , getAllEntities ) =
2114+ member _.GetDeclarationListSymbols ( parseResultsOpt , line , lineStr , partialName , getAllEntities , genBodyForOverriddenMeth ) =
20892115 let isSigFile = SourceFileImpl.IsSignatureFile mainInputFileName
20902116
20912117 DiagnosticsScope.Protect
@@ -2104,7 +2130,8 @@ type internal TypeCheckInfo
21042130 ResolveTypeNamesToCtors,
21052131 ResolveOverloads.Yes,
21062132 None,
2107- getAllEntities
2133+ getAllEntities,
2134+ genBodyForOverriddenMeth
21082135 )
21092136
21102137 match declItemsOpt with
@@ -2285,7 +2312,8 @@ type internal TypeCheckInfo
22852312 ResolveTypeNamesToCtors,
22862313 ResolveOverloads.Yes,
22872314 None,
2288- ( fun () -> [])
2315+ ( fun () -> []),
2316+ false
22892317 )
22902318
22912319 match declItemsOpt with
@@ -2347,7 +2375,8 @@ type internal TypeCheckInfo
23472375 ResolveTypeNamesToCtors,
23482376 ResolveOverloads.No,
23492377 None,
2350- ( fun () -> [])
2378+ ( fun () -> []),
2379+ false
23512380 )
23522381
23532382 match declItemsOpt with
@@ -2393,7 +2422,8 @@ type internal TypeCheckInfo
23932422 ResolveTypeNamesToCtors,
23942423 ResolveOverloads.No,
23952424 None,
2396- ( fun () -> [])
2425+ ( fun () -> []),
2426+ false
23972427 )
23982428
23992429 match declItemsOpt with
@@ -2434,7 +2464,8 @@ type internal TypeCheckInfo
24342464 ResolveTypeNamesToCtors,
24352465 ResolveOverloads.No,
24362466 None,
2437- ( fun () -> [])
2467+ ( fun () -> []),
2468+ false
24382469 )
24392470
24402471 match declItemsOpt with
@@ -2470,7 +2501,8 @@ type internal TypeCheckInfo
24702501 ResolveTypeNamesToCtors,
24712502 ResolveOverloads.Yes,
24722503 None,
2473- ( fun () -> [])
2504+ ( fun () -> []),
2505+ false
24742506 )
24752507
24762508 match declItemsOpt with
@@ -2618,7 +2650,8 @@ type internal TypeCheckInfo
26182650 ResolveTypeNamesToCtors,
26192651 ResolveOverloads.Yes,
26202652 None,
2621- ( fun () -> [])
2653+ ( fun () -> []),
2654+ false
26222655 )
26232656
26242657 match declItemsOpt with
@@ -2647,7 +2680,8 @@ type internal TypeCheckInfo
26472680 ResolveTypeNamesToCtors,
26482681 ResolveOverloads.Yes,
26492682 None,
2650- ( fun () -> [])
2683+ ( fun () -> []),
2684+ false
26512685 )
26522686
26532687 match declItemsOpt with
@@ -3348,20 +3382,40 @@ type FSharpCheckFileResults
33483382 | Some( scope, _ builderOpt) -> Some scope.TcImports
33493383
33503384 /// Intellisense autocompletions
3351- member _.GetDeclarationListInfo ( parsedFileResults , line , lineText , partialName , ? getAllEntities , ? completionContextAtPos ) =
3385+ member _.GetDeclarationListInfo
3386+ (
3387+ parsedFileResults ,
3388+ line ,
3389+ lineText ,
3390+ partialName ,
3391+ ? getAllEntities ,
3392+ ? completionContextAtPos ,
3393+ ? genBodyForOverriddenMeth
3394+ ) =
33523395 let getAllEntities = defaultArg getAllEntities ( fun () -> [])
3396+ let genBodyForOverriddenMeth = defaultArg genBodyForOverriddenMeth true
33533397
33543398 match details with
33553399 | None -> DeclarationListInfo.Empty
33563400 | Some( scope, _ builderOpt) ->
3357- scope.GetDeclarations( parsedFileResults, line, lineText, partialName, completionContextAtPos, getAllEntities)
3401+ scope.GetDeclarations(
3402+ parsedFileResults,
3403+ line,
3404+ lineText,
3405+ partialName,
3406+ completionContextAtPos,
3407+ getAllEntities,
3408+ genBodyForOverriddenMeth
3409+ )
33583410
3359- member _.GetDeclarationListSymbols ( parsedFileResults , line , lineText , partialName , ? getAllEntities ) =
3411+ member _.GetDeclarationListSymbols ( parsedFileResults , line , lineText , partialName , ? getAllEntities , ? genBodyForOverriddenMeth ) =
33603412 let getAllEntities = defaultArg getAllEntities ( fun () -> [])
3413+ let genBodyForOverriddenMeth = defaultArg genBodyForOverriddenMeth true
33613414
33623415 match details with
33633416 | None -> []
3364- | Some( scope, _ builderOpt) -> scope.GetDeclarationListSymbols( parsedFileResults, line, lineText, partialName, getAllEntities)
3417+ | Some( scope, _ builderOpt) ->
3418+ scope.GetDeclarationListSymbols( parsedFileResults, line, lineText, partialName, getAllEntities, genBodyForOverriddenMeth)
33653419
33663420 member _.GetKeywordTooltip ( names : string list ) =
33673421 ToolTipText.ToolTipText
0 commit comments