Mapping SearchEngine results into jdt.core.dom nodes? [message #1738189] |
Sun, 17 July 2016 22:24 |
|
Hello all,
In the Epsilon [1] project, we want to expose regular Java projects as models. To do so, we wrote some code [2] that takes IJavaProject instances and uses an ASTVisitor instance to collect information from jdt.core.dom AST nodes. For instance, with TypeDeclaration.all" you can list all the TypeDeclarations in a project.
Later on, we found out about the SearchEngine class in jdt.core.search and thought it'd be nice to use that to be able to quickly look up classes by name. We have a first version of the integration, but we've run into a slight issue: the search engine serves up SourceTypes and BinaryTypes, not the TypeDeclarations that we want.
We first tried adapting some code from the JDT autocomplete code, but that produced jdt.internal.compiler.ast TypeDeclarations, which a) are internal and b) are not the jdt.core.dom TypeDeclarations that we want. Eventually what we did [3] is get the ICompilationUnit from the search result, reparse and find the jdt.core.dom TypeDeclaration whose name matches that of the SourceType, but having to reparse the file feels inefficient.
Is there a better way to map the results of the SearchEngine to JDT DOM nodes? Should we use a different approach?
Thanks in advance!
Antonio
[1]: http://www.eclipse.org/epsilon/
[2]: https://github.com/epsilonlabs/emc-jdt
[3]: https://github.com/epsilonlabs/emc-jdt/blob/master/org.eclipse.epsilon.emc.jdt/src/org/eclipse/epsilon/emc/jdt/SearchableTypeCollection.java#L73
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04491 seconds