Skip to content

Commit

Permalink
enabled quick evaluate and smart step into while debugging decompiled…
Browse files Browse the repository at this point in the history
… code
  • Loading branch information
gorrus committed Feb 4, 2015
1 parent 1285037 commit ff46945
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2015 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.
Expand All @@ -16,6 +16,7 @@
package com.intellij.debugger.actions;

import com.intellij.debugger.SourcePosition;
import com.intellij.debugger.impl.DebuggerUtilsEx;
import com.intellij.lang.java.JavaLanguage;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.fileEditor.FileDocumentManager;
Expand Down Expand Up @@ -67,7 +68,7 @@ public List<SmartStepTarget> findSmartStepTargets(final SourcePosition position)
final int startOffset = doc.getLineStartOffset(line);
final TextRange lineRange = new TextRange(startOffset, doc.getLineEndOffset(line));
final int offset = CharArrayUtil.shiftForward(doc.getCharsSequence(), startOffset, " \t");
PsiElement element = file.findElementAt(offset);
PsiElement element = DebuggerUtilsEx.findElementAt(file, offset);
if (element != null && !(element instanceof PsiCompiledElement)) {
do {
final PsiElement parent = element.getParent();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
Expand All @@ -21,6 +21,7 @@
import com.intellij.debugger.engine.evaluation.TextWithImports;
import com.intellij.debugger.engine.evaluation.TextWithImportsImpl;
import com.intellij.debugger.engine.events.DebuggerContextCommandImpl;
import com.intellij.debugger.impl.DebuggerUtilsEx;
import com.intellij.debugger.impl.EditorTextProvider;
import com.intellij.debugger.ui.impl.watch.NodeManagerImpl;
import com.intellij.debugger.ui.impl.watch.WatchItemDescriptor;
Expand Down Expand Up @@ -103,11 +104,7 @@ public TextRange getExpressionRangeAtOffset(final Project project, final Documen
PsiDocumentManager.getInstance(project).commitAndRunReadAction(new Runnable() {
@Override
public void run() {
PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(document);
if (psiFile == null) {
return;
}
PsiElement elementAtCursor = psiFile.findElementAt(offset);
PsiElement elementAtCursor = DebuggerUtilsEx.findElementAt(PsiDocumentManager.getInstance(project).getPsiFile(document), offset);
if (elementAtCursor == null) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
Expand Down Expand Up @@ -668,4 +668,16 @@ public Navigatable createNavigatable(@NotNull Project project) {
return XSourcePositionImpl.createOpenFileDescriptor(project, this);
}
}

/**
* Decompiler aware version
*/
@Nullable
public static PsiElement findElementAt(@Nullable PsiFile file, int offset) {
if (file instanceof PsiCompiledFile) {
file = ((PsiCompiledFile)file).getDecompiledPsiFile();
}
if (file == null) return null;
return file.findElementAt(offset);
}
}

0 comments on commit ff46945

Please sign in to comment.