Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[Dltk-dev] How can I access the built AST from the plugin code?

Hi,

Are there any nont-internal ways (caches, managers, etc) that I can access in order to get references to the built AST (all the classes that inherit from org.eclipse.dltk.ast.ASTNode that were built during the source code parsing)?

I need some more information from the AST that the IModelElement classes do not provide. The SourceElementRequestVisitor transforms the ASTNode objects (e.g. ModuleDeclaration, MethodDeclaration, etc.) into IModelElement classes (e.g. SourceModule, SourceMethod, etc.).

On one hand, I was able to extend the AST with other ASTNode node types specific for my needs. On the other hand, I was not able to do the same on the IModelElement hierarchy because all the classes are internal (e.g. SourceMethod, etc). If I try to define my own SourceElementRequestVisitor and SourceModuleStructureRequestor, I have the problem that both the SourceModuleStructureRequestor (that adds the IModelElement (resp. their Infos) to the ModelManager) and the ModelManager are both internal classes and therefore I should not use them.

Any sugestions for this?

In my particular case, I need to get the parameter types from an IMethod, SourceMethod, or a MethodInfo. But the default implementation does store only the parameter names (methodInfo.parameterNames) as strings. I would like to have either a list of SourceArgument-s (this would be a new IModelElement coresponding to the AST Argument class) or another list of type references. Of course the first solution would be more elegant: for each SourceArgument you can get it's type. The current initializers (methodInfo.parameterInitializers) would have their place in the SourceArgument class.

The same story aplies for the return type of a function. (I've seen code comments and TODOs that were suggesting that this kind of work is on his way)

Is your current work going in this direction? (I was also told that you plan in allowing users to extend the DLTK model (Alex Panchenko)). Is your future work going support such plugins that extend both AST and DLTK Model hyerarchies?


Thanks for being patient with such a long email (but I am really enthusiast about DLTK: It's like facebook, if you start using it you cannot stop anymore. It's cool!),

Regards,
Gabriel

--
MSc Gabriel Petrovay
MCSA, MCDBA, MCAD
Mobile: +41(0)787978034

Back to the top