Bug 3181 - Does not format nicely anonymous type (1FRLTO1)
Summary: Does not format nicely anonymous type (1FRLTO1)
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: All Windows NT
: P3 normal (vote)
Target Milestone: 3.0 M4   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 11232 37609 (view as bug list)
Depends on:
Blocks:
 
Reported: 2001-10-10 22:50 EDT by Philipe Mulet CLA
Modified: 2003-10-13 08:54 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philipe Mulet CLA 2001-10-10 22:50:51 EDT
Formatter does not handle nicely the following method source:

[public static Compiler getCompiler() {
	if (compiler == null) {
		CompilerOptions options = new CompilerOptions();
		options.handleImportProblemAsError(false);

		compiler = 
			new Compiler(
				null, 
				DefaultErrorHandlingPolicies.proceedWithAllProblems(), 
				options.getConfigurableOptions(Locale.getDefault()), 
				new ICompilerRequestor() {
					private CompilationResult compilationResult;
					public void acceptResult(CompilationResult compilationResult) {
						this.compilationResult = compilationResult;
					}
					public CompilationResult retrieveCompilationResult() {
						return compilationResult;
					}
				}, 
				compilerProblemFactory);
	}
	return compiler;
}]

NOTES:
	OT (7/18/00 2:50:30 PM)
		What is the expected formatted string of this example?
	What we get now is:
[public static Compiler getCompiler() {
	if (compiler == null) {
		CompilerOptions options = new CompilerOptions();
		options.handleImportProblemAsError(false);

		compiler =
			new Compiler(
				null,
				DefaultErrorHandlingPolicies.proceedWithAllProblems(),
				options.getConfigurableOptions(Locale.getDefault()),
				new ICompilerRequestor() {
			private CompilationResult compilationResult;
			public void acceptResult(CompilationResult compilationResult) {
				this.compilationResult = compilationResult;
			}
			public CompilationResult retrieveCompilationResult() {
				return compilationResult;
			}
		}, compilerProblemFactory);
	}
	return compiler;
}]

	This problem is due to the fact that the outputLine methods doesn't remember the number of indentation performed. The following code is considered as a single line which needs to be 
	split.
		compiler =
			new Compiler(
				null,
				DefaultErrorHandlingPolicies.proceedWithAllProblems(),
				options.getConfigurableOptions(Locale.getDefault()),
				new ICompilerRequestor() {
	But while spitting it, two indentations are performed, and these two identations are not propagate when returning from the outputLine method. Which means that the next input will
	be indented according to the current indentation of the previous line.
	Therefore the following block missed two indentations.
					[private CompilationResult compilationResult;
					public void acceptResult(CompilationResult compilationResult) {
						this.compilationResult = compilationResult;
					}
					public CompilationResult retrieveCompilationResult() {
						return compilationResult;
					}
				}, compilerProblemFactory);]
Comment 1 Philipe Mulet CLA 2001-10-11 09:35:28 EDT
Defer
Comment 2 Philipe Mulet CLA 2002-07-25 06:30:48 EDT
Resurrecting formatter issues in 2.1 stream.
Comment 3 Philipe Mulet CLA 2002-07-25 06:32:38 EDT
Clearing resolution
Comment 4 Olivier Thomann CLA 2002-07-30 13:50:35 EDT
*** Bug 11232 has been marked as a duplicate of this bug. ***
Comment 5 Olivier Thomann CLA 2003-01-15 13:22:42 EST
We need to clear 2.1 bug reports that won't be addressed before 2.1. The new 
implementation is still in the works. Therefore we cannot include it for 2.1. 
Not enough testing and we need to polish the preferences. This will be address 
for 2.2 as stated in the JDT/Core plan.
Comment 6 Olivier Thomann CLA 2003-05-20 11:22:26 EDT
*** Bug 37609 has been marked as a duplicate of this bug. ***
Comment 7 Philipe Mulet CLA 2003-06-12 06:25:45 EDT
Resurrecting for 3.0
Comment 8 Olivier Thomann CLA 2003-10-03 09:02:01 EDT
Fixed and released in the new formatter.
Regression test added.
Comment 9 David Audel CLA 2003-10-13 08:54:38 EDT
Verified