本文整理汇总了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);
}
}
}
}
}
示例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);
}
}
}
}
}
示例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);
}
示例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);
}
}
}
}
}
}
示例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);
}