use of org.eclipse.emf.ecore.ENamedElement in project xtext-core by eclipse.
the class XtextValidator method checkGeneratedPackageForNameClashes.
@Check
public void checkGeneratedPackageForNameClashes(GeneratedMetamodel metamodel) {
EPackage pack = metamodel.getEPackage();
Multimap<String, ENamedElement> constantNameToElement = HashMultimap.create();
Multimap<String, ENamedElement> accessorNameToElement = HashMultimap.create();
if (pack != null) {
for (EClassifier classifier : pack.getEClassifiers()) {
String accessorName = classifier.getName();
if ("Class".equals(accessorName) || "Name".equals(accessorName))
accessorName += "_";
accessorNameToElement.put("get" + accessorName, classifier);
String classifierConstantName = CodeGenUtil2.format(classifier.getName(), '_', null, true, true).toUpperCase();
constantNameToElement.put(classifierConstantName, classifier);
if (classifier instanceof EClass) {
for (EStructuralFeature feature : ((EClass) classifier).getEAllStructuralFeatures()) {
String featureConstantPart = CodeGenUtil2.format(feature.getName(), '_', null, false, false).toUpperCase();
String featureConstantName = classifierConstantName + "__" + featureConstantPart;
constantNameToElement.put(featureConstantName, feature);
String featureAccessorName = "get" + classifier.getName() + "_" + Strings.toFirstUpper(feature.getName());
accessorNameToElement.put(featureAccessorName, feature);
}
}
}
}
createMessageForNameClashes(constantNameToElement);
createMessageForNameClashes(accessorNameToElement);
}
Aggregations