@@ -2459,8 +2459,17 @@ let ResolveRecordOrClassFieldsOfType (ncenv: NameResolver) m ad typ statics =
24592459|> List.filter( fun rfref -> rfref.IsStatic= statics&& IsFieldInfoAccessible ad rfref)
24602460|> List.map Item.RecdField
24612461
2462+ [<RequireQualifiedAccess>]
2463+ type ResolveCompletionTargets =
2464+ | Allof ( MethInfo -> TType -> bool )
2465+ | SettablePropertiesAndFields
2466+ member this.ResolveAll =
2467+ match thiswith
2468+ | All_ -> true
2469+ | SettablePropertiesAndFields-> false
2470+
24622471/// Resolve a (possibly incomplete) long identifier to a set of possible resolutions, qualified by type.
2463- let ResolveCompletionsInType ( ncenv : NameResolver ) nenvisApplicableMeth m ad statics typ =
2472+ let ResolveCompletionsInType ( ncenv : NameResolver ) nenv ( completionTargets : ResolveCompletionTargets ) m ad statics typ =
24642473let g = ncenv.g
24652474let amap = ncenv.amap
24662475
@@ -2469,21 +2478,23 @@ let ResolveCompletionsInType (ncenv: NameResolver) nenv isApplicableMeth m ad st
24692478|> List.filter( fun rfref -> rfref.IsStatic= statics&& IsFieldInfoAccessible ad rfref)
24702479
24712480let ucinfos =
2472- if statics&& isAppTy g typthen
2481+ if completionTargets.ResolveAll && statics&& isAppTy g typthen
24732482let tc , tinst = destAppTy g typ
24742483 tc.UnionCasesAsRefList
24752484|> List.filter( IsUnionCaseUnseen ad g ncenv.amap m>> not )
24762485|> List.map( fun ucref -> Item.UnionCase( UnionCaseInfo( tinst, ucref), false ))
24772486else []
24782487
24792488let einfos =
2480- ncenv.InfoReader.GetEventInfosOfType( None, ad, m, typ)
2481- |> List.filter( fun x ->
2482- IsStandardEventInfo ncenv.InfoReader m ad x&&
2483- x.IsStatic= statics)
2489+ if completionTargets.ResolveAllthen
2490+ ncenv.InfoReader.GetEventInfosOfType( None, ad, m, typ)
2491+ |> List.filter( fun x ->
2492+ IsStandardEventInfo ncenv.InfoReader m ad x&&
2493+ x.IsStatic= statics)
2494+ else []
24842495
24852496let nestedTypes =
2486- if staticsthen
2497+ if completionTargets.ResolveAll && staticsthen
24872498 typ
24882499|> GetNestedTypesOfType( ad, ncenv, None, TypeNameResolutionStaticArgsInfo.Indefinite, false , m)
24892500else
@@ -2501,7 +2512,6 @@ let ResolveCompletionsInType (ncenv: NameResolver) nenv isApplicableMeth m ad st
25012512 x.IsStatic= statics&&
25022513 IsPropInfoAccessible g amap m ad x)
25032514
2504-
25052515// Exclude get_ and set_ methods accessed by properties
25062516let pinfoMethNames =
25072517( pinfosIncludingUnseen
@@ -2513,13 +2523,15 @@ let ResolveCompletionsInType (ncenv: NameResolver) nenv isApplicableMeth m ad st
25132523|> List.map( fun pinfo -> pinfo.SetterMethod.LogicalName))
25142524
25152525let einfoMethNames =
2516- [ for einfoin einfosdo
2517- let delegateType = einfo.GetDelegateType( amap, m)
2518- let ( SigOfFunctionForDelegate ( invokeMethInfo , _ , _ , _ )) = GetSigOfFunctionForDelegate ncenv.InfoReader delegateType m ad
2519- // Only events with void return types are suppressed in intellisense.
2520- if slotSigHasVoidReturnTy( invokeMethInfo.GetSlotSig( amap, m)) then
2521- yield einfo.GetAddMethod() .DisplayName
2522- yield einfo.GetRemoveMethod() .DisplayName]
2526+ if completionTargets.ResolveAllthen
2527+ [ for einfoin einfosdo
2528+ let delegateType = einfo.GetDelegateType( amap, m)
2529+ let ( SigOfFunctionForDelegate ( invokeMethInfo , _ , _ , _ )) = GetSigOfFunctionForDelegate ncenv.InfoReader delegateType m ad
2530+ // Only events with void return types are suppressed in intellisense.
2531+ if slotSigHasVoidReturnTy( invokeMethInfo.GetSlotSig( amap, m)) then
2532+ yield einfo.GetAddMethod() .DisplayName
2533+ yield einfo.GetRemoveMethod() .DisplayName]
2534+ else []
25232535
25242536let suppressedMethNames = Zset.ofList String.order( pinfoMethNames@ einfoMethNames)
25252537
@@ -2528,6 +2540,10 @@ let ResolveCompletionsInType (ncenv: NameResolver) nenv isApplicableMeth m ad st
25282540|> List.filter( fun x -> not ( PropInfoIsUnseen m x))
25292541
25302542let minfoFilter ( minfo : MethInfo ) =
2543+ let isApplicableMeth =
2544+ match completionTargetswith
2545+ | ResolveCompletionTargets.All x-> x
2546+ | _ -> failwith" internal error: expected completionTargets = ResolveCompletionTargets.All"
25312547// Only show the Finalize, MemberwiseClose etc. methods on System.Object for values whose static type really is
25322548// System.Object. Few of these are typically used from F#.
25332549//
@@ -2566,24 +2582,37 @@ let ResolveCompletionsInType (ncenv: NameResolver) nenv isApplicableMeth m ad st
25662582 result
25672583
25682584let pinfoItems =
2585+ let pinfos =
2586+ match completionTargetswith
2587+ | ResolveCompletionTargets.SettablePropertiesAndFields-> pinfos|> List.filter( fun p -> p.HasSetter)
2588+ | _ -> pinfos
2589+
25692590 pinfos
2570- |> List.map( fun pinfo -> DecodeFSharpEvent[ pinfo] ad g ncenv m)
2571- |> List.filter( fun pinfo -> match pinfowith
2572- | Some( Item.Event( einfo)) -> IsStandardEventInfo ncenv.InfoReader m ad einfo
2573- | _ -> pinfo.IsSome)
2574- |> List.map( fun pinfo -> pinfo.Value)
2575-
2576- let addersAndRemovers =
2577- pinfoItems
2578- |> List.map( function Item.Event( FSEvent(_,_, addValRef, removeValRef)) -> [ addValRef.LogicalName; removeValRef.LogicalName] | _ -> [])
2579- |> List.concat
2580-
2591+ |> List.choose( fun pinfo ->
2592+ let pinfoOpt = DecodeFSharpEvent[ pinfo] ad g ncenv m
2593+ match pinfoOpt, completionTargetswith
2594+ | Some( Item.Event( einfo)), ResolveCompletionTargets.All_ -> if IsStandardEventInfo ncenv.InfoReader m ad einfothen pinfoOptelse None
2595+ | _ -> pinfoOpt)
2596+
25812597// REVIEW: add a name filter here in the common cases?
25822598let minfos =
2583- AllMethInfosOfTypeInScope ncenv.InfoReader nenv( None, ad) PreferOverrides m typ
2584- |> List.filter minfoFilter
2585- |> List.filter( fun minfo -> not ( addersAndRemovers|> List.exists( fun ar -> ar= minfo.LogicalName)))
2599+ if completionTargets.ResolveAllthen
2600+ let minfos =
2601+ AllMethInfosOfTypeInScope ncenv.InfoReader nenv( None, ad) PreferOverrides m typ
2602+ |> List.filter minfoFilter
2603+
2604+ let addersAndRemovers =
2605+ pinfoItems
2606+ |> List.map( function Item.Event( FSEvent(_,_, addValRef, removeValRef)) -> [ addValRef.LogicalName; removeValRef.LogicalName] | _ -> [])
2607+ |> List.concat
2608+
2609+ match addersAndRemoverswith
2610+ | [] -> minfos
2611+ | addersAndRemovers->
2612+ let isNotAdderOrRemover ( minfo : MethInfo ) = not ( addersAndRemovers|> List.exists( fun ar -> ar= minfo.LogicalName))
2613+ List.filter isNotAdderOrRemover minfos
25862614
2615+ else []
25872616// Partition methods into overload sets
25882617let rec partitionl ( l : MethInfo list ) acc =
25892618match lwith
@@ -2592,8 +2621,6 @@ let ResolveCompletionsInType (ncenv: NameResolver) nenv isApplicableMeth m ad st
25922621let nm = h.LogicalName
25932622 partitionl t( NameMultiMap.add nm h acc)
25942623
2595-
2596-
25972624// Build the results
25982625 ucinfos@
25992626 List.map Item.RecdField rfinfos@
@@ -2891,7 +2918,7 @@ let rec ResolvePartialLongIdentPrim (ncenv: NameResolver) (nenv: NameResolutionE
28912918
28922919/// Resolve a (possibly incomplete) long identifier to a set of possible resolutions.
28932920let ResolvePartialLongIdent ncenv nenv isApplicableMeth m ad plid allowObsolete =
2894- ResolvePartialLongIdentPrim ncenv nenv isApplicableMeth OpenQualified m ad plid allowObsolete
2921+ ResolvePartialLongIdentPrim ncenv nenv( ResolveCompletionTargets.All isApplicableMeth) OpenQualified m ad plid allowObsolete
28952922
28962923// REVIEW: has much in common with ResolvePartialLongIdentInModuleOrNamespace - probably they should be united
28972924let rec ResolvePartialLongIdentInModuleOrNamespaceForRecordFields ( ncenv : NameResolver ) nenv m ad ( modref : ModuleOrNamespaceRef ) plid allowObsolete =