示例#1
0
        private static DirectiveStack ApplyDirectivesToTrivia(GreenNode triviaList, DirectiveStack stack)
        {
            if (triviaList != null && triviaList.ContainsDirectives)
            {
                return(ApplyDirectivesToListOrNode(triviaList, stack));
            }

            return(stack);
        }
示例#2
0
        public override DirectiveStack ApplyDirectives(DirectiveStack stack)
        {
            if (this.ContainsDirectives)
            {
                stack = ApplyDirectivesToTrivia(this.GetLeadingTrivia(), stack);
                stack = ApplyDirectivesToTrivia(this.GetTrailingTrivia(), stack);
            }

            return(stack);
        }
示例#3
0
        private bool IsPreprocessorSymbolDefined(DirectiveStack directives, string symbolName)
        {
            switch (directives.IsDefined(symbolName))
            {
            case DefineState.Defined:
                return(true);

            case DefineState.Undefined:
                return(false);

            default:
                return(this.Options.PreprocessorSymbols.Contains(symbolName));
            }
        }
示例#4
0
        public static DirectiveStack ApplyDirectives(GreenNode node, DirectiveStack stack)
        {
            if (node.ContainsDirectives)
            {
                for (int i = 0, n = node.SlotCount; i < n; i++)
                {
                    var child = node.GetSlot(i);
                    if (child != null)
                    {
                        stack = ApplyDirectivesToListOrNode(child, stack);
                    }
                }
            }

            return(stack);
        }
示例#5
0
        public bool IncrementallyEquivalent(DirectiveStack other)
        {
            var  mine         = SkipInsignificantDirectives(_directives);
            var  theirs       = SkipInsignificantDirectives(other._directives);
            bool mineHasAny   = mine != null && mine.Any();
            bool theirsHasAny = theirs != null && theirs.Any();

            while (mineHasAny && theirsHasAny)
            {
                if (!mine.Head.IncrementallyEquivalent(theirs.Head))
                {
                    return(false);
                }

                mine         = SkipInsignificantDirectives(mine.Tail);
                theirs       = SkipInsignificantDirectives(theirs.Tail);
                mineHasAny   = mine != null && mine.Any();
                theirsHasAny = theirs != null && theirs.Any();
            }

            return(mineHasAny == theirsHasAny);
        }
示例#6
0
 public void SetDirectiveStack(DirectiveStack directives)
 {
     _directives    = directives;
     _hasDirectives = true;
 }
示例#7
0
 public static DirectiveStack ApplyDirectivesToListOrNode(GreenNode listOrNode, DirectiveStack stack)
 {
     // If we have a list of trivia, then that node is not actually a LeeSyntaxNode.
     // Just defer to our standard ApplyDirectives helper as it will do the appropriate
     // walking of this list to ApplyDirectives to the children.
     if (listOrNode.RawKind == GreenNode.ListKind)
     {
         return(ApplyDirectives(listOrNode, stack));
     }
     else
     {
         // Otherwise, we must have an actual piece of C# trivia.  Just apply the stack
         // to that node directly.
         return(((LeeSyntaxNode)listOrNode).ApplyDirectives(stack));
     }
 }
示例#8
0
 public virtual DirectiveStack ApplyDirectives(DirectiveStack stack)
 {
     return(ApplyDirectives(this, stack));
 }
示例#9
0
        public ParsedSyntaxTree(SourceText textOpt, string path, ParseOptions options, LeeSyntaxNode root, DirectiveStack directives)
        {
            Debug.Assert(root != null);
            Debug.Assert(options != null);
            Debug.Assert(textOpt != null);

            _lazyText = textOpt;
            _options  = options;
            _path     = path ?? string.Empty;
            _root     = root;
            _hasCompilationUnitRoot = root.Kind == SyntaxKind.CompilationUnit;
            this.SetDirectiveStack(directives);
        }
示例#10
0
 public DirectiveParser(Lexer lexer, DirectiveStack context)
     : base(lexer, LexerMode.Directive)
 {
     _context = context;
 }