Exemple #1
0
        public static string GetHighlightingAttributeId([NotNull] this FSharpSymbol symbol)
        {
            switch (symbol)
            {
            case FSharpEntity entity when !entity.IsUnresolved:
                return(GetEntityHighlightingAttributeId(entity.GetAbbreviatedEntity()));

            case FSharpMemberOrFunctionOrValue mfv when !mfv.IsUnresolved:
                return(GetMfvHighlightingAttributeId(mfv.AccessorProperty?.Value ?? mfv));

            case FSharpField field:
                return(field.IsLiteral
            ? FSharpHighlightingAttributeIdsModule.Literal
            : FSharpHighlightingAttributeIdsModule.Field);

            case FSharpUnionCase _:
                return(FSharpHighlightingAttributeIdsModule.UnionCase);

            case FSharpGenericParameter _:
                return(FSharpHighlightingAttributeIdsModule.TypeParameter);

            case FSharpActivePatternCase _:
                return(FSharpHighlightingAttributeIdsModule.ActivePatternCase);
            }

            // some highlighting is needed for tooltip provider
            return(FSharpHighlightingAttributeIdsModule.Value);
        }
Exemple #2
0
        public static string GetHighlightingAttributeId([NotNull] this FSharpSymbol symbol)
        {
            switch (symbol)
            {
            case FSharpEntity entity when !entity.IsUnresolved:
                return(GetEntityHighlightingAttributeId(entity));

            case FSharpMemberOrFunctionOrValue mfv when !mfv.IsUnresolved:
                return(GetMfvHighlightingAttributeId(mfv.AccessorProperty?.Value ?? mfv));

            case FSharpField field:
                return(field.IsLiteral
            ? HighlightingAttributeIds.CONSTANT_IDENTIFIER_ATTRIBUTE
            : HighlightingAttributeIds.FIELD_IDENTIFIER_ATTRIBUTE);

            case FSharpUnionCase _:
                return(HighlightingAttributeIds.TYPE_ENUM_ATTRIBUTE);

            case FSharpGenericParameter _:
                return(HighlightingAttributeIds.TYPE_PARAMETER_ATTRIBUTE);

            case FSharpActivePatternCase _:
                return(HighlightingAttributeIds.METHOD_IDENTIFIER_ATTRIBUTE);
            }

            // some highlighting is needed for tooltip provider
            return(HighlightingAttributeIds.LOCAL_VARIABLE_IDENTIFIER_ATTRIBUTE);
        }
        private static void AddUsagesRanges(FSharpSymbol symbol, HashSet <DocumentRange> ranges,
                                            FSharpCheckFileResults checkResults, IDocument document, IFSharpFile fsFile)
        {
            var isActivePatternCase = symbol is FSharpActivePatternCase;
            var isGreaterOp         =
                symbol is FSharpMemberOrFunctionOrValue mfv && mfv.LogicalName == StandardOperatorNames.GreaterThan;

            var symbolUsages = checkResults?.GetUsesOfSymbolInFile(symbol).RunAsTask();

            if (symbolUsages == null)
            {
                return;
            }

            foreach (var symbolUse in symbolUsages)
            {
                var treeOffset = document.GetTreeEndOffset(symbolUse.RangeAlternate);
                var usageToken = fsFile.FindTokenAt(treeOffset - 1);
                if (usageToken == null)
                {
                    continue;
                }

                if (isActivePatternCase && symbolUse.IsFromDefinition)
                {
                    if (!(symbolUse.Symbol is FSharpActivePatternCase useSymbol))
                    {
                        continue;
                    }

                    if (useSymbol.DeclarationLocation.Equals(symbolUse.RangeAlternate))
                    {
                        var caseDeclaration = usageToken.GetContainingNode <IActivePatternId>()?.Cases[useSymbol.Index];
                        if (caseDeclaration != null)
                        {
                            ranges.Add(caseDeclaration.GetDocumentRange());
                            continue;
                        }
                    }
                }

                if (!(usageToken is FSharpIdentifierToken identToken))
                {
                    continue;
                }

                var tokenType = identToken.GetTokenType();

                if ((tokenType == FSharpTokenType.GREATER || tokenType == FSharpTokenType.GREATER_RBRACK) && !isGreaterOp)
                {
                    continue; // found usage of generic symbol with specified type parameter
                }
                ranges.Add(identToken.GetDocumentRange());
            }
        }
        private static IList <FSharpField> GetFields([NotNull] FSharpSymbol typeSymbol)
        {
            switch (typeSymbol)
            {
            case FSharpUnionCase unionCase:
                return(unionCase.UnionCaseFields);

            case FSharpEntity entity when entity.IsFSharpExceptionDeclaration:
                return(entity.FSharpFields);

            default:
                return(null);
            }
        }
        public static IDeclaredElement CreateBindingDeclaredElement([NotNull] FSharpSymbol fcsSymbol,
                                                                    [NotNull] TopPatternDeclarationBase declaration)
        {
            if (!(fcsSymbol is FSharpMemberOrFunctionOrValue mfv))
            {
                return(null);
            }

            var typeDeclaration = declaration.GetContainingNode <ITypeDeclaration>();

            if (typeDeclaration == null)
            {
                return(null);
            }

            if (typeDeclaration is IFSharpTypeOldDeclaration)
            {
                if ((!mfv.CurriedParameterGroups.IsEmpty() || !mfv.GenericParameters.IsEmpty()) && !mfv.IsMutable)
                {
                    return(new FSharpTypePrivateMethod(declaration));
                }

                if (mfv.LiteralValue != null)
                {
                    return(new FSharpLiteral(declaration));
                }

                return(new FSharpTypePrivateField(declaration));
            }

            if (mfv.LiteralValue != null)
            {
                return(new FSharpLiteral(declaration));
            }

            if (!mfv.IsValCompiledAsMethod())
            {
                return(new ModuleValue(declaration));
            }

            return(!mfv.IsInstanceMember && mfv.CompiledName.StartsWith("op_", StringComparison.Ordinal)
        ? (IDeclaredElement) new FSharpSignOperator <TopPatternDeclarationBase>(declaration)
        : new ModuleFunction(declaration));
        }
        protected override FSharpSymbol GetActualSymbol(FSharpSymbol symbol)
        {
            if (!(symbol is FSharpMemberOrFunctionOrValue mfv))
            {
                return(null);
            }

            if (mfv.IsProperty || !mfv.IsModuleValueOrMember)
            {
                return(mfv);
            }

            if (mfv.AccessorProperty?.Value is { } prop)
            {
                return(prop);
            }

            var members = mfv.DeclaringEntity?.Value.MembersFunctionsAndValues;

            return(members?.FirstOrDefault(m => m.IsProperty && m.LogicalName == mfv.LogicalName) ?? mfv);
        }
