private static DirectiveStack ApplyDirectivesToTrivia(GreenNode triviaList, DirectiveStack stack) { if (triviaList != null && triviaList.ContainsDirectives) { return(ApplyDirectivesToListOrNode(triviaList, stack)); } return(stack); }
public override DirectiveStack ApplyDirectives(DirectiveStack stack) { if (this.ContainsDirectives) { stack = ApplyDirectivesToTrivia(this.GetLeadingTrivia(), stack); stack = ApplyDirectivesToTrivia(this.GetTrailingTrivia(), stack); } return(stack); }
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)); } }
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); }
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); }
public void SetDirectiveStack(DirectiveStack directives) { _directives = directives; _hasDirectives = true; }
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)); } }
public virtual DirectiveStack ApplyDirectives(DirectiveStack stack) { return(ApplyDirectives(this, stack)); }
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); }
public DirectiveParser(Lexer lexer, DirectiveStack context) : base(lexer, LexerMode.Directive) { _context = context; }