Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » defined int attribute in the grammar ,this elements is incrementally automatically
defined int attribute in the grammar ,this elements is incrementally automatically [message #1095504] Tue, 27 August 2013 06:22
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Hi all,

I defined a rule : id is defined int type.for every rule has an id in my grammar.

SingleInstanceUserTask returns SingleInstanceUserTask:
'SingleInstanceUserTask' name=QualifiedName
'{'
'id' '=' id=INT
'joinType' '=' joinType=TaskType

'}';

my aim is :

When the user enter "id =" ,automatically write an id (such as 1, 2 ,3) for my every instance .start with 1 for first id ,and then second id =2 .

I use AutoEditStrategy (below) .contents = contents + IDUtil.generateId this line must generate id (id must be ordered number (1 2 3))

IDUtil not generate an number :(Sad how can ı do this?


public class EditStrategyProvider extends DefaultAutoEditStrategyProvider {

	private final class Surprise implements IAutoEditStrategy {

		private String contents;

		public void customizeDocumentCommand(IDocument document,
				DocumentCommand command) {
			try {
				if (command.text.equals("=")
						&& document.get(command.offset - 3, 3).equals("id ")) {
					// System.out.println(document.get(command.offset-5, 5));
					contents = document.get();
					String afterCommandString = contents.substring(
							command.offset, document.getLength());
					contents = document.get(0, command.offset);
					int index=1;
					contents = contents + GUIDUtil.generateId (index);
							





Best regards
Previous Topic:JVM inferred objects and content assist still not solved
Next Topic:Generator: Force the encoding
Goto Forum:
  


Current Time: Fri Apr 26 09:32:59 GMT 2024

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

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

Back to the top