本文整理汇总了Java中org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion.getStart方法的典型用法代码示例。如果您正苦于以下问题:Java IStructuredDocumentRegion.getStart方法的具体用法?Java IStructuredDocumentRegion.getStart怎么用?Java IStructuredDocumentRegion.getStart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion
的用法示例。
在下文中一共展示了IStructuredDocumentRegion.getStart方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getStartOffset
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
/**
* getStartOffset method
*
* @return int
*/
public int getStartOffset() {
if (this.flatNode != null)
return this.flatNode.getStart();
JSONNodeImpl prev = (JSONNodeImpl) getPreviousSibling();
if (prev != null)
return prev.getEndOffset();
IJSONNode parent = getParentNode();
if (parent != null && parent.getNodeType() == IJSONNode.OBJECT_NODE) {
JSONObjectImpl element = (JSONObjectImpl) parent;
if (element.hasStartTag())
return element.getStartEndOffset();
return element.getStartOffset();
}
// final fallback to look into first child
JSONNodeImpl child = (JSONNodeImpl) getFirstChild();
while (child != null) {
IStructuredDocumentRegion childStructuredDocumentRegion = child
.getStructuredDocumentRegion();
if (childStructuredDocumentRegion != null)
return childStructuredDocumentRegion.getStart();
child = (JSONNodeImpl) child.getFirstChild();
}
return 0;
}
示例2: changeAttrName
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
/**
* changeAttrName method
*
*/
private void changeAttrName(IStructuredDocumentRegion flatNode,
ITextRegion region) {
int offset = flatNode.getStart();
if (offset < 0)
return;
JSONNodeImpl root = (JSONNodeImpl) this.context.getRootNode();
if (root == null)
return;
IJSONNode node = root.getNodeAt(offset);
if (node == null)
return;
if (node.getNodeType() != IJSONNode.PAIR_NODE) {
return;
}
JSONPairImpl pair = (JSONPairImpl) node;
String name = flatNode.getText(region);
pair.setName(name);
/*
* List<IJSONPair> attributes = element.getPairs(); if (attributes ==
* null) return; for (IJSONPair attr : attributes) { if (((JSONPairImpl)
* attr).getNameRegion() != region) continue;
*
* String name = flatNode.getText(region); ((JSONPairImpl)
* attr).setName(name); break; }
*/
}
示例3: getStart
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
/**
*/
public int getStart() {
IStructuredDocumentRegion first = getFirstStructuredDocumentRegion();
if (first == null)
return 0;
return first.getStart();
}
示例4: setStructuredDocumentRegion
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
/**
*/
void setStructuredDocumentRegion(IStructuredDocumentRegion flatNode) {
if (this.flatNode != null)
this.offset += this.flatNode.getStart();
this.flatNode = flatNode;
if (this.flatNode != null)
this.offset -= flatNode.getStart();
}
示例5: changeEndTag
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
/**
*/
private void changeEndTag(IStructuredDocumentRegion flatNode,
ITextRegionList newRegions, ITextRegionList oldRegions) {
int offset = flatNode.getStart();
if (offset < 0)
return; // error
JSONNodeImpl root = (JSONNodeImpl) this.context.getRootNode();
if (root == null)
return; // error
IJSONNode node = root.getNodeAt(offset);
if (node == null)
return; // error
if (node.getNodeType() != IJSONNode.OBJECT_NODE) {
changeStructuredDocumentRegion(flatNode);
return;
}
// check if change is only for close tag
// if (newRegions != null) {
// Iterator e = newRegions.iterator();
// while (e.hasNext()) {
// ITextRegion region = (ITextRegion) e.next();
// String regionType = region.getType();
// if (regionType == JSONRegionContexts.JSON_TAG_CLOSE)
// continue;
//
// // other region has changed
// changeStructuredDocumentRegion(flatNode);
// return;
// }
// }
// if (oldRegions != null) {
// Iterator e = oldRegions.iterator();
// while (e.hasNext()) {
// ITextRegion region = (ITextRegion) e.next();
// String regionType = region.getType();
// if (regionType == JSONRegionContexts.JSON_TAG_CLOSE)
// continue;
//
// // other region has changed
// changeStructuredDocumentRegion(flatNode);
// return;
// }
// }
// change for close tag has no impact
// do nothing
}
示例6: setupContext
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
/**
* setupContext method
*
*/
private void setupContext(
IStructuredDocumentRegion startStructuredDocumentRegion) {
int offset = startStructuredDocumentRegion.getStart();
if (offset < 0)
return;
JSONNodeImpl root = (JSONNodeImpl) this.context.getRootNode();
if (root == null)
return;
if (offset == 0) {
// at the beginning of document
IJSONNode child = root.getFirstChild();
if (child != null)
this.context.setNextNode(child);
else
this.context.setParentNode(root);
return;
}
JSONNodeImpl node = (JSONNodeImpl) root.getNodeAt(offset);
if (node == null) {
// might be at the end of document
this.context.setParentNode(root);
this.context.setLast();
return;
}
if (offset == node.getStartOffset()) {
this.context.setNextNode(node);
return;
}
// if (node.getNodeType() == Node.TEXT_NODE) {
// TextImpl text = (TextImpl) node;
// Text nextText = text.splitText(startStructuredDocumentRegion);
// // notify the change
// text.notifyValueChanged();
// if (nextText == null)
// return; // error
// this.context.setNextNode(nextText);
// return;
// }
for (IJSONNode child = node.getFirstChild(); child != null; child = child
.getNextSibling()) {
if (offset >= ((JSONNodeImpl) child).getEndOffset())
continue;
this.context.setNextNode(child);
return;
}
this.context.setParentNode(node);
this.context.setLast();
}