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


Java ILeafNode.getTotalLength方法代码示例

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


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

示例1: createReversedLeafIterator

import org.eclipse.xtext.nodemodel.ILeafNode; //导入方法依赖的package包/类
private PeekingIterator<ILeafNode> createReversedLeafIterator(INode root, INode candidate, LinkedList<ILeafNode> sameGrammarElement) {
	EObject grammarElement = null;
	PeekingIterator<ILeafNode> iterator = Iterators.peekingIterator(Iterators.filter(root.getAsTreeIterable().reverse().iterator(), ILeafNode.class));
	// traverse until we find the current candidate
	while(iterator.hasNext()) {
		ILeafNode next = iterator.next();
		if (candidate.equals(next)) {
			break;
		} else if (next.getTotalLength() == 0) {
			EObject otherGrammarElement = tryGetGrammarElementAsRule(next);
			if (grammarElement == null) {
				grammarElement = otherGrammarElement;
			}
			if (otherGrammarElement.equals(grammarElement)) {
				sameGrammarElement.add(next);
			} else {
				sameGrammarElement.removeLast();
			}
		}
	}
	return iterator;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:23,代码来源:IndentationAwareCompletionPrefixProvider.java

示例2: doCheckLeafNodeAndReturnLength

import org.eclipse.xtext.nodemodel.ILeafNode; //导入方法依赖的package包/类
protected int doCheckLeafNodeAndReturnLength(ILeafNode leafNode, int startsAt) {
	if (leafNode.getTotalOffset() != startsAt)
		throw new InconsistentNodeModelException("node with unexpected offset");
	return leafNode.getTotalLength();
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:6,代码来源:InvariantChecker.java

示例3: findBestEndToken

import org.eclipse.xtext.nodemodel.ILeafNode; //导入方法依赖的package包/类
protected INode findBestEndToken(INode root, INode candidate, int completionColumn, boolean candidateIsEndToken) {
	LinkedList<ILeafNode> sameGrammarElement = Lists.newLinkedList();
	PeekingIterator<ILeafNode> iterator = createReversedLeafIterator(root, candidate, sameGrammarElement);
	if (!iterator.hasNext()) {
		return candidate;
	}
	// collect all candidates that belong to the same offset
	LinkedList<ILeafNode> sameOffset = candidateIsEndToken ? collectLeafsWithSameOffset((ILeafNode)candidate, iterator) : Lists.newLinkedList();
	// continue until we find a paired leaf with length 0 that is at the correct offset
	EObject grammarElement = tryGetGrammarElementAsRule(candidateIsEndToken || sameGrammarElement.isEmpty() ? candidate : sameGrammarElement.getLast()); 
	ILeafNode result = candidateIsEndToken ? null : (ILeafNode) candidate;
	int sameOffsetSize = sameOffset.size();
	while(iterator.hasNext()) {
		ILeafNode next = iterator.next();
		if (result == null || result.isHidden()) {
			result = next;
		}
		if (next.getTotalLength() == 0) {
			// potential indentation token
			EObject rule = tryGetGrammarElementAsRule(next);
			if (rule != grammarElement) {
				LineAndColumn lineAndColumn = NodeModelUtils.getLineAndColumn(root, next.getTotalOffset());
				if (lineAndColumn.getColumn() <= completionColumn) {
					return result;
				} else {
					if (sameOffset.isEmpty()) {
						if (sameGrammarElement.isEmpty()) {
							result = null;	
						} else {
							result = sameGrammarElement.removeLast();
						}
						
					} else {
						if (sameOffsetSize >= sameOffset.size()) {
							result = sameOffset.removeLast();	
						} else {
							sameOffset.removeLast();
						}
					}
				}
			} else {
				sameOffset.add(next);
			}
		}
	}
	return candidate;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:48,代码来源:IndentationAwareCompletionPrefixProvider.java


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