use of org.eclipse.xtext.common.types.access.impl.AbstractClassMirror in project xtext-eclipse by eclipse.
the class JvmMemberRenameStrategy method setName.
protected JvmMember setName(URI targetURI, ResourceSet resourceSet, final String newName) {
final JvmMember member = (JvmMember) resourceSet.getEObject(targetURI, true);
// clear all cached identifiers of contained members
for (JvmMember containedMember : EcoreUtil2.eAllOfType(member, JvmMember.class)) containedMember.internalSetIdentifier(null);
member.setSimpleName(newName);
if (member instanceof JvmDeclaredType && ((InternalEObject) member).eDirectResource() != null) {
Resource typeResource = member.eResource();
if (typeResource instanceof TypeResource) {
// rename the resource
String originalURI = typeResource.getURI().toString();
int lastIndexOf = Math.max(originalURI.lastIndexOf('.'), originalURI.lastIndexOf('/')) + 1;
URI typeResourceNewURI = URI.createURI(originalURI.substring(0, lastIndexOf) + newName);
typeResource.setURI(typeResourceNewURI);
// disconnect the mirrored IJavaElement as it is invalid now
((TypeResource) typeResource).setMirror(new AbstractClassMirror() {
@Override
public boolean isSealed() {
return false;
}
@Override
public void initialize(TypeResource typeResource) {
}
@Override
protected String getTypeName() {
return member.getIdentifier();
}
});
}
}
return member;
}
Aggregations