/** * Returns next word after the cursor position * * @throws BadLocationException */ public char getNextChar() throws BadLocationException { if (document.getLength() == offset) { return ' '; } return document.getChar(offset); }
@Override public ITypedRegion getPartition(int offset) { // in case we are in the end of document // we return the partition of last region int docLength = fStructuredDocument.getLength(); if (offset == docLength) { return super.getPartition(offset - 1); } return super.getPartition(offset); }
public void formatModel(IStructuredModel structuredModel) { int start = 0; int length = structuredModel.getStructuredDocument().getLength(); formatModel(structuredModel, start, length); }
public void cleanupModel(IStructuredModel structuredModel) { int start = 0; int length = structuredModel.getStructuredDocument().getLength(); cleanupModel(structuredModel, start, length); }
void performValidation(IFile f, IReporter reporter, IStructuredModel model) { fTaglibPrefixes.clear(); int length = model.getStructuredDocument().getLength(); performValidation(f, reporter, model, new Region(0, length)); }
/** * Determines the text region from the text region collection and offset * * @param regionCollection * @param offset */ protected ITextRegion determineTextRegion(IStructuredDocument document, ITextRegionCollection regionCollection, int offset) { ITextRegion textRegion; // in case we are at the end of the document, asking for completion if (offset == document.getLength()) { textRegion = regionCollection.getLastRegion(); } else { textRegion = regionCollection.getRegionAtCharacterOffset(offset); } return textRegion; }
/** */ public void replaceSource(IStructuredModel model, int offset, int length, String source) { if (model == null) return; IStructuredDocument structuredDocument = model.getStructuredDocument(); if (structuredDocument == null) return; if (offset >= 0 && length >= 0 && offset + length <= structuredDocument.getLength()) { if (structuredDocument.containsReadOnly(offset, length)) return; if (source == null) source = new String(); // We use 'structuredDocument' as the requester object just so // this and the other // format-related 'repalceText' (in replaceSource) can use the // same requester. // Otherwise, if requester is not identical, // the undo group gets "broken" into multiple pieces based // on the requesters being different. Technically, any unique, // common // requester object would work. structuredDocument.replaceText(structuredDocument, offset, length, source); } }
private String getNamedStyleAtOffset(int offset) { // ensure the offset is clean if (offset >= fDocument.getLength()) return getNamedStyleAtOffset(fDocument.getLength() - 1); else if (offset < 0) return getNamedStyleAtOffset(0); IStructuredDocumentRegion documentRegion = fDocument.getFirstStructuredDocumentRegion(); while (documentRegion != null && !documentRegion.containsOffset(offset)) { documentRegion = documentRegion.getNext(); } if (documentRegion != null) { // find the ITextRegion's Context at this offset ITextRegion interest = documentRegion.getRegionAtCharacterOffset(offset); if (interest == null) return null; if (offset > documentRegion.getTextEndOffset(interest)) return null; String regionContext = interest.getType(); if (regionContext == null) return null; // find the named style (internal/selectable name) for that // context String namedStyle = (String) fContextToStyleMap.get(regionContext); if (namedStyle != null) { return namedStyle; } } return null; }
public void setStructuredDocument(IStructuredDocument newStructuredDocument) { IStructuredDocument oldStructuredDocument = super.getStructuredDocument(); if (newStructuredDocument == oldStructuredDocument) return; // noting to do if (oldStructuredDocument != null) oldStructuredDocument.removeDocumentChangingListener(this); super.setStructuredDocument(newStructuredDocument); if (newStructuredDocument != null) { if (newStructuredDocument.getLength() > 0) { newModel(new NewDocumentEvent(newStructuredDocument, this)); } newStructuredDocument.addDocumentChangingListener(this); } }
} else { int maxLength = model.getStructuredDocument().getLength(); List structures = new ArrayList(2); while (region != null && region.getEndOffset() <= end
if (tRegion == null && offset == document.getLength()) { offset -= 1; tRegion = sdRegion.getRegionAtCharacterOffset(offset);
return; int documentLength = node.getStructuredDocument().getLength(); if (documentLength < 1 || (node.getEndOffset() >= (documentLength - 1))) return;
int offset = (refRule != null) ? refRule.getStartOffset() : doc.getLength(); doc.replaceText(this, offset, 0, rule);
if (tRegion == null && offset == document.getLength()) { offset -= 1; tRegion = sdRegion.getRegionAtCharacterOffset(offset);
if (tRegion == null && offset == document.getLength()) { tRegion = sdRegion.getRegionAtCharacterOffset(offset - 1);
if (tRegion == null && offset == document.getLength()) { offset -= 1; tRegion = sdRegion.getRegionAtCharacterOffset(offset);
if (scriptRegion == null && offset == document.getLength()) { offset -= 1; scriptRegion = sdRegion.getRegionAtCharacterOffset(offset);
if (scriptRegion == null && offset == document.getLength()) { offset -= 1; scriptRegion = sdRegion.getRegionAtCharacterOffset(offset);
/** * /* the main control loop for translating the document, driven by the * structuredDocument nodes */ public void translate() { if (fTagToVariableMap == null) { fTagToVariableMap = new StackMap(); } setCurrentNode(new ZeroStructuredDocumentRegion(fStructuredDocument, 0)); translatePreludes(); setCurrentNode(fStructuredDocument.getFirstStructuredDocumentRegion()); while (getCurrentNode() != null && !isCanceled()) { // intercept HTML comment flat node // also handles UNDEFINED (which is what CDATA comes in as) // basically this part will handle any "embedded" JSP containers if (getCurrentNode().getType() == DOMRegionContext.XML_COMMENT_TEXT || getCurrentNode().getType() == DOMRegionContext.XML_CDATA_TEXT || getCurrentNode().getType() == DOMRegionContext.UNDEFINED) { translateXMLCommentNode(getCurrentNode()); } else { // iterate through each region in the flat node translateRegionContainer(getCurrentNode(), STANDARD_JSP); } if (getCurrentNode() != null) advanceNextNode(); } setCurrentNode(new ZeroStructuredDocumentRegion(fStructuredDocument, fStructuredDocument.getLength())); translateCodas(); buildResult(); fTagToVariableMap.clear(); }
if (node.getStructuredDocument().getLength() == 0) { return null;