@Nullable @Override public XSourcePosition getSourcePosition() { VirtualFile file = findFile(); return file == null ? null : XDebuggerUtil.getInstance().createPosition(file, myLocation.line - 1); }
/** * Returns the source position. This is used to show the debug hit in the file. */ @Nullable @Override public XSourcePosition getSourcePosition() { VirtualFile file = findFile(); return file == null ? null : XDebuggerUtil.getInstance().createPosition(file, myFrame.getLineID() - 1); }
@Nullable public static SourcePosition create(@NotNull String filePath, int line) { VirtualFile file = LocalFileSystem.getInstance().findFileByPath(filePath); XSourcePosition sourcePosition = XDebuggerUtil.getInstance().createPosition(file, line); if (sourcePosition != null) { return new SourcePosition(sourcePosition); } else { return null; } }
private static boolean isLineBreakpointAvailable(@NotNull VirtualFile file, int line, @NotNull Project project) { Document document = FileDocumentManager.getInstance().getDocument(file); if (document == null || document.getLineEndOffset(line) == document.getLineStartOffset(line)) return false; Checker canPutAtChecker = new Checker(); XDebuggerUtil.getInstance().iterateLine(project, document, line, canPutAtChecker); return canPutAtChecker.isLineBreakpointAvailable(); }
@Nullable private XSourcePosition findPosition() { XDebugSession debugSession = getSession(); if (debugSession == null) return null; XStackFrame stackFrame = debugSession.getCurrentStackFrame(); if (stackFrame == null) return null; Project project = debugSession.getProject(); XSourcePosition position = debugSession.getCurrentPosition(); Editor editor = ((FileEditorManagerImpl)FileEditorManager.getInstance(project)).getSelectedTextEditor(true); if (editor == null || position == null) return null; String name = myName.startsWith("&") ? myName.replaceFirst("\\&", "") : myName; PsiElement resolved = findTargetElement(project, position, editor, name); if (resolved == null) return null; VirtualFile virtualFile = resolved.getContainingFile().getVirtualFile(); return XDebuggerUtil.getInstance().createPositionByOffset(virtualFile, resolved.getTextOffset()); } });
private static boolean isLineBreakpointAvailable(@NotNull VirtualFile file, int line, @NotNull Project project) { Document document = FileDocumentManager.getInstance().getDocument(file); if (document == null || document.getLineEndOffset(line) == document.getLineStartOffset(line)) { return false; } Checker canPutAtChecker = new Checker(); XDebuggerUtil.getInstance().iterateLine(project, document, line, canPutAtChecker); // Used to identify line comments, which cannot be correctly processed by the checker. if (document.getText(new TextRange(document.getLineStartOffset(line), document.getLineEndOffset(line))).trim() .startsWith(BALLERINA_LINE_COMMENT_PREFIX)) { return false; } return canPutAtChecker.isLineBreakpointAvailable(); }
@Nullable private XSourcePosition findPosition() { XDebugSession debugSession = myProcess.getSession(); if (debugSession == null) { return null; } XStackFrame stackFrame = debugSession.getCurrentStackFrame(); if (stackFrame == null) { return null; } Project project = debugSession.getProject(); XSourcePosition position = debugSession.getCurrentPosition(); Editor editor = ((FileEditorManagerImpl) FileEditorManager.getInstance(project)) .getSelectedTextEditor(true); if (editor == null || position == null) { return null; } String name = myName.startsWith("&") ? myName.replaceFirst("\\&", "") : myName; PsiElement resolved = findTargetElement(project, position, editor, name); if (resolved == null) { return null; } VirtualFile virtualFile = resolved.getContainingFile().getVirtualFile(); return XDebuggerUtil.getInstance().createPositionByOffset(virtualFile, resolved.getTextOffset()); } });
@Override public void computeTypeSourcePosition(@NotNull XNavigatable navigatable) { readActionInPooledThread(() -> { boolean isStructure = myVariable.isStructure(); boolean isPtr = myVariable.isPtr(); if (!isStructure && !isPtr) return; Project project = getProject(); if (project == null) return; String dlvType = myVariable.type; String fqn = dlvType.replaceFirst(isPtr ? "\\*struct " : "struct ", ""); List<String> split = StringUtil.split(fqn, "."); boolean noFqn = split.size() == 1; if (split.size() == 2 || noFqn) { String name = ContainerUtil.getLastItem(split); assert name != null; Collection<GoTypeSpec> types = GoTypesIndex.find(name, project, GlobalSearchScope.allScope(project), null); for (GoTypeSpec type : types) { if (noFqn || Comparing.equal(fqn, type.getQualifiedName())) { navigatable.setSourcePosition(XDebuggerUtil.getInstance().createPositionByOffset( type.getContainingFile().getVirtualFile(), type.getTextOffset())); return; } } } }); } }
@Override public List<XBreakpointGroupingRule<XLineBreakpoint<CloudLineBreakpointProperties>, ?>> getGroupingRules() { return XDebuggerUtil.getInstance().getGroupingByFileRuleAsList(); }
/** Initialize the frame. */ public CloudStackFrame( @NotNull Project project, @NotNull StackFrame frame, @NotNull List<Variable> variableTable, @Nullable List<Variable> evaluatedExpressions, @NotNull ServerToIdeFileResolver fileResolver) { this.frame = frame; this.variableTable = variableTable; this.evaluatedExpressions = evaluatedExpressions; String path = frame.getLocation().getPath(); if (!Strings.isNullOrEmpty(path)) { sourcePosition = XDebuggerUtil.getInstance() .createPosition( fileResolver.getFileFromPath(project, path), frame.getLocation().getLine() - 1); } else { sourcePosition = null; } }
/** * Gets the source position of the stack frame, if available. * * @return The source position, or null if it is not available. */ @Nullable @Override public XSourcePosition getSourcePosition() { if (m_frame.fileAbsolute == null || m_frame.line == null) { return null; } String path = m_frame.fileAbsolute.replace(File.separatorChar, '/'); if (SdkUtil.isWslPath(path)) { path = SdkUtil.translateWslPosixToWindowsPath(path); } VirtualFile file = LocalFileSystem.getInstance().findFileByPath(path); if (file == null) { return null; } return XDebuggerUtil.getInstance().createPosition(file, m_frame.line - 1); }
final Ref<Class<? extends CloudLineBreakpointType>> result = Ref.create(); assert document != null; XDebuggerUtil.getInstance() .iterateLine( project,
@SuppressWarnings("ConstantConditions") @Override public void actionPerformed(AnActionEvent event) { DataContext dataContext = event.getDataContext(); Editor editor = EDITOR.getData(dataContext); if (editor instanceof EditorEx && event.getInputEvent() instanceof MouseEvent && editor.getUserData(POPUP_LINE) != null) { EditorEx exEditor = (EditorEx) editor; if (exEditor.getProject() == null) { LOG.error("could not add a snapshot location as the target editor was unexpectedly null."); return; } if (editor.getUserData(POPUP_LINE) == null) { LOG.error("could not add a snapshot location as the target line was unexpectedly null."); return; } XDebuggerUtil.getInstance() .toggleLineBreakpoint( exEditor.getProject(), CloudLineBreakpointType.getInstance(), exEditor.getVirtualFile(), editor.getUserData(POPUP_LINE)); } }