Exemple #1
0
        public DocumentReferenceViewModel BuildReference(DataType dataType)
        {
            var comment = _commentParser.Read(dataType);
            var id      = BuildDataTypeId(dataType, comment);
            var uri     = BuildDataTypeUri(dataType);
            var titles  = BuildDataTypeIndexTitles(dataType);

            return(new DocumentReferenceViewModel(id, uri, titles));
        }
Exemple #2
0
        void AddMemberToTarget(Member member, DataType parentDataType, HashSet <DocumentViewModel> target)
        {
            // If this is some kind of overridden member, try to resolve the original declaration as it's the one that's
            // interesting to us
            member = ResolveOriginalDeclaration(member);

            // NOTE: Instead of just using GetUri and GetId directly on the entity to generate the ID, we use the
            // signature variants of the uri/id methods instead and prefix it with the uri and id of the containing
            // data type.
            //
            // This is done to properly support flattening inherited members into the data exchange format used by the
            // compiler backend; while the ToString() method on a type that inherits from Uno.Object without overriding
            // ToString() directly will have the ToString() method listed when using the EnumerateFlattenedMethods()
            // extension method, that method will still belong to Uno.Object and not the type that inherited the method.
            //
            // The data structure requires the type to own its own inherited methods, hence we do it like this.
            var id  = parentDataType.GetUri() + "/" + member.GetUriSignature();
            var uri = GetMemberUri(member, parentDataType);

            var comment = _commentParser.Read(member);
            var ns      = parentDataType.FindNamespace();
            var titles  = new TitlesViewModel(Naming.GetPageTitle(member),
                                              Naming.GetIndexTitle(member),
                                              Naming.GetFullIndexTitle(member),
                                              Naming.GetNavigationTitle(member),
                                              member.FullName);
            var syntax       = new SyntaxViewModel(Syntax.BuildUnoSyntax(member, parentDataType), Syntax.BuildUxSyntax(member));
            var location     = new LocationViewModel(ns.FullName, ns.GetUri(), member.Source.Package.Name, member.Source.Package.Version);
            var declaredIn   = new DataTypeBuilder(Naming, Syntax, Exportable, AttachedMembers, _commentParser).BuildReference(member.DeclaringType);
            var parameters   = GetParameters(member);
            var returns      = GetReturns(member);
            var uxProperties = GetUxProperties(member);
            var values       = BuildValues(member);
            var flags        = BuildFlags(member);
            var attributes   = BuildAttributes(member);

            var type      = GetTypeName(member, comment, uxProperties);
            var isVirtual = uri == null;

            var viewModel = new MemberViewModel(new DocumentIdViewModel(id, parentDataType.GetUri(), type, member.GetModifierNames()),
                                                new DocumentUriViewModel(id, member.GetUri(), isVirtual),
                                                titles,
                                                syntax,
                                                location,
                                                declaredIn,
                                                parameters,
                                                returns,
                                                uxProperties,
                                                values,
                                                flags,
                                                new CommentViewModel(comment),
                                                attributes,
                                                member);

            target.AddIfNotExists(viewModel);
        }
Exemple #3
0
        private bool IsVisible(IEntity entity)
        {
            // Regardless of entity visibility, if it's annotated with one of these flags it should be exported regardless:
            //  - @scriptevent
            //  - @scriptmethod
            //  - @scriptmodule
            //  - @scriptproperty
            var comment   = new SourceComment();
            var sourceObj = entity as SourceObject;

            if (sourceObj != null)
            {
                comment = _commentParser.Read(sourceObj);
            }

            if (comment.Attributes.ScriptEvent != null ||
                comment.Attributes.ScriptMethod != null ||
                comment.Attributes.ScriptModule != null ||
                comment.Attributes.ScriptProperty != null)
            {
                return(true);
            }

            if (entity.IsPrivate || entity.IsInternal)
            {
                return(false);
            }

            //If this type is visible but it has a parent type which is not, it should itself not be visible.
            //Note: restricting this to interfaces for now to avoid conflicts
            var @interface = entity as InterfaceType;

            if (@interface != null && @interface.IsNestedType)
            {
                return((@interface.ParentType != null) ? IsVisible(@interface.ParentType) : true);
            }

            var member = entity as Member;

            if (member == null)
            {
                return(true);
            }

            // Don't show protected members for sealed data types
            return(!member.DeclaringType.IsSealed || !member.IsProtected);
        }