content assist across files [message #763432] |
Fri, 09 December 2011 13:54  |
Eclipse User |
|
|
|
Hi,
if i have an autocompletion that lists all elements for some rule, now if i defined another dsl file with some aditional elements, can the autocompletion list all proposals from the two dsl files?
Thank you,
Mokhtar
|
|
|
|
|
|
Re: content assist across files [message #763464 is a reply to message #763457] |
Fri, 09 December 2011 15:27   |
Eclipse User |
|
|
|
Thank you! could you please tell me where and how to use the "ResourceDescriptionsProvider"?
for your question, actually, i am making dsl for prolog like language, given:
ct(head,condition(true),idcreation(skip),transformation(add(getter))).
ct(copyField(Field1,Field2,V),condition(true),idcreation(skip),transformation(replace(Field1,Field2))).
ctseq(doStuff,ct(head)).
ctseq(doStuff2,ct(copyField(F,F,value))).
those were say 4 prolog facts, in the third and fourth you note that i reused ct(head) and ct(copyField(..)) from their defining facts above. So i can't easily reference that part of prolog fact to the other fact providing at same time flexibility to user to change the arguments. SO prolog is type unsafe and you should beable in same program to change the structure of the predicates, so cross-reference FAILED and i think to do that job in IDE runtime
Thank you,
Mokhtar
|
|
|
|
|
Re: content assist across files [message #763474 is a reply to message #763473] |
Fri, 09 December 2011 15:47  |
Eclipse User |
|
|
|
Just to be complete here a demo of the strategy
Model:
greetings+=Greeting*;
Greeting:
'Hello' name=ID number=INT value=ID '!';
public class MydslResourceDescriptionStrategy extends
DefaultResourceDescriptionStrategy {
@Override
public boolean createEObjectDescriptions(EObject eObject,
IAcceptor<IEObjectDescription> acceptor) {
if (getQualifiedNameProvider() == null)
return false;
try {
QualifiedName qualifiedName = getQualifiedNameProvider().getFullyQualifiedName(eObject);
if (qualifiedName != null) {
Map<String, String> userData = new HashMap<String, String>();
if (eObject instanceof Greeting) {
userData.put("number", ((Greeting)eObject).getNumber()+"");
}
acceptor.accept(EObjectDescription.create(qualifiedName, eObject, userData ));
}
} catch (Exception exc) {
}
return true;
}
}
public class MyDslRuntimeModule extends org.xtext.example.mydsl.AbstractMyDslRuntimeModule {
public Class<? extends IDefaultResourceDescriptionStrategy> bindIDefaultResourceDescriptionStrategy() {
return MydslResourceDescriptionStrategy.class;
}
}
public class MyDslProposalProvider extends AbstractMyDslProposalProvider {
@Inject
ResourceDescriptionsProvider rdp;
@Override
public void completeGreeting_Value(EObject model, Assignment assignment,
ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
IResourceDescriptions rd = rdp.getResourceDescriptions(model.eResource());
for (IEObjectDescription d : rd.getExportedObjectsByType(MyDslPackage.Literals.GREETING)) {
acceptor.accept(createCompletionProposal(d.getQualifiedName().toString()+d.getUserData("number"), context));
}
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.08268 seconds