summaryrefslogtreecommitdiff
path: root/tools/gnu/classpath/tools/gjdoc/Parser.java
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2012-09-26 15:16:16 +0100
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2012-09-26 15:16:16 +0100
commitcd3ebd72a7d59734fcf99e8ed85331b74445df1f (patch)
tree476a173edde6aa73e24e3435fbd81a36e53b5a19 /tools/gnu/classpath/tools/gjdoc/Parser.java
parent4d4db712cf4df4feb4d7b98bb1b5b448218500b3 (diff)
downloadclasspath-cd3ebd72a7d59734fcf99e8ed85331b74445df1f.tar.gz
Warning cleanup in tools (gjdoc & rmic).
2012-09-24 Andrew John Hughes <gnu_andrew@member.fsf.org> * tools/com/sun/javadoc/Doc.java: Add type parameter to Comparable. * tools/gnu/classpath/tools/doclets/AbstractDoclet.java: (tagletMap): Use type parameters. (packageGroups): Likewise. (tagletPath): Removed, unused. (mentionedTags): Use type parameters. (optionNoEmailWarn): Removed, unused. (optionTagletPath): Likewise. (DocletOptionTaglet): Likewise. (DocletOptionGroup.set(String[])): Add type aprameters to groupPackages. (DocletOptionTagletPath): Removed, unused. (commonOptions): Remove optionTagletPath. (nameToOptionMap): Add type parameters. (getOptionLength(String)): Remove unnecessary cast. (getKnownDirectSubclasses(ClassDoc)): Add type parameters. (IndexKey): Add type parameter to Comparable. (IndexKey.compareTo(IndexKey)): Update to use specific type. (categorizedIndex): Use type parameters. (getCategorizedIndex()): Likewise. (indexByName): Likewise. (getIndexByName()): Likewise. (printTaglets(Tag[],TagletContext,TagletPrinter,boolean)): Likewise. (addUsedBy(Map,ClassDoc,UsageType,Doc,PackageDoc)): Likewise. (collectUsage()): Likewise. (usedClassToPackagesMap): Likewise. (getUsageOfClass(ClassDoc)): Likewise. (UsageType): Add type parameter to Comparable. (UsageType.compareTo(UsageType)): Update to use specific type. (getPackageGroups()): Use type parameters. * tools/gnu/classpath/tools/doclets/PackageMatcher.java: (patterns): Use type parameters. (filter(Packagedoc[])): Likewise. (match(PackageDoc)): Likewise. * tools/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet.java: (externalDocSets): Use type parameters. (packageNameToDocSet)): Likewise. (printPackagePage(File,String,PackageDoc,PackageDoc,PackageDoc)): Likewise. (TreeNode): Add type parameter to Comparable. (TreeNode.children): Use type parameters. (TreeNode.compareTo(TreeNode)): Update to use specific type. (addClassTreeNode(Map,ClassDoc)): Use type parameters. (addInterfacetreeNode(Map,ClassDoc)): Likewise. (printClassTree(HtmlPage,ClassDoc[])): Likewise. (printInterfaceTree(HtmlPage,ClassDoc[])): Likewise. (printFullTreePage()): Likewise. (printIndexEntry(HtmlPage,Doc)): Likewise. (printPackagesMenuPage()): Likewise. (printClassMenuSection(HtmlPage,Collection,String)): Likewise. (printClassMenuList(HtmlPage,ClassDoc[],boolean)): Likewise. (printSplitIndex()): Likewise. (printIndexPage(int,int,Character,List)): Likewise. (printSerializationPage()): Likewise. (printDeprecationPage()): Likewise. (getMemberDocURL(HtmlPage,ProgramElementDoc)): Likewise. (createTypeHref(HtmlPage,Type,boolean)): Likewise. (getPackageURL(PackageDoc)): Remove redundant cast. (getClassURL(ClassDoc)): Likewise. * tools/gnu/classpath/tools/gjdoc/ClassDocImpl.java: (primitiveNames): Add type parameters. (findClassCache): Likewise. (findClass(String,String): Likewise. (createInstance(ClassDoc,PackageDoc,ClassDoc[],PackageDoc[], char[],int,int,List)): Likewise. (resolve()): Likewise. (typeMap): Likewise. (typeForString(String)): Likewise.. (equals(Object)): Likewise. (maybeSerMethodList): Likewise. (setMaybeSerMethodList(List)): Likewise. (findFieldValue(String,ClassDoc,String,Set)): Likewise. (getValue(String,Set)): Likewise. (compareTo(Doc)): Use specific type. (importStatementList): Use type parameters. (setImportStatementList(List)): Likewise. * tools/gnu/classpath/tools/gjdoc/ClassDocProxy.java: (compareTo(Doc)): Use specific type. * tools/gnu/classpath/tools/gjdoc/ClassDocReflectedImpl.java: Expand imports. (findClass(String)): Don't use full class name for String. (compareTo(Doc)): Use specific type. * tools/gnu/classpath/tools/gjdoc/DocImpl.java: (compareTo(Doc)): Use specific type. * tools/gnu/classpath/tools/gjdoc/ExecutableMemberDocImpl.java: (compareTo(Doc)): Use specific type. * tools/gnu/classpath/tools/gjdoc/FieldDocImpl.java: (createFromSource(ClassDoc,PackageDoc,char[],int,int)): Use type parameters. Remove unused lastFieldDefStart variable. (constantValue(Set)): Use type parameters. * tools/gnu/classpath/tools/gjdoc/Main.java: (option_overview): Removed unused field. (option_classpath): Likewise. (option_sourcepath): Add type parameters. (option_extdirs): Removed unused field. (option_verbose): Likewise. (option_java_flags): Likewise. (option_subpackages): Add type parameters. (option_exclude): Likewise. (startDoclet(List)): Likewise. (addFoundPackages(String,Set)): Likewise. (findPackages(String,File,Set)): Likewise. (start(String[])): Likewise. (addJavaLangClasses()): Commented out, apparently unused. (options): Add type parameters. (initOptions()): Likewise. Remove redundant variable setting. * tools/gnu/classpath/tools/gjdoc/MemberDocImpl.java: (compareTo(Doc)): Use specific type. * tools/gnu/classpath/tools/gjdoc/PackageDocImpl.java: (allClassesSet): Use type parameters. (ordinaryClassesList): Likewise. (exceptionsList): Likewise. (interfacesList): Likewise. (errorsList): Likewise. (resolve()): Likewise. (toClassDocArray(Collection)): Likewise. (compareTo(Doc)): Use specific type. * tools/gnu/classpath/tools/gjdoc/Parser.java: Expand import statements. (process(Parser,char[],int,int)): Add type parameters. (processedFiles): Add type parameters. (processSourceFile(File,boolean,String,String)): Add type parameters. (classOpened(char[],int,int)): Likewise. (toArray(List,T[])): Likewise. (classClosed()): Likewise. (Context.fieldList): Likewise. (Context.filteredFieldList): Likewise. (Context.sfieldList): Likewise. (Context.methodList): Likewise. (Context.filteredMethodList): Likewise. (Context.maybeSerMethodList): Likewise. (Context.constructorList): Likewise. (Context.filteredConstructorList): Likewise. (Context.innerClassesList): Likewise. (Context.filteredInnerClassesList): Likewise. * tools/gnu/classpath/tools/gjdoc/RootDocImpl.java: (findSourceFiles(String)): Add type parameters. * tools/gnu/classpath/tools/gjdoc/expr/Evaluator.java: (evaluate(String,Set,EvaluatorEnvironment)): Add type parameters. * tools/gnu/classpath/tools/gjdoc/expr/EvaluatorEnvironment.java: (getValue(String,Set)): Add type parameters. * tools/gnu/classpath/tools/gjdoc/expr/Type.java: (clazz): Add type parameters. (Type(Class)): Likewise. * tools/gnu/classpath/tools/rmic/ClassRmicCompiler.java: (keep): Remove unused field. (errors): Add type parameter. (compile): Remove unused field. (classpath): Likewise. (clazz): Add type parameter. (mRemoteInterfaces): Likewise. (run(String[])): Add type parameters. (processClass(String)): Likewise. (getException()): Remove unnecessary cast. (typeArray(Class[])): Add type parameter. (param(Method,int)): Add type parameter. Use Integer.valueOf. (generateClassConstant(MethodVisitor,Class)): Add type parameters. (generateClassArray(MethodVisitor,Class)): Likewise. (generateStub()): Remove unused variables stubclassname, size & endReturnTryCatch. Remove unnecessary casts and add type parameters. (generateSkel()): Remove unused variable skelclassname. Use Long.valueOf. (generateMethodSkel(MethodVisitor,Method,Variables)): Add type parameters. (typeArg(Class)): Add type parameter. (readMethod(Class)): Likewise. (writeMethod(Class)): Likewise. (returnOpcode(Class)): Likewise. (loadOpcode(Class)): Likewise. (storeOpcode(Class)): Likewise. (unboxMethod(Class)): Likewise. (box(Class)): Likewise. (size(Class)): Likewise. (sortExceptions(Class[])): Add type parameters. (setup(boolean,boolean,boolean,boolean,boolean,boolean, boolean,boolean,boolean,boolean,String,String,String,String)): Remove unused variables keep & classpath. (findRemoteMethods()): Add type parameters. (MethodRef.exceptions): Add type parameter. (MethodRef.removeSubclasses(Class[])): Add type parameters. (MethodRef.intersectExceptions(Method)): Likewise. * tools/gnu/classpath/tools/rmic/Main.java: (backends): Add type parameter. (run(String[])): Remove redundant cast. * tools/gnu/classpath/tools/rmic/RmiMethodGenerator.java: (getArgumentList()): Add type parameters. (getArgumentNames()): Likewise. (getThrows()): Likewise. (getStaticMethodDeclarations()): Likewise. * tools/gnu/classpath/tools/rmic/SourceGiopRmicCompiler.java: Add type parameter to Comparable. (implementedRemotes): Add type parameter. (extraImports): Likewise. (methods): Likewise. (interfaces): Likewise. (compile(Class)): Add type parameters. (getId(Class)): Add type parameter. (getIdList(Collection)): Add type parameters. (generateStub()): Add type parameters. (generateTie()): Likewise. (compare(AbstractMethodGenerator,AbstractMethodGenerator)): Use more specific types. (getImportStatements()): Add type parameters. * tools/gnu/classpath/tools/rmic/Variables.java: (free): Add type parameter. (names): Add type parameters. (wides): Add type parameter. (declared): Likewise. (allocateNow(Object,int)): Use Integer.valueOf. (allocate(Object,int)): Add type parameters. (deallocate(Object)): Remove redundant cast. Use Integer.valueOf. (get(Object)): Remove redundant cast. Signed-off-by: Andrew John Hughes <gnu_andrew@member.fsf.org>
Diffstat (limited to 'tools/gnu/classpath/tools/gjdoc/Parser.java')
-rw-r--r--tools/gnu/classpath/tools/gjdoc/Parser.java148
1 files changed, 81 insertions, 67 deletions
diff --git a/tools/gnu/classpath/tools/gjdoc/Parser.java b/tools/gnu/classpath/tools/gjdoc/Parser.java
index d355b5384..af6b6b432 100644
--- a/tools/gnu/classpath/tools/gjdoc/Parser.java
+++ b/tools/gnu/classpath/tools/gjdoc/Parser.java
@@ -1,5 +1,5 @@
/* gnu.classpath.tools.gjdoc.Parser
- Copyright (C) 2001, 2005, 2008 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2005, 2008, 2012 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -37,21 +37,38 @@
package gnu.classpath.tools.gjdoc;
-import java.io.*;
+import com.sun.javadoc.ClassDoc;
+import com.sun.javadoc.ConstructorDoc;
+import com.sun.javadoc.FieldDoc;
+import com.sun.javadoc.MethodDoc;
+import com.sun.javadoc.PackageDoc;
+
+import gnu.classpath.tools.IOToolkit;
+import gnu.classpath.tools.NotifyingInputStreamReader;
+import gnu.classpath.tools.MalformedInputListener;
+import gnu.classpath.tools.MalformedInputEvent;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.Reader;
+
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CoderResult;
import java.nio.charset.CodingErrorAction;
-import java.util.*;
-import com.sun.javadoc.*;
-
-import gnu.classpath.tools.IOToolkit;
-import gnu.classpath.tools.NotifyingInputStreamReader;
-import gnu.classpath.tools.MalformedInputListener;
-import gnu.classpath.tools.MalformedInputEvent;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.Stack;
class IgnoredFileParseException extends ParseException
{
@@ -356,11 +373,11 @@ import gnu.classpath.tools.MalformedInputEvent;
if (endIndex-startIndex<=1) return endIndex;
//assert (parser.ctx!=null);
- Collection fields=FieldDocImpl.createFromSource(parser.ctx.classDoc,
- parser.ctx.classDoc.containingPackage(),
- source, startIndex, endIndex);
+ Collection<FieldDoc> fields = FieldDocImpl.createFromSource(parser.ctx.classDoc,
+ parser.ctx.classDoc.containingPackage(),
+ source, startIndex, endIndex);
- for (Iterator it=fields.iterator(); it.hasNext(); ) {
+ for (Iterator<FieldDoc> it=fields.iterator(); it.hasNext(); ) {
FieldDocImpl field=(FieldDocImpl)it.next();
boolean fieldHasSerialTag=!field.isTransient() && !field.isStatic(); //field.hasSerialTag();
if ((field.isIncluded() || fieldHasSerialTag) && parser.getAddComments()) {
@@ -408,27 +425,26 @@ import gnu.classpath.tools.MalformedInputEvent;
parser.setLastComment(null);
if (execDoc.isMethod()) {
- parser.ctx.methodList.add(execDoc);
- if (execDoc.isIncluded()) {
- parser.ctx.filteredMethodList.add(execDoc);
+ MethodDoc methDoc = (MethodDoc) execDoc;
+ parser.ctx.methodList.add(methDoc);
+ if (methDoc.isIncluded()) {
+ parser.ctx.filteredMethodList.add(methDoc);
}
- }
- else {
- parser.ctx.constructorList.add(execDoc);
- if (execDoc.isIncluded()) {
- parser.ctx.filteredConstructorList.add(execDoc);
- }
- }
-
- if (execDoc.isMethod()
- && (execDoc.name().equals("readObject")
- || execDoc.name().equals("writeObject")
- || execDoc.name().equals("readExternal")
- || execDoc.name().equals("writeExternal")
- || execDoc.name().equals("readResolve"))) {
+ if (methDoc.name().equals("readObject")
+ || methDoc.name().equals("writeObject")
+ || methDoc.name().equals("readExternal")
+ || methDoc.name().equals("writeExternal")
+ || methDoc.name().equals("readResolve")) {
// FIXME: add readExternal here?
- parser.ctx.maybeSerMethodList.add(execDoc);
+ parser.ctx.maybeSerMethodList.add(methDoc);
+ }
+ } else {
+ ConstructorDoc constDoc = (ConstructorDoc) execDoc;
+ parser.ctx.constructorList.add(constDoc);
+ if (constDoc.isIncluded()) {
+ parser.ctx.filteredConstructorList.add(constDoc);
+ }
}
return endIndex;
@@ -764,7 +780,7 @@ public class Parser {
return processedFiles.size();
}
- static Set processedFiles = new HashSet();
+ static Set<File> processedFiles = new HashSet<File>();
ClassDocImpl processSourceFile(File file, boolean addComments,
String encoding, String expectedPackageName)
@@ -803,8 +819,8 @@ public class Parser {
try {
parse(source, 0, sourceLevelComponents);
- ClassDoc[] importedClasses=(ClassDoc[])importedClassesList.toArray(new ClassDoc[0]);
- PackageDoc[] importedPackages=(PackageDoc[])importedPackagesList.toArray(new PackageDoc[0]);
+ ClassDoc[] importedClasses = importedClassesList.toArray(new ClassDoc[importedClassesList.size()]);
+ PackageDoc[] importedPackages = importedPackagesList.toArray(new PackageDoc[importedPackagesList.size()]);
if (Main.DESCEND_IMPORTED) {
for (int i=0; i<importedClasses.length; ++i) {
@@ -909,7 +925,7 @@ public class Parser {
ClassDocImpl classDoc
= ClassDocImpl.createInstance((ctx!=null)?(ctx.classDoc):null, currentPackage,
null,
- (PackageDoc[])importedPackagesList.toArray(new PackageDoc[0]),
+ importedPackagesList.toArray(new PackageDoc[importedPackagesList.size()]),
source, startIndex, endIndex,
importedStatementList);
@@ -921,11 +937,11 @@ public class Parser {
}
if (importedClassesList.isEmpty()) {
- for (Iterator it=importedStringList.iterator(); it.hasNext(); ) {
- importedClassesList.add(new ClassDocProxy((String)it.next(), classDoc));
+ for (Iterator<String> it=importedStringList.iterator(); it.hasNext(); ) {
+ importedClassesList.add(new ClassDocProxy(it.next(), classDoc));
}
}
- classDoc.setImportedClasses((ClassDoc[])importedClassesList.toArray(new ClassDoc[0]));
+ classDoc.setImportedClasses(importedClassesList.toArray(new ClassDoc[importedClassesList.size()]));
currentPackage.addClass(classDoc);
@@ -945,26 +961,24 @@ public class Parser {
//Debug.log(9,"ctx="+ctx);
}
- private Doc[] toArray(List list, Doc[] template)
+ private <T> T[] toArray(List<T> list, T[] template)
{
- Doc[] result = (Doc[])list.toArray(template);
- return result;
+ return list.toArray(template);
}
void classClosed() throws ParseException, IOException {
- ctx.classDoc.setFields((FieldDoc[])toArray(ctx.fieldList,
- new FieldDoc[0]));
- ctx.classDoc.setFilteredFields((FieldDoc[])toArray(ctx.filteredFieldList,
- new FieldDoc[0]));
- ctx.classDoc.setSerializableFields((FieldDoc[])toArray(ctx.sfieldList, new FieldDoc[0]));
- ctx.classDoc.setMethods((MethodDoc[])toArray(ctx.methodList, new MethodDoc[0]));
- ctx.classDoc.setFilteredMethods((MethodDoc[])toArray(ctx.filteredMethodList, new MethodDoc[0]));
+ ctx.classDoc.setFields(toArray(ctx.fieldList,new FieldDoc[ctx.fieldList.size()]));
+ ctx.classDoc.setFilteredFields(toArray(ctx.filteredFieldList,new FieldDoc[ctx.filteredFieldList.size()]));
+ ctx.classDoc.setSerializableFields(toArray(ctx.sfieldList, new FieldDoc[ctx.sfieldList.size()]));
+ ctx.classDoc.setMethods(toArray(ctx.methodList, new MethodDoc[ctx.methodList.size()]));
+ ctx.classDoc.setFilteredMethods(toArray(ctx.filteredMethodList, new MethodDoc[ctx.filteredMethodList.size()]));
ctx.classDoc.setMaybeSerMethodList(ctx.maybeSerMethodList);
- ctx.classDoc.setConstructors((ConstructorDoc[])toArray(ctx.constructorList, new ConstructorDoc[0]));
- ctx.classDoc.setFilteredConstructors((ConstructorDoc[])toArray(ctx.filteredConstructorList, new ConstructorDoc[0]));
-
- ctx.classDoc.setInnerClasses((ClassDocImpl[])toArray(ctx.innerClassesList, new ClassDocImpl[0]));
- ctx.classDoc.setFilteredInnerClasses((ClassDocImpl[])toArray(ctx.filteredInnerClassesList, new ClassDocImpl[0]));
+ ctx.classDoc.setConstructors(toArray(ctx.constructorList, new ConstructorDoc[ctx.constructorList.size()]));
+ ctx.classDoc.setFilteredConstructors(toArray(ctx.filteredConstructorList,
+ new ConstructorDoc[ctx.filteredConstructorList.size()]));
+ ctx.classDoc.setInnerClasses(toArray(ctx.innerClassesList, new ClassDocImpl[ctx.innerClassesList.size()]));
+ ctx.classDoc.setFilteredInnerClasses(toArray(ctx.filteredInnerClassesList,
+ new ClassDocImpl[ctx.filteredInnerClassesList.size()]));
ctx.classDoc.setBoilerplateComment(boilerplateComment);
Main.getRootDoc().addClassDoc(ctx.classDoc);
@@ -993,16 +1007,16 @@ public class Parser {
class Context {
Context(ClassDocImpl classDoc) { this.classDoc=classDoc; }
ClassDocImpl classDoc = null;
- List fieldList = new LinkedList();
- List filteredFieldList = new LinkedList();
- List sfieldList = new LinkedList();
- List methodList = new LinkedList();
- List filteredMethodList = new LinkedList();
- List maybeSerMethodList = new LinkedList();
- List constructorList = new LinkedList();
- List filteredConstructorList = new LinkedList();
- List innerClassesList = new LinkedList();
- List filteredInnerClassesList = new LinkedList();
+ List<FieldDoc> fieldList = new LinkedList<FieldDoc>();
+ List<FieldDoc> filteredFieldList = new LinkedList<FieldDoc>();
+ List<FieldDoc> sfieldList = new LinkedList<FieldDoc>();
+ List<MethodDoc> methodList = new LinkedList<MethodDoc>();
+ List<MethodDoc> filteredMethodList = new LinkedList<MethodDoc>();
+ List<MethodDoc> maybeSerMethodList = new LinkedList<MethodDoc>();
+ List<ConstructorDoc> constructorList = new LinkedList<ConstructorDoc>();
+ List<ConstructorDoc> filteredConstructorList = new LinkedList<ConstructorDoc>();
+ List<ClassDocImpl> innerClassesList = new LinkedList<ClassDocImpl>();
+ List<ClassDocImpl> filteredInnerClassesList = new LinkedList<ClassDocImpl>();
}
File currentFile = null;
@@ -1016,10 +1030,10 @@ public class Parser {
List allClassesList = new LinkedList();
List interfacesList = new LinkedList();
- List importedClassesList = new LinkedList();
- List importedStringList = new LinkedList();
- List importedPackagesList = new LinkedList();
- List importedStatementList = new LinkedList();
+ List<ClassDoc> importedClassesList = new LinkedList<ClassDoc>();
+ List<String> importedStringList = new LinkedList<String>();
+ List<PackageDoc> importedPackagesList = new LinkedList<PackageDoc>();
+ List<String> importedStatementList = new LinkedList<String>();
List referencedClassesList = new LinkedList();