本文整理汇总了Java中org.eclipse.xtext.nodemodel.INode.getGrammarElement方法的典型用法代码示例。如果您正苦于以下问题:Java INode.getGrammarElement方法的具体用法?Java INode.getGrammarElement怎么用?Java INode.getGrammarElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.xtext.nodemodel.INode
的用法示例。
在下文中一共展示了INode.getGrammarElement方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findMultiLineComments
import org.eclipse.xtext.nodemodel.INode; //导入方法依赖的package包/类
/**
* Finds multi line comments on eObject. Comment is consider multiline by its type (e.g. start-end markers). Actual
* conents can be either single line, or multiline content.
*
* @param eObject
* on which we look for multiline comment
* @return list of nodes with comment, can be empty if no comments
*/
protected List<INode> findMultiLineComments(EObject eObject) {
// get node
INode elementNode = NodeModelUtils.findActualNodeFor(eObject);
HiddenLeafs hLeafs = hla.getHiddenLeafsBefore(elementNode);
// check for comments
if (!hLeafs.containsComment()) {
return null;
}
// get all comments
List<LeafInfo> leafs = hLeafs.getLeafs();
List<INode> comments = new ArrayList<>();
final TerminalRule SL = grammarAccess.getSL_COMMENTRule();
// get only MultiLine comments
for (LeafInfo li : leafs) {
if (li instanceof CommentInfo) {
INode commentNode = li.getNode();
EObject ge = commentNode.getGrammarElement();
// are we sure we get here only ML/SL ?
if (ge != SL) { // ignore SL
// finds ML and SML
comments.add(commentNode);
}
}
}
return comments;
}