Skip to content
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

Handle spaces in JavadocImpl.getFullSpace #246

Merged
merged 1 commit into from
Jul 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.util.Set;

import org.eclipse.jdt.core.dom.Javadoc;
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.dom.TagElement;
import org.eclipse.jdt.core.dom.TextElement;
import org.jboss.forge.roaster.model.JavaDocTag;
Expand Down Expand Up @@ -93,22 +92,14 @@ public String getFullText()
List<Object> fragments = tagElement.fragments();
for (Iterator<Object> iterator = fragments.iterator(); iterator.hasNext();)
{
Object fragment = iterator.next();
if (fragment instanceof SimpleName)
String fragment = iterator.next().toString();
if (text.length() > 0 && (!fragment.startsWith(" ") && text.charAt(text.length() - 1) != ' '))
{
// Param name
text.append(' ').append(fragment);
}
else
{
text.append(fragment);
if (iterator.hasNext())
{
text.append(' ');
}
text.append(' ');
}
text.append(fragment);
}
text.append(System.getProperty("line.separator"));
text.append(System.lineSeparator());
}
return text.toString().trim();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/
public class JavaDocTest
{
private static final String LINE_SEPARATOR = System.getProperty("line.separator");
private static final String LINE_SEPARATOR = System.lineSeparator();

@Test
public void testJavaDocParsing()
Expand Down Expand Up @@ -205,4 +205,25 @@ public void testJavaDocFullTextShouldFormatParamWithSpace()
+ "@return the modified text",
method.getJavaDoc().getFullText());
}


@Test
public void testJavadocFullTextWithSeeTags() {
JavaClassSource src = Roaster.parse(JavaClassSource.class,
"package issue;\npublic class Issue { \n" +
" /**\n" +
" * Convenience entry point for {@link IdCard} assertions when being mixed with other \"assertThat\" assertion libraries.\n" +
" *\n" +
" * @see #assertThat\n" +
" */\n" +
" public static String someMethod(String actual) {\n" +
" return actual;\n" +
" }}");
MethodSource<JavaClassSource> method = src.getMethods().get(0);
assertEquals(
"Convenience entry point for {@link IdCard} assertions when being mixed with other \"assertThat\" assertion libraries.\n"
+ "@see #assertThat",
method.getJavaDoc().getFullText());

}
}