@@ -2459,8 +2459,17 @@ let ResolveRecordOrClassFieldsOfType (ncenv: NameResolver) m ad typ statics =
2459
2459
|> List.filter ( fun rfref -> rfref.IsStatic = statics && IsFieldInfoAccessible ad rfref)
2460
2460
|> List.map Item.RecdField
2461
2461
2462
+ [<RequireQualifiedAccess>]
2463
+ type ResolveCompletionTargets =
2464
+ | All of ( MethInfo -> TType -> bool )
2465
+ | SettablePropertiesAndFields
2466
+ member this.ResolveAll =
2467
+ match this with
2468
+ | All _ -> true
2469
+ | SettablePropertiesAndFields -> false
2470
+
2462
2471
/// Resolve a (possibly incomplete) long identifier to a set of possible resolutions, qualified by type.
2463
- let ResolveCompletionsInType ( ncenv : NameResolver ) nenv isApplicableMeth m ad statics typ =
2472
+ let ResolveCompletionsInType ( ncenv : NameResolver ) nenv ( completionTargets : ResolveCompletionTargets ) m ad statics typ =
2464
2473
let g = ncenv.g
2465
2474
let amap = ncenv.amap
2466
2475
@@ -2469,21 +2478,23 @@ let ResolveCompletionsInType (ncenv: NameResolver) nenv isApplicableMeth m ad st
2469
2478
|> List.filter ( fun rfref -> rfref.IsStatic = statics && IsFieldInfoAccessible ad rfref)
2470
2479
2471
2480
let ucinfos =
2472
- if statics && isAppTy g typ then
2481
+ if completionTargets.ResolveAll && statics && isAppTy g typ then
2473
2482
let tc , tinst = destAppTy g typ
2474
2483
tc.UnionCasesAsRefList
2475
2484
|> List.filter ( IsUnionCaseUnseen ad g ncenv.amap m >> not )
2476
2485
|> List.map ( fun ucref -> Item.UnionCase( UnionCaseInfo( tinst, ucref), false ))
2477
2486
else []
2478
2487
2479
2488
let 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.ResolveAll then
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 []
2484
2495
2485
2496
let nestedTypes =
2486
- if statics then
2497
+ if completionTargets.ResolveAll && statics then
2487
2498
typ
2488
2499
|> GetNestedTypesOfType ( ad, ncenv, None, TypeNameResolutionStaticArgsInfo.Indefinite, false , m)
2489
2500
else
@@ -2501,7 +2512,6 @@ let ResolveCompletionsInType (ncenv: NameResolver) nenv isApplicableMeth m ad st
2501
2512
x.IsStatic = statics &&
2502
2513
IsPropInfoAccessible g amap m ad x)
2503
2514
2504
-
2505
2515
// Exclude get_ and set_ methods accessed by properties
2506
2516
let pinfoMethNames =
2507
2517
( pinfosIncludingUnseen
@@ -2513,13 +2523,15 @@ let ResolveCompletionsInType (ncenv: NameResolver) nenv isApplicableMeth m ad st
2513
2523
|> List.map ( fun pinfo -> pinfo.SetterMethod.LogicalName))
2514
2524
2515
2525
let einfoMethNames =
2516
- [ for einfo in einfos do
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.ResolveAll then
2527
+ [ for einfo in einfos do
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 []
2523
2535
2524
2536
let suppressedMethNames = Zset.ofList String.order ( pinfoMethNames @ einfoMethNames)
2525
2537
@@ -2528,6 +2540,10 @@ let ResolveCompletionsInType (ncenv: NameResolver) nenv isApplicableMeth m ad st
2528
2540
|> List.filter ( fun x -> not ( PropInfoIsUnseen m x))
2529
2541
2530
2542
let minfoFilter ( minfo : MethInfo ) =
2543
+ let isApplicableMeth =
2544
+ match completionTargets with
2545
+ | ResolveCompletionTargets.All x -> x
2546
+ | _ -> failwith " internal error: expected completionTargets = ResolveCompletionTargets.All"
2531
2547
// Only show the Finalize, MemberwiseClose etc. methods on System.Object for values whose static type really is
2532
2548
// System.Object. Few of these are typically used from F#.
2533
2549
//
@@ -2566,24 +2582,37 @@ let ResolveCompletionsInType (ncenv: NameResolver) nenv isApplicableMeth m ad st
2566
2582
result
2567
2583
2568
2584
let pinfoItems =
2585
+ let pinfos =
2586
+ match completionTargets with
2587
+ | ResolveCompletionTargets.SettablePropertiesAndFields -> pinfos |> List.filter ( fun p -> p.HasSetter)
2588
+ | _ -> pinfos
2589
+
2569
2590
pinfos
2570
- |> List.map ( fun pinfo -> DecodeFSharpEvent [ pinfo] ad g ncenv m)
2571
- |> List.filter ( fun pinfo -> match pinfo with
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, completionTargets with
2594
+ | Some( Item.Event( einfo)), ResolveCompletionTargets.All _ -> if IsStandardEventInfo ncenv.InfoReader m ad einfo then pinfoOpt else None
2595
+ | _ -> pinfoOpt)
2596
+
2581
2597
// REVIEW: add a name filter here in the common cases?
2582
2598
let 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.ResolveAll then
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 addersAndRemovers with
2610
+ | [] -> minfos
2611
+ | addersAndRemovers ->
2612
+ let isNotAdderOrRemover ( minfo : MethInfo ) = not ( addersAndRemovers |> List.exists ( fun ar -> ar = minfo.LogicalName))
2613
+ List.filter isNotAdderOrRemover minfos
2586
2614
2615
+ else []
2587
2616
// Partition methods into overload sets
2588
2617
let rec partitionl ( l : MethInfo list ) acc =
2589
2618
match l with
@@ -2592,8 +2621,6 @@ let ResolveCompletionsInType (ncenv: NameResolver) nenv isApplicableMeth m ad st
2592
2621
let nm = h.LogicalName
2593
2622
partitionl t ( NameMultiMap.add nm h acc)
2594
2623
2595
-
2596
-
2597
2624
// Build the results
2598
2625
ucinfos @
2599
2626
List.map Item.RecdField rfinfos @
@@ -2891,7 +2918,7 @@ let rec ResolvePartialLongIdentPrim (ncenv: NameResolver) (nenv: NameResolutionE
2891
2918
2892
2919
/// Resolve a (possibly incomplete) long identifier to a set of possible resolutions.
2893
2920
let 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
2895
2922
2896
2923
// REVIEW: has much in common with ResolvePartialLongIdentInModuleOrNamespace - probably they should be united
2897
2924
let rec ResolvePartialLongIdentInModuleOrNamespaceForRecordFields ( ncenv : NameResolver ) nenv m ad ( modref : ModuleOrNamespaceRef ) plid allowObsolete =
0 commit comments