当前位置: 首页>>代码示例>>Java>>正文


Java IndexedRegion.contains方法代码示例

本文整理汇总了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);
}
 
开发者ID:angelozerr,项目名称:eclipse-wtp-json,代码行数:24,代码来源:JSONPairFormatter.java

示例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);
}
 
开发者ID:angelozerr,项目名称:eclipse-wtp-json,代码行数:24,代码来源:JSONPairFormatter.java

示例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;
}
 
开发者ID:angelozerr,项目名称:angular-eclipse,代码行数:23,代码来源:DOMUtils.java

示例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;
}
 
开发者ID:angelozerr,项目名称:eclipse-wtp-json,代码行数:42,代码来源:AbstractJSONSourceFormatter.java

示例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;
}
 
开发者ID:angelozerr,项目名称:eclipse-wtp-webresources,代码行数:15,代码来源:DOMHelper.java

示例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;
}
 
开发者ID:angelozerr,项目名称:angularjs-eclipse,代码行数:25,代码来源:DOMUtils.java

示例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;
}
 
开发者ID:angelozerr,项目名称:eclipse-wtp-json,代码行数:53,代码来源:AbstractJSONSourceFormatter.java


注:本文中的org.eclipse.wst.sse.core.internal.provisional.IndexedRegion.contains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。