Java Code Examples for com.intellij.xdebugger.XSourcePosition#getLine()
The following examples show how to use
com.intellij.xdebugger.XSourcePosition#getLine() .
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: MuleConfigUtils.java From mule-intellij-plugins with Apache License 2.0 | 6 votes |
private static XmlTag findXmlTag(XSourcePosition sourcePosition, XmlTag rootTag) { final XmlTag[] subTags = rootTag.getSubTags(); for (int i = 0; i < subTags.length; i++) { XmlTag subTag = subTags[i]; final int subTagLineNumber = getLineNumber(sourcePosition.getFile(), subTag); if (subTagLineNumber == sourcePosition.getLine()) { return subTag; } else if (subTagLineNumber > sourcePosition.getLine() && i > 0 && subTags[i - 1].getSubTags().length > 0) { return findXmlTag(sourcePosition, subTags[i - 1]); } } if (subTags.length > 0) { final XmlTag lastElement = subTags[subTags.length - 1]; return findXmlTag(sourcePosition, lastElement); } else { return null; } }
Example 2
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 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: XDebuggerEditorLinePainter.java From consulo with Apache License 2.0 | 5 votes |
private static int getCurrentBreakPointLineInFile(@Nullable XDebugSession session, VirtualFile file) { try { if (session != null) { final XSourcePosition position = session.getCurrentPosition(); if (position != null && position.getFile().equals(file)) { return position.getLine(); } } } catch (Exception ignore) { } return -1; }
Example 5
Source File: XValueNodeImpl.java From consulo with Apache License 2.0 | 5 votes |
private boolean showAsInlay(VirtualFile file, XSourcePosition position, XSourcePosition debuggerPosition) { if (!Registry.is("debugger.show.values.inplace")) return false; if (!debuggerPosition.getFile().equals(position.getFile()) || debuggerPosition.getLine() != position.getLine()) return false; XValue container = getValueContainer(); if (!(container instanceof XValueWithInlinePresentation)) return false; String presentation = ((XValueWithInlinePresentation)container).computeInlinePresentation(); if (presentation == null) return false; XDebuggerInlayUtil.createInlay(myTree.getProject(), file, position.getOffset(), presentation); return true; }
Example 6
Source File: DartVmServiceListener.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 4 votes |
private static boolean equalSourcePositions(@Nullable final XSourcePosition position1, @Nullable final XSourcePosition position2) { return position1 != null && position2 != null && position1.getFile().equals(position2.getFile()) && position1.getLine() == position2.getLine(); }
Example 7
Source File: DartVmServiceListener.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 4 votes |
private static boolean equalSourcePositions(@Nullable final XSourcePosition position1, @Nullable final XSourcePosition position2) { return position1 != null && position2 != null && position1.getFile().equals(position2.getFile()) && position1.getLine() == position2.getLine(); }
Example 8
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 9
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(); }