Summary: | Strange java delta when creating a new class | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Estelle Ringenbach <estelle_ringenbach> |
Component: | Core | Assignee: | Jerome Lanneluc <jerome_lanneluc> |
Status: | VERIFIED FIXED | QA Contact: | |
Severity: | major | ||
Priority: | P3 | CC: | dirk_baeumer, jerome_lanneluc |
Version: | 2.1 | ||
Target Milestone: | 2.1 RC1 | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Whiteboard: |
Description
Estelle Ringenbach
2003-01-30 11:45:14 EST
Jerome - pls double check if our behavior is fine (or is it UI causing grief?) Dirk, why did you move this bug to JDT/Core? Shouldn't JDT/UI use JavaCore.run () when creating classes and fields? Jerome I should have been a little bit more explicit. Sorry. I moved it to JDT/Core since the bug says that the behaviour shows up with the example code provided in the help section manipulating java code. I thought you might want to update the help using JavaCore.run(...). I think Estelle meant that she's using the example code provided in the help section to listen to Java deltas. Otherwise she's using the UI to create fiels, classes... Estelle can you confirm? Jerome, you are right. She is saying that she is using the UI to create them, but we don't have dialogs to create methods and fields. I will dig into the problem of creating classes. OK, I looked into your code and we are using JavaCore.run when creating a new type. Estelle, which build are you using. This got changed somewhere between M3 and M4. To be sure you should use I20030129. I succefully reproduced the problem in the version I20030129 (1650), using Hello World plugin template from PDE and copying the code from the "Manipulating the java code" help section into the plugin class. The listener is registered at the end of the plugin constructor thanks to those two lines: IElementChangedListener listener = new MyJavaElementChangeReporter(); JavaCore.addElementChangedListener(listener, ElementChangedEvent.PRE_AUTO_BUILD); Then to run, I activate the plugin, create a new class file using the class wizard, and I still get the 4 deltas I indicated in my initial post. Hope this helps. Thanks, Estelle for your help. Here is what's happening: - UI enclosed the creation of the new type in a runnable executed via JavaCore.run. - in fact 4 deltas are send out by the Java Model. - first triggered by CompilationUnit.getSharedWorkingCOpy - second triggered by WorkingCopy.reconcile - thrid triggered by WorkingCopy.destroy - forth triggered by Worksapce.endOperation. Moving to Core for commenting on why working copy operations are send out immediatelly Jerome - aren't we batching reconcile deltas ? We were not batching reconcile deltas. Added 3 new operations so as to be able to batch deltas for creation of shared working copies, deletion of shared working copies, and reconcile of working copies. I'm using I20030214 and when I create a new java class using the wizard, my PRE_AUTO_BUILD listener is notified twice that a java class has been added. The first PRE_AUTO_BUILD runs before the builder (what I expect) and the second one (PRE_AUTO_BUILD too) runs after the builder ..... I also noticed that the delta doesn't contain the creation of the IType correponding to the java class declaration (automatically created by the wizard). The listener notification works fine when I create a java class without using the wizard : I create an empty file (with java extension), save it and fill it with a class declaration. The first notification is the creation of the compilation unit. The second notification is the creation of the working copy (when the editor is opened). The creation of the IType is implicitely notified by the notification of the creation of the ICompilationUnit (When an IJavaElement is added/removed, the addition/removal of its children is implicit) Estelle, with the above explanation, is it ok to close ? Our delta looks good. A compilation unit and a working copy are distinct elements. Dirk, can you confirm that the UI does this in 2 batch operations? The first batch creates the compilation unit, the second opens the editor and creates the working copy. Batching of delta is good. Please open a separate report against JDT/UI if you want the creation+opening of the type to be done in one batch. Verified. |