Summary: | ASTParser: better reusability | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Christian Dietrich <christian.dietrich.opensource> |
Component: | Core | Assignee: | JDT-Core-Inbox <jdt-core-inbox> |
Status: | NEW --- | QA Contact: | |
Severity: | enhancement | ||
Priority: | P3 | CC: | jarthana, manoj.palat, mlippert, stephan.herrmann |
Version: | 4.7.1a | Keywords: | performance |
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | Mac OS X | ||
See Also: | https://bugs.eclipse.org/bugs/show_bug.cgi?id=150657 | ||
Whiteboard: | |||
Bug Depends on: | |||
Bug Blocks: | 392225 |
Description
Christian Dietrich
2017-10-26 11:02:08 EDT
The (internal) problem here is: all state (compiler & INameEnvironment) is held in the internal class CompilationUnitResolver, which is used by ASTParser only via static methods, i.e., any state is lost at the end of createBindings() or similar. From a client's p.o.v. I could imagine a pair of methods in ASTParser: startSession(); stopSession(); startSession() can be called after all ASTParser.set*(), to the effect that an instance of CompilationUnitResolver is prepared, and kept for repeated use. After that, any further call to ASTParser.set*() is illegal and will throw an exception (regarding the instance on which startSession() was invoked). Finally, stopSession() will release the CompilationUnitResolver and ASTParser.set*() will be admitted again. Alternatively, we could simply require that a new ASTParser be created (so no stopSession() would be needed). Still need to figure out, how much effort it would be, to craft a re-usable CompilationUnitResolver. After the first invocation, CUR#accept() might be our friend (replacing beginToCompile()). Perhaps, the new functionality should go into a subclass SessionBasedASTParser. Setting a reasonable target, but no promise yet. I am not an expert here, but what happens to the environment if you would pass in changed source files within such a session and resolve node again? Isn't the necessary information somehow stored in the environment, so that we would need some cleanup in between different parse attempts? Wow, genie just unearthed an old related idea: bug 150657 At a first glance I like the idea of explicitly exposing this new kind of environment. Any comment on whether the old proposal would help here? *** Bug 392333 has been marked as a duplicate of this bug. *** |