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


Java EcoreUtil2.getCompatibleType方法代码示例

本文整理汇总了Java中org.eclipse.xtext.EcoreUtil2.getCompatibleType方法的典型用法代码示例。如果您正苦于以下问题:Java EcoreUtil2.getCompatibleType方法的具体用法?Java EcoreUtil2.getCompatibleType怎么用?Java EcoreUtil2.getCompatibleType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.xtext.EcoreUtil2的用法示例。


在下文中一共展示了EcoreUtil2.getCompatibleType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: collectAbstractElements

import org.eclipse.xtext.EcoreUtil2; //导入方法依赖的package包/类
@Override
public void collectAbstractElements(Grammar grammar, EStructuralFeature feature,
		IFollowElementAcceptor followElementAcceptor) {
	for (Grammar superGrammar : grammar.getUsedGrammars()) {
		collectAbstractElements(superGrammar, feature, followElementAcceptor);
	}
	EClass declarator = feature.getEContainingClass();
	for (ParserRule rule : GrammarUtil.allParserRules(grammar)) {
		for (Assignment assignment : GrammarUtil.containedAssignments(rule)) {
			if (assignment.getFeature().equals(feature.getName())) {
				EClassifier classifier = GrammarUtil.findCurrentType(assignment);
				EClassifier compType = EcoreUtil2.getCompatibleType(declarator, classifier);
				if (compType == declarator) {
					followElementAcceptor.accept(assignment);
				}
			}
		}
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:20,代码来源:PatchedFollowElementComputer.java

示例2: collectAbstractElements

import org.eclipse.xtext.EcoreUtil2; //导入方法依赖的package包/类
public void collectAbstractElements(Grammar grammar, EStructuralFeature feature, IFollowElementAcceptor followElementAcceptor) {
	for (Grammar superGrammar : grammar.getUsedGrammars()) {
		collectAbstractElements(superGrammar, feature, followElementAcceptor);
	}
	EClass declarator = feature.getEContainingClass();
	for (ParserRule rule : GrammarUtil.allParserRules(grammar)) {
		for (Assignment assignment : GrammarUtil.containedAssignments(rule)) {
			if (assignment.getFeature().equals(feature.getName())) {
				EClassifier classifier = GrammarUtil.findCurrentType(assignment);
				EClassifier compType = EcoreUtil2.getCompatibleType(declarator, classifier);
				if (compType == declarator) {
					followElementAcceptor.accept(assignment);
				}
			}
		}
	}
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:18,代码来源:FollowElementComputer.java

示例3: getCompatibleType

import org.eclipse.xtext.EcoreUtil2; //导入方法依赖的package包/类
private EClassifierInfo getCompatibleType(EClassifierInfo infoA, EClassifierInfo infoB) {
	if (infoA.equals(infoB))
		return infoA;

	if (infoA.getEClassifier() instanceof EDataType || infoB.getEClassifier() instanceof EDataType)
		throw new IllegalArgumentException(
				"Simple Datatypes (lexer rules or keywords) do not have a common supertype (" + infoA + ", "
						+ infoB + ")");

	EClassifier compatibleType = EcoreUtil2.getCompatibleType(infoA.getEClassifier(), infoB.getEClassifier(), grammar);

	return getInfoOrNull(compatibleType);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:14,代码来源:EClassifierInfos.java

示例4: pushFeaturesUp

import org.eclipse.xtext.EcoreUtil2; //导入方法依赖的package包/类
private void pushFeaturesUp(EClassInfo info, Collection<EClass> traversedClasses) {
	EClass eClass = info.getEClass();
	if (info.isGenerated()) {
		if (traversedClasses.add(eClass)) {
			if (eClass.getESuperTypes().isEmpty())
				return;
			for(EClass superType: eClass.getESuperTypes()) {
				EClassInfo superInfo = (EClassInfo) infos.getInfoOrNull(superType);
				pushFeaturesUp(superInfo, traversedClasses);
			}
			Map<String, EStructuralFeature> allFeatures = Maps.newLinkedHashMap();
			Set<String> skippedNames = Sets.newLinkedHashSet();
			for(EStructuralFeature feature: eClass.getEAllStructuralFeatures()) {
				if (feature.getEContainingClass() != eClass) {
					if (allFeatures.containsKey(feature.getName())) {
						allFeatures.remove(feature.getName());
					} else if (skippedNames.add(feature.getName())) {
						allFeatures.put(feature.getName(), feature);
					}
				}
			}
			Iterator<EStructuralFeature> iter = eClass.getEStructuralFeatures().iterator();
			while(iter.hasNext()) {
				EStructuralFeature declared = iter.next();
				EStructuralFeature existing = allFeatures.get(declared.getName());
				if (existing != null) {
					EClassifier compatibleType = EcoreUtil2.getCompatibleType(declared.getEType(), existing.getEType(), grammar);
					if (compatibleType != null) {
						iter.remove();
						existing.setEType(compatibleType);
					}
				}
			}
		}
	}
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:37,代码来源:TypeHierarchyHelper.java

示例5: getCompatibleType

import org.eclipse.xtext.EcoreUtil2; //导入方法依赖的package包/类
protected EClassifier getCompatibleType(EClassifier a, EClassifier b, EObject context) {
	if (a == null)
		return b;
	if (b == null)
		return a;
	return EcoreUtil2.getCompatibleType(a, b, context);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:8,代码来源:CurrentTypeFinder.java


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