<div class="gmail_quote">On Wed Nov 05 2014 at 1:29:36 AM Dean Sutherland <<a href="mailto:dfsuther@yahoo-inc.com">dfsuther@yahoo-inc.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I'd like to write a matcher that would find the following ObjectiveC snippet:<br>
<br>
[self.externalWebView loadHTMLString:@"" baseURL:nil];<br>
<br>
(A dump of the AST for this code snippet is appended at the end of this message.)<br>
<br>
If matchers for ObjC AST nodes existed, the matcher I want might look something like this:<br>
<br>
objcMessageExpr(hasSelector("<u></u>loadHTMLString:baseURL:"),<br>
hasArgument(1, ignoringParenImpCasts(<u></u>integerLiteral(equals(0)))));<br>
<br>
How do I go about writing the matchers I need, such as objcMessageExpr<br>
and hasSelector?  I took a whack at the writing objcMessageExpr and<br>
promptly got lost in failed template instantiation errors.<br></blockquote><div><br></div><div>If you have a more concrete example of what you tried it would be easier to help :)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Suggestions or guidance would be most welcome.<br>
<br>
<br>
Dean<br>
<a href="mailto:dfsuther@yahoo-inc.com" target="_blank">dfsuther@yahoo-inc.com</a><br>
<br>
-----------------------<br>
`-ExprWithCleanups 0x7fb8af3f4210 <line:927:13, col:72> 'void'<br>
`-ObjCMessageExpr 0x7fb8af3f41c8 <col:13, col:72> 'void' selector=loadHTMLString:<u></u>baseURL:<br>
|-PseudoObjectExpr 0x7fb8af3f4188 <col:14, col:34> 'UIWebView *'<br>
| |-ObjCPropertyRefExpr 0x7fb8af3f4110 <col:14, col:34> '<pseudo-object type>' lvalue objcproperty Kind=PropertyRef Property="webview" Messaging=Getter<br>
| | `-OpaqueValueExpr 0x7fb8af3f40f0 <col:14, col:19> 'HRBookendedWebView *'<br>
| |   `-PseudoObjectExpr 0x7fb8af3f17c8 <col:14, col:19> 'HRBookendedWebView *'<br>
| |     |-ObjCPropertyRefExpr 0x7fb8af3f1750 <col:14, col:19> '<pseudo-object type>' lvalue objcproperty Kind=PropertyRef Property="articleWebView" Messaging=Getter<br>
| |     | `-OpaqueValueExpr 0x7fb8af3f1730 <col:14> 'HRiPadArticleViewController *'<br>
| |     |   `-ImplicitCastExpr 0x7fb8af3f16e8 <col:14> 'HRiPadArticleViewController *' <LValueToRValue><br>
| |     |     `-DeclRefExpr 0x7fb8af3f16c0 <col:14> 'HRiPadArticleViewController *const __strong' lvalue ImplicitParam 0x7fb8af3f0dd0 'self' 'HRiPadArticleViewController *const __strong'<br>
| |     |-OpaqueValueExpr 0x7fb8af3f1730 <col:14> 'HRiPadArticleViewController *'<br>
| |     | `-ImplicitCastExpr 0x7fb8af3f16e8 <col:14> 'HRiPadArticleViewController *' <LValueToRValue><br>
| |     |   `-DeclRefExpr 0x7fb8af3f16c0 <col:14> 'HRiPadArticleViewController *const __strong' lvalue ImplicitParam 0x7fb8af3f0dd0 'self' 'HRiPadArticleViewController *const __strong'<br>
| |     `-ImplicitCastExpr 0x7fb8af3f17b0 <col:19> 'HRBookendedWebView *' <ARCReclaimReturnedObject><br>
| |       `-ObjCMessageExpr 0x7fb8af3f1780 <col:19> 'HRBookendedWebView *' selector=articleWebView<br>
| |         `-OpaqueValueExpr 0x7fb8af3f1730 <col:14> 'HRiPadArticleViewController *'<br>
| |           `-ImplicitCastExpr 0x7fb8af3f16e8 <col:14> 'HRiPadArticleViewController *' <LValueToRValue><br>
| |             `-DeclRefExpr 0x7fb8af3f16c0 <col:14> 'HRiPadArticleViewController *const __strong' lvalue ImplicitParam 0x7fb8af3f0dd0 'self' 'HRiPadArticleViewController *const __strong'<br>
| |-OpaqueValueExpr 0x7fb8af3f40f0 <col:14, col:19> 'HRBookendedWebView *'<br>
| | `-PseudoObjectExpr 0x7fb8af3f17c8 <col:14, col:19> 'HRBookendedWebView *'<br>
| |   |-ObjCPropertyRefExpr 0x7fb8af3f1750 <col:14, col:19> '<pseudo-object type>' lvalue objcproperty Kind=PropertyRef Property="articleWebView" Messaging=Getter<br>
| |   | `-OpaqueValueExpr 0x7fb8af3f1730 <col:14> 'HRiPadArticleViewController *'<br>
| |   |   `-ImplicitCastExpr 0x7fb8af3f16e8 <col:14> 'HRiPadArticleViewController *' <LValueToRValue><br>
| |   |     `-DeclRefExpr 0x7fb8af3f16c0 <col:14> 'HRiPadArticleViewController *const __strong' lvalue ImplicitParam 0x7fb8af3f0dd0 'self' 'HRiPadArticleViewController *const __strong'<br>
| |   |-OpaqueValueExpr 0x7fb8af3f1730 <col:14> 'HRiPadArticleViewController *'<br>
| |   | `-ImplicitCastExpr 0x7fb8af3f16e8 <col:14> 'HRiPadArticleViewController *' <LValueToRValue><br>
| |   |   `-DeclRefExpr 0x7fb8af3f16c0 <col:14> 'HRiPadArticleViewController *const __strong' lvalue ImplicitParam 0x7fb8af3f0dd0 'self' 'HRiPadArticleViewController *const __strong'<br>
| |   `-ImplicitCastExpr 0x7fb8af3f17b0 <col:19> 'HRBookendedWebView *' <ARCReclaimReturnedObject><br>
| |     `-ObjCMessageExpr 0x7fb8af3f1780 <col:19> 'HRBookendedWebView *' selector=articleWebView<br>
| |       `-OpaqueValueExpr 0x7fb8af3f1730 <col:14> 'HRiPadArticleViewController *'<br>
| |         `-ImplicitCastExpr 0x7fb8af3f16e8 <col:14> 'HRiPadArticleViewController *' <LValueToRValue><br>
| |           `-DeclRefExpr 0x7fb8af3f16c0 <col:14> 'HRiPadArticleViewController *const __strong' lvalue ImplicitParam 0x7fb8af3f0dd0 'self' 'HRiPadArticleViewController *const __strong'<br>
| `-ImplicitCastExpr 0x7fb8af3f4170 <col:34> 'UIWebView *' <ARCReclaimReturnedObject><br>
|   `-ObjCMessageExpr 0x7fb8af3f4140 <col:34> 'UIWebView *' selector=webview<br>
|     `-OpaqueValueExpr 0x7fb8af3f40f0 <col:14, col:19> 'HRBookendedWebView *'<br>
|       `-PseudoObjectExpr 0x7fb8af3f17c8 <col:14, col:19> 'HRBookendedWebView *'<br>
|         |-ObjCPropertyRefExpr 0x7fb8af3f1750 <col:14, col:19> '<pseudo-object type>' lvalue objcproperty Kind=PropertyRef Property="articleWebView" Messaging=Getter<br>
|         | `-OpaqueValueExpr 0x7fb8af3f1730 <col:14> 'HRiPadArticleViewController *'<br>
|         |   `-ImplicitCastExpr 0x7fb8af3f16e8 <col:14> 'HRiPadArticleViewController *' <LValueToRValue><br>
|         |     `-DeclRefExpr 0x7fb8af3f16c0 <col:14> 'HRiPadArticleViewController *const __strong' lvalue ImplicitParam 0x7fb8af3f0dd0 'self' 'HRiPadArticleViewController *const __strong'<br>
|         |-OpaqueValueExpr 0x7fb8af3f1730 <col:14> 'HRiPadArticleViewController *'<br>
|         | `-ImplicitCastExpr 0x7fb8af3f16e8 <col:14> 'HRiPadArticleViewController *' <LValueToRValue><br>
|         |   `-DeclRefExpr 0x7fb8af3f16c0 <col:14> 'HRiPadArticleViewController *const __strong' lvalue ImplicitParam 0x7fb8af3f0dd0 'self' 'HRiPadArticleViewController *const __strong'<br>
|         `-ImplicitCastExpr 0x7fb8af3f17b0 <col:19> 'HRBookendedWebView *' <ARCReclaimReturnedObject><br>
|           `-ObjCMessageExpr 0x7fb8af3f1780 <col:19> 'HRBookendedWebView *' selector=articleWebView<br>
|             `-OpaqueValueExpr 0x7fb8af3f1730 <col:14> 'HRiPadArticleViewController *'<br>
|               `-ImplicitCastExpr 0x7fb8af3f16e8 <col:14> 'HRiPadArticleViewController *' <LValueToRValue><br>
|                 `-DeclRefExpr 0x7fb8af3f16c0 <col:14> 'HRiPadArticleViewController *const __strong' lvalue ImplicitParam 0x7fb8af3f0dd0 'self' 'HRiPadArticleViewController *const __strong'<br>
|-ObjCStringLiteral 0x7fb8af3f4058 <col:57, col:58> 'NSString *'<br>
| `-StringLiteral 0x7fb8af3f4030 <col:58> 'char [1]' lvalue ""<br>
`-ImplicitCastExpr 0x7fb8af3f41b0 </Applications/Xcode.app/<u></u>Contents/Developer/Platforms/<u></u>iPhoneSimulator.platform/<u></u>Developer/SDKs/<u></u>iPhoneSimulator8.1.sdk/usr/<u></u>include/sys/_types.h:52:23, col:33> 'NSURL *' <NullToPointer><br>
`-ParenExpr 0x7fb8af3f40d0 <col:23, col:33> 'void *'<br>
`-CStyleCastExpr 0x7fb8af3f40a8 <col:24, col:32> 'void *' <NullToPointer><br>
`-IntegerLiteral 0x7fb8af3f4078 <col:32> 'int' 0<br>
</blockquote></div>