本文整理汇总了Java中org.eclipse.xtext.GrammarUtil.containingCrossReference方法的典型用法代码示例。如果您正苦于以下问题:Java GrammarUtil.containingCrossReference方法的具体用法?Java GrammarUtil.containingCrossReference怎么用?Java GrammarUtil.containingCrossReference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.xtext.GrammarUtil
的用法示例。
在下文中一共展示了GrammarUtil.containingCrossReference方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: acceptRuleCall
import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
protected void acceptRuleCall(RuleCall rc, Object value, String token, int index, INode node) {
CrossReference crossRef = GrammarUtil.containingCrossReference(rc);
if (crossRef != null) {
if (rc.getRule() instanceof ParserRule)
sequenceAcceptor.acceptAssignedCrossRefDatatype(rc, token, (EObject) value, index,
getCompositeNode(node));
else if (rc.getRule() instanceof TerminalRule)
sequenceAcceptor.acceptAssignedCrossRefTerminal(rc, token, (EObject) value, index, getLeafNode(node));
else if (rc.getRule() instanceof EnumRule)
sequenceAcceptor.acceptAssignedCrossRefEnum(rc, token, (EObject) value, index, getCompositeNode(node));
} else {
if (rc.getRule() instanceof ParserRule) {
AbstractRule rule = rc.getRule();
if (rule.getType() != null && rule.getType().getClassifier() instanceof EClass)
acceptEObjectRuleCall(rc, (EObject) value, getCompositeNode(node));
else
sequenceAcceptor.acceptAssignedDatatype(rc, token, value, index, getCompositeNode(node));
} else if (rc.getRule() instanceof TerminalRule)
sequenceAcceptor.acceptAssignedTerminal(rc, token, value, index, getLeafNode(node));
else if (rc.getRule() instanceof EnumRule)
sequenceAcceptor.acceptAssignedEnum(rc, token, value, index, getCompositeNode(node));
}
}
示例2: isValid
import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
@Override
public boolean isValid(EObject semanticObject, CrossReference crossref, EObject target, INode node, Acceptor errors) {
if ((target == null || target.eIsProxy()) && node != null) {
CrossReference crossrefFromNode = GrammarUtil.containingCrossReference(node.getGrammarElement());
return crossref == crossrefFromNode;
}
final EReference ref = GrammarUtil.getReference(crossref, semanticObject.eClass());
final IScope scope = scopeProvider.getScope(semanticObject, ref);
if (scope == null) {
if (errors != null)
errors.accept(diagnostics.getNoScopeFoundDiagnostic(semanticObject, crossref, target));
return false;
}
if (target != null && target.eIsProxy()) {
target = handleProxy(target, semanticObject, ref);
}
return getCrossReferenceNameFromScope(semanticObject, crossref, target, scope, errors) != null;
}
示例3: getAbstractElements
import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
protected List<AbstractElement> getAbstractElements(EObject obj) {
if (obj instanceof AbstractElement)
return Collections.singletonList((AbstractElement) obj);
if (obj instanceof AbstractRule) {
AbstractRule rule = (AbstractRule) obj;
if (rule.getType().getClassifier() instanceof EClass)
return Collections.singletonList(rule.getAlternatives());
List<AbstractElement> result = Lists.newArrayList();
for (RuleCall rc : grammarAccess.findRuleCalls(rule)) {
CrossReference cr = GrammarUtil.containingCrossReference(rc);
result.add(cr == null ? rc : cr);
}
return result;
}
return null;
}
示例4: addCrossRef
import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
protected String addCrossRef(String result, AbstractElement ele) {
if (!showAssignment)
return result;
CrossReference cr = GrammarUtil.containingCrossReference(ele);
if (cr == null)
return result;
String name = cr.getType() != null && cr.getType().getClassifier() != null ? cr.getType().getClassifier()
.getName() : "null";
return "[" + name + "|" + result + "]";
}
示例5: acceptKeyword
import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
protected void acceptKeyword(Assignment ass, Keyword keyword, Object value, String token, int index, ILeafNode node) {
CrossReference crossRef = GrammarUtil.containingCrossReference(keyword);
if (crossRef != null)
sequenceAcceptor.acceptAssignedCrossRefKeyword(keyword, token, (EObject) value, index, node);
else
sequenceAcceptor.acceptAssignedKeyword(keyword, token, value, index, node);
}
示例6: getToken
import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
protected String getToken(Keyword keyword, Object value, ILeafNode node) {
CrossReference crossRef = GrammarUtil.containingCrossReference(keyword);
if (crossRef != null)
return provider.crossRefSerializer.serializeCrossRef(semanticObject, crossRef, (EObject) value, node,
errorAcceptor);
return provider.keywordSerializer.serializeAssignedKeyword(semanticObject, keyword, value, node, errorAcceptor);
}
示例7: findValidAssignmentsForCrossRef
import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
protected Set<AbstractElement> findValidAssignmentsForCrossRef(EObject semanticObj,
Iterable<AbstractElement> assignedElements, EObject value, INode node) {
Set<AbstractElement> result = Sets.newLinkedHashSet();
for (AbstractElement ass : assignedElements) {
CrossReference crossref = GrammarUtil.containingCrossReference(ass);
EReference eref = GrammarUtil.getReference(crossref, semanticObj.eClass());
if (EcoreUtil2.isAssignableFrom(eref.getEReferenceType(), value.eClass())
&& crossRefSerializer.isValid(semanticObj, crossref, value, node, null))
result.add(ass);
}
return result;
}
示例8: createSequence
import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
@Override
public void createSequence(ISerializationContext context, EObject semanticObject) {
SemanticNodeIterator ni = new SemanticNodeIterator(semanticObject);
while (ni.hasNext()) {
Triple<INode, AbstractElement, EObject> node = ni.next();
if (node.getSecond() instanceof RuleCall) {
RuleCall rc = (RuleCall) node.getSecond();
TypeRef ruleType = rc.getRule().getType();
if (ruleType == null || ruleType.getClassifier() instanceof EClass)
acceptSemantic(semanticObject, rc, node.getThird(), node.getFirst());
else if (GrammarUtil.containingCrossReference(node.getSecond()) != null) {
EStructuralFeature feature = FeatureFinderUtil.getFeature(node.getSecond(),
semanticObject.eClass());
acceptSemantic(semanticObject, rc, semanticObject.eGet(feature), node.getFirst());
} else {
String strVal = NodeModelUtils.getTokenText(node.getFirst());
Object val = valueConverter.toValue(strVal, ruleNames.getQualifiedName(rc.getRule()),
node.getFirst());
acceptSemantic(semanticObject, rc, val, node.getFirst());
}
} else if (node.getSecond() instanceof Keyword)
acceptSemantic(semanticObject, node.getSecond(), node.getFirst().getText(), node.getFirst());
else if (node.getSecond() instanceof Action) {
acceptSemantic(semanticObject, node.getSecond(), semanticObject, node.getFirst());
}
}
}