public LambdaMethodFilter(PsiLambdaExpression lambda, int expressionOrdinal, Range<Integer> callingExpressionLines) { myLambdaOrdinal = expressionOrdinal; myCallingExpressionLines = callingExpressionLines; SourcePosition firstStatementPosition = null; SourcePosition lastStatementPosition = null; final PsiElement body = lambda.getBody(); if (body instanceof PsiCodeBlock) { final PsiStatement[] statements = ((PsiCodeBlock)body).getStatements(); if (statements.length > 0) { firstStatementPosition = SourcePosition.createFromElement(statements[0]); if (firstStatementPosition != null) { final PsiStatement lastStatement = statements[statements.length - 1]; lastStatementPosition = SourcePosition.createFromOffset(firstStatementPosition.getFile(), lastStatement.getTextRange().getEndOffset()); } } } else if (body != null) { firstStatementPosition = SourcePosition.createFromElement(body); } myFirstStatementPosition = firstStatementPosition; myLastStatementLine = lastStatementPosition != null ? lastStatementPosition.getLine() : -1; }
public AnonymousClassMethodFilter(PsiMethod psiMethod, Range<Integer> lines) { super(psiMethod, lines); SourcePosition firstStatementPosition = null; SourcePosition lastStatementPosition = null; final PsiCodeBlock body = psiMethod.getBody(); if (body != null) { final PsiStatement[] statements = body.getStatements(); if (statements.length > 0) { firstStatementPosition = SourcePosition.createFromElement(statements[0]); if (firstStatementPosition != null) { final PsiStatement lastStatement = statements[statements.length - 1]; lastStatementPosition = SourcePosition.createFromOffset(firstStatementPosition.getFile(), lastStatement.getTextRange().getEndOffset()); } } } myBreakpointPosition = firstStatementPosition; myLastStatementLine = lastStatementPosition != null? lastStatementPosition.getLine() : -1; }
@NotNull private static Set<XLineBreakpoint> findLineBreakpoints(AnActionEvent e) { Project project = e.getProject(); Editor editor = e.getData(CommonDataKeys.EDITOR); if (project == null || editor == null) return Collections.emptySet(); XBreakpointManagerImpl breakpointManager = (XBreakpointManagerImpl)XDebuggerManager.getInstance(project).getBreakpointManager(); XLineBreakpointManager lineBreakpointManager = breakpointManager.getLineBreakpointManager(); Document document = editor.getDocument(); Collection<Range<Integer>> lineRanges = new ArrayList<Range<Integer>>(); for (Caret caret : editor.getCaretModel().getAllCarets()) { lineRanges.add(new Range<Integer>(document.getLineNumber(caret.getSelectionStart()), document.getLineNumber(caret.getSelectionEnd()))); } Collection<XLineBreakpointImpl> breakpoints = lineBreakpointManager.getDocumentBreakpoints(document); HashSet<XLineBreakpoint> res = new HashSet<XLineBreakpoint>(); for (XLineBreakpointImpl breakpoint : breakpoints) { int line = breakpoint.getLine(); for (Range<Integer> range : lineRanges) { if (range.isWithin(line)) { res.add(breakpoint); } } } return res; }
public boolean isOkToHavePointer(Point targetPoint, Rectangle bounds, int pointerLength, int pointerWidth, int arc) { if (bounds.x < targetPoint.x && bounds.x + bounds.width > targetPoint.x && bounds.y < targetPoint.y && bounds.y + bounds.height < targetPoint.y) return false; Rectangle pointless = getPointlessContentRec(bounds, pointerLength); int size = getDistanceToTarget(pointless, targetPoint); if (size < pointerLength) return false; Range<Integer> balloonRange; Range<Integer> pointerRange; if (isTopBottomPointer()) { balloonRange = new Range<Integer>(bounds.x + arc, bounds.x + bounds.width - arc * 2); pointerRange = new Range<Integer>(targetPoint.x - pointerWidth / 2, targetPoint.x + pointerWidth / 2); } else { balloonRange = new Range<Integer>(bounds.y + arc, bounds.y + bounds.height - arc * 2); pointerRange = new Range<Integer>(targetPoint.y - pointerWidth / 2, targetPoint.y + pointerWidth / 2); } return balloonRange.isWithin(pointerRange.getFrom()) && balloonRange.isWithin(pointerRange.getTo()); }
@Nullable @RequiredWriteAction private Range<Integer> findRangeOfElementsToMove(@Nonnull PsiElement[] elements, int startOffset, int endOffset) { int startIndex = elements.length; int endIndex = -1; if (startOffset == endOffset) { for (int i = 0; i < elements.length; i++) { if (elements[i].getTextRange().containsOffset(startOffset)) { startIndex = endIndex = i; break; } } } else { for (int i = 0; i < elements.length; i++) { PsiElement psiElement = elements[i]; TextRange range = psiElement.getTextRange(); if (i < startIndex && startOffset < range.getEndOffset()) startIndex = i; if (endOffset > range.getStartOffset()) endIndex = i; else break; } } return startIndex > endIndex || (myIsLeft ? startIndex == 0 : endIndex == elements.length - 1) ? null : new Range<Integer>(startIndex, endIndex); }
public AnonymousClassMethodFilter(PsiMethod psiMethod, Range<Integer> lines) { super(psiMethod, lines); SourcePosition firstStatementPosition = null; SourcePosition lastStatementPosition = null; final PsiCodeBlock body = psiMethod.getBody(); if(body != null) { final PsiStatement[] statements = body.getStatements(); if(statements.length > 0) { firstStatementPosition = SourcePosition.createFromElement(statements[0]); if(firstStatementPosition != null) { final PsiStatement lastStatement = statements[statements.length - 1]; lastStatementPosition = SourcePosition.createFromOffset(firstStatementPosition.getFile(), lastStatement.getTextRange().getEndOffset()); } } } myBreakpointPosition = firstStatementPosition; myLastStatementLine = lastStatementPosition != null ? lastStatementPosition.getLine() : -1; }
@Override protected void perform() { final Pair<PsiElement, PsiElement> table = getSelectedTable(editor); if (table != null && table.first != null && table.second != null) { final int startOffset = table.first.getTextRange().getStartOffset(); final int endOffset = table.second.getTextRange().getEndOffset(); editor.setSelection(new Range<>(startOffset, endOffset)); } }
protected BasicStepMethodFilter(@NotNull JVMName declaringClassName, @NotNull String targetMethodName, JVMName targetMethodSignature, Range<Integer> callingExpressionLines) { myDeclaringClassName = declaringClassName; myTargetMethodName = targetMethodName; myTargetMethodSignature = targetMethodSignature; myCallingExpressionLines = callingExpressionLines; }
private boolean isOnTheSameLine(SourcePosition locationPosition) { if (myMethodFilter == null) { return myPosition.getLine() == locationPosition.getLine(); } else { Range<Integer> exprLines = myMethodFilter.getCallingExpressionLines(); return exprLines != null && exprLines.isWithin(locationPosition.getLine()); } }
@Nullable public static Range<Integer> getExpandControlRange(@NotNull final JTree aTree, @Nullable final TreePath path) { TreeModel treeModel = aTree.getModel(); final BasicTreeUI basicTreeUI = (BasicTreeUI)aTree.getUI(); Icon expandedIcon = basicTreeUI.getExpandedIcon(); Range<Integer> box = null; if (path != null && !treeModel.isLeaf(path.getLastPathComponent())) { int boxWidth; Insets i = aTree.getInsets(); if (expandedIcon != null) { boxWidth = expandedIcon.getIconWidth(); } else { boxWidth = 8; } int boxLeftX = i != null ? i.left : 0; boolean leftToRight = aTree.getComponentOrientation().isLeftToRight(); int depthOffset = getDepthOffset(aTree); int totalChildIndent = basicTreeUI.getLeftChildIndent() + basicTreeUI.getRightChildIndent(); if (leftToRight) { boxLeftX += (path.getPathCount() + depthOffset - 2) * totalChildIndent + basicTreeUI.getLeftChildIndent() - boxWidth / 2; } int boxRightX = boxLeftX + boxWidth; box = new Range<Integer>(boxLeftX, boxRightX); } return box; }
@Nullable public static Range<Integer> getExpandControlRange(@Nonnull final JTree aTree, @Nullable final TreePath path) { TreeModel treeModel = aTree.getModel(); final BasicTreeUI basicTreeUI = (BasicTreeUI)aTree.getUI(); Icon expandedIcon = basicTreeUI.getExpandedIcon(); Range<Integer> box = null; if (path != null && !treeModel.isLeaf(path.getLastPathComponent())) { int boxWidth; Insets i = aTree.getInsets(); if (expandedIcon != null) { boxWidth = expandedIcon.getIconWidth(); } else { boxWidth = 8; } int boxLeftX = i != null ? i.left : 0; boolean leftToRight = aTree.getComponentOrientation().isLeftToRight(); int depthOffset = getDepthOffset(aTree); int totalChildIndent = basicTreeUI.getLeftChildIndent() + basicTreeUI.getRightChildIndent(); if (leftToRight) { boxLeftX += (path.getPathCount() + depthOffset - 2) * totalChildIndent + basicTreeUI.getLeftChildIndent() - boxWidth / 2; } int boxRightX = boxLeftX + boxWidth; box = new Range<>(boxLeftX, boxRightX); } return box; }
protected BasicStepMethodFilter(@NotNull JVMName declaringClassName, @NotNull String targetMethodName, @Nullable JVMName targetMethodSignature, Range<Integer> callingExpressionLines) { myDeclaringClassName = declaringClassName; myTargetMethodName = targetMethodName; myTargetMethodSignature = targetMethodSignature; myCallingExpressionLines = callingExpressionLines; }
public LambdaMethodFilter(PsiLambdaExpression lambda, int expressionOrdinal, Range<Integer> callingExpressionLines) { myLambdaOrdinal = expressionOrdinal; myCallingExpressionLines = callingExpressionLines; SourcePosition firstStatementPosition = null; SourcePosition lastStatementPosition = null; final PsiElement body = lambda.getBody(); if(body instanceof PsiCodeBlock) { final PsiStatement[] statements = ((PsiCodeBlock) body).getStatements(); if(statements.length > 0) { firstStatementPosition = SourcePosition.createFromElement(statements[0]); if(firstStatementPosition != null) { final PsiStatement lastStatement = statements[statements.length - 1]; lastStatementPosition = SourcePosition.createFromOffset(firstStatementPosition.getFile(), lastStatement.getTextRange().getEndOffset()); } } } else if(body != null) { firstStatementPosition = SourcePosition.createFromElement(body); } myFirstStatementPosition = firstStatementPosition; myLastStatementLine = lastStatementPosition != null ? lastStatementPosition.getLine() : -1; }
private boolean isOnTheSameLine(SourcePosition locationPosition) { if(myMethodFilter == null) { return myPosition.getLine() == locationPosition.getLine(); } else { Range<Integer> exprLines = myMethodFilter.getCallingExpressionLines(); return exprLines != null && exprLines.isWithin(locationPosition.getLine()); } }
protected SmartStepTarget( @Nullable String label, @Nullable PsiElement highlightElement, boolean needBreakpointRequest, Range<Integer> expressionLines) { myHighlightElement = highlightElement; myLabel = label; myNeedBreakpointRequest = needBreakpointRequest; myExpressionLines = expressionLines; }
public LambdaSmartStepTarget( @NotNull PsiLambdaExpression lambda, @Nullable String label, @Nullable PsiElement highlightElement, int ordinal, Range<Integer> lines) { super(label, highlightElement, true, lines); myLambda = lambda; myOrdinal = ordinal; }
public MethodSmartStepTarget( @NotNull PsiMethod method, @Nullable String label, @Nullable PsiElement highlightElement, boolean needBreakpointRequest, Range<Integer> lines) { super(label, highlightElement, needBreakpointRequest, lines); myMethod = method; }
public ConstructorStepMethodFilter(JVMName classJvmName, Range<Integer> callingExpressionLines) { super(classJvmName, JVMNameUtil.CONSTRUCTOR_NAME, null, callingExpressionLines); }
public ConstructorStepMethodFilter(PsiClass psiClass, Range<Integer> callingExpressionLines) { this(JVMNameUtil.getJVMQualifiedName(psiClass), callingExpressionLines); }
public ClassInstanceMethodFilter(PsiMethod psiMethod, Range<Integer> lines) { super(psiMethod.getContainingClass(), lines); myMethodFilter = new AnonymousClassMethodFilter(psiMethod, getCallingExpressionLines()); }
public ClassInstanceMethodFilter(JVMName classJvmName, BreakpointStepMethodFilter methodFilter, Range<Integer> lines) { super(classJvmName, lines); myMethodFilter = methodFilter; }
public BasicStepMethodFilter(@NotNull PsiMethod psiMethod, Range<Integer> callingExpressionLines) { this(JVMNameUtil.getJVMQualifiedName(psiMethod.getContainingClass()), JVMNameUtil.getJVMMethodName(psiMethod), JVMNameUtil.getJVMSignature(psiMethod), callingExpressionLines); }
@Nullable @Override public Range<Integer> getCallingExpressionLines() { return myCallingExpressionLines; }
protected SmartStepTarget(@Nullable String label, @Nullable PsiElement highlightElement, boolean needBreakpointRequest, Range<Integer> expressionLines) { myHighlightElement = highlightElement; myLabel = label; myNeedBreakpointRequest = needBreakpointRequest; myExpressionLines = expressionLines; }
@Nullable public Range<Integer> getCallingExpressionLines() { return myExpressionLines; }
public void setCallingExpressionLines(Range<Integer> expressionLines) { myExpressionLines = expressionLines; }
public LambdaSmartStepTarget(@NotNull PsiLambdaExpression lambda, @Nullable String label, @Nullable PsiElement highlightElement, int ordinal, Range<Integer> lines) { super(label, highlightElement, true, lines); myLambda = lambda; myOrdinal = ordinal; }
public MethodSmartStepTarget(@NotNull PsiMethod method, @Nullable String label, @Nullable PsiElement highlightElement, boolean needBreakpointRequest, Range<Integer> lines) { super(label, highlightElement, needBreakpointRequest, lines); myMethod = method; }
private static boolean isLocationInExpandControl(JTree aTree, TreePath path, int mouseX, int mouseY) { Range<Integer> box = TreeUtil.getExpandControlRange(aTree, path); return box != null && box.isWithin(mouseX); }
@Nullable Range<Integer> getCallingExpressionLines();