Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » PHP Development Tools (PDT) » Instantiate PHP Model
Instantiate PHP Model [message #1765464] Fri, 09 June 2017 19:42 Go to next message
Tiago Martins is currently offline Tiago MartinsFriend
Messages: 23
Registered: May 2017
Junior Member
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 #1765478 is a reply to message #1765464] Sat, 10 June 2017 13:59 Go to previous messageGo to next message
Tiago Martins is currently offline Tiago MartinsFriend
Messages: 23
Registered: May 2017
Junior Member
Anyone? Thank you
Re: Instantiate PHP Model [message #1765504 is a reply to message #1765478] Sun, 11 June 2017 12:07 Go to previous messageGo to next message
Michal Niewrzal is currently offline Michal NiewrzalFriend
Messages: 50
Registered: July 2009
Member
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 Go to previous messageGo to next message
Tiago Martins is currently offline Tiago MartinsFriend
Messages: 23
Registered: May 2017
Junior Member
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 Go to previous messageGo to next message
Michal Niewrzal is currently offline Michal NiewrzalFriend
Messages: 50
Registered: July 2009
Member
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 ;)
Re: Instantiate PHP Model [message #1765630 is a reply to message #1765628] Mon, 12 June 2017 21:38 Go to previous message
Tiago Martins is currently offline Tiago MartinsFriend
Messages: 23
Registered: May 2017
Junior Member
That's what I thought, thank you very much for your help!
Previous Topic:Fails to install org.eclipse.php.importer
Next Topic:Android app communicating with PDT debugger
Goto Forum:
  


Current Time: Sat Jun 23 18:13:59 GMT 2018

Powered by FUDForum. Page generated in 0.02390 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top