use of org.eclipse.emf.ecore.EClassifier in project xtext-core by eclipse.
the class Xtext2EcoreInterpretationContext method addFeature.
public void addFeature(Assignment assignment) throws TransformationException {
final String featureName = assignment.getFeature();
boolean isMultivalue = GrammarUtil.isMultipleAssignment(assignment);
boolean isContainment = true;
EClassifierInfo featureTypeInfo;
if (GrammarUtil.isBooleanAssignment(assignment)) {
checkNoFragmentRuleCall(assignment.getTerminal());
EDataType eBoolean = GrammarUtil.findEBoolean(GrammarUtil.getGrammar(assignment));
featureTypeInfo = getEClassifierInfoOrThrowException(eBoolean, assignment);
isMultivalue = false;
} else {
AbstractElement terminal = assignment.getTerminal();
if (terminal == null) {
throw new TransformationException(TransformationErrorCode.NoSuchTypeAvailable, "Cannot derive type from incomplete assignment.", assignment);
}
checkNoFragmentRuleCall(terminal);
EClassifier type = getTerminalType(terminal);
isContainment = isContainmentAssignment(assignment);
featureTypeInfo = getEClassifierInfoOrThrowException(type, assignment);
}
addFeature(featureName, featureTypeInfo, isMultivalue, isContainment, assignment);
}
use of org.eclipse.emf.ecore.EClassifier in project xtext-core by eclipse.
the class TypeRefImpl method setClassifier.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setClassifier(EClassifier newClassifier) {
EClassifier oldClassifier = classifier;
classifier = newClassifier;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, XtextTestPackage.TYPE_REF__CLASSIFIER, oldClassifier, classifier));
}
use of org.eclipse.emf.ecore.EClassifier in project xtext-core by eclipse.
the class SlotEntry method findEClasses.
protected Set<EClass> findEClasses(ResourceSet resourceSet, String nsURI2, String typeName2) {
if (typeName2 == null)
return Collections.emptySet();
Set<EClass> result = Sets.newHashSet();
Set<String> keySet = getNsUris();
for (String string : keySet) {
try {
EPackage ePackage = resourceSet.getPackageRegistry().getEPackage(string);
if (ePackage != null) {
EClassifier classifier = ePackage.getEClassifier(typeName2);
if (classifier instanceof EClass)
result.add((EClass) classifier);
}
} catch (NoClassDefFoundError e) {
throw new NoClassDefFoundError("NoClassDefFoundError while loading ePackage: " + string + " - " + e.getMessage());
}
}
if (result.isEmpty()) {
throw new WorkflowInterruptedException("Couldn't find EClass for name '" + typeName2 + "'.");
}
return result;
}
use of org.eclipse.emf.ecore.EClassifier in project xtext-core by eclipse.
the class TreeConstState method getTypesToCheck.
public Collection<TypeRef> getTypesToCheck() {
Map<EClassifier, TypeRef> localTypes = Maps.newLinkedHashMap();
for (TypeRef t : sortTypes(getTypes())) if (t != null)
localTypes.put(t.getClassifier(), t);
List<TreeConstTransition> incomming = getIncommingWithoutRuleCalls();
if (incomming.isEmpty())
return localTypes.values();
for (TreeConstTransition t : incomming) for (TypeRef r : t.getSource().getTypes()) if (r != null && !localTypes.containsKey(r.getClassifier()))
return localTypes.values();
return Collections.emptyList();
}
use of org.eclipse.emf.ecore.EClassifier in project xtext-core by eclipse.
the class GrammarUtilTest method testFindCurrentType_01.
@Test
public void testFindCurrentType_01() throws Exception {
this.with(XtextStandaloneSetup.class);
StringConcatenation _builder = new StringConcatenation();
_builder.append("grammar myLang with org.eclipse.xtext.common.Terminals");
_builder.newLine();
_builder.append("generate g \'http://1\'");
_builder.newLine();
_builder.append("Rule:");
_builder.newLine();
_builder.append("\t");
_builder.append("Fragment;");
_builder.newLine();
_builder.append("fragment Fragment*: name=ID;");
_builder.newLine();
String model = _builder.toString();
final XtextResource r = this.getResourceFromString(model);
EObject _get = r.getContents().get(0);
final Grammar grammar = ((Grammar) _get);
final AbstractRule rule = IterableExtensions.<AbstractRule>head(grammar.getRules());
final AbstractElement fragmentCall = rule.getAlternatives();
final EClassifier currentType = GrammarUtil.findCurrentType(fragmentCall);
Assert.assertEquals("Rule", currentType.getName());
}
Aggregations