public override void VisitGlobalStatement(GlobalStatementSyntax node)
 {
     throw new NotSupportedException();
 }
			public override void VisitGlobalStatement(GlobalStatementSyntax node)
			{
				base.VisitGlobalStatement(node);
				_counter++;
			}
Esempio n. 3
0
 public override void VisitGlobalStatement(GlobalStatementSyntax node)
 {
     VisitStatementIfNotNull(node.Statement);
 }
Esempio n. 4
0
 private bool CheckGlobalStatement(SemanticModel semanticModel, GlobalStatementSyntax globalStatement, CancellationToken cancellationToken)
 {
     return(true);
 }
        private ImmutableArray <SingleNamespaceOrTypeDeclaration> VisitNamespaceChildren(
            CSharpSyntaxNode node,
            SyntaxList <MemberDeclarationSyntax> members,
            CoreInternalSyntax.SyntaxList <Syntax.InternalSyntax.MemberDeclarationSyntax> internalMembers)
        {
            Debug.Assert(node.Kind() == SyntaxKind.NamespaceDeclaration || (node.Kind() == SyntaxKind.CompilationUnit && _syntaxTree.Options.Kind == SourceCodeKind.Regular));

            if (members.Count == 0)
            {
                return(ImmutableArray <SingleNamespaceOrTypeDeclaration> .Empty);
            }

            // We look for members that are not allowed in a namespace.
            // If there are any we create an implicit class to wrap them.
            bool hasGlobalMembers        = false;
            bool acceptSimpleProgram     = node.Kind() == SyntaxKind.CompilationUnit && _syntaxTree.Options.Kind == SourceCodeKind.Regular;
            bool hasAwaitExpressions     = false;
            bool isIterator              = false;
            bool hasReturnWithExpression = false;
            GlobalStatementSyntax firstGlobalStatement = null;

            var childrenBuilder = ArrayBuilder <SingleNamespaceOrTypeDeclaration> .GetInstance();

            foreach (var member in members)
            {
                SingleNamespaceOrTypeDeclaration namespaceOrType = Visit(member);
                if (namespaceOrType != null)
                {
                    childrenBuilder.Add(namespaceOrType);
                }
                else if (acceptSimpleProgram && member.IsKind(SyntaxKind.GlobalStatement))
                {
                    var global = (GlobalStatementSyntax)member;
                    firstGlobalStatement ??= global;
                    var topLevelStatement = global.Statement;

                    if (!hasAwaitExpressions)
                    {
                        hasAwaitExpressions = SyntaxFacts.HasAwaitOperations(topLevelStatement);
                    }

                    if (!isIterator)
                    {
                        isIterator = SyntaxFacts.HasYieldOperations(topLevelStatement);
                    }

                    if (!hasReturnWithExpression)
                    {
                        hasReturnWithExpression = SyntaxFacts.HasReturnWithExpression(topLevelStatement);
                    }
                }
                else if (!hasGlobalMembers && member.Kind() != SyntaxKind.IncompleteMember)
                {
                    hasGlobalMembers = true;
                }
            }

            // wrap all global statements in a compilation unit into a simple program type:
            if (firstGlobalStatement is object)
            {
                childrenBuilder.Add(CreateSimpleProgram(firstGlobalStatement, hasAwaitExpressions, isIterator, hasReturnWithExpression));
            }

            // wrap all members that are defined in a namespace or compilation unit into an implicit type:
            if (hasGlobalMembers)
            {
                //The implicit class is not static and has no extensions
                SingleTypeDeclaration.TypeDeclarationFlags declFlags = SingleTypeDeclaration.TypeDeclarationFlags.None;
                var memberNames = GetNonTypeMemberNames(internalMembers, ref declFlags, skipGlobalStatements: acceptSimpleProgram);
                var container   = _syntaxTree.GetReference(node);

                childrenBuilder.Add(CreateImplicitClass(memberNames, container, declFlags));
            }

            return(childrenBuilder.ToImmutableAndFree());
        }
 public override void VisitGlobalStatement(GlobalStatementSyntax node)
 {
     // Intentionally left empty.
     // Global statements are handled in CompilationUnitVisitor
 }
Esempio n. 7
0
 public override void VisitGlobalStatement(GlobalStatementSyntax node)
 {
     throw new NotSupportedException();
 }
 //
 // Summary:
 //     Called when the visitor visits a GlobalStatementSyntax node.
 public virtual void VisitGlobalStatement(GlobalStatementSyntax node);
 /// <summary>
 /// 
 /// </summary>
 /// <param name="node"></param>
 public override sealed void VisitGlobalStatement(GlobalStatementSyntax node)
 {
     this.OnNodeVisited(node, this.type.IsInstanceOfType(node));
     base.VisitGlobalStatement(node);
 }
 public override void VisitGlobalStatement(GlobalStatementSyntax node)
 {
     base.VisitGlobalStatement(node);
     _counter++;
 }
Esempio n. 11
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="node"></param>
 public override sealed void VisitGlobalStatement(GlobalStatementSyntax node)
 {
     this.OnNodeVisited(node);
     if (!this.traverseRootOnly) base.VisitGlobalStatement(node);
 }
Esempio n. 12
0
 public override void VisitGlobalStatement(GlobalStatementSyntax node)
 {
     Debug.Fail(node.ToString());
     base.VisitGlobalStatement(node);
 }
Esempio n. 13
0
 // 全局语句
 public virtual void VisitGlobalStatementSyntax(GlobalStatementSyntax value)
 {
     DefaultVisit(value);
 }
 private bool CheckGlobalStatement(SemanticModel semanticModel, GlobalStatementSyntax globalStatement, CancellationToken cancellationToken)
 {
     return true;
 }
Esempio n. 15
0
 public override void VisitGlobalStatement(GlobalStatementSyntax node)
 {
 }
Esempio n. 16
0
 public override void VisitGlobalStatement(GlobalStatementSyntax node)
 {
     Visit(node.Statement);
 }
Esempio n. 17
0
        public override void VisitGlobalStatement(GlobalStatementSyntax node)
        {
            node.Statement?.Accept(this);

            base.VisitGlobalStatement(node);
        }