|
|
Re: using filters in cross referencing [message #977432 is a reply to message #976014] |
Fri, 09 November 2012 09:29 |
sri sri Messages: 20 Registered: October 2012 |
Junior Member |
|
|
Hi,
Thanks a lot for your reply.
If i have to use below grammar, and can not use QN,
Model: cs+=Company* employees+=Emp* block+=Block+
;
Block: emp1=company_crossRef
| emp_id=empId_crossRef
;
company_crossRef: comp1=[Company] ':' emp2=[Emp] ':' empId2=[empId] ;
empId_crossRef: emp1=[Emp] ':' empId1=[empId];
Company: c='Company' name=ID '{' emp+=Emp+ '}';
Emp: r='Emp' name=ID '{' empIdName+= empId* '}'';' ;
empId: 'Employee_id' name=ID
Then,
(1) Do i need to cross reference at some higher rule like Block instead of in company_crossRef, empId_crossRef etc as this discussion suggests? http://www.eclipse.org/forums/index.php/m/898746/
(2) Do I need to give filter with IEObjectDescription in scopeProvider class or do i need to override lookupCrossReference method in proposal provider? I understood as lookupCrossReference, in turn takes scope provider's definition before actually giving the list of cross referable items. So, is it the same if i mention filter either in lookupCrossReference or in scopeProvider?
(3) I got very few examples of filter usage in eclipse discussions, other than that, don't we have good documentation explaining possible options in filters?
|
|
|
|
|
|
|
Re: using filters in cross referencing [message #977504 is a reply to message #977481] |
Fri, 09 November 2012 10:30 |
sri sri Messages: 20 Registered: October 2012 |
Junior Member |
|
|
Hi, Thank you for reply. Sorry i am not quite clear at this moment about what exactly are concrete and abstract syntax. But, yes, it is not possible, in my case, to change the syntax. Syntax is fixed for my grammar.
When i cross reference only one of company or employee, I needed to restrict the scope and it worked as i want, it shows employee of that particular company and after that employee Ids of that employee..By node model, do you mean gmf.node etc.,?
|
|
|
|
|
|
Re: using filters in cross referencing [message #981389 is a reply to message #977523] |
Mon, 12 November 2012 11:20 |
sri sri Messages: 20 Registered: October 2012 |
Junior Member |
|
|
Hi Christian,
Thank you for the link. I tried out the example in this link (I looked at later blog he created for more recent xtext versions, and tried that too..still could not get even that working).
while trying the first link, http://dslmeinte.wordpress.com/2010/08/16/path-expressions-in-entity-models/
I work on xtext 2.2.1, and the scope providers i have been writing appear similiar to what is there in this blog. So, For the domain model example grammar in xtext, i tried to copy scope provider in the blog to scopeProvider.java in my project, and i got below errors, which i could not fix. Do any of these errors appear obvious or any hint to me about how to fix these errors?
(1) On line 6, The method structuralFeatures(Entity) is undefined for the type MyDslScopeProvider
(2) On line 13,
The method structuralFeatures(Entity) is undefined for the type MyDslScopeProvider
(3) Multiple markers at this line. The method emptyIterable() is undefined for the type Iterables
(4) On line 15, The method emptyIterable() is undefined for the type Iterables. After i have imported, import com.google.common.collect.Iterables;
(5) On line 26, The type IResourceDescription.Event.Listener is not generic; it cannot be parameterized with arguments <StructuralFeature>
The list of packages i imported are:
package org.xtext.example.mydsl2.scoping;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.xtext.resource.IResourceDescription.Event.Listener;
import org.eclipse.xtext.scoping.IScope;
import org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.xtext.example.mydsl2.myDsl.Entity;
import org.xtext.example.mydsl2.myDsl.Feature;
import org.xtext.example.mydsl2.myDsl.PathHead;
import org.xtext.example.mydsl2.myDsl.PathTail;
import org.xtext.example.mydsl2.myDsl.Reference;
import org.xtext.example.mydsl2.myDsl.StructuralFeature;
import org.xtext.example.mydsl2.myDsl.Type;
import org.xtext.example.mydsl2.myDsl.impl.StructuralFeatureImpl;
import com.google.common.collect.Iterables;
Please give me a hint if the errors i am getting are because of any obvious reasons.
Thanks.
|
|
|
|
|
Re: using filters in cross referencing [message #981476 is a reply to message #981445] |
Mon, 12 November 2012 12:50 |
|
Just gave it a short try
Model: cs+=Company* employees+=Emp* (block+=Head ";")+
;
Named:
Company | Emp | empId
;
Head:
headable=[Named] tail=Tail
;
Tail:
{Tail}":" tailable=[Named] (tail=Tail)?
;
Company: c='Company' name=ID '{' emp+=Emp+ '}';
Emp: r='Emp' name=ID '{' empIdName+= empId* '}'';' ;
empId: 'Employee_id' name=ID;
public class MyDslNameProvider extends SimpleNameProvider {
}
public class MyDslRuntimeModule extends org.xtext.example.mydsl.AbstractMyDslRuntimeModule {
@Override
public Class<? extends IQualifiedNameProvider> bindIQualifiedNameProvider() {
return MyDslNameProvider.class;
}
}
public class MyDslScopeProvider extends AbstractDeclarativeScopeProvider {
IScope scope_Head_headable(EObject ctx, EReference ref) {
return new FilteringScope(delegateGetScope(ctx, ref), new Predicate<IEObjectDescription>() {
@Override
public boolean apply(IEObjectDescription input) {
return EcoreUtil2.isAssignableFrom(MyDslPackage.Literals.COMPANY, input.getEClass())
|| EcoreUtil2.isAssignableFrom(MyDslPackage.Literals.EMP, input.getEClass());
}
});
}
IScope scope_Tail_tailable(EObject ctx, EReference ref) {
EObject container = ctx.eContainer();
if (container instanceof Head) {
Head head = (Head)container;
if (head.getHeadable() instanceof Company) {
return Scopes.scopeFor(((Company)head.getHeadable()).getEmp());
}
if (head.getHeadable() instanceof Emp) {
return Scopes.scopeFor(((Emp)head.getHeadable()).getEmpIdName());
}
return IScope.NULLSCOPE;
} else if (container instanceof Tail) {
Tail tail = (Tail)container;
if (tail.getTailable() instanceof Emp) {
return Scopes.scopeFor(((Emp)tail.getTailable()).getEmpIdName());
}
return IScope.NULLSCOPE;
}
return IScope.NULLSCOPE;
}
}
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
Re: using filters in cross referencing [message #984452 is a reply to message #984362] |
Wed, 14 November 2012 18:07 |
|
the feature is called unassiged action. it creates the object at the place of the action and not lazy (first assignment) as it is usually done by xtext
otherwise you would have the head or parent tail in the scoping and not the tail you
are actually working on as context object during content assist.
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
Powered by
FUDForum. Page generated in 0.06310 seconds