Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After saving a file, Javadoc not shown on hover #375

Closed
fbricon opened this issue Oct 3, 2017 · 2 comments · Fixed by #392
Closed

After saving a file, Javadoc not shown on hover #375

fbricon opened this issue Oct 3, 2017 · 2 comments · Fixed by #392
Assignees

Comments

@fbricon
Copy link
Contributor

fbricon commented Oct 3, 2017

When hovering over a class or method or module you just opened, the Javadoc shows up as expected. If the javadoc is modified, javadoc on hover is updated.
As soon as the file is saved, javadoc is not shown anymore.

Turns out, this returns null:

ISourceRange javadocRange= member.getJavadocRange();

In Member.java, we have

public ISourceRange getJavadocRange() throws JavaModelException {
	ISourceRange range= getSourceRange();
	if (range == null) return null;
	IBuffer buf= null;
	if (isBinary()) {
		buf = getClassFile().getBuffer();
	} else {
		ICompilationUnit compilationUnit = getCompilationUnit();
		if (!compilationUnit.isConsistent()) {
			return null;
		}

The problem is compilationUnit.isConsistent() returns false. If we dig deeper, we see that, in CompilationUnit:

public boolean isConsistent() {
	return !JavaModelManager.getJavaModelManager().getElementsOutOfSynchWithBuffers().contains(this);
}

So, for some reason, the compilation unit, after saving the file, ends up in JavaModelManager.elementsOutOfSynchWithBuffers

@fbricon fbricon added the bug label Oct 3, 2017
@fbricon fbricon added this to the Mid October 2017 milestone Oct 3, 2017
@fbricon
Copy link
Contributor Author

fbricon commented Oct 3, 2017

So this is tricky: the buffer is put out of sync because a document change event is fired AFTER the workspace operation finishes to save the file :

JavaModelManager.getElementsOutOfSynchWithBuffers() line: 2132	
CompilationUnit(Openable).bufferChanged(BufferChangedEvent) line: 53	
DocumentAdapter.fireBufferChanged(BufferChangedEvent) line: 298	
DocumentAdapter.documentChanged(DocumentEvent) line: 289	
SynchronizableDocument(AbstractDocument).doFireDocumentChanged2(DocumentEvent) line: 744	
SynchronizableDocument(AbstractDocument).doFireDocumentChanged(DocumentEvent, boolean, IRegion) line: 713	
SynchronizableDocument(AbstractDocument).doFireDocumentChanged(DocumentEvent) line: 697	
SynchronizableDocument(AbstractDocument).fireDocumentChanged(DocumentEvent) line: 771	
SynchronizableDocument(AbstractDocument).set(String, long) line: 1142	
SynchronizableDocument.set(String, long) line: 197	
ResourceTextFileBuffer.handleFileContentChanged(boolean, boolean) line: 466	
ResourceFileBuffer$FileSynchronizer$2.execute() line: 148	
ResourceFileBuffer$FileSynchronizer$2(ResourceFileBuffer$SafeFileChange).run() line: 83	
ResourceFileBuffer$FileSynchronizer.resourceChanged(IResourceChangeEvent) line: 183	
NotificationManager$1.run() line: 299	
SafeRunner.run(ISafeRunnable) line: 42	
NotificationManager.notify(ResourceChangeListenerList$ListenerEntry[], ResourceChangeEvent, boolean) line: 289	
NotificationManager.broadcastChanges(ElementTree, ResourceChangeEvent, boolean) line: 152	
Workspace.broadcastPostChange() line: 374	
Workspace.endOperation(ISchedulingRule, boolean) line: 1469	
Workspace.run(ICoreRunnable, ISchedulingRule, int, IProgressMonitor) line: 2253	
Workspace.run(IWorkspaceRunnable, IProgressMonitor) line: 2262	
DocumentLifeCycleHandler.didSave(DidSaveTextDocumentParams) line: 186	

Not sure how to handle that. @gorkem, @aeschli, @snjeza, @tsmaeder ideas?

@aeschli
Copy link
Contributor

aeschli commented Oct 4, 2017

I guess the question is, how does the resource change event get triggered. It seems to happen while saving, or even be a side effect of saving.
I'd suggest to nail it down in the DocumentLifeCycleHandlerTest, e.g here

fbricon added a commit to fbricon/eclipse.jdt.ls that referenced this issue Oct 17, 2017
This fixes eclipse-jdtls#375 somehow

Signed-off-by: Fred Bricon <[email protected]>
@fbricon fbricon self-assigned this Oct 17, 2017
fbricon added a commit that referenced this issue Oct 18, 2017
This fixes #375 somehow

Signed-off-by: Fred Bricon <[email protected]>
@fbricon fbricon added the hover label Feb 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants