]
Kevin Mian Kraiker commented on ROASTER-107:
--------------------------------------------
For me, it does; my concern was about the (remote but present) possibility of someone
using tabs and/or line breaks between those types having problems later on.
Current master compilation returns only two unrelated test failures:
{noformat}
Failed tests:
JavaClassCreationTest.testImportStatementHasEmptyLineBeforeClassDeclaration:50
expected:<package org.foo;[
import java.lang.annotation.Documented;
@Documented
public class JavaClass {]
}> but was:<package org.foo;[
import java.lang.annotation.Documented;
@Documented
]ublic class JavaClass {
}>
JavaDocTest.testJavaDocFullTextShouldFormatParamWithSpace:199 expected:<...ew
instance of CLASS[
@param actual the actual value.]
@return the modifie...> but was:<...ew instance of CLASS[
]param actual the actual value.
@return the modifie...>
{noformat}
Problems with generic types in MethodSource.setReturnType
---------------------------------------------------------
Key: ROASTER-107
URL:
https://issues.jboss.org/browse/ROASTER-107
Project: Roaster
Issue Type: Bug
Components: API, Formatter
Affects Versions: 2.18.7.Final
Reporter: Kevin Mian Kraiker
Assignee: George Gastaldi
Fix For: 2.19.0.Final
When trying to set a method's return type, if there's a space between two generic
types (for example as in TreeMap<String, Object>), an IllegalArgumentExeption gets
thrown saying the identifier for the second type is invalid (because it includes the space
character as part of it). If there's none, then the final formatted code has one,
although the non-formatted one hasn't, which is inconsistent...
{code:java}
@Test
public void throwsException() {
JavaClassSource classSource = Roaster.create(JavaClassSource.class);
MethodSource<JavaClassSource> newMethod = classSource.addMethod()
.setName("tstMethod")
.setPublic();
newMethod.setReturnType("java.util.TreeMap<java.util.String,
java.util.Object>"); // Counts space as part of the second type's name
newMethod.setBody("return new TreeMap<String, Object>();");
assertTrue(newMethod.getReturnType().toString().equals("TreeMap<String,
Object>")); // If the exception wasn't thrown, this should pass.
// Also, if there's no space - as in
'java.util.TreeMap<java.util.String,java.util.Object>', the class'
formatted code has one but the above test would fail.
}
{code}