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

Bug 339453

Summary: Variable.getReceiverCalls() is empty but shouldn't
Product: z_Archived Reporter: Stefan Henss <stefan.henss>
Component: RecommendersAssignee: Marcel Bruch <marcel.bruch>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: lerch
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Stefan Henss CLA 2011-03-09 20:47:54 EST
b = new Button(null, 0);
b.setText("test");
b<^Space>

context.getReceiverType() etc. are null, I have to search for the variable using ((IntelligentCompletionContext) context).findMatchingVariable("b"). For the resulting variable the method getReceiverCalls() is empty.

For all variables which are detected by the context the receiver calls are not obtained using getReceiverCalls(), but with this:

for (final IVariableUsageResolver resolver : usageResolvers.get()) {
            if (resolver.canResolve(context)) {
                receiverMethodInvocations = resolver.getReceiverMethodInvocations();
                return true;
            }
        }

(...templates.PatternRecommender)
Comment 1 Marcel Bruch CLA 2011-03-10 01:08:30 EST
The context's getVariable method is a *handle-only* operation the returns the search key that may be used to lookup the real variable (with its usages) in a resolver.

Clearly there is a confusion which should be solved somehow. The context, however, should IMHO not be responsible to resolve the variable usages. We may return a new Variable-subtype that throws exceptions whenever another method than getVariableName and -Type is called.

Are there any other design proposals?

Added Johannes to the discussion.
Comment 2 Marcel Bruch CLA 2012-01-12 04:22:55 EST
closing this issue. API has been changed. The store based approach is completely gone.