本文整理匯總了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;
}