Example usage for org.eclipse.jdt.core IJavaModelStatusConstants BAD_TEXT_EDIT_LOCATION

List of usage examples for org.eclipse.jdt.core IJavaModelStatusConstants BAD_TEXT_EDIT_LOCATION

Introduction

In this page you can find the example usage for org.eclipse.jdt.core IJavaModelStatusConstants BAD_TEXT_EDIT_LOCATION.

Prototype

int BAD_TEXT_EDIT_LOCATION

To view the source code for org.eclipse.jdt.core IJavaModelStatusConstants BAD_TEXT_EDIT_LOCATION.

Click Source Link

Document

Status constant indicating that a text edit can not be applied as there is a problem with the text edit location.

Usage

From source file:com.codenvy.ide.ext.java.server.internal.core.CompilationUnit.java

License:Open Source License

public UndoEdit applyTextEdit(TextEdit edit, IProgressMonitor monitor) throws JavaModelException {
    IBuffer buffer = getBuffer();//from  www . j  a v a  2s  . c  om
    if (buffer instanceof IBuffer.ITextEditCapability) {
        return ((IBuffer.ITextEditCapability) buffer).applyTextEdit(edit, monitor);
    } else if (buffer != null) {
        IDocument document = buffer instanceof IDocument ? (IDocument) buffer : new DocumentAdapter(buffer);
        try {
            UndoEdit undoEdit = edit.apply(document);
            return undoEdit;
        } catch (MalformedTreeException e) {
            throw new JavaModelException(e, IJavaModelStatusConstants.BAD_TEXT_EDIT_LOCATION);
        } catch (BadLocationException e) {
            throw new JavaModelException(e, IJavaModelStatusConstants.BAD_TEXT_EDIT_LOCATION);
        }
    }
    return null; // can not happen, there are no compilation units without buffer
}