<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>I ended up writing my matcher like this:</p>
<p><tt>integerLiteral(</tt><tt><br>
</tt><tt> expr().bind("literal"),</tt><tt> //inline bind
call using a redundant node matcher<br>
</tt><tt> hasAncestor( //climb up the AST to the
nearest varDecl</tt><tt> ancestor<br>
</tt><tt>
varDecl(hasInitializer(ignoringParenCasts(equalsBoundNode("literal"))))
//check that this varDecl satisfies the original condition</tt><tt><br>
</tt><tt> )</tt><tt><br>
</tt><tt>)</tt></p>
<p>Any feedback is appreciated, as I am completely new to
LibTooling...</p>
<p>P.S.: The actual matcher I am working on is far more complicated.
Inverting it (i.e. using my very first example) would result in
much more difficult problems. Although this seems like a
roundabout hack, it might be effective when nested inside matchers
that have already been tested</p>
<p>Thanks,</p>
<p>Mike<br>
</p>
<br>
<div class="moz-cite-prefix">On 05/07/2018 7:31 PM, Michael Jabbour
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:3893667f-3cfa-1895-2b34-d1508cf5bbdc@gmail.com">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<p>Hello all,<br>
</p>
<p>When using has*() it is sometimes desirable to use
ignoringParenCasts(), for example (from the docs):</p>
<pre style="color: rgb(34, 34, 34); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial;">varDecl(hasInitializer(ignoringParenCasts(integerLiteral())))</pre>
<p>Is there any way to get the same effect when hasParent(), e.g.:</p>
<pre style="color: rgb(34, 34, 34); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial;">integerLiteral(hasParent(ignoringParenCasts(varDecl())))</pre>
<p>Obviously this does not work, but what is the best way to
achieve a similar effect?</p>
<p>cheers,</p>
<p>Mike<br>
</p>
</blockquote>
<br>
</body>
</html>