Bug 475131 - Improve the AQL code completion
Summary: Improve the AQL code completion
Status: CLOSED FIXED
Alias: None
Product: Sirius
Classification: Modeling
Component: Core (show other bugs)
Version: 3.0.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.1.0   Edit
Assignee: Stephane Begaudeau CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks: 477963 479752 470460 475176
  Show dependency tree
 
Reported: 2015-08-17 05:55 EDT by Stephane Begaudeau CLA
Modified: 2015-10-16 09:09 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stephane Begaudeau CLA 2015-08-17 05:55:45 EDT
Steps to reproduce:

- open the interpreter and select a model element with a structural feature named "name".
- type "[self.na/]" and put your cursor between the "a" and the "/"
- call the code completion and select "name"
- the result will be [self.name/], as expected
- now replace the expression with "aql:self.na"
- put your cursor after the "a" and select "name" in the code completion
- the result will be "aql:naname" (the existing part of the expression has not been replaced)

The problem comes from the fact that the Acceleo MTL interpreter can tell Sirius that the proposal "name" should replace some of the existing characters of the expression ("na" in our case).

This issue highlight a problem with the bundle org.eclipse.sirius.interpreter which depends on "org.eclipse.acceleo.ide.ui" in order to contribute to the Acceleo interpreter view but using this dependency and a dependency to "org.eclipse.sirius.common.acceleo.mtl.ide", it also provides a preferential treatment to the Acceleo MTL interpreter. Only Acceleo can provide advanced proposals with images for example. This dependency to the Sirius Acceleo MDE IDE bundle is used only to provide better completion proposals to the Acceleo MTL interpreter.

The SiriusInterpreterSourceViewer can ask an interpreter to provide ContentProposal (from Sirius Common), yet those content proposals are not powerful enough to indicate that a part of the existing expression should be replaced or to support images. Those basic proposals are then later converted by the Sirius Interpreter bundle into ICompletionProposal (from JFace) which are powerful enough to do the job (in the method computeCompletionProposals of SiriusContentAssistProcessor).

Given the fact that the Sirius interpreter API asks for an API which cannot hold the necessary information to do this job, neither the Acceleo MTL interpreter nor the Acceleo AQL one should be able to do the job in our use case but using the dependency to Acceleo 3, the Sirius Interpreter bundle uses an internal class of Acceleo MTL named AcceleoCompletionProposal, which has all the relevant pieces of information, to improve the support for Acceleo MTL.

The class org.eclipse.sirius.common.tools.api.contentassist.IProposalProvider asks for Sirius' ContentProposal which can only have:
- proposal: String
- display: String
- information: String
- cursorPosition: int

While it will try to create JFace's ICompletionProposal which, using the implementation SiriusCompletionProposal, can have:
- displayString: String
- replacementString: String
- replacementOffset: int
- replacementLength: int
- cursorPosition: int
- image: Image
- contextInformation: IContextInformation
- additionalProposalInfo: String

While we could trim the proposal returned by AQL to cover the basic use case highlighted here "aql:self.na", it would not work for more complex use cases like "aql:self.nam" with the cursor between the "a" and the "m". Using the Sirius API, AQL could not indicate that an "e" should be placed after the expression by saying like Acceleo that "nam" should be replaced by "name". Improving the completion proposal API could also let other interpreter improve their code completion proposals (feature:, var:, service:) with better replacement in the origin expression and maybe even images (it could be another bug entry).
Comment 1 Eclipse Genie CLA 2015-08-17 10:18:24 EDT
New Gerrit change created: https://git.eclipse.org/r/53891
Comment 3 Pierre-Charles David CLA 2015-08-31 09:59:26 EDT
Fixed by 8021528a682e09106ed319866698d3ddfddb3c5f.
Comment 4 Maxime Porhel CLA 2015-10-14 09:10:39 EDT
Validated on Sirius 3.1.0.201510130903
Comment 5 Pierre-Charles David CLA 2015-10-16 09:09:32 EDT
Available in Sirius 3.1.0.