Exemple #7
0
        public static ImmutableArray <string> From(FSharpSymbol symbol)
        {
            switch (symbol)
            {
            case FSharpField _: return(Field);

            case FSharpEntity e: return(FromEntity(e));

            case FSharpMemberOrFunctionOrValue m: {
                if (m.IsProperty)
                {
                    return(Property);
                }
                if (m.IsConstructor || m.FullType.IsFunctionType)
                {
                    return(Method);
                }
                return(ImmutableArray <string> .Empty);
            }

            default: return(ImmutableArray <string> .Empty);
            }
        }
Exemple #8
0
        protected override IDeclaredElement CreateDeclaredElement(FSharpSymbol fcsSymbol)
        {
            if (!(fcsSymbol is FSharpMemberOrFunctionOrValue mfv))
            {
                return(null);
            }

            if (mfv.IsProperty)
            {
                return(new FSharpProperty <MemberDeclaration>(this, mfv));
            }

            var property = mfv.AccessorProperty?.Value;

            if (property != null)
            {
                var cliEvent = property.EventForFSharpProperty?.Value;
                return(cliEvent != null
          ? (ITypeMember) new FSharpCliEvent <MemberDeclaration>(this)
          : new FSharpProperty <MemberDeclaration>(this, property));
            }

            return(new FSharpMethod <MemberDeclaration>(this));
        }
 protected override IDeclaredElement CreateDeclaredElement(FSharpSymbol fcsSymbol) =>
 CreateBindingDeclaredElement(fcsSymbol, this);
        public static IDeclaredElement GetDeclaredElement([CanBeNull] this FSharpSymbol symbol,
                                                          [NotNull] IPsiModule psiModule, [CanBeNull] IFSharpReferenceOwner referenceExpression = null)
        {
            if (symbol == null)
            {
                return(null);
            }

            if (symbol is FSharpEntity entity)
            {
                if (entity.IsUnresolved)
                {
                    return(null);
                }

                if (entity.IsNamespace)
                {
                    return(GetDeclaredNamespace(entity, psiModule));
                }

                return(GetTypeElement(entity, psiModule));
            }

            if (symbol is FSharpMemberOrFunctionOrValue mfv)
            {
                if (mfv.IsUnresolved)
                {
                    return(null);
                }

                return(mfv.IsModuleValueOrMember
          ? GetTypeMember(mfv, psiModule)
          : GetLocalValueDeclaredElement(mfv, referenceExpression));
            }

            if (symbol is FSharpUnionCase unionCase)
            {
                return(GetDeclaredElement(unionCase, psiModule));
            }

            if (symbol is FSharpField field)
            {
                if (field.IsAnonRecordField && referenceExpression != null)
                {
                    return(new FSharpAnonRecordFieldProperty(referenceExpression.Reference));
                }

                if (field.IsUnionCaseField && field.DeclaringUnionCase?.Value is { } fieldUnionCase)
                {
                    var unionEntity           = fieldUnionCase.ReturnType.TypeDefinition;
                    var fieldOwnerTypeElement =
                        unionEntity.UnionCases.Count > 1 && !unionEntity.IsValueType
              ? GetDeclaredElement(fieldUnionCase, psiModule, true) as ITypeElement
              : GetTypeElement(unionEntity, psiModule);

                    return(fieldOwnerTypeElement?.EnumerateMembers(field.Name, true).FirstOrDefault());
                }

                if (!field.IsUnresolved && field.DeclaringEntity?.Value is { } fieldEntity)
                {
                    return(GetTypeElement(fieldEntity, psiModule)?.EnumerateMembers(field.Name, true).FirstOrDefault());
                }
            }

            if (symbol is FSharpActivePatternCase patternCase)
            {
                return(GetActivePatternCaseElement(psiModule, referenceExpression, patternCase));
            }

            if (symbol is FSharpGenericParameter genericParameter)
            {
                return(GetTypeParameter(genericParameter, referenceExpression));
            }

            if (symbol is FSharpParameter parameter && referenceExpression != null)
            {
                return(parameter.GetOwner(referenceExpression.Reference)); // todo: map to parameter
            }
            return(null);
        }
        public static IDeclaredElement GetDeclaredElement([CanBeNull] this FSharpSymbol symbol,
                                                          [NotNull] IPsiModule psiModule, [CanBeNull] IFSharpReferenceOwner referenceExpression = null)
        {
            if (symbol == null)
            {
                return(null);
            }

            if (symbol is FSharpEntity entity)
            {
                if (entity.IsUnresolved)
                {
                    return(null);
                }

                if (entity.IsNamespace)
                {
                    return(GetDeclaredNamespace(entity, psiModule));
                }

                return(GetTypeElement(entity, psiModule));
            }

            if (symbol is FSharpMemberOrFunctionOrValue mfv)
            {
                if (mfv.IsUnresolved)
                {
                    return(null);
                }

                if (!mfv.IsModuleValueOrMember)
                {
                    var declaration = FindNode <IFSharpDeclaration>(mfv.DeclarationLocation, referenceExpression);
                    if (declaration is IFSharpLocalDeclaration localDeclaration)
                    {
                        return(localDeclaration);
                    }

                    return(declaration is ISynPat
            ? declaration.DeclaredElement
            : null);
                }

                var memberEntity = mfv.IsModuleValueOrMember ? mfv.DeclaringEntity : null;
                if (memberEntity == null)
                {
                    return(null);
                }

                if (mfv.IsConstructor && mfv.DeclaringEntity?.Value is FSharpEntity ctorEntity && ctorEntity.IsProvided)
                {
                    return(GetDeclaredElement(memberEntity.Value, psiModule, referenceExpression));
                }

                var typeElement = GetTypeElement(memberEntity.Value, psiModule);
                if (typeElement == null)
                {
                    return(null);
                }

                var mfvCompiledName = mfv.GetMfvCompiledName();
                var members         = mfv.IsConstructor
          ? typeElement.Constructors.AsList <ITypeMember>()
          : typeElement.EnumerateMembers(mfvCompiledName, true).AsList();

                switch (members.Count)
                {
                case 0:
                    return(null);

                case 1:
                    return(members[0]);
                }

                var mfvXmlDocId = GetXmlDocId(mfv);
                return(members.FirstOrDefault(member =>
                                              // todo: Fix signature for extension properties
                                              member is IFSharpMember fsMember && fsMember.Mfv?.XmlDocSig == mfvXmlDocId ||
                                              member.XMLDocId == mfvXmlDocId));
            }

            if (symbol is FSharpUnionCase unionCase)
            {
                if (unionCase.IsUnresolved)
                {
                    return(null);
                }

                var unionTypeElement = GetTypeElement(unionCase.ReturnType.TypeDefinition, psiModule);
                if (unionTypeElement == null)
                {
                    return(null);
                }

                var caseCompiledName = unionCase.CompiledName;
                var caseMember       = unionTypeElement.GetMembers().FirstOrDefault(m =>
                {
                    var shortName = m.ShortName;
                    return(shortName == caseCompiledName || shortName == "New" + caseCompiledName);
                });

                if (caseMember != null)
                {
                    return(caseMember);
                }

                var unionClrName     = unionTypeElement.GetClrName();
                var caseDeclaredType = TypeFactory.CreateTypeByCLRName(unionClrName + "+" + caseCompiledName, psiModule);
                return(caseDeclaredType.GetTypeElement());
            }

            if (symbol is FSharpField field)
            {
                if (field.IsAnonRecordField)
                {
                    return(new FSharpAnonRecordFieldProperty(referenceExpression.Reference));
                }

                if (field.IsUnionCaseField && field.DeclaringUnionCase?.Value is var fieldUnionCase)
                {
                    var unionCaseTypeElement = GetDeclaredElement(fieldUnionCase, psiModule, referenceExpression) as ITypeElement;
                    return(unionCaseTypeElement?.EnumerateMembers(field.Name, true).FirstOrDefault());
                }

                if (!field.IsUnresolved && field.DeclaringEntity?.Value is FSharpEntity fieldEntity)
                {
                    return(GetTypeElement(fieldEntity, psiModule)?.EnumerateMembers(field.Name, true).FirstOrDefault());
                }
            }

            if (symbol is FSharpActivePatternCase patternCase)
            {
                return(GetActivePatternCaseElement(psiModule, referenceExpression, patternCase));
            }

            if (symbol is FSharpGenericParameter genericParameter)
            {
                return(GetTypeParameter(genericParameter, referenceExpression));
            }

            if (symbol is FSharpParameter parameter && referenceExpression != null)
            {
                return(parameter.GetOwner(referenceExpression.Reference)); // todo: map to parameter
            }
            return(null);
        }
 public ResolvedFSharpSymbolElement(FSharpSymbol symbol, FSharpIdentifierToken referenceOwnerToken)
 {
     Symbol        = symbol;
     Module        = referenceOwnerToken.GetPsiModule();
     myPsiServices = referenceOwnerToken.GetPsiServices();
 }
        public static IDeclaredElement GetDeclaredElement([CanBeNull] FSharpSymbol symbol,
                                                          [NotNull] IPsiModule psiModule, [CanBeNull] IReferenceExpression referenceExpression = null)
        {
            if (symbol == null)
            {
                return(null);
            }

            if (symbol is FSharpEntity entity)
            {
                if (entity.IsUnresolved)
                {
                    return(null);
                }

                if (entity.IsNamespace)
                {
                    return(GetDeclaredNamespace(entity, psiModule));
                }

                return(GetTypeElement(entity, psiModule));
            }

            if (symbol is FSharpMemberOrFunctionOrValue mfv)
            {
                if (mfv.IsUnresolved)
                {
                    return(null);
                }

                if (!mfv.IsModuleValueOrMember)
                {
                    var declaration = FindNode <IFSharpDeclaration>(mfv.DeclarationLocation, referenceExpression);
                    if (declaration is IFSharpLocalDeclaration localDeclaration)
                    {
                        return(localDeclaration);
                    }

                    return(declaration is ISynPat
            ? declaration.DeclaredElement
            : null);
                }

                var memberEntity = mfv.IsModuleValueOrMember ? mfv.DeclaringEntity : null;
                if (memberEntity == null)
                {
                    return(null);
                }

                if (mfv.IsConstructor && mfv.DeclaringEntity?.Value is FSharpEntity ctorEntity && ctorEntity.IsProvided)
                {
                    return(GetDeclaredElement(memberEntity.Value, psiModule, referenceExpression));
                }

                var typeElement = GetTypeElement(memberEntity.Value, psiModule);
                if (typeElement == null)
                {
                    return(null);
                }

                var members = mfv.IsConstructor
          ? typeElement.Constructors.AsList <ITypeMember>()
          : typeElement.EnumerateMembers(mfv.GetMemberCompiledName(), true).AsList();

                switch (members.Count)
                {
                case 0:
                    return(null);

                case 1:
                    return(members[0]);
                }

                // F# optional extension member in a module.
                if (mfv.IsExtensionMember && mfv.IsInstanceMember)
                {
                    var apparentType = GetTypeElement(mfv.ApparentEnclosingEntity, psiModule);
                    if (apparentType != null)
                    {
                        foreach (var member in members)
                        {
                            if (!(member is IFSharpExtensionTypeMember e) || !(e.ApparentEntity is FSharpEntity otherEntity))
                            {
                                continue;
                            }

                            var otherApparentType = GetTypeElement(otherEntity, psiModule);
                            if (otherApparentType != null && Equals(otherApparentType, apparentType))
                            {
                                return(member);
                            }
                        }
                    }
                }

                var mfvXmlDocId = GetXmlDocId(mfv);
                return(members.FirstOrDefault(m => m.XMLDocId == mfvXmlDocId));
            }

            if (symbol is FSharpUnionCase unionCase)
            {
                if (unionCase.IsUnresolved)
                {
                    return(null);
                }

                var unionTypeElement = GetTypeElement(unionCase.ReturnType.TypeDefinition, psiModule);
                if (unionTypeElement == null)
                {
                    return(null);
                }

                var caseCompiledName = unionCase.CompiledName;
                var caseMember       = unionTypeElement.GetMembers().FirstOrDefault(m =>
                {
                    var shortName = m.ShortName;
                    return(shortName == caseCompiledName || shortName == "New" + caseCompiledName);
                });

                if (caseMember != null)
                {
                    return(caseMember);
                }

                var unionClrName     = unionTypeElement.GetClrName();
                var caseDeclaredType = TypeFactory.CreateTypeByCLRName(unionClrName + "+" + caseCompiledName, psiModule);
                return(caseDeclaredType.GetTypeElement());
            }

            if (symbol is FSharpField field && !field.IsUnresolved)
            {
                return(GetTypeElement(field.DeclaringEntity, psiModule)?.EnumerateMembers(field.Name, true).FirstOrDefault());
            }

            // find active pattern entity/member. if it's compiled use wrapper. if it's source defined find actual element
            if (symbol is FSharpActivePatternCase activePatternCase)
            {
                return(GetActivePatternCaseElement(activePatternCase, psiModule, referenceExpression));
            }

            if (symbol is FSharpGenericParameter parameter)
            {
                return(GetTypeParameter(parameter, referenceExpression));
            }

            return(null);
        }
