예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
 public bool TryGetVariable(SyntaxNodeOrToken nodeOrToken, out PatternVariable variable)
 {
     return nodeOrToken.IsToken
         ? TryGetVariable(nodeOrToken.AsToken(), out variable)
         : TryGetVariable(nodeOrToken.AsNode(), out variable);
 }
예제 #5
0
 public Match AddCapture(PatternVariable variable, SyntaxNodeOrToken startNodeOrToken, SyntaxNodeOrToken endNodeOrToken)
 {
     var capture = PatternCapture.Create(variable, startNodeOrToken, endNodeOrToken);
     return AddCapture(capture);
 }
예제 #6
0
 public Match AddCapture(PatternVariable variable, SyntaxNodeOrToken nodeOrToken)
 {
     var capture = PatternCapture.Create(variable, nodeOrToken);
     return AddCapture(capture);
 }
예제 #7
0
 public static PatternCapture Create(PatternVariable variable, SyntaxNodeOrToken nodeOrToken)
 {
     return new PatternCapture(variable, nodeOrToken, nodeOrToken);
 }
예제 #8
0
 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();
 }