~ubuntu-branches/ubuntu/saucy/monodevelop/saucy

« back to all changes in this revision

Viewing changes to contrib/ICSharpCode.NRefactory/PatternMatching/Backreference.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2012-05-27 18:08:20 UTC
  • mfrom: (1.8.5) (1.5.8 sid)
  • Revision ID: package-import@ubuntu.com-20120527180820-f1ub6lhg0s50wci1
Tags: 3.0.2+dfsg-3
* [fcecfe7] Fix monodevelop-core-addins.pc.in to point to actual 
  installed location of assemblies.
* [26e1a07] DebSrc 3.0 does not support Quilt's -p parameter, so 
  manually adjust the path in the patch file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
                {
44
44
                        return match.Get(referencedGroupName).Last().IsMatch(other);
45
45
                }
46
 
                
47
 
                public override S AcceptVisitor<T, S>(IPatternAstVisitor<T, S> visitor, T data)
48
 
                {
49
 
                        return visitor.VisitBackreference(this, data);
50
 
                }
51
 
        }
52
 
        
53
 
        /// <summary>
54
 
        /// Matches identifier expressions that have the same identifier as the referenced variable/type definition/method definition.
55
 
        /// </summary>
56
 
        public class IdentifierExpressionBackreference : Pattern
57
 
        {
58
 
                readonly string referencedGroupName;
59
 
                
60
 
                public string ReferencedGroupName {
61
 
                        get { return referencedGroupName; }
62
 
                }
63
 
                
64
 
                public IdentifierExpressionBackreference(string referencedGroupName)
65
 
                {
66
 
                        if (referencedGroupName == null)
67
 
                                throw new ArgumentNullException("referencedGroupName");
68
 
                        this.referencedGroupName = referencedGroupName;
69
 
                }
70
 
                
71
 
                public override bool DoMatch(INode other, Match match)
72
 
                {
73
 
                        CSharp.IdentifierExpression ident = other as CSharp.IdentifierExpression;
74
 
                        if (ident == null || ident.TypeArguments.Any())
75
 
                                return false;
76
 
                        CSharp.AstNode referenced = (CSharp.AstNode)match.Get(referencedGroupName).Last();
77
 
                        if (referenced == null)
78
 
                                return false;
79
 
                        return ident.Identifier == referenced.GetChildByRole(CSharp.AstNode.Roles.Identifier).Name;
80
 
                }
81
 
                
82
 
                public override S AcceptVisitor<T, S>(IPatternAstVisitor<T, S> visitor, T data)
83
 
                {
84
 
                        return visitor.VisitIdentifierExpressionBackreference(this, data);
85
 
                }
86
46
        }
87
47
}