Class CUCorrectionProposal

    • Constructor Detail

      • CUCorrectionProposal

        public CUCorrectionProposal​(java.lang.String name,
                                    ICompilationUnit cu,
                                    TextChange change,
                                    int relevance,
                                    Image image)
        Constructs a correction proposal working on a compilation unit with a given text change.
        Parameters:
        name - the name that is displayed in the proposal selection dialog
        cu - the compilation unit to which the change can be applied
        change - the change that is executed when the proposal is applied or null if implementors override addEdits(IDocument, TextEdit) to provide the text edits or createTextChange() to provide a text change
        relevance - the relevance of this proposal
        image - the image that is displayed for this proposal or null if no image is desired
      • CUCorrectionProposal

        public CUCorrectionProposal​(java.lang.String name,
                                    ICompilationUnit cu,
                                    TextChange change,
                                    int relevance)
        Constructs a correction proposal working on a compilation unit with a given text change. Uses the default image for this proposal.
        Parameters:
        name - the name that is displayed in the proposal selection dialog
        cu - the compilation unit to which the change can be applied
        change - the change that is executed when the proposal is applied or null if implementors override addEdits(IDocument, TextEdit) to provide the text edits or createTextChange() to provide a text change.
        relevance - the relevance of this proposal
      • CUCorrectionProposal

        protected CUCorrectionProposal​(java.lang.String name,
                                       ICompilationUnit cu,
                                       int relevance,
                                       Image image)
        Constructs a correction proposal working on a compilation unit.

        Users have to override addEdits(IDocument, TextEdit) to provide the text edits or createTextChange() to provide a text change.

        Parameters:
        name - the name that is displayed in the proposal selection dialog
        cu - the compilation unit on that the change works
        relevance - the relevance of this proposal
        image - the image that is displayed for this proposal or null if no image is desired
    • Method Detail

      • addEdits

        protected void addEdits​(IDocument document,
                                TextEdit editRoot)
                         throws CoreException
        Called when the CompilationUnitChange is initialized. Subclasses can override to add text edits to the root edit of the change. Implementors must not access the proposal, e.g. not call ChangeCorrectionProposal.getChange().

        The default implementation does not add any edits

        Parameters:
        document - content of the underlying compilation unit. To be accessed read only.
        editRoot - The root edit to add all edits to
        Throws:
        CoreException - can be thrown if adding the edits is failing.
      • getCompilationUnit

        public final ICompilationUnit getCompilationUnit()
        The compilation unit on which the change works.
        Returns:
        the compilation unit on which the change works
      • getPreviewContent

        public java.lang.String getPreviewContent()
                                           throws CoreException
        Creates a preview of the content of the compilation unit after applying the change.
        Returns:
        the preview of the changed compilation unit
        Throws:
        CoreException - if the creation of the change failed
        Restriction:
        This method is not intended to be referenced by clients.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • didOpenEditor

        protected boolean didOpenEditor()
        Returns whether the changed compilation unit was not previously open in an editor.
        Returns:
        true if the changed compilation unit was not previously open in an editor, false if the changed compilation unit was already open in an editor
        Restriction:
        This method is not intended to be referenced by clients.