| Summary: | ASTRewrite.rewriteAST(...) doesn't format enum constants | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Agnieszka Pachuta <pachuta.agnieszka> |
| Component: | Core | Assignee: | JDT-Core-Inbox <jdt-core-inbox> |
| Status: | CLOSED WONTFIX | QA Contact: | Manoj N Palat <manoj.palat> |
| Severity: | normal | ||
| Priority: | P3 | CC: | manoj.palat |
| Version: | 4.7 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Whiteboard: | stalebug | ||
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. |
ASTRewrite.rewriteAST(...) doesn't apply formatter options given as an argument to format enum constans alignment. The options are taken into account when I use formatter explicitly. Example: ... Document javaSourceDocument = new Document(javaSource); Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); JavaCore.setComplianceOptions(JavaCore.VERSION_1_8, options); options.put( DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS, DefaultCodeFormatterConstants.createAlignmentValue( true, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); TextEdit edits = astRewrite.rewriteAST(javaSourceDocument, options); edits.apply(javaSourceDocument); // Here, in javaSourceDocument.get() all enum constants are in the same line, not formatted. final CodeFormatter codeFormatter = ToolFactory.createCodeFormatter(options); // Use the same options. String source = javaSourceDocument.get(); TextEdit edits2 = codeFormatter.format( CodeFormatter.K_COMPILATION_UNIT, source, 0, source.length(), 0, System.getProperty("line.separator") ); Document document = new Document(source); edits2.apply(document); // Here, document.get() contains formatted enum constants.