static public boolean canHandleAsLetterOrDigit(ITextRegion region, String changes, int requestStart, int lengthToReplace) { boolean result = false; // Make sure we are in a non-white space area if ((requestStart <= (region.getTextEnd())) && (allLetterOrDigit(changes))) { result = true; } return result; }
static public String toString(ITextRegion region) { String className = region.getClass().getName(); String shortClassName = className.substring(className.lastIndexOf(".") + 1); //$NON-NLS-1$ String result = shortClassName + "--> " + region.getType() + ": " + region.getStart() + "-" + region.getTextEnd() + (region.getTextEnd() != region.getEnd() ? ("/" + region.getEnd()) : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ // NOTE: if the document held by any region has been updated and the // region offsets have not // yet been updated, the output from this method invalid. return result; }
static public boolean canHandleAsWhiteSpace(ITextRegion region, String changes, int requestStart, int lengthToReplace) { boolean result = false; // if we are in the "white space" area of a region, then // we don't want to handle, a reparse is needed. // the white space region is consider anywhere that would // leave whitespace between this character and the text part. // and of course, we can insert whitespace in whitespace region // // if there is no whitespace in this region, no need to look further if (region.getEnd() > region.getTextEnd()) { // no need to add one to end of text, as we used to, since we // change definition of length to equate to offset plus one. if (requestStart > region.getTextEnd()) { // ok, we are in the whitespace region, so we can't handle, // unless // we are just inserting whitespace. if (allWhiteSpace(changes)) { result = true; } else { result = false; } } } return result; }
public String getText(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion aRegion) { // Must be proxied here since aRegion should always be a child of // *this* container and indexed from // this container's offset return parent.getText().substring(start + aRegion.getStart(), start + aRegion.getTextEnd()); }
/** */ private void removeTailingSpaces(IStructuredDocumentRegion flatNode, ITextRegion region) { int offset = region.getTextEnd(); int count = region.getEnd() - offset; if (count <= 0) return; replaceSource(flatNode, offset, count, null); }
/** */ private void replaceTailingSpaces(IStructuredDocumentRegion flatNode, ITextRegion region, String spaces) { int offset = region.getTextEnd(); int count = region.getEnd() - offset; if (count == spaces.length()) { String source = flatNode.getFullText(region); if (source != null && source.endsWith(spaces)) { // nothing to do return; } } replaceSource(flatNode, offset, count, spaces); } }
/** */ private void compressTailingSpaces(IStructuredDocumentRegion flatNode, ITextRegion region) { int offset = region.getTextEnd(); int count = region.getEnd() - offset; if (count == 1) { String source = flatNode.getFullText(region); int start = region.getStart(); if (source != null && source.charAt(offset - start) == ' ') { // nothing to do return; } } replaceSource(flatNode, offset, count, " ");//$NON-NLS-1$ }
public int getTextEndOffset() { ITextRegion region = regions.get(regions.size() - 1); // our startOffset take into account our parent, and our start // (pa) 10/4 changed to be based on text end // it used to return incorrect value for embedded region containers // // TODO CRITICAL -- need to re-work this work around, so doesn't // depend on XMLRegionContext // // this is a workaround for 226823/////////// // for (int i = regions.size() - 1; i >= 0 && region.getType() == // XMLRegionContext.WHITE_SPACE; i--) // region = (ITextRegion) regions.get(i); // ///////////////////////////////////////////// return getStartOffset() + region.getTextEnd(); }
protected String getAttributeValue(String attrName, IStructuredDocumentRegion sdRegion) { String sdRegionText = fTextToParse.substring(sdRegion.getStartOffset(), sdRegion.getEndOffset()); String textRegionText, attrValue = ""; //$NON-NLS-1$ Iterator it = sdRegion.getRegions().iterator(); ITextRegion nameRegion, valueRegion = null; while (it.hasNext()) { nameRegion = (ITextRegion) it.next(); if (nameRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) { textRegionText = sdRegionText.substring(nameRegion.getStart(), nameRegion.getTextEnd()); if (textRegionText.equalsIgnoreCase(attrName)) { while (it.hasNext()) { valueRegion = (ITextRegion) it.next(); if (valueRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) { attrValue = sdRegionText.substring(valueRegion.getStart(), valueRegion.getEnd()); break; // inner } } break; // outer } } } return StringUtils.stripQuotes(attrValue); }
/** * Returns the end of the word on which code assist was invoked * * @return * @throws BadLocationException */ public int getPrefixEnd() throws BadLocationException { ITextRegion phpToken = getTwigToken(); int endOffset = regionCollection.getStartOffset() + twigScriptRegion.getStart() + phpToken.getTextEnd(); if (phpToken.getType() == PHPRegionTypes.PHP_CONSTANT_ENCAPSED_STRING) { --endOffset; } return endOffset; }
public int getTextEndOffset(ITextRegion containedRegion) { int result = 0; if (regions != null) { int length = getRegions().size(); for (int i = 0; i < length; i++) { ITextRegion region = getRegions().get(i); if (region == containedRegion) { result = getStartOffset(region) + region.getTextEnd(); break; } } } return result; }
end += valueRegion.getTextEnd(); end += equalRegion.getTextEnd(); start += equalRegion.getTextEnd(); start += nameRegion.getTextEnd(); value = '=' + value;
static public boolean canHandleAsWhiteSpace(ITextRegion region, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) { // we don't explect a null parent, but just in case! // (in which case, we must be dealing with regions that are // structuredDocumentRegions). if (parent == null) return canHandleAsWhiteSpace(region, changes, requestStart, lengthToReplace); boolean result = false; // if we are in the "white space" area of a region, then // we don't want to handle, a reparse is needed. // the white space region is consider anywhere that would // leave whitespace between this character and the text part. // and of course, we can insert whitespace in whitespace region // // if there is no whitespace in this region, no need to look further if (region.getEnd() > region.getTextEnd()) { // no need to add one to end of text, as we used to, since we // change definition of length to equate to offset plus one. if (requestStart > parent.getTextEndOffset(region)) { // ok, we are in the whitespace region, so we can't handle, // unless // we are just inserting whitespace. if (allWhiteSpace(changes)) { result = true; } else { result = false; } } } return result; }
protected void processElementAttrValueDoubleClicked2Times() { int prevRegionOffset = fStructuredDocumentRegion.getStartOffset(fTextRegion) - 1; ITextRegion prevRegion = fStructuredDocumentRegion.getRegionAtCharacterOffset(prevRegionOffset); if (prevRegion != null) { prevRegionOffset = fStructuredDocumentRegion.getStartOffset(prevRegion) - 1; prevRegion = fStructuredDocumentRegion.getRegionAtCharacterOffset(prevRegionOffset); if ((prevRegion != null) && (prevRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME)) { fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStartOffset(prevRegion), fTextRegion.getTextEnd() - prevRegion.getStart()); } } }
if ((region.getStart() >= region.getTextEnd()) || (Math.abs(lengthToReplace) >= region.getTextEnd() - region.getStart())) { canHandle = false; } else {
start += nameRegion.getStart(); end += nameRegion.getTextEnd();
protected void processElementAttrEqualsDoubleClicked2Times() { int prevRegionOffset = fStructuredDocumentRegion.getStartOffset(fTextRegion) - 1; ITextRegion prevRegion = fStructuredDocumentRegion.getRegionAtCharacterOffset(prevRegionOffset); int nextRegionOffset = fStructuredDocumentRegion.getEndOffset(fTextRegion); ITextRegion nextRegion = fStructuredDocumentRegion.getRegionAtCharacterOffset(nextRegionOffset); if ((prevRegion != null) && (prevRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) && (nextRegion != null) && (nextRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE)) { fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStartOffset(prevRegion), nextRegion.getTextEnd() - prevRegion.getStart()); } }
start += prevRegion.getTextEnd(); continue; int regionEnd = region.getEnd(); if (regionEnd == region.getTextEnd()) insertSpace = true; attrStart = regionEnd;
protected void processElementAttrNameDoubleClicked2Times() { int nextRegionOffset = fStructuredDocumentRegion.getEndOffset(fTextRegion); ITextRegion nextRegion = fStructuredDocumentRegion.getRegionAtCharacterOffset(nextRegionOffset); if (nextRegion != null) { nextRegionOffset = fStructuredDocumentRegion.getEndOffset(nextRegion); nextRegion = fStructuredDocumentRegion.getRegionAtCharacterOffset(nextRegionOffset); if ((nextRegion != null) && (nextRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE)) { fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStartOffset(fTextRegion), nextRegion.getTextEnd() - fTextRegion.getStart()); } else { // attribute has no value fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStart(), fStructuredDocumentRegion.getLength()); fDoubleClickCount = 0; } } }
startOffset = region.getEnd(); } else if (type == endType && prevRegion != null) { endOffset = prevRegion.getTextEnd();