public static MemberDecoration GetDecoration(INestedTypeUnionCaseDeclaration caseDeclaration) { if (caseDeclaration.FieldsEnumerable.IsEmpty()) { return(MemberDecoration.FromModifiers(Modifiers.INTERNAL)); } return(caseDeclaration.GetContainingTypeDeclaration() is IUnionDeclaration unionDeclaration ? GetDecoration(unionDeclaration.AccessModifiers, TreeNodeEnumerable <IFSharpAttribute> .Empty) : MemberDecoration.DefaultValue); }
public static MemberDecoration GetDecoration(IUnionCaseDeclaration caseDeclaration) { if (caseDeclaration.FieldsEnumerable.IsEmpty()) { return(MemberDecoration.FromModifiers(Modifiers.INTERNAL)); } return(UnionRepresentationNavigator.GetByUnionCase(caseDeclaration) is var repr && FSharpTypeDeclarationNavigator.GetByTypeRepresentation(repr) is { } decl ? GetDecoration(decl.AccessModifier, TreeNodeCollection <IAttribute> .Empty) : MemberDecoration.DefaultValue); }
private static MemberDecoration Normalize(MemberDecoration decoration) { if (decoration.AccessRights == AccessRights.NONE) { decoration.AccessRights = AccessRights.PUBLIC; } if (decoration.IsStatic) { decoration.IsAbstract = true; decoration.IsSealed = true; } return(decoration); }
protected FSharpTypePart([NotNull] T declaration, [NotNull] string shortName, MemberDecoration memberDecoration, int typeParameters, [NotNull] ICacheBuilder cacheBuilder) : base(declaration, shortName, typeParameters) { Modifiers = memberDecoration; var attrNames = new FrugalLocalHashSet <string>(); foreach (var attr in declaration.GetAttributes()) { attrNames.Add(cacheBuilder.Intern(attr.GetShortName())); } AttributeClassNames = attrNames.ToArray(); var methods = new LocalList <ExtensionMethodInfo>(); foreach (var member in declaration.MemberDeclarations) { // There are two interesting scenarios: // * Members in types // * Bindings in modules // Type declaration as a member can only appear in module and we ignore it. if (member is ITypeDeclaration) { continue; } // A cheap check until we have a proper attributes resolve during cache building. if (!member.GetAttributes().Any(a => a.ShortNameEquals("Extension"))) { continue; } var offset = member.GetTreeStartOffset().Offset; methods.Add(new ExtensionMethodInfo(AnyCandidateType.INSTANCE, offset, member.DeclaredName) { Owner = this }); } if (methods.IsEmpty()) { return; } ExtensionMethodInfos = methods.ToArray(); }
protected FSharpTypeParametersOwnerPart([NotNull] T declaration, MemberDecoration memberDecoration, TreeNodeCollection <ITypeParameterOfTypeDeclaration> typeParameters, [NotNull] ICacheBuilder cacheBuilder) : base(declaration, cacheBuilder.Intern(declaration.CompiledName), memberDecoration, typeParameters.Count, cacheBuilder) { if (typeParameters.Count == 0) { myTypeParameterNames = EmptyArray <string> .Instance; return; } myTypeParameterNames = new string[typeParameters.Count]; for (var i = 0; i < typeParameters.Count; i++) { myTypeParameterNames[i] = cacheBuilder.Intern(typeParameters[i].CompiledName); } }
protected FSharpTypePart(IReader reader) : base(reader) { Modifiers = MemberDecoration.FromInt(reader.ReadInt()); AttributeClassNames = reader.ReadStringArray(); var extensionMethodCount = reader.ReadInt(); if (extensionMethodCount <= 0) { return; } var methods = new ExtensionMethodInfo[extensionMethodCount]; for (var i = 0; i < extensionMethodCount; i++) { methods[i] = new ExtensionMethodInfo(reader, this); } ExtensionMethodInfos = methods; }
protected FSharpTypeParametersOwnerPart([NotNull] T declaration, MemberDecoration memberDecoration, TreeNodeCollection <ITypeParameterOfTypeDeclaration> typeParameters, [NotNull] ICacheBuilder cacheBuilder) : base(declaration, cacheBuilder.Intern(declaration.ShortName), memberDecoration, typeParameters.Count, cacheBuilder) { var parameters = declaration.TypeParameters; if (parameters.Count == 0) { myTypeParameterNames = EmptyArray <string> .Instance; return; } myTypeParameterNames = new string[typeParameters.Count]; for (var i = 0; i < typeParameters.Count; i++) { var name = typeParameters[i].GetText(); var trimmed = !name.IsEmpty() && name[0] == '\'' ? name.Substring(1) : name; myTypeParameterNames[i] = cacheBuilder.Intern(trimmed); } }
protected FSharpTypePart([NotNull] T declaration, [NotNull] string shortName, MemberDecoration memberDecoration, int typeParameters, [NotNull] ICacheBuilder cacheBuilder) : base(declaration, shortName, typeParameters) { Modifiers = memberDecoration; var attributes = declaration.GetAttributes(); var attrNames = new FrugalLocalHashSet <string>(); foreach (var attr in attributes) { attrNames.Add(cacheBuilder.Intern(attr.LongIdentifier?.Name.GetAttributeShortName())); } AttributeClassNames = attrNames.ToArray(); if (!attributes.Any(a => a.ShortNameEquals("Extension"))) { return; } var methods = new LocalList <ExtensionMethodInfo>(); foreach (var member in declaration.MemberDeclarations) { if (!member.GetAttributes().Any(a => a.ShortNameEquals("Extension"))) { continue; } var offset = member.GetTreeStartOffset().Offset; methods.Add(new ExtensionMethodInfo(AnyCandidateType.INSTANCE, offset, member.DeclaredName) { Owner = this }); } ExtensionMethodInfos = methods.ToArray(); }
protected FSharpClassLikePart([NotNull] T declaration, MemberDecoration memberDecoration, TreeNodeCollection <ITypeParameterOfTypeDeclaration> typeParameters, [NotNull] ICacheBuilder cacheBuilder) : base(declaration, memberDecoration, typeParameters, cacheBuilder) { }
protected ModulePartBase([NotNull] T declaration, [NotNull] string shortName, MemberDecoration memberDecoration, [NotNull] ICacheBuilder cacheBuilder) : base(declaration, shortName, memberDecoration, 0, cacheBuilder) { }
public AnonModulePart([NotNull] IAnonModuleDeclaration declaration, [NotNull] ICacheBuilder cacheBuilder) : base(declaration, cacheBuilder.Intern(declaration.CompiledName), MemberDecoration.FromModifiers(ReSharper.Psi.Modifiers.PUBLIC), cacheBuilder) { }