Class BlockScope
java.lang.Object
org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Scope
org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BlockScope
- Direct Known Subclasses:
CodeSnippetScope, MethodScope, ModuleScope
-
Nested Class Summary
Nested classes/interfaces inherited from class Scope
Scope.Substitutor -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final VariableBinding[]Used only during analyseCode and only for checking if a resource was closed in a finallyBlock.booleanintintstatic final VariableBinding[]static final VariableBinding[]intbooleanintintScope[]Fields inherited from class Scope
AUTOBOX_COMPATIBLE, BLOCK_SCOPE, CLASS_SCOPE, COMPATIBLE, COMPATIBLE_IGNORING_MISSING_TYPE, COMPILATION_UNIT_SCOPE, compilationUnitScope, EQUAL_OR_MORE_SPECIFIC, kind, METHOD_SCOPE, MODULE_SCOPE, MORE_GENERIC, NOT_COMPATIBLE, NOT_REDUNDANT, NOT_RELATED, parent, VARARGS_COMPATIBLEModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intintstatic final intstatic final intstatic final intstatic final intstatic Bindingstatic final intstatic final int -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBlockScope(int kind, Scope parent) BlockScope(BlockScope parent) BlockScope(BlockScope parent, boolean addToParentScope) BlockScope(BlockScope parent, int variableCount) -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddAnonymousType(TypeDeclaration anonymousType, ReferenceBinding superBinding) final voidaddLocalType(TypeDeclaration localType) final voidaddLocalVariable(LocalVariableBinding binding) voidaddSubscope(Scope childScope) voidvoidadjustLocalVariablePositions(int delta) final booleanAnswer true if the receiver is suitable for assigning final blank fields.voidcheckAppropriateMethodAgainstSupers(char[] selector, MethodBinding compileTimeMethod, TypeBinding[] parameters, InvocationSite site) 15.12.3 (Java 8) "Compile-Time Step 3: Is the Chosen Method Appropriate?"voidcheckUnclosedCloseables(FlowInfo flowInfo, FlowContext flowContext, ASTNode location, BlockScope locationScope) At the end of a block check the closing-status of all tracked closeables that are declared in this block.voidcorrelateTrackingVarsIfElse(FlowInfo thenFlowInfo, FlowInfo elseFlowInfo) If one branch of an if-else closes any AutoCloseable resource, and if the same resource is known to be null on the other branch mark it as closed, too, so that merging both branches indicates that the resource is always closed.voidemulateOuterAccess(LocalVariableBinding outerLocalVariable) protected Scopefinal ReferenceBindingfindLocalType(char[] name) findVariable(char[] variableName) getBinding(char[][] compoundName, int mask, InvocationSite invocationSite, boolean needResolve) final BindinggetBinding(char[][] compoundName, InvocationSite invocationSite) getCloseTrackerFor(LocalVariableBinding localVariable) Retrieve the nearest tracking variable for the given original binding.getEmulationPath(LocalVariableBinding outerLocalVariable) Object[]getEmulationPath(ReferenceBinding targetEnclosingType, boolean onlyExactMatch, boolean denyEnclosingArgInConstructorCall) booleanfinal booleanisDuplicateLocalVariable(char[] name) intfinal booleanReturns true if the context requires to check initialization of final blank fields.See also the contract ofProblemReporter.close().voidpropagateInnerEmulation(ReferenceBinding targetType, boolean isEnclosingInstanceSupplied) voidpruneWrapperTrackingVar(FakedTrackingVariable trackingVariable) Unregister a wrapper resource without affecting its inner.intregisterTrackingVariable(FakedTrackingVariable fakedTrackingVariable) Register a tracking variable and compute its id.voidremoveTrackingVar(FakedTrackingVariable trackingVariable) When are no longer interested in this tracking variable - remove it.voidreparentLocals(boolean reparent) voidreportClashingDeclarations(LocalVariableBinding[] left, LocalVariableBinding[] right) booleaninttoString()toString(int tab) Methods inherited from class Scope
boxing, checkRedundantDefaultNullness, classScope, collectClassesBeingInitialized, compareTypes, compilationUnitScope, compilerOptions, computeCompatibleMethod, connectTypeVariables, convertEliminatingTypeVariables, createArrayType, createArrayType, createTypeVariables, deferBoundCheck, enclosingClassScope, enclosingInstanceScope, enclosingLambdaScope, enclosingMethodScope, enclosingReceiverType, enclosingReferenceContext, enclosingSourceType, enclosingSwitchLabel, enterEarlyConstructionContext, environment, exclude, findDefaultAbstractMethod, findDirectMemberType, findExactMethod, findField, findField, findMemberType, findMethod, findMethod0, findMethodForArray, findMethodInSuperInterfaces, findPrivilegedHandler, findType, findTypeVariable, getBaseType, getBinding, getCommonReferenceBinding, getConstructor, getConstructor0, getCurrentPackage, getDeclarationModifiers, getExactConstructor, getExactMethod, getField, getImplicitMethod, getJavaIoSerializable, getJavaLangAnnotationAnnotation, getJavaLangAssertionError, getJavaLangBoolean, getJavaLangByte, getJavaLangCharacter, getJavaLangClass, getJavaLangClassDesc, getJavaLangClassNotFoundException, getJavaLangCloneable, getJavaLangDouble, getJavaLangEnum, getJavaLangEnumDesc, getJavaLangError, getJavaLangFloat, getJavaLangIllegalArgumentException, getJavaLangIncompatibleClassChangeError, getJavaLangInteger, getJavaLangInvokeConstantBootstraps, getJavaLangInvokeLambdaMetafactory, getJavaLangInvokeMethodHandle, getJavaLangInvokeMethodHandlesLookup, getJavaLangInvokeSerializedLambda, getJavaLangInvokeStringConcatFactory, getJavaLangInvokeVarHandle, getJavaLangIterable, getJavaLangLong, getJavaLangNoClassDefFoundError, getJavaLangNoSuchFieldError, getJavaLangObject, getJavaLangRecord, getJavaLangReflectField, getJavaLangReflectMethod, getJavaLangRuntimeObjectMethods, getJavaLangRuntimeSwitchBootstraps, getJavaLangShort, getJavaLangString, getJavaLangStringBuffer, getJavaLangStringBuilder, getJavaLangThrowable, getJavaLangVoid, getJavaUtilIterator, getMatchingUninitializedType, getMemberType, getMethod, getOnlyPackage, getPackage, getStaticFactory, getType, getType, getType, getTypeOrPackage, greaterLowerBound, greaterLowerBound, hasDefaultNullnessFor, hasDefaultNullnessForType, hasErasedCandidatesCollisions, include, invocationType, isBoxingCompatibleWith, isDefinedInField, isDefinedInMethod, isDefinedInSameEnclosingType, isDefinedInSameUnit, isDefinedInType, isInsideCase, isInsideDeprecatedCode, isInsideEarlyConstructionContext, isInStaticContext, isInterTypeScope, isLambdaScope, isLambdaSubscope, isSubtypeOfRawType, leaveEarlyConstructionContext, localCheckRedundantDefaultNullness, localNonNullByDefaultValue, lowerUpperBound, methodScope, minimalErasedCandidates, module, mostSpecificClassMethodBinding, mostSpecificInterfaceMethodBinding, mostSpecificMethodBinding, namedMethodScope, nearestEnclosingStaticScope, originalReferenceContext, outerMostClassScope, outerMostMethodScope, parameterCompatibilityLevel, parameterCompatibilityLevel, parameterCompatibilityLevelFromInference, recordNonNullByDefault, referenceCompilationUnit, referenceContext, setParent, substitute, substitute, substitute, tagAsAccessingEnclosingInstanceStateOf, typeAnnotationsResolutionScope, validateNullAnnotationModifier and TypeMethodDescriptionboxing(TypeBinding type) checkRedundantDefaultNullness(int nullBits, int sourceStart) Check whether the given null default is redundant at the given position inside this scope.final ClassScopeThis method captures the status of early construction context at the declaration of a lambda expression.static intcompareTypes(TypeBinding left, TypeBinding right) final CompilationUnitScopefinal CompilerOptionsFinds the most specific compiler optionsprotected final MethodBindingcomputeCompatibleMethod(MethodBinding method, TypeBinding[] arguments, InvocationSite invocationSite) Internal use only Given a method, returns null if arguments cannot be converted to parameters.protected booleanconnectTypeVariables(TypeParameter[] typeParameters, boolean checkForErasedCandidateCollisions) Connect type variable supertypes, and returns true if no problem was detectedstatic TypeBindingconvertEliminatingTypeVariables(TypeBinding originalType, ReferenceBinding genericType, int rank, Set<TypeBinding> eliminatedVariables) Returns a type where either all variables or specific ones got discarded.createArrayType(TypeBinding type, int dimension) createArrayType(TypeBinding type, int dimension, AnnotationBinding[] annotations) createTypeVariables(TypeParameter[] typeParameters, Binding declaringElement) voiddeferBoundCheck(TypeReference typeRef) final ClassScopefinal MethodScopefinal MethodScopefinal ReferenceBindingReturns the immediately enclosing reference context, starting from current scope parent.final SourceTypeBindingReturns the immediately enclosing case statement (carried by closest blockScope),voidCalled when a ctor with a late explicit constructor call starts processing statements.final LookupEnvironmentvoidexclude(LocalVariableBinding[] bindings) protected MethodBindingfindDefaultAbstractMethod(ReferenceBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite, ReferenceBinding classHierarchyStart, ObjectVector found, MethodBinding[] concreteMatches) findDirectMemberType(char[] typeName, ReferenceBinding enclosingType) findExactMethod(ReferenceBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) findField(TypeBinding receiverType, char[] fieldName, InvocationSite invocationSite, boolean needResolve) findField(TypeBinding receiverType, char[] fieldName, InvocationSite invocationSite, boolean needResolve, boolean invisibleFieldsOk) findMemberType(char[] typeName, ReferenceBinding enclosingType) findMethod(ReferenceBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite, boolean inStaticContext) findMethod0(ReferenceBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite, boolean inStaticContext) findMethodForArray(ArrayBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) protected voidfindMethodInSuperInterfaces(ReferenceBinding receiverType, char[] selector, ObjectVector found, List<TypeBinding> visitedTypes, InvocationSite invocationSite) static final IPrivilegedHandlerfindType(char[] typeName, PackageBinding declarationPackage, PackageBinding invocationPackage) findTypeVariable(char[] name, SourceTypeBinding sourceType) Other scopes can override this methodstatic TypeBindinggetBaseType(char[] name) getBinding(char[] name, int mask, InvocationSite invocationSite, boolean needResolve) getCommonReferenceBinding(char[] typeName) getConstructor(ReferenceBinding receiverType, TypeBinding[] argumentTypes, InvocationSite invocationSite) getConstructor0(ReferenceBinding receiverType, TypeBinding[] argumentTypes, InvocationSite invocationSite) final PackageBindingintReturns the modifiers of the innermost enclosing declaration.getExactConstructor(TypeBinding receiverType, InvocationSite invocationSite) getExactMethod(TypeBinding receiverType, char[] selector, InvocationSite invocationSite) getField(TypeBinding receiverType, char[] fieldName, InvocationSite invocationSite) getImplicitMethod(char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) final ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindingfinal ReferenceBindinggetMatchingUninitializedType(TypeBinding targetClass, boolean considerEnclosings) final ReferenceBindinggetMemberType(char[] typeName, ReferenceBinding enclosingType) getMethod(TypeBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) final BindinggetOnlyPackage(char[][] compoundName) final BindinggetPackage(char[][] compoundName) getStaticFactory(ParameterizedTypeBinding allocationType, ReferenceBinding originalEnclosingType, TypeBinding[] argumentTypes, InvocationSite allocationSite) final TypeBindinggetType(char[] name) final TypeBindinggetType(char[][] compoundName, int typeNameLength) final TypeBindinggetType(char[] name, PackageBinding packageBinding) final BindinggetTypeOrPackage(char[][] compoundName) static ReferenceBinding[]greaterLowerBound(ReferenceBinding[] types) static TypeBinding[]greaterLowerBound(TypeBinding[] types, Scope scope, LookupEnvironment environment) booleanhasDefaultNullnessFor(int location, int sourceStart) Answer a defaultNullness defined for the closest enclosing scope, using bits from Binding.NullnessDefaultMASK.booleanhasDefaultNullnessForType(TypeBinding type, int location, int sourceStart) booleanhasErasedCandidatesCollisions(TypeBinding one, TypeBinding two, Map<TypeBinding, Object> invocations, ReferenceBinding type, ASTNode typeRef) voidinclude(LocalVariableBinding[] bindings) For Java scopes, the invocationType is always the same as the enclosingSourceType This distinction is important for AspectJ's inter-type declarations For inter-type declarations, the invocationType is the lexically enclosing type.booleanisBoxingCompatibleWith(TypeBinding expressionType, TypeBinding targetType) final booleanisDefinedInField(FieldBinding field) final booleanisDefinedInMethod(MethodBinding method) final booleanfinal booleanfinal booleanbooleanisInsideCase(CaseStatement caseStatement) Returns true if the scope or one of its parent is associated to a given caseStatement, denoting being part of a given switch case statement.booleanbooleanisInsideEarlyConstructionContext(TypeBinding targetClass, boolean considerEnclosings) Is an instance of targetClass currently being constructed in this scope?booleanbooleanbooleanbooleanbooleanisSubtypeOfRawType(TypeBinding paramType) voidCalled at the end of processing a late explicit constructor call.protected final BindinglocalCheckRedundantDefaultNullness(int nullBits, int position) final intlocalNonNullByDefaultValue(int start) lowerUpperBound(TypeBinding[] types) Returns VoidBinding if types have no intersection (e.g.final MethodScopeprotected TypeBinding[]minimalErasedCandidates(TypeBinding[] types, Map<TypeBinding, Object> allInvocations) Returns the most specific set of types compatible with all given types.module()protected final MethodBindingmostSpecificClassMethodBinding(MethodBinding[] visible, int visibleSize, InvocationSite invocationSite) protected final MethodBindingmostSpecificInterfaceMethodBinding(MethodBinding[] visible, int visibleSize, InvocationSite invocationSite) protected final MethodBindingmostSpecificMethodBinding(MethodBinding[] visible, int visibleSize, TypeBinding[] argumentTypes, InvocationSite invocationSite, ReferenceBinding receiverType) final MethodScopefinal MethodScopeReturns the nearest original reference context, starting from current scope.final ClassScopefinal MethodScopeintparameterCompatibilityLevel(MethodBinding method, TypeBinding[] arguments, InvocationSite site) intparameterCompatibilityLevel(TypeBinding arg, TypeBinding param) intparameterCompatibilityLevelFromInference(MethodBinding method, TypeBinding[] arguments, InvocationSite site) booleanrecordNonNullByDefault(Binding target, int value, Annotation annotation, int scopeStart, int scopeEnd) Record a NNBD annotation applying to a given source range within the current scopeReturns the nearest reference context, starting from current scope.voidstatic ReferenceBinding[]substitute(Substitution substitution, ReferenceBinding[] originalTypes) Returns an array of types, where original types got substituted given a substitution.static TypeBindingsubstitute(Substitution substitution, TypeBinding originalType) Returns a type, where original type was substituted using the receiver parameterized type.static TypeBinding[]substitute(Substitution substitution, TypeBinding[] originalTypes) Returns an array of types, where original types got substituted given a substitution.voidtagAsAccessingEnclosingInstanceStateOf(ReferenceBinding enclosingType, boolean typeVariableAccess) static BlockScopebooleanvalidateNullAnnotation(long tagBits, TypeReference typeRef, Annotation[] annotations)
-
Field Details
-
locals
-
localIndex
public int localIndex -
startIndex
public int startIndex -
offset
public int offset -
maxOffset
public int maxOffset -
shiftScopes
-
subscopes
-
subscopeCount
public int subscopeCount -
enclosingCase
-
EmulationPathToImplicitThis
-
NoEnclosingInstanceInConstructorCall
-
NoEnclosingInstanceInStaticContext
-
insideTypeDeclarationAnnotations
public boolean insideTypeDeclarationAnnotations -
blockStatement
-
resolvingGuardExpression
public boolean resolvingGuardExpression -
finallyInfo
Used only during analyseCode and only for checking if a resource was closed in a finallyBlock.
-
-
Constructor Details
-
BlockScope
-
BlockScope
-
BlockScope
-
BlockScope
-
-
Method Details
-
addAnonymousType
-
addLocalType
-
addLocalVariable
-
addSubscope
-
allowBlankFinalFieldAssignment
Answer true if the receiver is suitable for assigning final blank fields. in other words, it is inside an initializer, a constructor or a clinit -
adjustLocalVariablePositions
public void adjustLocalVariablePositions(int delta) -
adjustCurrentAndSubScopeLocalVariablePositions
public void adjustCurrentAndSubScopeLocalVariablePositions(int delta) -
emulateOuterAccess
-
findLocalType
-
findVariable
- Overrides:
findVariablein classScope
-
getBinding
public Binding getBinding(char[][] compoundName, int mask, InvocationSite invocationSite, boolean needResolve) -
getBinding
-
getEmulationPath
-
getEmulationPath
public Object[] getEmulationPath(ReferenceBinding targetEnclosingType, boolean onlyExactMatch, boolean denyEnclosingArgInConstructorCall) -
isDuplicateLocalVariable
public final boolean isDuplicateLocalVariable(char[] name) -
maxShiftedOffset
public int maxShiftedOffset() -
needBlankFinalFieldInitializationCheck
Returns true if the context requires to check initialization of final blank fields. in other words, it is inside an initializer, a constructor or a clinit -
problemReporter
Description copied from class:ScopeSee also the contract ofProblemReporter.close().- Specified by:
problemReporterin classScope
-
propagateInnerEmulation
public void propagateInnerEmulation(ReferenceBinding targetType, boolean isEnclosingInstanceSupplied) -
referenceType
-
scopeIndex
public int scopeIndex() -
toString
-
toString
-
registerTrackingVariable
Register a tracking variable and compute its id. -
removeTrackingVar
When are no longer interested in this tracking variable - remove it. -
pruneWrapperTrackingVar
Unregister a wrapper resource without affecting its inner. -
hasResourceTrackers
public boolean hasResourceTrackers() -
checkUnclosedCloseables
public void checkUnclosedCloseables(FlowInfo flowInfo, FlowContext flowContext, ASTNode location, BlockScope locationScope) At the end of a block check the closing-status of all tracked closeables that are declared in this block. Also invoked when entering unreachable code. -
findLastRelevantSubScope
-
correlateTrackingVarsIfElse
If one branch of an if-else closes any AutoCloseable resource, and if the same resource is known to be null on the other branch mark it as closed, too, so that merging both branches indicates that the resource is always closed. Example: FileReader fr1 = null; try {\n" + fr1 = new FileReader(someFile);" + fr1.read(buf);\n" + } finally {\n" + if (fr1 != null)\n" + try {\n" + fr1.close();\n" + } catch (IOException e) { // do nothing } // after this if statement fr1 is definitely not leaked } -
getCloseTrackerFor
Retrieve the nearest tracking variable for the given original binding. -
checkAppropriateMethodAgainstSupers
public void checkAppropriateMethodAgainstSupers(char[] selector, MethodBinding compileTimeMethod, TypeBinding[] parameters, InvocationSite site) 15.12.3 (Java 8) "Compile-Time Step 3: Is the Chosen Method Appropriate?" -
reparentLocals
public void reparentLocals(boolean reparent) -
reportClashingDeclarations
-
resolvingGuardExpression
public boolean resolvingGuardExpression()- Overrides:
resolvingGuardExpressionin classScope
-