Skip to content

Potentially useful JDT APIs

Jean-Noël Rouvignac edited this page Sep 22, 2016 · 3 revisions
  • for issue #28:

    • org.eclipse.jface.text.Position with IDocument.addPosition(Position)

    • or org.eclipse.jdt.core.dom.rewrite.ASTRewrite.track(ASTNode node)

  • ITextEditor.getSelectionProvider().setSelection(ISelection)

    TextSelection selection = new TextSelection(position.getOffset(), position.getLength());
    ITextEditor editor = ...;
    editor.getSelectionProvider().setSelection(selection);
  • org.eclipse.core.runtime.jobs.JobGroup, see bug 432049 for issue #107

  • org.eclipse.jface.text.IDocumentExtension4.startRewriteSession(DocumentRewriteSessionType)

  • DocumentUndoManager.beginCompoundChange() and IDocumentUndoManager.endCompoundChange():

    IDocumentUndoManager manager = DocumentUndoManagerRegistry.getDocumentUndoManager(document);
    manager.beginCompoundChange();
    edit.apply(document);
    manager.endCompoundChange();
  • Insert empty line, or insert comments from the ASTRewriter (see 1 and 2):

    Statement commentPlaceHolder = (Statement)
        rewriter.createStringPlaceholder("//mycomment", ASTNode.EMPTY_STATEMENT);
    listRewrite.insertFirst(commentPlaceHolder, null);
    //notice here, we just create a string placeholder, and string is simply empty
    Statement emptyLinePlaceHolder = (Statement)
        rewriter.createStringPlaceholder("", ASTNode.EMPTY_STATEMENT);
    listRewrite.insertFirst(emptyLinePlaceHolder, null)
  • More at programcreek.com?

Clone this wiki locally