Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Get a List<String> in something.mydsl(XTEXT- grammar)  () 1 Vote
icon5.gif   Get a List<String> in something.mydsl [message #691823] Sat, 02 July 2011 09:11 Go to next message
Caner
Messages: 98
Registered: July 2011
Member
Hi, Thank you so much for magnificently useful tool.

However, I had some problems;

For example, I have a List<String>writers , which contains 10000 writer's names, for instance one of them is "Stefan King" .
I dont want to define all of them by one by, because i have ten more existing lists like this. Is there any way to get a list into my grammar?

Because While I am coding with my dsl in my
" something.mydsl " file. I want that content assist completes "Stefan King" or comes up with some proposal names, which start with "Ste", , while I typed "Ste"

How can I solve this?

Or is there any other way than this, how can i monitor List elements in a content assist displayer ,
such as when I type "Ste" for "Stefan King" in "something.mydsl"

Thanks a lot

[Updated on: Sat, 02 July 2011 14:55]

Report message to a moderator

Re: Get a List<String> in something.mydsl [message #692061 is a reply to message #691823] Sun, 03 July 2011 07:13 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6145
Registered: July 2009
Senior Member
Hi,

since you did not post the grammar it's hard to understand what the problem really is. e.g. having a grammar

Model:
	greetings+=Greeting*;
	
Greeting:
	'Hello' name=Name '!';
	
Name hidden(): ID (WS ID)* ;	


you can simply customize content assist

public class MyDslProposalProvider extends AbstractMyDslProposalProvider {
	
	....
	
	@Override
	public void completeGreeting_Name(EObject model, Assignment assignment,
			ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
		for (String writer : writers) {
			acceptor.accept(createCompletionProposal(writer, context));
		}
	}

}


the prefix matching works out of the box.

~Christian

[Updated on: Sun, 03 July 2011 07:22]

Report message to a moderator

Re: Get a List<String> in something.mydsl [message #692085 is a reply to message #692061] Sun, 03 July 2011 10:00 Go to previous message
Caner
Messages: 98
Registered: July 2011
Member
Thank you so much , this is exactly what i was asking Smile
Previous Topic:Beginner problems with simple grammar using the eclipse plugin
Next Topic:Slot 'models' is empty
Goto Forum:
  


Current Time: Fri Aug 01 22:36:37 EDT 2014

Powered by FUDForum. Page generated in 0.06173 seconds