Class CompilationContext
java.lang.Object
io.micronaut.el.processor.compiler.CompilationContext
The compilation time counterpart of a
jakarta.el.ELContext.
It holds the statically known types of the variables, the imported classes and packages, and the
functions of the expressions of a type, as declared with io.micronaut.el.annotation.ELEnvironment.
- Since:
- 1.0
- Author:
- Denis Stepanov
-
Constructor Summary
ConstructorsConstructorDescriptionCompilationContext(io.micronaut.inject.visitor.VisitorContext visitorContext, io.micronaut.inject.ast.Element originatingElement, ELFunctionDiscovery discovery, Map<String, io.micronaut.inject.ast.ClassElement> variables, Map<String, io.micronaut.inject.ast.ClassElement> importedClasses, List<String> importedPackages, List<io.micronaut.inject.ast.ClassElement> staticImports, Map<String, io.micronaut.inject.ast.MethodElement> functions) -
Method Summary
Modifier and TypeMethodDescriptionvoidenterLambdaScope(Map<String, ELCompiler.Typed> parameters, boolean withinEvaluation) Enters the scope of a lambda expression.voidExits the scope of a lambda expression.io.micronaut.inject.ast.Elementio.micronaut.inject.visitor.VisitorContextbooleanbooleanisLambdaParameter(String name) @Nullable ELCompiler.TypedlambdaParameter(String name) static StringqualifiedFunctionName(String prefix, String localName) @Nullable io.micronaut.inject.ast.ClassElementresolveClass(String simpleName) Resolves a class by its simple name, as described in the section 1.24.2 of the specification.@Nullable io.micronaut.inject.ast.MethodElementresolveFunction(String prefix, String localName) @Nullable io.micronaut.inject.ast.FieldElementresolveStaticField(String name) Resolves a static field imported statically, as described in the section 1.24.2 of the specification.@Nullable io.micronaut.inject.ast.MethodElementresolveStaticMethod(String name, int arguments) Resolves a static method imported statically, as described in the section 1.24.2 of the specification.@Nullable io.micronaut.inject.ast.ClassElementvariableType(String name)
-
Constructor Details
-
CompilationContext
public CompilationContext(io.micronaut.inject.visitor.VisitorContext visitorContext, io.micronaut.inject.ast.Element originatingElement, ELFunctionDiscovery discovery, Map<String, io.micronaut.inject.ast.ClassElement> variables, Map<String, io.micronaut.inject.ast.ClassElement> importedClasses, List<String> importedPackages, List<io.micronaut.inject.ast.ClassElement> staticImports, Map<String, io.micronaut.inject.ast.MethodElement> functions) - Parameters:
visitorContext- The visitor contextoriginatingElement- The element the expressions are declared ondiscovery- The functions discovered without a declarationvariables- The types of the variables by nameimportedClasses- The imported classes by simple nameimportedPackages- The imported packagesstaticImports- The classes imported staticallyfunctions- The functions by qualified name
-
-
Method Details
-
getOriginatingElement
public io.micronaut.inject.ast.Element getOriginatingElement()- Returns:
- The element the expressions are declared on, where the diagnostics are reported
-
getVisitorContext
public io.micronaut.inject.visitor.VisitorContext getVisitorContext()- Returns:
- The visitor context
-
variableType
- Parameters:
name- The name of the variable- Returns:
- The declared type of the variable or
nullwhen the variable is not declared
-
isLambdaParameter
- Parameters:
name- The name- Returns:
- True when the name is a parameter of one of the enclosing lambda expressions
-
lambdaParameter
- Parameters:
name- The name- Returns:
- The compiled parameter of the innermost enclosing lambda expression declaring the name, or
nullwhen no enclosing lambda expression declares it
-
inValueLambda
public boolean inValueLambda()- Returns:
- Whether the compilation is inside the body of a lambda expression compiled to a value, which may be invoked later, with another context, so that nothing of the evaluation can be shared with it
-
enterLambdaScope
Enters the scope of a lambda expression.- Parameters:
parameters- The formal parameters by name, compiled to the Java parameters holding themwithinEvaluation- Whether the lambda runs within the evaluation it is written in, as a Java lambda passed to a method does, rather than as a value invoked later
-
exitLambdaScope
public void exitLambdaScope()Exits the scope of a lambda expression. -
resolveClass
Resolves a class by its simple name, as described in the section 1.24.2 of the specification.- Parameters:
simpleName- The simple name- Returns:
- The class or
nullwhen the name is not an imported class
-
resolveStaticField
Resolves a static field imported statically, as described in the section 1.24.2 of the specification.- Parameters:
name- The name of the field- Returns:
- The field or
null
-
resolveStaticMethod
public @Nullable io.micronaut.inject.ast.MethodElement resolveStaticMethod(String name, int arguments) Resolves a static method imported statically, as described in the section 1.24.2 of the specification.- Parameters:
name- The name of the methodarguments- The number of arguments- Returns:
- The method or
null
-
resolveFunction
-
qualifiedFunctionName
-