diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Common/src/Util/FSharpSymbolUtil.fs b/ReSharper.FSharp/src/FSharp/FSharp.Common/src/Util/FSharpSymbolUtil.fs index fefdfc0ee1..d57b584243 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Common/src/Util/FSharpSymbolUtil.fs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Common/src/Util/FSharpSymbolUtil.fs @@ -32,7 +32,7 @@ let isEnumMember (field: FSharpField) = | Some entity -> entity.IsEnum | _ -> false -let formatMfv (mfv: FSharpMemberOrFunctionOrValue) (displayContext: FSharpDisplayContext) addParameterNames = +let formatMfv addParameterNames (displayContext: FSharpDisplayContext) (mfv: FSharpMemberOrFunctionOrValue) = let append (stringBuilder: StringBuilder) (s: string) = stringBuilder.Append(s) |> ignore diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi.Daemon/src/Stages/InferredTypeCodeVisionProvider.fs b/ReSharper.FSharp/src/FSharp/FSharp.Psi.Daemon/src/Stages/InferredTypeCodeVisionProvider.fs index f4a0639df6..5d814b356c 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi.Daemon/src/Stages/InferredTypeCodeVisionProvider.fs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi.Daemon/src/Stages/InferredTypeCodeVisionProvider.fs @@ -103,7 +103,7 @@ and InferredTypeCodeVisionProviderProcess(fsFile, settings, daemonProcess, provi match symbolUse.Symbol with | :? FSharpMemberOrFunctionOrValue as mfv -> - let text = formatMfv mfv emptyDisplayContext false + let text = formatMfv false emptyDisplayContext mfv x.AddHighlighting(consumer, binding, text) | :? FSharpField as field -> @@ -119,6 +119,6 @@ and InferredTypeCodeVisionProviderProcess(fsFile, settings, daemonProcess, provi match symbolUse.Symbol with | :? FSharpMemberOrFunctionOrValue as mfv -> - let text = formatMfv mfv emptyDisplayContext false + let text = formatMfv false emptyDisplayContext mfv x.AddHighlighting(consumer, decl, text) | _ -> () diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi.Features/src/AICore/FSharpFileSummarizer.fs b/ReSharper.FSharp/src/FSharp/FSharp.Psi.Features/src/AICore/FSharpFileSummarizer.fs index 575f711b96..6414208dc2 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi.Features/src/AICore/FSharpFileSummarizer.fs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi.Features/src/AICore/FSharpFileSummarizer.fs @@ -5,7 +5,6 @@ open System.Collections.Generic open System.Text open JetBrains.ReSharper.Plugins.FSharp.Psi open JetBrains.ReSharper.Plugins.FSharp.Psi.Features.Util.FcsTypeUtil -open JetBrains.ReSharper.Plugins.FSharp.Psi.Impl open JetBrains.ReSharper.Plugins.FSharp.Psi.Tree open JetBrains.ReSharper.Plugins.FSharp.Util open JetBrains.ReSharper.Psi @@ -50,74 +49,21 @@ type private FileSummarizerVisitor() = static let displayContext = emptyDisplayContext - static let formatFcsSymbolType (fcsSymbol: FSharpSymbol) = + let formatFcsSymbolType (fcsSymbol: FSharpSymbol) = match fcsSymbol with - | :? FSharpEntity as entity -> entity.AsType().Format(displayContext) - | :? FSharpMemberOrFunctionOrValue as mfv -> formatMfv mfv displayContext true - | _ -> "_" - - static let rec formatTypeUsage (typeUsage: ITypeUsage) = - match typeUsage with - | :? INamedTypeUsage as typeUsage -> - formatTypeReferenceName typeUsage.ReferenceName - - | :? ITupleTypeUsage as typeUsage -> - typeUsage.Items |> Seq.map formatTypeUsage |> String.concat " * " - - | :? IParenTypeUsage as typeUsage -> - $"({formatTypeUsage typeUsage.InnerTypeUsage})" - - | :? IFunctionTypeUsage as typeUsage -> - $"{formatTypeUsage typeUsage.ArgumentTypeUsage} -> {formatTypeUsage typeUsage.ReturnTypeUsage}" - - | :? IArrayTypeUsage as typeUsage -> - $"{formatTypeUsage typeUsage.TypeUsage}[]" - - | :? IAnonRecordTypeUsage as typeUsage -> - let fields = - typeUsage.Fields - |> Seq.map (fun field -> $"{field.ReferenceName.ShortName}: {formatTypeUsage field.TypeUsage}") - |> String.concat "; " - $"{{|{fields}|}}" - - | :? IWithNullTypeUsage as typeUsage -> - $"{formatTypeUsage typeUsage.TypeUsage} | null" - - | _ -> "" + | :? FSharpEntity as entity -> + let typars = + entity.GenericArguments + |> Seq.zip entity.GenericParameters + |> Seq.toList + entity.AsType().Instantiate(typars).Format(displayContext) - and formatTypeReferenceName (typeName: ITypeReferenceName) = - let name = typeName.Identifier.GetTypeParameterOrSourceName() - let typeArgs = typeName.TypeArgumentList - if isNull typeArgs then name else - let typeUsages = typeArgs.TypeUsages - if Seq.isEmpty typeUsages then name else + | :? FSharpMemberOrFunctionOrValue as mfv -> + formatMfv true displayContext mfv - let typeArgsRepresentation = - typeUsages - |> Seq.map formatTypeUsage - |> String.concat ", " - - match typeArgs with - | :? IPrefixAppTypeArgumentList -> $"{name}<{typeArgsRepresentation}>" - | _ -> $"{typeArgsRepresentation} {name}" - - let formatTypeOrExtDeclaration (typeDecl: IFSharpTypeOrExtensionDeclaration) = - let name = typeDecl.SourceName - let typeArgs = typeDecl.TypeParameterDeclarationList - if isNull typeArgs then name else - let typeParams = typeArgs.TypeParameters - if Seq.isEmpty typeParams then name else - - let typeArgsRepresentation = - typeParams - |> Seq.map _.NameIdentifier.GetTypeParameterOrSourceName() - |> String.concat ", " - - match typeArgs with - | :? IPostfixTypeParameterDeclarationList -> $"{name}<{typeArgsRepresentation}>" - | _ -> $"{typeArgsRepresentation} {name}" + | _ -> "_" - static let addBinding (binding: IBindingLikeDeclaration) (context: SummarizerContext) = + let addBinding (binding: IBindingLikeDeclaration) (context: SummarizerContext) = let referencePat = binding.HeadPattern.As() if isNull referencePat then () else @@ -125,12 +71,12 @@ type private FileSummarizerVisitor() = let representation = $"val {referencePat.GetFcsSymbol().DisplayName}: {typeRepr}" context.AddEntity(binding, representation) - static let addConstructor (constructor: IConstructorSignatureOrDeclaration) (context: SummarizerContext) = + let addConstructor (constructor: IConstructorSignatureOrDeclaration) (context: SummarizerContext) = let typeRepr = constructor.GetFcsSymbol() |> formatFcsSymbolType let representation = $"new: {typeRepr}" context.AddEntity(constructor, representation) - static let addMember (memberDecl: IOverridableMemberDeclaration) (context: SummarizerContext) = + let addMember (memberDecl: IOverridableMemberDeclaration) (context: SummarizerContext) = let typeRepr = memberDecl.GetFcsSymbol() |> formatFcsSymbolType let accessorNames = match memberDecl with @@ -173,7 +119,7 @@ type private FileSummarizerVisitor() = override x.VisitNamedModuleDeclaration(moduleDecl, context) = // Currently, we're not adding a top-level module to the scope to not duplicate its name in tokens - context.AddEntity(moduleDecl, "module " + moduleDecl.ClrName) + context.AddEntity(moduleDecl, "module " + moduleDecl.QualifiedName) x.VisitNode(moduleDecl, context) override x.VisitNestedModuleDeclaration(moduleDecl, context) = @@ -185,19 +131,25 @@ type private FileSummarizerVisitor() = use _ = context.OpenScope(moduleDecl, scopeRepr) x.VisitNode(moduleDecl, context) - override x.VisitFSharpTypeDeclaration(typeDecl: IFSharpTypeDeclaration, context) = - let inheritMembers = typeDecl.TypeOrInterfaceInheritMembers + override x.VisitFSharpTypeDeclaration(typeDecl, context) = + let inheritMembers = + typeDecl.TypeOrInterfaceInheritMembers + |> Seq.map _.TypeName + |> Seq.filter isNotNull + |> Seq.map (fun x -> formatFcsSymbolType (x.Reference.GetFcsSymbol())) + |> String.concat ", " + let inheritsRepr = - if Seq.isEmpty inheritMembers then "" else - let inherits = - inheritMembers - |> Seq.map _.TypeName - |> Seq.filter isNotNull - |> Seq.map formatTypeReferenceName + if inheritMembers = "" then "" else $"inherit {inheritMembers}" + + let typeRepr = + let name = typeDecl.SourceName + let typars = + typeDecl.TypeParameterDeclarations + |> Seq.map (fun x -> "'" + x.SourceName) |> String.concat ", " - if inherits = "" then "" else $"inherit {inherits}" - let typeRepr = formatTypeOrExtDeclaration typeDecl + if typars = "" then name else $"{name}<{typars}>" use _ = context.OpenScope(typeDecl, $"type {typeRepr}", inheritsRepr) x.VisitNode(typeDecl, context) @@ -206,8 +158,8 @@ type private FileSummarizerVisitor() = use _ = context.OpenScope(exceptionDecl, $"exception {exceptionDecl.SourceName}") x.VisitNode(exceptionDecl, context) - override x.VisitTypeExtensionDeclaration(extensionDecl: ITypeExtensionDeclaration, context) = - let extensionRepr = formatTypeOrExtDeclaration extensionDecl + override x.VisitTypeExtensionDeclaration(extensionDecl, context) = + let extensionRepr = extensionDecl.GetFcsSymbol() |> formatFcsSymbolType use _ = context.OpenScope(extensionDecl, $"type {extensionRepr}", "with") x.VisitNode(extensionDecl, context) @@ -216,7 +168,7 @@ type private FileSummarizerVisitor() = let typeName = interfaceImpl.TypeName if isNull typeName then () else - let interfaceRepr = formatTypeReferenceName typeName + let interfaceRepr = typeName.Reference.GetFcsSymbol() |> formatFcsSymbolType use _ = context.OpenScope(interfaceImpl, $"interface {interfaceRepr}") x.VisitNode(interfaceImpl, context) diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/FSharpImplUtil.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/FSharpImplUtil.cs index f1841ba281..b1b3e202e3 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/FSharpImplUtil.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/FSharpImplUtil.cs @@ -171,15 +171,6 @@ public static string GetCompiledName([CanBeNull] this IIdentifier identifier) public static string GetSourceName([CanBeNull] this IIdentifier identifier) => identifier?.Name ?? SharedImplUtil.MISSING_DECLARATION_NAME; - [NotNull] - public static string GetTypeParameterOrSourceName([CanBeNull] this IIdentifier identifier) - { - if (identifier == null) return SharedImplUtil.MISSING_DECLARATION_NAME; - return identifier is ITypeParameterId || identifier.PrevSibling?.GetTokenType() == FSharpTokenType.QUOTE - ? "'" + identifier.Name - : identifier.Name; - } - public static TreeTextRange GetNameRange([CanBeNull] this IFSharpIdentifier identifier) => // todo: fix navigating inside escaped names identifier?.NameRange ?? TreeTextRange.InvalidRange; diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Tree/NamedModuleDeclaration.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Tree/NamedModuleDeclaration.cs index 0b66f53d57..019ed57b1e 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Tree/NamedModuleDeclaration.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Tree/NamedModuleDeclaration.cs @@ -34,7 +34,19 @@ public string ClrName } public string NamespaceName => - QualifierReferenceName?.QualifiedName ?? + QualifierReferenceName?.QualifiedName ?? SharedImplUtil.MISSING_DECLARATION_NAME; + + public string QualifiedName + { + get + { + var ns = NamespaceName; + if (!ns.IsEmpty() && ns != SharedImplUtil.MISSING_DECLARATION_NAME) + return ns + "." + SourceName; + + return CompiledName; + } + } } } diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Tree/INamedModuleDeclaration.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Tree/INamedModuleDeclaration.cs index 5ed2a22b5c..6d9a2cd776 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Tree/INamedModuleDeclaration.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Tree/INamedModuleDeclaration.cs @@ -5,5 +5,6 @@ namespace JetBrains.ReSharper.Plugins.FSharp.Psi.Tree public partial interface INamedModuleDeclaration { [NotNull] public string NamespaceName { get; } + [NotNull] public string QualifiedName { get; } } } diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Implementation file 01.fs b/ReSharper.FSharp/test/data/ai/summarizer/Implementation file 01.fs deleted file mode 100644 index d32f15fd22..0000000000 --- a/ReSharper.FSharp/test/data/ai/summarizer/Implementation file 01.fs +++ /dev/null @@ -1,64 +0,0 @@ -namespace global - -type GlobalType = class end - -namespace N1.N - -[] -module M1 = - let x = 1 - let f x = x - let (+) a b = a + b - let (|One|_|) x = Some(x) - let (Some(some)) = Some(1) - - exception E1 of string - with member x.NewMessage = "" - - type Record = { - Field1: int - Field2: int - } - - type DU = - | Case1 of int - | Case2 - - type Struct = - struct - val X: float - val Y: float - new(x: float, y: float) = { X = x; Y = y } - end - - [] - type IInterface = - inherit System.IDisposable - inherit System.Collections.Generic.IList - abstract member M: x: int -> unit - - type System.Collections.Generic.List<'a> with - member x.Length = x.Count - - type GenericType<'t>(x: string) = - inherit ResizeArray() - let x = 4 - static let staticX = 4 - - new (x: 't) = new GenericType<'t>(string x) - - member _.Method1 x (y: 'a when 'a :> System.IDisposable, z) = x(y) + z - member _.Method2 (x, ?y) = y.Value + 1 - member val Prop1 = 5 with get - member _.Prop2 with get (x: string) = 1 and set (x: string) (z: int) = () - - interface System.IDisposable with - member this.Dispose() = () - - interface System.Collections.Generic.IList with - member this.Add(item) = failwith "todo" - - module NestedModule = - let x = 5 - -namespace N2.N \ No newline at end of file diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Implementation file 01.gold b/ReSharper.FSharp/test/data/ai/summarizer/Implementation file 01.gold deleted file mode 100644 index 5269659727..0000000000 --- a/ReSharper.FSharp/test/data/ai/summarizer/Implementation file 01.gold +++ /dev/null @@ -1,34 +0,0 @@ -namespace global (1-3) -type GlobalType (3-3) -namespace N1.N (5-62) -module M1 (7-62) -module M1 val x: int (9-9) -module M1 val f: x: 'a -> 'a (10-10) -module M1 val (+): a: int -> b: int -> int (11-11) -module M1 val (|One|_|): x: 'a -> 'a option (12-12) -module M1 exception E1 (15-16) -module M1 exception E1 member NewMessage: string (16-16) -module M1 type Record (18-21) -module M1 type DU (23-25) -module M1 type Struct (27-32) -module M1 type Struct new: x: float * y: float -> Struct (31-31) -module M1 type IInterface inherit IDisposable, IList (34-38) -module M1 type IInterface member M: x: int -> unit (38-38) -module M1 type List<'a> with (40-41) -module M1 type List<'a> member Length: int (41-41) -module M1 type GenericType<'t> inherit ResizeArray (43-59) -module M1 type GenericType<'t> new: x: string -> GenericType<'t> (43-43) -module M1 type GenericType<'t> val x: int (45-45) -module M1 type GenericType<'t> val staticX: int (46-46) -module M1 type GenericType<'t> new: x: 't -> GenericType<'t> (48-48) -module M1 type GenericType<'t> member Method1: x: ('a -> int) -> (y: 'a * z: int) -> int (50-50) -module M1 type GenericType<'t> member Method2: x: 'a * ?y: int -> int (51-51) -module M1 type GenericType<'t> member Prop1: int with get (52-52) -module M1 type GenericType<'t> member Prop2: int with get, set (53-53) -module M1 type GenericType<'t> interface IDisposable (55-56) -module M1 type GenericType<'t> interface IDisposable member Dispose: unit -> unit (56-56) -module M1 type GenericType<'t> interface IList (58-59) -module M1 type GenericType<'t> interface IList member Add: item: string -> unit (59-59) -module M1.NestedModule (61-62) -module M1.NestedModule val x: int (62-62) -namespace N2.N (64-64) diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Implementation file 02 - Top level module.fs b/ReSharper.FSharp/test/data/ai/summarizer/Implementation file 02 - Top level module.fs deleted file mode 100644 index 5edb031cda..0000000000 --- a/ReSharper.FSharp/test/data/ai/summarizer/Implementation file 02 - Top level module.fs +++ /dev/null @@ -1,3 +0,0 @@ -module Test - -let x = 4 diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Implementation file 02 - Top level module.gold b/ReSharper.FSharp/test/data/ai/summarizer/Implementation file 02 - Top level module.gold deleted file mode 100644 index 313eb0d054..0000000000 --- a/ReSharper.FSharp/test/data/ai/summarizer/Implementation file 02 - Top level module.gold +++ /dev/null @@ -1,2 +0,0 @@ -module Test (1-3) -val x: int (3-3) diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Implementation file 04 - Type parameters.gold b/ReSharper.FSharp/test/data/ai/summarizer/Implementation file 04 - Type parameters.gold deleted file mode 100644 index 4db88ca5f7..0000000000 --- a/ReSharper.FSharp/test/data/ai/summarizer/Implementation file 04 - Type parameters.gold +++ /dev/null @@ -1 +0,0 @@ -type A<'t> inherit IList>, IList, IList<(int * int) * int>, IList, IList<'t>, IList int>, IList<{|Kek: int; Lol: string|}> (3-12) diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Implementation file 05 - Type parameters.fs b/ReSharper.FSharp/test/data/ai/summarizer/Implementation file 05 - Type parameters.fs deleted file mode 100644 index 950436ca71..0000000000 --- a/ReSharper.FSharp/test/data/ai/summarizer/Implementation file 05 - Type parameters.fs +++ /dev/null @@ -1,4 +0,0 @@ -open System - -type A<'a, - 'b when 'b :> IDisposable> = class end diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Implementation file 05 - Type parameters.gold b/ReSharper.FSharp/test/data/ai/summarizer/Implementation file 05 - Type parameters.gold deleted file mode 100644 index 6692b4f97f..0000000000 --- a/ReSharper.FSharp/test/data/ai/summarizer/Implementation file 05 - Type parameters.gold +++ /dev/null @@ -1 +0,0 @@ -type A<'a, 'b> (3-4) diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Implementation file 06 - Inherit.gold b/ReSharper.FSharp/test/data/ai/summarizer/Implementation file 06 - Inherit.gold deleted file mode 100644 index 477cb916d5..0000000000 --- a/ReSharper.FSharp/test/data/ai/summarizer/Implementation file 06 - Inherit.gold +++ /dev/null @@ -1,6 +0,0 @@ -type Class1 inherit ResizeArray (3-4) -type Class1 new: unit -> Class1 (3-3) -type Class2 inherit ResizeArray (6-9) -type Class2 new: unit -> Class2 (6-6) -type Interface1 inherit IList (11-14) -type Interface2 inherit IList (16-18) diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Implementation file 06 - Inherit.fs b/ReSharper.FSharp/test/data/ai/summarizer/Inherit 01.fs similarity index 79% rename from ReSharper.FSharp/test/data/ai/summarizer/Implementation file 06 - Inherit.fs rename to ReSharper.FSharp/test/data/ai/summarizer/Inherit 01.fs index 05e76d5647..ba71233330 100644 --- a/ReSharper.FSharp/test/data/ai/summarizer/Implementation file 06 - Inherit.fs +++ b/ReSharper.FSharp/test/data/ai/summarizer/Inherit 01.fs @@ -1,3 +1,4 @@ +open System open System.Collections.Generic type Class1() = @@ -11,8 +12,10 @@ type Class2() = type Interface1 = interface inherit IList + inherit IDisposable end [] type Interface2 = inherit IList + inherit System.IDisposable diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Inherit 01.gold b/ReSharper.FSharp/test/data/ai/summarizer/Inherit 01.gold new file mode 100644 index 0000000000..9873710f8d --- /dev/null +++ b/ReSharper.FSharp/test/data/ai/summarizer/Inherit 01.gold @@ -0,0 +1,6 @@ +type Class1 inherit List (4-5) +type Class1 new: unit -> Class1 (4-4) +type Class2 inherit List (7-10) +type Class2 new: unit -> Class2 (7-7) +type Interface1 inherit IList, IDisposable (12-16) +type Interface2 inherit IList, IDisposable (18-21) diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Let bindings 01.fs b/ReSharper.FSharp/test/data/ai/summarizer/Let bindings 01.fs new file mode 100644 index 0000000000..5d59c5e57b --- /dev/null +++ b/ReSharper.FSharp/test/data/ai/summarizer/Let bindings 01.fs @@ -0,0 +1,7 @@ +module Module = + + let x = 5 + let f x = 1 + let (+) a b = a + b + let (|One|_|) (x: int) = Some(1) + let (Some(some)) = Some(1) diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Let bindings 01.gold b/ReSharper.FSharp/test/data/ai/summarizer/Let bindings 01.gold new file mode 100644 index 0000000000..2a963f7772 --- /dev/null +++ b/ReSharper.FSharp/test/data/ai/summarizer/Let bindings 01.gold @@ -0,0 +1,5 @@ +module Module (1-7) +module Module val x: int (3-3) +module Module val f: x: 'a -> int (4-4) +module Module val (+): a: int -> b: int -> int (5-5) +module Module val (|One|_|): x: int -> int option (6-6) diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Let bindings 02 - Signatures.fsi b/ReSharper.FSharp/test/data/ai/summarizer/Let bindings 02 - Signatures.fsi new file mode 100644 index 0000000000..5632cbe39e --- /dev/null +++ b/ReSharper.FSharp/test/data/ai/summarizer/Let bindings 02 - Signatures.fsi @@ -0,0 +1,6 @@ +module Module + +val x: int +val f: x: 'a -> 'a +val (+) : a: int -> b: int -> int +val (|One|_|) : x: 'a -> 'a option diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Let bindings 02 - Signatures.gold b/ReSharper.FSharp/test/data/ai/summarizer/Let bindings 02 - Signatures.gold new file mode 100644 index 0000000000..6002f72c5a --- /dev/null +++ b/ReSharper.FSharp/test/data/ai/summarizer/Let bindings 02 - Signatures.gold @@ -0,0 +1,5 @@ +module Module (1-6) +val x: int (3-3) +val f: x: 'a -> 'a (4-4) +val (+): a: int -> b: int -> int (5-5) +val (|One|_|): x: 'a -> 'a option (6-6) diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Members 01.fs b/ReSharper.FSharp/test/data/ai/summarizer/Members 01.fs new file mode 100644 index 0000000000..687011b94a --- /dev/null +++ b/ReSharper.FSharp/test/data/ai/summarizer/Members 01.fs @@ -0,0 +1,11 @@ +module Module + +type Type() = + static let x = 4 + new (x: int) = Type() + member _.M1 x = x + 1 + member private _.M2 x y = x(y) + member _.M3 (x, ?y) = y.Value + 1 + member _.Prop1 = 5 + member val Prop2 = 5 with get, set + member _.Prop3 with get () = 5 and set (x: int) = () diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Members 01.gold b/ReSharper.FSharp/test/data/ai/summarizer/Members 01.gold new file mode 100644 index 0000000000..250f5e6024 --- /dev/null +++ b/ReSharper.FSharp/test/data/ai/summarizer/Members 01.gold @@ -0,0 +1,11 @@ +module Module (1-11) +type Type (3-11) +type Type new: unit -> Type (3-3) +type Type val x: int (4-4) +type Type new: x: int -> Type (5-5) +type Type member M1: x: int -> int (6-6) +type Type member M2: x: ('b -> 'c) -> y: 'b -> 'c (7-7) +type Type member M3: x: 'a * ?y: int -> int (8-8) +type Type member Prop1: int (9-9) +type Type member Prop2: int with get, set (10-10) +type Type member Prop3: int with get, set (11-11) diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Members 02 - Interface impl.gold b/ReSharper.FSharp/test/data/ai/summarizer/Members 02 - Interface impl.gold new file mode 100644 index 0000000000..78db4d8c32 --- /dev/null +++ b/ReSharper.FSharp/test/data/ai/summarizer/Members 02 - Interface impl.gold @@ -0,0 +1,6 @@ +module Module (1-8) +type Type (3-8) +type Type interface IList (4-5) +type Type interface IList member Add: x: int -> unit (5-5) +type Type interface IDisposable (7-8) +type Type interface IDisposable member Dispose: unit -> unit (8-8) diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Members 02 - Interface impls.fs b/ReSharper.FSharp/test/data/ai/summarizer/Members 02 - Interface impls.fs new file mode 100644 index 0000000000..d3d826097d --- /dev/null +++ b/ReSharper.FSharp/test/data/ai/summarizer/Members 02 - Interface impls.fs @@ -0,0 +1,8 @@ +module Module + +type Type = + interface System.Collections.Generic.IList with + member this.Add(x) = () + + interface System.IDisposable with + member this.Dispose() = () diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Members 02 - Interface impls.gold b/ReSharper.FSharp/test/data/ai/summarizer/Members 02 - Interface impls.gold new file mode 100644 index 0000000000..78db4d8c32 --- /dev/null +++ b/ReSharper.FSharp/test/data/ai/summarizer/Members 02 - Interface impls.gold @@ -0,0 +1,6 @@ +module Module (1-8) +type Type (3-8) +type Type interface IList (4-5) +type Type interface IList member Add: x: int -> unit (5-5) +type Type interface IDisposable (7-8) +type Type interface IDisposable member Dispose: unit -> unit (8-8) diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Members 03 - Signatures.fsi b/ReSharper.FSharp/test/data/ai/summarizer/Members 03 - Signatures.fsi new file mode 100644 index 0000000000..69c3861fd1 --- /dev/null +++ b/ReSharper.FSharp/test/data/ai/summarizer/Members 03 - Signatures.fsi @@ -0,0 +1,9 @@ +module Module + +type Type = + inherit ResizeArray + interface System.Collections.Generic.IEnumerable + + new: unit -> Type + member Method: x: int * y: int * int -> unit + member Prop: int with get, set diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Members 03 - Signatures.gold b/ReSharper.FSharp/test/data/ai/summarizer/Members 03 - Signatures.gold new file mode 100644 index 0000000000..b089de2c22 --- /dev/null +++ b/ReSharper.FSharp/test/data/ai/summarizer/Members 03 - Signatures.gold @@ -0,0 +1,6 @@ +module Module (1-9) +type Type inherit ResizeArray (3-9) +type Type interface IEnumerable (5-5) +type Type new: unit -> Type (7-7) +type Type member Method: x: int * y: int * int -> unit (8-8) +type Type member Prop: int (9-9) diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Modules 01.fs b/ReSharper.FSharp/test/data/ai/summarizer/Modules 01.fs new file mode 100644 index 0000000000..b1b3e9a9af --- /dev/null +++ b/ReSharper.FSharp/test/data/ai/summarizer/Modules 01.fs @@ -0,0 +1,5 @@ +module Module1 = + type Type1 = class end + +module Module2 = + type Type2 = class end diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Modules 01.gold b/ReSharper.FSharp/test/data/ai/summarizer/Modules 01.gold new file mode 100644 index 0000000000..2ed323326d --- /dev/null +++ b/ReSharper.FSharp/test/data/ai/summarizer/Modules 01.gold @@ -0,0 +1,4 @@ +module Module1 (1-2) +module Module1 type Type1 (2-2) +module Module2 (4-5) +module Module2 type Type2 (5-5) diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Modules 02 - Top-level.fs b/ReSharper.FSharp/test/data/ai/summarizer/Modules 02 - Top-level.fs new file mode 100644 index 0000000000..558feb11dc --- /dev/null +++ b/ReSharper.FSharp/test/data/ai/summarizer/Modules 02 - Top-level.fs @@ -0,0 +1,4 @@ +[] +module Module.One + +type Type1 = class end diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Modules 02 - Top-level.gold b/ReSharper.FSharp/test/data/ai/summarizer/Modules 02 - Top-level.gold new file mode 100644 index 0000000000..666abadca7 --- /dev/null +++ b/ReSharper.FSharp/test/data/ai/summarizer/Modules 02 - Top-level.gold @@ -0,0 +1,2 @@ +module Module.One (1-4) +type Type1 (4-4) diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Namespaces 01.fs b/ReSharper.FSharp/test/data/ai/summarizer/Namespaces 01.fs new file mode 100644 index 0000000000..d09a196ba6 --- /dev/null +++ b/ReSharper.FSharp/test/data/ai/summarizer/Namespaces 01.fs @@ -0,0 +1,11 @@ +namespace global + +type GlobalType = class end + +namespace Namespace.One + +type Type1 = class end + +namespace Namespace.Two + +type Type2 = class end diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Namespaces 01.gold b/ReSharper.FSharp/test/data/ai/summarizer/Namespaces 01.gold new file mode 100644 index 0000000000..9a3bf48df5 --- /dev/null +++ b/ReSharper.FSharp/test/data/ai/summarizer/Namespaces 01.gold @@ -0,0 +1,6 @@ +namespace global (1-3) +type GlobalType (3-3) +namespace Namespace.One (5-7) +type Type1 (7-7) +namespace Namespace.Two (9-11) +type Type2 (11-11) diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Nested scopes 01.fs b/ReSharper.FSharp/test/data/ai/summarizer/Nested scopes 01.fs new file mode 100644 index 0000000000..5a2312c055 --- /dev/null +++ b/ReSharper.FSharp/test/data/ai/summarizer/Nested scopes 01.fs @@ -0,0 +1,9 @@ +namespace N.N1 + +open System + +module M1 = + module M2 = + type T = + interface IDisposable with + member _.Dispose() = () diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Nested scopes 01.gold b/ReSharper.FSharp/test/data/ai/summarizer/Nested scopes 01.gold new file mode 100644 index 0000000000..03ea649b94 --- /dev/null +++ b/ReSharper.FSharp/test/data/ai/summarizer/Nested scopes 01.gold @@ -0,0 +1,6 @@ +namespace N.N1 (1-9) +module M1 (5-9) +module M1.M2 (6-9) +module M1.M2 type T (7-9) +module M1.M2 type T interface IDisposable (8-9) +module M1.M2 type T interface IDisposable member Dispose: unit -> unit (9-9) diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Implementation file 07 - Syntax error.fs b/ReSharper.FSharp/test/data/ai/summarizer/Syntax error 01.fs similarity index 100% rename from ReSharper.FSharp/test/data/ai/summarizer/Implementation file 07 - Syntax error.fs rename to ReSharper.FSharp/test/data/ai/summarizer/Syntax error 01.fs diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Implementation file 07 - Syntax error.gold b/ReSharper.FSharp/test/data/ai/summarizer/Syntax error 01.gold similarity index 100% rename from ReSharper.FSharp/test/data/ai/summarizer/Implementation file 07 - Syntax error.gold rename to ReSharper.FSharp/test/data/ai/summarizer/Syntax error 01.gold diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Implementation file 04 - Type parameters.fs b/ReSharper.FSharp/test/data/ai/summarizer/Type parameters 01.fs similarity index 88% rename from ReSharper.FSharp/test/data/ai/summarizer/Implementation file 04 - Type parameters.fs rename to ReSharper.FSharp/test/data/ai/summarizer/Type parameters 01.fs index 7cf077dd3c..3912bb4d1b 100644 --- a/ReSharper.FSharp/test/data/ai/summarizer/Implementation file 04 - Type parameters.fs +++ b/ReSharper.FSharp/test/data/ai/summarizer/Type parameters 01.fs @@ -1,7 +1,7 @@ open System.Collections.Generic [] -type A<'t> = +type A<'a, 'b when 'b :> IDisposable> = inherit IList> inherit IList inherit IList<(int * int) * int> diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Type parameters 01.gold b/ReSharper.FSharp/test/data/ai/summarizer/Type parameters 01.gold new file mode 100644 index 0000000000..7aa1ed8841 --- /dev/null +++ b/ReSharper.FSharp/test/data/ai/summarizer/Type parameters 01.gold @@ -0,0 +1 @@ +type A<'a, 'b> inherit IList>, IList, IList<(int * int) * int>, IList, IList<'a>, IList<(int -> int)>, IList<{| Kek: int; Lol: string |}> (3-12) diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Types 01.fs b/ReSharper.FSharp/test/data/ai/summarizer/Types 01.fs new file mode 100644 index 0000000000..8bdd2276d4 --- /dev/null +++ b/ReSharper.FSharp/test/data/ai/summarizer/Types 01.fs @@ -0,0 +1,27 @@ +module Module + +[] +type Interface = + abstract member M: x: int -> unit + +exception E1 of string + with member x.NewMessage = "" + +type Record = { + Field1: int + Field2: int +} + +type DU = + | Case1 of int + | Case2 + +type Struct = + struct + val X: float + val Y: float + new(x: float, y: float) = { X = x; Y = y } + end + +type System.Collections.Generic.List<'a> with + member x.Length = x.Count diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Types 01.gold b/ReSharper.FSharp/test/data/ai/summarizer/Types 01.gold new file mode 100644 index 0000000000..16c055076d --- /dev/null +++ b/ReSharper.FSharp/test/data/ai/summarizer/Types 01.gold @@ -0,0 +1,11 @@ +module Module (1-27) +type Interface (3-5) +type Interface member M: x: int -> unit (5-5) +exception E1 (7-8) +exception E1 member NewMessage: string (8-8) +type Record (10-13) +type DU (15-17) +type Struct (19-24) +type Struct new: x: float * y: float -> Struct (23-23) +type List<'a> with (26-27) +type List<'a> member Length: int (27-27) diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Implementation file 03 - Unresolved type.fs b/ReSharper.FSharp/test/data/ai/summarizer/Unresolved type 01.fs similarity index 100% rename from ReSharper.FSharp/test/data/ai/summarizer/Implementation file 03 - Unresolved type.fs rename to ReSharper.FSharp/test/data/ai/summarizer/Unresolved type 01.fs diff --git a/ReSharper.FSharp/test/data/ai/summarizer/Implementation file 03 - Unresolved type.gold b/ReSharper.FSharp/test/data/ai/summarizer/Unresolved type 01.gold similarity index 100% rename from ReSharper.FSharp/test/data/ai/summarizer/Implementation file 03 - Unresolved type.gold rename to ReSharper.FSharp/test/data/ai/summarizer/Unresolved type 01.gold diff --git a/ReSharper.FSharp/test/src/FSharp.Tests/AICore/FSharpFileSummarizerTest.fs b/ReSharper.FSharp/test/src/FSharp.Tests/AI/FSharpFileSummarizerTest.fs similarity index 56% rename from ReSharper.FSharp/test/src/FSharp.Tests/AICore/FSharpFileSummarizerTest.fs rename to ReSharper.FSharp/test/src/FSharp.Tests/AI/FSharpFileSummarizerTest.fs index 3b2ba8ad56..2b4ff75567 100644 --- a/ReSharper.FSharp/test/src/FSharp.Tests/AICore/FSharpFileSummarizerTest.fs +++ b/ReSharper.FSharp/test/src/FSharp.Tests/AI/FSharpFileSummarizerTest.fs @@ -1,4 +1,4 @@ -namespace JetBrains.ReSharper.Plugins.FSharp.Tests.Features.AICore +namespace JetBrains.ReSharper.Plugins.FSharp.Tests.Features.AI open JetBrains.Lifetimes open JetBrains.ProjectModel @@ -16,14 +16,24 @@ type FSharpFileSummarizerTest() = override x.RelativeTestDataPath = "ai/summarizer" - [] member x.``Implementation file 01``() = x.DoNamedTestWithFs() - [] member x.``Implementation file 02 - Top level module``() = x.DoNamedTestWithFs() - [] member x.``Implementation file 03 - Unresolved type``() = x.DoNamedTestWithFs() - [] member x.``Implementation file 04 - Type parameters``() = x.DoNamedTestWithFs() - [] member x.``Implementation file 05 - Type parameters``() = x.DoNamedTestWithFs() - [] member x.``Implementation file 06 - Inherit``() = x.DoNamedTestWithFs() - [] member x.``Implementation file 07 - Syntax error``() = x.DoNamedTestWithFs() - [] member x.``Signature file 01``() = x.DoNamedTestWithFsi() + [] member x.``Namespaces 01``() = x.DoNamedTestWithFs() + [] member x.``Modules 01``() = x.DoNamedTestWithFs() + [] member x.``Modules 02 - Top-level``() = x.DoNamedTestWithFs() + + [] member x.``Let bindings 01``() = x.DoNamedTestWithFs() + [] member x.``Let bindings 02 - Signatures``() = x.DoNamedTestWithFsi() + + [] member x.``Types 01``() = x.DoNamedTestWithFs() + [] member x.``Inherit 01``() = x.DoNamedTestWithFs() + + [] member x.``Members 01``() = x.DoNamedTestWithFs() + [] member x.``Members 02 - Interface impls``() = x.DoNamedTestWithFs() + [] member x.``Members 03 - Signatures``() = x.DoNamedTestWithFsi() + + [] member x.``Nested scopes 01``() = x.DoNamedTestWithFs() + [] member x.``Unresolved type 01``() = x.DoNamedTestWithFs() + [] member x.``Type parameters 01``() = x.DoNamedTestWithFs() + [] member x.``Syntax error 01``() = x.DoNamedTestWithFs() override x.DoTest(_: Lifetime, project: IProject) = let psiServices = x.Solution.GetPsiServices() diff --git a/ReSharper.FSharp/test/src/FSharp.Tests/FSharp.Tests.fsproj b/ReSharper.FSharp/test/src/FSharp.Tests/FSharp.Tests.fsproj index 6c1dc93008..1d353bccb7 100644 --- a/ReSharper.FSharp/test/src/FSharp.Tests/FSharp.Tests.fsproj +++ b/ReSharper.FSharp/test/src/FSharp.Tests/FSharp.Tests.fsproj @@ -42,7 +42,7 @@ - +