Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » CTRL+SPACE action
CTRL+SPACE action [message #1063181] Wed, 12 June 2013 10:41 Go to next message
junior developer is currently offline junior developer
Messages: 335
Registered: January 2013
Senior Member
Hi all,

I want to remove duplicat names and same type in the View 's fields.How can I do this.I want to use my util class.
related part for this topic :http://www.eclipse.org/forums/index.php/m/1063178/#msg_1063178
Could you help me
My grammar is below :

View returns View:
'View'
name=QualifiedName
'{'
'guID' '=' guID=STRING
'displayName' '=' displayName=STRING
('description' '=' description=STRING)?
'type' '=' type= ViewType
('fields' '=' ownedViewField+=ViewField (','ownedViewField+=ViewField)*)?
'}';

ViewField returns ViewField:
(field= [Field|QualifiedName]);
my util class is below :


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;
	}
	



Re: CTRL+SPACE action [message #1063214 is a reply to message #1063181] Wed, 12 June 2013 12:37 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6131
Registered: July 2009
Senior Member
Hi,

once more your grammar is incomplete.
let us asume it looks like

Model:
	fields+=Field*
	views+=View*;
	
Field:
	"Field" name=ID
;	
	
View returns View:
'View'
name=QualifiedName
'{'
'guID' '=' guID=STRING
'displayName' '=' displayName=STRING
('description' '=' description=STRING)?
('fields' '=' ownedViewField+=ViewField (','ownedViewField+=ViewField)*)?
'}';

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

QualifiedName: ID ("." ID)*;


then the Proposal Provider could look like (written in Xtend):

class MyDslProposalProvider extends AbstractMyDslProposalProvider {
	
	override completeViewField_Field(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
		val view = EcoreUtil2::getContainerOfType(model, typeof(View))
		val names = view.ownedViewField.map[vw|vw.field?.name].filter[v|v!=null].toList
		println (names)
		lookupCrossReference(assignment.terminal as CrossReference, context, acceptor, [
			IEObjectDescription d | names.contains(d.qualifiedName.toString)
		])
	}
	
}
Re: CTRL+SPACE action [message #1063216 is a reply to message #1063214] Wed, 12 June 2013 12:44 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6131
Registered: July 2009
Senior Member
Please NOTE: you will need a validator for duplicates as well since this only adapts proposals.
Re: CTRL+SPACE action [message #1063253 is a reply to message #1063216] Wed, 12 June 2013 16:34 Go to previous messageGo to next message
junior developer is currently offline junior developer
Messages: 335
Registered: January 2013
Senior Member
Hi Christian,

I will try it but not comes anything in the View's fields (val names = view.ownedViewField.map[vw|vw.field?.name].filter[v|v!=null].toList comes null)
and my finally grammar:

Content returns Content:'{'
'ct' name=QualifiedName
application=WebApplication
	'}'
WebApplication returns WebApplication:
	'WebApplication' name=Qualifiedname
ownColection+=Collection (ownColection+=Collection)*'}'
Collection returns Collection:'{'
'Collection' name=QualifiedName
ownWeb=Web '}'

Web returns Web:
	'Web'
	name=QualifiedName
	'{'(lists+=Liste (lists+=Liste)*)?
	(webs+=Web (webs+=Web)*)?
	'}'
Liste returns Liste:
	'Liste'
	name=QualifiedName
	'{'(cttype+=CType (cttype+=CType)*)?
	(ownedView+=View (ownedView+=View)*)?
	'}'
View returns View:
	'View'
	name=QualifiedName
	'{''type' '=' type= ViewType
	('fields' '=' ownedViewField+=ViewField (','ownedViewField+=ViewField)*)?
	'}';
ViewField returns ViewField:
	(field= [Field|QualifiedName]);
Field returns Field:
	LookUp | Boolean 


Field returns Field:
	LookUp | BooleanField 
;

CType returns CType:
	'CType'
	name=QualifiedName
	'{' ('parent' '=' parentContentType=[ContentType|QualifiedName])?
	'fields' '{'
	(ownedField+=Field (ownedField+=Field)*)?
	'}'
	'}';


LookUp returns LookUp:
	'LookUp'
	name=QualifiedName
	'{' 'text' name=STRING '}'
QualifiedName : 
	ID('.'ID)*
;
	



best regards

[Updated on: Wed, 12 June 2013 16:44]

Report message to a moderator

Re: CTRL+SPACE action [message #1063265 is a reply to message #1063253] Wed, 12 June 2013 17:02 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6131
Registered: July 2009
Senior Member
first there was a typo in my post, you should have found that

!names.contains(d.qualifiedName.toString)


should be the closure


what do you mean by

it but not comes in the View's fields 
;(

and the grammar is not copy and pasteable Sad( And a sample model is missing Sad((
the fields have no name so they cannot be cross refd

and i do NOT get duplicate ownedFields proposed. ;((((

of course i had to fix the qualified name problem first (nameprovider or grammar+pp provider)

public class MyQNP extends DefaultDeclarativeQualifiedNameProvider{
	
	@Inject
	IQualifiedNameConverter qnc;

	QualifiedName qualifiedName(Field f) {
		System.out.println(f.getName());
		return qnc.toQualifiedName(f.getName());
	}
	
}


=> it always help to try things with a hello word example to get problems split

i never know what your current "hü oder hott" status is
Re: CTRL+SPACE action [message #1063269 is a reply to message #1063265] Wed, 12 June 2013 17:35 Go to previous messageGo to next message
junior developer is currently offline junior developer
Messages: 335
Registered: January 2013
Senior Member
Hi Christian,

I remove some rules in the grammar.I do it simplify .
Fistly :!names.contains(d.qualifiedName.toString) not understand it :(Sad I use DefaultDeclarativeQualifiedNameProvider :retuns all field names :This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.
******text
******created
******createdBy
******contentTYPE
******numberfield
******bool
 @Inject
			IQualifiedNameConverter qnc;

			QualifiedName qualifiedName(Field f) {
				System.out.println("******"+f.getName());
				return qnc.toQualifiedName(f.getName());
			}


Secondly :I want to say with (it but not comes in the View's fields ) :When I enter CTRL+SPACE,does not come nothing in the View's fields attribute. :(:(:(I used below code

override completeViewField_Field(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
		val view = EcoreUtil2::getContainerOfType(model, typeof(View))
		println ("viewwwww"+view)
		val names = view.ownedViewField.map[vw|vw.field?.name].filter[v|v!=null].toList
		println ("namessss"+names)
		
		lookupCrossReference(assignment.terminal as CrossReference, context, acceptor, [
			IEObjectDescription d | names.contains(d.qualifiedName.toString)
		])
		
	}



really ,I am very confised :(Sad Hence I allready duplicate name check with NamesAreUniqueValidator.My aim is:remove fields that has same type and same name in the View's ownedFields
(such as There are two Lookup field ,must get one lookupfield)


[Updated on: Wed, 12 June 2013 17:39]

Report message to a moderator

Re: CTRL+SPACE action [message #1063270 is a reply to message #1063269] Wed, 12 June 2013 17:39 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6131
Registered: July 2009
Senior Member
Hi I fear without binary sharing you complete code (zip) I can only
guess and not 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
Re: CTRL+SPACE action [message #1063271 is a reply to message #1063269] Wed, 12 June 2013 17:40 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6131
Registered: July 2009
Senior Member
BTW I wanted to to replace

names.contains(d.qualifiedName.toString

With

! names.contains(d.qualifiedName.toString

--
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
Re: CTRL+SPACE action [message #1063272 is a reply to message #1063270] Wed, 12 June 2013 17:47 Go to previous messageGo to next message
junior developer is currently offline junior developer
Messages: 335
Registered: January 2013
Senior Member
Hi Christian,

I can send an email ,I do not share all project Sad
Re: CTRL+SPACE action [message #1063273 is a reply to message #1063272] Wed, 12 June 2013 17:49 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6131
Registered: July 2009
Senior Member
Hi as I said: simplyfy it to a hello world example.
What do the prints in the proposalprovidet result in?

--
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
Re: CTRL+SPACE action [message #1063274 is a reply to message #1063273] Wed, 12 June 2013 17:51 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6131
Registered: July 2009
Senior Member
here is my current version

class MyDslProposalProvider extends AbstractMyDslProposalProvider {
	
	override completeViewField_Field(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
		val view = EcoreUtil2::getContainerOfType(model, typeof(View))
		val names = view.ownedViewField.map[vw|vw.field?.name].filter[v|v!=null].toList
		println (names)
		lookupCrossReference(assignment.terminal as CrossReference, context, acceptor, [
			IEObjectDescription d | println(d.qualifiedName);!names.contains(d.qualifiedName.toString)
		])
	}
}
Re: CTRL+SPACE action [message #1063278 is a reply to message #1063274] Wed, 12 June 2013 17:59 Go to previous messageGo to next message
junior developer is currently offline junior developer
Messages: 335
Registered: January 2013
Senior Member
Hi,
I tried this code .my result is below screenshot. gets all field Sad




Christian Dietrich wrote on Wed, 12 June 2013 17:51
here is my current version

class MyDslProposalProvider extends AbstractMyDslProposalProvider {
	
	override completeViewField_Field(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
		val view = EcoreUtil2::getContainerOfType(model, typeof(View))
		val names = view.ownedViewField.map[vw|vw.field?.name].filter[v|v!=null].toList
		println (names)
		lookupCrossReference(assignment.terminal as CrossReference, context, acceptor, [
			IEObjectDescription d | println(d.qualifiedName);!names.contains(d.qualifiedName.toString)
		])
	}
}

Re: CTRL+SPACE action [message #1063280 is a reply to message #1063278] Wed, 12 June 2013 18:03 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6131
Registered: July 2009
Senior Member
Sorry once more you are mixing up 1000 things

this code filters duplicates.i dont see duplicates ?!?
it does not take care about the scope of all possibilites.
(this was a different thread !?!)
Re: CTRL+SPACE action [message #1063283 is a reply to message #1063280] Wed, 12 June 2013 18:14 Go to previous messageGo to next message
junior developer is currently offline junior developer
Messages: 335
Registered: January 2013
Senior Member
Hi ,

oke ,it do now .sorry ,did not realize Sad I understand noww thanks for replly.
Now I will do second constraints.I remove same type .I can do it in AbstractMyDslProposalProvider?

Re: CTRL+SPACE action [message #1063286 is a reply to message #1063283] Wed, 12 June 2013 18:19 Go to previous messageGo to next message
junior developer is currently offline junior developer
Messages: 335
Registered: January 2013
Senior Member
I ask one question.

I must do this for qualifiedname : if I override qualifiedname ,not do it .certainly ,I must do ?

@Inject
IQualifiedNameConverter qnc;

QualifiedName qualifiedName(Field f) {
System.out.println("******"+f.getName());
return qnc.toQualifiedName(f.getName());
}
Re: CTRL+SPACE action [message #1063287 is a reply to message #1063283] Wed, 12 June 2013 18:15 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6131
Registered: July 2009
Senior Member
What do you mean with that? Can you give an example. Did you have a
look at my answer to your other post

--
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
Re: CTRL+SPACE action [message #1063289 is a reply to message #1063286] Wed, 12 June 2013 18:21 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6131
Registered: July 2009
Senior Member
Don't know your scoping so can't say.

--
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
Re: CTRL+SPACE action [message #1063294 is a reply to message #1063278] Wed, 12 June 2013 18:36 Go to previous messageGo to next message
junior developer is currently offline junior developer
Messages: 335
Registered: January 2013
Senior Member
Hi,
I used this code and duplicate names are remove.
but I use for field qualifiedname : overridequalifiedname screenshot
@Inject
			IQualifiedNameConverter qnc;

			QualifiedName qualifiedName(Field f) {
				System.out.println("******"+f.getName());
				return qnc.toQualifiedName(f.getName());
			}



if I do not use QualifiedName qualifiedName(Field f),result screenshot:withoutqualifiednameoverride:gets all field.

must I use IQualifiedNameConverter qnc?

junior developer wrote on Wed, 12 June 2013 17:59
Hi,
I tried this code .my result is below screenshot. gets all field Sad




Christian Dietrich wrote on Wed, 12 June 2013 17:51
here is my current version

class MyDslProposalProvider extends AbstractMyDslProposalProvider {
	
	override completeViewField_Field(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
		val view = EcoreUtil2::getContainerOfType(model, typeof(View))
		val names = view.ownedViewField.map[vw|vw.field?.name].filter[v|v!=null].toList
		println (names)
		lookupCrossReference(assignment.terminal as CrossReference, context, acceptor, [
			IEObjectDescription d | println(d.qualifiedName);!names.contains(d.qualifiedName.toString)
		])
	}
}

[Updated on: Wed, 12 June 2013 18:39]

Report message to a moderator

Re: CTRL+SPACE action [message #1063297 is a reply to message #1063294] Wed, 12 June 2013 18:43 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6131
Registered: July 2009
Senior Member
Or you have to adapt the filter logic so that it uses qualified names
for the already applied fields

(By asking iqualifiednsmeprovider for the name instead field?.name

--
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
Re: CTRL+SPACE action [message #1063298 is a reply to message #1063297] Wed, 12 June 2013 18:44 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6131
Registered: July 2009
Senior Member
P.s. once more: use the debugger to find out what happens

--
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
Re: CTRL+SPACE action [message #1063407 is a reply to message #1063297] Thu, 13 June 2013 02:21 Go to previous messageGo to next message
junior developer is currently offline junior developer
Messages: 335
Registered: January 2013
Senior Member
Hi Christian,

I do not understand this post.I cant use qualifiedname.

Christian Dietrich wrote on Wed, 12 June 2013 18:43
Or you have to adapt the filter logic so that it uses qualified names
for the already applied fields

(By asking iqualifiednsmeprovider for the name instead field?.name

--
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

Re: CTRL+SPACE action [message #1063408 is a reply to message #1063407] Thu, 13 June 2013 02:24 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6131
Registered: July 2009
Senior Member
If you don't use qualified names what do the printlns say?

--
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
Re: CTRL+SPACE action [message #1063538 is a reply to message #1063408] Thu, 13 June 2013 07:50 Go to previous messageGo to next message
junior developer is currently offline junior developer
Messages: 335
Registered: January 2013
Senior Member
Hi Christian,
now,My problem is qualifiedname.
I used qualifiedname :
public class QNP extends DefaultDeclarativeQualifiedNameProvider{


QualifiedName qualifiedName(Field f) {
System.out.println("++++++++++++++++++++++++"+f.getName());
return qualifiedName(f.getName());

}
}

Result:


contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.creaated
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.lookuppp
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.creaated
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.lookuppp
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.creaated
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.lookuppp
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.creaated
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.lookuppp
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.contentTYPE
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype1.text
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype1.created
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype1.createdBy
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype1.contentTYPE
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype1.numberfield
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype1.bool
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype2.text
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype2.creaated
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype2.createdBy
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype2.contentTYPE
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype2.lookup1
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.creaated
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.lookuppp
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.contentTYPE
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype1.text
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype1.created
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype1.createdBy
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype1.contentTYPE
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype1.numberfield
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype1.bool
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype2.text
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype2.creaated
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype2.createdBy
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype2.contentTYPE
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype2.lookup1
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.creaated
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.lookuppp
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.contentTYPE
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype1.text
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype1.created
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype1.createdBy
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype1.contentTYPE
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype1.numberfield
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype1.bool
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype2.text
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype2.creaated
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype2.createdBy
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype2.contentTYPE
contentmodel.webapp.sitecall1.rootweb.customlist1.contenttype2.lookup1
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.creaated
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.lookuppp
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.contentTYPE
++++++++++++++++++++++++text
++++++++++++++++++++++++created
++++++++++++++++++++++++createdBy
++++++++++++++++++++++++contentTYPE
++++++++++++++++++++++++numberfield
++++++++++++++++++++++++bool
++++++++++++++++++++++++text
++++++++++++++++++++++++creaated
++++++++++++++++++++++++createdBy
++++++++++++++++++++++++contentTYPE
++++++++++++++++++++++++lookup1
++++++++++++++++++++++++title
++++++++++++++++++++++++creaated
++++++++++++++++++++++++createdBy
++++++++++++++++++++++++contentTYPE
++++++++++++++++++++++++lookuppp
++++++++++++++++++++++++title
++++++++++++++++++++++++created
++++++++++++++++++++++++createdBy
++++++++++++++++++++++++contentTYPE
++++++++++++++++++++++++title
++++++++++++++++++++++++created
++++++++++++++++++++++++createdBy
++++++++++++++++++++++++contentTYPE





Hence if I used this code in the DefaultDeclarativeQualifiedNameProvider


public class QNP extends DefaultDeclarativeQualifiedNameProvider{
            @Inject
			IQualifiedNameConverter qnc;

			QualifiedName qualifiedName(Field f) {
				
				return qnc.toQualifiedName(f.getName());
			}
}




my below code works :

class MyDsl2ProposalProvider extends AbstractMyDsl2ProposalProvider {
	
	override completeViewField_Field(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
		val view = EcoreUtil2::getContainerOfType(model, typeof(View))
		val names = view.ownedViewField.map[vw|vw.field?.name].filter[v|v!=null].toList
		println (names)
		lookupCrossReference(assignment.terminal as CrossReference, context, acceptor, [
			IEObjectDescription d | println(d.qualifiedName);!names.contains(d.qualifiedName)
		])
	}



Re: CTRL+SPACE action [message #1063547 is a reply to message #1063538] Thu, 13 June 2013 07:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6131
Registered: July 2009
Senior Member
vw.field?.name

Adds simple name

Inject Iqualifiednameprovider.
Ask it for the fields name.
Add the qualified name to the list

--
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
Re: CTRL+SPACE action [message #1063581 is a reply to message #1063547] Thu, 13 June 2013 08:58 Go to previous messageGo to next message
junior developer is currently offline junior developer
Messages: 335
Registered: January 2013
Senior Member
Hi Christian ,

I try this code but not remove duplicate fields Sad
I remove this class

public class QNP extends DefaultDeclarativeQualifiedNameProvider{
/* @Inject
IQualifiedNameConverter qnc;

QualifiedName qualifiedName(Field f) {

return qnc.toQualifiedName(f.getName());
}*/
}





class MyDsl2ProposalProvider extends AbstractMyDsl2ProposalProvider {
	 @Inject extension IQualifiedNameProvider //add now
	override completeViewField_Field(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	
		
		val view = EcoreUtil2::getContainerOfType(model, typeof(View))
		val names = view.ownedViewField.map[vw|vw.field?.fullyQualifiedName].filter[v|v!=null].toList
		println (names)
		lookupCrossReference(assignment.terminal as CrossReference, context, acceptor, [
			IEObjectDescription d | println(d.qualifiedName);!names.contains(d.qualifiedName)
		])
	}

Re: CTRL+SPACE action [message #1063585 is a reply to message #1063581] Thu, 13 June 2013 09:01 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6131
Registered: July 2009
Senior Member
Hi do you want qualified names or not. It is always difficult to
find it out.

If you want them why did you post the name provider. If not why did
you change the proposal provider

--
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
Re: CTRL+SPACE action [message #1063610 is a reply to message #1063585] Thu, 13 June 2013 09:52 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6131
Registered: July 2009
Senior Member
Btw it should be vw.field?.fullyQualifiedName.toString

else you would compare äpfel with birnen
Re: CTRL+SPACE action [message #1063635 is a reply to message #1063610] Thu, 13 June 2013 10:51 Go to previous messageGo to next message
junior developer is currently offline junior developer
Messages: 335
Registered: January 2013
Senior Member
Hi Christian,

I want to Qualifiedname .I tried it

val view = EcoreUtil2::getContainerOfType(model, typeof(View))
val names = view.ownedViewField.map[vw|vw.field?.fullyQualifiedName.toString].filter[v|v!=null].toList
println (names)
lookupCrossReference(assignment.terminal as CrossReference, context, acceptor, [
IEObjectDescription d | println(d.qualifiedName);!names.contains(d.qualifiedName)
])

but I receive an error .

at org.eclipse.xtext.ui.editor.contentassist.AbstractContentProposalProvider$DefaultContentAssistProcessorSwitch.caseAssignment(AbstractContentProposalProvider.java:66)
at org.eclipse.xtext.ui.editor.contentassist.AbstractContentProposalProvider$DefaultContentAssistProcessorSwitch.caseAssignment(AbstractContentProposalProvider.java:1)
at org.eclipse.xtext.util.XtextSwitch.doSwitch(XtextSwitch.java:164)
at org.eclipse.xtext.util.XtextSwitch.doSwitch(XtextSwitch.java:70)
at org.eclipse.xtext.util.XtextSwitch.doSwitch(XtextSwitch.java:58)
Re: CTRL+SPACE action [message #1063652 is a reply to message #1063635] Thu, 13 June 2013 11:23 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6131
Registered: July 2009
Senior Member
Hi,

where is the rest of the stacktrace.
the following works for me

class MyDslProposalProvider extends AbstractMyDslProposalProvider {
	
	@Inject extension IQualifiedNameProvider
	
	override completeViewField_Field(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
		val view = EcoreUtil2::getContainerOfType(model, typeof(View))
		val names = view.ownedViewField.map[vw|vw.field?.fullyQualifiedName?.toString].filter[v|v!=null].toList
		println (names)
		lookupCrossReference(assignment.terminal as CrossReference, context, acceptor, [
			IEObjectDescription d | println(d.qualifiedName);!names.contains(d.qualifiedName.toString)
		])
	}
}
Re: CTRL+SPACE action [message #1063702 is a reply to message #1063652] Thu, 13 June 2013 15:09 Go to previous messageGo to next message
junior developer is currently offline junior developer
Messages: 335
Registered: January 2013
Senior Member
Hi Christian,

I try it but gets all field :(Sad

val view = EcoreUtil2::getContainerOfType(model, typeof(View))
val names = view.ownedViewField.map[vw|vw.field?.fullyQualifiedName?.toString].filter[v|v!=null].toList
println ("viewfielddddddddddddddd"+names)
lookupCrossReference(assignment.terminal as CrossReference, context, acceptor, [
IEObjectDescription d | println(d.qualifiedName);!names.contains(d.qualifiedName.toString)
])
}

println ("viewfielddddddddddddddd"+names) result : gets all field ,I do not solved my problem still


contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.creaated
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.lookuppp
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.creaated
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.lookuppp
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.contentTYPE

Re: CTRL+SPACE action [message #1063703 is a reply to message #1063702] Thu, 13 June 2013 15:20 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6131
Registered: July 2009
Senior Member
Hi,

you still do not get it:

this thread is about duplicates. it is NOT about visibility. do ou geht duplicates or not? i do not get duplicates!
i do not know your visibility semanctic. maybe
you are confusing this thread with http://www.eclipse.org/forums/index.php/t/488676/


Re: CTRL+SPACE action [message #1063704 is a reply to message #1063702] Thu, 13 June 2013 15:37 Go to previous messageGo to next message
junior developer is currently offline junior developer
Messages: 335
Registered: January 2013
Senior Member
Hi Christian
I solved http://www.eclipse.org/forums/index.php/t/488676/-> this topic's problem.Hence My grammar hierarch and scop same in this project (zip)http://www.eclipse.org/forums/index.php/t/488676/->
My onlly problem qualifiedname and below post(this thread).
My aim is :I dont get duplicate name and same type field in the View's ViewField.(fields).and I want to gets field with qualifiedname.
Hence,I do not use my util class,I share it above.I hope I explain my problem Sad

if I use qualifiedname ,My result is below screenshot.I can't use x.y.z now



junior developer wrote on Thu, 13 June 2013 15:09
Hi Christian,

I try it but gets all field :(Sad

val view = EcoreUtil2::getContainerOfType(model, typeof(View))
val names = view.ownedViewField.map[vw|vw.field?.fullyQualifiedName?.toString].filter[v|v!=null].toList
println ("viewfielddddddddddddddd"+names)
lookupCrossReference(assignment.terminal as CrossReference, context, acceptor, [
IEObjectDescription d | println(d.qualifiedName);!names.contains(d.qualifiedName.toString)
])
}

println ("viewfielddddddddddddddd"+names) result : gets all field ,I do not solved my problem still


contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.creaated
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.lookuppp
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.creaated
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contentype3.lookuppp
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.contenttype4.contentTYPE
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.title
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.created
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.createdBy
contentmodel.webapp.sitecall2.lookupfield.web2.ctlist2.CT4.contentTYPE

  • Attachment: 11111.png
    (Size: 42.10KB, Downloaded 33 times)

[Updated on: Thu, 13 June 2013 15:41]

Report message to a moderator

Re: CTRL+SPACE action [message #1063707 is a reply to message #1063704] Thu, 13 June 2013 15:43 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6131
Registered: July 2009
Senior Member
Hi,

my problem is: i do not understand your problem.
i do not have a complete grammar. i do not have a test model.

from your posts i do not see what is the output of the println ("viewfielddddddddddddddd"+names)
and what is the output of the println(d.qualifiedName);

viewfielddddddddddddddd should give you all used names.
println(d.qualifiedName) should give you all names that you want to filter agains used names

if i have a model

CType ctx
	 			{
	 				fields {
	 					bf a bf b bf c
	 				}
	 			}
	 			 View v1 {
	 			 	
	 			 	fields
	 			 	= 
	 			 }


i get a b and c

if i have

CType ctx
	 			{
	 				fields {
	 					bf a bf b bf c
	 				}
	 			}
	 			 View v1 {
	 			 	
	 			 	fields
	 			 	= ctx.c, 
	 			 }


i get a and b

so it looks working to me
Re: CTRL+SPACE action [message #1063708 is a reply to message #1063703] Thu, 13 June 2013 15:44 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6131
Registered: July 2009
Senior Member
btw from your screenshot: there are no duplicated since you have referenced zero fields so far.
Re: CTRL+SPACE action [message #1063710 is a reply to message #1063708] Thu, 13 June 2013 15:56 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6131
Registered: July 2009
Senior Member
here is my scoping (it may different in your case since i had to create the missing grammar myself.

class MyDslScopeProvider extends org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider {
	
	@Inject IQualifiedNameProvider qnp
	
	def IScope scope_ViewField_field(View ctx, EReference ref) {
		Scopes::scopeFor(ctx.type.type.ownedField, qnp, IScope::NULLSCOPE)
	}

}

Re: CTRL+SPACE action [message #1063724 is a reply to message #1063710] Thu, 13 June 2013 17:09 Go to previous messageGo to next message
junior developer is currently offline junior developer
Messages: 335
Registered: January 2013
Senior Member
Hi Christian ,

I load my grammar ,I added View and ownedfield.
I load sample model screenshot.

My aim is : remove fields that has same name and same type ( such as text and lookup) for View's ownedfield
******gets onnly function's fields (function is upper from the View).hence Screenshot :

View V 's fields get onnly function F's defined fields (text ,lookup):
I load "myexample" screenshot .I marked yellow wanted field (get these fields)

Hence "type" has a "parent" tahat is a type.this type's fields must get.

I hope ,I explain my problem Sad

Re: CTRL+SPACE action [message #1063743 is a reply to message #1063724] Fri, 14 June 2013 00:57 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6131
Registered: July 2009
Senior Member
HI,

why is your scoping empty if this is about scoping and not about duplicates

and please share a model that i can copy and paste.
i dont want to create a own one.

[Updated on: Fri, 14 June 2013 00:57]

Report message to a moderator

Re: CTRL+SPACE action [message #1063746 is a reply to message #1063743] Fri, 14 June 2013 01:35 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6131
Registered: July 2009
Senior Member
P.S:

if i understood your problem. the following works for me.
please note: it does not cover:
- endless parent recursion - you may have to make it save in this regards

class MyDsl6ScopeProvider extends AbstractDeclarativeScopeProvider {

	@Inject IQualifiedNameProvider qnp

	def IScope scope_ViewField_field(Function v, EReference ref) {
		Scopes::scopeFor(v.type.map[fields].flatten, qnp, IScope::NULLSCOPE)
	}
	
	def List<Field> getFields(Type t) {
		val res = <Field>newArrayList()
		res.addAll(t.ownedField)
		if (t.parentType != null) {
			res.addAll(getFields(t.parentType))
		}
		res
	}

}
Re: CTRL+SPACE action [message #1063769 is a reply to message #1063746] Fri, 14 June 2013 03:55 Go to previous messageGo to next message
junior developer is currently offline junior developer
Messages: 335
Registered: January 2013
Senior Member
Hi Christian,

Below code is works thaks for help really,

I do not understand this :v.type.map[fields].flatten

and How can I remove same type and same name .I use this code for remove duplicate name and same type. How can I do this

my util class.I can use this class in the scop class:

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;	
	}






Christian Dietrich wrote on Fri, 14 June 2013 01:35
P.S:

if i understood your problem. the following works for me.
please note: it does not cover:
- endless parent recursion - you may have to make it save in this regards

class MyDsl6ScopeProvider extends AbstractDeclarativeScopeProvider {

	@Inject IQualifiedNameProvider qnp

	def IScope scope_ViewField_field(Function v, EReference ref) {
		Scopes::scopeFor(v.type.map[fields].flatten, qnp, IScope::NULLSCOPE)
	}
	
	def List<Field> getFields(Type t) {
		val res = <Field>newArrayList()
		res.addAll(t.ownedField)
		if (t.parentType != null) {
			res.addAll(getFields(t.parentType))
		}
		res
	}

}
Re: CTRL+SPACE action [message #1063773 is a reply to message #1063769] Fri, 14 June 2013 03:57 Go to previous messageGo to previous message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6131
Registered: July 2009
Senior Member
Have a look at Xtend doku

--
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
Previous Topic:Accessing enum literals in Generator
Next Topic:Refactoring with importedNamespace and qualified name
Goto Forum:
  


Current Time: Sat Jul 26 11:14:14 EDT 2014

Powered by FUDForum. Page generated in 0.03814 seconds