/** * Returns the keyword which triggered template insertion. * * @return the keyword which triggered template insertion */ public String getKey() { int offset= getStart(); int length= getEnd() - offset; try { return fDocument.get(offset, length); } catch (BadLocationException e) { return ""; //$NON-NLS-1$ } }
/** * Returns the keyword which triggered template insertion. * * @return the keyword which triggered template insertion */ public String getKey() { int offset= getStart(); int length= getEnd() - offset; try { return fDocument.get(offset, length); } catch (BadLocationException e) { return ""; //$NON-NLS-1$ } }
/** * Returns the end offset of the range in the document that will be replaced * by applying this template. * * @return the end offset of the range in the document that will be replaced * by applying this template * @since 3.1 */ protected final int getReplaceEndOffset() { int end; if (fContext instanceof DocumentTemplateContext) { DocumentTemplateContext docContext = (DocumentTemplateContext)fContext; end= docContext.getEnd(); } else { end= fRegion.getOffset() + fRegion.getLength(); } return end; }
/** * Returns the end offset of the range in the document that will be replaced * by applying this template. * * @return the end offset of the range in the document that will be replaced * by applying this template * @since 3.1 */ protected final int getReplaceEndOffset() { int end; if (fContext instanceof DocumentTemplateContext) { DocumentTemplateContext docContext = (DocumentTemplateContext)fContext; end= docContext.getEnd(); } else { end= fRegion.getOffset() + fRegion.getLength(); } return end; }
/** * Returns the end offset of the range in the document that will be replaced * by applying this template. * * @return the end offset of the range in the document that will be replaced * by applying this template */ private int getReplaceEndOffset() { int end; if (fContext instanceof DocumentTemplateContext) { DocumentTemplateContext docContext = (DocumentTemplateContext)fContext; end= docContext.getEnd(); } else { end= fRegion.getOffset() + fRegion.getLength(); } return end; }
/** * Returns the end offset of the range in the document that will be replaced * by applying this template. * * @return the end offset of the range in the document that will be replaced * by applying this template */ protected final int getReplaceEndOffset() { int end; if (fContext instanceof DocumentTemplateContext) { DocumentTemplateContext docContext = (DocumentTemplateContext)fContext; end= docContext.getEnd(); } else { end= fRegion.getOffset() + fRegion.getLength(); } return end; }
/** * Returns the end offset of the range in the document that will be replaced * by applying this template. * * @return the end offset of the range in the document that will be replaced * by applying this template */ protected final int getReplaceEndOffset() { int end; if (fContext instanceof DocumentTemplateContext) { DocumentTemplateContext docContext = (DocumentTemplateContext)fContext; end= docContext.getEnd(); } else { end= fRegion.getOffset() + fRegion.getLength(); } return end; }
/** * Returns the end offset of the range in the document that will be replaced by applying this template. * * @return the end offset of the range in the document that will be replaced by applying this template * @since 3.1 */ protected final int getReplaceEndOffset() { int end; if (_context instanceof DocumentTemplateContext) { DocumentTemplateContext docContext = (DocumentTemplateContext) _context; end = docContext.getEnd(); } else { end = _region.getOffset() + _region.getLength(); } return end; }
private boolean isReplacedAreaEmpty(TemplateContext context) { // don't trim the buffer if the replacement area is empty // case: surrounding empty lines with block if (context instanceof DocumentTemplateContext) { DocumentTemplateContext dtc= (DocumentTemplateContext) context; if (dtc.getStart() == dtc.getCompletionOffset()) try { if (dtc.getDocument().get(dtc.getStart(), dtc.getEnd() - dtc.getStart()).trim().length() == 0) return true; } catch (BadLocationException x) { // ignore - this may happen when the document was modified after the initial invocation, and the // context does not track the changes properly - don't trim in that case return true; } } return false; }
private boolean isReplacedAreaEmpty(TemplateContext context) { // don't trim the buffer if the replacement area is empty // case: surrounding empty lines with block if (context instanceof DocumentTemplateContext) { DocumentTemplateContext dtc= (DocumentTemplateContext) context; if (dtc.getStart() == dtc.getCompletionOffset()) try { IDocument document= dtc.getDocument(); int lineOffset= document.getLineInformationOfOffset(dtc.getStart()).getOffset(); //only if we are at the beginning of the line if (lineOffset != dtc.getStart()) return false; //Does the selection only contain whitespace characters? if (document.get(dtc.getStart(), dtc.getEnd() - dtc.getStart()).trim().length() == 0) return true; } catch (BadLocationException x) { // ignore - this may happen when the document was modified after the initial invocation, and the // context does not track the changes properly - don't trim in that case return true; } } return false; }
private boolean isReplacedAreaEmpty(TemplateContext context) { // don't trim the buffer if the replacement area is empty // case: surrounding empty lines with block if (context instanceof DocumentTemplateContext) { DocumentTemplateContext dtc= (DocumentTemplateContext) context; if (dtc.getStart() == dtc.getCompletionOffset()) try { IDocument document= dtc.getDocument(); int lineOffset= document.getLineInformationOfOffset(dtc.getStart()).getOffset(); //only if we are at the beginning of the line if (lineOffset != dtc.getStart()) return false; //Does the selection only contain whitespace characters? if (document.get(dtc.getStart(), dtc.getEnd() - dtc.getStart()).trim().length() == 0) return true; } catch (BadLocationException x) { // ignore - this may happen when the document was modified after the initial invocation, and the // context does not track the changes properly - don't trim in that case return true; } } return false; }