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