Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Add types to auto-completion (Types are in database)
icon3.gif  Add types to auto-completion [message #1100661] Tue, 03 September 2013 12:14 Go to next message
Aurélien Lebeau is currently offline Aurélien LebeauFriend
Messages: 16
Registered: September 2013
Junior Member
Hi,

I am enhancing a RCP with Xtext and I would like to add values to default ones provided by cross-referencing and auto-completion. The problem is that these values, either types or variables, are defined in a SQL database that is handled in an another plugin.

For now, the cross-referencing looks like this and works great for variables declared in the same file.
variable: variable=[var_declaration|IDENTIFIER]


I know it's possible to refer to JVMTypes using these lines but it's not sufficient for what I want.
import "http://www.eclipse.org/xtext/common/JavaVMTypes" as jvmTypes
[jvmTypes::JvmType | IDENTIFIER]



How can I start ? ResourceProvider, Scope or anything else ? I should get values from DB, then including them in the xtext resources.

Is it possible to get a solution that is constantly refreshing references from database ? In other words, the database can be modified at any moment and I must have the latests values, so each time cross-reference is made, the values should be refreshed.


Thanks in advance !
Re: Add types to auto-completion [message #1100909 is a reply to message #1100661] Tue, 03 September 2013 19:37 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

can you elaborate a bit more: if the jvm types are not java classes why at all do you use them?

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Add types to auto-completion [message #1100910 is a reply to message #1100909] Tue, 03 September 2013 19:41 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hmmm looks like i got you wrong.
so you want to reference to something that is not really there right?

so the first question is: do you need references at all or are validated and proposed values ok? if so simply hook into validator and proposalprovider.
if not you need to make the stuff available somehow. e.g. by a special resource service provider.

maybe IDerivedStateComputer is a possible hook too.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Tue, 03 September 2013 19:52]

Report message to a moderator

Re: Add types to auto-completion [message #1100929 is a reply to message #1100910] Tue, 03 September 2013 20:15 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Alternatively you could do something like Xtext does arround AbstractJvmTypeProvider but what would be extreme work i think.

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Add types to auto-completion [message #1101224 is a reply to message #1100661] Wed, 04 September 2013 06:57 Go to previous messageGo to next message
Aurélien Lebeau is currently offline Aurélien LebeauFriend
Messages: 16
Registered: September 2013
Junior Member
Thanks for your responses.

Ideally, I would like something like the jvm types but for now, it would be ok if I only have them proposed and validated.

So if I got it right, for the rules where I need cross-reference to these DB-values, I do not need to make cross-references like
[variable|IDENTIFIER]
but I can let only
IDENTIFIER
and then modify the validator and the proposal provider ?


Is it also possible to redefine the behaviour of ctrl-clic ? Actually, I display the variables and types (from DB) in a panel of my RCP. It would be great if when I ctrl-clic on a variable in my DSL file, the corresponding one is selected in my panel. I already have all the mechanism to select a variable given its name.

[Updated on: Wed, 04 September 2013 07:48]

Report message to a moderator

Re: Add types to auto-completion [message #1101241 is a reply to message #1101224] Wed, 04 September 2013 07:34 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
yes you can hook into HyperlinkHelper

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Add types to auto-completion [message #1101459 is a reply to message #1101241] Wed, 04 September 2013 13:32 Go to previous messageGo to next message
Aurélien Lebeau is currently offline Aurélien LebeauFriend
Messages: 16
Registered: September 2013
Junior Member
Thanks !

I achieved to proposed the values from the DB by overriding
override completeVariable_Name(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
    for(each value in db)
        acceptor.accept(createCompletionProposal(value.name, context));
}


Is it the right way ?

Another question, the number of values can be huge (~ millions). Is there a way to "force" the user to enter at least 3 characters (for example) before to propose values ? In the case he did not enter at least 3 chars, values with name length less than 3 chars would only be proposed. In other words, is it a way to know what the user has already entered ? ContentAssistContext ? If so, which attribute ?

What are usually the ways to improve ProposalProvider efficiency ?
Re: Add types to auto-completion [message #1101462 is a reply to message #1101459] Wed, 04 September 2013 13:40 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

i guess you can find infos about the current context in ContentAssistContext.getPrefix


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic: No EObjectDescription could be found in Scope
Next Topic:Unique identifiers across XText resources
Goto Forum:
  


Current Time: Tue Apr 16 13:29:51 GMT 2024

Powered by FUDForum. Page generated in 1.39802 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top