Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

DocProcessor.java

00001 package edu.ksu.cis.bandera.jjjc.doc;
00002 
00003 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00004  * Bandera, a Java(TM) analysis and transformation toolkit           *
00005  * Copyright (C) 1999, 2000   Robby (robby@cis.ksu.edu)              *
00006  * All rights reserved.                                              *
00007  *                                                                   *
00008  * This work was done as a project in the SAnToS Laboratory,         *
00009  * Department of Computing and Information Sciences, Kansas State    *
00010  * University, USA (http://www.cis.ksu.edu/santos).                  *
00011  * It is understood that any modification not identified as such is  *
00012  * not covered by the preceding statement.                           *
00013  *                                                                   *
00014  * This work is free software; you can redistribute it and/or        *
00015  * modify it under the terms of the GNU Library General Public       *
00016  * License as published by the Free Software Foundation; either      *
00017  * version 2 of the License, or (at your option) any later version.  *
00018  *                                                                   *
00019  * This work is distributed in the hope that it will be useful,      *
00020  * but WITHOUT ANY WARRANTY; without even the implied warranty of    *
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU *
00022  * Library General Public License for more details.                  *
00023  *                                                                   *
00024  * You should have received a copy of the GNU Library General Public *
00025  * License along with this toolkit; if not, write to the             *
00026  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,      *
00027  * Boston, MA  02111-1307, USA.                                      *
00028  *                                                                   *
00029  * Java is a trademark of Sun Microsystems, Inc.                     *
00030  *                                                                   *
00031  * To submit a bug report, send a comment, or get the latest news on *
00032  * this project and other SAnToS projects, please visit the web-site *
00033  *                http://www.cis.ksu.edu/santos                      *
00034  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00035 import java.io.*;
00036 import ca.mcgill.sable.soot.*;
00037 import ca.mcgill.sable.util.*;
00038 import edu.ksu.cis.bandera.jjjc.analysis.*;
00039 import edu.ksu.cis.bandera.jjjc.node.*;
00040 import java.util.Vector;
00041 import java.util.Hashtable;
00042 import java.util.StringTokenizer;
00043 public class DocProcessor extends DepthFirstAdapter {
00044     private static DocProcessor dp = new DocProcessor();
00045     private java.lang.Object key;
00046 /**
00047  * 
00048  */
00049 private DocProcessor() {}
00050 /**
00051  * 
00052  * @param node edu.ksu.cis.bandera.jjjc.node.AAbstractModifier
00053  */
00054 public void caseAAbstractModifier(AAbstractModifier node) {
00055     key = node.getAbstract();
00056 }
00057 /**
00058  * 
00059  * @param node edu.ksu.cis.bandera.jjjc.node.ABooleanPrimitiveType
00060  */
00061 public void caseABooleanPrimitiveType(ABooleanPrimitiveType node) {
00062     key = node.getBoolean();
00063 }
00064 /**
00065  * 
00066  * @param node edu.ksu.cis.bandera.jjjc.node.ABytePrimitiveType
00067  */
00068 public void caseABytePrimitiveType(ABytePrimitiveType node) {
00069     key = node.getByte();
00070 }
00071 /**
00072  * 
00073  * @param node edu.ksu.cis.bandera.jjjc.node.ACharPrimitiveType
00074  */
00075 public void caseACharPrimitiveType(ACharPrimitiveType node) {
00076     key = node.getChar();
00077 }
00078 /**
00079  * 
00080  * @param node edu.ksu.cis.bandera.jjjc.node.AClassDeclaration
00081  */
00082 public void caseAClassDeclaration(AClassDeclaration node) {
00083     if (node.getModifier().size() > 0)
00084         ((Node) node.getModifier().toArray()[0]).apply(this);
00085     else key = node.getTClass();
00086 }
00087 /**
00088  * 
00089  * @param node edu.ksu.cis.bandera.jjjc.node.AConstructorDeclaration
00090  */
00091 public void caseAConstructorDeclaration(AConstructorDeclaration node) {
00092     if (node.getModifier().size() > 0) 
00093         ((Node) node.getModifier().toArray()[0]).apply(this);
00094     else
00095         node.getConstructorDeclarator().apply(this);
00096 }
00097 /**
00098  * 
00099  * @param node edu.ksu.cis.bandera.jjjc.node.AConstructorDeclarator
00100  */
00101 public void caseAConstructorDeclarator(AConstructorDeclarator node) {
00102     key = node.getSimpleName();
00103 }
00104 /**
00105  * 
00106  * @param node edu.ksu.cis.bandera.jjjc.node.ADoublePrimitiveType
00107  */
00108 public void caseADoublePrimitiveType(ADoublePrimitiveType node) {
00109     key = node.getDouble();
00110 }
00111 /**
00112  * 
00113  * @param node edu.ksu.cis.bandera.jjjc.node.AFinalModifier
00114  */
00115 public void caseAFinalModifier(AFinalModifier node) {
00116     key = node.getFinal();
00117 }
00118 /**
00119  * 
00120  * @param node edu.ksu.cis.bandera.jjjc.node.AFloatPrimitiveType
00121  */
00122 public void caseAFloatPrimitiveType(AFloatPrimitiveType node) {
00123     key = node.getFloat();
00124 }
00125 /**
00126  * 
00127  * @param node edu.ksu.cis.bandera.jjjc.node.AIntPrimitiveType
00128  */
00129 public void caseAIntPrimitiveType(AIntPrimitiveType node) {
00130     key = node.getInt();
00131 }
00132 /**
00133  * 
00134  * @param node edu.ksu.cis.bandera.jjjc.node.ALongPrimitiveType
00135  */
00136 public void caseALongPrimitiveType(ALongPrimitiveType node) {
00137     key = node.getLong();
00138 }
00139 /**
00140  * 
00141  * @param node edu.ksu.cis.bandera.jjjc.node.AMethodDeclaration
00142  */
00143 public void caseAMethodDeclaration(AMethodDeclaration node) {
00144     node.getMethodHeader().apply(this);
00145 }
00146 /**
00147  * 
00148  * @param node edu.ksu.cis.bandera.jjjc.node.ANativeModifier
00149  */
00150 public void caseANativeModifier(ANativeModifier node) {
00151     key = node.getNative();
00152 }
00153 /**
00154  * 
00155  * @param node edu.ksu.cis.bandera.jjjc.node.APrivateModifier
00156  */
00157 public void caseAPrivateModifier(APrivateModifier node) {
00158     key = node.getPrivate();
00159 }
00160 /**
00161  * 
00162  * @param node edu.ksu.cis.bandera.jjjc.node.AProtectedModifier
00163  */
00164 public void caseAProtectedModifier(AProtectedModifier node) {
00165     key = node.getProtected();
00166 }
00167 /**
00168  * 
00169  * @param node edu.ksu.cis.bandera.jjjc.node.APublicModifier
00170  */
00171 public void caseAPublicModifier(APublicModifier node) {
00172     key = node.getPublic();
00173 }
00174 /**
00175  * 
00176  * @param node edu.ksu.cis.bandera.jjjc.node.AShortPrimitiveType
00177  */
00178 public void caseAShortPrimitiveType(AShortPrimitiveType node) {
00179     key = node.getShort();
00180 }
00181 /**
00182  * 
00183  * @param node edu.ksu.cis.bandera.jjjc.node.ASimpleName
00184  */
00185 public void caseASimpleName(ASimpleName node) {
00186     key = node.getId();
00187 }
00188 /**
00189  * 
00190  * @param node edu.ksu.cis.bandera.jjjc.node.AStaticModifier
00191  */
00192 public void caseAStaticModifier(AStaticModifier node) {
00193     key = node.getStatic();
00194 }
00195 /**
00196  * 
00197  * @param node edu.ksu.cis.bandera.jjjc.node.ATransientModifier
00198  */
00199 public void caseATransientModifier(ATransientModifier node) {
00200     key = node.getTransient();
00201 }
00202 /**
00203  * 
00204  * @param node edu.ksu.cis.bandera.jjjc.node.ATypedMethodHeader
00205  */
00206 public void caseATypedMethodHeader(ATypedMethodHeader node) {
00207     if (node.getModifier().size() > 0)
00208         ((Node) node.getModifier().toArray()[0]).apply(this);
00209     else
00210         node.getType().apply(this);
00211 }
00212 /**
00213  * 
00214  * @param node edu.ksu.cis.bandera.jjjc.node.AVoidMethodHeader
00215  */
00216 public void caseAVoidMethodHeader(AVoidMethodHeader node) {
00217     if (node.getModifier().size() > 0) 
00218         ((Node) node.getModifier().toArray()[0]).apply(this);
00219     else key = node.getVoid();
00220 }
00221 /**
00222  * 
00223  * @param node edu.ksu.cis.bandera.jjjc.node.AVolatileModifier
00224  */
00225 public void caseAVolatileModifier(AVolatileModifier node) {
00226     key = node.getVolatile();
00227 }
00228 /**
00229  * 
00230  * @return java.lang.Object
00231  */
00232 public static Object getKey(Node node) {
00233     node.apply(dp);
00234     return dp.key;
00235 }
00236 /**
00237  * 
00238  * @return java.util.Vector
00239  * @param node edu.ksu.cis.bandera.jjjc.node.Node
00240  * @param table java.lang.Hashtable
00241  */
00242 public static java.util.Vector tags(Node node, Hashtable table) {
00243     node.apply(dp);
00244 
00245     if (table.get(dp.key) == null)
00246         return new Vector();
00247     Object[] ignoredTokens = ((List) table.get(dp.key)).toArray();
00248     String comment = "";
00249     for (int i = ignoredTokens.length - 1; i >= 0; i--) {
00250         if (ignoredTokens[i] instanceof TDocumentationComment) {
00251             comment = ignoredTokens[i].toString();
00252             break;
00253         }
00254     }
00255     Vector tags = new Vector();
00256     StringTokenizer t = new StringTokenizer(comment, "@");
00257     t.nextToken();
00258     while (t.hasMoreTokens()) {
00259         tags.add("@" + t.nextToken());
00260     }
00261     Vector result = new Vector();
00262     for (java.util.Iterator i = tags.iterator(); i.hasNext();) {
00263         LineNumberReader r = new LineNumberReader(new StringReader((String) i.next()), 8192);
00264         String line;
00265         String tag = "";
00266         try {
00267             while ((line = r.readLine()) != null) {
00268                 try {
00269                     int start, end;
00270                     boolean f = true;
00271                     for (start = 0; (start < line.length()) && f; start++) {
00272                         switch(line.charAt(start)) {
00273                             case ' ':
00274                             case '\n':
00275                             case '\t':
00276                             case '*':
00277                                 break;
00278                         default: f = false;
00279                         }
00280                     }
00281                     f = true;
00282                     for (end = line.length() - 1; (end >= 0) && f; end--) {
00283                         switch(line.charAt(end)) {
00284                             case ' ':
00285                             case '\n':
00286                             case '\t':
00287                             case '*':
00288                             case '/':
00289                                 break;
00290                             default: f = false;
00291                         }
00292                     }
00293                     tag += line.substring(start - 1 , end + 2) + "\n";
00294                 } catch (Exception e2) {}
00295             }
00296         } catch (Exception e) {}
00297         result.add(tag);
00298     }
00299     return result;
00300 }
00301 }

Generated at Thu Feb 7 06:44:35 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001