Package com.intellij.psi

Examples of com.intellij.psi.PsiElement.replace()


    stringBuilder.append(")&");

    final PsiFile file = factory.createFileFromText("dummy.m", MathematicaFileType.INSTANCE, stringBuilder);
    final Function[] func = PsiTreeUtil.getChildrenOfType(file, Function.class);
    assert func != null && func[0] != null;
    e.replace(func[0]);
    return null;
  }
}
View Full Code Here


      last = last.getPrevSibling();
    }
    if (first == null || last == null || first == last && last instanceof PsiWhiteSpace) return null;
    PsiElement parent = element.getParent();
    PsiElement target = parent instanceof BnfQuantified || parent instanceof BnfPredicate? parent : element;
    return Collections.singletonList(target.replace(BnfElementFactory.createExpressionFromText(
      editor.getProject(), element.getContainingFile().getText().substring(first.getTextRange().getStartOffset(), last.getTextRange().getEndOffset()))));
  }

  @Nullable
  private static PsiElement findTargetElement(Editor editor, PsiFile file) {
View Full Code Here

        for (int i = 1; i < space.getTextLength(); i++) {
            sb.append("\n");
        }
        PsiElement[] statements = GoPsiElementFactory.createStatements((GoFile) file, sb.toString());
        if (statements.length > 0 && isNewLineNode(statements[0])) {
            space.replace(statements[0]);
        }
    }

    private PsiElement getNextNonWhitespaceSibling(PsiElement start) {
        while ((start = start.getNextSibling()) != null) {
View Full Code Here

  }

  @Nullable
  private static PsiElement replaceLeftmostArgumentDefinition(@NotNull PsiElement declaration, @NotNull List<PsiElement> occurrences) {
    PsiElement argDef = extractLeftmostArgumentDefinition(occurrences);
    return argDef == null ? null : argDef.replace(declaration);
  }

  @Nullable
  private static PsiElement extractLeftmostArgumentDefinition(@NotNull List<PsiElement> occurrences) {
    int occurrenceOffset = Integer.MAX_VALUE;
View Full Code Here

              PsiElement expr = host.getParent();
              ASTNode replacementNode = null;

              if (expr instanceof ErlangMaxExpression) {
                if (ErlangPsiImplUtil.getExpressionPrecedence(expr.getParent()) > ErlangPsiImplUtil.getExpressionPrecedence(rightWithoutParentheses)) {
                  replacementNode = expr.replace(ErlangPsiImplUtil.wrapWithParentheses(rightWithoutParentheses)).getNode();
                }
                else {
                  replacementNode = expr.replace(rightWithoutParentheses).getNode();
                }
              }
View Full Code Here

              if (expr instanceof ErlangMaxExpression) {
                if (ErlangPsiImplUtil.getExpressionPrecedence(expr.getParent()) > ErlangPsiImplUtil.getExpressionPrecedence(rightWithoutParentheses)) {
                  replacementNode = expr.replace(ErlangPsiImplUtil.wrapWithParentheses(rightWithoutParentheses)).getNode();
                }
                else {
                  replacementNode = expr.replace(rightWithoutParentheses).getNode();
                }
              }
              else if (expr instanceof ErlangFunExpression) {
                replacementNode = host.replace(rightWithoutParentheses).getNode();
              }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.