Search in sources :

Example 1 with AbstractValueHint

use of com.intellij.xdebugger.impl.evaluate.quick.common.AbstractValueHint in project intellij-community by JetBrains.

the class XQuickEvaluateHandler method createValueHintAsync.

@NotNull
@Override
public Promise<AbstractValueHint> createValueHintAsync(@NotNull final Project project, @NotNull final Editor editor, @NotNull final Point point, final ValueHintType type) {
    final XDebugSession session = XDebuggerManager.getInstance(project).getCurrentSession();
    if (session == null) {
        return Promise.resolve(null);
    }
    final XDebuggerEvaluator evaluator = session.getDebugProcess().getEvaluator();
    if (evaluator == null) {
        return Promise.resolve(null);
    }
    int offset = AbstractValueHint.calculateOffset(editor, point);
    return getExpressionInfo(evaluator, project, type, editor, offset).thenAsync(expressionInfo -> {
        AsyncPromise<AbstractValueHint> resultPromise = new AsyncPromise<>();
        UIUtil.invokeLaterIfNeeded(() -> {
            int textLength = editor.getDocument().getTextLength();
            if (expressionInfo == null) {
                resultPromise.setResult(null);
                return;
            }
            TextRange range = expressionInfo.getTextRange();
            if (range.getStartOffset() > range.getEndOffset() || range.getStartOffset() < 0 || range.getEndOffset() > textLength) {
                LOG.error("invalid range: " + range + ", text length = " + textLength + ", evaluator: " + evaluator);
                resultPromise.setResult(null);
                return;
            }
            resultPromise.setResult(new XValueHint(project, editor, point, type, expressionInfo, evaluator, session));
        });
        return resultPromise;
    });
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession) AbstractValueHint(com.intellij.xdebugger.impl.evaluate.quick.common.AbstractValueHint) XDebuggerEvaluator(com.intellij.xdebugger.evaluation.XDebuggerEvaluator) TextRange(com.intellij.openapi.util.TextRange) AsyncPromise(org.jetbrains.concurrency.AsyncPromise) AbstractValueHint(com.intellij.xdebugger.impl.evaluate.quick.common.AbstractValueHint) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

TextRange (com.intellij.openapi.util.TextRange)1 XDebugSession (com.intellij.xdebugger.XDebugSession)1 XDebuggerEvaluator (com.intellij.xdebugger.evaluation.XDebuggerEvaluator)1 AbstractValueHint (com.intellij.xdebugger.impl.evaluate.quick.common.AbstractValueHint)1 NotNull (org.jetbrains.annotations.NotNull)1 AsyncPromise (org.jetbrains.concurrency.AsyncPromise)1