[
https://issues.jboss.org/browse/FORGE-367?page=com.atlassian.jira.plugin....
]
fiorenzo pizza commented on FORGE-367:
--------------------------------------
to solve that, we need a simple modification on method
org.jboss.forge.parser.java.impl.ImportImpl.setName:
@Override
public Import setName(final String name)
{
if (name.endsWith(".*"))
{
imprt.setName(ast.newName(Types.tokenizeClassName(name.replaceAll("\\.\\*",
""))));
imprt.setOnDemand(true);
}
else
{
imprt.setName(ast.newName(Types.tokenizeClassName(name)));
}
return this;
}
my test method:
@Test
public void testImportStaticAndWithWildCard() throws ClassNotFoundException
{
JavaClass javaClass = JavaParser.create(JavaClass.class);
javaClass.setPackage("it.coopservice.test");
javaClass.setName("SimpleClass");
javaClass.addImport("org.junit.Assert.*")
.setStatic(true);
assertTrue(javaClass.getImport("org.junit.Assert") != null);
assertTrue(javaClass.getImport("org.junit.Assert").isStatic());
assertTrue(javaClass.getImport("org.junit.Assert").isWildcard());
}
i will pull request for that in the next days...
Java Parser needs to support wildcard (.*) imports.
---------------------------------------------------
Key: FORGE-367
URL:
https://issues.jboss.org/browse/FORGE-367
Project: Forge
Issue Type: Enhancement
Components: Parsers / File Manipulation
Reporter: Paul Bakker
Assignee: fiorenzo pizza
Fix For: 2.0.0.Alpha1
It is now impossible to do this:
{code}
JavaClass testClass...
testClass.addImport("org.junit.Assert.*").setStatic(true);
{code}
This is mainly required for static imports.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:
http://www.atlassian.com/software/jira