本文整理汇总了Java中org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion.getStartOffset方法的典型用法代码示例。如果您正苦于以下问题:Java IStructuredDocumentRegion.getStartOffset方法的具体用法?Java IStructuredDocumentRegion.getStartOffset怎么用?Java IStructuredDocumentRegion.getStartOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion
的用法示例。
在下文中一共展示了IStructuredDocumentRegion.getStartOffset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMatchString
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
private String getMatchString(IStructuredDocumentRegion parent,
ITextRegion aRegion, int offset) {
if (aRegion == null) {
return "";
}
String regionType = aRegion.getType();
if (regionType != JSONRegionContexts.JSON_OBJECT_KEY) {
return "";
}
if ((parent.getText(aRegion).length() > 0)
&& (parent.getStartOffset(aRegion) < offset)) {
return parent.getText(aRegion).substring(0,
offset - parent.getStartOffset(aRegion));
}
return "";
}
示例2: consumesElement
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
private List<Position> consumesElement(IStructuredDocumentRegion region) {
List<Position> positions = null;
ITextRegionList regionList = region.getRegions();
for (int i = 0; i < regionList.size(); i++) {
ITextRegion textRegion = regionList.get(i);
if (textRegion.getType().equals(DOMRegionContext.XML_TAG_NAME)) {
Position position = new Position(region.getStartOffset(textRegion), textRegion.getLength());
if (positions == null) {
positions = new ArrayList<Position>();
}
positions.add(position);
}
}
return positions;
}
示例3: computeObjectKeyProposals
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
private ContentAssistRequest computeObjectKeyProposals(String matchString,
ITextRegion completionRegion, IJSONNode nodeAtOffset,
IJSONNode node, CompletionProposalInvocationContext context) {
int documentPosition = context.getInvocationOffset();
ContentAssistRequest contentAssistRequest = null;
IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
int replaceLength = 0;
int begin = documentPosition;
if (completionRegion.getType() == JSONRegionContexts.JSON_OBJECT_KEY) {
replaceLength = completionRegion.getTextLength();
// if container region, be sure replace length is only the attribute
// value region not the entire container
if (completionRegion instanceof ITextRegionContainer) {
ITextRegion openRegion = ((ITextRegionContainer) completionRegion)
.getFirstRegion();
ITextRegion closeRegion = ((ITextRegionContainer) completionRegion)
.getLastRegion();
if (openRegion.getType() != closeRegion.getType()) {
replaceLength = openRegion.getTextLength();
}
}
begin = sdRegion.getStartOffset(completionRegion);
}
contentAssistRequest = new ContentAssistRequest(nodeAtOffset,
node.getParentNode(), sdRegion, completionRegion, begin,
replaceLength, matchString);
addObjectKeyProposals(contentAssistRequest, context);
return contentAssistRequest;
}
示例4: calcNewFoldPosition
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
/**
* @see org.eclipse.wst.sse.ui.internal.projection.AbstractFoldingStrategy#calcNewFoldPosition(org.eclipse.wst.sse.core.internal.provisional.IndexedRegion)
*/
protected Position calcNewFoldPosition(IndexedRegion indexedRegion) {
Position retPos = null;
// only want to fold regions of the valid type and with a valid range
if (indexedRegion.getStartOffset() >= 0
&& indexedRegion.getLength() >= 0) {
IJSONNode node = (IJSONNode) indexedRegion;
IStructuredDocumentRegion startRegion = node
.getStartStructuredDocumentRegion();
IStructuredDocumentRegion endRegion = node
.getEndStructuredDocumentRegion();
// if the node has an endRegion (end tag) then folding region is
// between the start and end tag
// else if the region is a comment
// else if the region is only an open tag or an open/close tag then
// don't fold it
if (startRegion != null && endRegion != null) {
if (endRegion.getEndOffset() >= startRegion.getStartOffset())
retPos = new JSONObjectFoldingPosition(startRegion,
endRegion);
}
// else if(startRegion != null && indexedRegion instanceof
// CommentImpl) {
// retPos = new JSONCommentFoldingPosition(startRegion);
// }
}
return retPos;
}
示例5: getHoverRegion
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
@Override
public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
if ((textViewer == null) || (textViewer.getDocument() == null)) {
return null;
}
IStructuredDocumentRegion flatNode = ((IStructuredDocument) textViewer
.getDocument()).getRegionAtCharacterOffset(offset);
ITextRegion region = null;
if (flatNode != null) {
region = flatNode.getRegionAtCharacterOffset(offset);
}
if (region != null) {
// only supply hoverhelp for object key, or simple JSON value
String regionType = region.getType();
if ((regionType == JSONRegionContexts.JSON_OBJECT_KEY)
|| JSONUtil.isJSONSimpleValue(regionType)) {
try {
// check if we are at whitespace before or after line
IRegion line = textViewer.getDocument()
.getLineInformationOfOffset(offset);
if ((offset > (line.getOffset()))
&& (offset < (line.getOffset() + line.getLength()))) {
// check if we are in region's trailing whitespace
// (whitespace after relevant info)
if (offset < flatNode.getTextEndOffset(region)) {
return new Region(flatNode.getStartOffset(region),
region.getTextLength());
}
}
} catch (BadLocationException e) {
Logger.logException(e);
}
}
}
return null;
}
示例6: applyStyles
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
/**
* Color the text in the sample area according to the current preferences
*/
void applyStyles() {
if (fText == null || fText.isDisposed())
return;
IStructuredDocumentRegion documentRegion = fDocument
.getFirstStructuredDocumentRegion();
while (documentRegion != null) {
ITextRegionList regions = documentRegion.getRegions();
for (int i = 0; i < regions.size(); i++) {
ITextRegion currentRegion = regions.get(i);
// lookup the local coloring type and apply it
String namedStyle = (String) fContextToStyleMap
.get(currentRegion.getType());
if (namedStyle == null)
continue;
TextAttribute attribute = getAttributeFor(namedStyle);
if (attribute == null)
continue;
StyleRange style = new StyleRange(
documentRegion.getStartOffset(currentRegion),
currentRegion.getTextLength(),
attribute.getForeground(), attribute.getBackground(),
attribute.getStyle());
style.strikeout = (attribute.getStyle() & TextAttribute.STRIKETHROUGH) != 0;
style.underline = (attribute.getStyle() & TextAttribute.UNDERLINE) != 0;
fText.setStyleRange(style);
}
documentRegion = documentRegion.getNext();
}
}
示例7: getRegionsWithoutWhiteSpaces
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
/**
*
*/
protected CompoundRegion[] getRegionsWithoutWhiteSpaces(
IStructuredDocument model, IRegion reg, IJSONCleanupStrategy stgy) {
int start = reg.getOffset();
int end = reg.getOffset() + reg.getLength() - 1;
ArrayList list = new ArrayList();
IStructuredDocumentRegion flatNode = model
.getRegionAtCharacterOffset(start);
while (flatNode != null && flatNode.getStartOffset() <= end) {
ITextRegionList regionList = flatNode.getRegions();
Iterator it = regionList.iterator();
while (it.hasNext()) {
ITextRegion region = (ITextRegion) it.next();
if (flatNode.getStartOffset(region) < start)
continue;
if (end < flatNode.getStartOffset(region))
break;
if (region.getType() != JSONRegionContexts.WHITE_SPACE
|| (isCleanup() && !stgy.isFormatSource())) // for
// not
// formatting
// case
// on
// cleanup
// action
list.add(new CompoundRegion(flatNode, region));
}
flatNode = flatNode.getNext();
}
if (list.size() > 0) {
CompoundRegion[] regions = new CompoundRegion[list.size()];
list.toArray(regions);
return regions;
}
return new CompoundRegion[0];
}
示例8: changeRegion
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
/**
* changeName method
*
* @param node
* org.w3c.dom.Node
*/
// void changeName(Node node) {
// if (node == null)
// return;
// if (getStructuredDocument() == null)
// return;
//
// // support changing name of attribute for setPrefix()
// short nodeType = node.getNodeType();
// if (nodeType == Node.ATTRIBUTE_NODE) {
// changeAttrName((Attr) node);
// return;
// }
//
// // not supported
// return;
// }
void changeRegion(RegionChangedEvent change,
IStructuredDocumentRegion flatNode, ITextRegion region) {
if (change.getOffset() >= flatNode.getStartOffset()
+ region.getTextEnd()) {
// change is entirely in white-space
return;
}
JSONNodeImpl root = (JSONNodeImpl) this.model.getDocument();
this.parentNode = root;
this.nextNode = (JSONNodeImpl) root.getFirstChild();
removeGapStructuredDocumentRegion(flatNode);
insertGapStructuredDocumentRegionBefore(flatNode.getStart());
changeStructuredDocumentRegion(flatNode);
insertGapStructuredDocumentRegionAfter(flatNode.getEnd());
}
示例9: findNodeBackward
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
/**
*
*/
public static IStructuredDocumentRegion findNodeBackward(
IStructuredDocumentRegion startNode,
IStructuredDocumentRegion endNode, String type) {
IStructuredDocumentRegion node;
for (node = startNode; node != null; node = node.getPrevious()) {
if (node.getStartOffset() < endNode.getStartOffset()) {
node = null;
break;
} else if (getStructuredDocumentRegionType(node) == type) {
break;
}
}
return node;
}
示例10: findNodeForward
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
/**
*
*/
public static IStructuredDocumentRegion findNodeForward(
IStructuredDocumentRegion startNode,
IStructuredDocumentRegion endNode, String type) {
IStructuredDocumentRegion node;
for (node = startNode; node != null; node = node.getNext()) {
if (endNode.getStartOffset() < node.getStartOffset()) {
node = null;
break;
} else if (getStructuredDocumentRegionType(node) == type) {
break;
}
}
return node;
}
示例11: applyStyles
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
/**
* Color the text in the sample area according to the current preferences
*/
void applyStyles() {
if (fText == null || fText.isDisposed())
return;
IStructuredModel model = null;
try {
model = getDomModel();
IStructuredDocumentRegion documentRegion = model.getStructuredDocument().getFirstStructuredDocumentRegion();
while (documentRegion != null) {
ITextRegionList regions = documentRegion.getRegions();
for (int i = 0; i < regions.size(); i++) {
ITextRegion currentRegion = regions.get(i);
// lookup the local coloring type and apply it
String namedStyle = (String) fContextToStyleMap.get(currentRegion.getType());
if (namedStyle == null)
continue;
TextAttribute attribute = getAttributeFor(namedStyle);
if (attribute == null)
continue;
StyleRange style = new StyleRange(documentRegion.getStartOffset(currentRegion),
currentRegion.getTextLength(), attribute.getForeground(), attribute.getBackground(),
attribute.getStyle());
style.strikeout = (attribute.getStyle() & TextAttribute.STRIKETHROUGH) != 0;
style.underline = (attribute.getStyle() & TextAttribute.UNDERLINE) != 0;
fText.setStyleRange(style);
Position[] positions = null;
for (AbstractAngularSemanticHighlighting highlighting : SemanticHighlightingManager.getInstance()
.getHighlightings()) {
positions = highlighting.consumes(documentRegion,
model.getIndexedRegion(documentRegion.getStartOffset()));
if (positions != null) {
for (int j = 0; j < positions.length; j++) {
Position position = positions[j];
StyleRange styleRange = createStyleRange(
getAttributeFor(highlighting.getStyleStringKey()), position);
fText.setStyleRange(styleRange);
}
}
}
}
documentRegion = documentRegion.getNext();
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (model != null) {
model.releaseFromRead();
}
}
}
开发者ID:angelozerr,项目名称:angular-eclipse,代码行数:56,代码来源:HTMLAngularEditorSyntaxColoringPreferencePage.java
示例12: getElementTagRegions
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
/**
* Finds the text regions (absolute positions within document) for the
* element's start and end tags.
*
* @param element the element whose tag regions are being found
* @param includePrefix whether to include the namespace prefix in the regions
* @return a non-null list of regions, with the start tag's region before the
* end tag's region (if there are two distinct tags)
*/
public static List<IRegion> getElementTagRegions(IDOMElement element,
final boolean includePrefix) {
final List<IRegion> regions = new ArrayList<IRegion>();
final IStructuredDocument doc = element.getStructuredDocument();
DomTextRegionVisitor visitor = new DomTextRegionVisitor() {
public boolean visitDomTextRegion(IDOMNode node,
IStructuredDocumentRegion domRegion, ITextRegion textRegion) {
try {
if (DOMRegionContext.XML_TAG_NAME.equals(textRegion.getType())) {
// DOM region is relative to document, text region is relative to
// the DOM
int nameOffset = domRegion.getStartOffset() + textRegion.getStart();
int nameLength = textRegion.getTextLength();
if (!includePrefix) {
// Lose the namespace prefix
int unprefixedOffset = XmlUtilities.getUnprefixedOffset(doc.get(
nameOffset, nameLength));
nameOffset += unprefixedOffset;
nameLength -= unprefixedOffset;
}
regions.add(new Region(nameOffset, nameLength));
return false;
}
} catch (BadLocationException e) {
// Ignore
}
return true;
}
};
XmlUtilities.visitDomTextRegions(element,
element.getFirstStructuredDocumentRegion(), visitor);
XmlUtilities.visitDomTextRegions(element,
element.getLastStructuredDocumentRegion(), visitor);
return regions;
}
示例13: create
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
/**
* Make sure to call {@link #release()} after you are done!
*
* @return a {@link DtdRemover} or null
*/
private static DtdRemover create(ITextViewer textViewer,
int documentPosition) {
IDocumentPartitionerFactory docPartitionerFactory = new IDocumentPartitionerFactory() {
public IDocumentPartitioner createDocumentPartitioner() {
return new StructuredTextPartitionerForUiBinderXml();
}
};
StructuredDocumentCloner structuredDocumentCloner = new StructuredDocumentCloner(
IXMLPartitions.XML_DEFAULT, docPartitionerFactory);
IStructuredDocument clonedDoc = structuredDocumentCloner.clone(textViewer.getDocument());
if (clonedDoc == null) {
return null;
}
IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(
clonedDoc);
try {
IDOMNode docType = (IDOMNode) model.getDocument().getDoctype();
if (docType == null) {
return null;
}
IStructuredDocumentRegion firstRegion = docType.getFirstStructuredDocumentRegion();
IStructuredDocumentRegion lastRegion = docType.getLastStructuredDocumentRegion();
int firstPos = firstRegion.getStartOffset();
int lastPos = lastRegion.getEndOffset();
int docTypeLen = lastPos - firstPos;
if (docTypeLen == 0 || documentPosition >= firstPos
&& documentPosition <= lastPos) {
return null;
}
try {
clonedDoc.replace(firstPos, docTypeLen,
StringUtilities.repeatCharacter(' ', docTypeLen));
} catch (BadLocationException e) {
GWTPluginLog.logError(e,
"Unexpected bad location while removing doctype");
return null;
}
} finally {
if (model != null) {
model.releaseFromRead();
}
}
return new DtdRemover(new DocumentChangingTextViewer(textViewer,
clonedDoc), documentPosition, structuredDocumentCloner, clonedDoc);
}
示例14: getRegions
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
/**
*
*/
protected CompoundRegion[] getRegions(IStructuredDocument model,
IRegion reg, IRegion exceptFor, String pickupType) {
int start = reg.getOffset();
int end = reg.getOffset() + reg.getLength();
int startE = (exceptFor != null) ? exceptFor.getOffset() : -1;
int endE = (exceptFor != null) ? exceptFor.getOffset()
+ exceptFor.getLength() : 0;
ArrayList list = new ArrayList();
IStructuredDocumentRegion flatNode = model
.getRegionAtCharacterOffset(start);
boolean pickuped = false;
while (flatNode != null && flatNode.getStartOffset() < end) {
ITextRegionList regionList = flatNode.getRegions();
Iterator it = regionList.iterator();
while (it.hasNext()) {
ITextRegion region = (ITextRegion) it.next();
if (flatNode.getStartOffset(region) < start)
continue;
if (end <= flatNode.getStartOffset(region))
break;
if (startE >= 0 && startE <= flatNode.getStartOffset(region)
&& flatNode.getEndOffset(region) <= endE)
continue;
// if (region.getType() == JSONRegionContexts.JSON_COMMENT
// || region.getType() == JSONRegionContexts.JSON_CDC
// || region.getType() == JSONRegionContexts.JSON_CDO)
// list.add(new CompoundRegion(flatNode, region));
// else
if (!pickuped && region.getType() == pickupType) {
list.add(new CompoundRegion(flatNode, region));
pickuped = true;
}
}
flatNode = flatNode.getNext();
}
if (list.size() > 0) {
CompoundRegion[] regions = new CompoundRegion[list.size()];
list.toArray(regions);
return regions;
}
return new CompoundRegion[0];
}
示例15: changeRegion
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
/**
* changeRegion method
*
*/
void changeRegion(RegionChangedEvent change,
IStructuredDocumentRegion flatNode, ITextRegion region) {
if (flatNode == null || region == null)
return;
if (this.model.getDocument() == null)
return;
this.context = new JSONModelContext(this.model.getDocument());
// determine if change was whitespace only change
boolean isWhitespaceChange = false;
if (change.getText() != null && change.getText().length() > 0) {
isWhitespaceChange = Character.isWhitespace(change.getText()
.charAt(0));
} else if (change.getDeletedText() != null
&& change.getDeletedText().length() > 0) {
isWhitespaceChange = Character.isWhitespace(change.getDeletedText()
.charAt(0));
}
if (isWhitespaceChange)
return;
// optimize typical cases
String regionType = region.getType();
/*
* if (regionType == JSONRegionContexts.JSON_CONTENT || regionType ==
* JSONRegionContexts.JSON_COMMENT_TEXT || regionType ==
* JSONRegionContexts.JSON_CDATA_TEXT || regionType ==
* JSONRegionContexts.BLOCK_TEXT || isNestedContent(regionType)) {
* changeData(flatNode, region); } else
*/
if (regionType == JSONRegionContexts.JSON_OBJECT_KEY) {
if (isWhitespaceChange
&& (change.getOffset() >= flatNode.getStartOffset()
+ region.getTextEnd())) {
// change is entirely in white-space
return;
}
changeAttrName(flatNode, region);
}
// else if (regionType == JSONRegionContexts.JSON_TAG_ATTRIBUTE_VALUE) {
// if (isWhitespaceChange
// && (change.getOffset() >= flatNode.getStartOffset()
// + region.getTextEnd())) {
// // change is entirely in white-space
// return;
// }
// changeAttrValue(flatNode, region);
// } else if (regionType ==
// JSONRegionContexts.JSON_TAG_ATTRIBUTE_EQUALS) {
// if (isWhitespaceChange
// && (change.getOffset() >= flatNode.getStartOffset()
// + region.getTextEnd())) {
// // change is entirely in white-space
// return;
// }
// changeAttrEqual(flatNode, region);
// } else if (regionType == JSONRegionContexts.JSON_TAG_NAME
// || isNestedTagName(regionType)) {
// if (isWhitespaceChange
// && (change.getOffset() >= flatNode.getStartOffset()
// + region.getTextEnd())) {
// // change is entirely in white-space
// return;
// }
// changeTagName(flatNode, region);
// }
else {
changeStructuredDocumentRegion(flatNode);
}
}