org.eclipse.xtend.core.jvmmodel
Class XtendJvmModelInferrer

java.lang.Object
  extended by org.eclipse.xtend.core.jvmmodel.XtendJvmModelInferrer
All Implemented Interfaces:
IJvmModelInferrer

@NonNullByDefault
public class XtendJvmModelInferrer
extends java.lang.Object
implements IJvmModelInferrer

Author:
Jan Koehnlein - Initial contribution and API, Sven Efftinge

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.eclipse.xtext.xbase.jvmmodel.IJvmModelInferrer
IJvmModelInferrer.NullImpl
 
Field Summary
static java.lang.String CREATE_CHACHE_VARIABLE_PREFIX
           
static java.lang.String CREATE_INITIALIZER_PREFIX
           
protected  TypesFactory typesFactory
           
 
Constructor Summary
XtendJvmModelInferrer()
           
 
Method Summary
protected  void addDataObjectMethods(XtendClass source, JvmGenericType inferredJvmType)
           
protected  void addDefaultConstructor(XtendClass source, JvmGenericType target)
           
protected  void appendSyntheticDispatchMethods(XtendClass source, JvmGenericType target)
           
protected  java.lang.String computeFieldName(XtendField field, JvmGenericType declaringType)
           
protected  void computeInferredReturnTypes(JvmGenericType inferredJvmType)
           
protected  boolean containsAnnotation(org.eclipse.emf.common.util.EList<XAnnotation> annotations, java.lang.Class<Property> class1)
           
protected  void copyAndFixTypeParameters(java.util.List<JvmTypeParameter> typeParameters, JvmTypeParameterDeclarator target)
           
protected  JvmOperation deriveGenericDispatchOperationSignature(java.util.List<JvmOperation> sortedOperations, JvmGenericType target)
           
protected  JvmConstructor getSuperConstructor(XtendClass source)
           
protected  JvmTypeReference getTypeProxy(org.eclipse.emf.ecore.EObject pointer)
           
protected  boolean hasAnnotation(XtendAnnotationTarget source, java.lang.Class<?> class1)
           
protected  boolean hasMethod(XtendClass xtendClass, java.lang.String simpleName, java.util.List<? extends JvmFormalParameter> parameters)
           
 void infer(org.eclipse.emf.ecore.EObject xtendFile, IJvmDeclaredTypeAcceptor acceptor, boolean preIndexingPhase)
           This method is called at two different times in a resource's life-cycle, reflected by whether {preIndexingPhase} is set to true or false.
protected  void initialize(XtendClass source, JvmGenericType inferredJvmType)
           
protected  void transform(XtendConstructor source, JvmGenericType container)
           
protected  void transform(XtendField source, JvmGenericType container)
           
protected  void transform(XtendFunction source, JvmGenericType container)
           
protected  void transform(XtendMember sourceMember, JvmGenericType container)
           
protected  void transformCreateExtension(XtendFunction source, CreateExtensionInfo createExtensionInfo, JvmGenericType container, JvmOperation operation, JvmTypeReference returnType)
           
protected  void translateParameter(JvmExecutable executable, XtendParameter parameter)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CREATE_INITIALIZER_PREFIX

public static final java.lang.String CREATE_INITIALIZER_PREFIX
See Also:
Constant Field Values

CREATE_CHACHE_VARIABLE_PREFIX

public static final java.lang.String CREATE_CHACHE_VARIABLE_PREFIX
See Also:
Constant Field Values

typesFactory

@Inject
protected TypesFactory typesFactory
Constructor Detail

XtendJvmModelInferrer

public XtendJvmModelInferrer()
Method Detail

infer

public void infer(@Nullable
                  org.eclipse.emf.ecore.EObject xtendFile,
                  IJvmDeclaredTypeAcceptor acceptor,
                  boolean preIndexingPhase)
Description copied from interface: IJvmModelInferrer

This method is called at two different times in a resource's life-cycle, reflected by whether {preIndexingPhase} is set to true or false. When set to true everything is still in a pre-indexing phase, that means linking hasn't been done yet. In this phase you just need to create the Jvm-elements which should be indexed (i.e. found globally). For regular Xbase expressions only the JvmTypes with the correct qualified name are needed at this point.

You must only infer Jvm elements which directly result from elements contained in the current resource!

When this method is called with preIndexingPhase set to false, you need to do the full inference including setting all links. But still you have to it in a particular order. First you need to create the complete tree structure and make sure you have passed the created JvmTypes to the acceptor. Only pass top level JvmTypes to the acceptor. Only if the tree structure is created and its root types have been passed to the acceptor, you are free to resolve any cross references.

Specified by:
infer in interface IJvmModelInferrer
Parameters:
xtendFile - the root element from the parse result
acceptor - an acceptor awaiting derived root JvmDeclaredTypes
preIndexingPhase - whether the call is done in before indexing. During this phase clients may not rely on any global indexing information and only need to to provide the information needed by the language's IDefaultResourceDescriptionStrategy. IF not implemented differently this is just the JvmDeclaredTypes with their qualified name, but no members and no other data.

initialize

protected void initialize(XtendClass source,
                          JvmGenericType inferredJvmType)

hasAnnotation

protected boolean hasAnnotation(XtendAnnotationTarget source,
                                java.lang.Class<?> class1)

addDataObjectMethods

protected void addDataObjectMethods(XtendClass source,
                                    JvmGenericType inferredJvmType)

getSuperConstructor

@Nullable
protected JvmConstructor getSuperConstructor(XtendClass source)

copyAndFixTypeParameters

protected void copyAndFixTypeParameters(java.util.List<JvmTypeParameter> typeParameters,
                                        JvmTypeParameterDeclarator target)

appendSyntheticDispatchMethods

protected void appendSyntheticDispatchMethods(XtendClass source,
                                              JvmGenericType target)

deriveGenericDispatchOperationSignature

@Nullable
protected JvmOperation deriveGenericDispatchOperationSignature(java.util.List<JvmOperation> sortedOperations,
                                                                        JvmGenericType target)
Returns:
a JvmOperation with common denominator argument types of all given operations

addDefaultConstructor

protected void addDefaultConstructor(XtendClass source,
                                     JvmGenericType target)

transform

protected void transform(XtendMember sourceMember,
                         JvmGenericType container)

transform

protected void transform(XtendFunction source,
                         JvmGenericType container)

transformCreateExtension

protected void transformCreateExtension(XtendFunction source,
                                        CreateExtensionInfo createExtensionInfo,
                                        JvmGenericType container,
                                        JvmOperation operation,
                                        @Nullable
                                        JvmTypeReference returnType)

translateParameter

protected void translateParameter(JvmExecutable executable,
                                  XtendParameter parameter)

transform

protected void transform(XtendConstructor source,
                         JvmGenericType container)

transform

protected void transform(XtendField source,
                         JvmGenericType container)

hasMethod

protected boolean hasMethod(XtendClass xtendClass,
                            java.lang.String simpleName,
                            java.util.List<? extends JvmFormalParameter> parameters)

containsAnnotation

protected boolean containsAnnotation(org.eclipse.emf.common.util.EList<XAnnotation> annotations,
                                     java.lang.Class<Property> class1)

computeFieldName

@Nullable
protected java.lang.String computeFieldName(XtendField field,
                                                     JvmGenericType declaringType)

computeInferredReturnTypes

protected void computeInferredReturnTypes(JvmGenericType inferredJvmType)

getTypeProxy

protected JvmTypeReference getTypeProxy(org.eclipse.emf.ecore.EObject pointer)