Instantiate PHP Model [message #1765464] |
Fri, 09 June 2017 19:42  |
Eclipse User |
|
|
|
Hi everyone,
Since there is a way to parse PHP code into an abstract syntax tree using import org.eclipse.php.internal.core.ast.nodes.ASTParser;
Is there also some kind of util to also instantiate the PHP Model correspondent to the file parsed?
Or do I have to implement my own factory with the entire Metamodel of the PHP Language Code?
Thank you very much for any incoming help!
|
|
|
|
Re: Instantiate PHP Model [message #1765504 is a reply to message #1765478] |
Sun, 11 June 2017 12:07   |
Eclipse User |
|
|
|
Hi,
At the moment I'm not sure what do you want to achieve but take a look at 'DLTKCore.create' methods. You can create IModelElement from IFile or IResource. For valid php source file it should return ISourceModule with file model. It will give you info about classes, methods, functions, etc. but not info about e.g. method source structure. It's much higher level than ASTParser. Let me know if it helps you or describe what you need exactly and we will try to help you :)
|
|
|
Re: Instantiate PHP Model [message #1765601 is a reply to message #1765504] |
Mon, 12 June 2017 17:22   |
Eclipse User |
|
|
|
Hi @Michal Niewrzal, thank you for your message.
My objective is to have a Model in Ecore correspondent to the PHP Model of the source file.
To do that I assume I have to iterate through the entire tree and instantiate each node individually in the target Ecore model?
Thank you!
|
|
|
Re: Instantiate PHP Model [message #1765628 is a reply to message #1765601] |
Mon, 12 June 2017 21:18   |
Eclipse User |
|
|
|
To traverse over file model you can use IModelElement.accept(IModelElementVisitor) or iterate recursively over the children's. How to do rest on EMF side is your decision ;)
|
|
|
|
Powered by
FUDForum. Page generated in 0.03796 seconds