You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package test;
/**
* Test Class
*
* Generated
*
*/
public class Test
{
}
The standalone-Formatter-Jar adds a HTML-Tag
before the "Generated". Unfortunately, when I call the plugin via the Eclipse-APIs:
finalTextEditedit =
codeFormatter.format(
CodeFormatter.K_COMPILATION_UNIT, // format a compilation unitcontent, // source to format0, // starting positioncontent.length(), // length0, // initial indentation"\r\n"// line separator
);
the method returns a null because it can not format the content. I have tracked the problem back to the class SnippetFormatter.java, Method toReplacements(). This method has the condition which checks the unformatted and the formatted source:
This condition checks that there are only whitespace-changes in the new formatted source. The Javadoc says:
under the assumption that they differ in whitespace alone.
Unfortunately, this assumption is not correct. The source has (as mentioned above) an additional non-whitespace change and the IllegalArgumentException is thrown. This Exception causes the Eclipse-Formatter-Class to fail and to return only null, thereby denying to format the source.
The text was updated successfully, but these errors were encountered:
The Eclipse-Plugin has sometimes a problem when I call the formatter programatically inside Eclipse. I am using the Snippet from https://help.eclipse.org/latest/topic/org.eclipse.jdt.doc.isv/guide/jdt_api_codeformatter.htm to format a complete Java-File. I have created a minimal Test-Class:
The standalone-Formatter-Jar adds a HTML-Tag
before the "Generated". Unfortunately, when I call the plugin via the Eclipse-APIs:
the method returns a null because it can not format the content. I have tracked the problem back to the class SnippetFormatter.java, Method toReplacements(). This method has the condition which checks the unformatted and the formatted source:
This condition checks that there are only whitespace-changes in the new formatted source. The Javadoc says:
Unfortunately, this assumption is not correct. The source has (as mentioned above) an additional non-whitespace change and the IllegalArgumentException is thrown. This Exception causes the Eclipse-Formatter-Class to fail and to return only null, thereby denying to format the source.
The text was updated successfully, but these errors were encountered: