-
-
Notifications
You must be signed in to change notification settings - Fork 351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix Template substitution of CtExecutableReference#simpleName #1325
Conversation
@@ -436,4 +436,18 @@ public void testTemplateMatcherMatchTwoSnippets() throws Exception { | |||
|
|||
assertTrue(match1.equals(match2)); | |||
} | |||
@Test | |||
public void testTemplateInvocationSubstitution() throws Exception { | |||
Launcher spoon = new Launcher(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contract: the template engine supports substitution of method names in method calls.
new InvocationTemplate(factory.Type().OBJECT, "hashCode").apply(resultKlass); | ||
CtMethod<?> templateMethod = (CtMethod<?>) resultKlass.getElements(new NameFilter("invoke")).get(0); | ||
CtStatement templateRoot = (CtStatement) templateMethod.getBody().getStatement(0); | ||
assertEquals("iface.hashCode()", templateRoot.toString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// iface.$method$() becomes iface.hashCode()
interesting! it looks more like a new feature than a fix :-) |
Thanks Pavel! you can be proud of being the first external contributor contributing to the awesome yet complex template engine!!! |
There was not possible to substitute name of invoked method.
Example template: