org.eclipse.emf.importer.java.builder
Class JavaEcoreBuilder

java.lang.Object
  extended byorg.eclipse.emf.importer.java.builder.JavaEcoreBuilder

public class JavaEcoreBuilder
extends java.lang.Object


Field Summary
protected  BasicDiagnostic basicDiagnostic
           
protected  java.util.Set demandCreatedEDataTypes
          The set of data types that were created without setting the instance class.
protected static java.util.regex.Pattern eAnnotationDetailExpression
           
protected static java.util.regex.Pattern eAnnotationExpression
           
protected  java.util.Map eClassToSuperTypeNamesMap
          The map from a class to its base class names.
protected  java.util.Map eModelElementToIDOMNodeMap
          The map from a model element to the corresponding JDOM node.
protected  java.util.Map eOperationToExceptionTypeNamesMap
          The map from an operation to its exception type names.
protected  java.util.Map ePackageToOrderingMap
          The map from package to the map of ordering constants.
protected  java.util.Map ePackageToPrefixMap
          The map from package to the it's prefix.
protected  java.util.Map eReferenceToOppositeNameMap
          The map from a reference to the name it's opposite.
protected  java.util.Map eTypedElementToInstanceTypeNameMap
          The map from a typed element to its datatype's instance type name.
protected  java.util.Map eTypedElementToTypeNameMap
          The map from a typed element to its type name.
protected static java.util.regex.Pattern extendsAnnotationExpression
          The pattern for extracting the @extends annotations.
protected  java.util.Collection externalGenModels
          All the external GenModels from all required projects.
protected  java.util.Map externalPackageNameToEPackageMap
          The map from a package name to the corresponding package.
protected  boolean foundJava
           
protected  GenModel genModel
          The GenModel being generated.
protected  IFile genModelFile
          The file being generated.
protected static java.util.regex.Pattern implementsAnnotationExpression
          The pattern for extracting the @implements annotations.
protected static org.eclipse.jdt.core.jdom.DOMFactory jdomFactory
          The factory used to create JDOM.
protected static java.util.regex.Pattern modelAnnotationExpression
          The pattern for extracting the @model annotations.
protected static java.util.regex.Pattern modelDocExpression
          The pattern for extracting the model documentation.
protected  GenModel oldGenModelVersion
          The old version to against which to reconcile.
protected  java.util.Map packageNameToEPackageMap
          The map from a package name to the corresponding package.
protected  java.util.Collection usedGenPackages
          All the used GenPackages.
 
Constructor Summary
JavaEcoreBuilder(IFile genModelFile)
          Creates a builder for the given file.
JavaEcoreBuilder(IFile genModelFile, GenModel oldGenModelVersion)
           
JavaEcoreBuilder(IFile genModelFile, GenModel oldGenModelVersion, GenModel genModel)
           
 
Method Summary
protected  IPath analyseProject(IProject project)
           
protected  void analyzeCompilationUnit(org.eclipse.jdt.core.jdom.IDOMCompilationUnit compilationUnit)
          Walks the compilation unit to analyze the type.
protected  void analyzeField(EEnum eEnum, org.eclipse.jdt.core.jdom.IDOMField field)
          Creates EEnumLiteral as appropriate.
protected  void analyzeMethod(EClass eClass, org.eclipse.jdt.core.jdom.IDOMMethod method)
          Creates an EOperation, EAttribute, or EReference as appropriate.
protected  ETypedElement analyzeMethod(EClass eClass, java.lang.String modelAnnotation, java.lang.String methodName, java.lang.String returnType, java.lang.String[] parameterNames, java.lang.String[] parameterTypes, java.lang.String[] exceptionTypes)
           
protected  void analyzeType(org.eclipse.jdt.core.jdom.IDOMType type)
          Walks the type either as an EClass or an ENum to analyze either the methods or the fields.
 void computeEPackages(Monitor monitor, ModelImporter modelImporter)
           
protected  EStructuralFeature createFeature(EClass eClass, java.lang.String name, EClassifier eType)
           
protected  ResourceSet createResourceSet()
           
 void determineExternalPackages(GenPackage genPackage)
           
protected  void determineExternalPackages(GenPackage genPackage, ModelImporter modelImporter)
           
protected  void error(java.lang.String message)
          Produces another IStatus in the MultiStatus.
protected  java.util.List extractEAnnotations(java.lang.String modelAnnotation)
           
 void getAllGenModelFiles(java.util.Collection result, IContainer container)
          Walks the container recursively.
 void getAllGenModelFiles(java.util.Collection result, IFile file)
          Walks the container recursively.
 void getAllReferencedProjects(java.util.Collection result, IProject[] projects)
          Walks the projects recursively.
 Diagnostic getDiagnostic()
          Returns the diagnostic.
protected  java.lang.String getExtendsAnnotation(java.lang.String comment)
          Returns the @extends/@implements annotation contents, or null.
protected  java.lang.String getFilteredModelAnnotations(java.lang.String modelAnnotation, java.lang.String filter)
          Returns the filtered matches xyzAttribute-name="value" or of xyxAttribute-name='value', or null.
 GenModel getGenModel()
          Returns the generator model.
protected  java.lang.String getModelAnnotation(java.lang.String comment)
          Returns the @model annotation contents, or null.
protected  java.lang.String getModelAnnotationAttribute(java.lang.String modelAnnotation, java.lang.String attributeName)
          Returns the unquoted value of attribute-name="value" or of attribute-name='value', or null.
protected  java.lang.String getModelAnnotationAttributes(java.lang.String modelAnnotation, java.lang.String attributeName)
          Returns the space separated concatenation of the unquoted value of each attribute-name="value" or attribute-name='value' repeat, or null.
protected  java.lang.String getModelDocumentation(java.lang.String comment)
          Returns the model documentation, or null.
protected  int getOrderingValue(ENamedElement eNamedElement, java.util.Map nameToIDMap)
           
 java.util.Collection getUsedGenPackages()
          Returns the list of used GenPackages.
protected  void handleETypedElement(ETypedElement eTypedElement, java.lang.String name, java.lang.String type, java.lang.String modelAnnotation, java.lang.String identifierName)
           
protected  EClassifier resolve(EModelElement eModelElement, java.lang.String typeName)
           
protected  EClassifier resolve(EModelElement eModelElement, java.lang.String typeName, boolean recordDemandCreatedEDataType)
           
protected  EClass resolveMapEntry(EPackage ePackage, EClassifier keyEClassifier, EClassifier valueEClassifier)
           
protected  EClassifier resolveType(ETypedElement eTypedElement)
           
protected  void sort(EList eList, java.util.Map nameToIDMap)
           
 void traverse(IContainer container, java.util.Set visited)
          Walks the container recursively.
 void traverse(IFile file)
          Analyzes .java files as JDOM compilation units.
 void used(EModelElement modelElement)
           
protected  void warning(java.lang.String message)
          Produces another IStatus in the MultiStatus, with warning severity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jdomFactory

protected static org.eclipse.jdt.core.jdom.DOMFactory jdomFactory
The factory used to create JDOM.


genModelFile

protected IFile genModelFile
The file being generated.


genModel

protected GenModel genModel
The GenModel being generated.


externalPackageNameToEPackageMap

protected java.util.Map externalPackageNameToEPackageMap
The map from a package name to the corresponding package. These are populated from the GenModels of required projects.


packageNameToEPackageMap

protected java.util.Map packageNameToEPackageMap
The map from a package name to the corresponding package. These are populated on demand during traversal as modeled class and enums are discovered.


ePackageToOrderingMap

protected java.util.Map ePackageToOrderingMap
The map from package to the map of ordering constants. These are populated as the package interface is traversed.


ePackageToPrefixMap

protected java.util.Map ePackageToPrefixMap
The map from package to the it's prefix. These are populated as the package interfaces are traversed.


eModelElementToIDOMNodeMap

protected java.util.Map eModelElementToIDOMNodeMap
The map from a model element to the corresponding JDOM node. These are populated during traversal as each model element is created.


eTypedElementToTypeNameMap

protected java.util.Map eTypedElementToTypeNameMap
The map from a typed element to its type name. These are populated during traversal as each typed element is created. They must be patched after traversal is completed.


eTypedElementToInstanceTypeNameMap

protected java.util.Map eTypedElementToInstanceTypeNameMap
The map from a typed element to its datatype's instance type name. These are populated during traversal as each typed element is created. They must be patched after traversal is completed. They are only needed if the instance must be determined bottom up.


demandCreatedEDataTypes

protected java.util.Set demandCreatedEDataTypes
The set of data types that were created without setting the instance class.


eClassToSuperTypeNamesMap

protected java.util.Map eClassToSuperTypeNamesMap
The map from a class to its base class names. These are populated during traversal as each class is created. They must be patched after traversal is completed.


eOperationToExceptionTypeNamesMap

protected java.util.Map eOperationToExceptionTypeNamesMap
The map from an operation to its exception type names. These are populated during traversal as each operation is created. They must be patched after traversal is completed.


eReferenceToOppositeNameMap

protected java.util.Map eReferenceToOppositeNameMap
The map from a reference to the name it's opposite. These are populated during traversal as each reference with an opposite is created. They must be patched after traversal and patching of typed elements is completed. The opposite found as a feature of the type.


externalGenModels

protected java.util.Collection externalGenModels
All the external GenModels from all required projects.


usedGenPackages

protected java.util.Collection usedGenPackages
All the used GenPackages.


basicDiagnostic

protected BasicDiagnostic basicDiagnostic

foundJava

protected boolean foundJava

oldGenModelVersion

protected GenModel oldGenModelVersion
The old version to against which to reconcile.


modelDocExpression

protected static java.util.regex.Pattern modelDocExpression
The pattern for extracting the model documentation.


modelAnnotationExpression

protected static java.util.regex.Pattern modelAnnotationExpression
The pattern for extracting the @model annotations.


extendsAnnotationExpression

protected static java.util.regex.Pattern extendsAnnotationExpression
The pattern for extracting the @extends annotations.


implementsAnnotationExpression

protected static java.util.regex.Pattern implementsAnnotationExpression
The pattern for extracting the @implements annotations.


eAnnotationExpression

protected static java.util.regex.Pattern eAnnotationExpression

eAnnotationDetailExpression

protected static java.util.regex.Pattern eAnnotationDetailExpression
Constructor Detail

JavaEcoreBuilder

public JavaEcoreBuilder(IFile genModelFile)
Creates a builder for the given file.


JavaEcoreBuilder

public JavaEcoreBuilder(IFile genModelFile,
                        GenModel oldGenModelVersion)

JavaEcoreBuilder

public JavaEcoreBuilder(IFile genModelFile,
                        GenModel oldGenModelVersion,
                        GenModel genModel)
Method Detail

createResourceSet

protected ResourceSet createResourceSet()

analyseProject

protected IPath analyseProject(IProject project)
                        throws java.lang.Exception
Throws:
java.lang.Exception

computeEPackages

public void computeEPackages(Monitor monitor,
                             ModelImporter modelImporter)
                      throws java.lang.Exception
Throws:
java.lang.Exception

used

public void used(EModelElement modelElement)

determineExternalPackages

public void determineExternalPackages(GenPackage genPackage)

determineExternalPackages

protected void determineExternalPackages(GenPackage genPackage,
                                         ModelImporter modelImporter)

getAllReferencedProjects

public void getAllReferencedProjects(java.util.Collection result,
                                     IProject[] projects)
                              throws CoreException
Walks the projects recursively.

Throws:
CoreException

getAllGenModelFiles

public void getAllGenModelFiles(java.util.Collection result,
                                IContainer container)
                         throws CoreException
Walks the container recursively.

Throws:
CoreException

getAllGenModelFiles

public void getAllGenModelFiles(java.util.Collection result,
                                IFile file)
                         throws CoreException
Walks the container recursively.

Throws:
CoreException

traverse

public void traverse(IContainer container,
                     java.util.Set visited)
              throws CoreException
Walks the container recursively.

Throws:
CoreException

traverse

public void traverse(IFile file)
              throws CoreException
Analyzes .java files as JDOM compilation units.

Throws:
CoreException

analyzeCompilationUnit

