1 11 package org.eclipse.jdt.internal.eval; 12 13 import org.eclipse.jdt.internal.compiler.ClassFile; 14 import org.eclipse.jdt.internal.compiler.CompilationResult; 15 import org.eclipse.jdt.internal.compiler.ast.ASTNode; 16 import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; 17 import org.eclipse.jdt.internal.compiler.problem.AbortType; 18 19 public class CodeSnippetTypeDeclaration extends TypeDeclaration { 20 21 public CodeSnippetTypeDeclaration(CompilationResult compilationResult){ 22 super(compilationResult); 23 } 24 25 28 public void generateCode(ClassFile enclosingClassFile) { 29 if ((this.bits & ASTNode.HasBeenGenerated) != 0) return; 30 this.bits |= ASTNode.HasBeenGenerated; 31 32 if (this.ignoreFurtherInvestigation) { 33 if (this.binding == null) 34 return; 35 CodeSnippetClassFile.createProblemType(this, this.scope.referenceCompilationUnit().compilationResult); 36 return; 37 } 38 try { 39 ClassFile classFile = new CodeSnippetClassFile(this.binding, enclosingClassFile, false); 41 classFile.addFieldInfos(); 43 if (this.binding.isMemberType()) { 44 classFile.recordInnerClasses(this.binding); 45 } else if (this.binding.isLocalType()) { 46 enclosingClassFile.recordInnerClasses(this.binding); 47 classFile.recordInnerClasses(this.binding); 48 } 49 50 if (this.memberTypes != null) { 51 for (int i = 0, max = this.memberTypes.length; i < max; i++) { 52 TypeDeclaration memberType = this.memberTypes[i]; 53 classFile.recordInnerClasses(memberType.binding); 54 memberType.generateCode(this.scope, classFile); 55 } 56 } 57 classFile.setForMethodInfos(); 59 if (this.methods != null) { 60 for (int i = 0, max = this.methods.length; i < max; i++) { 61 this.methods[i].generateCode(this.scope, classFile); 62 } 63 } 64 65 classFile.addSpecialMethods(); 67 68 if (this.ignoreFurtherInvestigation){ throw new AbortType(this.scope.referenceCompilationUnit().compilationResult, null); 70 } 71 72 classFile.addAttributes(); 74 this.scope.referenceCompilationUnit().compilationResult.record(this.binding.constantPoolName(), classFile); 75 } catch (AbortType e) { 76 if (this.binding == null) 77 return; 78 CodeSnippetClassFile.createProblemType(this, this.scope.referenceCompilationUnit().compilationResult); 79 } 80 } 81 } 82 | Popular Tags |