Exemple #1
0
        public override SingleNamespaceOrTypeDeclaration VisitDelegateDeclaration(DelegateDeclarationSyntax node)
        {
            var declFlags = node.AttributeLists.Any()
                ? SingleTypeDeclaration.TypeDeclarationFlags.HasAnyAttributes
                : SingleTypeDeclaration.TypeDeclarationFlags.None;

            var diagnostics = DiagnosticBag.GetInstance();

            if (node.Arity == 0)
            {
                Symbol.ReportErrorIfHasConstraints(node.ConstraintClauses, diagnostics);
            }

            declFlags |= SingleTypeDeclaration.TypeDeclarationFlags.HasAnyNontypeMembers;

            var modifiers = node.Modifiers.ToDeclarationModifiers(diagnostics: diagnostics);

            return(new SingleTypeDeclaration(
                       kind: DeclarationKind.Delegate,
                       name: node.Identifier.ValueText,
                       modifiers: modifiers,
                       declFlags: declFlags,
                       arity: node.Arity,
                       syntaxReference: _syntaxTree.GetReference(node),
                       nameLocation: new SourceLocation(node.Identifier),
                       memberNames: ImmutableHashSet <string> .Empty,
                       children: ImmutableArray <SingleTypeDeclaration> .Empty,
                       diagnostics: diagnostics.ToReadOnlyAndFree()));
        }
        private SingleNamespaceOrTypeDeclaration VisitTypeDeclaration(TypeDeclarationSyntax node, DeclarationKind kind)
        {
            SingleTypeDeclaration.TypeDeclarationFlags declFlags = node.AttributeLists.Any() ?
                                                                   SingleTypeDeclaration.TypeDeclarationFlags.HasAnyAttributes :
                                                                   SingleTypeDeclaration.TypeDeclarationFlags.None;

            if (node.BaseList != null)
            {
                declFlags |= SingleTypeDeclaration.TypeDeclarationFlags.HasBaseDeclarations;
            }

            var diagnostics = DiagnosticBag.GetInstance();

            if (node.Arity == 0)
            {
                Symbol.ReportErrorIfHasConstraints(node.ConstraintClauses, diagnostics);
            }

            var memberNames = GetNonTypeMemberNames(((Syntax.InternalSyntax.TypeDeclarationSyntax)(node.Green)).Members,
                                                    ref declFlags);

            // A record with parameters at least has a primary constructor
            if (((declFlags & SingleTypeDeclaration.TypeDeclarationFlags.HasAnyNontypeMembers) == 0) &&
                node is RecordDeclarationSyntax {
                ParameterList : { }
            })
Exemple #3
0
        private SingleNamespaceOrTypeDeclaration VisitTypeDeclaration(TypeDeclarationSyntax node, DeclarationKind kind)
        {
            SingleTypeDeclaration.TypeDeclarationFlags declFlags = node.AttributeLists.Any() ?
                                                                   SingleTypeDeclaration.TypeDeclarationFlags.HasAnyAttributes :
                                                                   SingleTypeDeclaration.TypeDeclarationFlags.None;

            if (node.BaseList != null)
            {
                declFlags |= SingleTypeDeclaration.TypeDeclarationFlags.HasBaseDeclarations;
            }

            var diagnostics = DiagnosticBag.GetInstance();

            if (node.Arity == 0)
            {
                Symbol.ReportErrorIfHasConstraints(node.ConstraintClauses, diagnostics);
            }

            var memberNames = GetNonTypeMemberNames(((Syntax.InternalSyntax.TypeDeclarationSyntax)(node.Green)).Members,
                                                    ref declFlags);

            var modifiers = node.Modifiers.ToDeclarationModifiers(diagnostics: diagnostics);

            return(new SingleTypeDeclaration(
                       kind: kind,
                       name: node.Identifier.ValueText,
                       modifiers: modifiers,
                       arity: node.Arity,
                       declFlags: declFlags,
                       syntaxReference: _syntaxTree.GetReference(node),
                       nameLocation: new SourceLocation(node.Identifier),
                       memberNames: memberNames,
                       children: VisitTypeChildren(node),
                       diagnostics: diagnostics.ToReadOnlyAndFree()));
        }