public static PatternCapture Create(PatternVariable variable, SyntaxNodeOrToken startNodeOrToken, SyntaxNodeOrToken endNodeOrToken) { Debug.Assert(endNodeOrToken.Parent != startNodeOrToken.Parent, $"{nameof(endNodeOrToken)}.{nameof(endNodeOrToken.Parent)} must match {nameof(startNodeOrToken)}", nameof(endNodeOrToken)); return new PatternCapture(variable, startNodeOrToken, endNodeOrToken); }
private bool TryGetVariable(SyntaxToken token, out PatternVariable variable) { variable = null; if (token.Kind() != SyntaxKind.IdentifierToken) return false; var variableName = token.ValueText; return _variableMap.TryGetValue(variableName, out variable); }
private bool TryGetVariable(SyntaxNode node, out PatternVariable variable) { variable = null; var tokens = node.DescendantTokens().Take(2).ToImmutableArray(); if (tokens.Length != 1) return false; var token = tokens[0]; return TryGetVariable(token, out variable); }
public bool TryGetVariable(SyntaxNodeOrToken nodeOrToken, out PatternVariable variable) { return nodeOrToken.IsToken ? TryGetVariable(nodeOrToken.AsToken(), out variable) : TryGetVariable(nodeOrToken.AsNode(), out variable); }
public Match AddCapture(PatternVariable variable, SyntaxNodeOrToken startNodeOrToken, SyntaxNodeOrToken endNodeOrToken) { var capture = PatternCapture.Create(variable, startNodeOrToken, endNodeOrToken); return AddCapture(capture); }
public Match AddCapture(PatternVariable variable, SyntaxNodeOrToken nodeOrToken) { var capture = PatternCapture.Create(variable, nodeOrToken); return AddCapture(capture); }
public static PatternCapture Create(PatternVariable variable, SyntaxNodeOrToken nodeOrToken) { return new PatternCapture(variable, nodeOrToken, nodeOrToken); }
private PatternCapture(PatternVariable variable, SyntaxNodeOrToken startNodeOrToken, SyntaxNodeOrToken endNodeOrToken) { Variable = variable; StartNodeOrToken = startNodeOrToken; EndNodeOrToken = endNodeOrToken; }
public ReplacedCapture(PatternVariable variable, IEnumerable<SyntaxNodeOrToken> contents) { Variable = variable; Contents = contents.ToImmutableArray(); }