use of org.eclipse.emf.ecore.EClassifier in project xtext-core by eclipse.
the class GrammarUtilTest method testFindCurrentType_06.
@Test
public void testFindCurrentType_06() throws Exception {
with(XtextStandaloneSetup.class);
String model = "grammar myLang with org.eclipse.xtext.common.Terminals\n" + "generate g 'http://1'\n" + "Rule:\n" + " Fragment;\n" + "fragment Fragment returns Rule:\n" + " name=ID Fragment?\n" + ";\n";
XtextResource r = getResourceFromString(model);
Grammar grammar = (Grammar) r.getContents().get(0);
AbstractRule rule = Iterables.getLast(grammar.getRules());
AbstractElement fragmentCall = Iterables.getLast(((Group) rule.getAlternatives()).getElements());
EClassifier currentType = GrammarUtil.findCurrentType(fragmentCall);
Assert.assertEquals("Rule", currentType.getName());
}
use of org.eclipse.emf.ecore.EClassifier in project xtext-core by eclipse.
the class GrammarUtilTest method testFindCurrentType_03.
@Test
public void testFindCurrentType_03() throws Exception {
with(XtextStandaloneSetup.class);
String model = "grammar myLang with org.eclipse.xtext.common.Terminals\n" + "generate g 'http://1'\n" + "Rule:\n" + " Fragment;\n" + "fragment Fragment: name=ID SecondFragment;\n" + "fragment SecondFragment: {SubRule.named=current} value=ID;\n";
XtextResource r = getResourceFromString(model);
Grammar grammar = (Grammar) r.getContents().get(0);
AbstractRule rule = Iterables.getFirst(grammar.getRules(), null);
AbstractElement fragmentCall = rule.getAlternatives();
EClassifier currentType = GrammarUtil.findCurrentType(fragmentCall);
Assert.assertEquals("SubRule", currentType.getName());
}
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 {
with(XtextStandaloneSetup.class);
String model = "grammar myLang with org.eclipse.xtext.common.Terminals\n" + "generate g 'http://1'\n" + "Rule:\n" + " Fragment;\n" + "fragment Fragment*: name=ID;\n";
XtextResource r = getResourceFromString(model);
Grammar grammar = (Grammar) r.getContents().get(0);
AbstractRule rule = Iterables.getFirst(grammar.getRules(), null);
AbstractElement fragmentCall = rule.getAlternatives();
EClassifier currentType = GrammarUtil.findCurrentType(fragmentCall);
Assert.assertEquals("Rule", currentType.getName());
}
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
*/
@Override
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 EMFGeneratorFragment2 method findAllUsedEPackages.
private Map<String, EPackage> findAllUsedEPackages(final List<EPackage> generatedPackages) {
final HashMap<String, EPackage> result = CollectionLiterals.<String, EPackage>newHashMap();
final TreeIterator<EObject> packageContentIterator = EcoreUtil.<EObject>getAllContents(generatedPackages);
while (packageContentIterator.hasNext()) {
{
final EObject current = packageContentIterator.next();
EList<EObject> _eCrossReferences = current.eCrossReferences();
for (final EObject referenced : _eCrossReferences) {
{
boolean _eIsProxy = referenced.eIsProxy();
if (_eIsProxy) {
throw new RuntimeException(((("Unresolved proxy: " + referenced) + " in ") + current));
}
if ((referenced instanceof EClassifier)) {
final EPackage referencedPackage = ((EClassifier) referenced).getEPackage();
boolean _contains = generatedPackages.contains(referencedPackage);
boolean _not = (!_contains);
if (_not) {
result.put(referencedPackage.getNsURI(), referencedPackage);
}
}
}
}
}
}
return result;
}
Aggregations