aboutsummaryrefslogtreecommitdiffstats
path: root/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/rootmakers/Javadoc14.java
blob: 3846c8abacbc97a9bbc94fe6c0e0b9a2f6b03fc3 (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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
/* -*- 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.ajdoc.rootmakers;

//import com.sun.javadoc.RootDoc;
//import com.sun.javadoc.DocErrorReporter;
//
//import java.lang.reflect.InvocationTargetException;
//import java.lang.reflect.Constructor;
//import java.lang.reflect.Method;
//import java.util.Iterator;
//import java.util.List;
//
//import org.aspectj.tools.ajdoc.CannotMakeRootDocException;
//import org.aspectj.tools.ajdoc.ErrPrinter;
//import org.aspectj.tools.ajdoc.RootDocMaker;
//import org.aspectj.tools.ajdoc.AccessChecker;

//XXX
//import com.sun.tools.javac.v8.util.Hashtable;

/**
 * Makes a RootDoc using javadoc from SDK 1.4 as an example.
 *
 * @author Jeff Palm
 */
//public class Javadoc14 extends Javadoc implements RootDocMaker {
//
//    public Javadoc14() {}
//
//    public RootDoc makeRootDoc(String sourcepath,
//                               String classpath,
//                               String bootclasspath,
//                               String extdirs,
//                               long flags,
//                               String encoding,
//                               String locale,
//                               String source,
//                               List classesAndPackages,
//                               List options,
//                               DocErrorReporter docErrorReporter,
//                               String programName,
//                               AccessChecker filter)
//        throws CannotMakeRootDocException {
//        this.err = (ErrPrinter)docErrorReporter;
//        Class hashtableClass = null;
//        String classname = "com.sun.tools.javac.v8.util.Hashtable";
//        try {
//            hashtableClass = Class.forName(classname);
//        } catch (ClassNotFoundException e) {
//            err.ex(e, "class_not_found", "Hashtable", classname);
//            return null;
//        }
//        Object hashtable = null;
//        try {
//            hashtable = hashtableClass.newInstance();
//            Method put = hashtableClass.getMethod("put",
//                                                  new Class[]{Object.class,
//                                                              Object.class});
//            if (sourcepath != null) {
//                put.invoke(hashtable, new Object[]{"-sourcepath",
//                                                   sourcepath});
//            }
//            if (classpath != null) {
//                put.invoke(hashtable, new Object[]{"-classpath",
//                                                   classpath});
//            }
//            if (bootclasspath != null) {
//                put.invoke(hashtable, new Object[]{"-bootclasspath",
//                                                   bootclasspath});
//            }
//            if (extdirs != null) {
//                put.invoke(hashtable, new Object[]{"-extdirs",
//                                                   extdirs});
//            }
//            if (encoding != null) {
//                put.invoke(hashtable, new Object[]{"-encoding",
//                                                   encoding});
//            }
//            if (true || (flags & 0x1) != 0) {
//                put.invoke(hashtable, new Object[]{"-verbose",
//                                                   ""});
//            }
//            if (source != null) {
//                put.invoke(hashtable, new Object[]{"-source",
//                                                   source});
//            }
//            if (filter != null) {
//                put.invoke(hashtable, new Object[]{"-" + filter.getOption(),
//                                                   ""});
//            }
//            Hashtable h = (Hashtable)hashtable;
//            
//        } catch (NoSuchMethodException e) {
//            err.ex(e, "method_not_found", classname, "put");
//            return null;
//        } catch (InvocationTargetException e) {
//            err.invocationTargetException(e, classname, "put");
//            return null;
//        } catch (InstantiationException e) {
//            err.ex(e, "must_have_default_ctor", classname);
//            return null;
//        } catch (IllegalAccessException e) {
//            err.ex(e, "method_not_accessible", classname, "new()");
//            return null;
//        }
//        Class messagerClass = null;
//        classname = "com.sun.tools.javadoc.Messager";
//        try {
//            messagerClass = Class.forName(classname);
//        } catch (ClassNotFoundException e) {
//            err.ex(e, "class_not_found", "Messager", classname);
//            return null;
//        }
//        Object messager = null;
//        try {
//            Constructor ctor =
//                messagerClass.getConstructor(new Class[]{String.class});
//            messager = ctor.newInstance(new Object[]{programName});
//        } catch (InstantiationException e) {
//            err.ex(e, "cant_construct_object", classname);
//            return null;            
//        } catch (NoSuchMethodException e) {
//            err.ex(e, "method_not_found", classname, "new(String)");
//            return null;
//        } catch (IllegalAccessException e) {
//            err.ex(e, "method_not_accessible", classname, "new(String)");
//            return null;
//        } catch (InvocationTargetException e) {
//            err.invocationTargetException(e, classname, "new(String)");
//            return null;
//        }
//        Class javadocToolClass = null;
//        classname = "com.sun.tools.javadoc.JavadocTool";
//        try {
//            javadocToolClass = Class.forName(classname);
//        } catch (ClassNotFoundException e) {
//            err.ex(e, "class_not_found", "JavadocTool", classname);
//            return null;
//        }
//        Object javadocTool = null;
//        try {
//            Method make = javadocToolClass.getMethod("make",
//                                                     new Class[]{messagerClass,
//                                                                 hashtableClass});
//            javadocTool = make.invoke(null, new Object[]{messager,
//                                                         hashtable});
//        } catch (NoSuchMethodException e) {
//            err.ex(e, "method_not_found", classname, "make");
//            return null;
//        } catch (InvocationTargetException e) {
//            err.invocationTargetException(e, classname, "make");
//            return null;
//        } catch (IllegalAccessException e) {
//            err.ex(e, "method_not_accessible", classname, "make");
//            return null;
//        } catch (Exception e) {
//            err.ex(e, "exception_thrown", "JavadocTool",
//                      classname, "make", e != null ? e.getMessage() : e+"");
//            return null;
//        }
//        Class modifierFilterClass = null;
//        classname = "com.sun.tools.javadoc.ModifierFilter";
//        try {
//            modifierFilterClass = Class.forName(classname);
//        } catch (ClassNotFoundException e) {
//            err.ex(e, "class_not_found", "ModifierFilter", classname);
//            return null;
//        }
//        Object modifierFilter = null;
//        classname = "com.sun.tools.javadoc.ModifierFilter";
//        try {
//            Constructor ctor =
//                modifierFilterClass.getConstructor(new Class[]{long.class});
//            modifierFilter = ctor.newInstance(new Object[]{new Long(flags)});
//        } catch (InstantiationException e) {
//            err.ex(e, "cant_construct_object", classname);
//            return null;            
//        } catch (NoSuchMethodException e) {
//            err.ex(e, "method_not_found", classname, "new()");
//            return null;
//        } catch (IllegalAccessException e) {
//            err.ex(e, "method_not_accessible", classname, "new()");
//            return null;
//        } catch (InvocationTargetException e) {
//            err.invocationTargetException(e, classname, "new()");
//            return null;
//        }
//        Class listClass = null;
//        classname = "com.sun.tools.javac.v8.util.List";
//        try {
//            listClass = Class.forName(classname);
//        } catch (ClassNotFoundException e) {
//            err.ex(e, "class_not_found", "List", classname);
//            return null;
//        }
//        RootDoc rootDoc = null;
//        classname = "com.sun.tools.javadoc.JavadocTool";
//        try {
//            Method getRootDocImpl =
//                javadocToolClass.getMethod("getRootDocImpl",
//                                           new Class[]{String.class,
//                                                       modifierFilterClass,
//                                                       listClass,
//                                                       listClass});
//            Object classesOrPackageList = list(classesAndPackages, listClass);
//            Object optionsList = list(options, listClass);
//
//            rootDoc =
//                (RootDoc)getRootDocImpl.invoke(javadocTool,
//                                               new Object[]{locale,
//                                                            modifierFilter,
//                                                            classesOrPackageList,
//                                                            optionsList});
//        } catch (NoSuchMethodException e) {
//            err.ex(e, "method_not_found", classname, "getRootDocImpl");
//            return null;
//        } catch (InvocationTargetException e) {
//            err.invocationTargetException(e, classname, "getRootDocImpl");
//            return null;
//        } catch (IllegalAccessException e) {
//            err.ex(e, "method_not_accessible", classname, "getRootDocImpl");
//            return null;
//        } catch (ClassCastException e) {
//            err.ex(e, "class_cast_exception", "getRootDocImpl", classname,
//                      "com.sun.javadoc.RootDoc",
//                      rootDoc == null ? "" : rootDoc.getClass().getName());
//            return null;
//        }
//        return rootDoc;
//    }
//
//
//    private final Object list(List list, Class listClass) {
//        if (listClass == null) return null;
//        Object newlist = newInstance(listClass);
//        if (newlist == null) return null;
//        if (list == null) return newlist;
//        Class listBufferClass = type("com.sun.tools.javac.v8.util.ListBuffer");
//        if (listBufferClass == null) return newlist;
//        Object listBuffer = newInstance(listBufferClass);
//        if (listBuffer == null) return newlist;
//        Method append = method("append", new Class[]{Object.class},listBufferClass);
//        if (append == null) return newlist;
//        for (Iterator i = list.iterator(); i.hasNext();) {
//            invoke(append, listBuffer, new Object[]{i.next()});
//        }
//
//        Method toList = method("toList", new Class[]{}, listBufferClass);
//        if (toList == null) return newlist;
//        newlist = invoke(toList, listBuffer, new Object[]{});
//        return newlist;
//    }
//}