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

Bug 484858

Summary: [AQL] Completion after metamodel prefix adds a 2nd prefix
Product: [Modeling] Sirius Reporter: Etienne Juliot <etienne.juliot>
Component: CoreAssignee: Laurent Fasani <laurent.fasani>
Status: CLOSED FIXED QA Contact: Florian Barbin <florian.barbin>
Severity: normal    
Priority: P3 CC: esteban.dugueperoux, florian.barbin, laurent.fasani, pierre-charles.david, yvan.lussaud
Version: 3.1.0Keywords: triaged
Target Milestone: 6.0.0   
Hardware: PC   
OS: Windows NT   
See Also: https://git.eclipse.org/r/115004
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=a3393ba4f56b52a4dc6b16f4119b1d84b96ba80c
Whiteboard: backport

Description Etienne Juliot CLA 2015-12-23 09:22:08 EST
steps to reproduce:
- with basicfamily, on Man, write "aql:self.oclAsType(basicfamily::)"
- select basicfamily::Man
- the completion creates "aql:self.oclAsType(basicfamily::basicfamily::Man)" which is invalidated

It should not re-add the MM prefix.
Comment 1 Esteban DUGUEPEROUX CLA 2015-12-28 10:02:57 EST
I confirm the bug, I have had the same through https://bugs.eclipse.org/bugs/show_bug.cgi?id=484217#c4
Comment 2 Yvan Lussaud CLA 2016-05-31 09:06:07 EDT
see https://bugs.eclipse.org/bugs/show_bug.cgi?id=479826#c2
Comment 3 Laurent Fasani CLA 2018-01-05 11:18:11 EST
At a first sight, the fix seems trivial. 
Just provide a proposal that complete what the user has already written:
String proposal = propFromAQL.getProposal().substring(completionResult.getReplacementLength());

For example aql:self.eAllContents(basicfamily::P+CTRL+SPACE -> proposal=erson

But, why have not we got the issue for method completion? aql:self.eAllC+CTRL+SPACE

Because, there is a post processing in TextContentProposalProvider.getProposals(String, int) to convert sirius proposal into Jface. The process is not specific to a particular interpreter. It cuts the proposal according to what users has already written (String proposalStart = new ContentContextHelper(contents, position, prefix).getProposalStart()).

proposal1:
* update TextContentProposalProvider.getProposalStart()to better understand how to cut the proposal.
proposal2:
* update AQLProposalProvider.getProposals(ExpressionTrimmer, int, IQueryEnvironment, Map<String, Set<IType>>) to let the specific interpreter cut the proposal himself.
Comment 4 Eclipse Genie CLA 2018-01-05 12:33:34 EST
New Gerrit change created: https://git.eclipse.org/r/115004
Comment 6 Laurent Fasani CLA 2018-01-30 11:57:28 EST
Steps to validate:
* Create a VSP
* In the odesign, create a diagramDescription and a node mapping
* In an expression, type "aql:self.eAllContents(ecore::EAtt)", position cursor after EAtt and call the completion then select ecore::EAttribute
=>The resulting expression shoulb be "aql:self.eAllContents(ecore::EAttribute)".
Comment 7 Laurent Redor CLA 2018-06-27 11:55:50 EDT
Available in Sirius 6.0.0, see https://wiki.eclipse.org/Sirius/6.0.0 for details