Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Hooking into JDT for listening to classpath changes on a project
Hooking into JDT for listening to classpath changes on a project [message #1809038] Sat, 06 July 2019 21:26 Go to next message
Alex Mising name is currently offline Alex Mising nameFriend
Messages: 149
Registered: March 2010
Senior Member
Hello,

I have a builder which works on JDT projects and needs to react to classpath changes (i.e. if a user changes the Java project's classpath, I need to reindex my builder's state).

Now, I would like to support incremental building (i.e. if a classpath entry was removed, I just want to prune anything in my model that points into it and if a classpath entry was added I want to scan it to save information in my model).

What is the best way for my plugin to register interest with JDT for "classpath changes" on the JDT project to which my builder is attached?
Re: Hooking into JDT for listening to classpath changes on a project [message #1809039 is a reply to message #1809038] Sun, 07 July 2019 08:20 Go to previous messageGo to next message
Alex Mising name is currently offline Alex Mising nameFriend
Messages: 149
Registered: March 2010
Senior Member
So I've been reading around to figure this out and found:

JavaCore.addElementChangedListener(myListener);

	@Override
	public void elementChanged(ElementChangedEvent event) {
		IJavaElementDelta jed = event.getDelta();
		if ((jed.getFlags() & IJavaElementDelta.F_ADDED_TO_CLASSPATH) != 0)
			// ...
		if ((jed.getFlags() & IJavaElementDelta.F_REMOVED_FROM_CLASSPATH) != 0)
			// ...
	}


Only caveat is that it seems there seems to be no out-of-the-box visitor for this?
Re: Hooking into JDT for listening to classpath changes on a project [message #1809045 is a reply to message #1809039] Mon, 08 July 2019 05:56 Go to previous messageGo to next message
Jay Arthanareeswaran is currently offline Jay ArthanareeswaranFriend
Messages: 128
Registered: July 2009
Senior Member
Hi Alexandros,

Your understanding is correct. We don't have any visitor. You have to iterate through the delta and process the change.

Jay
Re: Hooking into JDT for listening to classpath changes on a project [message #1809087 is a reply to message #1809045] Mon, 08 July 2019 19:22 Go to previous message
Alex Mising name is currently offline Alex Mising nameFriend
Messages: 149
Registered: March 2010
Senior Member
Thank you. Obviously it's not a big deal, but when you're learning a new API you're always wondering whether you've missed something and are "doing things wrong".

It's nice to know that this is simply different to the resource deltas of builders and you're just supposed to do it yourself.
Previous Topic: Question about eclipse compiler.!!
Next Topic:<terminated>???
Goto Forum:
  


Current Time: Thu Apr 25 10:31:27 GMT 2024

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

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

Back to the top