use of org.eclipse.emf.ecore.EClassifier in project xtext-eclipse by eclipse.
the class AbstractTemplateVariableResolver method getEClassifierForGrammar.
protected EClassifier getEClassifierForGrammar(String fqnClassName, Grammar grammar) {
int dotIndex = fqnClassName.indexOf('.');
String packageName = null;
String className = fqnClassName;
if (dotIndex > 0) {
packageName = fqnClassName.substring(0, dotIndex);
className = fqnClassName.substring(dotIndex + 1);
}
List<AbstractMetamodelDeclaration> allMetamodelDeclarations = GrammarUtil.allMetamodelDeclarations(grammar);
for (AbstractMetamodelDeclaration decl : allMetamodelDeclarations) {
EPackage pack = decl.getEPackage();
if (packageName == null || pack.getName().equals(packageName)) {
EClassifier eClassifier = pack.getEClassifier(className);
if (eClassifier != null) {
return eClassifier;
}
}
}
return null;
}
use of org.eclipse.emf.ecore.EClassifier in project xtext-eclipse by eclipse.
the class EmfResourceReferenceUpdater method createReferenceUpdates.
@Override
protected void createReferenceUpdates(ElementRenameArguments elementRenameArguments, Multimap<URI, IReferenceDescription> resource2references, ResourceSet resourceSet, IRefactoringUpdateAcceptor updateAcceptor, IProgressMonitor monitor) {
for (URI referringResourceURI : resource2references.keySet()) {
try {
if (monitor.isCanceled())
throw new OperationCanceledException();
Resource referringResource = resourceSet.getResource(referringResourceURI, false);
EObject refactoredElement = resourceSet.getEObject(elementRenameArguments.getNewElementURI(elementRenameArguments.getTargetElementURI()), true);
if (referringResource != refactoredElement.eResource()) {
if (refactoredElement instanceof EClassifier) {
for (IReferenceDescription reference : resource2references.get(referringResourceURI)) {
EObject source = referringResource.getEObject(reference.getSourceEObjectUri().fragment());
if (source == null) {
LOG.error("Couldn't find source element " + reference.getSourceEObjectUri() + " in " + referringResource.getURI());
} else {
EObject referringEReference = source.eContainer();
if (referringEReference != null && referringEReference instanceof EReference)
((EReference) referringEReference).setEType((EClassifier) refactoredElement);
}
}
}
changeUtil.addSaveAsUpdate(referringResource, updateAcceptor);
}
} catch (OperationCanceledException e) {
throw e;
} catch (Exception exc) {
throw new WrappedException(exc);
}
}
}
use of org.eclipse.emf.ecore.EClassifier in project Palladio-Editors-Sirius by PalladioSimulator.
the class PCMServices method setParameterValue.
/**
* Sets the value of the {@link EStructuralFeature} on the given {@link EObject} to the parsed
* value literal.
*
* @param parameter
* the feature to set
* @param owningEObject
* the object for which the feature will be set
* @param valueLiteral
* the literal representing the new value
*/
public void setParameterValue(final EStructuralFeature parameter, final EObject owningEObject, final String valueLiteral) {
final EClassifier eType = parameter.getEType();
Object value = null;
if (valueLiteral == null && eType != null) {
value = parameter.isMany() ? null : eType.getDefaultValue();
} else if (eType instanceof EDataType) {
final EFactory factory = eType.getEPackage().getEFactoryInstance();
final EDataType eDataType = (EDataType) eType;
if (eDataType.isSerializable()) {
try {
value = factory.createFromString(eDataType, valueLiteral);
} catch (final Throwable e) {
// At development time, the real factory may not be
// available. Just return null.
//
}
}
}
owningEObject.eSet(parameter, value);
}
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, XtextGrammarTestPackage.TYPE_REF__CLASSIFIER, oldClassifier, classifier));
}
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, XtextTerminalsTestLanguagePackage.TYPE_REF__CLASSIFIER, oldClassifier, classifier));
}
Aggregations