Bug 80904 - Quick Fix "Assign parameter to new field" doesn't appear with commented type
Summary: Quick Fix "Assign parameter to new field" doesn't appear with commented type
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2 RC2   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-14 03:26 EST by Markus Keller CLA
Modified: 2006-04-27 22:34 EDT (History)
1 user (show)

See Also:


Attachments
Proposed patch and regression test (4.20 KB, patch)
2006-04-19 12:56 EDT, Jerome Lanneluc CLA
no flags Details | Diff
Better patch and same regression test (2.75 KB, patch)
2006-04-20 13:31 EDT, Jerome Lanneluc CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2004-12-14 03:26:47 EST
200412081200

import java.util.List;
class A {
	public A (List/*<String>*/ list, Integer integer) {
	}
}

Quick Fix "Assign parameter to new field" works correctly for "integer", but
does not appear for "list".
Comment 1 Martin Aeschlimann CLA 2005-05-12 11:39:23 EDT
reproduced in 20050509-2010

The reason is that the AST received from reconcile has the second parameter
'Integer integer' represented as a SingleVariableDeclaration with source range
starting at the block comment start, overlapping with the first parameter.

Unfortunatly the ASTView doesn't show you this. We thought the 'reconciled' mode
in the ASTView would do the same as happens in reconcile, but obviously there is
a third case of AST are build. Set a breakpoint in
QuickAssistProcessor.getAssignParamToFieldProposals to see that node.

If you can't reproduce and the quick assist show up correcty: Cut the
constructor, save, wait a bit, paste and do the quick fix
Comment 2 Jerome Lanneluc CLA 2006-04-18 12:42:30 EDT
When I put a breakpoint in QuickAssistProcessor.getAssignParamToFieldProposals, the 'node' param is a SingleVariableDeclaration for 'Integer integer'. When I inspect its parent and look at the first parameter, the position of the SingleVariableDeclation 'List list' is correct.

So why is the 'node' the SingleVariableDeclaration 'Integer integer' ?
Comment 3 Martin Aeschlimann CLA 2006-04-19 03:43:29 EDT
The problem is the source range of the SingleVariableDeclaration for 'Integer integer'.

I just reproduced this again in N20060418-0010
Comment 4 Jerome Lanneluc CLA 2006-04-19 12:54:30 EDT
Thanks for the clarification. The problem comes from the fact that we don't use the same parser when the working copy is consistent (CommentRecorderParser), and when it is not (SourceElementParser). SourceElementParser#checkComment() was not updated when CommentRecorderParser#checkComment() was.
Comment 5 Jerome Lanneluc CLA 2006-04-19 12:56:03 EDT
Created attachment 38954 [details]
Proposed patch and regression test
Comment 6 Philipe Mulet CLA 2006-04-20 07:29:48 EDT
+1 for 3.2RC2
Comment 7 Jerome Lanneluc CLA 2006-04-20 13:28:01 EDT
Patch is not good. It prevents non-Javadoc comments from being associated with a declaration.
Comment 8 Jerome Lanneluc CLA 2006-04-20 13:31:48 EDT
Created attachment 39071 [details]
Better patch and same regression test
Comment 9 Jerome Lanneluc CLA 2006-04-20 13:32:51 EDT
Released patch and regression test from comment 8
Comment 10 Olivier Thomann CLA 2006-04-27 22:34:19 EDT
Verified with I20060427-1600 for RC2.