use of com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl in project intellij-community by JetBrains.
the class JumpToObjectAction method update.
@Override
public void update(final AnActionEvent e) {
if (!isFirstStart(e)) {
return;
}
final DebuggerContextImpl debuggerContext = getDebuggerContext(e.getDataContext());
final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
if (debugProcess == null) {
e.getPresentation().setVisible(false);
return;
}
DebuggerTreeNodeImpl selectedNode = getSelectedNode(e.getDataContext());
if (selectedNode == null) {
e.getPresentation().setVisible(false);
return;
}
final NodeDescriptorImpl descriptor = selectedNode.getDescriptor();
if (descriptor instanceof ValueDescriptor) {
debugProcess.getManagerThread().schedule(new EnableCommand(debuggerContext, (ValueDescriptor) descriptor, debugProcess, e));
} else {
e.getPresentation().setVisible(false);
}
}
use of com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl in project intellij-community by JetBrains.
the class ToggleFieldBreakpointAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
Project project = e.getData(CommonDataKeys.PROJECT);
if (project == null) {
return;
}
final SourcePosition place = getPlace(e);
if (place != null) {
Document document = PsiDocumentManager.getInstance(project).getDocument(place.getFile());
if (document != null) {
DebuggerManagerEx debuggerManager = DebuggerManagerEx.getInstanceEx(project);
BreakpointManager manager = debuggerManager.getBreakpointManager();
final int offset = place.getOffset();
final Breakpoint breakpoint = offset >= 0 ? manager.findBreakpoint(document, offset, FieldBreakpoint.CATEGORY) : null;
if (breakpoint == null) {
FieldBreakpoint fieldBreakpoint = manager.addFieldBreakpoint(document, offset);
if (fieldBreakpoint != null) {
if (DebuggerAction.isContextView(e)) {
final DebuggerTreeNodeImpl selectedNode = DebuggerAction.getSelectedNode(e.getDataContext());
if (selectedNode != null && selectedNode.getDescriptor() instanceof FieldDescriptorImpl) {
ObjectReference object = ((FieldDescriptorImpl) selectedNode.getDescriptor()).getObject();
if (object != null) {
long id = object.uniqueID();
InstanceFilter[] instanceFilters = new InstanceFilter[] { InstanceFilter.create(Long.toString(id)) };
fieldBreakpoint.setInstanceFilters(instanceFilters);
fieldBreakpoint.setInstanceFiltersEnabled(true);
}
}
}
final Editor editor = CommonDataKeys.EDITOR.getData(e.getDataContext());
if (editor != null) {
manager.editBreakpoint(fieldBreakpoint, editor);
}
}
} else {
manager.removeBreakpoint(breakpoint);
}
}
}
}
use of com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl in project intellij-community by JetBrains.
the class ToggleFieldBreakpointAction method getPlace.
@Nullable
public static SourcePosition getPlace(AnActionEvent event) {
final DataContext dataContext = event.getDataContext();
final Project project = event.getData(CommonDataKeys.PROJECT);
if (project == null) {
return null;
}
if (ActionPlaces.PROJECT_VIEW_POPUP.equals(event.getPlace()) || ActionPlaces.STRUCTURE_VIEW_POPUP.equals(event.getPlace()) || ActionPlaces.FAVORITES_VIEW_POPUP.equals(event.getPlace())) {
final PsiElement psiElement = event.getData(CommonDataKeys.PSI_ELEMENT);
if (psiElement instanceof PsiField) {
return SourcePosition.createFromElement(psiElement);
}
return null;
}
final DebuggerTreeNodeImpl selectedNode = DebuggerAction.getSelectedNode(dataContext);
if (selectedNode != null && selectedNode.getDescriptor() instanceof FieldDescriptorImpl) {
final DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(dataContext);
final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
if (debugProcess != null) {
// if there is an active debug session
final Ref<SourcePosition> positionRef = new Ref<>(null);
debugProcess.getManagerThread().invokeAndWait(new DebuggerContextCommandImpl(debuggerContext) {
@Override
public Priority getPriority() {
return Priority.HIGH;
}
@Override
public void threadAction() {
ApplicationManager.getApplication().runReadAction(() -> positionRef.set(SourcePositionProvider.getSourcePosition(selectedNode.getDescriptor(), project, debuggerContext)));
}
});
final SourcePosition sourcePosition = positionRef.get();
if (sourcePosition != null) {
return sourcePosition;
}
}
}
if (DebuggerAction.isContextView(event)) {
DebuggerTree tree = DebuggerTree.DATA_KEY.getData(dataContext);
if (tree != null && tree.getSelectionPath() != null) {
DebuggerTreeNodeImpl node = ((DebuggerTreeNodeImpl) tree.getSelectionPath().getLastPathComponent());
if (node != null && node.getDescriptor() instanceof FieldDescriptorImpl) {
Field field = ((FieldDescriptorImpl) node.getDescriptor()).getField();
DebuggerSession session = tree.getDebuggerContext().getDebuggerSession();
PsiClass psiClass = DebuggerUtils.findClass(field.declaringType().name(), project, (session != null) ? session.getSearchScope() : GlobalSearchScope.allScope(project));
if (psiClass != null) {
psiClass = (PsiClass) psiClass.getNavigationElement();
final PsiField psiField = psiClass.findFieldByName(field.name(), true);
if (psiField != null) {
return SourcePosition.createFromElement(psiField);
}
}
}
}
return null;
}
Editor editor = event.getData(CommonDataKeys.EDITOR);
if (editor == null) {
editor = FileEditorManager.getInstance(project).getSelectedTextEditor();
}
if (editor != null) {
final Document document = editor.getDocument();
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(document);
if (file != null) {
final VirtualFile virtualFile = file.getVirtualFile();
FileType fileType = virtualFile != null ? virtualFile.getFileType() : null;
if (StdFileTypes.JAVA == fileType || StdFileTypes.CLASS == fileType) {
final PsiField field = FieldBreakpoint.findField(project, document, editor.getCaretModel().getOffset());
if (field != null) {
return SourcePosition.createFromElement(field);
}
}
}
}
return null;
}
use of com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl in project intellij-community by JetBrains.
the class DebuggerAction method getSelectedNodes.
@Nullable
public static DebuggerTreeNodeImpl[] getSelectedNodes(DataContext dataContext) {
DebuggerTree tree = getTree(dataContext);
if (tree == null)
return null;
TreePath[] paths = tree.getSelectionPaths();
if (paths == null || paths.length == 0) {
return EMPTY_TREE_NODE_ARRAY;
}
List<DebuggerTreeNodeImpl> nodes = new ArrayList<>(paths.length);
for (TreePath path : paths) {
Object component = path.getLastPathComponent();
if (component instanceof DebuggerTreeNodeImpl) {
nodes.add((DebuggerTreeNodeImpl) component);
}
}
return nodes.toArray(new DebuggerTreeNodeImpl[nodes.size()]);
}
use of com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl in project intellij-community by JetBrains.
the class DebuggerAction method getSelectedNode.
@Nullable
public static DebuggerTreeNodeImpl getSelectedNode(DataContext dataContext) {
DebuggerTree tree = getTree(dataContext);
if (tree == null)
return null;
if (tree.getSelectionCount() != 1) {
return null;
}
TreePath path = tree.getSelectionPath();
if (path == null) {
return null;
}
Object component = path.getLastPathComponent();
if (!(component instanceof DebuggerTreeNodeImpl)) {
return null;
}
return (DebuggerTreeNodeImpl) component;
}
Aggregations