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


Java IStructuredDocumentRegion.getRegionAtCharacterOffset方法代码示例

本文整理汇总了Java中org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion.getRegionAtCharacterOffset方法的典型用法代码示例。如果您正苦于以下问题:Java IStructuredDocumentRegion.getRegionAtCharacterOffset方法的具体用法?Java IStructuredDocumentRegion.getRegionAtCharacterOffset怎么用?Java IStructuredDocumentRegion.getRegionAtCharacterOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion的用法示例。


在下文中一共展示了IStructuredDocumentRegion.getRegionAtCharacterOffset方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: computeHoverHelp

import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
/**
 * Retrieves documentation to display in the hover help popup.
 * 
 * @return String any documentation information to display <code>null</code>
 *         if there is nothing to display.
 * 
 */
protected String computeHoverHelp(ITextViewer textViewer,
		int documentPosition) {
	String result = null;

	IndexedRegion treeNode = ContentAssistUtils.getNodeAt(textViewer,
			documentPosition);
	if (treeNode == null) {
		return null;
	}
	IJSONNode node = (IJSONNode) treeNode;
	IJSONNode parentNode = node.getParentNode();

	IStructuredDocumentRegion flatNode = ((IStructuredDocument) textViewer
			.getDocument()).getRegionAtCharacterOffset(documentPosition);
	if (flatNode != null) {
		ITextRegion region = flatNode
				.getRegionAtCharacterOffset(documentPosition);
		if (region != null) {
			result = computeRegionHelp(treeNode, parentNode, flatNode,
					region);
		}
	}

	return result;
}
 
开发者ID:angelozerr,项目名称:eclipse-wtp-json,代码行数:33,代码来源:JSONHoverProcessor.java

示例2: getChildInsertPos

import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
/**
	 * 
	 */
	public int getChildInsertPos(IJSONNode node) {
		int n = ((IndexedRegion) node).getEndOffset();
		if (n > 0) {
			IStructuredDocument structuredDocument = node.getOwnerDocument()
					.getModel().getStructuredDocument();
			IStructuredDocumentRegion flatNode = structuredDocument
					.getRegionAtCharacterOffset(n - 1);
			ITextRegion region = flatNode.getRegionAtCharacterOffset(n - 1);
			RegionIterator it = new RegionIterator(flatNode, region);
			while (it.hasPrev()) {
				ITextRegion reg = it.prev();
//				if (reg.getType() == JSONRegionContexts.JSON_CDC)
//					return it.getStructuredDocumentRegion().getStartOffset(reg);
			}
			return n;
		}
		return -1;
	}
 
开发者ID:angelozerr,项目名称:eclipse-wtp-json,代码行数:22,代码来源:JSONDocumentFormatter.java

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

示例4: getNamedStyleAtOffset

import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
private String getNamedStyleAtOffset(int offset) {
	// ensure the offset is clean
	if (offset >= fDocument.getLength())
		return getNamedStyleAtOffset(fDocument.getLength() - 1);
	else if (offset < 0)
		return getNamedStyleAtOffset(0);
	IStructuredDocumentRegion documentRegion = fDocument
			.getFirstStructuredDocumentRegion();
	while (documentRegion != null && !documentRegion.containsOffset(offset)) {
		documentRegion = documentRegion.getNext();
	}
	if (documentRegion != null) {
		// find the ITextRegion's Context at this offset
		ITextRegion interest = documentRegion
				.getRegionAtCharacterOffset(offset);
		if (interest == null)
			return null;
		if (offset > documentRegion.getTextEndOffset(interest))
			return null;
		String regionContext = interest.getType();
		if (regionContext == null)
			return null;
		// find the named style (internal/selectable name) for that
		// context
		String namedStyle = (String) fContextToStyleMap.get(regionContext);
		if (namedStyle != null) {
			return namedStyle;
		}
	}
	return null;
}
 
开发者ID:angelozerr,项目名称:eclipse-wtp-json,代码行数:32,代码来源:JSONSyntaxColoringPage.java

示例5: getLengthToReformatAfter

import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的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

示例6: getNamedStyleAtOffset

import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的package包/类
private String getNamedStyleAtOffset(int offset) {
	IDOMModel model = null;
	IStructuredDocument document = null;
	try {
		model = getDomModel();
		document = model.getStructuredDocument();
		// ensure the offset is clean
		if (offset >= document.getLength())
			return getNamedStyleAtOffset(document.getLength() - 1);
		else if (offset < 0)
			return getNamedStyleAtOffset(0);
		IStructuredDocumentRegion documentRegion = document.getFirstStructuredDocumentRegion();
		while (documentRegion != null && !documentRegion.containsOffset(offset)) {
			documentRegion = documentRegion.getNext();
		}
		if (documentRegion != null) {
			// find the ITextRegion's Context at this offset
			ITextRegion interest = documentRegion.getRegionAtCharacterOffset(offset);
			if (interest == null)
				return null;
			if (offset > documentRegion.getTextEndOffset(interest))
				return null;
			String regionContext = interest.getType();
			if (regionContext == null)
				return null;
			// find the named style (internal/selectable name) for that
			// context
			String namedStyle = (String) fContextToStyleMap.get(regionContext);
			if (namedStyle != null) {
				return namedStyle;
			}
		}
	} catch (IOException e) {
		Trace.trace(Trace.SEVERE, "Error while loading DOM.", e);
	} finally {
		if (model != null) {
			model.releaseFromRead();
		}
	}
	return null;
}
 
开发者ID:angelozerr,项目名称:angular-eclipse,代码行数:42,代码来源:HTMLAngularEditorSyntaxColoringPreferencePage.java

示例7: getLengthToReformatBefore

import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; //导入方法依赖的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.text.IStructuredDocumentRegion.getRegionAtCharacterOffset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。