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


Java NodeModelUtils.getLineAndColumn方法代码示例

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


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

示例1: testUnresolved_02

import org.eclipse.xtext.nodemodel.util.NodeModelUtils; //导入方法依赖的package包/类
@Test
public void testUnresolved_02() {
	Type type = getContext();
	INode nameNode = NodeModelUtils.findNodesForFeature(type, ImportedURIPackage.Literals.TYPE__NAME).get(0);
	resolve(type, "BlaBlaBla", nameNode.getOffset(), nameNode.getLength());
	Resource resource = type.eResource();
	assertEquals(resource.getErrors().toString(), 1, resource.getErrors().size());
	
	LineAndColumn lineAndColumn = NodeModelUtils.getLineAndColumn(nameNode, nameNode.getOffset());

	Diagnostic diagnostic = (Diagnostic) resource.getErrors().get(0);
	assertEquals(nameNode.getOffset(), diagnostic.getOffset());
	assertEquals(nameNode.getLength(), diagnostic.getLength());
	assertEquals(lineAndColumn.getLine(), diagnostic.getLine());
	assertEquals(lineAndColumn.getColumn(), diagnostic.getColumn());
	assertEquals("Couldn't resolve reference to Type 'BlaBlaBla'.", diagnostic.getMessage());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:18,代码来源:Bug437669Test.java

示例2: getColumn

import org.eclipse.xtext.nodemodel.util.NodeModelUtils; //导入方法依赖的package包/类
@Override
public int getColumn() {
	INode node = getNode();
	if (node != null) {
		LineAndColumn lineAndColumn = NodeModelUtils.getLineAndColumn(node, getOffset());
		return lineAndColumn.getColumn();
	}
	return 0;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:10,代码来源:AbstractDiagnostic.java

示例3: newPosition

import org.eclipse.xtext.nodemodel.util.NodeModelUtils; //导入方法依赖的package包/类
public Position newPosition(final Resource resource, final int offset) {
  if ((resource instanceof XtextResource)) {
    final ICompositeNode rootNode = ((XtextResource)resource).getParseResult().getRootNode();
    final LineAndColumn lineAndColumn = NodeModelUtils.getLineAndColumn(rootNode, offset);
    int _line = lineAndColumn.getLine();
    int _minus = (_line - 1);
    int _column = lineAndColumn.getColumn();
    int _minus_1 = (_column - 1);
    return new Position(_minus, _minus_1);
  }
  return null;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:13,代码来源:DocumentExtensions.java

示例4: findBestEndToken

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