use of com.intellij.xdebugger.frame.XStackFrame 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.xdebugger.frame.XStackFrame in project intellij-community by JetBrains.
the class JavaExecutionStack method createStackFrame.
private static XStackFrame createStackFrame(@NotNull StackFrameProxyImpl stackFrameProxy, @NotNull MethodsTracker tracker) {
StackFrameDescriptorImpl descriptor = new StackFrameDescriptorImpl(stackFrameProxy, tracker);
DebugProcessImpl debugProcess = (DebugProcessImpl) descriptor.getDebugProcess();
Location location = descriptor.getLocation();
if (location != null) {
XStackFrame customFrame = debugProcess.getPositionManager().createStackFrame(stackFrameProxy, debugProcess, location);
if (customFrame != null) {
return customFrame;
}
}
return new JavaStackFrame(descriptor, true);
}
use of com.intellij.xdebugger.frame.XStackFrame in project intellij-community by JetBrains.
the class XFramesView method processSessionEvent.
@Override
public void processSessionEvent(@NotNull SessionEvent event, @NotNull XDebugSession session) {
myRefresh = event == SessionEvent.SETTINGS_CHANGED;
if (event == SessionEvent.BEFORE_RESUME) {
return;
}
XStackFrame currentStackFrame = session.getCurrentStackFrame();
XSuspendContext suspendContext = session.getSuspendContext();
if (event == SessionEvent.FRAME_CHANGED) {
ApplicationManager.getApplication().assertIsDispatchThread();
if (currentStackFrame != null) {
myFramesList.setSelectedValue(currentStackFrame, true);
mySelectedFrameIndex = myFramesList.getSelectedIndex();
myExecutionStacksWithSelection.put(mySelectedStack, mySelectedFrameIndex);
}
return;
}
myLaterInvocator.offer(() -> {
if (event != SessionEvent.SETTINGS_CHANGED) {
mySelectedFrameIndex = 0;
mySelectedStack = null;
myVisibleRect = null;
} else {
myVisibleRect = myFramesList.getVisibleRect();
}
myListenersEnabled = false;
myBuilders.values().forEach(StackFramesListBuilder::dispose);
myBuilders.clear();
if (suspendContext == null) {
requestClear();
return;
}
if (event == SessionEvent.PAUSED) {
// clear immediately
cancelClear();
clear();
}
XExecutionStack[] executionStacks = suspendContext.getExecutionStacks();
addExecutionStacks(Arrays.asList(executionStacks));
XExecutionStack activeExecutionStack = mySelectedStack != null ? mySelectedStack : suspendContext.getActiveExecutionStack();
myThreadComboBox.setSelectedItem(activeExecutionStack);
myThreadsPanel.removeAll();
myThreadsPanel.add(myToolbar.getComponent(), BorderLayout.EAST);
final boolean invisible = executionStacks.length == 1 && StringUtil.isEmpty(executionStacks[0].getDisplayName());
if (!invisible) {
myThreadsPanel.add(myThreadComboBox, BorderLayout.CENTER);
}
myToolbar.setAddSeparatorFirst(!invisible);
updateFrames(activeExecutionStack, session);
});
}
use of com.intellij.xdebugger.frame.XStackFrame in project intellij-plugins by JetBrains.
the class DartPopFrameAction method getStackFrame.
@Nullable
private static DartVmServiceStackFrame getStackFrame(@NotNull final AnActionEvent e) {
final Project project = e.getProject();
if (project == null)
return null;
XDebugSession session = e.getData(XDebugSession.DATA_KEY);
if (session == null) {
session = XDebuggerManager.getInstance(project).getCurrentSession();
}
if (session != null) {
XStackFrame frame = session.getCurrentStackFrame();
if (frame instanceof DartVmServiceStackFrame) {
return ((DartVmServiceStackFrame) frame);
}
}
return null;
}
use of com.intellij.xdebugger.frame.XStackFrame in project intellij-plugins by JetBrains.
the class VmServiceWrapper method computeStackFrames.
public void computeStackFrames(@NotNull final String isolateId, final int firstFrameIndex, @NotNull final XExecutionStack.XStackFrameContainer container, @Nullable final InstanceRef exception) {
addRequest(() -> myVmService.getStack(isolateId, new StackConsumer() {
@Override
public void received(final Stack vmStack) {
ApplicationManager.getApplication().executeOnPooledThread(() -> {
InstanceRef exceptionToAddToFrame = exception;
// Check to see if the VM passing in awaiter frames; if so, use them. Else check
// for async causal frames. Finally, fall back to using regular sync frames.
ElementList<Frame> elementList = vmStack.getAwaiterFrames();
if (elementList == null) {
elementList = vmStack.getAsyncCausalFrames();
if (elementList == null) {
elementList = vmStack.getFrames();
}
}
final List<Frame> vmFrames = Lists.newArrayList(elementList);
final List<XStackFrame> xStackFrames = new ArrayList<>(vmFrames.size());
for (final Frame vmFrame : vmFrames) {
if (vmFrame.getKind() == FrameKind.AsyncSuspensionMarker) {
// Render an asynchronous gap.
final XStackFrame markerFrame = new DartAsyncMarkerFrame();
xStackFrames.add(markerFrame);
} else {
final DartVmServiceStackFrame stackFrame = new DartVmServiceStackFrame(myDebugProcess, isolateId, vmFrame, vmFrames, exceptionToAddToFrame);
stackFrame.setIsDroppableFrame(vmFrame.getKind() == FrameKind.Regular);
xStackFrames.add(stackFrame);
if (!stackFrame.isInDartSdkPatchFile()) {
// The exception (if any) is added to the frame where debugger stops and to the upper frames.
exceptionToAddToFrame = null;
}
}
}
container.addStackFrames(firstFrameIndex == 0 ? xStackFrames : xStackFrames.subList(firstFrameIndex, xStackFrames.size()), true);
});
}
@Override
public void onError(final RPCError error) {
container.errorOccurred(error.getMessage());
}
}));
}
Aggregations