Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 280616

Summary: [formatter] Valid 1.5 code is not formatted inside <pre> tag
Product: [Eclipse Project] JDT Reporter: Frederic Fusier <frederic_fusier>
Component: CoreAssignee: Frederic Fusier <frederic_fusier>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Olivier_Thomann, satyam.kandula, srikanth_sankaran
Version: 3.5   
Target Milestone: 3.5.1   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on: 196308    
Bug Blocks:    
Attachments:
Description Flags
Proposed patch none

Description Frederic Fusier CLA 2009-06-17 09:50:20 EDT
Using 3.5.0 (I20090611-1540) but should happen since day 1...

While formatting bug 280061 comment 0 test case:

public interface Z {
/**
 * <pre>
 *   void solve(Executor e,
 *              Collection&lt;Callable&lt;Result&gt;&gt; solvers)
 *     throws InterruptedException, ExecutionException {
 *       CompletionService&lt;Result&gt; ecs
 *           = new ExecutorCompletionService&lt;Result&gt;(e);
 *       for (Callable&lt;Result&gt; s : solvers)
 *           ecs.submit(s);
 *       int n = solvers.size();
 *       for (int i = 0; i &lt; n; ++i) {
 *           Result r = ecs.take().get();
 *           if (r != null)
 *               use(r);
 *       }
 *   }
 * </pre>
 */
 void foo();
}

I observed that the code inside the <pre> tag is not formatted although this is valid 1.5 code. I would expect this code to be correctly formatted...
Comment 1 Frederic Fusier CLA 2009-06-17 09:52:05 EDT
Although is set the compliance in my project to 1.6, it appears that the source level used to format the snippet inside the <pre> tag is the default one (i.e. 1.3), hence fails to parse this 1.5 code...
Comment 2 Frederic Fusier CLA 2009-06-17 10:46:36 EDT
Created attachment 139436 [details]
Proposed patch

If the source level of the formatter options is over 1.3, then use it while formatting the code snippet inside <pre> HTML tags of Javadoc comments...
Comment 3 Olivier Thomann CLA 2009-06-17 13:51:05 EDT
Fix looks simple and safe.
Tagging for 3.5.1.
Comment 4 Frederic Fusier CLA 2009-06-18 07:23:28 EDT
Released for 3.6M1 in HEAD stream.
Comment 5 Frederic Fusier CLA 2009-06-18 07:23:53 EDT
Released for 3.5.1 in R3_5_maintenance stream.
Comment 6 Srikanth Sankaran CLA 2009-08-04 00:17:30 EDT
Verified for 3.6M1 using build I20090802-2000
Comment 7 Satyam Kandula CLA 2009-08-27 10:21:31 EDT
Verified for 3.5.1 using build M20090826-1100
Comment 8 Olivier Thomann CLA 2009-08-27 15:19:33 EDT
Verified.