mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup - no need for extra debugger context field
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,7 +18,6 @@ package com.intellij.debugger.ui;
|
||||
import com.intellij.codeInsight.hint.HintManager;
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.debugger.DebuggerInvocationUtil;
|
||||
import com.intellij.debugger.DebuggerManagerEx;
|
||||
import com.intellij.debugger.engine.evaluation.EvaluateException;
|
||||
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
|
||||
import com.intellij.debugger.engine.events.DebuggerContextCommandImpl;
|
||||
@@ -27,7 +26,6 @@ import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -38,16 +36,13 @@ public abstract class EditorEvaluationCommand<T> extends DebuggerContextCommandI
|
||||
protected final PsiElement myElement;
|
||||
@Nullable private final Editor myEditor;
|
||||
protected final ProgressIndicator myProgressIndicator;
|
||||
private final DebuggerContextImpl myDebuggerContext;
|
||||
|
||||
public EditorEvaluationCommand(@Nullable Editor editor, PsiElement expression, DebuggerContextImpl context,
|
||||
final ProgressIndicator indicator) {
|
||||
super(context);
|
||||
Project project = expression.getProject();
|
||||
myProgressIndicator = indicator;
|
||||
myEditor = editor;
|
||||
myElement = expression;
|
||||
myDebuggerContext = (DebuggerManagerEx.getInstanceEx(project)).getContext();
|
||||
}
|
||||
|
||||
public Priority getPriority() {
|
||||
@@ -57,19 +52,19 @@ public abstract class EditorEvaluationCommand<T> extends DebuggerContextCommandI
|
||||
protected abstract T evaluate(EvaluationContextImpl evaluationContext) throws EvaluateException;
|
||||
|
||||
public T evaluate() throws EvaluateException {
|
||||
myProgressIndicator.setText(
|
||||
DebuggerBundle.message("progress.evaluating",
|
||||
ReadAction.compute(myElement::getText)));
|
||||
myProgressIndicator.setText(DebuggerBundle.message("progress.evaluating", ReadAction.compute(myElement::getText)));
|
||||
|
||||
try {
|
||||
T result = evaluate(myDebuggerContext.createEvaluationContext());
|
||||
T result = evaluate(getDebuggerContext().createEvaluationContext());
|
||||
|
||||
if (myProgressIndicator.isCanceled()) throw new ProcessCanceledException();
|
||||
|
||||
return result;
|
||||
} catch (final EvaluateException e) {
|
||||
if (myEditor != null) {
|
||||
DebuggerInvocationUtil.invokeLater(myDebuggerContext.getProject(), () -> showEvaluationHint(myEditor, myElement, e), myProgressIndicator.getModalityState());
|
||||
DebuggerInvocationUtil.invokeLater(myElement.getProject(),
|
||||
() -> showEvaluationHint(myEditor, myElement, e),
|
||||
myProgressIndicator.getModalityState());
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user