@Override public CharSequence extract(ProcessingEnvironment environment, TypeElement typeElement) throws IOException { if (typeElement instanceof ElementImpl) { Binding binding = ((ElementImpl) typeElement)._binding; if (binding instanceof SourceTypeBinding) { CompilationUnitDeclaration unit = ((SourceTypeBinding) binding).scope.referenceCompilationUnit(); char[] contents = unit.compilationResult.compilationUnit.getContents(); return CharBuffer.wrap(contents); } } return UNABLE_TO_EXTRACT; }
void buildLocalTypeBinding(SourceTypeBinding enclosingType) { LocalTypeBinding localType = buildLocalType(enclosingType, enclosingType.fPackage); connectTypeHierarchy(); if (compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) { checkParameterizedTypeBounds(); checkParameterizedSuperTypeCollisions(); } buildFieldsAndMethods(); localType.faultInTypesForFieldsAndMethods(); this.referenceContext.binding.verifyMethods(environment().methodVerifier()); }
void buildFieldsAndMethods() { buildFields(); buildMethods(); SourceTypeBinding sourceType = this.referenceContext.binding; if (sourceType.isMemberType() && !sourceType.isLocalType()) ((MemberTypeBinding) sourceType).checkSyntheticArgsAndFields(); ReferenceBinding[] memberTypes = sourceType.memberTypes; for (int i = 0, length = memberTypes.length; i < length; i++) ((SourceTypeBinding) memberTypes[i]).scope.buildFieldsAndMethods(); }
/** * Construct enum special methods: values or valueOf methods */ public SyntheticMethodBinding(SourceTypeBinding declaringEnum, char[] selector) { this.declaringClass = declaringEnum; this.selector = selector; this.modifiers = ClassFileConstants.AccPublic | ClassFileConstants.AccStatic; this.tagBits |= (TagBits.AnnotationResolved | TagBits.DeprecatedAnnotationResolved); LookupEnvironment environment = declaringEnum.scope.environment(); this.thrownExceptions = Binding.NO_EXCEPTIONS; if (selector == TypeConstants.VALUES) { this.returnType = environment.createArrayType(environment.convertToParameterizedType(declaringEnum), 1); this.parameters = Binding.NO_PARAMETERS; this.purpose = SyntheticMethodBinding.EnumValues; } else if (selector == TypeConstants.VALUEOF) { this.returnType = environment.convertToParameterizedType(declaringEnum); this.parameters = new TypeBinding[]{ declaringEnum.scope.getJavaLangString() }; this.purpose = SyntheticMethodBinding.EnumValueOf; } SyntheticMethodBinding[] knownAccessMethods = ((SourceTypeBinding)this.declaringClass).syntheticMethods(); int methodId = knownAccessMethods == null ? 0 : knownAccessMethods.length; this.index = methodId; if (declaringEnum.isStrictfp()) { this.modifiers |= ClassFileConstants.AccStrictfp; } }
public final void addAnonymousType(TypeDeclaration anonymousType, ReferenceBinding superBinding) { ClassScope anonymousClassScope = new ClassScope(this, anonymousType); anonymousClassScope.buildAnonymousTypeBinding( enclosingSourceType(), superBinding); }
public final void addLocalType(TypeDeclaration localType) { ClassScope localTypeScope = new ClassScope(this, localType); addSubscope(localTypeScope); localTypeScope.buildLocalTypeBinding(enclosingSourceType()); }
void initializeForStaticImports() { if (!isPrototype()) { this.prototype.initializeForStaticImports(); return; } if (this.scope == null) return; // already initialized if (this.superInterfaces == null) this.scope.connectTypeHierarchy(); this.scope.buildFields(); this.scope.buildMethods(); }
@Override public ProblemReporter problemReporter() { MethodScope outerMethodScope; if ((outerMethodScope = outerMostMethodScope()) == null) { ProblemReporter problemReporter = referenceCompilationUnit().problemReporter; problemReporter.referenceContext = this.referenceContext; return problemReporter; } return outerMethodScope.problemReporter(); }
@Override public CompilationUnitDeclaration getCompilationUnitDeclaration() { if (this.scope != null) { return this.scope.compilationUnitScope().referenceContext; } return null; }
public void propagateInnerEmulationForAllLocalTypes() { this.isPropagatingInnerClassEmulation = true; for (int i = 0, max = this.localTypeCount; i < max; i++) { LocalTypeBinding localType = this.localTypes[i]; // only propagate for reachable local types if ((localType.scope.referenceType().bits & IsReachable) != 0) { localType.updateInnerEmulationDependents(); } } }
SimpleLookupTable storedAnnotations(boolean forceInitialize) { if (forceInitialize && this.storedAnnotations == null && this.scope != null) { // scope null when no annotation cached, and type got processed fully (159631) this.scope.referenceCompilationUnit().compilationResult.hasAnnotations = true; if (!this.scope.environment().globalOptions.storeAnnotations) return null; // not supported during this compile this.storedAnnotations = new SimpleLookupTable(3); } return this.storedAnnotations; } public ReferenceBinding superclass() {
/** * Bytecode generation for a member inner type */ public void generateCode(ClassScope classScope, ClassFile enclosingClassFile) { if ((this.bits & ASTNode.HasBeenGenerated) != 0) return; if (this.binding != null) { SyntheticArgumentBinding[] enclosingInstances = ((NestedTypeBinding) this.binding).syntheticEnclosingInstances(); for (int i = 0, slotSize = 0, count = enclosingInstances == null ? 0 : enclosingInstances.length; i < count; i++){ SyntheticArgumentBinding enclosingInstance = enclosingInstances[i]; enclosingInstance.resolvedPosition = ++slotSize; // shift by 1 to leave room for aload0==this if (slotSize > 0xFF) { // no more than 255 words of arguments classScope.problemReporter().noMoreAvailableSpaceForArgument(enclosingInstance, classScope.referenceType()); } } } generateCode(enclosingClassFile); }
void buildFieldsAndMethods() { for (int i = 0, length = this.topLevelTypes.length; i < length; i++) this.topLevelTypes[i].scope.buildFieldsAndMethods(); } void buildTypeBindings(AccessRestriction accessRestriction) {
void buildLocalTypeBinding(SourceTypeBinding enclosingType) { LocalTypeBinding localType = buildLocalType(enclosingType, enclosingType.fPackage); connectTypeHierarchy(); if (compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) { checkParameterizedTypeBounds(); checkParameterizedSuperTypeCollisions(); } buildFieldsAndMethods(); localType.faultInTypesForFieldsAndMethods(); this.referenceContext.binding.verifyMethods(environment().methodVerifier()); }
void buildFieldsAndMethods() { buildFields(); buildMethods(); SourceTypeBinding sourceType = this.referenceContext.binding; if (!sourceType.isPrivate() && sourceType.superclass instanceof SourceTypeBinding && sourceType.superclass.isPrivate()) ((SourceTypeBinding) sourceType.superclass).tagIndirectlyAccessibleMembers(); if (sourceType.isMemberType() && !sourceType.isLocalType()) ((MemberTypeBinding) sourceType).checkSyntheticArgsAndFields(); ReferenceBinding[] memberTypes = sourceType.memberTypes; for (int i = 0, length = memberTypes.length; i < length; i++) ((SourceTypeBinding) memberTypes[i]).scope.buildFieldsAndMethods(); }
/** * Construct enum special methods: values or valueOf methods */ public SyntheticMethodBinding(SourceTypeBinding declaringEnum, char[] selector) { this.declaringClass = declaringEnum; this.selector = selector; this.modifiers = ClassFileConstants.AccPublic | ClassFileConstants.AccStatic; this.tagBits |= (TagBits.AnnotationResolved | TagBits.DeprecatedAnnotationResolved); LookupEnvironment environment = declaringEnum.scope.environment(); this.thrownExceptions = Binding.NO_EXCEPTIONS; if (selector == TypeConstants.VALUES) { this.returnType = environment.createArrayType(environment.convertToParameterizedType(declaringEnum), 1); this.parameters = Binding.NO_PARAMETERS; this.purpose = SyntheticMethodBinding.EnumValues; } else if (selector == TypeConstants.VALUEOF) { this.returnType = environment.convertToParameterizedType(declaringEnum); this.parameters = new TypeBinding[]{ declaringEnum.scope.getJavaLangString() }; this.purpose = SyntheticMethodBinding.EnumValueOf; } SyntheticMethodBinding[] knownAccessMethods = ((SourceTypeBinding)this.declaringClass).syntheticMethods(); int methodId = knownAccessMethods == null ? 0 : knownAccessMethods.length; this.index = methodId; if (declaringEnum.isStrictfp()) { this.modifiers |= ClassFileConstants.AccStrictfp; } }
public final void addAnonymousType(TypeDeclaration anonymousType, ReferenceBinding superBinding) { ClassScope anonymousClassScope = new ClassScope(this, anonymousType); anonymousClassScope.buildAnonymousTypeBinding( enclosingSourceType(), superBinding); }
public final void addLocalType(TypeDeclaration localType) { ClassScope localTypeScope = new ClassScope(this, localType); addSubscope(localTypeScope); localTypeScope.buildLocalTypeBinding(enclosingSourceType()); }
void initializeForStaticImports() { if (!isPrototype()) { this.prototype.initializeForStaticImports(); return; } if (this.scope == null) return; // already initialized if (this.superInterfaces == null) this.scope.connectTypeHierarchy(); this.scope.buildFields(); this.scope.buildMethods(); }
public ProblemReporter problemReporter() { MethodScope outerMethodScope; if ((outerMethodScope = outerMostMethodScope()) == null) { ProblemReporter problemReporter = referenceCompilationUnit().problemReporter; problemReporter.referenceContext = this.referenceContext; return problemReporter; } return outerMethodScope.problemReporter(); }