use of com.intellij.debugger.engine.JavaStackFrame in project intellij-community by JetBrains.
the class AlternativeSourceNotificationProvider method createNotificationPanel.
@Nullable
@Override
public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) {
if (!DebuggerSettings.getInstance().SHOW_ALTERNATIVE_SOURCE) {
return null;
}
XDebugSession session = XDebuggerManager.getInstance(myProject).getCurrentSession();
if (session == null) {
FILE_PROCESSED_KEY.set(file, null);
return null;
}
XSourcePosition position = session.getCurrentPosition();
if (position == null || !file.equals(position.getFile())) {
FILE_PROCESSED_KEY.set(file, null);
return null;
}
final PsiFile psiFile = PsiManager.getInstance(myProject).findFile(file);
if (psiFile == null)
return null;
if (!(psiFile instanceof PsiJavaFile))
return null;
PsiClass[] classes = ((PsiJavaFile) psiFile).getClasses();
if (classes.length == 0)
return null;
PsiClass baseClass = classes[0];
String name = baseClass.getQualifiedName();
if (name == null)
return null;
if (DumbService.getInstance(myProject).isDumb())
return null;
ArrayList<PsiClass> alts = ContainerUtil.newArrayList(JavaPsiFacade.getInstance(myProject).findClasses(name, GlobalSearchScope.allScope(myProject)));
ContainerUtil.removeDuplicates(alts);
FILE_PROCESSED_KEY.set(file, true);
if (alts.size() > 1) {
for (PsiClass cls : alts) {
if (cls.equals(baseClass) || cls.getNavigationElement().equals(baseClass)) {
alts.remove(cls);
break;
}
}
alts.add(0, baseClass);
ComboBoxClassElement[] elems = ContainerUtil.map2Array(alts, ComboBoxClassElement.class, psiClass -> new ComboBoxClassElement((PsiClass) psiClass.getNavigationElement()));
String locationDeclName = null;
XStackFrame frame = session.getCurrentStackFrame();
if (frame instanceof JavaStackFrame) {
Location location = ((JavaStackFrame) frame).getDescriptor().getLocation();
if (location != null) {
locationDeclName = location.declaringType().name();
}
}
return new AlternativeSourceNotificationPanel(elems, baseClass, myProject, file, locationDeclName);
}
return null;
}
use of com.intellij.debugger.engine.JavaStackFrame in project intellij-community by JetBrains.
the class PopFrameAction method actionPerformed.
public void actionPerformed(@NotNull AnActionEvent e) {
final Project project = e.getData(CommonDataKeys.PROJECT);
final JavaStackFrame stackFrame = getStackFrame(e);
if (stackFrame == null || stackFrame.getStackFrameProxy().isBottom()) {
return;
}
try {
final DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(e.getDataContext());
final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
if (debugProcess == null) {
return;
}
debugProcess.getSession().setSteppingThrough(stackFrame.getStackFrameProxy().threadProxy());
if (evaluateFinallyBlocks(project, UIUtil.removeMnemonic(ActionsBundle.actionText(DebuggerActions.POP_FRAME)), stackFrame, new XDebuggerEvaluator.XEvaluationCallback() {
@Override
public void evaluated(@NotNull XValue result) {
popFrame(debugProcess, debuggerContext, stackFrame);
}
@Override
public void errorOccurred(@NotNull final String errorMessage) {
ApplicationManager.getApplication().invokeLater(() -> Messages.showMessageDialog(project, DebuggerBundle.message("error.executing.finally", errorMessage), UIUtil.removeMnemonic(ActionsBundle.actionText(DebuggerActions.POP_FRAME)), Messages.getErrorIcon()));
}
}))
return;
popFrame(debugProcess, debuggerContext, stackFrame);
} catch (NativeMethodException e2) {
Messages.showMessageDialog(project, DebuggerBundle.message("error.native.method.exception"), UIUtil.removeMnemonic(ActionsBundle.actionText(DebuggerActions.POP_FRAME)), Messages.getErrorIcon());
} catch (InvalidStackFrameException | VMDisconnectedException ignored) {
}
}
use of com.intellij.debugger.engine.JavaStackFrame in project intellij-community by JetBrains.
the class ForceEarlyReturnAction method update.
public void update(@NotNull AnActionEvent e) {
boolean enable = false;
JavaStackFrame stackFrame = PopFrameAction.getStackFrame(e);
if (stackFrame != null && stackFrame.getDescriptor().getUiIndex() == 0) {
enable = stackFrame.getStackFrameProxy().getVirtualMachine().canForceEarlyReturn();
}
if (ActionPlaces.isMainMenuOrActionSearch(e.getPlace()) || ActionPlaces.DEBUGGER_TOOLBAR.equals(e.getPlace())) {
e.getPresentation().setEnabled(enable);
} else {
e.getPresentation().setVisible(enable);
}
}
use of com.intellij.debugger.engine.JavaStackFrame in project intellij-community by JetBrains.
the class ForceEarlyReturnAction method actionPerformed.
public void actionPerformed(@NotNull AnActionEvent e) {
final Project project = e.getProject();
final JavaStackFrame stackFrame = PopFrameAction.getStackFrame(e);
if (stackFrame == null || project == null) {
return;
}
final DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(e.getDataContext());
final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
if (debugProcess == null) {
return;
}
final StackFrameProxyImpl proxy = stackFrame.getStackFrameProxy();
final ThreadReferenceProxyImpl thread = proxy.threadProxy();
debugProcess.getManagerThread().schedule(new DebuggerContextCommandImpl(debuggerContext, thread) {
@Override
public void threadAction() {
Method method;
try {
method = proxy.location().method();
} catch (EvaluateException e) {
showError(project, DebuggerBundle.message("error.early.return", e.getLocalizedMessage()));
return;
}
if ("void".equals(method.returnTypeName())) {
forceEarlyReturnWithFinally(thread.getVirtualMachine().mirrorOfVoid(), stackFrame, debugProcess, null);
} else {
ApplicationManager.getApplication().invokeLater(() -> new ReturnExpressionDialog(project, debugProcess.getXdebugProcess().getEditorsProvider(), debugProcess, stackFrame).show());
}
}
});
}
Aggregations