Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 402665 - [1.8][dom ast] LambdaExpression's VariableDeclarationFragment misses source range
Summary: [1.8][dom ast] LambdaExpression's VariableDeclarationFragment misses source r...
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.3   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: BETA J8   Edit
Assignee: Manoj N Palat CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-07 10:37 EST by Markus Keller CLA
Modified: 2013-03-09 07:22 EST (History)
3 users (show)

See Also:
manoj.palat: review? (srikanth_sankaran)


Attachments
Proposed Patch - WIP (5.20 KB, patch)
2013-03-08 01:30 EST, Manoj N Palat CLA
no flags Details | Diff
Proposed Patch (4.92 KB, patch)
2013-03-08 05:40 EST, Manoj N Palat CLA
no flags Details | Diff
Proposed Patch (4.57 KB, patch)
2013-03-08 07:38 EST, Manoj N Palat 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 2013-03-07 10:37:18 EST
In LambdaExpressions, parameters of type VariableDeclarationFragment are missing a source range. The AST view shows such nodes with a red background color.

Example:

package jsr335;

public class SpecExamples335 {
	public static interface StringToInt {
		int stoi(String s);
	}
	public static interface ReduceInt {
		int reduce(int a, int b);
	}
	
	void foo(StringToInt s) { }
	void bar(ReduceInt r) { }
	
	void bar() {
		foo(s -> s.length());
		foo((s) -> s.length());
		foo((String s) -> s.length()); //SingleVariableDeclaration is OK
		
		bar((x, y) -> x+y);
		bar((int x, int y) -> x+y); //SingleVariableDeclarations are OK
	}
}
Comment 1 Srikanth Sankaran CLA 2013-03-07 18:24:40 EST
Manoj, please follow up. Bug fixes to LE should get top priority to enable UI
work.
Comment 2 Srikanth Sankaran CLA 2013-03-07 22:03:40 EST
Jay & Manoj, let us start using the ASTView plugin ourselves so these sort
of problems can be caught upfront without relying on downstream components
to report them, TIA.
Comment 3 Srikanth Sankaran CLA 2013-03-07 23:53:32 EST
(In reply to comment #2)
> Jay & Manoj, let us start using the ASTView plugin ourselves so these sort
> of problems can be caught upfront without relying on downstream components
> to report them, TIA.

Please see https://bugs.eclipse.org/bugs/show_bug.cgi?id=391890#c7
Comment 4 Manoj N Palat CLA 2013-03-08 01:30:02 EST
Created attachment 228122 [details]
Proposed Patch  - WIP

Work in Progress Patch
Comment 5 Manoj N Palat CLA 2013-03-08 05:40:48 EST
Created attachment 228130 [details]
Proposed Patch
Comment 6 Markus Keller CLA 2013-03-08 07:18:24 EST
In the tests, it's better to use checkSourceRange(..) rather than doing manual "getStartPosition() > 0" tests.
Comment 7 Manoj N Palat CLA 2013-03-08 07:38:57 EST
Created attachment 228134 [details]
Proposed Patch

>>> In the tests, it's better to use checkSourceRange(..) rather than doing manual "getStartPosition() > 0" tests.

Modified as per the review comment.
Comment 8 Srikanth Sankaran CLA 2013-03-09 07:22:40 EST
Fix and test released here: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?h=BETA_JAVA8&id=d7b968f8074ad4e44b5a08309dcb414a4be941a4

Thanks Manoj.