protected void analyzeCompilationUnit(org.eclipse.jdt.core.jdom.IDOMCompilationUnit compilationUnit)
Walks the compilation unit to analyze the type.


analyzeType

protected void analyzeType(org.eclipse.jdt.core.jdom.IDOMType type)
Walks the type either as an EClass or an ENum to analyze either the methods or the fields.


analyzeMethod

protected void analyzeMethod(EClass eClass,
                             org.eclipse.jdt.core.jdom.IDOMMethod method)
Creates an EOperation, EAttribute, or EReference as appropriate.


analyzeMethod

protected ETypedElement analyzeMethod(EClass eClass,
                                      java.lang.String modelAnnotation,
                                      java.lang.String methodName,
                                      java.lang.String returnType,
                                      java.lang.String[] parameterNames,
                                      java.lang.String[] parameterTypes,
                                      java.lang.String[] exceptionTypes)

handleETypedElement

protected void handleETypedElement(ETypedElement eTypedElement,
                                   java.lang.String name,
                                   java.lang.String type,
                                   java.lang.String modelAnnotation,
                                   java.lang.String identifierName)

createFeature

protected EStructuralFeature createFeature(EClass eClass,
                                           java.lang.String name,
                                           EClassifier eType)

analyzeField

protected void analyzeField(EEnum eEnum,
                            org.eclipse.jdt.core.jdom.IDOMField field)
Creates EEnumLiteral as appropriate.


getModelDocumentation

protected java.lang.String getModelDocumentation(java.lang.String comment)
Returns the model documentation, or null.


getModelAnnotation

protected java.lang.String getModelAnnotation(java.lang.String comment)
Returns the @model annotation contents, or null.


getExtendsAnnotation

protected java.lang.String getExtendsAnnotation(java.lang.String comment)
Returns the @extends/@implements annotation contents, or null.


getModelAnnotationAttribute

protected java.lang.String getModelAnnotationAttribute(java.lang.String modelAnnotation,
                                                       java.lang.String attributeName)
Returns the unquoted value of attribute-name="value" or of attribute-name='value', or null.


getModelAnnotationAttributes

protected java.lang.String getModelAnnotationAttributes(java.lang.String modelAnnotation,
                                                        java.lang.String attributeName)
Returns the space separated concatenation of the unquoted value of each attribute-name="value" or attribute-name='value' repeat, or null.


extractEAnnotations

protected java.util.List extractEAnnotations(java.lang.String modelAnnotation)

getFilteredModelAnnotations

protected java.lang.String getFilteredModelAnnotations(java.lang.String modelAnnotation,
                                                       java.lang.String filter)
Returns the filtered matches xyzAttribute-name="value" or of xyxAttribute-name='value', or null.


resolve

protected EClassifier resolve(EModelElement eModelElement,
                              java.lang.String typeName)

resolve

protected EClassifier resolve(EModelElement eModelElement,
                              java.lang.String typeName,
                              boolean recordDemandCreatedEDataType)

resolveMapEntry

protected EClass resolveMapEntry(EPackage ePackage,
                                 EClassifier keyEClassifier,
                                 EClassifier valueEClassifier)

resolveType

protected EClassifier resolveType(ETypedElement eTypedElement)

sort

protected void sort(EList eList,
                    java.util.Map nameToIDMap)

getOrderingValue

protected int getOrderingValue(ENamedElement eNamedElement,
                               java.util.Map nameToIDMap)

getDiagnostic

public Diagnostic getDiagnostic()
Returns the diagnostic.

Returns:
the status.

getGenModel

public GenModel getGenModel()
Returns the generator model.

Returns:
the generator model.

getUsedGenPackages

public java.util.Collection getUsedGenPackages()
Returns the list of used GenPackages.

Returns:
the list of used GenPackages.

error

protected void error(java.lang.String message)
Produces another IStatus in the MultiStatus.

Parameters:
message - a description of the error.

warning

protected void warning(java.lang.String message)
Produces another IStatus in the MultiStatus, with warning severity.

Parameters:
message - a description of the error.

Copyright 2001-2006 IBM Corporation and others.
All Rights Reserved.