Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 201873 Details for
Bug 354245
Enhanced support for XCore
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Updates to make the import manager more reusable.
354245.patch (text/plain), 49.75 KB, created by
Ed Merks
on 2011-08-21 14:26:10 EDT
(
hide
)
Description:
Updates to make the import manager more reusable.
Filename:
MIME Type:
Creator:
Ed Merks
Created:
2011-08-21 14:26:10 EDT
Size:
49.75 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.emf.codegen >Index: src/org/eclipse/emf/codegen/util/ImportManager.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.codegen/src/org/eclipse/emf/codegen/util/ImportManager.java,v >retrieving revision 1.9 >diff -u -r1.9 ImportManager.java >--- src/org/eclipse/emf/codegen/util/ImportManager.java 3 Jun 2009 23:50:59 -0000 1.9 >+++ src/org/eclipse/emf/codegen/util/ImportManager.java 21 Aug 2011 18:24:00 -0000 >@@ -495,7 +495,7 @@ > importedPackages.add(packageName); > imports.add(importName); > } >- else if (!shortNameToImportMap.containsKey(shortName) && (!CodeGenUtil.isJavaDefaultType(shortName))) >+ else if (!shortNameToImportMap.containsKey(shortName) && shouldImport(packageName, shortName, importName)) > { > shortNameToImportMap.put(shortName, importName); > >@@ -505,6 +505,16 @@ > } > } > } >+ >+ /** >+ * Determines whether the given non-wildcard import should be added. >+ * By default, this returns false if the short name is a built-in Java language type name. >+ * @since 2.8 >+ */ >+ protected boolean shouldImport(String packageName, String shortName, String importName) >+ { >+ return !CodeGenUtil.isJavaDefaultType(shortName); >+ } > > /** > * Registers a pseudo-import for the given qualified name. >#P org.eclipse.emf.codegen.ecore >Index: src/org/eclipse/emf/codegen/ecore/genmodel/GenClass.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/genmodel/GenClass.java,v >retrieving revision 1.36 >diff -u -r1.36 GenClass.java >--- src/org/eclipse/emf/codegen/ecore/genmodel/GenClass.java 21 Jan 2011 07:19:08 -0000 1.36 >+++ src/org/eclipse/emf/codegen/ecore/genmodel/GenClass.java 21 Aug 2011 18:24:01 -0000 >@@ -624,4 +624,11 @@ > * @since 2.4 > */ > boolean hasCollidingUnsetAccessorOperation(GenFeature genFeature); >+ >+ /** >+ * Returns as list that corresponds to {@link #getInterfaceExtends()}. >+ * @since 2.8 >+ */ >+ List<String >getQualifiedInterfaceExtendsList(); >+ > } >Index: src/org/eclipse/emf/codegen/ecore/genmodel/GenModel.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/genmodel/GenModel.java,v >retrieving revision 1.69 >diff -u -r1.69 GenModel.java >--- src/org/eclipse/emf/codegen/ecore/genmodel/GenModel.java 24 Aug 2010 16:59:38 -0000 1.69 >+++ src/org/eclipse/emf/codegen/ecore/genmodel/GenModel.java 21 Aug 2011 18:24:02 -0000 >@@ -32,7 +32,10 @@ > import org.eclipse.emf.common.util.EList; > import org.eclipse.emf.ecore.EClass; > import org.eclipse.emf.ecore.EClassifier; >+import org.eclipse.emf.ecore.EOperation; > import org.eclipse.emf.ecore.EPackage; >+import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.emf.ecore.ETypeParameter; > import org.eclipse.emf.ecore.util.ExtendedMetaData; > import org.eclipse.jdt.core.formatter.CodeFormatter; > >@@ -2794,4 +2797,25 @@ > * @since 2.7 > */ > String getQualifiedEditorEntryPointClassName(); >+ >+ /** >+ * Set up reasonable initial defaults. >+ * @since 2.8 >+ */ >+ void initialize(); >+ >+ /** >+ * @since 2.8 >+ */ >+ GenTypeParameter findGenTypeParameter(ETypeParameter eTypeParameter); >+ >+ /** >+ * @since 2.8 >+ */ >+ GenFeature findGenFeature(EStructuralFeature eStructuralFeature); >+ >+ /** >+ * @since 2.8 >+ */ >+ GenOperation findGenOperation(EOperation eOperation); > } >Index: src/org/eclipse/emf/codegen/ecore/genmodel/impl/GenModelImpl.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/genmodel/impl/GenModelImpl.java,v >retrieving revision 1.117 >diff -u -r1.117 GenModelImpl.java >--- src/org/eclipse/emf/codegen/ecore/genmodel/impl/GenModelImpl.java 6 Jan 2011 21:03:33 -0000 1.117 >+++ src/org/eclipse/emf/codegen/ecore/genmodel/impl/GenModelImpl.java 21 Aug 2011 18:24:05 -0000 >@@ -30,7 +30,13 @@ > import java.util.Map; > import java.util.Set; > >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IWorkspace; >+import org.eclipse.core.resources.ResourcesPlugin; > import org.eclipse.core.runtime.IStatus; >+import org.eclipse.jdt.core.IClasspathEntry; >+import org.eclipse.jdt.core.IJavaProject; >+import org.eclipse.jdt.core.JavaCore; > import org.eclipse.jdt.core.ToolFactory; > import org.eclipse.jdt.core.formatter.CodeFormatter; > >@@ -75,13 +81,18 @@ > import org.eclipse.emf.common.util.TreeIterator; > import org.eclipse.emf.common.util.URI; > import org.eclipse.emf.common.util.UniqueEList; >+import org.eclipse.emf.ecore.EAnnotation; >+import org.eclipse.emf.ecore.EAttribute; > import org.eclipse.emf.ecore.EClass; > import org.eclipse.emf.ecore.EClassifier; > import org.eclipse.emf.ecore.EDataType; > import org.eclipse.emf.ecore.EEnum; >+import org.eclipse.emf.ecore.EModelElement; > import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.EOperation; > import org.eclipse.emf.ecore.EPackage; > import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.emf.ecore.ETypeParameter; > import org.eclipse.emf.ecore.EValidator; > import org.eclipse.emf.ecore.EcorePackage; > import org.eclipse.emf.ecore.InternalEObject; >@@ -8995,6 +9006,46 @@ > { > return super.findGenClassifier(classifier); > } >+ >+ @Override >+ public GenFeature findGenFeature(EStructuralFeature feature) >+ { >+ return super.findGenFeature(feature); >+ } >+ >+ @Override >+ public GenOperation findGenOperation(EOperation operation) >+ { >+ return super.findGenOperation(operation); >+ } >+ >+ public GenTypeParameter findGenTypeParameter(ETypeParameter eTypeParameter) >+ { >+ for (EObject eObject = eTypeParameter.eContainer(); eObject != null; eObject = eObject.eContainer()) >+ { >+ if (eObject instanceof EOperation) >+ { >+ EOperation eOperation = (EOperation)eObject; >+ int index = eOperation.getETypeParameters().indexOf(eTypeParameter); >+ if (index != -1) >+ { >+ GenOperation genOperation = findGenOperation(eOperation); >+ return genOperation.getGenTypeParameters().get(index); >+ } >+ } >+ else if (eObject instanceof EClassifier) >+ { >+ EClassifier eClassifier = (EClassifier)eObject; >+ int index = eClassifier.getETypeParameters().indexOf(eTypeParameter); >+ if (index != -1) >+ { >+ GenClassifier genClassifier = findGenClassifier(eClassifier); >+ return genClassifier.getGenTypeParameters().get(index); >+ } >+ } >+ } >+ return null; >+ } > > public boolean isSuppressedAnnotation(String source) > { >@@ -9378,4 +9429,127 @@ > return getEditorModuleName(); > } > >+ public void initialize() >+ { >+ Resource resource = eResource(); >+ if (resource != null) >+ { >+ URI uri = resource.getURI(); >+ setModelDirectory(EclipseHelper.getModelDirectory(uri)); >+ setComplianceLevel(EclipseHelper.getComplianceLevel(uri)); >+ } >+ setUpdateClasspath(false); >+ setOperationReflection(true); >+ setMinimalReflectiveMethods(true); >+ setRootExtendsClass("org.eclipse.emf.ecore.impl.MinimalEObjectImpl$Container"); >+ GenPackage mainGenPackage = getMainGenPackage(); >+ setModelName(mainGenPackage.getPrefix()); >+ GenRuntimeVersion[] values = GenRuntimeVersion.values(); >+ setRuntimeVersion(values[values.length - 1]); >+ >+ handleAnnotations(this, mainGenPackage.getEcorePackage()); >+ for (TreeIterator<EObject> i = eAllContents(); i.hasNext();) >+ { >+ EObject content = i.next(); >+ if (content instanceof GenBase) >+ { >+ GenBase genBase = (GenBase)content; >+ EModelElement eModelElement = genBase.getEcoreModelElement(); >+ if (eModelElement != null) >+ { >+ handleAnnotations(genBase, eModelElement); >+ } >+ } >+ } >+ } >+ >+ protected void handleAnnotations(GenBase genBase, EModelElement eModelElement) >+ { >+ EAnnotation eAnnotation = eModelElement.getEAnnotation(GenModelPackage.eNS_URI); >+ if (eAnnotation != null) >+ { >+ EClass eClass = genBase.eClass(); >+ for (Map.Entry<String, String> entry : eAnnotation.getDetails()) >+ { >+ EStructuralFeature eStructuralFeature = eClass.getEStructuralFeature(entry.getKey()); >+ if (eStructuralFeature instanceof EAttribute) >+ { >+ EAttribute eAttribute = (EAttribute)eStructuralFeature; >+ genBase.eSet(eStructuralFeature, EcoreUtil.createFromString(eAttribute.getEAttributeType(), entry.getValue())); >+ } >+ } >+ } >+ } >+ >+ private static class EclipseHelper >+ { >+ static String getModelDirectory(URI uri) >+ { >+ if (EMFPlugin.IS_RESOURCES_BUNDLE_AVAILABLE) >+ { >+ try >+ { >+ IWorkspace workspace = ResourcesPlugin.getWorkspace(); >+ IProject project = workspace.getRoot().getProject(uri.segment(1)); >+ IJavaProject javaProject = JavaCore.create(project); >+ IClasspathEntry[] classpath = javaProject.getRawClasspath(); >+ IClasspathEntry bestEntry = null; >+ for (IClasspathEntry classpathEntry : classpath) >+ { >+ if (classpathEntry.getEntryKind() == IClasspathEntry.CPE_SOURCE) >+ { >+ // Look for the first entry that's Java source. >+ if (bestEntry == null) >+ { >+ bestEntry = classpathEntry; >+ } >+ // If there's a src-gen entry, prefer that over all others. >+ // >+ else if (classpathEntry.getPath().toString().endsWith("src-gen")) >+ { >+ bestEntry = classpathEntry; >+ } >+ } >+ } >+ return bestEntry == null ? project.getFullPath() + "/src" : bestEntry.getPath().toString(); >+ } >+ catch (Exception exception) >+ { >+ CodeGenEcorePlugin.INSTANCE.log(exception); >+ } >+ } >+ return null; >+ } >+ >+ static GenJDKLevel getComplianceLevel(URI uri) >+ { >+ if (EMFPlugin.IS_RESOURCES_BUNDLE_AVAILABLE) >+ { >+ try >+ { >+ IWorkspace workspace = ResourcesPlugin.getWorkspace(); >+ IProject project = workspace.getRoot().getProject(uri.segment(2)); >+ String complianceLevel = CodeGenUtil.EclipseUtil.getJavaComplianceLevel(project); >+ if ("1.5".equals(complianceLevel)) >+ { >+ return GenJDKLevel.JDK50_LITERAL; >+ } >+ else if ("1.6".equals(complianceLevel)) >+ { >+ return GenJDKLevel.JDK60_LITERAL; >+ } >+ else if ("1.4".equals(complianceLevel)) >+ { >+ return GenJDKLevel.JDK14_LITERAL; >+ } >+ } >+ catch (Exception exception) >+ { >+ CodeGenEcorePlugin.INSTANCE.log(exception); >+ } >+ } >+ return GenJDKLevel.JDK50_LITERAL; >+ } >+ } >+ > } //GenModelImpl >Index: src/org/eclipse/emf/codegen/ecore/genmodel/impl/GenTypeParameterImpl.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.codegen.ecore/src/org/eclipse/emf/codegen/ecore/genmodel/impl/GenTypeParameterImpl.java,v >retrieving revision 1.5 >diff -u -r1.5 GenTypeParameterImpl.java >--- src/org/eclipse/emf/codegen/ecore/genmodel/impl/GenTypeParameterImpl.java 11 Jun 2007 21:09:49 -0000 1.5 >+++ src/org/eclipse/emf/codegen/ecore/genmodel/impl/GenTypeParameterImpl.java 21 Aug 2011 18:24:05 -0000 >@@ -23,6 +23,7 @@ > import org.eclipse.emf.common.notify.Notification; > import org.eclipse.emf.ecore.EClass; > import org.eclipse.emf.ecore.EGenericType; >+import org.eclipse.emf.ecore.EModelElement; > import org.eclipse.emf.ecore.EObject; > import org.eclipse.emf.ecore.ETypeParameter; > import org.eclipse.emf.ecore.InternalEObject; >@@ -252,5 +253,11 @@ > } > return result.toString().trim(); > } >+ >+ @Override >+ public EModelElement getEcoreModelElement() >+ { >+ return getEcoreTypeParameter(); >+ } > > } //GenTypeParameterImpl >#P org.eclipse.emf.ecore >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.ecore/plugin.properties,v >retrieving revision 1.41 >diff -u -r1.41 plugin.properties >--- plugin.properties 3 Dec 2010 01:23:45 -0000 1.41 >+++ plugin.properties 21 Aug 2011 18:24:07 -0000 >@@ -122,6 +122,7 @@ > _UI_SettingDelegateRegistry_extensionpoint = Feature Setting Delegate Factory Registry > _UI_InvocationDelegateRegistry_extensionpoint = Operation Invocation Delegate Factory Registry > _UI_QueryDelegateRegistry_extensionpoint = Query Delegate Factory Registry >+_UI_ConversionDelegateRegistry_extensionpoint = Conversion Delegate Factory Registry > > _UI_GenericInvariant_diagnostic = The ''{0}'' invariant is violated on ''{1}'' > _UI_GenericConstraint_diagnostic = The ''{0}'' constraint is violated on ''{1}'' >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.ecore/plugin.xml,v >retrieving revision 1.26 >diff -u -r1.26 plugin.xml >--- plugin.xml 3 Dec 2010 01:23:45 -0000 1.26 >+++ plugin.xml 21 Aug 2011 18:24:07 -0000 >@@ -14,6 +14,7 @@ > <extension-point id="setting_delegate" name="%_UI_SettingDelegateRegistry_extensionpoint" schema="schema/setting_delegate.exsd"/> > <extension-point id="invocation_delegate" name="%_UI_InvocationDelegateRegistry_extensionpoint" schema="schema/invocation_delegate.exsd"/> > <extension-point id="query_delegate" name="%_UI_QueryDelegateRegistry_extensionpoint" schema="schema/query_delegate.exsd"/> >+ <extension-point id="conversion_delegate" name="%_UI_ConversionDelegateRegistry_extensionpoint" schema="schema/conversion_delegate.exsd"/> > > <extension point="org.eclipse.emf.ecore.generated_package"> > <package >Index: schema/conversion_delegate.exsd >=================================================================== >RCS file: schema/conversion_delegate.exsd >diff -N schema/conversion_delegate.exsd >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ schema/conversion_delegate.exsd 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,124 @@ >+<?xml version='1.0' encoding='UTF-8'?> >+<!-- Schema file written by PDE --> >+<schema targetNamespace="org.eclipse.emf.ecore" xmlns="http://www.w3.org/2001/XMLSchema"> >+<annotation> >+ <appInfo> >+ <meta.schema plugin="org.eclipse.emf.ecore" id="conversion_delegate" name="Conversion Delegate Factory Registry"/> >+ </appInfo> >+ <documentation> >+ This extension point is used to define a factory for conversion delegates whose type is identified by a URI. The global EMF conversion delegate factory registry, <samp>EDataType.Internal.ConversionDelegate.Factory.Registry.INSTANCE</samp>, is used to record the registration. >+ </documentation> >+ </annotation> >+ >+ <element name="extension"> >+ <annotation> >+ <appInfo> >+ <meta.element /> >+ </appInfo> >+ </annotation> >+ <complexType> >+ <sequence> >+ <element ref="factory" minOccurs="1" maxOccurs="unbounded"/> >+ </sequence> >+ <attribute name="point" type="string" use="required"> >+ <annotation> >+ <documentation> >+ A fully qualified identifier of the target extension point. >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="id" type="string"> >+ <annotation> >+ <documentation> >+ An optional identifier of the extension instance. >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="name" type="string"> >+ <annotation> >+ <documentation> >+ An optional name of the extension instance. >+ </documentation> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <element name="factory"> >+ <annotation> >+ <appInfo> >+ <meta.element labelAttribute="id"/> >+ </appInfo> >+ </annotation> >+ <complexType> >+ <attribute name="uri" type="string" use="required"> >+ <annotation> >+ <documentation> >+ A URI identifying the type of conversion delegates that can be created by the factory. >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="class" type="string" use="required"> >+ <annotation> >+ <documentation> >+ The fully qualified name of a Java class implementing <samp>org.eclipse.emf.ecore.EDataType.Internal.Delegate.Factory</samp>. >+ </documentation> >+ <appInfo> >+ <meta.attribute kind="java" basedOn="org.eclipse.emf.ecore.EDataType.Internal.ConversionDelegate.Factory"/> >+ </appInfo> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="since"/> >+ </appInfo> >+ <documentation> >+ 2.8.0 >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="examples"/> >+ </appInfo> >+ <documentation> >+ Following is an example of how an conversion delegate factory can be registered: >+<pre> >+ <extension point="org.eclipse.emf.ecore.conversion_delegate" > >+ <factory uri="http://www.eclipse.org/emf/2002/Ecore/Javascript" class="org.eclipse.emf.js4emf.ecore.internal.delegates.JavascriptDelegateFactory"/> >+ </extension> >+</pre> >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="apiInfo"/> >+ </appInfo> >+ <documentation> >+ The value of the class attribute must represent a class that implements <samp>org.eclipse.emf.ecore.EDataType.Internal.ConversionDelegate.Factory</samp> and has a no argument contructor. >+<p> >+A conversion delegate factory can be also registered from the source code with the <samp>EDataType.Internal.ConversionDelegate.Factory.Registry.INSTANCE</samp> as follows: >+</p> >+<pre> >+ EDataType.Internal.ConversionDelegate.Factory.Registry.INSTANCE.put("http://www.eclipse.org/emf/2002/Ecore/Javascript", new JavascriptDelegateFactory()); >+</pre> >+ </documentation> >+ </annotation> >+ >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="copyright"/> >+ </appInfo> >+ <documentation> >+ Copyright (c) 2011 Hallvard Traetteberg and others.<br> >+All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at <a >+href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a> >+ </documentation> >+ </annotation> >+ >+</schema> >Index: src/org/eclipse/emf/ecore/EDataType.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/EDataType.java,v >retrieving revision 1.4 >diff -u -r1.4 EDataType.java >--- src/org/eclipse/emf/ecore/EDataType.java 14 Jun 2007 18:32:46 -0000 1.4 >+++ src/org/eclipse/emf/ecore/EDataType.java 21 Aug 2011 18:24:08 -0000 >@@ -16,6 +16,8 @@ > */ > package org.eclipse.emf.ecore; > >+import java.util.HashMap; >+import java.util.Map; > > > /** >@@ -70,4 +72,103 @@ > */ > void setSerializable(boolean value); > >+ /** >+ * Internal API implemented by all data types. >+ * @since 2.8 >+ */ >+ interface Internal >+ { >+ /** >+ * An API for converting values of the data type to and from a string representation. >+ */ >+ interface ConversionDelegate >+ { >+ /** >+ * A factory for creating conversion delegates. >+ */ >+ interface Factory >+ { >+ /** >+ * Creates a conversion delegate for the given EDataType. >+ * @param eDataType the EDataType for which a conversion delegate is to be created. >+ * @return a new conversion delegate for the given EDataType. >+ */ >+ ConversionDelegate createConversionDelegate(EDataType eDataType); >+ >+ /** >+ * A <code>Factory</code> wrapper that is used by the {@link Factory.Registry}. >+ */ >+ interface Descriptor >+ { >+ Factory getFactory(); >+ } >+ >+ /** >+ * A registry of factories for creating conversion delegates. >+ */ >+ interface Registry extends Map<String, Object> >+ { >+ Registry INSTANCE = new Impl(); >+ >+ Factory getFactory(String uri); >+ >+ class Impl extends HashMap<String, Object> implements Registry >+ { >+ private static final long serialVersionUID = 1L; >+ >+ @Override >+ public Object get(Object key) >+ { >+ Object factory = super.get(key); >+ if (factory instanceof Descriptor) >+ { >+ Descriptor factoryDescriptor = (Descriptor)factory; >+ factory = factoryDescriptor.getFactory(); >+ put((String)key, factory); >+ return factory; >+ } >+ else >+ { >+ return factory; >+ } >+ } >+ >+ public Factory getFactory(String uri) >+ { >+ return (Factory)get(uri); >+ } >+ } >+ } >+ } >+ >+ /** >+ * Converts a value of the data type to a string literal. >+ * @param value the value to be converted. >+ * @return the literal representation of the value. >+ */ >+ String convertToString(Object value); >+ >+ /** >+ * Creates a value of the data type from a string literal. >+ * @param literal the string literal to be converted. >+ * @return the value of the literal representation. >+ */ >+ Object createFromString(String literal); >+ } >+ >+ /** >+ * Returns the delegate for this data type. >+ * A default delegate implementation need not be available, >+ * so this might <code>null</code>. >+ * @return the delegate for this feature. >+ */ >+ ConversionDelegate getConversionDelegate(); >+ >+ /** >+ * Sets the specialized delegate for this data type. >+ * @param settingDelegate the specialized delegate. >+ */ >+ void setConversionDelegate(ConversionDelegate conversionDelegate); >+ } >+ > } //EDataType >Index: src/org/eclipse/emf/ecore/impl/EDataTypeImpl.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/impl/EDataTypeImpl.java,v >retrieving revision 1.12 >diff -u -r1.12 EDataTypeImpl.java >--- src/org/eclipse/emf/ecore/impl/EDataTypeImpl.java 22 Dec 2008 14:24:54 -0000 1.12 >+++ src/org/eclipse/emf/ecore/impl/EDataTypeImpl.java 21 Aug 2011 18:24:08 -0000 >@@ -18,6 +18,7 @@ > > > import java.util.Collection; >+import java.util.List; > > import org.eclipse.emf.common.notify.Notification; > import org.eclipse.emf.ecore.EAnnotation; >@@ -25,6 +26,7 @@ > import org.eclipse.emf.ecore.EDataType; > import org.eclipse.emf.ecore.ETypeParameter; > import org.eclipse.emf.ecore.EcorePackage; >+import org.eclipse.emf.ecore.util.EcoreUtil; > > > /** >@@ -40,7 +42,7 @@ > * > * @generated > */ >-public class EDataTypeImpl extends EClassifierImpl implements EDataType >+public class EDataTypeImpl extends EClassifierImpl implements EDataType, EDataType.Internal > { > /** > * The default value of the '{@link #isSerializable() <em>Serializable</em>}' attribute. >@@ -326,4 +328,34 @@ > return result.toString(); > } > >+ protected ConversionDelegate conversionDelegate; >+ protected boolean conversionDelegateIsSet; >+ >+ public ConversionDelegate getConversionDelegate() >+ { >+ if (conversionDelegate == null) >+ { >+ List<String> conversionDelegates = EcoreUtil.getConversionDelegates(getEPackage()); >+ if (!conversionDelegates.isEmpty()) >+ { >+ for (String eDataTypeDelegateUri : conversionDelegates) >+ { >+ String body = EcoreUtil.getAnnotation(this, eDataTypeDelegateUri, "createFromString"); >+ if (body != null) >+ { >+ EDataType.Internal.ConversionDelegate.Factory eDataTypeDelegateFactory = EcoreUtil.getConversionDelegateFactory(this); >+ conversionDelegate = eDataTypeDelegateFactory.createConversionDelegate(this); >+ conversionDelegateIsSet = true; >+ } >+ } >+ } >+ } >+ return conversionDelegate; >+ } >+ >+ public void setConversionDelegate(ConversionDelegate conversionDelegate) >+ { >+ this.conversionDelegate = conversionDelegate; >+ } >+ > } >Index: src/org/eclipse/emf/ecore/impl/EFactoryImpl.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/impl/EFactoryImpl.java,v >retrieving revision 1.30 >diff -u -r1.30 EFactoryImpl.java >--- src/org/eclipse/emf/ecore/impl/EFactoryImpl.java 20 Jul 2010 22:12:48 -0000 1.30 >+++ src/org/eclipse/emf/ecore/impl/EFactoryImpl.java 21 Aug 2011 18:24:08 -0000 >@@ -359,6 +359,12 @@ > throw new IllegalArgumentException("The value '" + stringValue + "' does not match any member types of the union datatype '" + eDataType.getName() + "'"); > } > >+ EDataType.Internal.ConversionDelegate conversionDelegate = ((EDataType.Internal)eDataType).getConversionDelegate(); >+ if (conversionDelegate != null) >+ { >+ return conversionDelegate.createFromString(stringValue); >+ } >+ > Class<?> c = EcoreUtil.wrapperClassFor(eDataType.getInstanceClass()); > if (c == null) return null; > >@@ -523,6 +529,12 @@ > throw new IllegalArgumentException("Invalid value: '" + objectValue + "' for datatype :"+eDataType.getName()); > } > >+ EDataType.Internal.ConversionDelegate conversionDelegate = ((EDataType.Internal)eDataType).getConversionDelegate(); >+ if (conversionDelegate != null) >+ { >+ return conversionDelegate.convertToString(objectValue); >+ } >+ > if (objectValue == null) > { > return null; >Index: src/org/eclipse/emf/ecore/plugin/ConversionDelegateFactoryRegistryReader.java >=================================================================== >RCS file: src/org/eclipse/emf/ecore/plugin/ConversionDelegateFactoryRegistryReader.java >diff -N src/org/eclipse/emf/ecore/plugin/ConversionDelegateFactoryRegistryReader.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/ecore/plugin/ConversionDelegateFactoryRegistryReader.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,92 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2011 Hallvard Traetteberg and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Hallvard Traetteberg - Initial API and implementation >+ * >+ * </copyright> >+ * >+ * $Id$ >+ */ >+package org.eclipse.emf.ecore.plugin; >+ >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.emf.ecore.EDataType; >+ >+ >+/** >+ * A plugin extension reader that populates the >+ * {@link org.eclipse.emf.ecore.util.EDataType.ConversionDelegate.Factory.Registry#INSTANCE global} EDataType delegate factory registry. >+ * Clients are not expected to use this class directly. >+ */ >+class ConversionDelegateFactoryRegistryReader extends RegistryReader >+{ >+ static class ConversionDelegateFactoryDescriptor extends PluginClassDescriptor implements EDataType.Internal.ConversionDelegate.Factory.Descriptor >+ { >+ protected EDataType.Internal.ConversionDelegate.Factory factory; >+ >+ public ConversionDelegateFactoryDescriptor(IConfigurationElement e, String attrName) >+ { >+ super(e, attrName); >+ } >+ >+ public EDataType.Internal.ConversionDelegate.Factory getFactory() >+ { >+ if (factory == null) >+ { >+ factory = (EDataType.Internal.ConversionDelegate.Factory)createInstance(); >+ } >+ return factory; >+ } >+ } >+ >+ static final String TAG_FACTORY = "factory"; >+ static final String ATT_URI = "uri"; >+ static final String ATT_CLASS = "class"; >+ >+ public ConversionDelegateFactoryRegistryReader() >+ { >+ super(Platform.getExtensionRegistry(), EcorePlugin.getPlugin().getBundle().getSymbolicName(), EcorePlugin.CONVERSION_DELEGATE_PPID); >+ } >+ >+ @Override >+ protected boolean readElement(IConfigurationElement element, boolean add) >+ { >+ if (element.getName().equals(TAG_FACTORY)) >+ { >+ String uri = element.getAttribute(ATT_URI); >+ if (uri == null) >+ { >+ logMissingAttribute(element, ATT_URI); >+ } >+ else if (element.getAttribute(ATT_CLASS) == null) >+ { >+ logMissingAttribute(element, ATT_CLASS); >+ } >+ else if (add) >+ { >+ Object previous = EDataType.Internal.ConversionDelegate.Factory.Registry.INSTANCE.put(uri, new ConversionDelegateFactoryDescriptor(element, ATT_CLASS)); >+ if (previous instanceof ConversionDelegateFactoryDescriptor) >+ { >+ ConversionDelegateFactoryDescriptor descriptor = (ConversionDelegateFactoryDescriptor)previous; >+ EcorePlugin.INSTANCE.log("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a conversion delegate factory for '" + uri + "'"); >+ } >+ return true; >+ } >+ else >+ { >+ EDataType.Internal.ConversionDelegate.Factory.Registry.INSTANCE.remove(uri); >+ return true; >+ } >+ } >+ >+ return false; >+ } >+} >Index: src/org/eclipse/emf/ecore/plugin/EcorePlugin.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/plugin/EcorePlugin.java,v >retrieving revision 1.26 >diff -u -r1.26 EcorePlugin.java >--- src/org/eclipse/emf/ecore/plugin/EcorePlugin.java 3 Dec 2010 01:23:45 -0000 1.26 >+++ src/org/eclipse/emf/ecore/plugin/EcorePlugin.java 21 Aug 2011 18:24:09 -0000 >@@ -639,4 +639,5 @@ > public static final String SETTING_DELEGATE_PPID = "setting_delegate"; > public static final String INVOCATION_DELEGATE_PPID = "invocation_delegate"; > public static final String QUERY_DELEGATE_PPID = "query_delegate"; >+ public static final String CONVERSION_DELEGATE_PPID = "conversion_delegate"; > } >\ No newline at end of file >Index: src/org/eclipse/emf/ecore/util/EObjectValidator.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/util/EObjectValidator.java,v >retrieving revision 1.37 >diff -u -r1.37 EObjectValidator.java >--- src/org/eclipse/emf/ecore/util/EObjectValidator.java 12 Jan 2011 16:24:26 -0000 1.37 >+++ src/org/eclipse/emf/ecore/util/EObjectValidator.java 21 Aug 2011 18:24:10 -0000 >@@ -1649,7 +1649,7 @@ > { > getValueLabel(eDataType, value, context), > value == null ? "<null>" : value.getClass().getName(), >- eDataType.getInstanceClass().getName() >+ eDataType.getInstanceClassName() > }, > new Object [] { value, eDataType }, > context)); >Index: src/org/eclipse/emf/ecore/util/EcoreUtil.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/util/EcoreUtil.java,v >retrieving revision 1.75 >diff -u -r1.75 EcoreUtil.java >--- src/org/eclipse/emf/ecore/util/EcoreUtil.java 12 May 2011 15:08:56 -0000 1.75 >+++ src/org/eclipse/emf/ecore/util/EcoreUtil.java 21 Aug 2011 18:24:12 -0000 >@@ -4318,6 +4318,75 @@ > return null; > } > >+ /** >+ * @since 2.8 >+ */ >+ public static List<String> getConversionDelegates(EPackage ePackage) >+ { >+ EAnnotation eAnnotation = ePackage.getEAnnotation(EcorePackage.eNS_URI); >+ if (eAnnotation != null) >+ { >+ String eDataTypeDelegates = eAnnotation.getDetails().get("conversionDelegates"); >+ if (eDataTypeDelegates != null) >+ { >+ List<String> result = new ArrayList<String>(); >+ for (StringTokenizer stringTokenizer = new StringTokenizer(eDataTypeDelegates); stringTokenizer.hasMoreTokens();) >+ { >+ String eDataTypeDelegate = stringTokenizer.nextToken(); >+ result.add(eDataTypeDelegate); >+ } >+ return result; >+ } >+ } >+ return Collections.emptyList(); >+ } >+ >+ public static void setConversionDelegates(EPackage ePackage, List<String> eDataTypeDelegates) >+ { >+ EAnnotation eAnnotation = ePackage.getEAnnotation(EcorePackage.eNS_URI); >+ if (eDataTypeDelegates == null || eDataTypeDelegates.isEmpty()) >+ { >+ if (eAnnotation != null) >+ { >+ eAnnotation.getDetails().remove("conversionDelegates"); >+ } >+ } >+ else >+ { >+ if (eAnnotation == null) >+ { >+ eAnnotation = EcoreFactory.eINSTANCE.createEAnnotation(); >+ eAnnotation.setSource(EcorePackage.eNS_URI); >+ ePackage.getEAnnotations().add(eAnnotation); >+ } >+ StringBuffer value = new StringBuffer(); >+ for (Iterator<String> i = eDataTypeDelegates.iterator(); i.hasNext();) >+ { >+ value.append(i.next()); >+ if (i.hasNext()) >+ { >+ value.append(' '); >+ } >+ } >+ eAnnotation.getDetails().put("conversionDelegates", value.toString()); >+ } >+ } >+ >+ /** >+ * @since 2.8 >+ */ >+ public static EDataType.Internal.ConversionDelegate.Factory getConversionDelegateFactory(EDataType eDataType) >+ { >+ for (String eDataTypeDelegate : getConversionDelegates(eDataType.getEPackage())) >+ { >+ if (eDataType.getEAnnotation(eDataTypeDelegate) != null) >+ { >+ return EDataType.Internal.ConversionDelegate.Factory.Registry.INSTANCE.getFactory(eDataTypeDelegate); >+ } >+ } >+ return null; >+ } >+ > /* > static > { >Index: src/org/eclipse/emf/ecore/util/EcoreValidator.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/util/EcoreValidator.java,v >retrieving revision 1.45 >diff -u -r1.45 EcoreValidator.java >--- src/org/eclipse/emf/ecore/util/EcoreValidator.java 13 May 2011 15:08:08 -0000 1.45 >+++ src/org/eclipse/emf/ecore/util/EcoreValidator.java 21 Aug 2011 18:24:14 -0000 >@@ -2580,7 +2580,7 @@ > createDiagnostic > (Diagnostic.ERROR, > DIAGNOSTIC_SOURCE, >- VALID_LOWER_BOUND, >+ VALID_DEFAULT_VALUE_LITERAL, > "_UI_EStructuralFeatureValidDefaultValueLiteral_diagnostic", > new Object[] { defaultValueLiteral }, > new Object[] { eStructuralFeature }, >#P org.eclipse.emf.ecore.change >Index: src/org/eclipse/emf/ecore/change/impl/ChangeDescriptionImpl.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.ecore.change/src/org/eclipse/emf/ecore/change/impl/ChangeDescriptionImpl.java,v >retrieving revision 1.23 >diff -u -r1.23 ChangeDescriptionImpl.java >--- src/org/eclipse/emf/ecore/change/impl/ChangeDescriptionImpl.java 7 Apr 2011 23:41:05 -0000 1.23 >+++ src/org/eclipse/emf/ecore/change/impl/ChangeDescriptionImpl.java 21 Aug 2011 18:24:15 -0000 >@@ -479,7 +479,7 @@ > } > }; > Collection<EObject> newObjectsToAttach = copier.copyAll(objectToDetach); >- copier.copyReferences(); >+ // copier.copyReferences(); > > // The children of the objects to attach might become orphans; > // we'll need to check for that later. >@@ -612,6 +612,10 @@ > { > newObjectsToAttach.add(eObject); > } >+ else >+ { >+ newObjectsToAttach.remove(eObject); >+ } > } > > // Reverse the objects to attach and detach lists. >Index: src/org/eclipse/emf/ecore/change/impl/FeatureChangeImpl.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.ecore.change/src/org/eclipse/emf/ecore/change/impl/FeatureChangeImpl.java,v >retrieving revision 1.38 >diff -u -r1.38 FeatureChangeImpl.java >--- src/org/eclipse/emf/ecore/change/impl/FeatureChangeImpl.java 7 Apr 2011 23:41:05 -0000 1.38 >+++ src/org/eclipse/emf/ecore/change/impl/FeatureChangeImpl.java 21 Aug 2011 18:24:15 -0000 >@@ -718,9 +718,21 @@ > > protected void reverse(EList<Object> toList) > { >+ EList<Object> copy = null; > for (ListChange listChange : getListChanges()) > { >- listChange.reverse(toList); >+ if (listChange.getKind() == ChangeKind.REMOVE_LITERAL) >+ { >+ if (copy == null) >+ { >+ copy = new BasicEList<Object>(toList); >+ } >+ listChange.applyAndReverse(copy); >+ } >+ else >+ { >+ listChange.reverse(toList); >+ } > } > } > >Index: src/org/eclipse/emf/ecore/change/util/ChangeRecorder.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.ecore.change/src/org/eclipse/emf/ecore/change/util/ChangeRecorder.java,v >retrieving revision 1.49 >diff -u -r1.49 ChangeRecorder.java >--- src/org/eclipse/emf/ecore/change/util/ChangeRecorder.java 7 Apr 2011 23:41:05 -0000 1.49 >+++ src/org/eclipse/emf/ecore/change/util/ChangeRecorder.java 21 Aug 2011 18:24:15 -0000 >@@ -252,7 +252,7 @@ > > protected boolean isOrphan(EObject eObject) > { >- return eObject.eContainer() == null && eObject.eResource() == null; >+ return ((InternalEObject)eObject).eInternalContainer() == null && eObject.eResource() == null; > } > > public void notifyChanged(Notification notification) >#P org.eclipse.emf.ecore.editor >Index: src/org/eclipse/emf/ecore/presentation/EcoreEditor.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.ecore.editor/src/org/eclipse/emf/ecore/presentation/EcoreEditor.java,v >retrieving revision 1.62 >diff -u -r1.62 EcoreEditor.java >--- src/org/eclipse/emf/ecore/presentation/EcoreEditor.java 12 May 2011 20:21:12 -0000 1.62 >+++ src/org/eclipse/emf/ecore/presentation/EcoreEditor.java 21 Aug 2011 18:24:17 -0000 >@@ -19,6 +19,7 @@ > > import java.io.IOException; > import java.io.InputStream; >+import java.lang.reflect.Method; > > import java.util.ArrayList; > import java.util.Collection; >@@ -32,6 +33,7 @@ > > import org.eclipse.core.resources.IFile; > import org.eclipse.core.resources.IMarker; >+import org.eclipse.core.resources.IProject; > import org.eclipse.core.resources.IResource; > import org.eclipse.core.resources.IResourceChangeEvent; > import org.eclipse.core.resources.IResourceChangeListener; >@@ -113,6 +115,7 @@ > > import org.eclipse.emf.common.notify.AdapterFactory; > import org.eclipse.emf.common.notify.Notification; >+import org.eclipse.emf.common.notify.impl.AdapterImpl; > > import org.eclipse.emf.common.ui.MarkerHelper; > >@@ -762,7 +765,7 @@ > * This sets up the editing domain for the model editor. > * <!-- begin-user-doc --> > * <!-- end-user-doc --> >- * @generated >+ * @generated NOT > */ > protected void initializeEditingDomain() > { >@@ -808,9 +811,49 @@ > } > }); > >+ ResourceSet resourceSet = null; >+ try >+ { >+ Class<?> xtextResourceSetClass = CommonPlugin.loadClass("org.eclipse.xtext", "org.eclipse.xtext.resource.XtextResourceSet"); >+ >+ resourceSet = (ResourceSet)xtextResourceSetClass.newInstance(); >+ class EditingDomainProvider extends AdapterImpl implements IEditingDomainProvider >+ { >+ public EditingDomain getEditingDomain() >+ { >+ return editingDomain; >+ } >+ @Override >+ public boolean isAdapterForType(Object type) >+ { >+ return IEditingDomainProvider.class.equals(type); >+ } >+ } >+ resourceSet.eAdapters().add(new EditingDomainProvider()); >+ } >+ catch (Exception e) >+ { >+ e.printStackTrace(); >+ // ignore missing Xtext >+ } >+ > // Create the editing domain with a special command stack. > // >- editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new HashMap<Resource, Boolean>()); >+ editingDomain = >+ new AdapterFactoryEditingDomain(adapterFactory, commandStack, resourceSet) >+ { >+ { >+ resourceToReadOnlyMap = new HashMap<Resource, Boolean>(); >+ } >+ @Override >+ public boolean isReadOnly(Resource resource) >+ { >+ return >+ "java".equals(resource.getURI().scheme()) || >+ "xcore".equals(resource.getURI().fileExtension()) || >+ super.isReadOnly(resource); >+ } >+ }; > } > > /** >@@ -1637,7 +1680,7 @@ > * This is called during startup. > * <!-- begin-user-doc --> > * <!-- end-user-doc --> >- * @generated >+ * @generated NOT > */ > @Override > public void init(IEditorSite site, IEditorInput editorInput) >@@ -1648,6 +1691,22 @@ > site.setSelectionProvider(this); > site.getPage().addPartListener(partListener); > ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener, IResourceChangeEvent.POST_CHANGE); >+ >+ try >+ { >+ ResourceSet resourceSet = editingDomain.getResourceSet(); >+ Method setClasspathURIContextMethod = resourceSet.getClass().getMethod("setClasspathURIContext", Object.class); >+ Class<?> javaCoreClass = CommonPlugin.loadClass("org.eclipse.jdt.core", "org.eclipse.jdt.core.JavaCore"); >+ IProject project = ((IFileEditorInput)editorInput).getFile().getProject(); >+ Method createMethod = javaCoreClass.getMethod("create", IProject.class); >+ Object javaProject = createMethod.invoke(null, project); >+ setClasspathURIContextMethod.invoke(resourceSet, javaProject); >+ } >+ catch (Exception e) >+ { >+ e.printStackTrace(); >+ // ignore missing Xtext >+ } > } > > /** >#P org.eclipse.emf.test.core >Index: src/org/eclipse/emf/test/core/change/ChangeDescriptionReverseTest.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/change/ChangeDescriptionReverseTest.java,v >retrieving revision 1.1 >diff -u -r1.1 ChangeDescriptionReverseTest.java >--- src/org/eclipse/emf/test/core/change/ChangeDescriptionReverseTest.java 7 Apr 2011 23:41:08 -0000 1.1 >+++ src/org/eclipse/emf/test/core/change/ChangeDescriptionReverseTest.java 21 Aug 2011 18:24:19 -0000 >@@ -36,6 +36,7 @@ > import org.eclipse.emf.ecore.EObject; > import org.eclipse.emf.ecore.EPackage; > import org.eclipse.emf.ecore.EcoreFactory; >+import org.eclipse.emf.ecore.InternalEObject; > import org.eclipse.emf.ecore.change.ChangeDescription; > import org.eclipse.emf.ecore.change.util.ChangeRecorder; > import org.eclipse.emf.ecore.resource.Resource; >@@ -54,6 +55,7 @@ > public static Test suite() > { > TestSuite ts = new TestSuite("ChangeDescription copyAndReverse Test"); >+ /* > ts.addTest(new ChangeDescriptionReverseTest("testOne")); > ts.addTest(new ChangeDescriptionReverseTest("testTwo")); > ts.addTest(new ChangeDescriptionReverseTest("testThree")); >@@ -61,6 +63,8 @@ > ts.addTest(new ChangeDescriptionReverseTest("testFive")); > ts.addTest(new ChangeDescriptionReverseTest("testSix")); > ts.addTest(new ChangeDescriptionReverseTest("testSeven")); >+ */ >+ ts.addTest(new ChangeDescriptionReverseTest("testEight")); > return ts; > } > >@@ -81,6 +85,13 @@ > makeChanges(); > > ChangeDescription changeDescription = changeRecorder.endRecording(); >+ { >+ ResourceSet finalResourceSet = new ResourceSetImpl(); >+ Resource changeDescriptionResource = finalResourceSet.createResource(URI.createURI("changes.change")); >+ changeDescriptionResource.getContents().add(changeDescription); >+ changeDescriptionResource.save(System.err, null); >+ >+ } > changeDescription.copyAndReverse(eObjectToProxyURIMap); > > ResourceSet finalResourceSet = new ResourceSetImpl(); >@@ -288,6 +299,67 @@ > }.doit(); > } > >+ public void testEight() throws Exception >+ { >+ new TestHelper() >+ { >+ Resource ecoreResource; >+ EPackage ecorePackage; >+ >+ @Override >+ void loadResources(ResourceSet resourceSet) >+ { >+ ecoreResource = resourceSet.getResource(URI.createURI("platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore"), true); >+ ecorePackage = (EPackage)ecoreResource.getContents().get(0); >+ >+ EAnnotation eAnnotation = EcoreFactory.eINSTANCE.createEAnnotation(); >+ ecorePackage.getEAnnotations().add(eAnnotation); >+ >+ eAnnotation.setSource(getName()); >+ >+ EList<EObject> references = eAnnotation.getReferences(); >+ >+ EObject eClassProxy = EcoreFactory.eINSTANCE.createEObject(); >+ ((InternalEObject)eClassProxy).eSetProxyURI(URI.createURI("platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EClass")); >+ references.add(eClassProxy); >+ >+ EObject ePackageProxy = EcoreFactory.eINSTANCE.createEObject(); >+ ((InternalEObject)ePackageProxy).eSetProxyURI(URI.createURI("platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EPackage")); >+ references.add(ePackageProxy); >+ } >+ >+ @Override >+ void makeChanges() >+ { >+ EList<EObject> references = ecorePackage.getEAnnotation(getName()).getReferences(); >+ references.clear(); >+ >+ references.add(ecorePackage.getEClassifier("EClass")); >+ references.add(ecorePackage.getEClassifier("EPackage")); >+ >+ EClass eClass = EcoreFactory.eINSTANCE.createEClass(); >+ eClass.setName("NewClass"); >+ >+ EAnnotation eAnnotation = EcoreFactory.eINSTANCE.createEAnnotation(); >+ eAnnotation.getReferences().add(eClass); >+ >+ EPackage ePackage = EcoreFactory.eINSTANCE.createEPackage(); >+ ePackage.setName("NewPackage"); >+ >+ ePackage.getEClassifiers().add(eClass); >+ >+ ecorePackage.getESubpackages().add(ePackage); >+ ecorePackage.getEAnnotations().add(eAnnotation); >+ >+ ResourceSet resourceSet = ecoreResource.getResourceSet(); >+ resourceSet.createResource(URI.createURI("platform:/plugin/org.eclipse.emf.ecore/model/EPackage/NewPackage.ecore")).getContents().add( >+ ePackage); >+ resourceSet.createResource(URI.createURI("platform:/plugin/org.eclipse.emf.ecore/model/EClass/NewClass.ecore")).getContents().add( >+ eClass); >+ } >+ }.doit(); >+ } >+ > void assertEquals(ResourceSet resourceSet1, ResourceSet resourceSet2) > { > EcoreUtil.resolveAll(resourceSet1); >Index: src/org/eclipse/emf/test/core/ecore/BadEcoreDiagnosticTest.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/ecore/BadEcoreDiagnosticTest.java,v >retrieving revision 1.15 >diff -u -r1.15 BadEcoreDiagnosticTest.java >--- src/org/eclipse/emf/test/core/ecore/BadEcoreDiagnosticTest.java 3 Dec 2010 20:42:55 -0000 1.15 >+++ src/org/eclipse/emf/test/core/ecore/BadEcoreDiagnosticTest.java 21 Aug 2011 18:24:19 -0000 >@@ -1192,7 +1192,7 @@ > assertEquals(Diagnostic.ERROR, diagnostic126.getSeverity()); > assertEquals("org.eclipse.emf.ecore.model", diagnostic126.getSource()); > assertEquals("The default value literal '256' must be a valid literal of the attribute's type", removeObjectHashCode(diagnostic126.getMessage())); >- assertEquals(39, diagnostic126.getCode()); >+ assertEquals(38, diagnostic126.getCode()); > assertEquals(1, diagnostic126.getChildren().size()); > assertEquals(1, diagnostic126.getData().size()); > assertNull(diagnostic126.getException()); >@@ -1210,7 +1210,7 @@ > assertEquals(Diagnostic.ERROR, diagnostic128.getSeverity()); > assertEquals("org.eclipse.emf.ecore.model", diagnostic128.getSource()); > assertEquals("The default value literal '' must be a valid literal of the attribute's type", removeObjectHashCode(diagnostic128.getMessage())); >- assertEquals(39, diagnostic128.getCode()); >+ assertEquals(38, diagnostic128.getCode()); > assertEquals(0, diagnostic128.getChildren().size()); > assertEquals(1, diagnostic128.getData().size()); > assertNull(diagnostic128.getException());
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 354245
:
201141
|
201408
|
201453
|
201873
|
201883
|
202635
|
202849
|
202955
|
203077
|
205521
|
205526