Skip to content

Commit 3828c87

Browse files
authored
Add FSharpCodeCompletionOptions (#19030)
* Add FSharpCodeCompletionOptions * Allows providing obsolete items * Allows disabling override items * Allows disabling pattern name suggestion items
1 parent e6217ba commit 3828c87

File tree

11 files changed

+644
-186
lines changed

11 files changed

+644
-186
lines changed

docs/release-notes/.FSharp.Compiler.Service/11.0.0.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
### Added
1313

14+
* Add FSharpCodeCompletionOptions ([PR #19030](https://github.com/dotnet/fsharp/pull/19030))
15+
1416
### Changed
1517

1618
* Parallel compilation stabilised and enabled by default ([PR #18998](https://github.com/dotnet/fsharp/pull/18998))

src/Compiler/Checking/AttributeChecking.fs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -478,13 +478,11 @@ let CheckFSharpAttributesForObsolete (g:TcGlobals) attribs =
478478
// like Span and ReadOnlySpan in completion lists due to their dual attributes.
479479
not (HasFSharpAttributeOpt g g.attrib_IsByRefLikeAttribute_opt attribs)
480480

481-
/// Indicate if a list of F# attributes contains 'ObsoleteAttribute'. Used to suppress the item in intellisense.
482-
/// Also check the attributes for CompilerMessageAttribute, which has an IsHidden argument that allows
483-
/// items to be suppressed from intellisense.
484-
let CheckFSharpAttributesForUnseen g attribs _m =
481+
/// Indicates if a list of F# attributes contains 'ObsoleteAttribute' or CompilerMessageAttribute', which has an IsHidden argument
482+
/// May be used to suppress items from intellisense.
483+
let CheckFSharpAttributesForUnseen g attribs _m allowObsolete =
485484
not (isNil attribs) &&
486-
(CheckFSharpAttributesForObsolete g attribs ||
487-
CheckFSharpAttributesForHidden g attribs)
485+
(not allowObsolete && CheckFSharpAttributesForObsolete g attribs || CheckFSharpAttributesForHidden g attribs)
488486

489487
#if !NO_TYPEPROVIDERS
490488
/// Indicate if a list of provided attributes contains 'ObsoleteAttribute'. Used to suppress the item in intellisense.
@@ -577,13 +575,13 @@ let CheckMethInfoAttributes g m tyargsOpt (minfo: MethInfo) =
577575

578576
/// Indicate if a method has 'Obsolete', 'CompilerMessageAttribute' or 'TypeProviderEditorHideMethodsAttribute'.
579577
/// Used to suppress the item in intellisense.
580-
let MethInfoIsUnseen g (m: range) (ty: TType) minfo =
581-
let isUnseenByObsoleteAttrib () =
578+
let MethInfoIsUnseen g (m: range) (ty: TType) minfo allowObsolete =
579+
let isUnseenByObsoleteAttrib () =
582580
match BindMethInfoAttributes m minfo
583-
(fun ilAttribs -> Some(CheckILAttributesForUnseen g ilAttribs m))
584-
(fun fsAttribs -> Some(CheckFSharpAttributesForUnseen g fsAttribs m))
581+
(fun ilAttribs -> Some(not allowObsolete && CheckILAttributesForUnseen g ilAttribs m))
582+
(fun fsAttribs -> Some(CheckFSharpAttributesForUnseen g fsAttribs m allowObsolete))
585583
#if !NO_TYPEPROVIDERS
586-
(fun provAttribs -> Some(CheckProvidedAttributesForUnseen provAttribs m))
584+
(fun provAttribs -> Some(not allowObsolete && CheckProvidedAttributesForUnseen provAttribs m))
587585
#else
588586
(fun _provAttribs -> None)
589587
#endif
@@ -620,14 +618,14 @@ let MethInfoIsUnseen g (m: range) (ty: TType) minfo =
620618

621619
/// Indicate if a property has 'Obsolete' or 'CompilerMessageAttribute'.
622620
/// Used to suppress the item in intellisense.
623-
let PropInfoIsUnseen m pinfo =
621+
let PropInfoIsUnseen m allowObsolete pinfo =
624622
match pinfo with
625623
| ILProp (ILPropInfo(_, pdef) as ilpinfo) ->
626624
// Properties on .NET tuple types are resolvable but unseen
627625
isAnyTupleTy pinfo.TcGlobals ilpinfo.ILTypeInfo.ToType ||
628626
CheckILAttributesForUnseen pinfo.TcGlobals pdef.CustomAttrs m
629627
| FSProp (g, _, Some vref, _)
630-
| FSProp (g, _, _, Some vref) -> CheckFSharpAttributesForUnseen g vref.Attribs m
628+
| FSProp (g, _, _, Some vref) -> CheckFSharpAttributesForUnseen g vref.Attribs m allowObsolete
631629
| FSProp _ -> failwith "CheckPropInfoAttributes: unreachable"
632630
#if !NO_TYPEPROVIDERS
633631
| ProvidedProp (_amap, pi, m) ->

src/Compiler/Checking/AttributeChecking.fsi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ val CheckFSharpAttributesForHidden: g: TcGlobals -> attribs: Attrib list -> bool
6868

6969
val CheckFSharpAttributesForObsolete: g: TcGlobals -> attribs: Attrib list -> bool
7070

71-
val CheckFSharpAttributesForUnseen: g: TcGlobals -> attribs: Attrib list -> _m: 'a -> bool
71+
val CheckFSharpAttributesForUnseen: g: TcGlobals -> attribs: Attrib list -> _m: 'a -> allowObsolete: bool -> bool
7272

7373
val CheckPropInfoAttributes: pinfo: PropInfo -> m: range -> OperationResult<unit>
7474

@@ -77,9 +77,9 @@ val CheckILFieldAttributes: g: TcGlobals -> finfo: ILFieldInfo -> m: range -> un
7777
val CheckMethInfoAttributes:
7878
g: TcGlobals -> m: range -> tyargsOpt: 'a option -> minfo: MethInfo -> OperationResult<unit>
7979

80-
val MethInfoIsUnseen: g: TcGlobals -> m: range -> ty: TType -> minfo: MethInfo -> bool
80+
val MethInfoIsUnseen: g: TcGlobals -> m: range -> ty: TType -> minfo: MethInfo -> allowObsolete: bool -> bool
8181

82-
val PropInfoIsUnseen: m: 'a -> pinfo: PropInfo -> bool
82+
val PropInfoIsUnseen: m: 'a -> allowObsolete: bool -> pinfo: PropInfo -> bool
8383

8484
val CheckEntityAttributes: g: TcGlobals -> tcref: TyconRef -> m: range -> OperationResult<unit>
8585

0 commit comments

Comments
 (0)