コード例 #1
0
  @Override
  protected void collectAdditionalElementsToRename(List<Pair<PsiElement, TextRange>> stringUsages) {
    if (isReplaceAllOccurrences()) {
      for (E expression : getOccurrences()) {
        LOG.assertTrue(expression.isValid(), expression.getText());
        stringUsages.add(
            Pair.<PsiElement, TextRange>create(
                expression, new TextRange(0, expression.getTextLength())));
      }
    } else if (getExpr() != null) {
      correctExpression();
      final E expr = getExpr();
      LOG.assertTrue(expr.isValid(), expr.getText());
      stringUsages.add(
          Pair.<PsiElement, TextRange>create(expr, new TextRange(0, expr.getTextLength())));
    }

    final V localVariable = getLocalVariable();
    if (localVariable != null) {
      final PsiElement nameIdentifier = localVariable.getNameIdentifier();
      if (nameIdentifier != null) {
        int length = nameIdentifier.getTextLength();
        stringUsages.add(
            Pair.<PsiElement, TextRange>create(nameIdentifier, new TextRange(0, length)));
      }
    }
  }
コード例 #2
0
  public boolean startsOnTheSameElement(E expr, V localVariable) {
    if (myExprMarker != null
        && myExprMarker.isValid()
        && expr != null
        && myExprMarker.getStartOffset() == expr.getTextOffset()) {
      return true;
    }

    if (myLocalMarker != null
        && myLocalMarker.isValid()
        && localVariable != null
        && myLocalMarker.getStartOffset() == localVariable.getTextOffset()) {
      return true;
    }
    return isRestart();
  }
コード例 #3
0
 private IncludeDuplicate(E start, E end) {
   myStart =
       SmartPointerManager.getInstance(start.getProject()).createSmartPsiElementPointer(start);
   myEnd = SmartPointerManager.getInstance(start.getProject()).createSmartPsiElementPointer(end);
 }
コード例 #4
0
 @Nullable
 protected String getExpressionText(E expr) {
   return expr != null ? expr.getText() : null;
 }