/** * Returns the offset of the range in the document that will be replaced by * applying this template. * * @return the offset of the range in the document that will be replaced by * applying this template * @since 3.1 */ protected final int getReplaceOffset() { int start; if (fContext instanceof DocumentTemplateContext) { DocumentTemplateContext docContext = (DocumentTemplateContext)fContext; start= docContext.getStart(); } else { start= fRegion.getOffset(); } return start; }
/** * Returns the offset of the range in the document that will be replaced by * applying this template. * * @return the offset of the range in the document that will be replaced by * applying this template */ private int getReplaceOffset() { int start; if (fContext instanceof DocumentTemplateContext) { DocumentTemplateContext docContext = (DocumentTemplateContext)fContext; start= docContext.getStart(); } else { start= fRegion.getOffset(); } return start; }
/** * Returns the offset of the range in the document that will be replaced by * applying this template. * * @return the offset of the range in the document that will be replaced by * applying this template * @since 3.1 */ protected final int getReplaceOffset() { int start; if (fContext instanceof DocumentTemplateContext) { DocumentTemplateContext docContext = (DocumentTemplateContext)fContext; start= docContext.getStart(); } else { start= fRegion.getOffset(); } return start; }
/** * Returns the offset of the range in the document that will be replaced by * applying this template. * * @return the offset of the range in the document that will be replaced by * applying this template */ protected final int getReplaceOffset() { int start; if (fContext instanceof DocumentTemplateContext) { DocumentTemplateContext docContext = (DocumentTemplateContext)fContext; start= docContext.getStart(); } else { start= fRegion.getOffset(); } return start; }
/** * Returns the offset of the range in the document that will be replaced by * applying this template. * * @return the offset of the range in the document that will be replaced by * applying this template */ protected final int getReplaceOffset() { int start; if (fContext instanceof DocumentTemplateContext) { DocumentTemplateContext docContext = (DocumentTemplateContext)fContext; start= docContext.getStart(); } else { start= fRegion.getOffset(); } return start; }
/** * Returns the offset of the range in the document that will be replaced by applying this template. * * @return the offset of the range in the document that will be replaced by applying this template * @since 3.1 */ protected final int getReplaceOffset() { int start; if (_context instanceof DocumentTemplateContext) { DocumentTemplateContext docContext = (DocumentTemplateContext) _context; start = docContext.getStart(); } else { start = _region.getOffset(); } return start; }
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; }
/** * 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$ } }