Forráskód Böngészése

return unmodifieable List to avoid classcast when using crossrefadapter (#2141)

see https://bugs.eclipse.org/bugs/show_bug.cgi?id=472365
Andreas Mülder 7 éve
szülő
commit
42876f5dc6

+ 1 - 1
plugins/org.yakindu.sct.model.sgraph/src/org/yakindu/sct/model/sgraph/impl/ChoiceImpl.java

@@ -164,7 +164,7 @@ public class ChoiceImpl extends PseudostateImpl implements Choice {
 	public String toString() {
 		if (eIsProxy()) return super.toString();
 
-		StringBuffer result = new StringBuffer(super.toString());
+		StringBuilder result = new StringBuilder(super.toString());
 		result.append(" (kind: ");
 		result.append(kind);
 		result.append(')');

+ 1 - 1
plugins/org.yakindu.sct.model.sgraph/src/org/yakindu/sct/model/sgraph/impl/EntryImpl.java

@@ -165,7 +165,7 @@ public class EntryImpl extends PseudostateImpl implements Entry {
 	public String toString() {
 		if (eIsProxy()) return super.toString();
 
-		StringBuffer result = new StringBuffer(super.toString());
+		StringBuilder result = new StringBuilder(super.toString());
 		result.append(" (kind: ");
 		result.append(kind);
 		result.append(')');

+ 3 - 3
plugins/org.yakindu.sct.model.sgraph/src/org/yakindu/sct/model/sgraph/impl/SGraphPackageImpl.java

@@ -263,7 +263,7 @@ public class SGraphPackageImpl extends EPackageImpl implements SGraphPackage {
 
 	/**
 	 * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
-	 * 
+	 *
 	 * <p>This method is used to initialize {@link SGraphPackage#eINSTANCE} when that field is accessed.
 	 * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package.
 	 * <!-- begin-user-doc -->
@@ -277,7 +277,8 @@ public class SGraphPackageImpl extends EPackageImpl implements SGraphPackage {
 		if (isInited) return (SGraphPackage)EPackage.Registry.INSTANCE.getEPackage(SGraphPackage.eNS_URI);
 
 		// Obtain or create and register package
-		SGraphPackageImpl theSGraphPackage = (SGraphPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof SGraphPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new SGraphPackageImpl());
+		Object registeredSGraphPackage = EPackage.Registry.INSTANCE.get(eNS_URI);
+		SGraphPackageImpl theSGraphPackage = registeredSGraphPackage instanceof SGraphPackageImpl ? (SGraphPackageImpl)registeredSGraphPackage : new SGraphPackageImpl();
 
 		isInited = true;
 
@@ -294,7 +295,6 @@ public class SGraphPackageImpl extends EPackageImpl implements SGraphPackage {
 		// Mark meta-data to indicate it can't be changed
 		theSGraphPackage.freeze();
 
-  
 		// Update the registry and return the package
 		EPackage.Registry.INSTANCE.put(SGraphPackage.eNS_URI, theSGraphPackage);
 		return theSGraphPackage;

+ 1 - 1
plugins/org.yakindu.sct.model.sgraph/src/org/yakindu/sct/model/sgraph/impl/ScopedElementImpl.java

@@ -222,7 +222,7 @@ public abstract class ScopedElementImpl extends EObjectImpl implements ScopedEle
 	public String toString() {
 		if (eIsProxy()) return super.toString();
 
-		StringBuffer result = new StringBuffer(super.toString());
+		StringBuilder result = new StringBuilder(super.toString());
 		result.append(" (namespace: ");
 		result.append(namespace);
 		result.append(')');

+ 1 - 1
plugins/org.yakindu.sct.model.sgraph/src/org/yakindu/sct/model/sgraph/impl/SpecificationElementImpl.java

@@ -165,7 +165,7 @@ public abstract class SpecificationElementImpl extends EObjectImpl implements Sp
 	public String toString() {
 		if (eIsProxy()) return super.toString();
 
-		StringBuffer result = new StringBuffer(super.toString());
+		StringBuilder result = new StringBuilder(super.toString());
 		result.append(" (specification: ");
 		result.append(specification);
 		result.append(')');

+ 6 - 4
plugins/org.yakindu.sct.model.sgraph/src/org/yakindu/sct/model/sgraph/impl/StateImpl.java

@@ -14,6 +14,7 @@ import java.util.Collection;
 
 import org.eclipse.emf.common.notify.Notification;
 import org.eclipse.emf.common.notify.NotificationChain;
+import org.eclipse.emf.common.util.BasicEList;
 import org.eclipse.emf.common.util.EList;
 import org.eclipse.emf.ecore.EClass;
 import org.eclipse.emf.ecore.InternalEObject;
@@ -22,6 +23,7 @@ import org.eclipse.emf.ecore.util.BasicInternalEList;
 import org.eclipse.emf.ecore.util.EObjectContainmentEList;
 import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
 import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList;
+import org.eclipse.emf.ecore.util.EcoreEList;
 import org.eclipse.emf.ecore.util.EcoreUtil;
 import org.eclipse.emf.ecore.util.InternalEList;
 import org.yakindu.base.base.BasePackage;
@@ -237,13 +239,13 @@ public class StateImpl extends SpecificationElementImpl implements State {
 	 * @generated NOT
 	 */
 	public EList<Reaction> getLocalReactions() {
-		EList<Reaction> result = new BasicInternalEList<Reaction>(
-				Reaction.class);
+		EList<Reaction> result = new BasicEList<Reaction>();
 		EList<Scope> scopes = getScopes();
 		for (Scope scope : scopes) {
 			result.addAll(scope.getReactions());
 		}
-		return result;
+		return new EcoreEList.UnmodifiableEList<Reaction>(this,
+				SGraphPackage.Literals.REACTIVE_ELEMENT__LOCAL_REACTIONS, result.size(), result.toArray());
 	}
 
 	/**
@@ -769,7 +771,7 @@ public class StateImpl extends SpecificationElementImpl implements State {
 	public String toString() {
 		if (eIsProxy()) return super.toString();
 
-		StringBuffer result = new StringBuffer(super.toString());
+		StringBuilder result = new StringBuilder(super.toString());
 		result.append(" (namespace: ");
 		result.append(namespace);
 		result.append(", name: ");

+ 6 - 4
plugins/org.yakindu.sct.model.sgraph/src/org/yakindu/sct/model/sgraph/impl/StatechartImpl.java

@@ -14,6 +14,7 @@ import java.util.Collection;
 
 import org.eclipse.emf.common.notify.Notification;
 import org.eclipse.emf.common.notify.NotificationChain;
+import org.eclipse.emf.common.util.BasicEList;
 import org.eclipse.emf.common.util.EList;
 import org.eclipse.emf.ecore.EClass;
 import org.eclipse.emf.ecore.InternalEObject;
@@ -21,6 +22,7 @@ import org.eclipse.emf.ecore.impl.ENotificationImpl;
 import org.eclipse.emf.ecore.util.BasicInternalEList;
 import org.eclipse.emf.ecore.util.EObjectContainmentEList;
 import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
+import org.eclipse.emf.ecore.util.EcoreEList;
 import org.eclipse.emf.ecore.util.InternalEList;
 import org.yakindu.base.base.BasePackage;
 import org.yakindu.base.base.DocumentedElement;
@@ -203,13 +205,13 @@ public class StatechartImpl extends SpecificationElementImpl implements
 	 * @generated NOT
 	 */
 	public EList<Reaction> getLocalReactions() {
-		EList<Reaction> result = new BasicInternalEList<Reaction>(
-				Reaction.class);
+		EList<Reaction> result = new BasicEList<Reaction>();
 		EList<Scope> scopes = getScopes();
 		for (Scope scope : scopes) {
 				result.addAll(scope.getReactions());
 		}
-		return result;
+		return new EcoreEList.UnmodifiableEList<Reaction>(this,
+				SGraphPackage.Literals.REACTIVE_ELEMENT__LOCAL_REACTIONS, result.size(), result.toArray());
 	}
 
 	/**
@@ -605,7 +607,7 @@ public class StatechartImpl extends SpecificationElementImpl implements
 	public String toString() {
 		if (eIsProxy()) return super.toString();
 
-		StringBuffer result = new StringBuffer(super.toString());
+		StringBuilder result = new StringBuilder(super.toString());
 		result.append(" (namespace: ");
 		result.append(namespace);
 		result.append(", name: ");

+ 1 - 1
plugins/org.yakindu.sct.model.sgraph/src/org/yakindu/sct/model/sgraph/impl/TransitionImpl.java

@@ -639,7 +639,7 @@ public class TransitionImpl extends SpecificationElementImpl implements Transiti
 	public String toString() {
 		if (eIsProxy()) return super.toString();
 
-		StringBuffer result = new StringBuffer(super.toString());
+		StringBuilder result = new StringBuilder(super.toString());
 		result.append(" (documentation: ");
 		result.append(documentation);
 		result.append(')');