当前位置: 首页>>代码示例>>Java>>正文


Java GrammarUtil.containingCrossReference方法代码示例

本文整理汇总了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));
	}
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:24,代码来源:SequenceFeeder.java

示例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;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:22,代码来源:CrossReferenceSerializer.java

示例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;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:17,代码来源:AbstractFormattingConfig.java

示例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 + "]";
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:11,代码来源:GrammarElementTitleSwitch.java

示例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);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:8,代码来源:SequenceFeeder.java

示例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);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:8,代码来源:SequenceFeeder.java

示例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;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:13,代码来源:AssignmentFinder.java

示例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());
		}
	}
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:28,代码来源:NodeModelSemanticSequencer.java


注:本文中的org.eclipse.xtext.GrammarUtil.containingCrossReference方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。