本文整理汇总了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;
}
示例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();
}
示例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;
}