Bug 465379 - Code assist in semanticCandidateExpressions has a wrong type for "self"
Summary: Code assist in semanticCandidateExpressions has a wrong type for "self"
Status: RESOLVED DUPLICATE of bug 463456
Alias: None
Product: Sirius
Classification: Modeling
Component: Diagram (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2015-04-24 04:30 EDT by Cedric Brun CLA
Modified: 2015-04-24 08:31 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Cedric Brun CLA 2015-04-24 04:30:59 EDT
Steps to reproduce :
- Create a  VSM with a diagram description  on ecore.EPackage
- Create a Mapping (Edge, Container or Node, they are all failing) 
- Set a domain class for this mapping : ecore.EReference for instance
- trigger the code assist on the semantic candidate expression [self.<CTRL+SPACE>/]
=> the proposed features are related to the ecore.EReference type instead of the EPackage one.

It does not depend on the query language used, aql, mtl or feature, they all fail.

"fun fact"  : the validation on the other hand uses the right type, which means you ends up with a validation error (rightly so) if you used the completion and did set feature:eType for instance.
Comment 1 Cedric Brun CLA 2015-04-24 04:41:08 EDT
It looks like org.eclipse.sirius.ui.tools.api.assist.TextContentProposalProvider.initContext(EObject, EStructuralFeature) to specify the feature for which the proposal is triggered is supposed to be called and is not. Either we never called it and did not notice or we lost some code.
Comment 2 Cedric Brun CLA 2015-04-24 04:57:48 EDT
After digging into the history it looks like we never (or not in the last few years) did call this method.

Possible fix :

change org.eclipse.sirius.editor.tools.api.assist.TypeContentProposalProvider.bindPluginsCompletionProcessors to add a new parameter feature of type EStructuralFeature

To get this 

org.eclipse.sirius.editor.tools.api.assist.TypeContentProposalProvider.bindPluginsCompletionProcessors(AbstractPropertySection, Text, EStructuralFeature)

in the implementation of this method call initContext with the given feature.

contentProposalAdapter.setView(section);
contentProposalAdapter.initContext(null, feature);

(the selected EObject itself will be retrieved "on demand" through TextContentProposalProvider.getSelectedElement()

update the generator to generate such calls :

TypeContentProposalProvider.bindPluginsCompletionProcessors(this, text,getFeature());

I did all of that manually for DiagramElementMappingSemanticCandidatesExpressionPropertySection and it fixed the problem.
Comment 3 Pierre-Charles David CLA 2015-04-24 08:31:17 EDT
This looks like the same regression already identified by https://bugs.eclipse.org/bugs/show_bug.cgi?id=463456#c8

In commit 0a64eb1bc2399e8d72a6b2be8fb3f6acb794589c for bug 463456, the interpreted expressions property sections inheritance was changed from:

  extends AbstractTextPropertySection implements ContentProposalClient

to

  extends AbstractTextWithButtonPropertySection

i.e. we lost "implements ContentProposalClient".

But TextContentProposalProvider.getEStructuralFeature() tests if the property section if "instanceof ContentProposalClient" in order to configure the completion context correctly.

*** This bug has been marked as a duplicate of bug 463456 ***