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


Java ILeafNode.getTotalOffset方法代码示例

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


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

示例1: calculatePartialParsingPointers

import org.eclipse.xtext.nodemodel.ILeafNode; //导入方法依赖的package包/类
protected PartialParsingPointers calculatePartialParsingPointers(ICompositeNode oldRoot, ILeafNode left, ILeafNode right) {
	ICompositeNode result = right.getParent();
	while(result.getTotalOffset() > left.getTotalOffset()) {
		result = result.getParent();
	}
	List<ICompositeNode> nodesEnclosingRegion = getAllParents(result);
	Range range = new Range(left.getTotalOffset(), right.getTotalEndOffset());
	List<ICompositeNode> validReplaceRootNodes = internalFindValidReplaceRootNodeForChangeRegion(nodesEnclosingRegion);

	filterInvalidRootNodes(validReplaceRootNodes);

	if (validReplaceRootNodes.isEmpty()) {
		validReplaceRootNodes = Collections.singletonList(oldRoot);
	}
	return new PartialParsingPointers(oldRoot, range.getOffset(), range.getLength(), validReplaceRootNodes, nodesEnclosingRegion);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:17,代码来源:TokenSequencePreservingPartialParsingHelper.java

示例2: getOffset

import org.eclipse.xtext.nodemodel.ILeafNode; //导入方法依赖的package包/类
@Override
public int getOffset() {
	Iterator<ILeafNode> leafIter = Iterators.filter(basicIterator(), ILeafNode.class);
	int firstLeafOffset = -1;
	while(leafIter.hasNext()) {
		ILeafNode leaf = leafIter.next();
		if (firstLeafOffset == -1) {
			firstLeafOffset = leaf.getTotalOffset();
		}
		if (!leaf.isHidden())
			return leaf.getTotalOffset();
	}
	if (firstLeafOffset != -1)
		return firstLeafOffset;
	return getTotalOffset();
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:17,代码来源:AbstractNode.java

示例3: nextToken

import org.eclipse.xtext.nodemodel.ILeafNode; //导入方法依赖的package包/类
/**
 * Implementation of the {@link TokenSource} interface. Return new tokens as long as there are some, afterwards
 * return {@link Token#EOF_TOKEN}.
 */
@Override
public Token nextToken() {
	if (next != null) {
		Token result = next;
		next = null;
		return result;
	}
	if (!leafNodes.hasNext()) {
		return Token.EOF_TOKEN;
	}
	ILeafNode leaf = leafNodes.next();
	if (leaf.getTotalOffset() >= endOffset) {
		leafNodes = Iterators.emptyIterator();
		return Token.EOF_TOKEN;
	}
	if (leaf.getTotalEndOffset() <= startOffset) {
		return nextToken();
	}
	if (leaf.getTotalEndOffset() > endOffset) {
		return toPrefixToken(leaf);
	}
	SyntaxErrorMessage syntaxErrorMessage = leaf.getSyntaxErrorMessage();
	if (syntaxErrorMessage != null && SEMICOLON_INSERTED.equals(syntaxErrorMessage.getIssueCode())) {
		return toASIToken(leaf);
	}
	if (leaf.isHidden()) {
		return processHiddenToken(leaf);
	}
	int tokenType = tokenTypeMapper.getInternalTokenType(leaf);
	return new CommonToken(tokenType, leaf.getText());
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:36,代码来源:NodeModelTokenSource.java

示例4: findEntryPoint

import org.eclipse.xtext.nodemodel.ILeafNode; //导入方法依赖的package包/类
protected ICompositeNode findEntryPoint(ICompositeNode node, int offset) {
	ICompositeNode result = node;
	result = getApplicableNode(result);
	while (result != null) {
		int remainingLookAhead = result.getLookAhead();
		if (remainingLookAhead != 0) {
			Iterator<ILeafNode> leafNodes = result.getLeafNodes().iterator();
			while (leafNodes.hasNext() && remainingLookAhead > 0) {
				ILeafNode leaf = leafNodes.next();
				if (leaf.getTotalOffset() >= offset) {
					break;
				}
				if (!leaf.isHidden()) {
					if (remainingLookAhead > 0) {
						remainingLookAhead--;
					}
					if (remainingLookAhead == 0) {
						if (shouldUseParent(result, offset, leaf)) {
							ICompositeNode parent = result.getParent();
							return parent;
						}
						return result;
					}
				}
			}
		}
		result = getApplicableNode(result.getParent());
	}
	return result;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:31,代码来源:EntryPointFinder.java

示例5: collectLeafsWithSameOffset

import org.eclipse.xtext.nodemodel.ILeafNode; //导入方法依赖的package包/类
private LinkedList<ILeafNode> collectLeafsWithSameOffset(ILeafNode candidate, PeekingIterator<ILeafNode> iterator) {
	LinkedList<ILeafNode> sameOffset = Lists.newLinkedList();
	sameOffset.add(candidate);
	int offset = candidate.getTotalOffset();
	while(iterator.hasNext()) {
		ILeafNode peek = iterator.peek();
		if (peek.getTotalOffset() == offset) {
			sameOffset.add(peek);
			iterator.next();
		} else {
			break;
		}
	}
	return sameOffset;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:16,代码来源:IndentationAwareCompletionPrefixProvider.java

示例6: reparse

import org.eclipse.xtext.nodemodel.ILeafNode; //导入方法依赖的package包/类
@Override
public IParseResult reparse(IParser parser, IParseResult previousParseResult, ReplaceRegion changedRegion) {
	if (isBrokenPreviousState(previousParseResult, changedRegion.getOffset())) {
		return fullyReparse(parser, previousParseResult, changedRegion);
	}
	ICompositeNode oldRootNode = previousParseResult.getRootNode();
	Iterator<ILeafNode> leafNodes = oldRootNode.getLeafNodes().iterator();
	ILeafNode leftNode = getLeftNode(leafNodes, changedRegion.getOffset());
	if (leftNode == null) {
		return fullyReparse(parser, previousParseResult, changedRegion);
	}
	ILeafNode rightNode = getRightNode(leafNodes, changedRegion.getEndOffset());
	if (rightNode == null) {
		return fullyReparse(parser, previousParseResult, changedRegion);
	}
	while(leafNodes.hasNext()) {
		if (leafNodes.next().getSyntaxErrorMessage() != null) {
			return fullyReparse(parser, previousParseResult, changedRegion);
		}
	}
	String originalText = oldRootNode.getText().substring(leftNode.getTotalOffset());
	StringBuilder newTextBuilder = new StringBuilder(originalText);
	changedRegion.shiftBy(-leftNode.getTotalOffset()).applyTo(newTextBuilder);
	String newText = newTextBuilder.toString();
	if (originalText.equals(newText)) {
		// nothing to do
		return previousParseResult;
	}
	int originalLength = rightNode.getTotalEndOffset() - leftNode.getTotalOffset();
	int expectedLength = originalLength - changedRegion.getLength() + changedRegion.getText().length();
	if (!isSameTokenSequence(originalText.substring(0, originalLength), newText, expectedLength)) {
		// different token sequence, cannot perform a partial parse run
		return fullyReparse(parser, previousParseResult, changedRegion);
	}
	
	PartialParsingPointers parsingPointers = calculatePartialParsingPointers(oldRootNode, leftNode, rightNode);
	ICompositeNode replaceMe = getReplacedNode(parsingPointers);
	if (replaceMe == null || replaceMe == oldRootNode || replaceMe.getOffset() == 0 && replaceMe.getEndOffset() == oldRootNode.getLength()) {
		return fullyReparse(parser, previousParseResult, changedRegion);
	}
	String reparseRegion = insertChangeIntoReplaceRegion(replaceMe, changedRegion);
	
	EObject oldSemanticElement = getOldSemanticElement(replaceMe, parsingPointers);
	if (oldSemanticElement == null)
		return fullyReparse(parser, previousParseResult, changedRegion);
	if (oldSemanticElement == replaceMe.getParent().getSemanticElement()) {
		throw new IllegalStateException("oldParent == oldElement");
	}
	
	IParseResult newParseResult = doParseRegion(parser, parsingPointers, replaceMe, reparseRegion);
	if (newParseResult == null) {
		throw new IllegalStateException("Could not perform a partial parse operation");
	}
	
	replaceOldSemanticElement(oldSemanticElement, previousParseResult, newParseResult);
	nodeModelBuilder.replaceAndTransferLookAhead(replaceMe, newParseResult.getRootNode());
	((ParseResult) newParseResult).setRootNode(oldRootNode);
	StringBuilder builder = new StringBuilder(oldRootNode.getText());
	changedRegion.applyTo(builder);
	nodeModelBuilder.setCompleteContent(oldRootNode, builder.toString());
	return newParseResult;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:63,代码来源:TokenSequencePreservingPartialParsingHelper.java

示例7: 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


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