Java 类com.intellij.util.Range 实例源码

项目:intellij-ce-playground    文件:LambdaMethodFilter.java   
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;
}
项目:intellij-ce-playground    文件:AnonymousClassMethodFilter.java   
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;
}
项目:intellij-ce-playground    文件:ToggleBreakpointEnabledAction.java   
@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;
}
项目:tools-idea    文件:BalloonImpl.java   
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());
}
项目:consulo    文件:MoveElementLeftRightActionHandler.java   
@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);
}
项目:consulo-java    文件:AnonymousClassMethodFilter.java   
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;
}
项目:hybris-integration-intellij-idea-plugin    文件:SelectImpexTableOperation.java   
@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));
    }
}
项目:intellij-ce-playground    文件:BasicStepMethodFilter.java   
protected BasicStepMethodFilter(@NotNull JVMName declaringClassName,
                             @NotNull String targetMethodName,
                             JVMName targetMethodSignature,
                             Range<Integer> callingExpressionLines) {
  myDeclaringClassName = declaringClassName;
  myTargetMethodName = targetMethodName;
  myTargetMethodSignature = targetMethodSignature;
  myCallingExpressionLines = callingExpressionLines;
}
项目:intellij-ce-playground    文件:RequestHint.java   
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());
  }
}
项目:intellij-ce-playground    文件:TreeUtil.java   
@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;
}
项目:tools-idea    文件:TreeUtil.java   
@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;
}
项目:consulo    文件:TreeUtil.java   
@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;
}
项目:consulo-java    文件:BasicStepMethodFilter.java   
protected BasicStepMethodFilter(@NotNull JVMName declaringClassName, @NotNull String targetMethodName, @Nullable JVMName targetMethodSignature, Range<Integer> callingExpressionLines)
{
    myDeclaringClassName = declaringClassName;
    myTargetMethodName = targetMethodName;
    myTargetMethodSignature = targetMethodSignature;
    myCallingExpressionLines = callingExpressionLines;
}
项目:consulo-java    文件:LambdaMethodFilter.java   
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;
}
项目:consulo-java    文件:RequestHint.java   
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());
    }
}
项目:consulo-java    文件:SmartStepTarget.java   
protected SmartStepTarget(
        @Nullable String label,
        @Nullable PsiElement highlightElement,
        boolean needBreakpointRequest,
        Range<Integer> expressionLines)
{
    myHighlightElement = highlightElement;
    myLabel = label;
    myNeedBreakpointRequest = needBreakpointRequest;
    myExpressionLines = expressionLines;
}
项目:consulo-java    文件:LambdaSmartStepTarget.java   
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;
}
项目:consulo-java    文件:MethodSmartStepTarget.java   
public MethodSmartStepTarget(
        @NotNull PsiMethod method,
        @Nullable String label,
        @Nullable PsiElement highlightElement,
        boolean needBreakpointRequest,
        Range<Integer> lines)
{
    super(label, highlightElement, needBreakpointRequest, lines);
    myMethod = method;
}
项目:intellij-ce-playground    文件:ConstructorStepMethodFilter.java   
public ConstructorStepMethodFilter(JVMName classJvmName, Range<Integer> callingExpressionLines) {
  super(classJvmName, JVMNameUtil.CONSTRUCTOR_NAME, null, callingExpressionLines);
}
项目:intellij-ce-playground    文件:ConstructorStepMethodFilter.java   
public ConstructorStepMethodFilter(PsiClass psiClass, Range<Integer> callingExpressionLines) {
  this(JVMNameUtil.getJVMQualifiedName(psiClass), callingExpressionLines);
}
项目:intellij-ce-playground    文件:ClassInstanceMethodFilter.java   
public ClassInstanceMethodFilter(PsiMethod psiMethod, Range<Integer> lines) {
  super(psiMethod.getContainingClass(), lines);
  myMethodFilter = new AnonymousClassMethodFilter(psiMethod, getCallingExpressionLines());
}
项目:intellij-ce-playground    文件:ClassInstanceMethodFilter.java   
public ClassInstanceMethodFilter(JVMName classJvmName, BreakpointStepMethodFilter methodFilter, Range<Integer> lines) {
  super(classJvmName, lines);
  myMethodFilter = methodFilter;
}
项目:intellij-ce-playground    文件:BasicStepMethodFilter.java   
public BasicStepMethodFilter(@NotNull PsiMethod psiMethod, Range<Integer> callingExpressionLines) {
  this(JVMNameUtil.getJVMQualifiedName(psiMethod.getContainingClass()),
       JVMNameUtil.getJVMMethodName(psiMethod),
       JVMNameUtil.getJVMSignature(psiMethod),
       callingExpressionLines);
}
项目:intellij-ce-playground    文件:BasicStepMethodFilter.java   
@Nullable
@Override
public Range<Integer> getCallingExpressionLines() {
  return myCallingExpressionLines;
}
项目:intellij-ce-playground    文件:LambdaMethodFilter.java   
@Nullable
@Override
public Range<Integer> getCallingExpressionLines() {
  return myCallingExpressionLines;
}
项目:intellij-ce-playground    文件:SmartStepTarget.java   
protected SmartStepTarget(@Nullable String label, @Nullable PsiElement highlightElement, boolean needBreakpointRequest, Range<Integer> expressionLines) {
  myHighlightElement = highlightElement;
  myLabel = label;
  myNeedBreakpointRequest = needBreakpointRequest;
  myExpressionLines = expressionLines;
}
项目:intellij-ce-playground    文件:SmartStepTarget.java   
@Nullable
public Range<Integer> getCallingExpressionLines() {
  return myExpressionLines;
}
项目:intellij-ce-playground    文件:SmartStepTarget.java   
public void setCallingExpressionLines(Range<Integer> expressionLines) {
  myExpressionLines = expressionLines;
}
项目:intellij-ce-playground    文件:LambdaSmartStepTarget.java   
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;
}
项目:intellij-ce-playground    文件:MethodSmartStepTarget.java   
public MethodSmartStepTarget(@NotNull PsiMethod method, @Nullable String label, @Nullable PsiElement highlightElement, boolean needBreakpointRequest, Range<Integer> lines) {
  super(label, highlightElement, needBreakpointRequest, lines);
  myMethod = method;
}
项目:intellij-ce-playground    文件:TreePopupImpl.java   
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);
}
项目:tools-idea    文件:TreePopupImpl.java   
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);
}
项目:consulo    文件:TreePopupImpl.java   
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);
}
项目:consulo-java    文件:ConstructorStepMethodFilter.java   
public ConstructorStepMethodFilter(JVMName classJvmName, Range<Integer> callingExpressionLines)
{
    super(classJvmName, JVMNameUtil.CONSTRUCTOR_NAME, null, callingExpressionLines);
}
项目:consulo-java    文件:ConstructorStepMethodFilter.java   
public ConstructorStepMethodFilter(PsiClass psiClass, Range<Integer> callingExpressionLines)
{
    this(JVMNameUtil.getJVMQualifiedName(psiClass), callingExpressionLines);
}
项目:consulo-java    文件:ClassInstanceMethodFilter.java   
public ClassInstanceMethodFilter(PsiMethod psiMethod, Range<Integer> lines)
{
    super(psiMethod.getContainingClass(), lines);
    myMethodFilter = new AnonymousClassMethodFilter(psiMethod, getCallingExpressionLines());
}
项目:consulo-java    文件:BasicStepMethodFilter.java   
public BasicStepMethodFilter(@NotNull PsiMethod psiMethod, Range<Integer> callingExpressionLines)
{
    this(JVMNameUtil.getJVMQualifiedName(psiMethod.getContainingClass()), JVMNameUtil.getJVMMethodName(psiMethod), JVMNameUtil.getJVMSignature(psiMethod), callingExpressionLines);
}
项目:consulo-java    文件:BasicStepMethodFilter.java   
@Nullable
@Override
public Range<Integer> getCallingExpressionLines()
{
    return myCallingExpressionLines;
}
项目:consulo-java    文件:LambdaMethodFilter.java   
@Nullable
@Override
public Range<Integer> getCallingExpressionLines()
{
    return myCallingExpressionLines;
}
项目:consulo-java    文件:MethodFilter.java   
@Nullable
Range<Integer> getCallingExpressionLines();