Examples of replaceString()


Examples of com.intellij.openapi.editor.Document.replaceString()

    HbPath path = PsiTreeUtil.findChildOfType(targetBlockMustache, HbPath.class);
    final Document document = PsiDocumentManager.getInstance(project).getDocument(file);
    if (path != null && document != null) {
      final TextRange textRange = path.getTextRange();
      document.replaceString(textRange.getStartOffset(), textRange.getEndOffset(), myCorrectedName);
    }
  }

  @Override
  public boolean startInWriteAction() {
View Full Code Here

Examples of com.intellij.openapi.editor.Document.replaceString()

    if (pairOffset == -1) {
      assertEmpty("File lacks pair marker");
    }

    Document document = myFixture.getEditor().getDocument();
    document.replaceString(pairOffset, pairOffset + pairMarker.length(), "");
    PsiDocumentManager.getInstance(getProject()).commitDocument(document);

    return pairOffset;
  }
View Full Code Here

Examples of com.intellij.openapi.editor.Document.replaceString()

                               @Nullable RangeMarker originalStatementRange) {
        Document document = editor.getDocument();
        RangeMarker insertPoint = document.createRangeMarker(offset, offset);
        for (RangeMarker exprMarker : exprMarkers) {
            // replace expression with const
            document.replaceString(exprMarker.getStartOffset(), exprMarker.getEndOffset(), '$' + VARIABLE + '$');
        }

        document.replaceString(insertPoint.getStartOffset(), insertPoint.getEndOffset(), stmt);
        TextRange range;
        if (originalStatementRange != null) {
View Full Code Here

Examples of com.intellij.openapi.editor.Document.replaceString()

        for (RangeMarker exprMarker : exprMarkers) {
            // replace expression with const
            document.replaceString(exprMarker.getStartOffset(), exprMarker.getEndOffset(), '$' + VARIABLE + '$');
        }

        document.replaceString(insertPoint.getStartOffset(), insertPoint.getEndOffset(), stmt);
        TextRange range;
        if (originalStatementRange != null) {
            range = TextRange.create(originalStatementRange);
        } else {
            range = new TextRange(insertPoint.getStartOffset(), insertPoint.getEndOffset() + stmt.length());
View Full Code Here

Examples of com.intellij.openapi.editor.Document.replaceString()

        GoFunctionDeclaration functionDeclaration = GoPsiUtils.findParentOfType(element, GoFunctionDeclaration.class);
        int startOffset;
        PsiElement result = GoPsiUtils.findChildOfType(functionDeclaration, GoElementTypes.FUNCTION_RESULT);
        if (result != null) {
            startOffset = result.getTextOffset();
            doc.replaceString(startOffset, result.getTextRange().getEndOffset(),
                    i > 1 ?
                            "(" + stringBuilder.toString() + ")" : stringBuilder.toString()
            );
        } else {
            startOffset = functionDeclaration.getBlock().getTextOffset();
View Full Code Here

Examples of com.intellij.openapi.editor.Document.replaceString()

                    return;
                }

                TextRange textRange = packageDeclaration.getTextRange();

                doc.replaceString(textRange.getStartOffset(),
                                  textRange.getEndOffset(),
                                  "package " + targetPackage);
            }
        });
    }
View Full Code Here

Examples of com.intellij.openapi.editor.Document.replaceString()

        final PsiElement finalE = e;
        WriteCommandAction writeCommandAction = new WriteCommandAction(project) {
            @Override
            protected void run(@NotNull Result result) throws Throwable {
                doc.replaceString(finalE.getTextOffset(), finalE.getTextOffset() + finalE.getTextLength(), "=");
            }
        };
        writeCommandAction.execute();
    }
}
View Full Code Here

Examples of com.intellij.openapi.editor.Document.replaceString()

        final String text = "(\n" + declaration.getText() + "\n)";

        WriteCommandAction writeCommandAction = new WriteCommandAction(element.getContainingFile().getProject()) {
            @Override
            protected void run(@NotNull Result result) throws Throwable {
                document.replaceString(range.getStartOffset(), range.getEndOffset(), text);
            }
        };
        writeCommandAction.execute();

        PsiFile file = element.getContainingFile();
View Full Code Here

Examples of com.intellij.openapi.editor.Document.replaceString()

        } else {
            String oldImport = lastImport.getText();
            int start = lastImport.getTextOffset();
            int end = start + lastImport.getTextLength();
            String declarations = String.format("(\n%s\n\"%s\"\n)", oldImport, pathToImport);
            document.replaceString(start, end, declarations);
            reformatPositions(file, start, start + declarations.length());
        }
    }

    private static void addImportUnderPackage(GoFile file, Document document, String pathToImport) {
View Full Code Here

Examples of com.intellij.openapi.editor.Document.replaceString()

        final GoIfStatement finalInner = inner;
        WriteCommandAction writeCommandAction = new WriteCommandAction(element.getContainingFile().getProject()) {
            @Override
            protected void run(@NotNull Result result) throws Throwable {
                document.replaceString(finalInner.getTextOffset(), innerEnd, simpleStatementAndExpression);

                document.deleteString(outerIfRange.getStartOffset(), outerIfRange.getEndOffset());
                document.deleteString(rightCurlyRange.getStartOffset(), rightCurlyRange.getEndOffset());
            }
        };
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.