Exemple #14
0
        public static IDeclaredElement GetDeclaredElement([CanBeNull] FSharpSymbol symbol,
                                                          [NotNull] IPsiModule psiModule, [CanBeNull] FSharpIdentifierToken referenceOwnerToken = null)
        {
            if (symbol == null)
            {
                return(null);
            }

            if (symbol is FSharpEntity entity)
            {
                if (entity.IsUnresolved)
                {
                    return(null);
                }
                return(entity.IsNamespace
          ? GetDeclaredNamespace(entity, psiModule)
          : GetTypeElement(entity, psiModule));
            }

            if (symbol is FSharpMemberOrFunctionOrValue mfv)
            {
                if (mfv.IsUnresolved)
                {
                    return(null);
                }

                if (!mfv.IsModuleValueOrMember)
                {
                    return(FindDeclaration <LocalDeclaration>(mfv.DeclarationLocation, referenceOwnerToken));
                }

                var memberEntity = mfv.IsModuleValueOrMember ? mfv.DeclaringEntity : null;
                if (memberEntity == null)
                {
                    return(null);
                }

                if (mfv.IsImplicitConstructor)
                {
                    return(GetDeclaredElement(memberEntity.Value, psiModule, referenceOwnerToken));
                }

                var typeElement = GetTypeElement(memberEntity.Value, psiModule);
                if (typeElement == null)
                {
                    return(null);
                }

                var members = mfv.IsConstructor
          ? typeElement.Constructors.AsList <ITypeMember>()
          : typeElement.EnumerateMembers(mfv.GetMemberCompiledName(), true).AsList();

                switch (members.Count)
                {
                case 0:
                    return(null);

                case 1:
                    return(members[0]);
                }

                var mfvXmlDocId = GetXmlDocId(mfv);
                return(members.FirstOrDefault(m => m.XMLDocId == mfvXmlDocId));
            }

            if (symbol is FSharpUnionCase unionCase)
            {
                if (unionCase.IsUnresolved)
                {
                    return(null);
                }

                var unionType = unionCase.ReturnType;
                Assertion.AssertNotNull(unionType, "unionType != null");
                var unionTypeElement = GetTypeElement(unionType.TypeDefinition, psiModule);
                if (unionTypeElement == null)
                {
                    return(null);
                }

                var caseMember = unionTypeElement.EnumerateMembers(unionCase.CompiledName, true).FirstOrDefault();
                if (caseMember != null)
                {
                    return(caseMember);
                }

                var newCaseMember = unionTypeElement.EnumerateMembers("New" + unionCase.CompiledName, true).FirstOrDefault();
                if (newCaseMember != null)
                {
                    return(newCaseMember);
                }

                var unionClrName     = unionTypeElement.GetClrName();
                var caseDeclaredType = TypeFactory.CreateTypeByCLRName(unionClrName + "+" + unionCase.CompiledName, psiModule);
                return(caseDeclaredType.GetTypeElement());
            }

            if (symbol is FSharpField field && !field.IsUnresolved)
            {
                return(GetTypeElement(field.DeclaringEntity, psiModule)?.EnumerateMembers(field.Name, true).FirstOrDefault());
            }

            if (symbol is FSharpActivePatternCase activePatternCase)
            {
                return
                    (activePatternCase.Group.DeclaringEntity != null
          ? new ResolvedFSharpSymbolElement(activePatternCase, referenceOwnerToken)
          : FindDeclaration <ActivePatternCaseDeclaration>(activePatternCase.DeclarationLocation, referenceOwnerToken)?.DeclaredElement);
            }

            return(null);
        }
