Search in sources :

Example 1 with LineRange

use of org.eclipse.che.jface.text.source.LineRange in project che by eclipse.

the class JavaFormatter method indent.

private void indent(IDocument document) throws BadLocationException, MalformedTreeException {
    // first line
    int offset = document.getLineOffset(0);
    document.replace(offset, 0, CodeFormatterUtil.createIndentString(fInitialIndentLevel, fProject));
    // following lines
    int lineCount = document.getNumberOfLines();
    IndentUtil.indentLines(document, new LineRange(1, lineCount - 1), fProject, null);
}
Also used : LineRange(org.eclipse.che.jface.text.source.LineRange)

Example 2 with LineRange

use of org.eclipse.che.jface.text.source.LineRange in project che by eclipse.

the class TemplateProposal method getAdditionalProposalInfo.

/*
	 * @see ICompletionProposal#getAdditionalProposalInfo()
	 */
public String getAdditionalProposalInfo() {
    try {
        fContext.setReadOnly(true);
        TemplateBuffer templateBuffer;
        try {
            templateBuffer = fContext.evaluate(fTemplate);
        } catch (TemplateException e) {
            return null;
        }
        IDocument document = new Document(templateBuffer.getString());
        IndentUtil.indentLines(document, new LineRange(0, document.getNumberOfLines()), null, null);
        StringBuffer buffer = new StringBuffer();
        HTMLPrinter.insertPageProlog(buffer, 0, JavadocFinder.getStyleSheet());
        HTMLPrinter.addParagraph(buffer, document.get());
        HTMLPrinter.addPageEpilog(buffer);
        return buffer.toString();
    } catch (BadLocationException e) {
        //			handleException(
        //					JavaPlugin.getActiveWorkbenchShell(), new CoreException(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, "", e))); //$NON-NLS-1$
        JavaPlugin.log(e);
        return null;
    }
}
Also used : TemplateException(org.eclipse.jface.text.templates.TemplateException) TemplateBuffer(org.eclipse.jface.text.templates.TemplateBuffer) Document(org.eclipse.jface.text.Document) IDocument(org.eclipse.jface.text.IDocument) LineRange(org.eclipse.che.jface.text.source.LineRange) IDocument(org.eclipse.jface.text.IDocument) BadLocationException(org.eclipse.jface.text.BadLocationException)

Aggregations

LineRange (org.eclipse.che.jface.text.source.LineRange)2 BadLocationException (org.eclipse.jface.text.BadLocationException)1 Document (org.eclipse.jface.text.Document)1 IDocument (org.eclipse.jface.text.IDocument)1 TemplateBuffer (org.eclipse.jface.text.templates.TemplateBuffer)1 TemplateException (org.eclipse.jface.text.templates.TemplateException)1