Beispiel #1
0
 protected UnionPartBase([NotNull] IUnionDeclaration declaration, [NotNull] ICacheBuilder cacheBuilder,
                         bool hasPublicNestedTypes) : base(declaration, cacheBuilder)
 {
     HasPublicNestedTypes       = hasPublicNestedTypes;
     RepresentationAccessRights = GetRepresentationAccessRights(declaration);
     IsSingleCaseUnion          = declaration.UnionCases.Count == 1;
 }
Beispiel #2
0
        public override void VisitUnionDeclaration(IUnionDeclaration decl)
        {
            var unionCases = decl.UnionCases;

            var casesWithFieldsCount = 0;

            foreach (var unionCase in unionCases)
            {
                if (unionCase is INestedTypeUnionCaseDeclaration)
                {
                    casesWithFieldsCount++;
                }
            }
            var hasPublicNestedTypes = casesWithFieldsCount > 0 && unionCases.Count > 1;

            var unionPart =
                decl.HasAttribute(FSharpImplUtil.Struct)
          ? (Part) new StructUnionPart(decl, Builder, false)
          : new UnionPart(decl, Builder, hasPublicNestedTypes);

            Builder.StartPart(unionPart);
            foreach (var unionCase in unionCases)
            {
                unionCase.Accept(this);
            }
            ProcessTypeMembers(decl.MemberDeclarations);
            Builder.EndPart();
        }
Beispiel #3
0
 public void FinishUnionDeclaration(IUnionDeclaration decl)
 {
     foreach (var unionCase in decl.UnionCasesEnumerable)
     {
         unionCase.Accept(this);
     }
     ProcessTypeMembers(decl.MemberDeclarations);
     Builder.EndPart();
 }
Beispiel #4
0
        private static AccessRights GetRepresentationAccessRights([NotNull] IUnionDeclaration declaration)
        {
            var casesList = declaration.UnionCasesList;
            var modifier  = casesList.Modifier;

            if (modifier != null)
            {
                var tokenNodeType = modifier.GetTokenType();
                if (tokenNodeType == FSharpTokenType.PRIVATE)
                {
                    return(AccessRights.PRIVATE);
                }
                if (tokenNodeType == FSharpTokenType.INTERNAL)
                {
                    return(AccessRights.INTERNAL);
                }
            }

            // todo: hidden by signature in fsi
            return(AccessRights.PUBLIC);
        }
Beispiel #5
0
 public StructUnionPart([NotNull] IUnionDeclaration declaration, [NotNull] ICacheBuilder cacheBuilder,
                        bool hasPublicNestedTypes) : base(declaration, cacheBuilder, hasPublicNestedTypes)
 {
 }
Beispiel #6
0
 public StructUnionPart([NotNull] IUnionDeclaration declaration, [NotNull] ICacheBuilder cacheBuilder,
                        bool isSingleCase) : base(declaration, cacheBuilder, false, isSingleCase)
 {
 }
Beispiel #7
0
 public UnionPart([NotNull] IUnionDeclaration declaration, [NotNull] ICacheBuilder cacheBuilder,
                  bool hasPublicNestedTypes, bool isSingleCase) : base(declaration, cacheBuilder, hasPublicNestedTypes, isSingleCase)
 {
 }