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);
}
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;
}
}
Aggregations