/** * This method is used to reset the CanBeStatic the enclosing method of the current block */ public void resetEnclosingMethodStaticFlag() { MethodScope methodScope = methodScope(); if (methodScope != null) { if (methodScope.referenceContext instanceof MethodDeclaration) { MethodDeclaration methodDeclaration = (MethodDeclaration) methodScope.referenceContext; methodDeclaration.bits &= ~ASTNode.CanBeStatic; } else if (methodScope.referenceContext instanceof TypeDeclaration) { // anonymous type, find enclosing method methodScope = methodScope.enclosingMethodScope(); if (methodScope != null && methodScope.referenceContext instanceof MethodDeclaration) { MethodDeclaration methodDeclaration = (MethodDeclaration) methodScope.referenceContext; methodDeclaration.bits &= ~ASTNode.CanBeStatic; } } } }
public final void addAnonymousType(TypeDeclaration anonymousType, ReferenceBinding superBinding) { ClassScope anonymousClassScope = new ClassScope(this, anonymousType); anonymousClassScope.buildAnonymousTypeBinding( enclosingSourceType(), superBinding); /* Tag any enclosing lambdas as instance capturing. Strictly speaking they need not be, unless the local/anonymous type references enclosing instance state. but the types themselves track enclosing types regardless of whether the state is accessed or not. This creates a mismatch in expectations in code generation time, if we choose to make the lambda method static. To keep things simple and avoid a messy rollback, we force the lambda to be an instance method under this situation. However if per source, the lambda occurs in a static context, we would generate a static synthetic method. */ MethodScope methodScope = methodScope(); while (methodScope != null && methodScope.referenceContext instanceof LambdaExpression) { LambdaExpression lambda = (LambdaExpression) methodScope.referenceContext; if (!lambda.scope.isStatic && !lambda.scope.isConstructorCall) { lambda.shouldCaptureInstance = true; } methodScope = methodScope.enclosingMethodScope(); } }
public final void addAnonymousType(TypeDeclaration anonymousType, ReferenceBinding superBinding) { ClassScope anonymousClassScope = new ClassScope(this, anonymousType); anonymousClassScope.buildAnonymousTypeBinding( enclosingSourceType(), superBinding); /* Tag any enclosing lambdas as instance capturing. Strictly speaking they need not be, unless the local/anonymous type references enclosing instance state. but the types themselves track enclosing types regardless of whether the state is accessed or not. This creates a mismatch in expectations in code generation time, if we choose to make the lambda method static. To keep things simple and avoid a messy rollback, we force the lambda to be an instance method under this situation. However if per source, the lambda occurs in a static context, we would generate a static synthetic method. */ MethodScope methodScope = methodScope(); while (methodScope != null && methodScope.referenceContext instanceof LambdaExpression) { LambdaExpression lambda = (LambdaExpression) methodScope.referenceContext; if (!lambda.scope.isStatic && !lambda.scope.isConstructorCall) { lambda.shouldCaptureInstance = true; } methodScope = methodScope.enclosingMethodScope(); } }
public final void addAnonymousType(TypeDeclaration anonymousType, ReferenceBinding superBinding) { ClassScope anonymousClassScope = new ClassScope(this, anonymousType); anonymousClassScope.buildAnonymousTypeBinding( enclosingSourceType(), superBinding); /* Tag any enclosing lambdas as instance capturing. Strictly speaking they need not be, unless the local/anonymous type references enclosing instance state. but the types themselves track enclosing types regardless of whether the state is accessed or not. This creates a mismatch in expectations in code generation time, if we choose to make the lambda method static. To keep things simple and avoid a messy rollback, we force the lambda to be an instance method under this situation. However if per source, the lambda occurs in a static context, we would generate a static synthetic method. */ MethodScope methodScope = methodScope(); while (methodScope != null && methodScope.referenceContext instanceof LambdaExpression) { LambdaExpression lambda = (LambdaExpression) methodScope.referenceContext; if (!lambda.scope.isStatic && !lambda.scope.isConstructorCall) { lambda.shouldCaptureInstance = true; } methodScope = methodScope.enclosingMethodScope(); } }
public final void addLocalType(TypeDeclaration localType) { ClassScope localTypeScope = new ClassScope(this, localType); addSubscope(localTypeScope); localTypeScope.buildLocalTypeBinding(enclosingSourceType()); // See comment in addAnonymousType. MethodScope methodScope = methodScope(); while (methodScope != null && methodScope.referenceContext instanceof LambdaExpression) { LambdaExpression lambda = (LambdaExpression) methodScope.referenceContext; if (!lambda.scope.isStatic && !lambda.scope.isConstructorCall) { lambda.shouldCaptureInstance = true; } methodScope = methodScope.enclosingMethodScope(); } }
public final void addLocalType(TypeDeclaration localType) { ClassScope localTypeScope = new ClassScope(this, localType); addSubscope(localTypeScope); localTypeScope.buildLocalTypeBinding(enclosingSourceType()); // See comment in addAnonymousType. MethodScope methodScope = methodScope(); while (methodScope != null && methodScope.referenceContext instanceof LambdaExpression) { LambdaExpression lambda = (LambdaExpression) methodScope.referenceContext; if (!lambda.scope.isStatic && !lambda.scope.isConstructorCall) { lambda.shouldCaptureInstance = true; } methodScope = methodScope.enclosingMethodScope(); } }
public final void addAnonymousType(TypeDeclaration anonymousType, ReferenceBinding superBinding) { ClassScope anonymousClassScope = new ClassScope(this, anonymousType); anonymousClassScope.buildAnonymousTypeBinding( enclosingSourceType(), superBinding); /* Tag any enclosing lambdas as instance capturing. Strictly speaking they need not be, unless the local/anonymous type references enclosing instance state. but the types themselves track enclosing types regardless of whether the state is accessed or not. This creates a mismatch in expectations in code generation time, if we choose to make the lambda method static. To keep things simple and avoid a messy rollback, we force the lambda to be an instance method under this situation. However if per source, the lambda occurs in a static context, we would generate a static synthetic method. */ MethodScope methodScope = methodScope(); while (methodScope != null && methodScope.referenceContext instanceof LambdaExpression) { LambdaExpression lambda = (LambdaExpression) methodScope.referenceContext; if (!lambda.scope.isStatic && !lambda.scope.isConstructorCall) { lambda.shouldCaptureInstance = true; } methodScope = methodScope.enclosingMethodScope(); } }
public final void addAnonymousType(TypeDeclaration anonymousType, ReferenceBinding superBinding) { ClassScope anonymousClassScope = new ClassScope(this, anonymousType); anonymousClassScope.buildAnonymousTypeBinding( enclosingSourceType(), superBinding); /* Tag any enclosing lambdas as instance capturing. Strictly speaking they need not be, unless the local/anonymous type references enclosing instance state. but the types themselves track enclosing types regardless of whether the state is accessed or not. This creates a mismatch in expectations in code generation time, if we choose to make the lambda method static. To keep things simple and avoid a messy rollback, we force the lambda to be an instance method under this situation. However if per source, the lambda occurs in a static context, we would generate a static synthetic method. */ MethodScope methodScope = methodScope(); while (methodScope != null && methodScope.referenceContext instanceof LambdaExpression) { LambdaExpression lambda = (LambdaExpression) methodScope.referenceContext; if (!lambda.scope.isStatic && !lambda.scope.isConstructorCall) { lambda.shouldCaptureInstance = true; } methodScope = methodScope.enclosingMethodScope(); } }
public final void addLocalType(TypeDeclaration localType) { ClassScope localTypeScope = new ClassScope(this, localType); addSubscope(localTypeScope); localTypeScope.buildLocalTypeBinding(enclosingSourceType()); // See comment in addAnonymousType. MethodScope methodScope = methodScope(); while (methodScope != null && methodScope.referenceContext instanceof LambdaExpression) { LambdaExpression lambda = (LambdaExpression) methodScope.referenceContext; if (!lambda.scope.isStatic && !lambda.scope.isConstructorCall) { lambda.shouldCaptureInstance = true; } methodScope = methodScope.enclosingMethodScope(); } }
public final void addAnonymousType(TypeDeclaration anonymousType, ReferenceBinding superBinding) { ClassScope anonymousClassScope = new ClassScope(this, anonymousType); anonymousClassScope.buildAnonymousTypeBinding( enclosingSourceType(), superBinding); /* Tag any enclosing lambdas as instance capturing. Strictly speaking they need not be, unless the local/anonymous type references enclosing instance state. but the types themselves track enclosing types regardless of whether the state is accessed or not. This creates a mismatch in expectations in code generation time, if we choose to make the lambda method static. To keep things simple and avoid a messy rollback, we force the lambda to be an instance method under this situation. However if per source, the lambda occurs in a static context, we would generate a static synthetic method. */ MethodScope methodScope = methodScope(); while (methodScope != null && methodScope.referenceContext instanceof LambdaExpression) { LambdaExpression lambda = (LambdaExpression) methodScope.referenceContext; if (!lambda.scope.isStatic && !lambda.scope.isConstructorCall) { lambda.shouldCaptureInstance = true; } methodScope = methodScope.enclosingMethodScope(); } }
public final void addLocalType(TypeDeclaration localType) { ClassScope localTypeScope = new ClassScope(this, localType); addSubscope(localTypeScope); localTypeScope.buildLocalTypeBinding(enclosingSourceType()); // See comment in addAnonymousType. MethodScope methodScope = methodScope(); while (methodScope != null && methodScope.referenceContext instanceof LambdaExpression) { LambdaExpression lambda = (LambdaExpression) methodScope.referenceContext; if (!lambda.scope.isStatic && !lambda.scope.isConstructorCall) { lambda.shouldCaptureInstance = true; } methodScope = methodScope.enclosingMethodScope(); } }
public final void addLocalType(TypeDeclaration localType) { ClassScope localTypeScope = new ClassScope(this, localType); addSubscope(localTypeScope); localTypeScope.buildLocalTypeBinding(enclosingSourceType()); // See comment in addAnonymousType. MethodScope methodScope = methodScope(); while (methodScope != null && methodScope.referenceContext instanceof LambdaExpression) { LambdaExpression lambda = (LambdaExpression) methodScope.referenceContext; if (!lambda.scope.isStatic && !lambda.scope.isConstructorCall) { lambda.shouldCaptureInstance = true; } methodScope = methodScope.enclosingMethodScope(); } }
public final void addLocalType(TypeDeclaration localType) { ClassScope localTypeScope = new ClassScope(this, localType); addSubscope(localTypeScope); localTypeScope.buildLocalTypeBinding(enclosingSourceType()); // See comment in addAnonymousType. MethodScope methodScope = methodScope(); while (methodScope != null && methodScope.referenceContext instanceof LambdaExpression) { LambdaExpression lambda = (LambdaExpression) methodScope.referenceContext; if (!lambda.scope.isStatic && !lambda.scope.isConstructorCall) { lambda.shouldCaptureInstance = true; } methodScope = methodScope.enclosingMethodScope(); } }
public final void addLocalType(TypeDeclaration localType) { ClassScope localTypeScope = new ClassScope(this, localType); addSubscope(localTypeScope); localTypeScope.buildLocalTypeBinding(enclosingSourceType()); // See comment in addAnonymousType. MethodScope methodScope = methodScope(); while (methodScope != null && methodScope.referenceContext instanceof LambdaExpression) { LambdaExpression lambda = (LambdaExpression) methodScope.referenceContext; if (!lambda.scope.isStatic && !lambda.scope.isConstructorCall) { lambda.shouldCaptureInstance = true; } methodScope = methodScope.enclosingMethodScope(); } }
public final void addLocalType(TypeDeclaration localType) { ClassScope localTypeScope = new ClassScope(this, localType); addSubscope(localTypeScope); localTypeScope.buildLocalTypeBinding(enclosingSourceType()); // See comment in addAnonymousType. MethodScope methodScope = methodScope(); while (methodScope != null && methodScope.referenceContext instanceof LambdaExpression) { LambdaExpression lambda = (LambdaExpression) methodScope.referenceContext; if (!lambda.scope.isStatic && !lambda.scope.isConstructorCall) { lambda.shouldCaptureInstance = true; } methodScope = methodScope.enclosingMethodScope(); } }
protected IJavaElement findLocalElement(int pos, MethodScope scope) { if (scope != null && scope.isLambdaScope()) { IJavaElement parent = findLocalElement(pos, scope.enclosingMethodScope()); LambdaExpression expression = (LambdaExpression) scope.originalReferenceContext(); if (expression != null && expression.resolvedType != null && expression.resolvedType.isValidBinding()) { org.eclipse.jdt.internal.core.LambdaExpression lambdaElement = LambdaFactory.createLambdaExpression((JavaElement) parent, expression); return lambdaElement.getMethod(); } return parent; } return findLocalElement(pos); }
protected IJavaElement findLocalElement(int pos, MethodScope scope) { if (scope != null && scope.isLambdaScope()) { IJavaElement parent = findLocalElement(pos, scope.enclosingMethodScope()); LambdaExpression expression = (LambdaExpression) scope.originalReferenceContext(); if (expression != null && expression.resolvedType != null && expression.resolvedType.isValidBinding()) { org.eclipse.jdt.internal.core.LambdaExpression lambdaElement = LambdaFactory.createLambdaExpression((JavaElement) parent, expression); return lambdaElement.getMethod(); } return parent; } return findLocalElement(pos); }
protected IJavaElement findLocalElement(int pos, MethodScope scope) { if (scope != null && scope.isLambdaScope()) { IJavaElement parent = findLocalElement(pos, scope.enclosingMethodScope()); LambdaExpression expression = (LambdaExpression) scope.originalReferenceContext(); if (expression != null && expression.resolvedType != null && expression.resolvedType.isValidBinding()) { org.eclipse.jdt.internal.core.LambdaExpression lambdaElement = LambdaFactory.createLambdaExpression((JavaElement) parent, expression); return lambdaElement.getMethod(); } return parent; } return findLocalElement(pos); }
protected IJavaElement findLocalElement(int pos, MethodScope scope) { if (scope != null && scope.isLambdaScope()) { IJavaElement parent = findLocalElement(pos, scope.enclosingMethodScope()); LambdaExpression expression = (LambdaExpression) scope.originalReferenceContext(); if (expression != null && expression.resolvedType != null && expression.resolvedType.isValidBinding()) { org.eclipse.jdt.internal.core.LambdaExpression lambdaElement = LambdaFactory.createLambdaExpression((JavaElement) parent, expression); return lambdaElement.getMethod(); } return parent; } return findLocalElement(pos); }
protected IJavaElement findLocalElement(int pos, MethodScope scope) { if (scope != null && scope.isLambdaScope()) { IJavaElement parent = findLocalElement(pos, scope.enclosingMethodScope()); LambdaExpression expression = (LambdaExpression) scope.originalReferenceContext(); if (expression != null && expression.resolvedType != null && expression.resolvedType.isValidBinding()) { org.eclipse.jdt.internal.core.LambdaExpression lambdaElement = LambdaFactory.createLambdaExpression((JavaElement) parent, expression); return lambdaElement.getMethod(); } return parent; } return findLocalElement(pos); }