本文整理汇总了Java中org.eclipse.xtext.nodemodel.INode.getSemanticElement方法的典型用法代码示例。如果您正苦于以下问题:Java INode.getSemanticElement方法的具体用法?Java INode.getSemanticElement怎么用?Java INode.getSemanticElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.xtext.nodemodel.INode
的用法示例。
在下文中一共展示了INode.getSemanticElement方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleLastCompleteNodeIsAtEndOfDatatypeNode
import org.eclipse.xtext.nodemodel.INode; //导入方法依赖的package包/类
@Override
protected void handleLastCompleteNodeIsAtEndOfDatatypeNode() {
String prefix = getPrefix(lastCompleteNode);
INode previousNode = getLastCompleteNodeByOffset(rootNode, lastCompleteNode.getOffset());
EObject previousModel = previousNode.getSemanticElement();
INode currentDatatypeNode = getContainingDatatypeRuleNode(currentNode);
Collection<FollowElement> followElements = getParser().getFollowElements(rootNode, 0,
lastCompleteNode.getOffset(), true);
int prevSize = contextBuilders.size();
doCreateContexts(previousNode, currentDatatypeNode, prefix, previousModel, followElements);
if (lastCompleteNode instanceof ILeafNode && lastCompleteNode.getGrammarElement() == null
&& contextBuilders.size() != prevSize) {
handleLastCompleteNodeHasNoGrammarElement(contextBuilders.subList(prevSize, contextBuilders.size()),
previousModel);
}
}
示例2: filterLeafsWithKeywordInsteadOfComma
import org.eclipse.xtext.nodemodel.INode; //导入方法依赖的package包/类
/**
* Returns nodes which represent keywords and specified in keywords.
*
* @param keywords
* keywords in natural order used in Arrays#s
*/
protected List<ILeafNode> filterLeafsWithKeywordInsteadOfComma(EObject semanticElement, String stopAtKeyword,
ICompositeNode node,
final String... keywords) {
List<ILeafNode> filteredLeaves = null;
for (BidiTreeIterator<INode> iter = node.getAsTreeIterable().iterator(); iter.hasNext();) {
INode child = iter.next();
EObject childSemElement = child.getSemanticElement();
if (child != node && childSemElement != null && childSemElement != semanticElement) {
iter.prune();
} else if (child instanceof ILeafNode) {
ILeafNode leaf = (ILeafNode) child;
EObject grammarElement = leaf.getGrammarElement();
if (grammarElement instanceof Keyword) {
String value = ((Keyword) grammarElement).getValue();
if (stopAtKeyword.equals(value)) {
break;
}
if (Arrays.binarySearch(keywords, value) >= 0) {
if (grammarElement.eContainer() instanceof Alternatives) {
AbstractElement first = ((Alternatives) (grammarElement.eContainer())).getElements().get(0);
boolean inCommaAlternative = (first instanceof Keyword && ",".equals(((Keyword) first)
.getValue()));
if (inCommaAlternative) {
if (filteredLeaves == null) {
filteredLeaves = new ArrayList<>(5);
}
filteredLeaves.add(leaf);
}
}
}
}
}
}
return filteredLeaves == null ? Collections.emptyList() : filteredLeaves;
}
示例3: doFindLeafWithKeyword
import org.eclipse.xtext.nodemodel.INode; //导入方法依赖的package包/类
/**
* Returns the first keyword with the given value, or null if no such keyword is found.
*/
private ILeafNode doFindLeafWithKeyword(EObject semanticElement, String stopAtKeyword, ICompositeNode node,
String keyWord,
boolean commaAlternative, int hitNumber) {
EObject grammarElement;
int foundHits = 0;
for (BidiTreeIterator<INode> iter = node.getAsTreeIterable().iterator(); iter.hasNext();) {
INode child = iter.next();
EObject childSemElement = child.getSemanticElement();
if (child != node && childSemElement != null && childSemElement != semanticElement) {
iter.prune();
} else if (child instanceof ILeafNode) {
ILeafNode leaf = (ILeafNode) child;
grammarElement = leaf.getGrammarElement();
if (grammarElement instanceof Keyword) {
String value = ((Keyword) grammarElement).getValue();
if (stopAtKeyword.equals(value)) {
return null;
}
if (keyWord.equals(value)) {
if (grammarElement.eContainer() instanceof Alternatives) {
AbstractElement first = ((Alternatives) (grammarElement.eContainer())).getElements().get(0);
boolean inCommaAlternative = (first instanceof Keyword && ",".equals(((Keyword) first)
.getValue()));
if (inCommaAlternative == commaAlternative) {
foundHits++;
if (foundHits >= hitNumber) {
return leaf;
}
}
} else {
if (!commaAlternative) {
foundHits++;
if (foundHits >= hitNumber) {
return leaf;
}
}
}
}
}
}
}
return null;
}