public RoutingCompletionStrategy(ICompletionContext context) {
super(context);
this.context = context;
sourceModule = ((AbstractCompletionContext) context).getSourceModule();
IScriptProject scriptProject = sourceModule.getScriptProject();
this.model = SymfonyWorkspaceModelManager.getInstance().getModel(scriptProject.getProject());
}
@Override
public void apply(ICompletionReporter reporter) {
Iterator it = model.getRoutings().entrySet().iterator();
while (it.hasNext()) {
try {
Map.Entry pairs = (Map.Entry)it.next();
FakeType type = new FakeType((ModelElement)sourceModule, (String)pairs.getKey());
reporter.reportType(type, "", getReplacementRange(getContext()));
} catch (BadLocationException e) {
e.printStackTrace();
}
}
}
The part in the Extending_PDT_2.2 wiki page about contributing to the structured model
has a use case where you add additional "nodes" to an existing PHP Model, in the
example adding methods to a class. But i'm trying to explicitly define a new Type.
The problem with the above code is, that i pass the sourcemodule if the completion requester itself as the
parent to the new FakeType (because i had nothing else i could pass to it).
Therefore, in the code assistance dialog, it's reported that the route "dashboard" belongs to the Class "SomeAction".
What i would like to achive is, that the code assist popup displays the Routes as distinct Model Types, so it's clear what this actually is.
I hope the description is somewhat clear ;)
regards
-robert
On Mar 2, 2010, at 9:04 AM, 赵忠伟 wrote:
I think you have to parse the *.yml files(because you must transtate the text to model).
In Michael's link,I think it only works for php or php compatible files.
But I am not sure.
On Tue, Mar 2, 2010 at 3:51 PM, Michael Spector
<spektom@xxxxxxxxx> wrote:
Have a look at:
http://wiki.eclipse.org/Extending_PDT_2.2
2010/3/2 Robert Gründler
<doobre@xxxxxxxxx>
Hi everyone,
i'm asking for some advice how to implement the following scenario:
The framework i'm extending PDT for uses Yaml config files, and i would
like to add support for them in the IDE. One example for such a configuration
file would be a routing file, which looks like this:
routing.yml:
home:
url: /
param: { module: home, action: index }
dashboard:
url: /
param: { module: user, action: dashboard }
I would like to add this information to the ScriptModel as a new Type,
so for example you can expand the .yml file in the Project Explorer and
have 2 more nodes "home" and "dashboard", or add content assist
which suggests those 2 routings in cases like $someController->redirect("@ home | dashboard");
Basically i would need to tell DLTK that there are 2 more Model elements:
1. A Routing (which represents the .yml file)
2. A Route (which has Routing as parent element)
In the above example the model would have one Routing (routing.yml) which
contains 2 Routes (home and dashboard).
Has anyone a hint how i could accomplish this?
thanks again!
-robert
_______________________________________________
dltk-dev mailing list
dltk-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/dltk-dev
_______________________________________________
dltk-dev mailing list
dltk-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/dltk-dev
--
Thanks!
Best Regards!
Zhao
_______________________________________________
dltk-dev mailing list
dltk-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/dltk-dev