@NotNull public VirtualFile getFile() { return mySourcePosition.getFile(); }
@Nullable private static PsiElement findTargetElement(@NotNull Project project, @NotNull XSourcePosition position, @NotNull Editor editor, @NotNull String name) { PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()); if (file == null || !file.getVirtualFile().equals(position.getFile())) return null; ASTNode leafElement = file.getNode().findLeafElementAt(position.getOffset()); if (leafElement == null) return null; GoTopLevelDeclaration topLevel = PsiTreeUtil.getTopmostParentOfType(leafElement.getPsi(), GoTopLevelDeclaration.class); SyntaxTraverser<PsiElement> traverser = SyntaxTraverser.psiTraverser(topLevel) .filter(e -> e instanceof GoNamedElement && Comparing.equal(name, ((GoNamedElement)e).getName())); Iterator<PsiElement> iterator = traverser.iterator(); return iterator.hasNext() ? iterator.next() : null; }
private XBreakpoint<BallerinaBreakpointProperties> findBreakPoint(@NotNull BreakPoint breakPoint) { String fileName = breakPoint.getFileName(); String packagePath = breakPoint.getPackagePath(); String relativeFilePathInProject; // If the package is ".", full path of the file will be sent as the filename. if (".".equals(packagePath)) { // Then we need to get the actual filename from the path. int index = fileName.lastIndexOf(File.separator); if (index <= -1) { return null; } relativeFilePathInProject = fileName.substring(index); } else { // If the absolute path is not sent, we need to construct the relative file path in the project. relativeFilePathInProject = packagePath.replaceAll("\\.", File.separator) + File.separator + fileName; } int lineNumber = breakPoint.getLineNumber(); for (XBreakpoint<BallerinaBreakpointProperties> breakpoint : breakpoints) { XSourcePosition breakpointPosition = breakpoint.getSourcePosition(); if (breakpointPosition == null) { continue; } VirtualFile fileInBreakpoint = breakpointPosition.getFile(); int line = breakpointPosition.getLine() + 1; if (fileInBreakpoint.getPath().endsWith(relativeFilePathInProject) && line == lineNumber) { return breakpoint; } } return null; }
return; VirtualFile file = breakpointPosition.getFile(); int line = breakpointPosition.getLine(); Project project = getSession().getProject();
@Override public void registerBreakpoint(@NotNull XLineBreakpoint<DlvBreakpointProperties> breakpoint) { XSourcePosition breakpointPosition = breakpoint.getSourcePosition(); if (breakpointPosition == null) return; VirtualFile file = breakpointPosition.getFile(); int line = breakpointPosition.getLine(); send(new DlvRequest.CreateBreakpoint(file.getPath(), line + 1)) .done(b -> { breakpoint.putUserData(ID, b.id); breakpoints.put(b.id, breakpoint); getSession().updateBreakpointPresentation(breakpoint, AllIcons.Debugger.Db_verified_breakpoint, null); }) .rejected(t -> { String message = t == null ? null : t.getMessage(); getSession().updateBreakpointPresentation(breakpoint, AllIcons.Debugger.Db_invalid_breakpoint, message); }); }
@Override public void runToPosition(@NotNull XSourcePosition position, XSuspendContext context) { m_gdb.sendCommand(String.format("%s %s:%s", "-exec-until", position.getFile().getPath(), (position.getLine() + 1))); }
@Nullable private static Language getFileTypeLanguage( XLineBreakpoint<CloudLineBreakpointProperties> breakpoint) { if (breakpoint.getSourcePosition() != null) { FileType fileType = breakpoint.getSourcePosition().getFile().getFileType(); if (fileType instanceof LanguageFileType) { return ((LanguageFileType) fileType).getLanguage(); } } return null; }
component.append(function + "():" + (sourcePosition.getLine() + 1), SimpleTextAttributes.REGULAR_ATTRIBUTES); component.append(" (" + sourcePosition.getFile().getName() + ")", SimpleTextAttributes.GRAY_ITALIC_ATTRIBUTES); } else { sourcePosition.getFile().getName() + ":" + (sourcePosition.getLine() + 1), SimpleTextAttributes.REGULAR_ATTRIBUTES); } else {
@Nullable public static PerlLineBreakPointDescriptor createFromSourcePosition(XSourcePosition position, PerlDebugThread debugThread) { VirtualFile virtualFile = position.getFile(); String virtualFilePath = virtualFile.getCanonicalPath(); if (virtualFilePath == null) { return null; } String filePath = debugThread.getDebugProfileState().mapPathToRemote(virtualFilePath); if (filePath == null) { return null; } PerlLineBreakPointDescriptor descriptor = new PerlLineBreakPointDescriptor(); descriptor.path = filePath; descriptor.line = position.getLine(); return descriptor; } }
String filePath = sourcePosition.getFile().getPath(); if (m_isWsl) { filePath = SdkUtil.translateWslWindowsToPosixPath(filePath);
XSourcePosition sourcePosition = mock(XSourcePosition.class); when(sourcePosition.getLine()).thenReturn(sourceLine); when(sourcePosition.getFile()).thenReturn(mockFile); when(mockFile.isValid()).thenReturn(Boolean.TRUE);
final VirtualFile virtualFile = sourcePosition.getFile(); PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
PsiFile psiFile = psiManager.findFile(ideBreakpoint.getSourcePosition().getFile());