aboutsummaryrefslogtreecommitdiffstats
path: root/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/SuperIntroductionSubWriter.java
blob: ade3dcc6f1dd03e5d5abdc72a9b16e6d5a1ddf63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 *
 * This file is part of the debugger and core tools for the AspectJ(tm)
 * programming language; see http://aspectj.org
 *
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is AspectJ.
 *
 * The Initial Developer of the Original Code is Xerox Corporation. Portions
 * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation.
 * All Rights Reserved.
 */
package org.aspectj.tools.doclets.standard;

import org.aspectj.ajdoc.AspectDoc;
import org.aspectj.ajdoc.IntroducedSuperDoc;
import org.aspectj.ajdoc.IntroductionDoc;

import com.sun.javadoc.ClassDoc;
import com.sun.javadoc.ProgramElementDoc;
import com.sun.javadoc.Type;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

public class SuperIntroductionSubWriter extends AbstractSubWriter {

    protected Class delegateClass() {
        return null; //XXX ????
    }

    public SuperIntroductionSubWriter
        (com.sun.tools.doclets.standard.SubWriterHolderWriter writer,
         AspectDoc ad)
    {
        super(writer, ad);
    }
    
    public SuperIntroductionSubWriter
        (com.sun.tools.doclets.standard.SubWriterHolderWriter writer)
    {
        super(writer);
    }

    protected final String keyName() { return "Super_Introduction"; }

    public void printInheritedSummaryAnchor(ClassDoc cd) {}
    public void printInheritedSummaryLabel(ClassDoc cd) {}
    protected void printInheritedSummaryLink(ClassDoc cd, ProgramElementDoc ped) {}

    protected void printSummaryLink(ClassDoc cd, ProgramElementDoc member) {
        IntroducedSuperDoc intro = (IntroducedSuperDoc)member;
        writer.codeEnd();
        writer.printText("doclet.declare_parents");
        print(' ');
        Type[] targets = intro.targets();
        for (int i = 0; i < targets.length; i++) {
            if (i > 0) print(", ");
            printTypeLink(targets[i]);
        }
        print(' ');
        String str = intro.isImplements() ? "implements" : "extends";
        writer.printClassLink(cd, link(intro), str, false);
        print(' ');
        Type[] types = intro.types();
        for (int i = 0; i < types.length; i++) {
            if (i > 0) print(", ");
            printTypeLink(types[i]);
        }

    }

    protected static String link(IntroducedSuperDoc intro) {
        String str = intro.isImplements() ? "+implements" : "+extends";
        Type[] types = intro.types();
        str += "%";
        for (int i = 0; i < types.length; i++) str += types[i].qualifiedTypeName();
        str += "%";
        ClassDoc[] targets = intro.targets();
        for (int i = 0; i < targets.length; i++) str += targets[i].qualifiedTypeName();
        return str;
    }

    protected void printSummaryType(ProgramElementDoc member) {}

    protected void printBodyHtmlEnd(ClassDoc cd) {}

    protected void nonfinalPrintMember(ProgramElementDoc member) {
        IntroducedSuperDoc intro = (IntroducedSuperDoc)member;
        writer.anchor(link(intro));
        String head = intro.isImplements() ? "+implements " : "+extends ";
        Type[] types = intro.types();
        for (int i = 0; i < types.length; i++) {
            head += (i > 0 ? ", " : "") + types[i].typeName();
        }
        printHead(head);
        printFullComment(intro);
    }

    protected void printDeprecatedLink(ProgramElementDoc member) {
        //TODO: ???
    }

    protected List getMembers(ClassDoc cd) {
        if (!(cd instanceof AspectDoc)) return Collections.EMPTY_LIST;
        IntroductionDoc[] introductions = ((AspectDoc)cd).introductions();
        List list = new ArrayList();
        if (introductions == null) return list;
        for (int i = 0; i < introductions.length; i++) {
            IntroductionDoc intro = introductions[i];
            if (intro instanceof IntroducedSuperDoc) {
                list.add(intro);
            }
        }
        return list;
    }

    public void printCrosscuts(ClassDoc cd, ProgramElementDoc member) {
        org.aspectj.ajdoc.IntroducedSuperDoc intro =
            (org.aspectj.ajdoc.IntroducedSuperDoc)member;
        ClassDoc[] targets = intro.targets();
        if (targets.length > 0) {
            writer.dt();
            writer.boldText("doclet.Introduced_on");
            writer.dd();
            writer.code();
            Set targetSet = new HashSet();
            for (int i = 0; i < targets.length; i++) {
                targetSet.add(targets[i]);
            }
            List targetList = new ArrayList(targetSet);
            Collections.sort(targetList);
            for (Iterator i = targetList.iterator(); i.hasNext();) {
                ClassDoc target = (ClassDoc)i.next();
                writer.printClassLink(target);
                if (i.hasNext()) writer.print(", ");
                
            }
            writer.codeEnd();
        }
    }

    public void printSummaryCrosscuts(ClassDoc cd,
                                      ProgramElementDoc member) {
        Set set = new HashSet();
        org.aspectj.ajdoc.IntroducedSuperDoc intro =
            (org.aspectj.ajdoc.IntroducedSuperDoc)member;
        ClassDoc[] targets = intro.targets();
        for (int i = 0; i < targets.length; i++) {
            set.add(targets[i]);
        }
        if (targets.length > 0) {
            writer.boldText("doclet.Advises");
            List list = new ArrayList(set);
            Collections.sort(list);
            for (Iterator i = list.iterator(); i.hasNext();) {
                print(' ');
                ClassDoc target = (ClassDoc)i.next();
                writer.printClassLink(target);
                if (i.hasNext()) print(",");
            }
        }
    }

    public boolean hasCrosscuts(ClassDoc cd, ProgramElementDoc member) {
        return true;
    }
}