Skip to content

Commit

Permalink
No need to run didOpen/didClose/didChange with scheduling rule (#2637)
Browse files Browse the repository at this point in the history
No need to run document lifecycle operation with scheduling rule
  • Loading branch information
testforstephen authored May 8, 2023
1 parent c98fd2c commit 1bbff65
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -302,44 +302,41 @@ public IProblemRequestor getProblemRequestor(ICompilationUnit workingCopy) {

public void didClose(DidCloseTextDocumentParams params) {
documentVersions.remove(params.getTextDocument().getUri());
ISchedulingRule rule = JDTUtils.getRule(params.getTextDocument().getUri());
try {
ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
handleClosed(params);
}
}, rule, IWorkspace.AVOID_UPDATE, new NullProgressMonitor());
}, null, IWorkspace.AVOID_UPDATE, new NullProgressMonitor());
} catch (CoreException e) {
JavaLanguageServerPlugin.logException("Handle document close ", e);
}
}

public void didOpen(DidOpenTextDocumentParams params) {
documentVersions.put(params.getTextDocument().getUri(), params.getTextDocument().getVersion());
ISchedulingRule rule = JDTUtils.getRule(params.getTextDocument().getUri());
try {
ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
handleOpen(params);
}
}, rule, IWorkspace.AVOID_UPDATE, new NullProgressMonitor());
}, null, IWorkspace.AVOID_UPDATE, new NullProgressMonitor());
} catch (CoreException e) {
JavaLanguageServerPlugin.logException("Handle document open ", e);
}
}

public void didChange(DidChangeTextDocumentParams params) {
documentVersions.put(params.getTextDocument().getUri(), params.getTextDocument().getVersion());
ISchedulingRule rule = JDTUtils.getRule(params.getTextDocument().getUri());
try {
ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
handleChanged(params);
}
}, rule, IWorkspace.AVOID_UPDATE, new NullProgressMonitor());
}, null, IWorkspace.AVOID_UPDATE, new NullProgressMonitor());
} catch (CoreException e) {
JavaLanguageServerPlugin.logException("Handle document change ", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public static int toOffset(IDocument document, int line, int column) {
try {
return document.getLineOffset(line) + column;
} catch (BadLocationException e) {
JavaLanguageServerPlugin.logException(e.getMessage(), e);
JavaLanguageServerPlugin.debugTrace("toOffset: " + (e.getMessage() == null ? e.toString() : e.getMessage()));
}
}
return -1;
Expand Down Expand Up @@ -157,7 +157,7 @@ public static int[] toLine(IDocument document, int offset) {
int column = offset - document.getLineOffset(line);
return new int[] { line, column };
} catch (BadLocationException e) {
JavaLanguageServerPlugin.logException(e.getMessage(), e);
JavaLanguageServerPlugin.debugTrace("toLine: " + (e.getMessage() == null ? e.toString() : e.getMessage()));
}
}
return null;
Expand Down

0 comments on commit 1bbff65

Please sign in to comment.