4. IBatchTypeResolver
Cancelable Type Resolution for a Resource
Returns IResolvedTypes
Type for each JvmIdentifiableElement (Local Var, Param, ..)
Resolved Generics
For each XExpression:
Actual Type and Expected Type
Return Type and Expected Return Type
5. Actual Type vs Return Type
Type: What would ‘Extract Local Var’ do? == boolean
Return Type: What would ‘Extract Method’ yield? == void
{
if (!isValid(value))
return;
hashSet.add(value);
}
7. LightweightTypeReference
Solve the EMF Dilemma
Rich API
getSuperTypes, getTypeArguments,
isAssignableFrom, …
Context and Service Access via getOwner()
Lossless conversion from/to JvmTypeReference
9. Facade for Clients
Find Relevant Root Elements in Resource
Traverse Root Instance Tree
Guard Against Infinite Recursion
Prepare and Compute
Traverse Expression Trees
First Candidate for Customizing
IBatchTypeResolver
IReentrantTypeResolver
ITypeComputer
IBatchTypeResolver
13. Type System Invariants
All Expressions Must be Visited
All InferredTypes Must be Resolved
JvmMember Signatures Must be Complete
Explicit Tree Traversal
No eAllContents.forEach in Framework Code
21. Validate Expressions
def dispatch computeTypes(DateLiteral date, ITCState s) {
if (isInvalid(date.day, date.month, date.year)) {
s.addDiagnostic(new EObjectDiagnosticImpl(
Severity.ERROR, IssueCodes.INVALID_DATE_LITERAL,
’’’«day».«month».«year» is not a valid date’’’,
date, null, -1, Strings.EMPTY_ARRAY));
}
..
}
22. Library Types
Globally Available Types
XImportSectionNamespaceScopeProvider and
IImportsConfiguration
Globally Available Features
ImplicitlyImportedFeatures
Locally Available Features
ITypeComputationState.addImports
23. Library Types
def dispatch computeTypes(MyExpression e, ITCState s) {
s.addImports [ ITypeImporter it |
for(e: s.expectations) {
if (isEnum(e.expectedType)) {
it.importStatic(
e.expectedType.type as JvmEnumerationType)
}
}
]
// see also s.addTypeToStaticImportScope(..)
s.computeTypes(e.childExpression)
}
24. Different Qualities of Assignability
Synonyms
Type A is Convertable to Type B
Compiler / Interpreter Need Special Treatment
Native Assignability
Only Reasonable with Custom Interpreter / Runtime
Assignable According to Runtime
Custom Assignability Rules
27. Recap:
What to customize if …
JvmModelInferrer
Always
Put XExpression into “some” Context
Mark Types as Inferred
28. Recap:
What to customize if …
XbaseTypeComputer
Newly Introduced Expression
Modified Expression Semantics
29. Recap:
What to customize if …
DefaultReentrantTypeResolver
iff Expressions without JVM Model (Discouraged)
and Expressions not at Root Level
LogicalContainerAwareReentrantTypeResolver
Handle AntLR Error Recovery Situations
30. Recap:
What to customize if …
*ReentrantTypeResolver
Prepare Special Cases of InferredTypeIndicators
e.g. InferredType 1:n or 1:0 XExpression
31. Recap:
What to customize if …
DefaultBatchTypeResolver
Non-JVM Model Entry Points on Resource Level
LogicalContainerAwareBatchTypeResolver
Handle AntLR Error Recovery Situations
Usually Not Necessary