本文整理汇总了Java中org.eclipse.wst.sse.core.internal.provisional.IndexedRegion.contains方法的典型用法代码示例。如果您正苦于以下问题:Java IndexedRegion.contains方法的具体用法?Java IndexedRegion.contains怎么用?Java IndexedRegion.contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.wst.sse.core.internal.provisional.IndexedRegion
的用法示例。
在下文中一共展示了IndexedRegion.contains方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLengthToReformatAfter
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; //导入方法依赖的package包/类
/**
*
* @return int
* @param node
* org.eclipse.wst.css.core.model.interfaces.IJSONNode
* @param insertPos
* int
*/
public int getLengthToReformatAfter(IJSONNode node, int insertPos) {
if (node == null)
return 0;
IndexedRegion nnode = (IndexedRegion) node;
if (insertPos < 0 || !nnode.contains(insertPos)) {
if (node.getParentNode() != null && nnode.getEndOffset() <= 0) {
IJSONSourceGenerator pntFormatter = getParentFormatter(node);
if (pntFormatter != null)
return pntFormatter.getLengthToReformatAfter(
node.getParentNode(), insertPos);
}
return 0;
}
return super.getLengthToReformatAfter(node, insertPos);
}
示例2: getLengthToReformatBefore
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; //导入方法依赖的package包/类
/**
*
* @return int
* @param node
* org.eclipse.wst.css.core.model.interfaces.IJSONNode
* @param insertPos
* int
*/
public int getLengthToReformatBefore(IJSONNode node, int insertPos) {
if (node == null)
return 0;
IndexedRegion nnode = (IndexedRegion) node;
if (insertPos <= 0 || !nnode.contains(insertPos - 1)) {
if (node.getParentNode() != null && nnode.getEndOffset() <= 0) {
IJSONSourceGenerator pntFormatter = getParentFormatter(node);
if (pntFormatter != null)
return pntFormatter.getLengthToReformatBefore(
node.getParentNode(), insertPos);
}
return 0;
}
return super.getLengthToReformatBefore(node, insertPos);
}
示例3: getAttrByOffset
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; //导入方法依赖的package包/类
/**
* Returns the SSE DOM Attribute {@link IDOMAttr} by offset from the SSE DOM
* node {@link IDOMNode}.
*
* @param E
* the SSE DOM element {@link IDOMElement}.
* @param region
* the region.
* @return
*/
public static final IDOMAttr getAttrByOffset(Node node, int offset) {
if ((node instanceof IndexedRegion) && ((IndexedRegion) node).contains(offset) && node.hasAttributes()) {
NamedNodeMap attrs = node.getAttributes();
for (int i = 0; i < attrs.getLength(); i++) {
IndexedRegion attRegion = (IndexedRegion) attrs.item(i);
if (attRegion.contains(offset))
return (IDOMAttr) attrs.item(i);
}
}
return null;
}
示例4: getLengthToReformatAfter
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; //导入方法依赖的package包/类
/**
*
* @return int
* @param node
* org.eclipse.wst.css.core.model.interfaces.IJSONNode
* @param insertPos
* int
*/
public int getLengthToReformatAfter(IJSONNode node, int insertPos) {
if (node == null)
return 0;
IndexedRegion nnode = (IndexedRegion) node;
if (insertPos < 0 || !nnode.contains(insertPos))
return 0;
IStructuredDocumentRegion flatNode = node.getOwnerDocument().getModel()
.getStructuredDocument().getRegionAtCharacterOffset(insertPos);
if (flatNode == null)
return 0;
ITextRegion region = flatNode.getRegionAtCharacterOffset(insertPos);
if (region == null)
return 0;
RegionIterator it = new RegionIterator(flatNode, region);
boolean found = false;
while (it.hasNext()) {
region = it.next();
// if (region.getType() != JSONRegionContexts.WHITE_SPACE &&
// region.getType() != JSONRegionContexts.JSON_DELIMITER &&
// region.getType() !=
// JSONRegionContexts.JSON_DECLARATION_DELIMITER) {
if (region.getType() != JSONRegionContexts.WHITE_SPACE) {
found = true;
break;
}
}
int pos = (found ? it.getStructuredDocumentRegion().getStartOffset(
region) : it.getStructuredDocumentRegion().getTextEndOffset(
region))
- insertPos;
return (pos >= 0) ? pos : 0;
}
示例5: getAttrByOffset
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; //导入方法依赖的package包/类
private static IDOMAttr getAttrByOffset(IndexedRegion node, int offset) {
NamedNodeMap attrs = ((IDOMNode) node).getAttributes();
if (attrs == null) {
// see
// https://github.com/angelozerr/eclipse-wtp-webresources/issues/34
return null;
}
for (int i = 0; i < attrs.getLength(); i++) {
IndexedRegion attRegion = (IndexedRegion) attrs.item(i);
if (attRegion.contains(offset))
return (IDOMAttr) attrs.item(i);
}
return null;
}
示例6: getAttrByOffset
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; //导入方法依赖的package包/类
/**
* Returns the SSE DOM Attribute {@link IDOMAttr} by offset from the SSE DOM
* node {@link IDOMNode}.
*
* @param E
* the SSE DOM element {@link IDOMElement}.
* @param region
* the region.
* @return
*/
public static final IDOMAttr getAttrByOffset(Node node, int offset) {
if ((node instanceof IndexedRegion)
&& ((IndexedRegion) node).contains(offset)
&& node.hasAttributes()) {
NamedNodeMap attrs = node.getAttributes();
for (int i = 0; i < attrs.getLength(); i++) {
IndexedRegion attRegion = (IndexedRegion) attrs.item(i);
if (attRegion.contains(offset))
return (IDOMAttr) attrs.item(i);
}
}
return null;
}
示例7: getLengthToReformatBefore
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; //导入方法依赖的package包/类
/**
*
* @return int
* @param node
* org.eclipse.wst.css.core.model.interfaces.IJSONNode
* @param insertPos
* int
*/
public int getLengthToReformatBefore(IJSONNode node, int insertPos) {
if (node == null)
return 0;
IndexedRegion nnode = (IndexedRegion) node;
if (insertPos <= 0 || !nnode.contains(insertPos - 1))
return 0;
IStructuredDocumentRegion flatNode = node.getOwnerDocument().getModel()
.getStructuredDocument()
.getRegionAtCharacterOffset(insertPos - 1);
if (flatNode == null)
return 0;
ITextRegion region = flatNode.getRegionAtCharacterOffset(insertPos - 1);
if (region == null)
return 0;
RegionIterator it = new RegionIterator(flatNode, region);
boolean found = false;
while (it.hasPrev()) {
region = it.prev();
// if (region.getType() != JSONRegionContexts.WHITE_SPACE &&
// region.getType() != JSONRegionContexts.JSON_DELIMITER &&
// region.getType() !=
// JSONRegionContexts.JSON_DECLARATION_DELIMITER) {
if (region.getType() != JSONRegionContexts.WHITE_SPACE) {
found = true;
break;
}
}
int pos = insertPos
- (found ? it.getStructuredDocumentRegion().getTextEndOffset(
region) : it.getStructuredDocumentRegion()
.getStartOffset(region));
// flatNode = it.getStructuredDocumentRegion();
// if (found) {
// if (region.getLength() != region.getTextLength()) {
// pos = insertPos - flatNode.getTextEndOffset(region);
// } else {
// pos = insertPos - flatNode.getEndOffset(region);
// }
// } else {
// pos = insertPos - flatNode.getStartOffset(region);
// }
return (pos >= 0) ? pos : 0;
}