Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » [JDT-Core][API] How to get a list of compilation units affected by a change?
[JDT-Core][API] How to get a list of compilation units affected by a change? [message #1745483] Tue, 11 October 2016 12:43
Abel Hegedus is currently offline Abel HegedusFriend
Messages: 197
Registered: September 2015
Senior Member
TL;DR: Is it possible to find out which compilation units are built by JDT after a change?

We have created a prototype for transforming Java source code to UML models incrementally by listening to element change listener notifications on the JavaModel ( https://github.com/viatra/viatra-evm-jdt/wiki/Demo ).

Our approach works on a compilation unit level and relies on JDT to resolve cross references when identifying types of fields and method parameters or return types ( https://github.com/viatra/viatra-evm-jdt/wiki/Cross-reference-updating-between-compilation-units ). Since the element change listener only provides notifications on content changes, we needed an other way to refresh cross references when the referenced type is resolved without any change on the element itself (e.g. a missing type is created).

We found that this information is available in the build state of JDT, however we have not found any public API for accessing this from our code. For our prototype, we solved this by using a CompilationParticipant (
JavaModelManager.getJavaModelManager().getLastBuiltState(iproject, new NullProgressMonitor())
) and reflection to read some internal fields of org.eclipse.jdt.internal.core.builder.State and org.eclipse.jdt.internal.compiler.util.SimpleLookupTable (see JDTBuildState and JDTReferenceStorage ).

The information that we need is the list of compilation units that are affected by the change of a given element.

My questions are the following:


  1. Is there any API that provides this information without dealing with reflection?
  2. Does the new index provide any change notifications and if yes, can it be used to identify which types/compilation units were recompiled after a change?


If needed, I can send a message to the jdt-core-dev mailing list if the JDT developers think that is a more appropriate place to discuss this.

Thanks a lot for any input!
Previous Topic:Eclipse Neon 4.6.1 Ignores @formatter:off
Next Topic:Internal Errors during "Project classpath scan"?
Goto Forum:
  


Current Time: Fri Mar 29 04:56:12 GMT 2024

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

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

Back to the top