From 8ad0ec95d66ffc601412f73a7ff0a3fbc21960b4 Mon Sep 17 00:00:00 2001 From: Eugene Auduchinok Date: Fri, 22 May 2026 15:16:23 +0200 Subject: [PATCH 1/3] RIDER-24878 Implement a basic declared element presenter for F# GitOrigin-RevId: ccdaa7f812cf6493e2ac7a5d08e7404a3aae7f19 --- .../FSharp.Psi.Features.fsproj | 1 + .../Rules/NameSuggestionRule.fs | 2 +- .../FSharpDeclaredElementIconProvider.fs | 3 +- .../FSharpDeclaredElementPresenter.fs | 36 +++++++++++++++++++ .../LanguageService/FSharpLanguageService.fs | 3 +- .../NewRecordPostfixTemplate.fs | 2 +- .../src/Search/RecordCtorSearch.fs | 4 +-- .../GenerateMissingRecordFieldsFix.fs | 2 +- .../src/Refactorings/Rename.fs | 2 +- .../src/Util/ObjExprUtil.fs | 2 +- .../src/Util/RecordExprUtil.fs | 2 +- .../FSharp.Psi/src/IFSharpDeclaredElement.cs | 1 + .../Compiled/FSharpCompiledClassBase.cs | 23 ++++++------ .../Cache2/Compiled/FSharpCompiledDelegate.cs | 2 ++ .../Cache2/Compiled/FSharpCompiledEnum.cs | 2 ++ .../Compiled/FSharpCompiledInterface.cs | 2 ++ .../Cache2/Compiled/FSharpCompiledModule.cs | 2 ++ .../Cache2/Compiled/FSharpCompiledStruct.cs | 2 ++ .../FSharp.Psi/src/Impl/Cache2/FSharpClass.cs | 2 +- .../FSharpClassOrProvidedTypeAbbreviation.cs | 12 +++++-- .../src/Impl/Cache2/FSharpDelegate.cs | 1 + .../FSharp.Psi/src/Impl/Cache2/FSharpEnum.cs | 2 ++ .../src/Impl/Cache2/FSharpInterface.cs | 1 + .../src/Impl/Cache2/FSharpModule.cs | 1 + .../Cache2/FSharpObjectExpressionClass.cs | 2 ++ .../src/Impl/Cache2/FSharpStruct.cs | 1 + .../src/Impl/Cache2/FSharpUnionCaseClass.cs | 2 ++ .../Compiled/CompiledActivePatternCase.cs | 30 ++++++---------- .../FSharpGeneratedElementBase.cs | 1 + .../FSharpAnonRecordFieldProperty.cs | 11 +++--- .../Impl/DeclaredElement/FSharpFieldBase.cs | 2 ++ .../DeclaredElement/FSharpFieldProperty.cs | 6 ++-- .../src/Impl/DeclaredElement/FSharpLiteral.cs | 7 ++-- .../Impl/DeclaredElement/FSharpMemberBase.cs | 7 ++-- .../src/Impl/DeclaredElement/FSharpMethod.cs | 18 ++++------ .../FSharpMethodParameterBase.cs | 1 + .../Impl/DeclaredElement/FSharpTypeMember.cs | 9 +++-- .../FSharpUnionCaseProperty.cs | 2 ++ .../Impl/DeclaredElement/ModuleFunction.cs | 15 ++++---- .../src/Impl/DeclaredElement/ModuleValue.cs | 2 ++ .../DeclaredElement/TopActivePatternCase.cs | 10 +++--- .../src/Impl/FSharpDeclaredElementType.cs | 20 +++++++---- .../FSharp.Psi/src/Impl/FSharpImplUtil.cs | 23 ++++++++++-- .../src/Impl/FSharpReferenceBindingUtil.cs | 2 +- .../src/Impl/Tree/LocalDeclaration.cs | 4 ++- .../src/Searching/FSharpSearcherFactory.cs | 2 +- .../src/Util/FcsSymbolMappingUtil.cs | 2 +- .../navigation/declaration/Module 01.fs | 6 ++++ .../navigation/declaration/Module 01.fs.gold | 35 ++++++++++++++++++ .../navigation/declaration/Module 01.fsi | 4 +++ .../navigation/declaration/Module 02.fs | 9 +++++ .../navigation/declaration/Module 02.fs.gold | 35 ++++++++++++++++++ .../navigation/declaration/Module 02.fsi | 7 ++++ .../declaration/Record - Field 01.fs | 7 ++++ .../declaration/Record - Field 01.fs.gold | 34 ++++++++++++++++++ .../declaration/Record - Field 01.fsi | 4 +++ .../declaration/Record - Field 02.fs | 6 ++++ .../declaration/Record - Field 02.fs.gold | 34 ++++++++++++++++++ .../declaration/Record - Field 02.fsi | 4 +++ .../declaration/Signature 01.fs.gold | 2 +- .../Signature 02 - Same range.fs.gold | 2 +- .../Union - Case - Empty 01 - Expr.fs | 2 ++ .../Union - Case - Empty 01 - Expr.fs.gold | 26 ++++++++++++-- .../Union - Case - Empty 01 - Expr.fsi | 5 +++ .../Union - Case - Empty 02 - Pattern.fs | 2 ++ .../Union - Case - Empty 02 - Pattern.fs.gold | 26 ++++++++++++-- .../Union - Case - Empty 02 - Pattern.fsi | 5 +++ .../Union - Case - Fields 01 - Expr.fs | 2 ++ .../Union - Case - Fields 01 - Expr.fs.gold | 26 ++++++++++++-- .../Union - Case - Fields 01 - Expr.fsi | 5 +++ .../Union - Case - Fields 02 - Pattern.fs | 2 ++ ...Union - Case - Fields 02 - Pattern.fs.gold | 26 ++++++++++++-- .../Union - Case - Fields 02 - Pattern.fsi | 5 +++ ...nion - Case - Single - Fields 01 - Expr.fs | 2 ++ ...- Case - Single - Fields 01 - Expr.fs.gold | 25 +++++++++++-- ...ion - Case - Single - Fields 01 - Expr.fsi | 4 +++ ...n - Case - Single - Fields 01 - Pattern.fs | 2 ++ ...ase - Single - Fields 01 - Pattern.fs.gold | 25 +++++++++++-- ... - Case - Single - Fields 01 - Pattern.fsi | 4 +++ .../quickdoc/ActivePattern 01.fs.gold | 2 +- .../quickdoc/ActivePattern 02.fs.gold | 2 +- .../quickdoc/Partial ActivePattern 01.fs.gold | 2 +- .../quickdoc/Partial ActivePattern 02.fs.gold | 2 +- .../test/src/FSharp.Tests/NavigationTests.fs | 20 ++++++----- 84 files changed, 568 insertions(+), 134 deletions(-) create mode 100644 ReSharper.FSharp/src/FSharp/FSharp.Psi.Features/src/LanguageService/FSharpDeclaredElementPresenter.fs create mode 100644 ReSharper.FSharp/test/data/features/navigation/declaration/Module 01.fs create mode 100644 ReSharper.FSharp/test/data/features/navigation/declaration/Module 01.fs.gold create mode 100644 ReSharper.FSharp/test/data/features/navigation/declaration/Module 01.fsi create mode 100644 ReSharper.FSharp/test/data/features/navigation/declaration/Module 02.fs create mode 100644 ReSharper.FSharp/test/data/features/navigation/declaration/Module 02.fs.gold create mode 100644 ReSharper.FSharp/test/data/features/navigation/declaration/Module 02.fsi create mode 100644 ReSharper.FSharp/test/data/features/navigation/declaration/Record - Field 01.fs create mode 100644 ReSharper.FSharp/test/data/features/navigation/declaration/Record - Field 01.fs.gold create mode 100644 ReSharper.FSharp/test/data/features/navigation/declaration/Record - Field 01.fsi create mode 100644 ReSharper.FSharp/test/data/features/navigation/declaration/Record - Field 02.fs create mode 100644 ReSharper.FSharp/test/data/features/navigation/declaration/Record - Field 02.fs.gold create mode 100644 ReSharper.FSharp/test/data/features/navigation/declaration/Record - Field 02.fsi create mode 100644 ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Empty 01 - Expr.fsi create mode 100644 ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Empty 02 - Pattern.fsi create mode 100644 ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Fields 01 - Expr.fsi create mode 100644 ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Fields 02 - Pattern.fsi create mode 100644 ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Single - Fields 01 - Expr.fsi create mode 100644 ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Single - Fields 01 - Pattern.fsi diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi.Features/FSharp.Psi.Features.fsproj b/ReSharper.FSharp/src/FSharp/FSharp.Psi.Features/FSharp.Psi.Features.fsproj index 2664767876..167bbd6d86 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi.Features/FSharp.Psi.Features.fsproj +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi.Features/FSharp.Psi.Features.fsproj @@ -103,6 +103,7 @@ + diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi.Features/src/CodeCompletion/Rules/NameSuggestionRule.fs b/ReSharper.FSharp/src/FSharp/FSharp.Psi.Features/src/CodeCompletion/Rules/NameSuggestionRule.fs index 7f54958ef7..50f2a8b61c 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi.Features/src/CodeCompletion/Rules/NameSuggestionRule.fs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi.Features/src/CodeCompletion/Rules/NameSuggestionRule.fs @@ -97,7 +97,7 @@ type NameSuggestionFromAsInstanceOfRule() = isNotNull isInstType && let typeElement = isInstType.GetTypeElement() - isNotNull typeElement && typeElement.IsUnion() + isNotNull typeElement && typeElement.IsFSharpUnion() collector.RemoveWhere(fun item -> match item with diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi.Features/src/LanguageService/FSharpDeclaredElementIconProvider.fs b/ReSharper.FSharp/src/FSharp/FSharp.Psi.Features/src/LanguageService/FSharpDeclaredElementIconProvider.fs index 05b73f986c..2b451d8644 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi.Features/src/LanguageService/FSharpDeclaredElementIconProvider.fs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi.Features/src/LanguageService/FSharpDeclaredElementIconProvider.fs @@ -6,7 +6,6 @@ open JetBrains.ReSharper.Plugins.FSharp.Psi open JetBrains.ReSharper.Plugins.FSharp.Psi.Impl open JetBrains.ReSharper.Plugins.FSharp.Psi.Impl.Cache2 open JetBrains.ReSharper.Plugins.FSharp.Psi.Impl.Cache2.Parts -open JetBrains.ReSharper.Plugins.FSharp.Psi.Impl.DeclaredElement open JetBrains.ReSharper.Plugins.FSharp.Util open JetBrains.ReSharper.Psi open JetBrains.ReSharper.Psi.ExtensionsAPI.Caches2 @@ -68,7 +67,7 @@ type FSharpDeclaredElementIconProvider() = PsiSymbolsThemedIcons.Class.Id | :? TypeElement as typeElement when - typeElement.PresentationLanguage.Is() && typeElement.IsUnion() -> + typeElement.PresentationLanguage.Is() && typeElement.IsFSharpUnion() -> PsiSymbolsThemedIcons.Enum.Id | :? IFSharpFieldProperty as fieldProp -> diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi.Features/src/LanguageService/FSharpDeclaredElementPresenter.fs b/ReSharper.FSharp/src/FSharp/FSharp.Psi.Features/src/LanguageService/FSharpDeclaredElementPresenter.fs new file mode 100644 index 0000000000..c3787e78d1 --- /dev/null +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi.Features/src/LanguageService/FSharpDeclaredElementPresenter.fs @@ -0,0 +1,36 @@ +namespace JetBrains.ReSharper.Plugins.FSharp.Psi.Features.LanguageService + +open JetBrains.ReSharper.Plugins.FSharp.Psi +open JetBrains.ReSharper.Psi +open JetBrains.ReSharper.Psi.CSharp.Impl + +type FSharpDeclaredElementPresenter() = + inherit CSharpDeclaredElementPresenter() + + let unwrapGenerated (declaredElement: IDeclaredElement) = + match declaredElement with + | :? IFSharpGeneratedFromOtherElement as generatedElement -> + let originElement = generatedElement.OriginElement + if isNull originElement then declaredElement else originElement + | _ -> + declaredElement + + static member val Instance = FSharpDeclaredElementPresenter() + + override this.Format(style, declaredElement, substitution, marking) = + let element = unwrapGenerated declaredElement + base.Format(style, element, substitution, &marking) + + override this.GetEntityKind(declaredElement) = + let element = unwrapGenerated declaredElement + let elementType = + match element with + | :? IFSharpDeclaredElement as fsDeclaredElement -> + let elementType = fsDeclaredElement.FSharpElementType + if isNotNull elementType then elementType else null + + | _ -> null + + match elementType with + | null -> base.GetEntityKind(declaredElement) + | elementType -> elementType.PresentableName diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi.Features/src/LanguageService/FSharpLanguageService.fs b/ReSharper.FSharp/src/FSharp/FSharp.Psi.Features/src/LanguageService/FSharpLanguageService.fs index 8af2377c6a..3d067cf891 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi.Features/src/LanguageService/FSharpLanguageService.fs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi.Features/src/LanguageService/FSharpLanguageService.fs @@ -18,7 +18,6 @@ open JetBrains.ReSharper.Plugins.FSharp.Psi.Resolve open JetBrains.ReSharper.Plugins.FSharp.Psi.Tree open JetBrains.ReSharper.Plugins.FSharp.Psi.Util open JetBrains.ReSharper.Psi -open JetBrains.ReSharper.Psi.CSharp.Impl open JetBrains.ReSharper.Psi.Impl open JetBrains.ReSharper.Psi.Modules open JetBrains.ReSharper.Psi.Parsing @@ -56,7 +55,7 @@ type FSharpLanguageService(languageType, constantValueService, cacheProvider: FS | _ -> true override x.TypePresenter = CLRTypePresenter.Instance - override x.DeclaredElementPresenter = CSharpDeclaredElementPresenter.Instance :> _ // todo: implement F# presenter + override x.DeclaredElementPresenter = FSharpDeclaredElementPresenter.Instance :> _ override x.FindTypeDeclarations _ = EmptyList.Instance :> _ diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi.Features/src/PostfixTemplates/NewRecordPostfixTemplate.fs b/ReSharper.FSharp/src/FSharp/FSharp.Psi.Features/src/PostfixTemplates/NewRecordPostfixTemplate.fs index f0351f58a0..24de58b212 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi.Features/src/PostfixTemplates/NewRecordPostfixTemplate.fs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi.Features/src/PostfixTemplates/NewRecordPostfixTemplate.fs @@ -33,7 +33,7 @@ type NewRecordPostfixTemplate() = match refExpr.Qualifier with | :? IReferenceExpr as refExpr -> let typeElement = refExpr.Reference.Resolve().DeclaredElement.As() - typeElement.IsRecord() + typeElement.IsFSharpRecord() | _ -> false override this.IsEnabled _ = true diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi.Features/src/Search/RecordCtorSearch.fs b/ReSharper.FSharp/src/FSharp/FSharp.Psi.Features/src/Search/RecordCtorSearch.fs index 9dab8d2cc3..2404c16781 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi.Features/src/Search/RecordCtorSearch.fs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi.Features/src/Search/RecordCtorSearch.fs @@ -20,13 +20,13 @@ type RecordCtorSearchFactory() = override x.GetAllPossibleWordsInFile(declaredElement) = match declaredElement with - | :? ITypeElement as typeElement when typeElement.IsRecord() -> typeElement.GetRecordFieldNames() :> _ + | :? ITypeElement as typeElement when typeElement.IsFSharpRecord() -> typeElement.GetRecordFieldNames() :> _ | _ -> EmptyList.Instance :> _ override x.CreateReferenceSearcher(declaredElements, findCandidates) = let recordTypeElements = declaredElements.FilterByType() - |> Seq.filter (fun typeElement -> typeElement.IsRecord()) + |> Seq.filter (fun typeElement -> typeElement.IsFSharpRecord()) |> Array.ofSeq if recordTypeElements.IsEmpty() then null else diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi.Intentions/src/QuickFixes/GenerateMissingRecordFieldsFix.fs b/ReSharper.FSharp/src/FSharp/FSharp.Psi.Intentions/src/QuickFixes/GenerateMissingRecordFieldsFix.fs index 04e4d0debc..03b1025b57 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi.Intentions/src/QuickFixes/GenerateMissingRecordFieldsFix.fs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi.Intentions/src/QuickFixes/GenerateMissingRecordFieldsFix.fs @@ -36,7 +36,7 @@ type GenerateMissingRecordFieldsFix(recordExpr: IRecordExpr) = override x.ExecutePsiTransaction(_, _) = let typeElement = recordExpr.Reference.Resolve().DeclaredElement :?> ITypeElement - Assertion.Assert(typeElement.IsRecord(), "Expecting record type") + Assertion.Assert(typeElement.IsFSharpRecord(), "Expecting record type") let generatedBindings = RecordExprUtil.generateBindings typeElement recordExpr diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi.Services/src/Refactorings/Rename.fs b/ReSharper.FSharp/src/FSharp/FSharp.Psi.Services/src/Refactorings/Rename.fs index 81459c9e9f..80a21ded74 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi.Services/src/Refactorings/Rename.fs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi.Services/src/Refactorings/Rename.fs @@ -282,7 +282,7 @@ type SingleUnionCaseRenameEvaluator() = member x.CreateFromElement(initialElement, _, _) = let isApplicable (typeElement: ITypeElement) = - typeElement.IsUnion() && + typeElement.IsFSharpUnion() && let sourceName = typeElement.GetSourceName() sourceName <> SharedImplUtil.MISSING_DECLARATION_NAME && diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi.Services/src/Util/ObjExprUtil.fs b/ReSharper.FSharp/src/FSharp/FSharp.Psi.Services/src/Util/ObjExprUtil.fs index 3053b4b8c3..79171643ef 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi.Services/src/Util/ObjExprUtil.fs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi.Services/src/Util/ObjExprUtil.fs @@ -47,7 +47,7 @@ module NewObjPostfixTemplate = let isApplicableType (typeElement: ITypeElement) = (typeElement :? IClass || typeElement :? IInterface) && - not (typeElement.IsRecord() || typeElement.IsUnion()) + not (typeElement.IsFSharpRecord() || typeElement.IsFSharpUnion()) let isApplicableExpr (expr: IFSharpExpression) = let reference = getReference expr diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi.Services/src/Util/RecordExprUtil.fs b/ReSharper.FSharp/src/FSharp/FSharp.Psi.Services/src/Util/RecordExprUtil.fs index 5417516b37..864e7fb759 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi.Services/src/Util/RecordExprUtil.fs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi.Services/src/Util/RecordExprUtil.fs @@ -147,7 +147,7 @@ let private generateUnorderedBindings recordExpr (existingBindings: TreeNodeColl generateBindingsImpl recordExpr indexedBindings declaredFields let generateBindings (recordTypeElement: ITypeElement) (recordExpr: IRecordExpr) : IRecordFieldBinding seq = - Assertion.Assert(recordTypeElement.IsRecord(), "Expecting record type") + Assertion.Assert(recordTypeElement.IsFSharpRecord(), "Expecting record type") let fieldNames = recordTypeElement.GetRecordFieldNames() let existingBindings = recordExpr.FieldBindings diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/IFSharpDeclaredElement.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/IFSharpDeclaredElement.cs index 215c503320..93328e5985 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/IFSharpDeclaredElement.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/IFSharpDeclaredElement.cs @@ -13,6 +13,7 @@ namespace JetBrains.ReSharper.Plugins.FSharp.Psi public interface IFSharpDeclaredElement : IClrDeclaredElement { string SourceName { get; } + [CanBeNull] DeclaredElementType FSharpElementType { get; } } public interface IFSharpTypeElement : IFSharpDeclaredElement, ITypeElement, ITypeMember diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/Compiled/FSharpCompiledClassBase.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/Compiled/FSharpCompiledClassBase.cs index 753d9288c5..64d36ee830 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/Compiled/FSharpCompiledClassBase.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/Compiled/FSharpCompiledClassBase.cs @@ -8,24 +8,21 @@ namespace JetBrains.ReSharper.Plugins.FSharp.Psi.Impl.Cache2.Compiled { - public class FSharpCompiledClassBase : Class, IFSharpCompiledTypeElement + public abstract class FSharpCompiledClassBase( + [CanBeNull] FSharpMetadataEntity entity, + [NotNull] ICompiledEntity parent, + [NotNull] IReflectionBuilder builder, + [NotNull] IMetadataTypeInfo info) + : Class(parent, builder, info), IFSharpCompiledTypeElement { - [NotNull] private FSharpDeclaredName FSharpName { get; } - public FSharpCompiledTypeRepresentation Representation { get; } - public FSharpAccessRights FSharpAccessRights { get; } + [NotNull] private FSharpDeclaredName FSharpName { get; } = FSharpMetadataEntityModule.getCompiledModuleDeclaredName(entity); + public FSharpCompiledTypeRepresentation Representation { get; } = FSharpMetadataEntityModule.getRepresentation(entity); + public FSharpAccessRights FSharpAccessRights { get; } = entity.GetFSharpAccessRights(); public ICacheTrieNode AlternativeNameTrieNode { get; set; } - public FSharpCompiledClassBase([CanBeNull] FSharpMetadataEntity entity, [NotNull] ICompiledEntity parent, - [NotNull] IReflectionBuilder builder, - [NotNull] IMetadataTypeInfo info) : base(parent, builder, info) - { - FSharpName = FSharpMetadataEntityModule.getCompiledModuleDeclaredName(entity); - Representation = FSharpMetadataEntityModule.getRepresentation(entity); - FSharpAccessRights = entity.GetFSharpAccessRights(); - } - public string SourceName => FSharpName.SourceName; + public virtual DeclaredElementType FSharpElementType => this.TryGetFSharpDeclaredElementType(); string IAlternativeNameOwner.AlternativeName => FSharpName.AlternativeName; public virtual ModuleMembersAccessKind AccessKind => ModuleMembersAccessKind.Normal; // todo } diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/Compiled/FSharpCompiledDelegate.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/Compiled/FSharpCompiledDelegate.cs index b16cb35dc7..cc7f8853d6 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/Compiled/FSharpCompiledDelegate.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/Compiled/FSharpCompiledDelegate.cs @@ -1,6 +1,7 @@ using JetBrains.Annotations; using JetBrains.Metadata.Reader.API; using JetBrains.ReSharper.Plugins.FSharp.Metadata; +using JetBrains.ReSharper.Psi; using JetBrains.ReSharper.Psi.Caches.SymbolCache; using JetBrains.ReSharper.Psi.Impl.Reflection2; using JetBrains.ReSharper.Psi.Impl.reflection2.elements.Compiled; @@ -27,5 +28,6 @@ public FSharpCompiledDelegate([CanBeNull] FSharpMetadataEntity entity, [NotNull] public string SourceName => FSharpName.SourceName; public string AlternativeName => FSharpName.AlternativeName; public ModuleMembersAccessKind AccessKind => ModuleMembersAccessKind.Normal; // todo + public DeclaredElementType FSharpElementType => null; } } diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/Compiled/FSharpCompiledEnum.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/Compiled/FSharpCompiledEnum.cs index 36fdf2d06f..9bb7c8f8bf 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/Compiled/FSharpCompiledEnum.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/Compiled/FSharpCompiledEnum.cs @@ -1,6 +1,7 @@ using JetBrains.Annotations; using JetBrains.Metadata.Reader.API; using JetBrains.ReSharper.Plugins.FSharp.Metadata; +using JetBrains.ReSharper.Psi; using JetBrains.ReSharper.Psi.Caches.SymbolCache; using JetBrains.ReSharper.Psi.Impl.Reflection2; using JetBrains.ReSharper.Psi.Impl.reflection2.elements.Compiled; @@ -26,5 +27,6 @@ public FSharpCompiledEnum([CanBeNull] FSharpMetadataEntity entity, [NotNull] ICo public string SourceName => FSharpName.SourceName; public string AlternativeName => FSharpName.AlternativeName; public ModuleMembersAccessKind AccessKind => ModuleMembersAccessKind.RequiresQualifiedAccess; + public DeclaredElementType FSharpElementType => null; } } diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/Compiled/FSharpCompiledInterface.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/Compiled/FSharpCompiledInterface.cs index 5e8358b025..a056227b77 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/Compiled/FSharpCompiledInterface.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/Compiled/FSharpCompiledInterface.cs @@ -1,6 +1,7 @@ using JetBrains.Annotations; using JetBrains.Metadata.Reader.API; using JetBrains.ReSharper.Plugins.FSharp.Metadata; +using JetBrains.ReSharper.Psi; using JetBrains.ReSharper.Psi.Caches.SymbolCache; using JetBrains.ReSharper.Psi.Impl.Reflection2; using JetBrains.ReSharper.Psi.Impl.reflection2.elements.Compiled; @@ -27,5 +28,6 @@ public FSharpCompiledInterface([CanBeNull] FSharpMetadataEntity entity, [NotNull public string SourceName => FSharpName.SourceName; public string AlternativeName => FSharpName.AlternativeName; public ModuleMembersAccessKind AccessKind => ModuleMembersAccessKind.Normal; // todo + public DeclaredElementType FSharpElementType => null; } } diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/Compiled/FSharpCompiledModule.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/Compiled/FSharpCompiledModule.cs index e9a66dae69..525a80db50 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/Compiled/FSharpCompiledModule.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/Compiled/FSharpCompiledModule.cs @@ -168,5 +168,7 @@ private ITypeElement TryGetAssociatedTypeElement() bool HasSameName(ITypeElement typeElement) => !Equals(typeElement) && typeElement.TypeParametersCount == 0 && typeElement.GetSourceName() == sourceName; } + + public override DeclaredElementType FSharpElementType => FSharpDeclaredElementType.Module; } } diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/Compiled/FSharpCompiledStruct.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/Compiled/FSharpCompiledStruct.cs index 7d5f97959c..320e467f66 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/Compiled/FSharpCompiledStruct.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/Compiled/FSharpCompiledStruct.cs @@ -1,6 +1,7 @@ using JetBrains.Annotations; using JetBrains.Metadata.Reader.API; using JetBrains.ReSharper.Plugins.FSharp.Metadata; +using JetBrains.ReSharper.Psi; using JetBrains.ReSharper.Psi.Caches.SymbolCache; using JetBrains.ReSharper.Psi.Impl.Reflection2; using JetBrains.ReSharper.Psi.Impl.reflection2.elements.Compiled; @@ -26,5 +27,6 @@ public FSharpCompiledStruct([CanBeNull] FSharpMetadataEntity entity, [NotNull] I public string SourceName => FSharpName.SourceName; public string AlternativeName => FSharpName.AlternativeName; public ModuleMembersAccessKind AccessKind => ModuleMembersAccessKind.Normal; // todo + public DeclaredElementType FSharpElementType => this.TryGetFSharpDeclaredElementType(); } } diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/FSharpClass.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/FSharpClass.cs index 4178f4b3a9..c5718cb27d 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/FSharpClass.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/FSharpClass.cs @@ -5,7 +5,6 @@ using JetBrains.ReSharper.Psi; using JetBrains.ReSharper.Psi.ExtensionsAPI.Caches2; using JetBrains.ReSharper.Psi.Tree; -using JetBrains.ReSharper.Psi.Xml.XmlDocComments; using JetBrains.Util; namespace JetBrains.ReSharper.Plugins.FSharp.Psi.Impl.Cache2 @@ -32,6 +31,7 @@ part is IClassPart and IFSharpTypePart typePart and not IModulePart && public virtual ModuleMembersAccessKind AccessKind => EnumerateParts().GetAccessKind(); public ITypeDeclaration DefiningDeclaration => this.GetDefiningDeclaration(); + public virtual DeclaredElementType FSharpElementType => this.TryGetFSharpDeclaredElementType(); public override IClass GetSuperClass() { diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/FSharpClassOrProvidedTypeAbbreviation.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/FSharpClassOrProvidedTypeAbbreviation.cs index f7d6dbde34..59a8830ad5 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/FSharpClassOrProvidedTypeAbbreviation.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/FSharpClassOrProvidedTypeAbbreviation.cs @@ -10,7 +10,8 @@ namespace JetBrains.ReSharper.Plugins.FSharp.Psi.Impl.Cache2 { // todo: why provided type for simple union? // type T = a - public class FSharpClassOrProvidedTypeAbbreviation([NotNull] Class.IClassPart part) : FSharpClass(part), ILanguageSpecificDeclaredElement + public class FSharpClassOrProvidedTypeAbbreviation([NotNull] Class.IClassPart part) + : FSharpClass(part), ILanguageSpecificDeclaredElement { // Triggers FCS resolve private GenerativeMembersConverter ProvidedClass => @@ -53,7 +54,14 @@ ProvidedClass is { } x public override XmlNode GetXMLDoc(bool expand) => ProvidedClass is { } x ? x.GetXmlDoc(expand) : base.GetXMLDoc(expand); - bool ILanguageSpecificDeclaredElement.IsErased => + internal bool IsTypeAbbreviation => Parts is TypeAbbreviationOrDeclarationPart { IsUnionCase: false, IsProvidedAndGenerated: false }; + + bool ILanguageSpecificDeclaredElement.IsErased => IsTypeAbbreviation; + + public override DeclaredElementType FSharpElementType => + IsTypeAbbreviation + ? FSharpDeclaredElementType.TypeAbbreviation + : !IsProvidedAndGenerated ? FSharpDeclaredElementType.Union : null; } } diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/FSharpDelegate.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/FSharpDelegate.cs index 08e34f94ca..78110c662c 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/FSharpDelegate.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/FSharpDelegate.cs @@ -26,6 +26,7 @@ protected override bool AcceptsPart(TypePart part) => public ModuleMembersAccessKind AccessKind => ModuleMembersAccessKind.Normal; public ITypeDeclaration DefiningDeclaration => this.GetDefiningDeclaration(); + public DeclaredElementType FSharpElementType => null; public override string ToString() => this.TestToString(BuildTypeParameterString()); } diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/FSharpEnum.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/FSharpEnum.cs index b03578fb21..5c4d7e8b69 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/FSharpEnum.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/FSharpEnum.cs @@ -1,5 +1,6 @@ using System.Xml; using JetBrains.ReSharper.Plugins.FSharp.Psi.Impl.Cache2.Parts; +using JetBrains.ReSharper.Psi; using JetBrains.ReSharper.Psi.ExtensionsAPI.Caches2; using JetBrains.ReSharper.Psi.Tree; @@ -19,6 +20,7 @@ protected override bool AcceptsPart(TypePart part) => public ModuleMembersAccessKind AccessKind => ModuleMembersAccessKind.RequiresQualifiedAccess; public ITypeDeclaration DefiningDeclaration => this.GetDefiningDeclaration(); + public DeclaredElementType FSharpElementType => null; public override string ToString() => this.TestToString(BuildTypeParameterString()); } diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/FSharpInterface.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/FSharpInterface.cs index 4f3cb7a665..0120103dea 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/FSharpInterface.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/FSharpInterface.cs @@ -36,6 +36,7 @@ public override IList GetSuperTypeElements() public ModuleMembersAccessKind AccessKind => ModuleMembersAccessKind.Normal; public ITypeDeclaration DefiningDeclaration => this.GetDefiningDeclaration(); + public DeclaredElementType FSharpElementType => null; public override string ToString() => this.TestToString(BuildTypeParameterString()); } diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/FSharpModule.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/FSharpModule.cs index 53d853a7df..fed316fe1d 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/FSharpModule.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/FSharpModule.cs @@ -65,5 +65,6 @@ private string[] GetNames(Func getter) string IAlternativeNameOwner.AlternativeName => SourceName != ShortName ? SourceName : null; public override string ToString() => this.TestToString(BuildTypeParameterString()); + public override DeclaredElementType FSharpElementType => FSharpDeclaredElementType.Module; } } diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/FSharpObjectExpressionClass.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/FSharpObjectExpressionClass.cs index 6323a6b605..8123fa071f 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/FSharpObjectExpressionClass.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/FSharpObjectExpressionClass.cs @@ -17,6 +17,8 @@ protected override bool AcceptsPart(TypePart part) => public AccessRights RepresentationAccessRights => AccessRights.PUBLIC; public bool IsErased => true; + public override DeclaredElementType FSharpElementType => FSharpDeclaredElementType.ObjectExpression; + public override string ToString() => this.TestToString(BuildTypeParameterString()); } } diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/FSharpStruct.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/FSharpStruct.cs index 0f5d4e6b07..96a4455c87 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/FSharpStruct.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/FSharpStruct.cs @@ -37,6 +37,7 @@ public override IList GetSuperTypeElements() public ModuleMembersAccessKind AccessKind => EnumerateParts().GetAccessKind(); public ITypeDeclaration DefiningDeclaration => this.GetDefiningDeclaration(); + public virtual DeclaredElementType FSharpElementType => this.TryGetFSharpDeclaredElementType(); public override string ToString() => this.TestToString(BuildTypeParameterString()); } diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/FSharpUnionCaseClass.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/FSharpUnionCaseClass.cs index 461cc91568..6b2e1c04b0 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/FSharpUnionCaseClass.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Cache2/FSharpUnionCaseClass.cs @@ -17,5 +17,7 @@ public class FSharpUnionCaseClass([NotNull] Class.IClassPart part) : FSharpClass public IDeclaredElementPointer CreatePointer() => new FSharpUnionCaseClassPointer(this); + public override DeclaredElementType FSharpElementType => FSharpDeclaredElementType.UnionCase; + public override string ToString() => this.TestToString(BuildTypeParameterString()); } diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/Compiled/CompiledActivePatternCase.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/Compiled/CompiledActivePatternCase.cs index c84baac1fc..1bc83b4660 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/Compiled/CompiledActivePatternCase.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/Compiled/CompiledActivePatternCase.cs @@ -5,17 +5,11 @@ namespace JetBrains.ReSharper.Plugins.FSharp.Psi.Impl.DeclaredElement.Compiled { - public class CompiledActivePatternCase : DelegatingDeclaredElement, IFSharpGeneratedFromOtherElement, - IActivePatternCase + public class CompiledActivePatternCase([NotNull] IMethod activePattern, string name, int index) + : DelegatingDeclaredElement(activePattern), IFSharpGeneratedFromOtherElement, IActivePatternCase { - public CompiledActivePatternCase([NotNull] IMethod activePattern, string name, int index) : base(activePattern) - { - ShortName = name; - Index = index; - } - - public override string ShortName { get; } - public int Index { get; } + public override string ShortName { get; } = name; + public int Index { get; } = index; public override ITypeMember GetContainingTypeMember() => (ITypeMember)Origin; public override DeclaredElementType GetElementType() => FSharpDeclaredElementType.ActivePatternCase; @@ -35,19 +29,15 @@ public override bool Equals(object obj) public IDeclaredElementPointer CreatePointer() => new CompiledActivePatternCasePointer(this, ShortName, Index); + + public DeclaredElementType FSharpElementType => FSharpDeclaredElementType.ActivePatternCase; } - public class CompiledActivePatternCasePointer : FSharpGeneratedElementPointerBase + public class CompiledActivePatternCasePointer(CompiledActivePatternCase patternCase, string shortName, int index) + : FSharpGeneratedElementPointerBase(patternCase) { - public string ShortName { get; } - public int Index { get; } - - public CompiledActivePatternCasePointer(CompiledActivePatternCase patternCase, string shortName, int index) - : base(patternCase) - { - ShortName = shortName; - Index = index; - } + public string ShortName { get; } = shortName; + public int Index { get; } = index; public override CompiledActivePatternCase CreateGenerated(IMethod fsElement) => new(fsElement, ShortName, Index); } diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/CompilerGenerated/FSharpGeneratedElementBase.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/CompilerGenerated/FSharpGeneratedElementBase.cs index 9b8ee81ed6..81fec107b5 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/CompilerGenerated/FSharpGeneratedElementBase.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/CompilerGenerated/FSharpGeneratedElementBase.cs @@ -11,6 +11,7 @@ public abstract class FSharpGeneratedElementBase : FSharpDeclaredElementBase, IF [NotNull] protected abstract IClrDeclaredElement ContainingElement { get; } public virtual string SourceName => SharedImplUtil.MISSING_DECLARATION_NAME; + public DeclaredElementType FSharpElementType => null; public override bool IsValid() => ContainingElement.IsValid(); public override IPsiServices GetPsiServices() => ContainingElement.GetPsiServices(); diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/FSharpAnonRecordFieldProperty.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/FSharpAnonRecordFieldProperty.cs index 394a6700ce..e4785f5383 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/FSharpAnonRecordFieldProperty.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/FSharpAnonRecordFieldProperty.cs @@ -8,12 +8,10 @@ namespace JetBrains.ReSharper.Plugins.FSharp.Psi.Impl.DeclaredElement { - internal class FSharpAnonRecordFieldProperty : FSharpDeclaredElementBase, IFSharpAnonRecordFieldProperty + internal class FSharpAnonRecordFieldProperty(FSharpSymbolReference reference) + : FSharpDeclaredElementBase, IFSharpAnonRecordFieldProperty { - public FSharpSymbolReference Reference { get; } - - public FSharpAnonRecordFieldProperty(FSharpSymbolReference reference) => - Reference = reference; + public FSharpSymbolReference Reference { get; } = reference; public FSharpField FcsField => Reference.GetFcsSymbol() as FSharpField; public FSharpAnonRecordTypeDetails AnonType => FcsField.AnonRecordFieldDetails.Item1; @@ -28,7 +26,7 @@ public FSharpAnonRecordFieldProperty(FSharpSymbolReference reference) => EmptySubstitution.INSTANCE; public override DeclaredElementType GetElementType() => - CommonDeclaredElementType.AnonymousTypeProperty; + FSharpDeclaredElementType.RecordField; public override IPsiModule Module => Reference.GetElement().GetPsiModule(); public override IPsiServices GetPsiServices() => Module.GetPsiServices(); @@ -64,5 +62,6 @@ public override int GetHashCode() => ShortName.GetHashCode(); public string SourceName => ShortName; + public DeclaredElementType FSharpElementType => null; } } diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/FSharpFieldBase.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/FSharpFieldBase.cs index 0cab762bc3..3f0eedff37 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/FSharpFieldBase.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/FSharpFieldBase.cs @@ -53,6 +53,8 @@ internal class FSharpTypePrivateField([NotNull] TopPatternDeclarationBase declar public override bool IsStatic => GetDeclaration() is { IsStatic: true }; + + public override DeclaredElementType FSharpElementType => FSharpDeclaredElementType.Value; } internal class FSharpValField([NotNull] ValFieldDeclaration declaration) diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/FSharpFieldProperty.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/FSharpFieldProperty.cs index e8175b3973..9ed087795a 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/FSharpFieldProperty.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/FSharpFieldProperty.cs @@ -38,7 +38,7 @@ public override IParameter GetGeneratedParameter() : null; } - public int Index => GetDeclaration()?.Index ?? -1; + public override int Index => GetDeclaration()?.Index ?? -1; } /// Record field compiled to a property. @@ -87,6 +87,8 @@ public virtual IParameter GetGeneratedParameter() => ? new FSharpGeneratedParameter(constructor, this, false) : null; - public int Index => throw new System.NotImplementedException(); + public virtual int Index => throw new System.NotImplementedException(); + + public override DeclaredElementType FSharpElementType => CLRDeclaredElementType.FIELD; } } diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/FSharpLiteral.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/FSharpLiteral.cs index 4658b16390..4e2386b8f3 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/FSharpLiteral.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/FSharpLiteral.cs @@ -10,12 +10,9 @@ namespace JetBrains.ReSharper.Plugins.FSharp.Psi.Impl.DeclaredElement { - internal class FSharpLiteral : FSharpTypeMember, IField, ITopLevelPatternDeclaredElement + internal class FSharpLiteral([NotNull] ITypeMemberDeclaration declaration) + : FSharpTypeMember(declaration), IField, ITopLevelPatternDeclaredElement { - public FSharpLiteral([NotNull] ITypeMemberDeclaration declaration) : base(declaration) - { - } - [CanBeNull] public FSharpMemberOrFunctionOrValue Mfv => Symbol as FSharpMemberOrFunctionOrValue; public override DeclaredElementType GetElementType() => diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/FSharpMemberBase.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/FSharpMemberBase.cs index a0f63c90a4..e004bf0d0b 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/FSharpMemberBase.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/FSharpMemberBase.cs @@ -11,12 +11,11 @@ namespace JetBrains.ReSharper.Plugins.FSharp.Psi.Impl.DeclaredElement { - internal abstract class FSharpMemberBase : FSharpTypeMember, IFSharpMember + internal abstract class FSharpMemberBase([NotNull] ITypeMemberDeclaration declaration) + : FSharpTypeMember(declaration), IFSharpMember where TDeclaration : IFSharpDeclaration, IModifiersOwnerDeclaration, ITypeMemberDeclaration { - protected FSharpMemberBase([NotNull] ITypeMemberDeclaration declaration) : base(declaration) - { - } + public override DeclaredElementType FSharpElementType => null; public FSharpMemberOrFunctionOrValue Mfv => Symbol as FSharpMemberOrFunctionOrValue; diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/FSharpMethod.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/FSharpMethod.cs index 3a462907aa..0ad48f94e2 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/FSharpMethod.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/FSharpMethod.cs @@ -9,23 +9,17 @@ namespace JetBrains.ReSharper.Plugins.FSharp.Psi.Impl.DeclaredElement { - internal class FSharpMethod : FSharpMethodBase, IFSharpMethod + internal class FSharpMethod([NotNull] ITypeMemberDeclaration declaration) + : FSharpMethodBase(declaration), IFSharpMethod where TDeclaration : IFSharpDeclaration, IModifiersOwnerDeclaration, ITypeMemberDeclaration { - public FSharpMethod([NotNull] ITypeMemberDeclaration declaration) : base(declaration) - { - } - public override bool IsStatic => GetContainingType() is IFSharpModule || base.IsStatic; } - internal class FSharpTypePrivateMethod : FSharpMethodBase, ITypePrivateMember, - ITopLevelPatternDeclaredElement + internal class FSharpTypePrivateMethod([NotNull] ITypeMemberDeclaration declaration) + : FSharpMethodBase(declaration), ITypePrivateMember, + ITopLevelPatternDeclaredElement { - public FSharpTypePrivateMethod([NotNull] ITypeMemberDeclaration declaration) : base(declaration) - { - } - public override AccessRights GetAccessRights() => AccessRights.INTERNAL; public override bool IsStatic => @@ -35,5 +29,7 @@ public FSharpTypePrivateMethod([NotNull] ITypeMemberDeclaration declaration) : b GetDeclaration() is { } decl && decl.GetContainingTypeDeclaration()?.GetFcsSymbol() is FSharpEntity fcsEntity ? fcsEntity.GenericParameters.Concat(base.MfvTypeParameters).ToList() : base.MfvTypeParameters; + + public override DeclaredElementType FSharpElementType => FSharpDeclaredElementType.Function; } } diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/FSharpMethodParameterBase.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/FSharpMethodParameterBase.cs index 785c518873..2e8bcb2a95 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/FSharpMethodParameterBase.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/FSharpMethodParameterBase.cs @@ -48,6 +48,7 @@ public abstract class FSharpMethodParameterBase([NotNull] IParametersOwner owner public bool HasDeclarationsIn(IPsiSourceFile sourceFile) => false; public abstract string ShortName { get; } public abstract string SourceName { get; } + public DeclaredElementType FSharpElementType => null; public ITypeElement GetContainingType() => Owner.GetContainingType(); public ITypeMember GetContainingTypeMember() => (ITypeMember) Owner; diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/FSharpTypeMember.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/FSharpTypeMember.cs index acec0bc5ad..5111ffdea3 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/FSharpTypeMember.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/FSharpTypeMember.cs @@ -16,13 +16,10 @@ namespace JetBrains.ReSharper.Plugins.FSharp.Psi.Impl.DeclaredElement { - internal abstract class FSharpTypeMember : FSharpCachedTypeMemberBase, IFSharpTypeMember + internal abstract class FSharpTypeMember([NotNull] IDeclaration declaration) + : FSharpCachedTypeMemberBase(declaration), IFSharpTypeMember where TDeclaration : IFSharpDeclaration, IModifiersOwnerDeclaration, ITypeMemberDeclaration { - protected FSharpTypeMember([NotNull] IDeclaration declaration) : base(declaration) - { - } - public ITypeMember GetContainingTypeMember() => (ITypeMember) GetContainingType(); @@ -147,5 +144,7 @@ protected IType GetType([CanBeNull] FSharpType fcsType) => fcsType != null ? fcsType.MapType(AllTypeParameters, Module) : TypeFactory.CreateUnknownType(Module); + + public virtual DeclaredElementType FSharpElementType => null; } } diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/FSharpUnionCaseProperty.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/FSharpUnionCaseProperty.cs index b092b6613e..f44be212b3 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/FSharpUnionCaseProperty.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/FSharpUnionCaseProperty.cs @@ -37,6 +37,8 @@ public IFSharpParameterOwner GetConstructor() => public override bool IsStatic => true; + public override DeclaredElementType FSharpElementType => FSharpDeclaredElementType.UnionCase; + public override IType ReturnType => GetContainingType() is { } containingType ? TypeFactory.CreateType(containingType) diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/ModuleFunction.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/ModuleFunction.cs index cfc048cb20..cf05ce25a9 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/ModuleFunction.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/ModuleFunction.cs @@ -1,15 +1,14 @@ using JetBrains.Annotations; using JetBrains.ReSharper.Plugins.FSharp.Psi.Impl.Tree; +using JetBrains.ReSharper.Psi; using JetBrains.ReSharper.Psi.Tree; -namespace JetBrains.ReSharper.Plugins.FSharp.Psi.Impl.DeclaredElement +namespace JetBrains.ReSharper.Plugins.FSharp.Psi.Impl.DeclaredElement; + +internal class ModuleFunction([NotNull] ITypeMemberDeclaration declaration) + : FSharpMethodBase(declaration), ITopLevelPatternDeclaredElement { - internal class ModuleFunction : FSharpMethodBase, ITopLevelPatternDeclaredElement - { - public ModuleFunction([NotNull] ITypeMemberDeclaration declaration) : base(declaration) - { - } + public override bool IsStatic => true; - public override bool IsStatic => true; - } + public override DeclaredElementType FSharpElementType => FSharpDeclaredElementType.Function; } diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/ModuleValue.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/ModuleValue.cs index f9d83688ea..a555b0cb5f 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/ModuleValue.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/ModuleValue.cs @@ -53,5 +53,7 @@ public override bool Equals(object obj) => public override int GetHashCode() => ShortName.GetHashCode(); + + public override DeclaredElementType FSharpElementType => FSharpDeclaredElementType.Value; } } diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/TopActivePatternCase.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/TopActivePatternCase.cs index abbbad7ae6..684a5ce269 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/TopActivePatternCase.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/DeclaredElement/TopActivePatternCase.cs @@ -10,14 +10,12 @@ namespace JetBrains.ReSharper.Plugins.FSharp.Psi.Impl.DeclaredElement { - internal class TopActivePatternCase : FSharpCachedTypeMemberBase, - IFSharpDeclaredElement, IActivePatternCase + internal class TopActivePatternCase(ITopActivePatternCaseDeclaration declaration) + : FSharpCachedTypeMemberBase(declaration), + IFSharpDeclaredElement, IActivePatternCase { - public TopActivePatternCase(ITopActivePatternCaseDeclaration declaration) : base(declaration) - { - } - public override DeclaredElementType GetElementType() => FSharpDeclaredElementType.ActivePatternCase; + public DeclaredElementType FSharpElementType => null; public override string ShortName => GetDeclaration()?.CompiledName ?? SharedImplUtil.MISSING_DECLARATION_NAME; public int Index => GetDeclaration()?.Index ?? -1; diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/FSharpDeclaredElementType.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/FSharpDeclaredElementType.cs index aec4afba15..29778e5d6c 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/FSharpDeclaredElementType.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/FSharpDeclaredElementType.cs @@ -1,17 +1,25 @@ using JetBrains.Annotations; using JetBrains.ReSharper.Psi; using JetBrains.ReSharper.Psi.CSharp.Impl; +using JetBrains.ReSharper.Psi.Resources; using JetBrains.UI.Icons; namespace JetBrains.ReSharper.Plugins.FSharp.Psi.Impl { - public class FSharpDeclaredElementType : DeclaredElementTypeBase + public class FSharpDeclaredElementType(string name, [CanBeNull] IconId imageName) + : DeclaredElementTypeBase(name, imageName) { public static readonly DeclaredElementType ActivePatternCase = new FSharpDeclaredElementType("active pattern case", null); - - public FSharpDeclaredElementType(string name, [CanBeNull] IconId imageName) : base(name, imageName) - { - } + public static readonly DeclaredElementType Exception = new FSharpDeclaredElementType("exception", null); + public static readonly DeclaredElementType Function = new FSharpDeclaredElementType("function", null); + public static readonly DeclaredElementType ObjectExpression = new FSharpDeclaredElementType("object expression", null); + public static readonly DeclaredElementType Module = new FSharpDeclaredElementType("module", null); + public static readonly DeclaredElementType Record = new FSharpDeclaredElementType("record", null); + public static readonly DeclaredElementType RecordField = new FSharpDeclaredElementType("field", null); + public static readonly DeclaredElementType TypeAbbreviation = new FSharpDeclaredElementType("type abbreviation", null); + public static readonly DeclaredElementType Union = new FSharpDeclaredElementType("union", PsiSymbolsThemedIcons.EnumMember.Id); + public static readonly DeclaredElementType UnionCase = new FSharpDeclaredElementType("union case", PsiSymbolsThemedIcons.EnumMember.Id); + public static readonly DeclaredElementType Value = new FSharpDeclaredElementType("value", null); protected override IDeclaredElementPresenter DefaultPresenter => CSharpDeclaredElementPresenter.Instance; @@ -20,4 +28,4 @@ public override bool IsPresentable(PsiLanguageType language) return language.Is(); } } -} \ No newline at end of file +} 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 9da588ff2b..da25e1b417 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/FSharpImplUtil.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/FSharpImplUtil.cs @@ -331,7 +331,7 @@ ICompiledElement compiled when compiled.IsFromFSharpAssembly() => compiled.IsCom _ => false }; - public static bool IsUnion([NotNull] this ITypeElement typeElement) => + public static bool IsFSharpUnion([NotNull] this ITypeElement typeElement) => typeElement switch { IFSharpSourceTypeElement fsTypeElement => fsTypeElement.GetPart() != null, @@ -669,7 +669,7 @@ public static bool HasAutoOpenAttribute([NotNull] this ITypeElement typeElement) _ => typeElement.HasAttributeInstance(FSharpPredefinedType.AutoOpenAttrTypeName, false) }; - public static bool IsRecord([CanBeNull] this ITypeElement typeElement) => + public static bool IsFSharpRecord([CanBeNull] this ITypeElement typeElement) => typeElement switch { IFSharpSourceTypeElement fsTypeElement => (fsTypeElement.GetPart() != null), @@ -709,8 +709,25 @@ public static ModuleMembersAccessKind GetAccessType([NotNull] this ITypeElement : ModuleMembersAccessKind.Normal; } + public static DeclaredElementType TryGetFSharpDeclaredElementType([NotNull] this ITypeElement typeElement) + { + if (typeElement.IsFSharpRecord()) + return FSharpDeclaredElementType.Record; + + if (typeElement.IsFSharpUnion()) + return FSharpDeclaredElementType.Union; + + if (typeElement.IsModule()) + return FSharpDeclaredElementType.Module; + + if (typeElement.IsFSharpException()) + return FSharpDeclaredElementType.Exception; + + return null; + } + public static bool MayHaveRequireQualifiedAccessAttribute([NotNull] this ITypeElement typeElement) => - typeElement.IsModule() || typeElement.IsUnion() || typeElement.IsRecord(); + typeElement.IsModule() || typeElement.IsFSharpUnion() || typeElement.IsFSharpRecord(); public static bool RequiresQualifiedAccess([NotNull] this ITypeElement typeElement) => typeElement.GetAccessType() == ModuleMembersAccessKind.RequiresQualifiedAccess; diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/FSharpReferenceBindingUtil.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/FSharpReferenceBindingUtil.cs index 6828fceab9..830b4e130c 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/FSharpReferenceBindingUtil.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/FSharpReferenceBindingUtil.cs @@ -88,7 +88,7 @@ public static void SetRequiredQualifiersForContainingType([NotNull] this FSharpS return; } - if ((containingType.IsUnion() || containingType.IsRecord()) && !containingType.RequiresQualifiedAccess()) + if ((containingType.IsFSharpUnion() || containingType.IsFSharpRecord()) && !containingType.RequiresQualifiedAccess()) { // Containing module may require qualifier. SetRequiredQualifiers(reference, containingType, context); diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Tree/LocalDeclaration.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Tree/LocalDeclaration.cs index d1a227ec1d..3057de5d60 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Tree/LocalDeclaration.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Tree/LocalDeclaration.cs @@ -21,7 +21,7 @@ internal abstract class LocalDeclarationBase : FSharpDeclarationBase, ILocalVari string IDeclaredElement.ShortName => SourceName; public override string CompiledName => SourceName; - public IList GetDeclarations() => new IDeclaration[] {this}; + public IList GetDeclarations() => [this]; public IList GetDeclarationsIn(IPsiSourceFile sourceFile) => SharedImplUtil.GetDeclarationsIn(this, sourceFile); @@ -64,6 +64,8 @@ public override void SetName(string name) => public bool IsStatic => false; public ScopedKind Scope => ScopedKind.None; public ReferenceKind ReferenceKind => ReferenceKind.VALUE; + + public virtual DeclaredElementType FSharpElementType => null; } internal partial class LocalDeclaration diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Searching/FSharpSearcherFactory.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Searching/FSharpSearcherFactory.cs index 73f2dc41c6..33408a6c4a 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Searching/FSharpSearcherFactory.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Searching/FSharpSearcherFactory.cs @@ -80,7 +80,7 @@ public override IEnumerable GetRelatedDeclaredElements(I if (element is IFSharpProperty { IsIndexerLike: true } property) return property.Accessors.Select(member => new RelatedDeclaredElement(member)); - if (element is IFSharpSourceTypeElement typeElement && typeElement.IsUnion()) + if (element is IFSharpSourceTypeElement typeElement && typeElement.IsFSharpUnion()) { var result = new List(); foreach (var sourceUnionCase in typeElement.GetSourceUnionCases()) diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Util/FcsSymbolMappingUtil.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Util/FcsSymbolMappingUtil.cs index 4d04b480ba..814f2a5267 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Util/FcsSymbolMappingUtil.cs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Util/FcsSymbolMappingUtil.cs @@ -233,7 +233,7 @@ private static IDeclaredElement GetDeclaredElement(FSharpUnionCase unionCase, IP if (unionTypeElement == null) return null; // todo: remove preferType param, get the field through the union case - if (!preferType && unionTypeElement is IFSharpSourceTypeElement sourceTypeElement && sourceTypeElement.IsUnion()) + if (!preferType && unionTypeElement is IFSharpSourceTypeElement sourceTypeElement && sourceTypeElement.IsFSharpUnion()) { var sourceUnionCase = sourceTypeElement.GetSourceUnionCases() .FirstOrDefault(sourceUnionCase => sourceUnionCase.ShortName == unionCase.Name); diff --git a/ReSharper.FSharp/test/data/features/navigation/declaration/Module 01.fs b/ReSharper.FSharp/test/data/features/navigation/declaration/Module 01.fs new file mode 100644 index 0000000000..c2aa42e44f --- /dev/null +++ b/ReSharper.FSharp/test/data/features/navigation/declaration/Module 01.fs @@ -0,0 +1,6 @@ +module Module + +module Nested = + let x = 1 + +open Nested{on} diff --git a/ReSharper.FSharp/test/data/features/navigation/declaration/Module 01.fs.gold b/ReSharper.FSharp/test/data/features/navigation/declaration/Module 01.fs.gold new file mode 100644 index 0000000000..a429980c9c --- /dev/null +++ b/ReSharper.FSharp/test/data/features/navigation/declaration/Module 01.fs.gold @@ -0,0 +1,35 @@ +## GotoDeclarationProvider activity: + Show context popup menu `Declarations of module 'Nested'`: + TO: [O] module |Nested| = RANGE: (22,28) @ Module 01.fs + Menu item (enabled) : + icon: Fsharp + text: Module 01.fs (3) + tail: in + tooltip: module **Nested** = + Navigation result: + opened file: Module 01.fs + ------------------ + module Module + + module |CARET|Nested = + let x = 1 + + ------------------ + + TO: [O] module |Nested| = RANGE: (22,28) @ Module 01.fsi + Menu item (enabled) : + icon: FsharpSignature + text: Module 01.fsi (3) + tail: in + tooltip: module **Nested** = + Navigation result: + opened file: Module 01.fsi + ------------------ + module Module + + module |CARET|Nested = + val x: int + + ------------------ + + diff --git a/ReSharper.FSharp/test/data/features/navigation/declaration/Module 01.fsi b/ReSharper.FSharp/test/data/features/navigation/declaration/Module 01.fsi new file mode 100644 index 0000000000..1ec35a23f1 --- /dev/null +++ b/ReSharper.FSharp/test/data/features/navigation/declaration/Module 01.fsi @@ -0,0 +1,4 @@ +module Module + +module Nested = + val x: int diff --git a/ReSharper.FSharp/test/data/features/navigation/declaration/Module 02.fs b/ReSharper.FSharp/test/data/features/navigation/declaration/Module 02.fs new file mode 100644 index 0000000000..63091b080c --- /dev/null +++ b/ReSharper.FSharp/test/data/features/navigation/declaration/Module 02.fs @@ -0,0 +1,9 @@ +module Module + +module Nested = + let x = 1 + +type Nested = + { F: int } + +open Nested{on} diff --git a/ReSharper.FSharp/test/data/features/navigation/declaration/Module 02.fs.gold b/ReSharper.FSharp/test/data/features/navigation/declaration/Module 02.fs.gold new file mode 100644 index 0000000000..a79cba6322 --- /dev/null +++ b/ReSharper.FSharp/test/data/features/navigation/declaration/Module 02.fs.gold @@ -0,0 +1,35 @@ +## GotoDeclarationProvider activity: + Show context popup menu `Declarations of module 'NestedModule'`: + TO: [O] module |Nested| = RANGE: (22,28) @ Module 02.fs + Menu item (enabled) : + icon: Fsharp + text: Module 02.fs (3) + tail: in + tooltip: module **Nested** = + Navigation result: + opened file: Module 02.fs + ------------------ + module Module + + module |CARET|Nested = + let x = 1 + + ------------------ + + TO: [O] module |Nested| = RANGE: (22,28) @ Module 02.fsi + Menu item (enabled) : + icon: FsharpSignature + text: Module 02.fsi (3) + tail: in + tooltip: module **Nested** = + Navigation result: + opened file: Module 02.fsi + ------------------ + module Module + + module |CARET|Nested = + val x: int + + ------------------ + + diff --git a/ReSharper.FSharp/test/data/features/navigation/declaration/Module 02.fsi b/ReSharper.FSharp/test/data/features/navigation/declaration/Module 02.fsi new file mode 100644 index 0000000000..e87a663860 --- /dev/null +++ b/ReSharper.FSharp/test/data/features/navigation/declaration/Module 02.fsi @@ -0,0 +1,7 @@ +module Module + +module Nested = + val x: int + +type Nested = + { F: int } diff --git a/ReSharper.FSharp/test/data/features/navigation/declaration/Record - Field 01.fs b/ReSharper.FSharp/test/data/features/navigation/declaration/Record - Field 01.fs new file mode 100644 index 0000000000..ac6c594276 --- /dev/null +++ b/ReSharper.FSharp/test/data/features/navigation/declaration/Record - Field 01.fs @@ -0,0 +1,7 @@ +module Module + +type R = + { F: int } + +let r = { F = 1 } +let i = r.F{on} diff --git a/ReSharper.FSharp/test/data/features/navigation/declaration/Record - Field 01.fs.gold b/ReSharper.FSharp/test/data/features/navigation/declaration/Record - Field 01.fs.gold new file mode 100644 index 0000000000..0682baf0b7 --- /dev/null +++ b/ReSharper.FSharp/test/data/features/navigation/declaration/Record - Field 01.fs.gold @@ -0,0 +1,34 @@ +## GotoDeclarationProvider activity: + Show context popup menu `Declarations of field 'F'`: + TO: [O] { |F|: int } RANGE: (30,31) @ Record - Field 01.fs + Menu item (enabled) : + icon: Fsharp + text: Record - Field 01.fs (4) + tail: in + tooltip: { **F**: int } + Navigation result: + opened file: Record - Field 01.fs + ------------------ + + type R = + { |CARET|F: int } + + let r = { F = 1 } + ------------------ + + TO: [O] { |F|: int } RANGE: (30,31) @ Record - Field 01.fsi + Menu item (enabled) : + icon: FsharpSignature + text: Record - Field 01.fsi (4) + tail: in + tooltip: { **F**: int } + Navigation result: + opened file: Record - Field 01.fsi + ------------------ + + type R = + { |CARET|F: int } + + ------------------ + + diff --git a/ReSharper.FSharp/test/data/features/navigation/declaration/Record - Field 01.fsi b/ReSharper.FSharp/test/data/features/navigation/declaration/Record - Field 01.fsi new file mode 100644 index 0000000000..ea38c421f3 --- /dev/null +++ b/ReSharper.FSharp/test/data/features/navigation/declaration/Record - Field 01.fsi @@ -0,0 +1,4 @@ +module Module + +type R = + { F: int } diff --git a/ReSharper.FSharp/test/data/features/navigation/declaration/Record - Field 02.fs b/ReSharper.FSharp/test/data/features/navigation/declaration/Record - Field 02.fs new file mode 100644 index 0000000000..b01618ad39 --- /dev/null +++ b/ReSharper.FSharp/test/data/features/navigation/declaration/Record - Field 02.fs @@ -0,0 +1,6 @@ +module Module + +type R = + { F: int } + +let r = { F{on} = 1 } diff --git a/ReSharper.FSharp/test/data/features/navigation/declaration/Record - Field 02.fs.gold b/ReSharper.FSharp/test/data/features/navigation/declaration/Record - Field 02.fs.gold new file mode 100644 index 0000000000..d4bf497101 --- /dev/null +++ b/ReSharper.FSharp/test/data/features/navigation/declaration/Record - Field 02.fs.gold @@ -0,0 +1,34 @@ +## GotoDeclarationProvider activity: + Show context popup menu `Declarations of field 'F'`: + TO: [O] { |F|: int } RANGE: (30,31) @ Record - Field 02.fs + Menu item (enabled) : + icon: Fsharp + text: Record - Field 02.fs (4) + tail: in + tooltip: { **F**: int } + Navigation result: + opened file: Record - Field 02.fs + ------------------ + + type R = + { |CARET|F: int } + + let r = { F = 1 } + ------------------ + + TO: [O] { |F|: int } RANGE: (30,31) @ Record - Field 02.fsi + Menu item (enabled) : + icon: FsharpSignature + text: Record - Field 02.fsi (4) + tail: in + tooltip: { **F**: int } + Navigation result: + opened file: Record - Field 02.fsi + ------------------ + + type R = + { |CARET|F: int } + + ------------------ + + diff --git a/ReSharper.FSharp/test/data/features/navigation/declaration/Record - Field 02.fsi b/ReSharper.FSharp/test/data/features/navigation/declaration/Record - Field 02.fsi new file mode 100644 index 0000000000..ea38c421f3 --- /dev/null +++ b/ReSharper.FSharp/test/data/features/navigation/declaration/Record - Field 02.fsi @@ -0,0 +1,4 @@ +module Module + +type R = + { F: int } diff --git a/ReSharper.FSharp/test/data/features/navigation/declaration/Signature 01.fs.gold b/ReSharper.FSharp/test/data/features/navigation/declaration/Signature 01.fs.gold index 6d28c6cc6c..46eb6190f6 100644 --- a/ReSharper.FSharp/test/data/features/navigation/declaration/Signature 01.fs.gold +++ b/ReSharper.FSharp/test/data/features/navigation/declaration/Signature 01.fs.gold @@ -1,5 +1,5 @@ ## GotoDeclarationProvider activity: - Show context popup menu `Declarations of property 'x'`: + Show context popup menu `Declarations of value 'x'`: TO: [O] let |x| = 123 RANGE: (18,19) @ Signature 01.fs Menu item (enabled) : icon: Fsharp diff --git a/ReSharper.FSharp/test/data/features/navigation/declaration/Signature 02 - Same range.fs.gold b/ReSharper.FSharp/test/data/features/navigation/declaration/Signature 02 - Same range.fs.gold index a4db99b61c..907838d862 100644 --- a/ReSharper.FSharp/test/data/features/navigation/declaration/Signature 02 - Same range.fs.gold +++ b/ReSharper.FSharp/test/data/features/navigation/declaration/Signature 02 - Same range.fs.gold @@ -1,5 +1,5 @@ ## GotoDeclarationProvider activity: - Show context popup menu `Declarations of property 'x'`: + Show context popup menu `Declarations of value 'x'`: TO: [O] let |x| = 123 RANGE: (19,20) @ Signature 02 - Same range.fs Menu item (enabled) : icon: Fsharp diff --git a/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Empty 01 - Expr.fs b/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Empty 01 - Expr.fs index f4ee2b16e3..5b323cb2ca 100644 --- a/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Empty 01 - Expr.fs +++ b/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Empty 01 - Expr.fs @@ -1,3 +1,5 @@ +module Module + type U = | A | B diff --git a/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Empty 01 - Expr.fs.gold b/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Empty 01 - Expr.fs.gold index 3528080fc0..f1dfb0b377 100644 --- a/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Empty 01 - Expr.fs.gold +++ b/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Empty 01 - Expr.fs.gold @@ -1,9 +1,31 @@ ## GotoDeclarationProvider activity: - Immediate result: - TO: [O] | |A| RANGE: (15,16) @ Union - Case - Empty 01 - Expr.fs + Show context popup menu `Declarations of union case 'A'`: + TO: [O] | |A| RANGE: (30,31) @ Union - Case - Empty 01 - Expr.fs + Menu item (enabled) : + icon: Fsharp + text: Union - Case - Empty 01 - Expr.fs (4) + tail: in + tooltip: | **A** Navigation result: opened file: Union - Case - Empty 01 - Expr.fs ------------------ + + type U = + | |CARET|A + | B + + ------------------ + + TO: [O] | |A| RANGE: (30,31) @ Union - Case - Empty 01 - Expr.fsi + Menu item (enabled) : + icon: FsharpSignature + text: Union - Case - Empty 01 - Expr.fsi (4) + tail: in + tooltip: | **A** + Navigation result: + opened file: Union - Case - Empty 01 - Expr.fsi + ------------------ + type U = | |CARET|A | B diff --git a/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Empty 01 - Expr.fsi b/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Empty 01 - Expr.fsi new file mode 100644 index 0000000000..e9caf1eb5c --- /dev/null +++ b/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Empty 01 - Expr.fsi @@ -0,0 +1,5 @@ +module Module + +type U = + | A + | B diff --git a/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Empty 02 - Pattern.fs b/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Empty 02 - Pattern.fs index 6ff10a0c35..bb35661b6e 100644 --- a/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Empty 02 - Pattern.fs +++ b/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Empty 02 - Pattern.fs @@ -1,3 +1,5 @@ +module Module + type U = | A | B diff --git a/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Empty 02 - Pattern.fs.gold b/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Empty 02 - Pattern.fs.gold index 9e8418a657..bb3372759e 100644 --- a/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Empty 02 - Pattern.fs.gold +++ b/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Empty 02 - Pattern.fs.gold @@ -1,9 +1,31 @@ ## GotoDeclarationProvider activity: - Immediate result: - TO: [O] | |A| RANGE: (15,16) @ Union - Case - Empty 02 - Pattern.fs + Show context popup menu `Declarations of union case 'A'`: + TO: [O] | |A| RANGE: (30,31) @ Union - Case - Empty 02 - Pattern.fs + Menu item (enabled) : + icon: Fsharp + text: Union - Case - Empty 02 - Pattern.fs (4) + tail: in + tooltip: | **A** Navigation result: opened file: Union - Case - Empty 02 - Pattern.fs ------------------ + + type U = + | |CARET|A + | B + + ------------------ + + TO: [O] | |A| RANGE: (30,31) @ Union - Case - Empty 02 - Pattern.fsi + Menu item (enabled) : + icon: FsharpSignature + text: Union - Case - Empty 02 - Pattern.fsi (4) + tail: in + tooltip: | **A** + Navigation result: + opened file: Union - Case - Empty 02 - Pattern.fsi + ------------------ + type U = | |CARET|A | B diff --git a/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Empty 02 - Pattern.fsi b/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Empty 02 - Pattern.fsi new file mode 100644 index 0000000000..e9caf1eb5c --- /dev/null +++ b/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Empty 02 - Pattern.fsi @@ -0,0 +1,5 @@ +module Module + +type U = + | A + | B diff --git a/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Fields 01 - Expr.fs b/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Fields 01 - Expr.fs index c2c0c72caf..c702590bdf 100644 --- a/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Fields 01 - Expr.fs +++ b/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Fields 01 - Expr.fs @@ -1,3 +1,5 @@ +module Module + type U = | A of int | B diff --git a/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Fields 01 - Expr.fs.gold b/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Fields 01 - Expr.fs.gold index e54d85d3c3..0ca429273e 100644 --- a/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Fields 01 - Expr.fs.gold +++ b/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Fields 01 - Expr.fs.gold @@ -1,9 +1,31 @@ ## GotoDeclarationProvider activity: - Immediate result: - TO: [O] | |A| of int RANGE: (15,16) @ Union - Case - Fields 01 - Expr.fs + Show context popup menu `Declarations of union case 'A'`: + TO: [O] | |A| of int RANGE: (30,31) @ Union - Case - Fields 01 - Expr.fs + Menu item (enabled) : + icon: Fsharp + text: Union - Case - Fields 01 - Expr.fs (4) + tail: in + tooltip: | **A** of int Navigation result: opened file: Union - Case - Fields 01 - Expr.fs ------------------ + + type U = + | |CARET|A of int + | B + + ------------------ + + TO: [O] | |A| of int RANGE: (30,31) @ Union - Case - Fields 01 - Expr.fsi + Menu item (enabled) : + icon: FsharpSignature + text: Union - Case - Fields 01 - Expr.fsi (4) + tail: in + tooltip: | **A** of int + Navigation result: + opened file: Union - Case - Fields 01 - Expr.fsi + ------------------ + type U = | |CARET|A of int | B diff --git a/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Fields 01 - Expr.fsi b/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Fields 01 - Expr.fsi new file mode 100644 index 0000000000..5132019126 --- /dev/null +++ b/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Fields 01 - Expr.fsi @@ -0,0 +1,5 @@ +module Module + +type U = + | A of int + | B diff --git a/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Fields 02 - Pattern.fs b/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Fields 02 - Pattern.fs index 7265aeaf8a..78fbc95847 100644 --- a/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Fields 02 - Pattern.fs +++ b/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Fields 02 - Pattern.fs @@ -1,3 +1,5 @@ +module Module + type U = | A of int | B diff --git a/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Fields 02 - Pattern.fs.gold b/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Fields 02 - Pattern.fs.gold index 8667e965fd..80c9de1fc1 100644 --- a/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Fields 02 - Pattern.fs.gold +++ b/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Fields 02 - Pattern.fs.gold @@ -1,9 +1,31 @@ ## GotoDeclarationProvider activity: - Immediate result: - TO: [O] | |A| of int RANGE: (15,16) @ Union - Case - Fields 02 - Pattern.fs + Show context popup menu `Declarations of union case 'A'`: + TO: [O] | |A| of int RANGE: (30,31) @ Union - Case - Fields 02 - Pattern.fs + Menu item (enabled) : + icon: Fsharp + text: Union - Case - Fields 02 - Pattern.fs (4) + tail: in + tooltip: | **A** of int Navigation result: opened file: Union - Case - Fields 02 - Pattern.fs ------------------ + + type U = + | |CARET|A of int + | B + + ------------------ + + TO: [O] | |A| of int RANGE: (30,31) @ Union - Case - Fields 02 - Pattern.fsi + Menu item (enabled) : + icon: FsharpSignature + text: Union - Case - Fields 02 - Pattern.fsi (4) + tail: in + tooltip: | **A** of int + Navigation result: + opened file: Union - Case - Fields 02 - Pattern.fsi + ------------------ + type U = | |CARET|A of int | B diff --git a/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Fields 02 - Pattern.fsi b/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Fields 02 - Pattern.fsi new file mode 100644 index 0000000000..5132019126 --- /dev/null +++ b/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Fields 02 - Pattern.fsi @@ -0,0 +1,5 @@ +module Module + +type U = + | A of int + | B diff --git a/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Single - Fields 01 - Expr.fs b/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Single - Fields 01 - Expr.fs index 83d397a5bb..f32181e057 100644 --- a/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Single - Fields 01 - Expr.fs +++ b/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Single - Fields 01 - Expr.fs @@ -1,3 +1,5 @@ +module Module + type U = | A of int diff --git a/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Single - Fields 01 - Expr.fs.gold b/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Single - Fields 01 - Expr.fs.gold index 2e256d8b2d..43d8837723 100644 --- a/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Single - Fields 01 - Expr.fs.gold +++ b/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Single - Fields 01 - Expr.fs.gold @@ -1,13 +1,34 @@ ## GotoDeclarationProvider activity: - Immediate result: - TO: [O] | |A| of int RANGE: (15,16) @ Union - Case - Single - Fields 01 - Expr.fs + Show context popup menu `Declarations of union case 'A'`: + TO: [O] | |A| of int RANGE: (30,31) @ Union - Case - Single - Fields 01 - Expr.fs + Menu item (enabled) : + icon: Fsharp + text: Union - Case - Single - Fields 01 - Expr.fs (4) + tail: in + tooltip: | **A** of int Navigation result: opened file: Union - Case - Single - Fields 01 - Expr.fs ------------------ + type U = | |CARET|A of int let a = A 123 ------------------ + TO: [O] | |A| of int RANGE: (30,31) @ Union - Case - Single - Fields 01 - Expr.fsi + Menu item (enabled) : + icon: FsharpSignature + text: Union - Case - Single - Fields 01 - Expr.fsi (4) + tail: in + tooltip: | **A** of int + Navigation result: + opened file: Union - Case - Single - Fields 01 - Expr.fsi + ------------------ + + type U = + | |CARET|A of int + + ------------------ + diff --git a/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Single - Fields 01 - Expr.fsi b/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Single - Fields 01 - Expr.fsi new file mode 100644 index 0000000000..ce66ecd08c --- /dev/null +++ b/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Single - Fields 01 - Expr.fsi @@ -0,0 +1,4 @@ +module Module + +type U = + | A of int diff --git a/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Single - Fields 01 - Pattern.fs b/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Single - Fields 01 - Pattern.fs index 301ba1e3a3..fb05b28da3 100644 --- a/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Single - Fields 01 - Pattern.fs +++ b/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Single - Fields 01 - Pattern.fs @@ -1,3 +1,5 @@ +module Module + type U = | A of int diff --git a/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Single - Fields 01 - Pattern.fs.gold b/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Single - Fields 01 - Pattern.fs.gold index ec8b43cc5c..79a90841bb 100644 --- a/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Single - Fields 01 - Pattern.fs.gold +++ b/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Single - Fields 01 - Pattern.fs.gold @@ -1,13 +1,34 @@ ## GotoDeclarationProvider activity: - Immediate result: - TO: [O] | |A| of int RANGE: (15,16) @ Union - Case - Single - Fields 01 - Pattern.fs + Show context popup menu `Declarations of union case 'A'`: + TO: [O] | |A| of int RANGE: (30,31) @ Union - Case - Single - Fields 01 - Pattern.fs + Menu item (enabled) : + icon: Fsharp + text: Union - Case - Single - Fields 01 - Pattern.fs (4) + tail: in + tooltip: | **A** of int Navigation result: opened file: Union - Case - Single - Fields 01 - Pattern.fs ------------------ + type U = | |CARET|A of int match A 123 with ------------------ + TO: [O] | |A| of int RANGE: (30,31) @ Union - Case - Single - Fields 01 - Pattern.fsi + Menu item (enabled) : + icon: FsharpSignature + text: Union - Case - Single - Fields 01 - Pattern.fsi (4) + tail: in + tooltip: | **A** of int + Navigation result: + opened file: Union - Case - Single - Fields 01 - Pattern.fsi + ------------------ + + type U = + | |CARET|A of int + + ------------------ + diff --git a/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Single - Fields 01 - Pattern.fsi b/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Single - Fields 01 - Pattern.fsi new file mode 100644 index 0000000000..ce66ecd08c --- /dev/null +++ b/ReSharper.FSharp/test/data/features/navigation/declaration/Union - Case - Single - Fields 01 - Pattern.fsi @@ -0,0 +1,4 @@ +module Module + +type U = + | A of int diff --git a/ReSharper.FSharp/test/data/features/quickdoc/ActivePattern 01.fs.gold b/ReSharper.FSharp/test/data/features/quickdoc/ActivePattern 01.fs.gold index 556ea43140..a79a85a8ac 100644 --- a/ReSharper.FSharp/test/data/features/quickdoc/ActivePattern 01.fs.gold +++ b/ReSharper.FSharp/test/data/features/quickdoc/ActivePattern 01.fs.gold @@ -1,3 +1,3 @@  -
public static method FSharpChoice<Unit,Unit> |Even|Odd|
Some Doc on ActivePattern
\ No newline at end of file +
public static function FSharpChoice<Unit,Unit> |Even|Odd|
Some Doc on ActivePattern
\ No newline at end of file diff --git a/ReSharper.FSharp/test/data/features/quickdoc/ActivePattern 02.fs.gold b/ReSharper.FSharp/test/data/features/quickdoc/ActivePattern 02.fs.gold index 556ea43140..a79a85a8ac 100644 --- a/ReSharper.FSharp/test/data/features/quickdoc/ActivePattern 02.fs.gold +++ b/ReSharper.FSharp/test/data/features/quickdoc/ActivePattern 02.fs.gold @@ -1,3 +1,3 @@  -
public static method FSharpChoice<Unit,Unit> |Even|Odd|
Some Doc on ActivePattern
\ No newline at end of file +
public static function FSharpChoice<Unit,Unit> |Even|Odd|
Some Doc on ActivePattern
\ No newline at end of file diff --git a/ReSharper.FSharp/test/data/features/quickdoc/Partial ActivePattern 01.fs.gold b/ReSharper.FSharp/test/data/features/quickdoc/Partial ActivePattern 01.fs.gold index 68e42ec818..6cdc9a929f 100644 --- a/ReSharper.FSharp/test/data/features/quickdoc/Partial ActivePattern 01.fs.gold +++ b/ReSharper.FSharp/test/data/features/quickdoc/Partial ActivePattern 01.fs.gold @@ -1,3 +1,3 @@  -
public static method FSharpOption<int> |IsThree|_|
Some comment
\ No newline at end of file +
public static function FSharpOption<int> |IsThree|_|
Some comment
\ No newline at end of file diff --git a/ReSharper.FSharp/test/data/features/quickdoc/Partial ActivePattern 02.fs.gold b/ReSharper.FSharp/test/data/features/quickdoc/Partial ActivePattern 02.fs.gold index 68e42ec818..6cdc9a929f 100644 --- a/ReSharper.FSharp/test/data/features/quickdoc/Partial ActivePattern 02.fs.gold +++ b/ReSharper.FSharp/test/data/features/quickdoc/Partial ActivePattern 02.fs.gold @@ -1,3 +1,3 @@  -
public static method FSharpOption<int> |IsThree|_|
Some comment
\ No newline at end of file +
public static function FSharpOption<int> |IsThree|_|
Some comment
\ No newline at end of file diff --git a/ReSharper.FSharp/test/src/FSharp.Tests/NavigationTests.fs b/ReSharper.FSharp/test/src/FSharp.Tests/NavigationTests.fs index 546d51bcb9..3ca784dcd6 100644 --- a/ReSharper.FSharp/test/src/FSharp.Tests/NavigationTests.fs +++ b/ReSharper.FSharp/test/src/FSharp.Tests/NavigationTests.fs @@ -192,14 +192,18 @@ type FSharpGoToDeclarationTest() = [] [] member x.``Same type from different assemblies``() = x.DoNamedTest() - [] member x.``Union - Case - Empty 01 - Expr``() = x.DoNamedTest() - [] member x.``Union - Case - Empty 02 - Pattern``() = x.DoNamedTest() - - [] member x.``Union - Case - Fields 01 - Expr``() = x.DoNamedTest() - [] member x.``Union - Case - Fields 02 - Pattern``() = x.DoNamedTest() - - [] member x.``Union - Case - Single - Fields 01 - Expr``() = x.DoNamedTest() - [] member x.``Union - Case - Single - Fields 01 - Pattern``() = x.DoNamedTest() + [] member x.``Module 01``() = x.DoNamedTestWithSignature() + [] member x.``Module 02``() = x.DoNamedTestWithSignature() + + [] member x.``Record - Field 01``() = x.DoNamedTestWithSignature() + [] member x.``Record - Field 02``() = x.DoNamedTestWithSignature() + + [] member x.``Union - Case - Empty 01 - Expr``() = x.DoNamedTestWithSignature() + [] member x.``Union - Case - Empty 02 - Pattern``() = x.DoNamedTestWithSignature() + [] member x.``Union - Case - Fields 01 - Expr``() = x.DoNamedTestWithSignature() + [] member x.``Union - Case - Fields 02 - Pattern``() = x.DoNamedTestWithSignature() + [] member x.``Union - Case - Single - Fields 01 - Expr``() = x.DoNamedTestWithSignature() + [] member x.``Union - Case - Single - Fields 01 - Pattern``() = x.DoNamedTestWithSignature() [] member x.``Union - Field 01``() = x.DoNamedTest() [] member x.``Union - Field 02 - Single case``() = x.DoNamedTest() From b416e06f7344eddbd772f2139e660e1ee34d7abf Mon Sep 17 00:00:00 2001 From: Eugene Auduchinok Date: Wed, 27 May 2026 15:19:43 +0200 Subject: [PATCH 2/3] RIDER-139329 Navigation/context: disable for functional members GitOrigin-RevId: 87ae24310884ab4b6288922874454bc1e911a34a --- .../src/Navigation/FSharpBaseContextSearch.cs | 14 ++++++++++++++ .../Navigation/FSharpContextNavigationUtil.cs | 18 ++++++++++++++++++ .../FSharpInheritorsContextSearch.cs | 14 ++++++++++++++ .../navigation/base/Union case 01.fs.gold | 4 +--- 4 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Navigation/FSharpBaseContextSearch.cs create mode 100644 ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Navigation/FSharpContextNavigationUtil.cs create mode 100644 ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Navigation/FSharpInheritorsContextSearch.cs diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Navigation/FSharpBaseContextSearch.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Navigation/FSharpBaseContextSearch.cs new file mode 100644 index 0000000000..aee29dafd7 --- /dev/null +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Navigation/FSharpBaseContextSearch.cs @@ -0,0 +1,14 @@ +using JetBrains.Application; +using JetBrains.Application.DataContext; +using JetBrains.ReSharper.Feature.Services.Navigation.ContextNavigation; + +namespace JetBrains.ReSharper.Plugins.FSharp.Psi.Navigation; + +[ShellFeaturePart] +public class FSharpBaseContextSearch : BaseContextSearch +{ + public override bool IsContextApplicable(IDataContext dataContext) => + FSharpContextNavigationUtil.SupportsNoHierarchyNavigation(dataContext, ReferencePreferenceKind); + + public override bool IsAvailable(IDataContext context) => false; +} diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Navigation/FSharpContextNavigationUtil.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Navigation/FSharpContextNavigationUtil.cs new file mode 100644 index 0000000000..7ed5ae4209 --- /dev/null +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Navigation/FSharpContextNavigationUtil.cs @@ -0,0 +1,18 @@ +using System.Linq; +using JetBrains.Application.DataContext; +using JetBrains.ReSharper.Feature.Services.Navigation.ContextNavigation; +using JetBrains.ReSharper.Psi; +using JetBrains.ReSharper.Psi.Util; + +namespace JetBrains.ReSharper.Plugins.FSharp.Psi.Navigation; + +public static class FSharpContextNavigationUtil +{ + public static bool SupportsNoHierarchyNavigation(IDeclaredElement declaredElement) + { + return declaredElement is IFSharpModule or IFSharpRecordField or IFSharpUnionCase; + } + + public static bool SupportsNoHierarchyNavigation(IDataContext dataContext, ReferencePreferenceKind kind) => + ContextNavigationUtil.GetCandidateElements(dataContext, kind, false).Any(SupportsNoHierarchyNavigation); +} diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Navigation/FSharpInheritorsContextSearch.cs b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Navigation/FSharpInheritorsContextSearch.cs new file mode 100644 index 0000000000..5f28755451 --- /dev/null +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Navigation/FSharpInheritorsContextSearch.cs @@ -0,0 +1,14 @@ +using JetBrains.Application; +using JetBrains.Application.DataContext; +using JetBrains.ReSharper.Feature.Services.Navigation.ContextNavigation; + +namespace JetBrains.ReSharper.Plugins.FSharp.Psi.Navigation; + +[ShellFeaturePart] +public class FSharpInheritorsContextSearch : InheritorsContextSearch +{ + public override bool IsContextApplicable(IDataContext dataContext) => + FSharpContextNavigationUtil.SupportsNoHierarchyNavigation(dataContext, ReferencePreferenceKind); + + public override bool IsAvailable(IDataContext context) => false; +} diff --git a/ReSharper.FSharp/test/data/features/navigation/base/Union case 01.fs.gold b/ReSharper.FSharp/test/data/features/navigation/base/Union case 01.fs.gold index aaaea6c051..5f282702bb 100644 --- a/ReSharper.FSharp/test/data/features/navigation/base/Union case 01.fs.gold +++ b/ReSharper.FSharp/test/data/features/navigation/base/Union case 01.fs.gold @@ -1,3 +1 @@ -## NavigateToBaseProvider activity: - Tooltip was shown: Base properties of 'A' were not found - + \ No newline at end of file From a652056f3e22f8a02150133771487dfa6a4c5549 Mon Sep 17 00:00:00 2001 From: Eugene Auduchinok Date: Tue, 26 May 2026 15:54:58 +0200 Subject: [PATCH 3/3] RIDER-139012 Debugger/return values: drop 'returned' text GitOrigin-RevId: 547652a23d05c9c9d22ccf595f44d12f1a92b2f9 --- .../gold/testReturnValues.gold | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/rider-fsharp/src/test/testData/debugger/FSharpSteppingTest/testReturnValues/gold/testReturnValues.gold b/rider-fsharp/src/test/testData/debugger/FSharpSteppingTest/testReturnValues/gold/testReturnValues.gold index 934dfbb4cd..144b646c45 100644 --- a/rider-fsharp/src/test/testData/debugger/FSharpSteppingTest/testReturnValues/gold/testReturnValues.gold +++ b/rider-fsharp/src/test/testData/debugger/FSharpSteppingTest/testReturnValues/gold/testReturnValues.gold @@ -31,7 +31,7 @@ $Program.main@() in , ReturnValueTest.dll Stepped over l4: --> Program.fs:24(212,254) // let i1 = l1.Length + l2.Length + l3.Length $Program.main@() in , ReturnValueTest.dll - +List.map _.Length … returned = {FSharpList} Length = 2 + +List.map _.Length … = {FSharpList} Length = 2 +l2 = {FSharpList} Length = 1 +l3 = {FSharpList} Length = 2 +l4 = {FSharpList} Length = 2 @@ -40,10 +40,10 @@ $Program.main@() in , ReturnValueTest.dll Stepped over i1: --> Program.fs:25(255,267) // let i2 = f 1 $Program.main@() in , ReturnValueTest.dll - +l1 returned = {FSharpList} Length = 0 - l1.Length returned = {int} 0 - l2.Length returned = {int} 1 - l3.Length returned = {int} 2 + +l1 = {FSharpList} Length = 0 + l1.Length = {int} 0 + l2.Length = {int} 1 + l3.Length = {int} 2 i1 = {int} 3 +l2 = {FSharpList} Length = 1 +l3 = {FSharpList} Length = 2 @@ -53,7 +53,7 @@ $Program.main@() in , ReturnValueTest.dll Stepped over i2: --> Program.fs:26(268,286) // let i3 = f (1 + 1) $Program.main@() in , ReturnValueTest.dll - f 1 returned = {int} 2 + f 1 = {int} 2 i1 = {int} 3 i2 = {int} 2 +l2 = {FSharpList} Length = 1 @@ -64,7 +64,7 @@ $Program.main@() in , ReturnValueTest.dll Stepped over i3: --> Program.fs:27(287,321) // let i4 = f (System.Math.Max(1, 2)) $Program.main@() in , ReturnValueTest.dll - f (1 + 1) returned = {int} 3 + f (1 + 1) = {int} 3 i1 = {int} 3 i2 = {int} 2 i3 = {int} 3 @@ -76,8 +76,8 @@ $Program.main@() in , ReturnValueTest.dll Stepped over i4: --> Program.fs:28(322,334) // let i5 = g 1 $Program.main@() in , ReturnValueTest.dll - System.Math.Max(1, 2) returned = {int} 2 - f (System.Math.Max(1, 2)) returned = {int} 3 + System.Math.Max(1, 2) = {int} 2 + f (System.Math.Max(1, 2)) = {int} 3 i1 = {int} 3 i2 = {int} 2 i3 = {int} 3 @@ -90,7 +90,7 @@ $Program.main@() in , ReturnValueTest.dll Stepped over i5: --> Program.fs:29(335,350) // let i6 = t.Prop $Program.main@() in , ReturnValueTest.dll - g 1 returned = {int} 1 + g 1 = {int} 1 i1 = {int} 3 i2 = {int} 2 i3 = {int} 3 @@ -104,7 +104,7 @@ $Program.main@() in , ReturnValueTest.dll Stepped over i6: --> Program.fs:30(351,371) // let i7 = h ((+) 1) 1 $Program.main@() in , ReturnValueTest.dll - t.Prop returned = {int} 1 + t.Prop = {int} 1 i1 = {int} 3 i2 = {int} 2 i3 = {int} 3 @@ -119,7 +119,7 @@ $Program.main@() in , ReturnValueTest.dll Stepped over i7: --> Program.fs:31(372,392) // let i8 = h (add 1) 1 $Program.main@() in , ReturnValueTest.dll - h ((+) 1) 1 returned = {int} 2 + h ((+) 1) 1 = {int} 2 i1 = {int} 3 i2 = {int} 2 i3 = {int} 3 @@ -135,7 +135,7 @@ $Program.main@() in , ReturnValueTest.dll Stepped over i8: --> Program.fs:33(394,407) // let u1 = g () $Program.main@() in , ReturnValueTest.dll - h (add 1) 1 returned = {int} 2 + h (add 1) 1 = {int} 2 i1 = {int} 3 i2 = {int} 2 i3 = {int} 3 @@ -184,7 +184,7 @@ $Program.main@() in , ReturnValueTest.dll Stepped over s1: --> Program.fs:37(452,492) // let s2 = "123".Substring(1).Substring(1) $Program.main@() in , ReturnValueTest.dll - "123".Substring(1) returned = {string} "23" + "123".Substring(1) = {string} "23" i1 = {int} 3 i2 = {int} 2 i3 = {int} 3 @@ -202,8 +202,8 @@ $Program.main@() in , ReturnValueTest.dll Stepped over s2: --> Program.fs:39(494,508) // let f1 = add 1 $Program.main@() in , ReturnValueTest.dll - "123".Substring(1) returned = {string} "23" - "123".Substring(1).Substring(1) returned = {string} "3" + "123".Substring(1) = {string} "23" + "123".Substring(1).Substring(1) = {string} "3" i1 = {int} 3 i2 = {int} 2 i3 = {int} 3