Bug 77314 [implementation] Deadlock of text hover presenter with ChangeTypeAction
20041029 Got the following deadlock after replacing a word in a new class just created by the new type wizard. - The main thread comes from the ChangeTypeAction triggered by a document change event and wants to do a reconcile (not sure if it a good idea to do work in a test selection change event - The text hover is in the middle of a code resolve and waits to access the document org.eclipse.core.launcher.Main at localhost:3144 Thread [main] (Suspended) JavaModelUtil.reconcile(ICompilationUnit) line: 806 SelectionConverter.getElementAtOffset(IJavaElement, ITextSelection) line: 229 ChangeTypeAction.canEnable(ITextSelection) line: 148 ChangeTypeAction.selectionChanged(ITextSelection) line: 141 ChangeTypeAction(SelectionDispatchAction).dispatchSelectionChanged(ISelection) line: 204 ChangeTypeAction(SelectionDispatchAction).selectionChanged(SelectionChangedEvent) line: 195 Viewer$2.run() line: 163 InternalPlatform.run(ISafeRunnable) line: 616 Platform.run(ISafeRunnable) line: 747 CompilationUnitEditor$AdaptedSourceViewer(Viewer).fireSelectionChanged(SelectionChangedEvent) line: 161 CompilationUnitEditor$AdaptedSourceViewer(TextViewer).fireSelectionChanged(int, int) line: 2206 CompilationUnitEditor$AdaptedSourceViewer(TextViewer).selectionChanged(int, int) line: 2189 TextViewer$3.widgetSelected(SelectionEvent) line: 1446 TypedListener.handleEvent(Event) line: 89 EventTable.sendEvent(Event) line: 82 StyledText(Widget).sendEvent(Event) line: 800 StyledText(Widget).sendEvent(int, Event, boolean) line: 824 StyledText(Widget).sendEvent(int, Event) line: 809 StyledText(Widget).notifyListeners(int, Event) line: 617 StyledText.sendSelectionEvent() line: 6468 StyledText.clearSelection(boolean) line: 2060 StyledText.internalSetSelection(int, int, boolean) line: 7231 StyledText.updateSelection(int, int, int) line: 7735 StyledText.handleTextChanged(TextChangedEvent) line: 5146 StyledText$6.textChanged(TextChangedEvent) line: 4709 DefaultDocumentAdapter.fireTextChanged() line: 337 DefaultDocumentAdapter.documentChanged(DocumentEvent) line: 281 PartiallySynchronizedDocument(AbstractDocument).doFireDocumentChanged2(DocumentEvent) line: 704 PartiallySynchronizedDocument(AbstractDocument).doFireDocumentChanged(DocumentEvent, boolean, IRegion) line: 677 PartiallySynchronizedDocument(AbstractDocument).doFireDocumentChanged(DocumentEvent) line: 662 PartiallySynchronizedDocument(AbstractDocument).fireDocumentChanged(DocumentEvent) line: 739 PartiallySynchronizedDocument(AbstractDocument).replace(int, int, String) line: 1030 PartiallySynchronizedDocument.replace(int, int, String) line: 92 DefaultDocumentAdapter.replaceTextRange(int, int, String) line: 238 StyledText.modifyContent(Event, boolean) line: 5604 StyledText.sendKeyEvent(Event) line: 6444 StyledText.doContent(char) line: 2536 StyledText.handleKey(Event) line: 4979 StyledText.handleKeyDown(Event) line: 5002 StyledText$7.handleEvent(Event) line: 4747 EventTable.sendEvent(Event) line: 82 StyledText(Widget).sendEvent(Event) line: 800 StyledText(Widget).sendEvent(int, Event, boolean) line: 824 StyledText(Widget).sendEvent(int, Event) line: 809 StyledText(Widget).sendKeyEvent(int, int, int, int, Event) line: 837 StyledText(Widget).sendKeyEvent(int, int, int, int) line: 833 StyledText(Widget).wmChar(int, int, int) line: 1096 StyledText(Control).WM_CHAR(int, int) line: 3077 StyledText(Control).windowProc(int, int, int, int) line: 2987 Display.windowProc(int, int, int, int) line: 3361 OS.DispatchMessageW(MSG) line: not available [native method] OS.DispatchMessage(MSG) line: 1499 Display.readAndDispatch() line: 2446 Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 1527 Workbench.runUI() line: 1498 Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 276 PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 144 IDEApplication.run(Object) line: 102 PlatformActivator$1.run(Object) line: 335 EclipseStarter.run(Object) line: 273 EclipseStarter.run(String[], Runnable) line: 129 NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method] NativeMethodAccessorImpl.invoke(Object, Object[]) line: 79 DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 41 Method.invoke(Object, Object[]) line: 386 Main.basicRun(String[]) line: 185 Main.run(String[]) line: 704 Main.main(String[]) line: 688 Thread [Framework Event Dispatcher] (Suspended) EventThread(Object).wait(long, int) line: not available [native method] EventThread(Object).wait() line: 193 EventThread.getNextEvent() line: 162 EventThread.run() line: 100 Thread [Start Level Event Dispatcher] (Suspended) EventThread(Object).wait(long, int) line: not available [native method] EventThread(Object).wait() line: 193 EventThread.getNextEvent() line: 162 EventThread.run() line: 100 Thread [Reference Cleaner: 1] (Suspended) ReferenceQueue(Object).wait(long, int) line: not available [native method] ReferenceQueue(Object).wait(long) line: 223 ReferenceQueue.remove(long) line: 96 ReferenceQueue.remove() line: 68 ImageCache$ReferenceCleanerThread.run() line: 376 Thread [Java indexing] (Suspended) IndexManager(Object).wait(long, int) line: not available [native method] IndexManager(Object).wait() line: 193 IndexManager(JobManager).run() line: 345 Thread.run() line: 802 Thread [org.eclipse.jdt.internal.ui.text.JavaReconciler] (Suspended) DirtyRegionQueue(Object).wait(long, int) line: not available [native method] DirtyRegionQueue(Object).wait(long) line: 223 AbstractReconciler$BackgroundThread.run() line: 176 Thread [org.eclipse.jdt.internal.ui.text.JavaReconciler] (Suspended) DirtyRegionQueue(Object).wait(long, int) line: not available [native method] DirtyRegionQueue(Object).wait(long) line: 223 AbstractReconciler$BackgroundThread.run() line: 176 Thread [Worker-7] (Suspended) WorkerPool(Object).wait(long, int) line: not available [native method] WorkerPool(Object).wait(long) line: 223 WorkerPool.sleep(long) line: 166 WorkerPool.startJob(Worker) line: 193 Worker.run() line: 59 Thread [org.eclipse.jdt.internal.ui.text.JavaReconciler] (Suspended) DirtyRegionQueue(Object).wait(long, int) line: not available [native method] DirtyRegionQueue(Object).wait(long) line: 223 AbstractReconciler$BackgroundThread.run() line: 176 Thread [Text Viewer Hover Presenter] (Suspended) PartiallySynchronizedDocument.get() line: 64 DocumentAdapter.getContents() line: 276 DocumentAdapter.getCharacters() line: 268 CompilationUnit.getContents() line: 595 SelectionEngine.select(ICompilationUnit, int, int) line: 435 CompilationUnit(Openable).codeSelect(ICompilationUnit, int, int, WorkingCopyOwner) line: 140 CompilationUnit.codeSelect(int, int, WorkingCopyOwner) line: 299 CompilationUnit.codeSelect(int, int) line: 293 JavadocHover(AbstractJavaEditorTextHover).getHoverInfo(ITextViewer, IRegion) line: 108 BestMatchHover.getHoverInfo(ITextViewer, IRegion) line: 102 JavaEditorTextHoverProxy.getHoverInfo(ITextViewer, IRegion) line: 69 TextViewerHoverManager$4.run() line: 160
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/ChangeTypeAction.java
* the selection provided by the site's selection provider is of type
	 * <code>org.eclipse.jface.viewers.IStructuredSelection</code>.
	 * 
	 * @param site the site providing context information for this action
	 */
	public ChangeTypeAction(IWorkbenchSite site) {
		super(site);
		setText(RefactoringMessages.getString("ChangeTypeAction.label")); 
		setToolTipText(RefactoringMessages.getString("ChangeTypeAction.tooltipText")); 
		setDescription(RefactoringMessages.getString("ChangeTypeAction.description")); 
		WorkbenchHelp.setHelp(this, IJavaHelpContextIds.CHANGE_TYPE_ACTION);
		fDialogMessageTitle= RefactoringMessages.getString("ChangeTypeAction.dialog.title"); 
	}
	
	
	public void selectionChanged(IStructuredSelection selection) {
		try {
			setEnabled(getMember(selection) != null);
		} catch (JavaModelException e) {
			setEnabled(false);
		}
	}
	public void run(IStructuredSelection selection) {
		try {
			IMember member= getMember(selection);
			if (member == null)
				return;
			ISourceRange range= member.getNameRange();
			ICompilationUnit icu= member.getCompilationUnit();
			ITextSelection textSelection= new TextSelection(range.getOffset(), range.getLength());