Java Code Examples for com.intellij.xdebugger.XSourcePosition#getFile()
The following examples show how to use
com.intellij.xdebugger.XSourcePosition#getFile() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XToggleLineBreakpointActionHandler.java From consulo with Apache License 2.0 | 6 votes |
@Override public boolean isEnabled(@Nonnull final Project project, final AnActionEvent event) { XLineBreakpointType<?>[] breakpointTypes = XDebuggerUtil.getInstance().getLineBreakpointTypes(); final XBreakpointManager breakpointManager = XDebuggerManager.getInstance(project).getBreakpointManager(); for (XSourcePosition position : XDebuggerUtilImpl.getAllCaretsPositions(project, event.getDataContext())) { for (XLineBreakpointType<?> breakpointType : breakpointTypes) { final VirtualFile file = position.getFile(); final int line = position.getLine(); if (XLineBreakpointResolverTypeExtension.INSTANCE.resolveBreakpointType(project, file, line) != null || breakpointManager.findBreakpointAtLine(breakpointType, file, line) != null) { return true; } } } return false; }
Example 2
Source File: XBreakpointFileGroupingRule.java From consulo with Apache License 2.0 | 6 votes |
public XBreakpointFileGroup getGroup(@Nonnull final B breakpoint, @Nonnull final Collection<XBreakpointFileGroup> groups) { if (!(breakpoint instanceof XLineBreakpoint)) { return null; } XSourcePosition position = ((XLineBreakpoint)breakpoint).getSourcePosition(); if (position == null) return null; VirtualFile file = position.getFile(); for (XBreakpointFileGroup group : groups) { if (group.getFile().equals(file)) { return group; } } return new XBreakpointFileGroup(file); }
Example 3
Source File: MuleConfigUtils.java From mule-intellij-plugins with Apache License 2.0 | 5 votes |
@NotNull public static Breakpoint toMuleBreakpoint(Project project, @NotNull XSourcePosition sourcePosition, XExpression conditionExpression, @Nullable Map<String, String> modulesToAppsMap) { VirtualFile file = sourcePosition.getFile(); Module module = ModuleUtilCore.findModuleForFile(file, project); String deployableName = module.getName(); if (modulesToAppsMap != null && !StringUtils.isEmpty(modulesToAppsMap.get(deployableName))) deployableName = modulesToAppsMap.get(deployableName); final String conditionScript = conditionExpression != null ? asMelScript(conditionExpression.getExpression()) : null; final XmlTag tag = getXmlTagAt(module.getProject(), sourcePosition); if (tag != null) { //TODO - Module name is an app name - but can I get it from Maven? Or override it by using the additional param? return new Breakpoint(getMulePath(tag), conditionScript, deployableName); } else { final int line = sourcePosition.getLine(); final Document document = FileDocumentManager.getInstance().getDocument(sourcePosition.getFile()); final PsiElement xmlElement = WeavePsiUtils.getFirstWeaveElement(module.getProject(), document, line); if (xmlElement != null) { PsiLanguageInjectionHost parent = PsiTreeUtil.getParentOfType(xmlElement, PsiLanguageInjectionHost.class); if (parent != null) { final XmlTag weavePart = PsiTreeUtil.getParentOfType(xmlElement, XmlTag.class); final XmlTag weaveTag = PsiTreeUtil.getParentOfType(weavePart, XmlTag.class); int lineNumber = line + 1 - XSourcePositionImpl.createByElement(xmlElement).getLine(); final String mulePath = getMulePath(weaveTag); //TODO - Module name is an app name - but can I get it from Maven? Or override it by using the additional param? return new Breakpoint(mulePath, getPrefix(weavePart) + "/" + (lineNumber + 1), conditionScript, deployableName); } } } return new Breakpoint("", conditionScript, deployableName); }
Example 4
Source File: MuleConfigUtils.java From mule-intellij-plugins with Apache License 2.0 | 5 votes |
@Nullable public static XmlTag getXmlTagAt(Project project, XSourcePosition sourcePosition) { final VirtualFile file = sourcePosition.getFile(); final XmlFile xmlFile = (XmlFile) PsiManager.getInstance(project).findFile(file); final XmlTag rootTag = xmlFile.getRootTag(); return findXmlTag(sourcePosition, rootTag); }
Example 5
Source File: XValueNodeImpl.java From consulo with Apache License 2.0 | 5 votes |
public void updateInlineDebuggerData() { try { XDebugSession session = XDebugView.getSession(getTree()); final XSourcePosition debuggerPosition = session == null ? null : session.getCurrentPosition(); if (debuggerPosition == null) { return; } final XInlineDebuggerDataCallback callback = new XInlineDebuggerDataCallback() { @Override public void computed(XSourcePosition position) { if (isObsolete() || position == null) return; VirtualFile file = position.getFile(); // filter out values from other files if (!Comparing.equal(debuggerPosition.getFile(), file)) { return; } final Document document = FileDocumentManager.getInstance().getDocument(file); if (document == null) return; XVariablesView.InlineVariablesInfo data = myTree.getProject().getUserData(XVariablesView.DEBUG_VARIABLES); if (data == null) { return; } if (!showAsInlay(file, position, debuggerPosition)) { data.put(file, position, XValueNodeImpl.this, document.getModificationStamp()); myTree.updateEditor(); } } }; if (getValueContainer().computeInlineDebuggerData(callback) == ThreeState.UNSURE) { getValueContainer().computeSourcePosition(callback::computed); } } catch (Exception ignore) { } }
Example 6
Source File: XDebugView.java From consulo with Apache License 2.0 | 5 votes |
@Nullable protected VirtualFile getCurrentFile(@Nonnull Component component) { XDebugSession session = getSession(component); if (session != null) { XSourcePosition position = session.getCurrentPosition(); if (position != null) { return position.getFile(); } } return null; }
Example 7
Source File: XVariablesViewBase.java From consulo with Apache License 2.0 | 5 votes |
private void registerInlineEvaluator(final XStackFrame stackFrame, final XSourcePosition position, final Project project) { final VirtualFile file = position.getFile(); final FileEditor fileEditor = FileEditorManagerEx.getInstanceEx(project).getSelectedEditor(file); if (fileEditor instanceof TextEditor) { final Editor editor = ((TextEditor)fileEditor).getEditor(); removeSelectionListener(); mySelectionListener = new MySelectionListener(editor, stackFrame, project); editor.getSelectionModel().addSelectionListener(mySelectionListener); } }
Example 8
Source File: XQueryBreakpointHandler.java From intellij-xquery with Apache License 2.0 | 4 votes |
public static String getFileUrl(XSourcePosition sourcePosition) { final VirtualFile file = sourcePosition.getFile(); return getFileURL(file); }
Example 9
Source File: XSourcePositionImpl.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull public static OpenFileDescriptor doCreateOpenFileDescriptor(@Nonnull Project project, @Nonnull XSourcePosition position) { return position.getOffset() != -1 ? new OpenFileDescriptor(project, position.getFile(), position.getOffset()) : new OpenFileDescriptor(project, position.getFile(), position.getLine(), 0); }
Example 10
Source File: XBreakpointUtil.java From consulo with Apache License 2.0 | 4 votes |
/** * Toggle line breakpoint with editor support: * - unfolds folded block on the line * - if folded, checks if line breakpoints could be toggled inside folded text */ @Nonnull public static AsyncResult<XLineBreakpoint> toggleLineBreakpoint(@Nonnull Project project, @Nonnull XSourcePosition position, @Nullable Editor editor, boolean temporary, boolean moveCaret) { int lineStart = position.getLine(); VirtualFile file = position.getFile(); // for folded text check each line and find out type with the biggest priority int linesEnd = lineStart; if (editor != null) { FoldRegion region = FoldingUtil.findFoldRegionStartingAtLine(editor, lineStart); if (region != null && !region.isExpanded()) { linesEnd = region.getDocument().getLineNumber(region.getEndOffset()); } } final XBreakpointManager breakpointManager = XDebuggerManager.getInstance(project).getBreakpointManager(); XLineBreakpointType<?>[] lineTypes = XDebuggerUtil.getInstance().getLineBreakpointTypes(); XLineBreakpointType<?> typeWinner = null; int lineWinner = -1; for (int line = lineStart; line <= linesEnd; line++) { for (XLineBreakpointType<?> type : lineTypes) { final XLineBreakpoint<? extends XBreakpointProperties> breakpoint = breakpointManager.findBreakpointAtLine(type, file, line); if (breakpoint != null && temporary && !breakpoint.isTemporary()) { breakpoint.setTemporary(true); } else if(breakpoint != null) { typeWinner = type; lineWinner = line; break; } } XLineBreakpointType<?> breakpointType = XLineBreakpointResolverTypeExtension.INSTANCE.resolveBreakpointType(project, file, line); if(breakpointType != null) { typeWinner = breakpointType; lineWinner = line; } // already found max priority type - stop if (typeWinner != null) { break; } } if (typeWinner != null) { XSourcePosition winPosition = (lineStart == lineWinner) ? position : XSourcePositionImpl.create(file, lineWinner); if (winPosition != null) { AsyncResult<XLineBreakpoint> res = XDebuggerUtilImpl.toggleAndReturnLineBreakpoint(project, typeWinner, winPosition, temporary, editor); if (editor != null && lineStart != lineWinner) { int offset = editor.getDocument().getLineStartOffset(lineWinner); ExpandRegionAction.expandRegionAtOffset(project, editor, offset); if (moveCaret) { editor.getCaretModel().moveToOffset(offset); } } return res; } } return AsyncResult.rejected(); }
Example 11
Source File: XDebuggerFramesList.java From consulo with Apache License 2.0 | 4 votes |
@Nullable private static VirtualFile getFile(XStackFrame frame) { XSourcePosition position = frame.getSourcePosition(); return position != null ? position.getFile() : null; }