1 22 package org.aspectj.tools.ajdoc; 23 24 import org.aspectj.ajdoc.ClassDoc; 25 import org.aspectj.ajdoc.IntroducedDoc; 26 import org.aspectj.ajdoc.MemberDoc; 27 import org.aspectj.compiler.base.ast.ConstructorDec; 28 import org.aspectj.compiler.base.ast.Dec; 29 import org.aspectj.compiler.base.ast.FieldDec; 30 import org.aspectj.compiler.base.ast.MethodDec; 31 import org.aspectj.compiler.base.ast.TypeDec; 32 import org.aspectj.compiler.crosscuts.ast.GenTypeName; 33 import org.aspectj.compiler.crosscuts.ast.IntroducedDec; 34 35 import java.util.Iterator ; 36 import java.util.Set ; 37 38 public class IntroducedDocImpl extends IntroductionDocImpl implements IntroducedDoc { 39 40 41 private final IntroducedDec introducedDec; 42 43 44 private final MemberDocImpl member; 45 46 public IntroducedDocImpl(com.sun.javadoc.ClassDoc containingClass, 47 IntroducedDec introducedDec) { 48 super(containingClass); 49 this.introducedDec = introducedDec; (member = findMember()).setIntroduced(this); 51 createTargets(); 52 } 53 54 protected Dec dec() { 55 return introducedDec; 56 } 57 58 protected void createTargets() { 59 68 Set affects = ajc().getCorrespondences().getAffects(introducedDec); 69 if (affects.size() < 1) return; 70 nextType: 71 for (Iterator it = affects.iterator(); it.hasNext();) { 72 Object o = it.next(); 73 if (o instanceof TypeDec) { 74 TypeDec owner = (TypeDec)o; 75 ClassDoc cd = ClassDocImpl.getInstance(owner); 76 com.sun.javadoc.FieldDoc[] fs = cd.fields(); 77 for (int i = 0; i < fs.length; i++) { 78 if (member.weakEquals(fs[i])) { ((FieldDocImpl)fs[i]).setIntroduced(this); 80 addTarget(cd); 81 ((FieldDocImpl)member).setType(((FieldDocImpl)fs[i]). 82 fieldDec().getType()); 83 continue nextType; 85 } 86 } 87 com.sun.javadoc.MethodDoc[] ms = cd.methods(); 88 for (int i = 0; i < ms.length; i++) { 89 if (member.weakEquals(ms[i])) { 90 ((MethodDocImpl)ms[i]).setIntroduced(this); 91 addTarget(cd); 92 ((MethodDocImpl)member).setType(((MethodDocImpl)ms[i]). 93 codeDec().getResultTypeD(). 94 getType()); 95 ((ExecutableMemberDocImpl)member). 96 makeParameters(((MethodDocImpl)ms[i]). 97 codeDec().getFormals()); 98 continue nextType; 99 } 100 } 101 com.sun.javadoc.ConstructorDoc[] cs = cd.constructors(); 102 for (int i = 0; i < cs.length; i++) { 103 if (member.weakEquals(cs[i])) { 104 ((ConstructorDocImpl)cs[i]).setIntroduced(this); 105 addTarget(cd); 106 ((ExecutableMemberDocImpl)member). 107 makeParameters(((ConstructorDocImpl)cs[i]). 108 codeDec().getFormals()); 109 continue nextType; 110 } 111 } 112 } 113 } 114 } 115 116 public MemberDoc member() { 117 return member; 118 } 119 120 125 public String name() { Dec indec = introducedDec.getDec(); 127 if (indec != null) { 128 return "" + indec.getId(); } else { 130 return ""; 131 } 132 } 133 134 private MemberDocImpl findMember() { 135 Dec dec = introducedDec.getDec(); 136 dec.setSourceLocation(introducedDec.getSourceLocation()); if (dec instanceof FieldDec) { 141 return new FieldDocImpl(containingClass(), 142 (FieldDec)dec); 143 144 } else if (dec instanceof ConstructorDec) { 145 return new ConstructorDocImpl(containingClass(), 146 (ConstructorDec)dec); 147 } else if (dec instanceof MethodDec) { 148 return new MethodDocImpl(containingClass(), 149 (MethodDec)dec); 150 } else { 151 return null; 152 } 153 } 160 161 166 public String toString() { 167 return member.toString(); 168 } 169 } 170 | Popular Tags |