mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[platform] post-review fixes (IDEA-CR-15535)
This commit is contained in:
+9
-5
@@ -20,6 +20,7 @@ import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.editor.EditorBundle;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.pom.Navigatable;
|
||||
import com.intellij.psi.PsiElement;
|
||||
@@ -27,6 +28,8 @@ import com.intellij.psi.SmartPointerManager;
|
||||
import com.intellij.psi.SmartPsiElementPointer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static com.intellij.openapi.util.Conditions.or;
|
||||
|
||||
public class PsiElementNavigatable implements Navigatable {
|
||||
private final SmartPsiElementPointer<PsiElement> myPointer;
|
||||
|
||||
@@ -40,14 +43,15 @@ public class PsiElementNavigatable implements Navigatable {
|
||||
if (element != null && element.isValid()) {
|
||||
VirtualFile file = element.getContainingFile().getVirtualFile();
|
||||
if (file != null) {
|
||||
new Task.Backgroundable(element.getProject(), EditorBundle.message("editor.open.file.progress", file.getName())) {
|
||||
new Task.Modal(element.getProject(), EditorBundle.message("editor.open.file.progress", file.getName()), true) {
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
if (element.isValid() && !myProject.isDisposed()) {
|
||||
int offset = ReadAction.compute(() -> element.getTextOffset()); // may trigger decompilation
|
||||
indicator.checkCanceled();
|
||||
int offset = ReadAction.compute(() -> element.isValid() ? element.getTextOffset() : -1); // may trigger decompilation
|
||||
indicator.checkCanceled();
|
||||
if (offset >= 0) {
|
||||
OpenFileDescriptor descriptor = new OpenFileDescriptor(myProject, file, offset);
|
||||
ApplicationManager.getApplication().invokeLater(() -> descriptor.navigate(requestFocus), myProject.getDisposed());
|
||||
Condition<?> expired = or(myProject.getDisposed(), o -> !file.isValid());
|
||||
ApplicationManager.getApplication().invokeLater(() -> descriptor.navigate(requestFocus), expired);
|
||||
}
|
||||
}
|
||||
}.queue();
|
||||
|
||||
Reference in New Issue
Block a user