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

Bug 337430

Summary: Unqualified variable names could be resolved
Product: z_Archived Reporter: Stefan Henss <stefan.henss>
Component: RecommendersAssignee: Marcel Bruch <marcel.bruch>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Stefan Henss CLA 2011-02-17 08:17:50 EST
Button b = new Button(null, 0);
b<^Space>

gives correct receiverName but is not resolved as a variable (receiverType etc. are missing).
Comment 1 Marcel Bruch CLA 2011-02-18 13:22:27 EST
Is IntelligentCompletionContext.findMatchingLocalVariable(String) what you want? We could make this public if this meets your requirements.
Comment 2 Stefan Henss CLA 2011-02-19 22:47:47 EST
Yes, indeed, using this method I could handle the problem.
Comment 3 Marcel Bruch CLA 2011-02-20 04:22:02 EST
(In reply to comment #2)
> Yes, indeed, using this method I could handle the problem.

Here you go: public Variable findMatchingVariable(final String variableName)

It's not tested. Feel free to change it if you experience any exceptions. Only take care that as little as possible jdt.compiler AST nodes are propagated to outside world.


Please note, it searches the locals and fields declared in the current compilation unit but ignores inherited fields.Enabling this requires reworking the context and binding it to WALA or JDT. Since WALA integration is not perfectly stable yet I would postpone this for a while.
Comment 4 Marcel Bruch CLA 2012-02-02 01:41:30 EST
Closing this issue. Please give latest dev build (v0.5) a try:

http://download.eclipse.org/recommenders/updates/dev/e37/
http://download.eclipse.org/recommenders/updates/dev/e42/
Comment 5 Marcel Bruch CLA 2012-02-02 01:41:52 EST
Closing this issue. Please give latest dev build (v0.5) a try:

http://download.eclipse.org/recommenders/updates/dev/e37/
http://download.eclipse.org/recommenders/updates/dev/e42/