Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Scoping
Scoping [message #1062927] Tue, 11 June 2013 12:42 Go to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Hi all,

I wrote code in the AbstractDeclarativeScopeProvider.I define two method but one method is works but another method is not work (I debug but not enter in the second method)

I do not understand my problem Sad please help me .
Re: Scoping [message #1062949 is a reply to message #1062927] Tue, 11 June 2013 14:07 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Debuging into getScope will help.

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Scoping [message #1063085 is a reply to message #1062949] Wed, 12 June 2013 08:43 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Hi Christian,

I can not call second fucntion in the abstractdeclarativescopprovider.
I do not understand my problem Sad

My code is below.I try getscop.

public class MyScoping extends AbstractDeclarativeScopeProvider {
	IScope scope_ContentType_parentContentType(ContentType ctx, EReference r) {
		final ArrayList<ContentType> possiblecontenttype = ContentTypeUtil.getPossibleParentContentType(ctx);
		
		
		
		return Scopes.scopeFor( possiblecontenttype);
		
		
	}
	
	
	*****not entered*****public IScope getScope(LookUp context, EReference reference) { //I not call this fucntion :(
    
		System.out.println("xxxxxxxxxxxxxxxxxxxx");
		final ArrayList<Field> possiblefield = LookUpUtil.returnSourceContentTypeNotLookUpFields(context.getContentType());
		
		return Scopes.scopeFor( possiblefield);
		
		
	};
	 
	 



Re: Scoping [message #1063086 is a reply to message #1063085] Wed, 12 June 2013 08:48 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Sorry what do you want to do with this second function.

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Scoping [message #1063088 is a reply to message #1063085] Wed, 12 June 2013 08:51 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
P.d. and why do z you expect it to be entered it has no scope_XXX_yyy
signature

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Scoping [message #1063108 is a reply to message #1063088] Wed, 12 June 2013 11:19 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Hi Christian,

I solved my problem.My scop is LookUp 's showfield.my grammar below


IScope scope_ContentType_parentContentType(final ContentType ctx, EReference r) {
		final ArrayList<ContentType> possiblecontenttype = ContentTypeUtil.getPossibleParentContentType(ctx);
		
		//final ArrayList<Field> possiblefieldview = ViewUtil.possibleFieldForViewField(ctx) ;
		//final ArrayList<Field> possiblefield = LookUpUtil.returnSourceContentTypeNotLookUpFields(ctx);
		
		return Scopes.scopeFor( possiblecontenttype);
		
		
	}
	
	
	
	
	
	public IScope scope_LookUp_showField(final LookUp context, EReference reference) {
    
		
		final ArrayList<Field> possiblefield = LookUpUtil.returnSourceContentTypeNotLookUpFields(context.getContentType());
		
		return Scopes.scopeFor( possiblefield);
		
		
	};
	 



my grammar:



LookUp returns LookUp:
	'LookUp'
	name=QualifiedName
	'{'
		('contentType' '=' contentType=[ContentType|QualifiedName])
	 	('showField' '=' showField =[Field|QualifiedName])
	'}';

Re: Scoping [message #1063109 is a reply to message #1063108] Wed, 12 June 2013 11:26 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Hi,

I ask one question ,my grammar part is below :

View returns View:
'View'
name=QualifiedName
'{'

('fields' '=' ownedViewField+=ViewField (','ownedViewField+=ViewField)*)?
'}';

ViewField returns ViewField:
(field= [Field|QualifiedName]);


I want to write a scop in the ViewField_field .it calls in the View .I do not define scop for View->fields Sad haw can I do it.
('fields' '=' ownedViewField+=ViewField


my code :
my problem is IScope scope_View_ownedViewField.How can I do this
public IScope scope_View_ownedViewField(final View context, EReference reference) {

System.out.println("xxxxxxxxxxxxxxx") ;
final ArrayList<Field> possiblefieldview = ViewUtil.possibleFieldForViewField(context);

return Scopes.scopeFor( possiblefieldview);


};


Re: Scoping [message #1063113 is a reply to message #1063109] Wed, 12 June 2013 11:36 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

ownedViewField is not a cross reference. the only cross ref you have is

scope_ViewField_field

since xtext instantiastes ViewField lazy the signature may be

scope_ViewField_field(View ctx, ERefeference Ref)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Scoping [message #1063115 is a reply to message #1063113] Wed, 12 June 2013 11:44 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Hi Christian ,

I tried it :

public IScope scope_ViewField_field(final View context, EReference reference) {

System.out.println("xxxxxxxxxxxxxxx") ;
final ArrayList<Field> possiblefieldview = ViewUtil.possibleFieldForViewField(context);

return Scopes.scopeFor( possiblefieldview);


};
I receive an error :

An internal error occurred during: "Xtext validation".
Cyclic resolution of lazy links : ViewField.field->ViewField.field

Re: Scoping [message #1063116 is a reply to message #1063115] Wed, 12 June 2013 11:48 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

possibleFieldForViewField is not allowed to ask a View for its fields.
i dont know your semantics from what you have posted.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Scoping [message #1063121 is a reply to message #1063116] Wed, 12 June 2013 11:58 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Hi ,

My util class :


public static ArrayList<Field> possibleFieldForViewField(View view){
ArrayList<Field> uniqueFields = returnUniqueParenListFields(view);
EList<ViewField> ownedViewFields = view.getOwnedViewField();
for (Iterator<ViewField> iterator = ownedViewFields.iterator(); iterator.hasNext();) {
			ViewField viewField = (ViewField) iterator.next();
			Field alreadyAddedField = viewField.getField();
			
			for(int i = 0; i < uniqueFields.size(); i++){
				Field field = uniqueFields.get(i);
				if(field.eClass().getName().equals(alreadyAddedField.eClass().getName()) && field.getName().equals(alreadyAddedField.getName())){
uniqueFields.remove(i);
				}
			}
		}
		
		return uniqueFields;
	}
}
public static ArrayList<Field> returnUniqueParenListFields(View view){
		ArrayList<Field> allFields = returnAllParenListFields(view);
		
		for(int i = 0; i < allFields.size(); i++){
			Field field1 = allFields.get(i);
			
			for(int j = i+1; j < allFields.size(); j++){
				Field field2 = allFields.get(j);
				
				if(field1.eClass().getName().equals(field2.eClass().getName()) && field1.getName().equals(field2.getName())){
allFields.remove(j);
					
				}
			}
		}	
		return allFields;	
	}
public static ArrayList<Field> returnAllParenListFields(View view){
		ArrayList<Field> allFields = new ArrayList<>();
		CustomList parentList = (CustomList) view.eContainer();
		
		EList<ContentType> ownedContentTypes = parentList.getOwnedContentType();
		for (Iterator<ContentType> iterator = ownedContentTypes.iterator(); iterator
				.hasNext();) {
			ContentType contentType = (ContentType) iterator.next();
			EList<Field> fields = contentType.getOwnedField();
			for (Iterator<Field> iterator2 = fields.iterator(); iterator2.hasNext();) {
				Field field = (Field) iterator2.next();
				allFields.add(field);
			}
		}
		
		return allFields;
	}
	



[Updated on: Wed, 12 June 2013 11:58]

Report message to a moderator

Re: Scoping [message #1063123 is a reply to message #1063121] Wed, 12 June 2013 12:04 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

duplicates checks you would not do by scoping.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Scoping [message #1063126 is a reply to message #1063123] Wed, 12 June 2013 12:11 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Hi Christian,

How can I do it .same name and same type musnt comes .Which class is used

[Updated on: Wed, 12 June 2013 12:13]

Report message to a moderator

Re: Scoping [message #1063133 is a reply to message #1063126] Wed, 12 June 2013 12:51 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

are you talking about content assist or validation?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Scoping [message #1063135 is a reply to message #1063133] Wed, 12 June 2013 12:53 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

sorry. to your updated question. i do no get the point.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Scoping [message #1063178 is a reply to message #1063135] Wed, 12 June 2013 14:30 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Hi Christian ,

oke I will create a new topic.

But I do not do validation .I will use contentAssist but How can I do this.I do not understand
Re: Scoping [message #1063182 is a reply to message #1063178] Wed, 12 June 2013 14:41 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Please post the new topic with a complete grammar and example model

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Fillter predicate
Next Topic:Terminals with whitespace
Goto Forum:
  


Current Time: Fri Apr 19 23:08:20 GMT 2024

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

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

Back to the top