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

perf: don't get document when file is opened #1229

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
package com.redhat.devtools.intellij.lsp4ij;

import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.fileEditor.FileEditorManagerListener;
import com.intellij.openapi.project.DumbService;
Expand Down Expand Up @@ -56,21 +54,18 @@ public void projectClosing(@NotNull Project project) {

@Override
public void fileOpened(@NotNull FileEditorManager source, @NotNull VirtualFile file) {
Document document = FileDocumentManager.getInstance().getDocument(file);
if (document != null) {
Project project = source.getProject();
boolean readAccessAllowed = ApplicationManager.getApplication().isReadAccessAllowed();
boolean dumb = DumbService.isDumb(project);
// As document matcher requires read action, we try to open the file in read action and when indexing is finishsed.
if (readAccessAllowed && !dumb) {
// No indexing and read action enabled
// --> force the start of all languages servers mapped with the given file immediately
connectToLanguageServer(file, project);
} else {
// Wait for indexing is finished and read action is enabled
// --> force the start of all languages servers mapped with the given file when indexing is finished and read action is allowed
new ConnectToLanguageServerCompletableFuture(file, project);
}
Project project = source.getProject();
boolean readAccessAllowed = ApplicationManager.getApplication().isReadAccessAllowed();
boolean dumb = DumbService.isDumb(project);
// As document matcher requires read action, we try to open the file in read action and when indexing is finishsed.
if (readAccessAllowed && !dumb) {
// No indexing and read action enabled
// --> force the start of all languages servers mapped with the given file immediately
connectToLanguageServer(file, project);
} else {
// Wait for indexing is finished and read action is enabled
// --> force the start of all languages servers mapped with the given file when indexing is finished and read action is allowed
new ConnectToLanguageServerCompletableFuture(file, project);
}
}

Expand Down
Loading