Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 275289 - createStructure is called for left and right element when editing right side
Summary: createStructure is called for left and right element when editing right side
Status: RESOLVED DUPLICATE of bug 275286
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Compare (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Tomasz Zarna CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-07 07:57 EDT by Tomasz Zarna CLA
Modified: 2009-05-11 11:21 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tomasz Zarna CLA 2009-05-07 07:57:27 EDT
3.5M7

Steps:
1. select two Java files in PE and do Compare With > Each Other 
2. toggle breakpoint in StructureCreator.createStructure(Object, IProgressMonitor). 
3a. edit left side
=> observe that createStructure is called twice for the left element
3b. edit right side
=> observe that createStructure is called once for the left element and once for the right element
Comment 1 Tomasz Zarna CLA 2009-05-07 08:24:47 EDT
Missed one step that should go between 1 and 2:
- Open the file from the left side in a separate CU editor

or

- Open the file from the right side in a separate CU editor to get an opposite result:
=> createStructure is called twice for the right element when editing right
=> craeteStrucute is called once for the left element and once for the right element when editing left
Comment 2 Tomasz Zarna CLA 2009-05-07 08:29:24 EDT
Dani is this an expected behavior?
Comment 3 Dani Megert CLA 2009-05-07 08:58:03 EDT
>Dani is this an expected behavior?
It should not happen but I can imagine the cause for this: compare probably does not disable the reconciler when it gets deactivated (i.e. the Java editor activated) and hence two reconcile take place and acted upon.

The code which does this is in JavaReconciler but of course it expects that the Java editor is the top level part and can't handle nesting.
Comment 4 Tomasz Zarna CLA 2009-05-07 09:04:57 EDT
You're right. Here is the stack:

Daemon Thread [org.eclipse.jdt.internal.ui.text.JavaReconciler] (Suspended (breakpoint at line 171 in StructureDiffViewer$StructureInfo))	
	StructureDiffViewer$StructureInfo.getRefreshTask() line: 171	
	JavaStructureDiffViewer(StructureDiffViewer).contentChanged(IContentChangeNotifier) line: 401	
	JavaStructureDiffViewer.elementChanged(ElementChangedEvent) line: 258	
	DeltaProcessor$3.run() line: 1557	
	SafeRunner.run(ISafeRunnable) line: 42	
	DeltaProcessor.notifyListeners(IJavaElementDelta, int, IElementChangedListener[], int[], int) line: 1547	
	DeltaProcessor.fireReconcileDelta(IElementChangedListener[], int[], int) line: 1399	
	DeltaProcessor.fire(IJavaElementDelta, int) line: 1358	
	ReconcileWorkingCopyOperation(JavaModelOperation).run(IProgressMonitor) line: 769	
	ReconcileWorkingCopyOperation(JavaModelOperation).runOperation(IProgressMonitor) line: 788	
	CompilationUnit.reconcile(int, int, WorkingCopyOwner, IProgressMonitor) line: 1242	
	JavaReconcilingStrategy.reconcile(ICompilationUnit, boolean) line: 126	
	JavaReconcilingStrategy.access$0(JavaReconcilingStrategy, ICompilationUnit, boolean) line: 108	
	JavaReconcilingStrategy$1.run() line: 89	
	SafeRunner.run(ISafeRunnable) line: 42	
	JavaReconcilingStrategy.reconcile(boolean) line: 87	
	JavaReconcilingStrategy.reconcile(IRegion) line: 151	
	JavaCompositeReconcilingStrategy(CompositeReconcilingStrategy).reconcile(IRegion) line: 86	
	JavaCompositeReconcilingStrategy.reconcile(IRegion) line: 102	
	JavaReconciler(MonoReconciler).process(DirtyRegion) line: 77	
	AbstractReconciler$BackgroundThread.run() line: 206	

In case when the createStructure is called for both sides reconcile is done for two different documents.

I didn't get the part about deactivating compare. These doubled calls happen when editing in Compare Editor, so it supposed to be active.
Comment 5 Dani Megert CLA 2009-05-07 09:09:29 EDT
>These doubled calls happen
>when editing in Compare Editor, so it supposed to be active.
Right. Should have read all details.
Comment 6 Tomasz Zarna CLA 2009-05-07 11:41:50 EDT
In case when createStructure is called twice for the same element (editing B.java in Compare Editor, compared with A.java and having B.java open in another editor), ElementChangedEvent events are slightly different:
- [Working copy] B.java[*]: {CONTENT | FINE GRAINED | AST AFFECTED}
- [Working copy] B.java[*]: {AST AFFECTED}

And when called for both elements (editing A.java in Compare Editor, compared with B.java and having B.java open in another editor), the events are :

- [Working copy] A.java[*]: {CONTENT | FINE GRAINED}
- [Working copy] B.java[*]: {AST AFFECTED}
Comment 7 Tomasz Zarna CLA 2009-05-08 05:35:57 EDT
Patch from bug 275286 fixes this issue as well. Again, code change is completely on JDT side.
Comment 8 Tomasz Zarna CLA 2009-05-11 11:21:08 EDT
See the comment above. This bug has exactly the same cause as bug 275286.

*** This bug has been marked as a duplicate of bug 275286 ***