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

            return(stack);
        }
Ejemplo n.º 2
0
        public override DirectiveStack ApplyDirectives(DirectiveStack stack)
        {
            if (this.ContainsDirectives)
            {
                stack = ApplyDirectivesToTrivia(this.GetLeadingTrivia(), stack);
                stack = ApplyDirectivesToTrivia(this.GetTrailingTrivia(), stack);
            }

            return(stack);
        }
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 6
0
 public void SetDirectiveStack(DirectiveStack directives)
 {
     _directives    = directives;
     _hasDirectives = true;
 }
Ejemplo n.º 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));
     }
 }
Ejemplo n.º 8
0
 public virtual DirectiveStack ApplyDirectives(DirectiveStack stack)
 {
     return(ApplyDirectives(this, stack));
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 10
0
 public DirectiveParser(Lexer lexer, DirectiveStack context)
     : base(lexer, LexerMode.Directive)
 {
     _context = context;
 }