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 201141 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]
Enhanced GenModel APIs
354245.patch (text/plain), 11.06 KB, created by
Ed Merks
on 2011-08-09 09:25:02 EDT
(
hide
)
Description:
Enhanced GenModel APIs
Filename:
MIME Type:
Creator:
Ed Merks
Created:
2011-08-09 09:25:02 EDT
Size:
11.06 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#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 9 Aug 2011 13:22:20 -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 9 Aug 2011 13:22:21 -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 9 Aug 2011 13:22:24 -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 9 Aug 2011 13:22:24 -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
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