Exemple #15
0
 protected override IList <FSharpField> GetTypeFields(FSharpSymbol type) =>
 type is FSharpEntity
 {
 protected override IDeclaredElement CreateDeclaredElement([CanBeNull] FSharpSymbol fcsSymbol) =>
 fcsSymbol is FSharpMemberOrFunctionOrValue mfv && (mfv.IsPropertyGetterMethod || mfv.IsPropertySetterMethod)
 protected override FSharpSymbol GetActualSymbol(FSharpSymbol symbol) =>
 (symbol as FSharpMemberOrFunctionOrValue)?.AccessorProperty?.Value?.EventForFSharpProperty?.Value;
 public IDeclaredElement GetOrCreateDeclaredElement([NotNull] FSharpSymbol fcsSymbol) =>
 this.GetOrCreateDeclaredElement(declaration => declaration.CreateDeclaredElement(fcsSymbol));
 protected virtual IDeclaredElement CreateDeclaredElement([NotNull] FSharpSymbol fcsSymbol) =>
 CreateDeclaredElement();
Exemple #20
0
 protected override IDeclaredElement CreateDeclaredElement(FSharpSymbol fcsSymbol) =>
 this.CreateMemberDeclaredElement(fcsSymbol);
Exemple #21
0
 private static bool CanIgnoreSymbol([NotNull] FSharpSymbol symbol) =>
 symbol is FSharpEntity ||
 symbol is FSharpMemberOrFunctionOrValue mfv && mfv.LogicalName == "op_RangeStep";
 protected virtual FSharpSymbol GetActualSymbol([NotNull] FSharpSymbol symbol) => symbol;
Exemple #23
0
 protected override IList <FSharpField> GetTypeFields(FSharpSymbol type) =>
 type is FSharpUnionCase unionCase ? unionCase.Fields : null;
 protected abstract IList <FSharpField> GetTypeFields([NotNull] FSharpSymbol type);
 protected override IList <FSharpField> GetTypeFields(FSharpSymbol type) =>
 type is FSharpEntity entity && entity.IsFSharpExceptionDeclaration ? entity.FSharpFields : null;