From 5846ec74cc40e252d27441b86f2d85d1d225aa28 Mon Sep 17 00:00:00 2001 From: Ben Dodson Date: Tue, 17 Aug 2010 09:52:09 -0700 Subject: [PATCH] Removed unused source files. Apicheck and droiddoc are now in external/doclava. Change-Id: I13bcdbd27214e15235fa9687b6f15f8853f5f448 --- tools/apicheck/Android.mk | 31 +- tools/apicheck/src/Android.mk | 28 - tools/apicheck/src/MANIFEST.mf | 2 - .../android/apicheck/AbstractMethodInfo.java | 24 - .../src/com/android/apicheck/ApiCheck.java | 242 --- .../src/com/android/apicheck/ApiInfo.java | 91 - .../src/com/android/apicheck/ClassInfo.java | 341 ---- .../com/android/apicheck/ConstructorInfo.java | 148 -- .../src/com/android/apicheck/Errors.java | 157 -- .../src/com/android/apicheck/FieldInfo.java | 160 -- .../src/com/android/apicheck/MethodInfo.java | 209 --- .../src/com/android/apicheck/PackageInfo.java | 78 - .../com/android/apicheck/ParameterInfo.java | 35 - .../android/apicheck/SourcePositionInfo.java | 123 -- tools/droiddoc/NOTICE | 45 - tools/droiddoc/src/Android.mk | 69 - .../droiddoc/src/AnnotationInstanceInfo.java | 60 - tools/droiddoc/src/AnnotationValueInfo.java | 79 - tools/droiddoc/src/AttrTagInfo.java | 142 -- tools/droiddoc/src/AttributeInfo.java | 100 -- tools/droiddoc/src/ClassInfo.java | 1464 ----------------- tools/droiddoc/src/ClearPage.java | 226 --- tools/droiddoc/src/Comment.java | 395 ----- tools/droiddoc/src/ContainerInfo.java | 21 - tools/droiddoc/src/Converter.java | 755 --------- tools/droiddoc/src/DocFile.java | 148 -- tools/droiddoc/src/DocInfo.java | 67 - tools/droiddoc/src/DroidDoc.java | 1385 ---------------- tools/droiddoc/src/Errors.java | 146 -- tools/droiddoc/src/FieldInfo.java | 317 ---- tools/droiddoc/src/Hierarchy.java | 155 -- tools/droiddoc/src/InheritedTags.java | 27 - tools/droiddoc/src/KeywordEntry.java | 51 - tools/droiddoc/src/LinkReference.java | 446 ----- tools/droiddoc/src/LiteralTagInfo.java | 31 - tools/droiddoc/src/MemberInfo.java | 155 -- tools/droiddoc/src/MethodInfo.java | 670 -------- tools/droiddoc/src/NavTree.java | 146 -- tools/droiddoc/src/PackageInfo.java | 189 --- tools/droiddoc/src/ParamTagInfo.java | 96 -- tools/droiddoc/src/ParameterInfo.java | 72 - tools/droiddoc/src/ParsedTagInfo.java | 61 - tools/droiddoc/src/Proofread.java | 178 -- tools/droiddoc/src/SampleCode.java | 178 -- tools/droiddoc/src/SampleTagInfo.java | 289 ---- tools/droiddoc/src/Scoped.java | 23 - tools/droiddoc/src/SeeTagInfo.java | 80 - tools/droiddoc/src/SinceTagger.java | 237 --- tools/droiddoc/src/Sorter.java | 32 - tools/droiddoc/src/SourcePositionInfo.java | 95 -- tools/droiddoc/src/Stubs.java | 999 ----------- tools/droiddoc/src/TagInfo.java | 100 -- tools/droiddoc/src/TextTagInfo.java | 21 - tools/droiddoc/src/ThrowsTagInfo.java | 83 - tools/droiddoc/src/TodoFile.java | 195 --- tools/droiddoc/src/TypeInfo.java | 291 ---- 56 files changed, 2 insertions(+), 11986 deletions(-) delete mode 100644 tools/apicheck/src/Android.mk delete mode 100644 tools/apicheck/src/MANIFEST.mf delete mode 100644 tools/apicheck/src/com/android/apicheck/AbstractMethodInfo.java delete mode 100644 tools/apicheck/src/com/android/apicheck/ApiCheck.java delete mode 100644 tools/apicheck/src/com/android/apicheck/ApiInfo.java delete mode 100644 tools/apicheck/src/com/android/apicheck/ClassInfo.java delete mode 100644 tools/apicheck/src/com/android/apicheck/ConstructorInfo.java delete mode 100644 tools/apicheck/src/com/android/apicheck/Errors.java delete mode 100644 tools/apicheck/src/com/android/apicheck/FieldInfo.java delete mode 100644 tools/apicheck/src/com/android/apicheck/MethodInfo.java delete mode 100644 tools/apicheck/src/com/android/apicheck/PackageInfo.java delete mode 100644 tools/apicheck/src/com/android/apicheck/ParameterInfo.java delete mode 100644 tools/apicheck/src/com/android/apicheck/SourcePositionInfo.java delete mode 100644 tools/droiddoc/NOTICE delete mode 100644 tools/droiddoc/src/Android.mk delete mode 100644 tools/droiddoc/src/AnnotationInstanceInfo.java delete mode 100644 tools/droiddoc/src/AnnotationValueInfo.java delete mode 100644 tools/droiddoc/src/AttrTagInfo.java delete mode 100644 tools/droiddoc/src/AttributeInfo.java delete mode 100644 tools/droiddoc/src/ClassInfo.java delete mode 100644 tools/droiddoc/src/ClearPage.java delete mode 100644 tools/droiddoc/src/Comment.java delete mode 100644 tools/droiddoc/src/ContainerInfo.java delete mode 100644 tools/droiddoc/src/Converter.java delete mode 100644 tools/droiddoc/src/DocFile.java delete mode 100644 tools/droiddoc/src/DocInfo.java delete mode 100644 tools/droiddoc/src/DroidDoc.java delete mode 100644 tools/droiddoc/src/Errors.java delete mode 100644 tools/droiddoc/src/FieldInfo.java delete mode 100755 tools/droiddoc/src/Hierarchy.java delete mode 100644 tools/droiddoc/src/InheritedTags.java delete mode 100644 tools/droiddoc/src/KeywordEntry.java delete mode 100644 tools/droiddoc/src/LinkReference.java delete mode 100644 tools/droiddoc/src/LiteralTagInfo.java delete mode 100644 tools/droiddoc/src/MemberInfo.java delete mode 100644 tools/droiddoc/src/MethodInfo.java delete mode 100644 tools/droiddoc/src/NavTree.java delete mode 100644 tools/droiddoc/src/PackageInfo.java delete mode 100644 tools/droiddoc/src/ParamTagInfo.java delete mode 100644 tools/droiddoc/src/ParameterInfo.java delete mode 100755 tools/droiddoc/src/ParsedTagInfo.java delete mode 100644 tools/droiddoc/src/Proofread.java delete mode 100644 tools/droiddoc/src/SampleCode.java delete mode 100644 tools/droiddoc/src/SampleTagInfo.java delete mode 100644 tools/droiddoc/src/Scoped.java delete mode 100644 tools/droiddoc/src/SeeTagInfo.java delete mode 100644 tools/droiddoc/src/SinceTagger.java delete mode 100644 tools/droiddoc/src/Sorter.java delete mode 100644 tools/droiddoc/src/SourcePositionInfo.java delete mode 100644 tools/droiddoc/src/Stubs.java delete mode 100644 tools/droiddoc/src/TagInfo.java delete mode 100644 tools/droiddoc/src/TextTagInfo.java delete mode 100644 tools/droiddoc/src/ThrowsTagInfo.java delete mode 100644 tools/droiddoc/src/TodoFile.java delete mode 100644 tools/droiddoc/src/TypeInfo.java diff --git a/tools/apicheck/Android.mk b/tools/apicheck/Android.mk index e4c66c54b..92f462751 100644 --- a/tools/apicheck/Android.mk +++ b/tools/apicheck/Android.mk @@ -1,4 +1,4 @@ -# Copyright (C) 2007-2008 The Android Open Source Project +# Copyright (C) 2008 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,31 +14,4 @@ LOCAL_PATH := $(call my-dir) -# We use copy-file-to-new-target so that the installed -# script file's timestamp is at least as new as the -# .jar file it wraps. - -#TODO(dbort): add a template to do this stuff; share with jx - -# the hat script -# ============================================================ -include $(CLEAR_VARS) -LOCAL_IS_HOST_MODULE := true -LOCAL_MODULE_CLASS := EXECUTABLES -LOCAL_MODULE := apicheck - -include $(BUILD_SYSTEM)/base_rules.mk - -$(LOCAL_BUILT_MODULE): $(HOST_OUT_JAVA_LIBRARIES)/doclava$(COMMON_JAVA_PACKAGE_SUFFIX) -$(LOCAL_BUILT_MODULE): $(LOCAL_PATH)/etc/apicheck | $(ACP) - @echo "Copy: $(PRIVATE_MODULE) ($@)" - $(copy-file-to-new-target) - $(hide) chmod 755 $@ - -# the other stuff -# ============================================================ -subdirs := $(addprefix $(LOCAL_PATH)/,$(addsuffix /Android.mk, \ - src \ - )) - -include $(subdirs) +# Apicheck is now part of Doclava -- See external/doclava. diff --git a/tools/apicheck/src/Android.mk b/tools/apicheck/src/Android.mk deleted file mode 100644 index c4e7c6e84..000000000 --- a/tools/apicheck/src/Android.mk +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright (C) 2008 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -LOCAL_PATH := $(call my-dir) - - -# apicheck java library -# ============================================================ -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := $(call all-subdir-java-files) -LOCAL_JAR_MANIFEST := MANIFEST.mf - -LOCAL_MODULE:= apicheck - -include $(BUILD_HOST_JAVA_LIBRARY) - diff --git a/tools/apicheck/src/MANIFEST.mf b/tools/apicheck/src/MANIFEST.mf deleted file mode 100644 index e6dc263be..000000000 --- a/tools/apicheck/src/MANIFEST.mf +++ /dev/null @@ -1,2 +0,0 @@ -Manifest-Version: 1.0 -Main-Class: com.android.apicheck.ApiCheck diff --git a/tools/apicheck/src/com/android/apicheck/AbstractMethodInfo.java b/tools/apicheck/src/com/android/apicheck/AbstractMethodInfo.java deleted file mode 100644 index ca90820bb..000000000 --- a/tools/apicheck/src/com/android/apicheck/AbstractMethodInfo.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.apicheck; - -public interface AbstractMethodInfo { - - public void addException(String exec); - public void addParameter(ParameterInfo p); - -} diff --git a/tools/apicheck/src/com/android/apicheck/ApiCheck.java b/tools/apicheck/src/com/android/apicheck/ApiCheck.java deleted file mode 100644 index b2f22650d..000000000 --- a/tools/apicheck/src/com/android/apicheck/ApiCheck.java +++ /dev/null @@ -1,242 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.apicheck; - -import org.xml.sax.*; -import org.xml.sax.helpers.*; -import java.io.*; -import java.util.ArrayList; -import java.util.Stack; - -public class ApiCheck { - // parse out and consume the -whatever command line flags - private static ArrayList parseFlags(ArrayList allArgs) { - ArrayList ret = new ArrayList(); - - int i; - for (i = 0; i < allArgs.size(); i++) { - // flags with one value attached - String flag = allArgs.get(i); - if (flag.equals("-error") - || flag.equals("-warning") - || flag.equals("-hide")) { - String[] arg = new String[2]; - arg[0] = flag; - arg[1] = allArgs.get(++i); - ret.add(arg); - } else { - // we've consumed all of the -whatever args, so we're done - break; - } - } - - // i now points to the first non-flag arg; strip what came before - for (; i > 0; i--) { - allArgs.remove(0); - } - return ret; - } - - public static void main(String[] originalArgs) { - // translate to an ArrayList for munging - ArrayList args = new ArrayList(originalArgs.length); - for (String a: originalArgs) { - args.add(a); - } - - ArrayList flags = ApiCheck.parseFlags(args); - for (String[] a: flags) { - if (a[0].equals("-error") || a[0].equals("-warning") - || a[0].equals("-hide")) { - try { - int level = -1; - if (a[0].equals("-error")) { - level = Errors.ERROR; - } - else if (a[0].equals("-warning")) { - level = Errors.WARNING; - } - else if (a[0].equals("-hide")) { - level = Errors.HIDDEN; - } - Errors.setErrorLevel(Integer.parseInt(a[1]), level); - } - catch (NumberFormatException e) { - System.err.println("Bad argument: " + a[0] + " " + a[1]); - System.exit(2); - } - } - } - - ApiCheck acheck = new ApiCheck(); - - ApiInfo oldApi = acheck.parseApi(args.get(0)); - ApiInfo newApi = acheck.parseApi(args.get(1)); - - // only run the consistency check if we haven't had XML parse errors - if (!Errors.hadError) { - oldApi.isConsistent(newApi); - } - - Errors.printErrors(); - System.exit(Errors.hadError ? 1 : 0); - } - - public ApiInfo parseApi(String xmlFile) { - FileReader fileReader = null; - try { - XMLReader xmlreader = XMLReaderFactory.createXMLReader(); - MakeHandler handler = new MakeHandler(); - xmlreader.setContentHandler(handler); - xmlreader.setErrorHandler(handler); - fileReader = new FileReader(xmlFile); - xmlreader.parse(new InputSource(fileReader)); - ApiInfo apiInfo = handler.getApi(); - apiInfo.resolveSuperclasses(); - apiInfo.resolveInterfaces(); - return apiInfo; - } catch (SAXParseException e) { - Errors.error(Errors.PARSE_ERROR, - new SourcePositionInfo(xmlFile, e.getLineNumber(), 0), - e.getMessage()); - } catch (Exception e) { - e.printStackTrace(); - Errors.error(Errors.PARSE_ERROR, - new SourcePositionInfo(xmlFile, 0, 0), e.getMessage()); - } finally { - if (fileReader != null) { - try { - fileReader.close(); - } catch (IOException ignored) {} - } - } - return null; - } - - private static class MakeHandler extends DefaultHandler { - - private ApiInfo mApi; - private PackageInfo mCurrentPackage; - private ClassInfo mCurrentClass; - private AbstractMethodInfo mCurrentMethod; - private Stack mClassScope = new Stack(); - - - public MakeHandler() { - super(); - mApi = new ApiInfo(); - } - - @Override - public void startElement(String uri, String localName, String qName, - Attributes attributes) { - if (qName.equals("package")) { - mCurrentPackage = new PackageInfo(attributes.getValue("name"), - SourcePositionInfo.fromXml(attributes.getValue("source"))); - } else if (qName.equals("class") - || qName.equals("interface")) { - // push the old outer scope for later recovery, then set - // up the new current class object - mClassScope.push(mCurrentClass); - mCurrentClass = new ClassInfo(attributes.getValue("name"), - mCurrentPackage, - attributes.getValue("extends") , - qName.equals("interface"), - Boolean.valueOf( - attributes.getValue("abstract")), - Boolean.valueOf( - attributes.getValue("static")), - Boolean.valueOf( - attributes.getValue("final")), - attributes.getValue("deprecated"), - attributes.getValue("visibility"), - SourcePositionInfo.fromXml(attributes.getValue("source")), - mCurrentClass); - } else if (qName.equals("method")) { - mCurrentMethod = new MethodInfo(attributes.getValue("name"), - attributes.getValue("return") , - Boolean.valueOf( - attributes.getValue("abstract")), - Boolean.valueOf( - attributes.getValue("native")), - Boolean.valueOf( - attributes.getValue("synchronized")), - Boolean.valueOf( - attributes.getValue("static")), - Boolean.valueOf( - attributes.getValue("final")), - attributes.getValue("deprecated"), - attributes.getValue("visibility"), - SourcePositionInfo.fromXml(attributes.getValue("source")), - mCurrentClass); - } else if (qName.equals("constructor")) { - mCurrentMethod = new ConstructorInfo(attributes.getValue("name"), - attributes.getValue("type") , - Boolean.valueOf( - attributes.getValue("static")), - Boolean.valueOf( - attributes.getValue("final")), - attributes.getValue("deprecated"), - attributes.getValue("visibility"), - SourcePositionInfo.fromXml(attributes.getValue("source")), - mCurrentClass); - } else if (qName.equals("field")) { - FieldInfo fInfo = new FieldInfo(attributes.getValue("name"), - attributes.getValue("type") , - Boolean.valueOf( - attributes.getValue("transient")), - Boolean.valueOf( - attributes.getValue("volatile")), - attributes.getValue("value"), - Boolean.valueOf( - attributes.getValue("static")), - Boolean.valueOf( - attributes.getValue("final")), - attributes.getValue("deprecated"), - attributes.getValue("visibility"), - SourcePositionInfo.fromXml(attributes.getValue("source")), - mCurrentClass); - mCurrentClass.addField(fInfo); - } else if (qName.equals("parameter")) { - mCurrentMethod.addParameter(new ParameterInfo(attributes.getValue("type"), - attributes.getValue("name"))); - } else if (qName.equals("exception")) { - mCurrentMethod.addException(attributes.getValue("type")); - } else if (qName.equals("implements")) { - mCurrentClass.addInterface(attributes.getValue("name")); - } - } - - @Override - public void endElement(String uri, String localName, String qName) { - if (qName.equals("method")) { - mCurrentClass.addMethod((MethodInfo) mCurrentMethod); - } else if (qName.equals("constructor")) { - mCurrentClass.addConstructor((ConstructorInfo) mCurrentMethod); - } else if (qName.equals("class") - || qName.equals("interface")) { - mCurrentPackage.addClass(mCurrentClass); - mCurrentClass = mClassScope.pop(); - } else if (qName.equals("package")){ - mApi.addPackage(mCurrentPackage); - } - } - public ApiInfo getApi() { - return mApi; - } - } -} diff --git a/tools/apicheck/src/com/android/apicheck/ApiInfo.java b/tools/apicheck/src/com/android/apicheck/ApiInfo.java deleted file mode 100644 index 47b9a15fe..000000000 --- a/tools/apicheck/src/com/android/apicheck/ApiInfo.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.apicheck; -import java.util.*; - -public class ApiInfo { - - private HashMap mPackages; - private HashMap mAllClasses; - - public ApiInfo() { - mPackages = new HashMap(); - mAllClasses = new HashMap(); - } - - public ClassInfo findClass(String name) { - return mAllClasses.get(name); - } - - public void resolveInterfaces() { - for (ClassInfo c : mAllClasses.values()) { - c.resolveInterfaces(this); - } - } - - public boolean isConsistent(ApiInfo otherApi) { - boolean consistent = true; - for (PackageInfo pInfo : mPackages.values()) { - if (otherApi.getPackages().containsKey(pInfo.name())) { - if (!pInfo.isConsistent(otherApi.getPackages().get(pInfo.name()))) { - consistent = false; - } - } else { - Errors.error(Errors.REMOVED_PACKAGE, pInfo.position(), - "Removed package " + pInfo.name()); - consistent = false; - } - } - for (PackageInfo pInfo : otherApi.mPackages.values()) { - if (!pInfo.isInBoth()) { - Errors.error(Errors.ADDED_PACKAGE, pInfo.position(), - "Added package " + pInfo.name()); - consistent = false; - } - } - return consistent; - } - - public HashMap getPackages() { - return mPackages; - } - - public void addPackage(PackageInfo pInfo) { - // track the set of organized packages in the API - mPackages.put(pInfo.name(), pInfo); - - // accumulate a direct map of all the classes in the API - for (ClassInfo cl: pInfo.allClasses().values()) { - mAllClasses.put(cl.qualifiedName(), cl); - } - } - - public void resolveSuperclasses() { - for (ClassInfo cl: mAllClasses.values()) { - // java.lang.Object has no superclass - if (!cl.qualifiedName().equals("java.lang.Object")) { - String scName = cl.superclassName(); - if (scName == null) { - scName = "java.lang.Object"; - } - - ClassInfo superclass = mAllClasses.get(scName); - cl.setSuperClass(superclass); - } - } - } -} diff --git a/tools/apicheck/src/com/android/apicheck/ClassInfo.java b/tools/apicheck/src/com/android/apicheck/ClassInfo.java deleted file mode 100644 index 962a316e8..000000000 --- a/tools/apicheck/src/com/android/apicheck/ClassInfo.java +++ /dev/null @@ -1,341 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.apicheck; -import java.util.*; - -public class ClassInfo { - private String mName; - private String mSuperClassName; - private boolean mIsInterface; - private boolean mIsAbstract; - private boolean mIsStatic; - private boolean mIsFinal; - private String mDeprecated; - private String mScope; - private List mInterfaceNames; - private List mInterfaces; - private HashMap mMethods; - private HashMap mFields; - private HashMap mConstructors; - private boolean mExistsInBoth; - private PackageInfo mPackage; - private SourcePositionInfo mSourcePosition; - private ClassInfo mSuperClass; - private ClassInfo mParentClass; - - public ClassInfo(String name, PackageInfo pack, String superClass, boolean isInterface, - boolean isAbstract, boolean isStatic, boolean isFinal, String deprecated, - String visibility, SourcePositionInfo source, ClassInfo parent) { - mName = name; - mPackage = pack; - mSuperClassName = superClass; - mIsInterface = isInterface; - mIsAbstract = isAbstract; - mIsStatic = isStatic; - mIsFinal = isFinal; - mDeprecated = deprecated; - mScope = visibility; - mInterfaceNames = new ArrayList(); - mInterfaces = new ArrayList(); - mMethods = new HashMap(); - mFields = new HashMap(); - mConstructors = new HashMap(); - mExistsInBoth = false; - mSourcePosition = source; - mParentClass = parent; - } - - public String name() { - return mName; - } - - public String qualifiedName() { - String parentQName = (mParentClass != null) - ? (mParentClass.qualifiedName() + ".") - : ""; - return mPackage.name() + "." + parentQName + name(); - } - - public String superclassName() { - return mSuperClassName; - } - - public SourcePositionInfo position() { - return mSourcePosition; - } - - public boolean isInterface() { - return mIsInterface; - } - - public boolean isFinal() { - return mIsFinal; - } - - // Find a superclass implementation of the given method. - public static MethodInfo overriddenMethod(MethodInfo candidate, ClassInfo newClassObj) { - if (newClassObj == null) { - return null; - } - for (MethodInfo mi : newClassObj.mMethods.values()) { - if (mi.matches(candidate)) { - // found it - return mi; - } - } - - // not found here. recursively search ancestors - return ClassInfo.overriddenMethod(candidate, newClassObj.mSuperClass); - } - - // Find a superinterface declaration of the given method. - public static MethodInfo interfaceMethod(MethodInfo candidate, ClassInfo newClassObj) { - if (newClassObj == null) { - return null; - } - for (ClassInfo interfaceInfo : newClassObj.mInterfaces) { - for (MethodInfo mi : interfaceInfo.mMethods.values()) { - if (mi.matches(candidate)) { - return mi; - } - } - } - return ClassInfo.interfaceMethod(candidate, newClassObj.mSuperClass); - } - - public boolean isConsistent(ClassInfo cl) { - cl.mExistsInBoth = true; - mExistsInBoth = true; - boolean consistent = true; - - if (isInterface() != cl.isInterface()) { - Errors.error(Errors.CHANGED_CLASS, cl.position(), - "Class " + cl.qualifiedName() - + " changed class/interface declaration"); - consistent = false; - } - for (String iface : mInterfaceNames) { - if (!implementsInterface(cl, iface)) { - Errors.error(Errors.REMOVED_INTERFACE, cl.position(), - "Class " + qualifiedName() + " no longer implements " + iface); - } - } - for (String iface : cl.mInterfaceNames) { - if (!mInterfaceNames.contains(iface)) { - Errors.error(Errors.ADDED_INTERFACE, cl.position(), - "Added interface " + iface + " to class " - + qualifiedName()); - consistent = false; - } - } - - for (MethodInfo mInfo : mMethods.values()) { - if (cl.mMethods.containsKey(mInfo.getHashableName())) { - if (!mInfo.isConsistent(cl.mMethods.get(mInfo.getHashableName()))) { - consistent = false; - } - } else { - /* This class formerly provided this method directly, and now does not. - * Check our ancestry to see if there's an inherited version that still - * fulfills the API requirement. - */ - MethodInfo mi = ClassInfo.overriddenMethod(mInfo, cl); - if (mi == null) { - mi = ClassInfo.interfaceMethod(mInfo, cl); - } - if (mi == null) { - Errors.error(Errors.REMOVED_METHOD, mInfo.position(), - "Removed public method " + mInfo.qualifiedName()); - consistent = false; - } - } - } - for (MethodInfo mInfo : cl.mMethods.values()) { - if (!mInfo.isInBoth()) { - /* Similarly to the above, do not fail if this "new" method is - * really an override of an existing superclass method. - */ - MethodInfo mi = ClassInfo.overriddenMethod(mInfo, cl); - if (mi == null) { - Errors.error(Errors.ADDED_METHOD, mInfo.position(), - "Added public method " + mInfo.qualifiedName()); - consistent = false; - } - } - } - - for (ConstructorInfo mInfo : mConstructors.values()) { - if (cl.mConstructors.containsKey(mInfo.getHashableName())) { - if (!mInfo.isConsistent(cl.mConstructors.get(mInfo.getHashableName()))) { - consistent = false; - } - } else { - Errors.error(Errors.REMOVED_METHOD, mInfo.position(), - "Removed public constructor " + mInfo.prettySignature()); - consistent = false; - } - } - for (ConstructorInfo mInfo : cl.mConstructors.values()) { - if (!mInfo.isInBoth()) { - Errors.error(Errors.ADDED_METHOD, mInfo.position(), - "Added public constructor " + mInfo.prettySignature()); - consistent = false; - } - } - - for (FieldInfo mInfo : mFields.values()) { - if (cl.mFields.containsKey(mInfo.name())) { - if (!mInfo.isConsistent(cl.mFields.get(mInfo.name()))) { - consistent = false; - } - } else { - Errors.error(Errors.REMOVED_FIELD, mInfo.position(), - "Removed field " + mInfo.qualifiedName()); - consistent = false; - } - } - for (FieldInfo mInfo : cl.mFields.values()) { - if (!mInfo.isInBoth()) { - Errors.error(Errors.ADDED_FIELD, mInfo.position(), - "Added public field " + mInfo.qualifiedName()); - consistent = false; - } - } - - if (mIsAbstract != cl.mIsAbstract) { - consistent = false; - Errors.error(Errors.CHANGED_ABSTRACT, cl.position(), - "Class " + cl.qualifiedName() + " changed abstract qualifier"); - } - - if (mIsFinal != cl.mIsFinal) { - consistent = false; - Errors.error(Errors.CHANGED_FINAL, cl.position(), - "Class " + cl.qualifiedName() + " changed final qualifier"); - } - - if (mIsStatic != cl.mIsStatic) { - consistent = false; - Errors.error(Errors.CHANGED_STATIC, cl.position(), - "Class " + cl.qualifiedName() + " changed static qualifier"); - } - - if (!mScope.equals(cl.mScope)) { - consistent = false; - Errors.error(Errors.CHANGED_SCOPE, cl.position(), - "Class " + cl.qualifiedName() + " scope changed from " - + mScope + " to " + cl.mScope); - } - - if (!mDeprecated.equals(cl.mDeprecated)) { - consistent = false; - Errors.error(Errors.CHANGED_DEPRECATED, cl.position(), - "Class " + cl.qualifiedName() + " has changed deprecation state"); - } - - if (mSuperClassName != null) { - if (cl.mSuperClassName == null || !mSuperClassName.equals(cl.mSuperClassName)) { - consistent = false; - Errors.error(Errors.CHANGED_SUPERCLASS, cl.position(), - "Class " + qualifiedName() + " superclass changed from " - + mSuperClassName + " to " + cl.mSuperClassName); - } - } else if (cl.mSuperClassName != null) { - consistent = false; - Errors.error(Errors.CHANGED_SUPERCLASS, cl.position(), - "Class " + qualifiedName() + " superclass changed from " - + "null to " + cl.mSuperClassName); - } - - return consistent; - } - - /** - * Returns true if {@code cl} implements the interface {@code iface} either - * by either being that interface, implementing that interface or extending - * a type that implements the interface. - */ - private boolean implementsInterface(ClassInfo cl, String iface) { - if (cl.qualifiedName().equals(iface)) { - return true; - } - for (ClassInfo clImplements : cl.mInterfaces) { - if (implementsInterface(clImplements, iface)) { - return true; - } - } - if (cl.mSuperClass != null && implementsInterface(cl.mSuperClass, iface)) { - return true; - } - return false; - } - - public void resolveInterfaces(ApiInfo apiInfo) { - for (String interfaceName : mInterfaceNames) { - mInterfaces.add(apiInfo.findClass(interfaceName)); - } - } - - public void addInterface(String name) { - mInterfaceNames.add(name); - } - - public void addMethod(MethodInfo mInfo) { - mMethods.put(mInfo.getHashableName(), mInfo); - } - - public void addConstructor(ConstructorInfo cInfo) { - mConstructors.put(cInfo.getHashableName(), cInfo); - - } - - public void addField(FieldInfo fInfo) { - mFields.put(fInfo.name(), fInfo); - - } - - public void setSuperClass(ClassInfo superclass) { - mSuperClass = superclass; - } - - public boolean isInBoth() { - return mExistsInBoth; - } - - public Map allConstructors() { - return mConstructors; - } - - public Map allFields() { - return mFields; - } - - public Map allMethods() { - return mMethods; - } - - /** - * Returns the class hierarchy for this class, starting with this class. - */ - public Iterable hierarchy() { - List result = new ArrayList(4); - for (ClassInfo c = this; c != null; c = c.mSuperClass) { - result.add(c); - } - return result; - } -} diff --git a/tools/apicheck/src/com/android/apicheck/ConstructorInfo.java b/tools/apicheck/src/com/android/apicheck/ConstructorInfo.java deleted file mode 100644 index f36c7cd0b..000000000 --- a/tools/apicheck/src/com/android/apicheck/ConstructorInfo.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.apicheck; -import java.util.*; - -public class ConstructorInfo implements AbstractMethodInfo { - - private String mName; - private String mType; - private boolean mIsStatic; - private boolean mIsFinal; - private String mDeprecated; - private String mScope; - private List mExceptions; - private List mParameters; - private boolean mExistsInBoth; - private SourcePositionInfo mSourcePosition; - private ClassInfo mClass; - - public ConstructorInfo(String name, String type, boolean isStatic, boolean isFinal, - String deprecated, String scope, SourcePositionInfo pos, ClassInfo clazz) { - mName = name; - mType = type; - mIsStatic = isStatic; - mIsFinal = isFinal; - mDeprecated= deprecated; - mScope = scope; - mExistsInBoth = false; - mExceptions = new ArrayList(); - mParameters = new ArrayList(); - mSourcePosition = pos; - mClass = clazz; - } - - public void addParameter(ParameterInfo pInfo) { - mParameters.add(pInfo); - } - - public void addException(String exec) { - mExceptions.add(exec); - } - - public String getHashableName() { - StringBuilder result = new StringBuilder(); - result.append(name()); - for (ParameterInfo pInfo : mParameters) { - result.append(":").append(pInfo.getType()); - } - return result.toString(); - } - - public boolean isInBoth() { - return mExistsInBoth; - } - - public SourcePositionInfo position() { - return mSourcePosition; - } - - public String name() { - return mName; - } - - public String qualifiedName() { - String baseName = (mClass != null) - ? (mClass.qualifiedName() + ".") - : ""; - return baseName + name(); - } - - public String prettySignature() { - String params = ""; - for (ParameterInfo pInfo : mParameters) { - if (params.length() > 0) { - params += ", "; - } - params += pInfo.getType(); - } - return qualifiedName() + '(' + params + ')'; - } - - public boolean isConsistent(ConstructorInfo mInfo) { - mInfo.mExistsInBoth = true; - mExistsInBoth = true; - boolean consistent = true; - - if (mIsFinal != mInfo.mIsFinal) { - consistent = false; - Errors.error(Errors.CHANGED_FINAL, mInfo.position(), - "Constructor " + mInfo.qualifiedName() + " has changed 'final' qualifier"); - } - - if (mIsStatic != mInfo.mIsStatic) { - consistent = false; - Errors.error(Errors.CHANGED_FINAL, mInfo.position(), - "Constructor " + mInfo.qualifiedName() + " has changed 'static' qualifier"); - } - - if (!mScope.equals(mInfo.mScope)) { - consistent = false; - Errors.error(Errors.CHANGED_SCOPE, mInfo.position(), - "Constructor " + mInfo.qualifiedName() + " changed scope from " - + mScope + " to " + mInfo.mScope); - } - - if (!mDeprecated.equals(mInfo.mDeprecated)) { - consistent = false; - Errors.error(Errors.CHANGED_DEPRECATED, mInfo.position(), - "Constructor " + mInfo.qualifiedName() + " has changed deprecation state"); - } - - for (String exec : mExceptions) { - if (!mInfo.mExceptions.contains(exec)) { - Errors.error(Errors.CHANGED_THROWS, mInfo.position(), - "Constructor " + mInfo.qualifiedName() + " no longer throws exception " - + exec); - consistent = false; - } - } - - for (String exec : mInfo.mExceptions) { - if (!mExceptions.contains(exec)) { - Errors.error(Errors.CHANGED_THROWS, mInfo.position(), - "Constructor " + mInfo.qualifiedName() + " added thrown exception " - + exec); - consistent = false; - } - } - - return consistent; - } - - -} diff --git a/tools/apicheck/src/com/android/apicheck/Errors.java b/tools/apicheck/src/com/android/apicheck/Errors.java deleted file mode 100644 index b0b620ef6..000000000 --- a/tools/apicheck/src/com/android/apicheck/Errors.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.apicheck; - -import java.lang.Comparable; -import java.util.TreeSet; - -public class Errors -{ - public static boolean hadError = false; - private static boolean warningsAreErrors = false; - private static TreeSet allErrors = new TreeSet(); - - private static class Message implements Comparable { - SourcePositionInfo pos; - String msg; - - Message(SourcePositionInfo p, String m) { - pos = p; - msg = m; - } - - public int compareTo(Object o) { - Message that = (Message)o; - int r = this.pos.compareTo(that.pos); - if (r != 0) return r; - return this.msg.compareTo(that.msg); - } - - @Override - public String toString() { - return this.pos.toString() + this.msg; - } - } - - public static void error(Error error, SourcePositionInfo where, String text) { - if (error.level == HIDDEN) { - return; - } - - String which = (!warningsAreErrors && error.level == WARNING) ? " warning " : " error "; - String message = which + error.code + ": " + text; - - if (where == null) { - where = new SourcePositionInfo("unknown", 0, 0); - } - - allErrors.add(new Message(where, message)); - - if (error.level == ERROR || (warningsAreErrors && error.level == WARNING)) { - hadError = true; - } - } - - public static void printErrors() { - for (Message m: allErrors) { - System.err.println(m.toString()); - } - } - - public static int HIDDEN = 0; - public static int WARNING = 1; - public static int ERROR = 2; - - public static void setWarningsAreErrors(boolean val) { - warningsAreErrors = val; - } - - public static class Error { - public int code; - public int level; - - public Error(int code, int level) - { - this.code = code; - this.level = level; - } - } - - public static Error PARSE_ERROR = new Error(1, ERROR); - public static Error ADDED_PACKAGE = new Error(2, WARNING); - public static Error ADDED_CLASS = new Error(3, WARNING); - public static Error ADDED_METHOD = new Error(4, WARNING); - public static Error ADDED_FIELD = new Error(5, WARNING); - public static Error ADDED_INTERFACE = new Error(6, WARNING); - public static Error REMOVED_PACKAGE = new Error(7, WARNING); - public static Error REMOVED_CLASS = new Error(8, WARNING); - public static Error REMOVED_METHOD = new Error(9, WARNING); - public static Error REMOVED_FIELD = new Error(10, WARNING); - public static Error REMOVED_INTERFACE = new Error(11, WARNING); - public static Error CHANGED_STATIC = new Error(12, WARNING); - public static Error CHANGED_FINAL = new Error(13, WARNING); - public static Error CHANGED_TRANSIENT = new Error(14, WARNING); - public static Error CHANGED_VOLATILE = new Error(15, WARNING); - public static Error CHANGED_TYPE = new Error(16, WARNING); - public static Error CHANGED_VALUE = new Error(17, WARNING); - public static Error CHANGED_SUPERCLASS = new Error(18, WARNING); - public static Error CHANGED_SCOPE = new Error(19, WARNING); - public static Error CHANGED_ABSTRACT = new Error(20, WARNING); - public static Error CHANGED_THROWS = new Error(21, WARNING); - public static Error CHANGED_NATIVE = new Error(22, HIDDEN); - public static Error CHANGED_CLASS = new Error(23, WARNING); - public static Error CHANGED_DEPRECATED = new Error(24, WARNING); - public static Error CHANGED_SYNCHRONIZED = new Error(25, ERROR); - - public static Error[] ERRORS = { - PARSE_ERROR, - ADDED_PACKAGE, - ADDED_CLASS, - ADDED_METHOD, - ADDED_FIELD, - ADDED_INTERFACE, - REMOVED_PACKAGE, - REMOVED_CLASS, - REMOVED_METHOD, - REMOVED_FIELD, - REMOVED_INTERFACE, - CHANGED_STATIC, - CHANGED_FINAL, - CHANGED_TRANSIENT, - CHANGED_VOLATILE, - CHANGED_TYPE, - CHANGED_VALUE, - CHANGED_SUPERCLASS, - CHANGED_SCOPE, - CHANGED_ABSTRACT, - CHANGED_THROWS, - CHANGED_NATIVE, - CHANGED_CLASS, - CHANGED_DEPRECATED, - CHANGED_SYNCHRONIZED, - }; - - public static boolean setErrorLevel(int code, int level) { - for (Error e: ERRORS) { - if (e.code == code) { - e.level = level; - return true; - } - } - return false; - } -} diff --git a/tools/apicheck/src/com/android/apicheck/FieldInfo.java b/tools/apicheck/src/com/android/apicheck/FieldInfo.java deleted file mode 100644 index d80d9f6a6..000000000 --- a/tools/apicheck/src/com/android/apicheck/FieldInfo.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.apicheck; - -public class FieldInfo { - - private String mName; - private String mType; - private boolean mIsTransient; - private boolean mIsVolatile; - private String mValue; - private boolean mIsStatic; - private boolean mIsFinal; - private String mDeprecated; - private String mScope; - private boolean mExistsInBoth; - private SourcePositionInfo mSourcePosition; - private ClassInfo mClass; - - public FieldInfo (String name, String type, boolean isTransient, boolean isVolatile, - String value, boolean isStatic, boolean isFinal, String deprecated, - String scope, SourcePositionInfo source, ClassInfo parent) { - mName = name; - mType = type; - mIsTransient = isTransient; - mIsVolatile = isVolatile; - mValue = value; - mIsStatic = isStatic; - mIsFinal = isFinal; - mDeprecated = deprecated; - mScope = scope; - mExistsInBoth = false; - mSourcePosition = source; - mClass = parent; - } - - public boolean isInBoth() { - return mExistsInBoth; - } - public SourcePositionInfo position() { - return mSourcePosition; - } - - public String name() { - return mName; - } - - public String qualifiedName() { - String parentQName = (mClass != null) - ? (mClass.qualifiedName() + ".") - : ""; - return parentQName + name(); - } - - // Check the declared value with a typed comparison, not a string comparison, - // to accommodate toolchains with different fp -> string conversions. - public boolean valueEquals(FieldInfo other) { - // Type mismatch means nonequal, as does a null/non-null mismatch - if (!mType.equals(other.mType) - || ((mValue == null) != (other.mValue == null))) { - return false; - } - - // Null values are considered equal - if (mValue == null) { - return true; - } - - // Floating point gets an implementation-type comparison; all others just use the string - // If float/double parse fails, fall back to string comparison -- it means that it's a - // canonical droiddoc-generated constant expression that represents a NaN. - try { - if (mType.equals("float")) { - float val = Float.parseFloat(mValue); - float otherVal = Float.parseFloat(other.mValue); - return (val == otherVal); - } else if (mType.equals("double")) { - double val = Double.parseDouble(mValue); - double otherVal = Double.parseDouble(other.mValue); - return (val == otherVal); - } - } catch (NumberFormatException e) { - // fall through - } - - return mValue.equals(other.mValue); - } - - public boolean isConsistent(FieldInfo fInfo) { - fInfo.mExistsInBoth = true; - mExistsInBoth = true; - boolean consistent = true; - if (!mType.equals(fInfo.mType)) { - Errors.error(Errors.CHANGED_TYPE, fInfo.position(), - "Field " + fInfo.qualifiedName() + " has changed type"); - consistent = false; - } - - if (!this.valueEquals(fInfo)) { - Errors.error(Errors.CHANGED_VALUE, fInfo.position(), - "Field " + fInfo.qualifiedName() + " has changed value from " - + mValue + " to " + fInfo.mValue); - consistent = false; - } - - if (!mScope.equals(fInfo.mScope)) { - Errors.error(Errors.CHANGED_SCOPE, fInfo.position(), - "Method " + fInfo.qualifiedName() + " changed scope from " - + mScope + " to " + fInfo.mScope); - consistent = false; - } - - if (mIsStatic != fInfo.mIsStatic) { - Errors.error(Errors.CHANGED_STATIC, fInfo.position(), - "Field " + fInfo.qualifiedName() + " has changed 'static' qualifier"); - consistent = false; - } - - if (mIsFinal != fInfo.mIsFinal) { - Errors.error(Errors.CHANGED_FINAL, fInfo.position(), - "Field " + fInfo.qualifiedName() + " has changed 'final' qualifier"); - consistent = false; - } - - if (mIsTransient != fInfo.mIsTransient) { - Errors.error(Errors.CHANGED_TRANSIENT, fInfo.position(), - "Field " + fInfo.qualifiedName() + " has changed 'transient' qualifier"); - consistent = false; - } - - if (mIsVolatile != fInfo.mIsVolatile) { - Errors.error(Errors.CHANGED_VOLATILE, fInfo.position(), - "Field " + fInfo.qualifiedName() + " has changed 'volatile' qualifier"); - consistent = false; - } - - if (!mDeprecated.equals(fInfo.mDeprecated)) { - Errors.error(Errors.CHANGED_DEPRECATED, fInfo.position(), - "Field " + fInfo.qualifiedName() + " has changed deprecation state"); - consistent = false; - } - - return consistent; - } - -} diff --git a/tools/apicheck/src/com/android/apicheck/MethodInfo.java b/tools/apicheck/src/com/android/apicheck/MethodInfo.java deleted file mode 100644 index e4e45376e..000000000 --- a/tools/apicheck/src/com/android/apicheck/MethodInfo.java +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.apicheck; -import java.util.*; - -public class MethodInfo implements AbstractMethodInfo { - - private String mName; - private String mReturn; - private boolean mIsAbstract; - private boolean mIsNative; - private boolean mIsSynchronized; - private boolean mIsStatic; - private boolean mIsFinal; - private String mDeprecated; - private String mScope; - private boolean mExistsInBoth; - private List mParameters; - private List mExceptions; - private SourcePositionInfo mSourcePosition; - private ClassInfo mClass; - - public MethodInfo (String name, String returnType, boolean isAbstract, boolean isNative, - boolean isSynchronized, boolean isStatic, boolean isFinal, String deprecated - , String scope, SourcePositionInfo source, ClassInfo parent) { - - mName = name; - mReturn = returnType; - mIsAbstract = isAbstract; - mIsNative = isNative; - mIsSynchronized = isSynchronized; - mIsStatic = isStatic; - mIsFinal = isFinal; - mDeprecated = deprecated; - mScope = scope; - mParameters = new ArrayList(); - mExceptions = new ArrayList(); - mExistsInBoth = false; - mSourcePosition = source; - mClass = parent; - } - - - public String name() { - return mName; - } - - public String qualifiedName() { - String parentQName = (mClass != null) - ? (mClass.qualifiedName() + ".") - : ""; - return parentQName + name(); - } - - public String prettySignature() { - String params = ""; - for (ParameterInfo pInfo : mParameters) { - if (params.length() > 0) { - params += ", "; - } - params += pInfo.getType(); - } - return qualifiedName() + '(' + params + ')'; - } - - public SourcePositionInfo position() { - return mSourcePosition; - } - - public ClassInfo containingClass() { - return mClass; - } - - public boolean matches(MethodInfo other) { - return getSignature().equals(other.getSignature()); - } - - public boolean isConsistent(MethodInfo mInfo) { - mInfo.mExistsInBoth = true; - mExistsInBoth = true; - boolean consistent = true; - if (!mReturn.equals(mInfo.mReturn)) { - consistent = false; - Errors.error(Errors.CHANGED_TYPE, mInfo.position(), - "Method " + mInfo.qualifiedName() + " has changed return type from " - + mReturn + " to " + mInfo.mReturn); - } - - if (mIsAbstract != mInfo.mIsAbstract) { - consistent = false; - Errors.error(Errors.CHANGED_ABSTRACT, mInfo.position(), - "Method " + mInfo.qualifiedName() + " has changed 'abstract' qualifier"); - } - - if (mIsNative != mInfo.mIsNative) { - consistent = false; - Errors.error(Errors.CHANGED_NATIVE, mInfo.position(), - "Method " + mInfo.qualifiedName() + " has changed 'native' qualifier"); - } - - if (mIsFinal != mInfo.mIsFinal) { - // Compiler-generated methods vary in their 'final' qual between versions of - // the compiler, so this check needs to be quite narrow. A change in 'final' - // status of a method is only relevant if (a) the method is not declared 'static' - // and (b) the method's class is not itself 'final'. - if (!mIsStatic) { - if ((mClass == null) || (!mClass.isFinal())) { - consistent = false; - Errors.error(Errors.CHANGED_FINAL, mInfo.position(), - "Method " + mInfo.qualifiedName() + " has changed 'final' qualifier"); - } - } - } - - if (mIsStatic != mInfo.mIsStatic) { - consistent = false; - Errors.error(Errors.CHANGED_STATIC, mInfo.position(), - "Method " + mInfo.qualifiedName() + " has changed 'static' qualifier"); - } - - if (!mScope.equals(mInfo.mScope)) { - consistent = false; - Errors.error(Errors.CHANGED_SCOPE, mInfo.position(), - "Method " + mInfo.qualifiedName() + " changed scope from " - + mScope + " to " + mInfo.mScope); - } - - if (!mDeprecated.equals(mInfo.mDeprecated)) { - Errors.error(Errors.CHANGED_DEPRECATED, mInfo.position(), - "Method " + mInfo.qualifiedName() + " has changed deprecation state"); - consistent = false; - } - - if (mIsSynchronized != mInfo.mIsSynchronized) { - Errors.error(Errors.CHANGED_SYNCHRONIZED, mInfo.position(), - "Method " + mInfo.qualifiedName() + " has changed 'synchronized' qualifier from " + mIsSynchronized + " to " + mInfo.mIsSynchronized); - consistent = false; - } - - for (String exec : mExceptions) { - if (!mInfo.mExceptions.contains(exec)) { - // exclude 'throws' changes to finalize() overrides with no arguments - if (!name().equals("finalize") || (mParameters.size() > 0)) { - Errors.error(Errors.CHANGED_THROWS, mInfo.position(), - "Method " + mInfo.qualifiedName() + " no longer throws exception " - + exec); - consistent = false; - } - } - } - - for (String exec : mInfo.mExceptions) { - // exclude 'throws' changes to finalize() overrides with no arguments - if (!mExceptions.contains(exec)) { - if (!name().equals("finalize") || (mParameters.size() > 0)) { - Errors.error(Errors.CHANGED_THROWS, mInfo.position(), - "Method " + mInfo.qualifiedName() + " added thrown exception " - + exec); - consistent = false; - } - } - } - - return consistent; - } - - public void addParameter(ParameterInfo pInfo) { - mParameters.add(pInfo); - } - - public void addException(String exc) { - mExceptions.add(exc); - } - - public String getParameterHash() { - String hash = ""; - for (ParameterInfo pInfo : mParameters) { - hash += ":" + pInfo.getType(); - } - return hash; - } - - public String getHashableName() { - return name() + getParameterHash(); - } - - public String getSignature() { - return name() + getParameterHash(); - } - - public boolean isInBoth() { - return mExistsInBoth; - } - -} diff --git a/tools/apicheck/src/com/android/apicheck/PackageInfo.java b/tools/apicheck/src/com/android/apicheck/PackageInfo.java deleted file mode 100644 index 2262f21fd..000000000 --- a/tools/apicheck/src/com/android/apicheck/PackageInfo.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.apicheck; -import java.util.*; - -public class PackageInfo { - private String mName; - private HashMap mClasses; - private boolean mExistsInBoth; - private SourcePositionInfo mPosition; - - public PackageInfo(String name, SourcePositionInfo position) { - mName = name; - mClasses = new HashMap(); - mExistsInBoth = false; - mPosition = position; - } - - public void addClass(ClassInfo cl) { - mClasses.put(cl.name() , cl); - } - - public HashMap allClasses() { - return mClasses; - } - - public String name() { - return mName; - } - - public SourcePositionInfo position() { - return mPosition; - } - - public boolean isConsistent(PackageInfo pInfo) { - mExistsInBoth = true; - pInfo.mExistsInBoth = true; - boolean consistent = true; - for (ClassInfo cInfo : mClasses.values()) { - if (pInfo.mClasses.containsKey(cInfo.name())) { - if (!cInfo.isConsistent(pInfo.mClasses.get(cInfo.name()))) { - consistent = false; - } - } else { - Errors.error(Errors.REMOVED_CLASS, cInfo.position(), - "Removed public class " + cInfo.qualifiedName()); - consistent = false; - } - } - for (ClassInfo cInfo : pInfo.mClasses.values()) { - if (!cInfo.isInBoth()) { - Errors.error(Errors.ADDED_CLASS, cInfo.position(), - "Added class " + cInfo.name() + " to package " - + pInfo.name()); - consistent = false; - } - } - return consistent; - } - - public boolean isInBoth() { - return mExistsInBoth; - } -} diff --git a/tools/apicheck/src/com/android/apicheck/ParameterInfo.java b/tools/apicheck/src/com/android/apicheck/ParameterInfo.java deleted file mode 100644 index 5788814cb..000000000 --- a/tools/apicheck/src/com/android/apicheck/ParameterInfo.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.apicheck; - -public class ParameterInfo { - private String mType; - private String mName; - - public ParameterInfo(String type, String name) { - mType = type; - mName = name; - } - - public String getType() { - return mType; - } - - public String getName() { - return mName; - } -} diff --git a/tools/apicheck/src/com/android/apicheck/SourcePositionInfo.java b/tools/apicheck/src/com/android/apicheck/SourcePositionInfo.java deleted file mode 100644 index 276771b16..000000000 --- a/tools/apicheck/src/com/android/apicheck/SourcePositionInfo.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.apicheck; - -import java.lang.Comparable; - -public class SourcePositionInfo implements Comparable -{ - public SourcePositionInfo() { - this.file = ""; - this.line = 0; - this.column = 0; - } - - public SourcePositionInfo(String file, int line, int column) - { - this.file = file; - this.line = line; - this.column = column; - } - - public SourcePositionInfo(SourcePositionInfo that) - { - this.file = that.file; - this.line = that.line; - this.column = that.column; - } - - /** - * Given this position and str which occurs at that position, as well as str an index into str, - * find the SourcePositionInfo. - * - * @throw StringIndexOutOfBoundsException if index > str.length() - */ - public static SourcePositionInfo add(SourcePositionInfo that, String str, int index) - { - if (that == null) { - return null; - } - int line = that.line; - char prev = 0; - for (int i=0; i=0; i--) { - char c = str.charAt(i); - if ((c == '\r' && prev != '\n') || (c == '\n')) { - line--; - } - prev = c; - } - return new SourcePositionInfo(that.file, line, 0); - } - - @Override - public String toString() - { - if (this.file == null) { - return "(unknown)"; - } else { - if (this.line == 0) { - return this.file + ':'; - } else { - return this.file + ':' + this.line + ':'; - } - } - } - - public int compareTo(Object o) { - SourcePositionInfo that = (SourcePositionInfo)o; - int r = this.file.compareTo(that.file); - if (r != 0) return r; - return this.line - that.line; - } - - /** - * Build a SourcePositionInfo from the XML source= notation - */ - public static SourcePositionInfo fromXml(String source) { - if (source != null) { - for (int i = 0; i < source.length(); i++) { - if (source.charAt(i) == ':') { - return new SourcePositionInfo(source.substring(0, i), - Integer.parseInt(source.substring(i+1)), 0); - } - } - } - - return new SourcePositionInfo("(unknown)", 0, 0); - } - - public String file; - public int line; - public int column; -} diff --git a/tools/droiddoc/NOTICE b/tools/droiddoc/NOTICE deleted file mode 100644 index 3f1b1bb5b..000000000 --- a/tools/droiddoc/NOTICE +++ /dev/null @@ -1,45 +0,0 @@ - -Copyright (C) 2008 The Android Open Source Project - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - - -====================================================================== - -jQuery 1.2.6 - New Wave Javascript - -Copyright (c) 2008 John Resig (jquery.com) -Dual licensed under the MIT (MIT-LICENSE.txt) -and GPL (GPL-LICENSE.txt) licenses. - -Copyright (c) 2009 John Resig, http://jquery.com/ - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/tools/droiddoc/src/Android.mk b/tools/droiddoc/src/Android.mk deleted file mode 100644 index 30270b566..000000000 --- a/tools/droiddoc/src/Android.mk +++ /dev/null @@ -1,69 +0,0 @@ -# Copyright (C) 2008 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - AnnotationInstanceInfo.java \ - AnnotationValueInfo.java \ - AttributeInfo.java \ - AttrTagInfo.java \ - ClassInfo.java \ - DroidDoc.java \ - ClearPage.java \ - Comment.java \ - ContainerInfo.java \ - Converter.java \ - DocFile.java \ - DocInfo.java \ - Errors.java \ - FieldInfo.java \ - Hierarchy.java \ - InheritedTags.java \ - KeywordEntry.java \ - LinkReference.java \ - LiteralTagInfo.java \ - MemberInfo.java \ - MethodInfo.java \ - NavTree.java \ - PackageInfo.java \ - ParamTagInfo.java \ - ParameterInfo.java \ - ParsedTagInfo.java \ - Proofread.java \ - SampleCode.java \ - SampleTagInfo.java \ - Scoped.java \ - SeeTagInfo.java \ - SinceTagger.java \ - Sorter.java \ - SourcePositionInfo.java \ - Stubs.java \ - TagInfo.java \ - TextTagInfo.java \ - ThrowsTagInfo.java \ - TodoFile.java \ - TypeInfo.java - -LOCAL_JAVA_LIBRARIES := \ - apicheck \ - clearsilver - -LOCAL_CLASSPATH := \ - $(HOST_JDK_TOOLS_JAR) - -LOCAL_MODULE:= droiddoc - -include $(BUILD_HOST_JAVA_LIBRARY) diff --git a/tools/droiddoc/src/AnnotationInstanceInfo.java b/tools/droiddoc/src/AnnotationInstanceInfo.java deleted file mode 100644 index c4abc7e65..000000000 --- a/tools/droiddoc/src/AnnotationInstanceInfo.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -class AnnotationInstanceInfo -{ - private ClassInfo mType; - private AnnotationValueInfo[] mElementValues; - - public AnnotationInstanceInfo(ClassInfo type, AnnotationValueInfo[] elementValues) - { - mType = type; - mElementValues = elementValues; - } - - ClassInfo type() - { - return mType; - } - - AnnotationValueInfo[] elementValues() - { - return mElementValues; - } - - @Override - public String toString() - { - StringBuilder str = new StringBuilder(); - str.append("@"); - str.append(mType.qualifiedName()); - str.append("("); - AnnotationValueInfo[] values = mElementValues; - final int N = values.length; - for (int i=0; i comparator = new Comparator() { - public int compare(AttributeInfo a, AttributeInfo b) { - return a.name().compareTo(b.name()); - } - }; - - public FieldInfo attrField; - public ArrayList methods = new ArrayList(); - - private ClassInfo mClass; - private String mName; - private Comment mComment; - - public AttributeInfo(ClassInfo cl, FieldInfo f) { - mClass = cl; - attrField = f; - } - - public String name() { - if (mName == null) { - for (AttrTagInfo comment: attrField.comment().attrTags()) { - String n = comment.name(); - if (n != null) { - mName = n; - return n; - } - } - } - return mName; - } - - public Comment comment() { - if (mComment == null) { - for (AttrTagInfo attr: attrField.comment().attrTags()) { - Comment c = attr.description(); - if (c != null) { - mComment = c; - return c; - } - } - } - if (mComment == null) { - return new Comment("", mClass, new SourcePositionInfo()); - } - return mComment; - } - - public String anchor() { - return "attr_" + name(); - } - public String htmlPage() { - return mClass.htmlPage() + "#" + anchor(); - } - - public void makeHDF(HDF data, String base) { - data.setValue(base + ".name", name()); - data.setValue(base + ".anchor", anchor()); - data.setValue(base + ".href", htmlPage()); - data.setValue(base + ".R.name", attrField.name()); - data.setValue(base + ".R.href", attrField.htmlPage()); - TagInfo.makeHDF(data, base + ".deprecated", attrField.comment().deprecatedTags()); - TagInfo.makeHDF(data, base + ".shortDescr", comment().briefTags()); - TagInfo.makeHDF(data, base + ".descr", comment().tags()); - - int i=0; - for (MethodInfo m: methods) { - String s = base + ".methods." + i; - data.setValue(s + ".href", m.htmlPage()); - data.setValue(s + ".name", m.name() + m.prettySignature()); - } - } - - public boolean checkLevel() { - return attrField.checkLevel(); - } -} - diff --git a/tools/droiddoc/src/ClassInfo.java b/tools/droiddoc/src/ClassInfo.java deleted file mode 100644 index f3f11de46..000000000 --- a/tools/droiddoc/src/ClassInfo.java +++ /dev/null @@ -1,1464 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import com.sun.javadoc.*; -import com.sun.tools.doclets.*; -import org.clearsilver.HDF; -import org.clearsilver.CS; -import java.util.*; -import java.io.*; - -public class ClassInfo extends DocInfo implements ContainerInfo, Comparable, Scoped -{ - public static final Comparator comparator = new Comparator() { - public int compare(ClassInfo a, ClassInfo b) { - return a.name().compareTo(b.name()); - } - }; - - public static final Comparator qualifiedComparator = new Comparator() { - public int compare(ClassInfo a, ClassInfo b) { - return a.qualifiedName().compareTo(b.qualifiedName()); - } - }; - - public ClassInfo( - ClassDoc cl, - String rawCommentText, SourcePositionInfo position, - boolean isPublic, boolean isProtected, boolean isPackagePrivate, - boolean isPrivate, boolean isStatic, - boolean isInterface, boolean isAbstract, boolean isOrdinaryClass, - boolean isException, boolean isError, boolean isEnum, boolean isAnnotation, - boolean isFinal, boolean isIncluded, String name, - String qualifiedName, String qualifiedTypeName, boolean isPrimitive) - { - super(rawCommentText, position); - - mClass = cl; - mIsPublic = isPublic; - mIsProtected = isProtected; - mIsPackagePrivate = isPackagePrivate; - mIsPrivate = isPrivate; - mIsStatic = isStatic; - mIsInterface = isInterface; - mIsAbstract = isAbstract; - mIsOrdinaryClass = isOrdinaryClass; - mIsException = isException; - mIsError = isError; - mIsEnum = isEnum; - mIsAnnotation = isAnnotation; - mIsFinal = isFinal; - mIsIncluded = isIncluded; - mName = name; - mQualifiedName = qualifiedName; - mQualifiedTypeName = qualifiedTypeName; - mIsPrimitive = isPrimitive; - mNameParts = name.split("\\."); - } - - public void init(TypeInfo typeInfo, ClassInfo[] interfaces, TypeInfo[] interfaceTypes, - ClassInfo[] innerClasses, - MethodInfo[] constructors, MethodInfo[] methods, MethodInfo[] annotationElements, - FieldInfo[] fields, FieldInfo[] enumConstants, - PackageInfo containingPackage, ClassInfo containingClass, - ClassInfo superclass, TypeInfo superclassType, AnnotationInstanceInfo[] annotations) - { - mTypeInfo = typeInfo; - mRealInterfaces = interfaces; - mRealInterfaceTypes = interfaceTypes; - mInnerClasses = innerClasses; - mAllConstructors = constructors; - mAllSelfMethods = methods; - mAnnotationElements = annotationElements; - mAllSelfFields = fields; - mEnumConstants = enumConstants; - mContainingPackage = containingPackage; - mContainingClass = containingClass; - mRealSuperclass = superclass; - mRealSuperclassType = superclassType; - mAnnotations = annotations; - - // after providing new methods and new superclass info,clear any cached - // lists of self + superclass methods, ctors, etc. - mSuperclassInit = false; - mConstructors = null; - mMethods = null; - mSelfMethods = null; - mFields = null; - mSelfFields = null; - mSelfAttributes = null; - mDeprecatedKnown = false; - - Arrays.sort(mEnumConstants, FieldInfo.comparator); - Arrays.sort(mInnerClasses, ClassInfo.comparator); - } - - public void init2() { - // calling this here forces the AttrTagInfo objects to be linked to the AttribtueInfo - // objects - selfAttributes(); - } - - public void init3(TypeInfo[] types, ClassInfo[] realInnerClasses){ - mTypeParameters = types; - mRealInnerClasses = realInnerClasses; - } - - public ClassInfo[] getRealInnerClasses(){ - return mRealInnerClasses; - } - - public TypeInfo[] getTypeParameters(){ - return mTypeParameters; - } - - public boolean checkLevel() - { - int val = mCheckLevel; - if (val >= 0) { - return val != 0; - } else { - boolean v = DroidDoc.checkLevel(mIsPublic, mIsProtected, - mIsPackagePrivate, mIsPrivate, isHidden()); - mCheckLevel = v ? 1 : 0; - return v; - } - } - - public int compareTo(Object that) { - if (that instanceof ClassInfo) { - return mQualifiedName.compareTo(((ClassInfo)that).mQualifiedName); - } else { - return this.hashCode() - that.hashCode(); - } - } - - @Override - public ContainerInfo parent() - { - return this; - } - - public boolean isPublic() - { - return mIsPublic; - } - - public boolean isProtected() - { - return mIsProtected; - } - - public boolean isPackagePrivate() - { - return mIsPackagePrivate; - } - - public boolean isPrivate() - { - return mIsPrivate; - } - - public boolean isStatic() - { - return mIsStatic; - } - - public boolean isInterface() - { - return mIsInterface; - } - - public boolean isAbstract() - { - return mIsAbstract; - } - - public PackageInfo containingPackage() - { - return mContainingPackage; - } - - public ClassInfo containingClass() - { - return mContainingClass; - } - - public boolean isOrdinaryClass() - { - return mIsOrdinaryClass; - } - - public boolean isException() - { - return mIsException; - } - - public boolean isError() - { - return mIsError; - } - - public boolean isEnum() - { - return mIsEnum; - } - - public boolean isAnnotation() - { - return mIsAnnotation; - } - - public boolean isFinal() - { - return mIsFinal; - } - - public boolean isIncluded() - { - return mIsIncluded; - } - - public HashSet typeVariables() - { - HashSet result = TypeInfo.typeVariables(mTypeInfo.typeArguments()); - ClassInfo cl = containingClass(); - while (cl != null) { - TypeInfo[] types = cl.asTypeInfo().typeArguments(); - if (types != null) { - TypeInfo.typeVariables(types, result); - } - cl = cl.containingClass(); - } - return result; - } - - private static void gatherHiddenInterfaces(ClassInfo cl, HashSet interfaces) { - for (ClassInfo iface: cl.mRealInterfaces) { - if (iface.checkLevel()) { - interfaces.add(iface); - } else { - gatherHiddenInterfaces(iface, interfaces); - } - } - } - - public ClassInfo[] interfaces() - { - if (mInterfaces == null) { - if (checkLevel()) { - HashSet interfaces = new HashSet(); - ClassInfo superclass = mRealSuperclass; - while (superclass != null && !superclass.checkLevel()) { - gatherHiddenInterfaces(superclass, interfaces); - superclass = superclass.mRealSuperclass; - } - gatherHiddenInterfaces(this, interfaces); - mInterfaces = interfaces.toArray(new ClassInfo[interfaces.size()]); - } else { - // put something here in case someone uses it - mInterfaces = mRealInterfaces; - } - Arrays.sort(mInterfaces, ClassInfo.qualifiedComparator); - } - return mInterfaces; - } - - public ClassInfo[] realInterfaces() - { - return mRealInterfaces; - } - - TypeInfo[] realInterfaceTypes() - { - return mRealInterfaceTypes; - } - - public String name() - { - return mName; - } - - public String[] nameParts() - { - return mNameParts; - } - - public String leafName() - { - return mNameParts[mNameParts.length-1]; - } - - public String qualifiedName() - { - return mQualifiedName; - } - - public String qualifiedTypeName() - { - return mQualifiedTypeName; - } - - public boolean isPrimitive() - { - return mIsPrimitive; - } - - public MethodInfo[] allConstructors() { - return mAllConstructors; - } - - public MethodInfo[] constructors() - { - if (mConstructors == null) { - MethodInfo[] methods = mAllConstructors; - ArrayList ctors = new ArrayList(); - for (int i=0; i 0); - boolean annotationDeprecated = false; - for (AnnotationInstanceInfo annotation : annotations()) { - if (annotation.type().qualifiedName().equals("java.lang.Deprecated")) { - annotationDeprecated = true; - break; - } - } - - if (commentDeprecated != annotationDeprecated) { - Errors.error(Errors.DEPRECATION_MISMATCH, position(), - "Class " + qualifiedName() - + ": @Deprecated annotation and @deprecated comment do not match"); - } - - mIsDeprecated = commentDeprecated | annotationDeprecated; - mDeprecatedKnown = true; - } - return mIsDeprecated; - } - - public TagInfo[] deprecatedTags() - { - // Should we also do the interfaces? - return comment().deprecatedTags(); - } - - public MethodInfo[] methods() - { - if (mMethods == null) { - TreeMap all = new TreeMap(); - - ClassInfo[] ifaces = interfaces(); - for (ClassInfo iface: ifaces) { - if (iface != null) { - MethodInfo[] inhereted = iface.methods(); - for (MethodInfo method: inhereted) { - String key = method.name() + method.signature(); - all.put(key, method); - } - } - } - - ClassInfo superclass = superclass(); - if (superclass != null) { - MethodInfo[] inhereted = superclass.methods(); - for (MethodInfo method: inhereted) { - String key = method.name() + method.signature(); - all.put(key, method); - } - } - - MethodInfo[] methods = selfMethods(); - for (MethodInfo method: methods) { - String key = method.name() + method.signature(); - MethodInfo old = all.put(key, method); - } - - mMethods = all.values().toArray(new MethodInfo[all.size()]); - } - return mMethods; - } - - public MethodInfo[] annotationElements() - { - return mAnnotationElements; - } - - public AnnotationInstanceInfo[] annotations() - { - return mAnnotations; - } - - private static void addFields(ClassInfo cl, TreeMap all) - { - FieldInfo[] fields = cl.fields(); - int N = fields.length; - for (int i=0; i all = new TreeMap(); - - ClassInfo[] interfaces = interfaces(); - N = interfaces.length; - for (int i=0; i fields) { - FieldInfo[] flds = cl.selfFields(); - for (FieldInfo f: flds) { - if (f.checkLevel()) { - fields.put(f.name(), f.cloneForClass(owner)); - } - } - } - - public FieldInfo[] selfFields() - { - if (mSelfFields == null) { - HashMap fields = new HashMap(); - // our hidden parents - if (mRealSuperclass != null && !mRealSuperclass.checkLevel()) { - gatherFields(this, mRealSuperclass, fields); - } - for (ClassInfo iface: mRealInterfaces) { - if (!iface.checkLevel()) { - gatherFields(this, iface, fields); - } - } - // mine - FieldInfo[] selfFields = mAllSelfFields; - for (int i=0; i methods) { - MethodInfo[] meth = cl.selfMethods(); - for (MethodInfo m: meth) { - if (m.checkLevel()) { - methods.put(m.name()+m.signature(), m.cloneForClass(owner)); - } - } - } - - public MethodInfo[] selfMethods() - { - if (mSelfMethods == null) { - HashMap methods = new HashMap(); - // our hidden parents - if (mRealSuperclass != null && !mRealSuperclass.checkLevel()) { - gatherMethods(this, mRealSuperclass, methods); - } - for (ClassInfo iface: mRealInterfaces) { - if (!iface.checkLevel()) { - gatherMethods(this, iface, methods); - } - } - // mine - MethodInfo[] selfMethods = mAllSelfMethods; - for (int i=0; i attrs = new TreeMap(); - - // the ones in the class comment won't have any methods - for (AttrTagInfo tag: comment().attrTags()) { - FieldInfo field = tag.reference(); - if (field != null) { - AttributeInfo attr = attrs.get(field); - if (attr == null) { - attr = new AttributeInfo(this, field); - attrs.put(field, attr); - } - tag.setAttribute(attr); - } - } - - // in the methods - for (MethodInfo m: selfMethods()) { - for (AttrTagInfo tag: m.comment().attrTags()) { - FieldInfo field = tag.reference(); - if (field != null) { - AttributeInfo attr = attrs.get(field); - if (attr == null) { - attr = new AttributeInfo(this, field); - attrs.put(field, attr); - } - tag.setAttribute(attr); - attr.methods.add(m); - } - } - } - - //constructors too - for (MethodInfo m: constructors()) { - for (AttrTagInfo tag: m.comment().attrTags()) { - FieldInfo field = tag.reference(); - if (field != null) { - AttributeInfo attr = attrs.get(field); - if (attr == null) { - attr = new AttributeInfo(this, field); - attrs.put(field, attr); - } - tag.setAttribute(attr); - attr.methods.add(m); - } - } - } - - mSelfAttributes = attrs.values().toArray(new AttributeInfo[attrs.size()]); - Arrays.sort(mSelfAttributes, AttributeInfo.comparator); - } - return mSelfAttributes; - } - - public FieldInfo[] enumConstants() - { - return mEnumConstants; - } - - public ClassInfo superclass() - { - if (!mSuperclassInit) { - if (this.checkLevel()) { - // rearrange our little inheritance hierarchy, because we need to hide classes that - // don't pass checkLevel - ClassInfo superclass = mRealSuperclass; - while (superclass != null && !superclass.checkLevel()) { - superclass = superclass.mRealSuperclass; - } - mSuperclass = superclass; - } else { - mSuperclass = mRealSuperclass; - } - } - return mSuperclass; - } - - public ClassInfo realSuperclass() - { - return mRealSuperclass; - } - - /** always the real superclass, not the collapsed one we get through superclass(), - * also has the type parameter info if it's generic. - */ - public TypeInfo superclassType() - { - return mRealSuperclassType; - } - - public TypeInfo asTypeInfo() - { - return mTypeInfo; - } - - TypeInfo[] interfaceTypes() - { - ClassInfo[] infos = interfaces(); - int len = infos.length; - TypeInfo[] types = new TypeInfo[len]; - for (int i=0; i keywords) - { - if (!checkLevel()) { - return; - } - - String htmlPage = htmlPage(); - String qualifiedName = qualifiedName(); - - keywords.add(new KeywordEntry(name(), htmlPage, - "class in " + containingPackage().name())); - - FieldInfo[] fields = selfFields(); - FieldInfo[] enumConstants = enumConstants(); - MethodInfo[] ctors = constructors(); - MethodInfo[] methods = selfMethods(); - - // enum constants - for (FieldInfo field: enumConstants()) { - if (field.checkLevel()) { - keywords.add(new KeywordEntry(field.name(), - htmlPage + "#" + field.anchor(), - "enum constant in " + qualifiedName)); - } - } - - // constants - for (FieldInfo field: fields) { - if (field.isConstant() && field.checkLevel()) { - keywords.add(new KeywordEntry(field.name(), - htmlPage + "#" + field.anchor(), - "constant in " + qualifiedName)); - } - } - - // fields - for (FieldInfo field: fields) { - if (!field.isConstant() && field.checkLevel()) { - keywords.add(new KeywordEntry(field.name(), - htmlPage + "#" + field.anchor(), - "field in " + qualifiedName)); - } - } - - // public constructors - for (MethodInfo m: ctors) { - if (m.isPublic() && m.checkLevel()) { - keywords.add(new KeywordEntry(m.name() + m.prettySignature(), - htmlPage + "#" + m.anchor(), - "constructor in " + qualifiedName)); - } - } - - // protected constructors - if (DroidDoc.checkLevel(DroidDoc.SHOW_PROTECTED)) { - for (MethodInfo m: ctors) { - if (m.isProtected() && m.checkLevel()) { - keywords.add(new KeywordEntry(m.name() + m.prettySignature(), - htmlPage + "#" + m.anchor(), - "constructor in " + qualifiedName)); - } - } - } - - // package private constructors - if (DroidDoc.checkLevel(DroidDoc.SHOW_PACKAGE)) { - for (MethodInfo m: ctors) { - if (m.isPackagePrivate() && m.checkLevel()) { - keywords.add(new KeywordEntry(m.name() + m.prettySignature(), - htmlPage + "#" + m.anchor(), - "constructor in " + qualifiedName)); - } - } - } - - // private constructors - if (DroidDoc.checkLevel(DroidDoc.SHOW_PRIVATE)) { - for (MethodInfo m: ctors) { - if (m.isPrivate() && m.checkLevel()) { - keywords.add(new KeywordEntry(m.name() + m.prettySignature(), - htmlPage + "#" + m.anchor(), - "constructor in " + qualifiedName)); - } - } - } - - // public methods - for (MethodInfo m: methods) { - if (m.isPublic() && m.checkLevel()) { - keywords.add(new KeywordEntry(m.name() + m.prettySignature(), - htmlPage + "#" + m.anchor(), - "method in " + qualifiedName)); - } - } - - // protected methods - if (DroidDoc.checkLevel(DroidDoc.SHOW_PROTECTED)) { - for (MethodInfo m: methods) { - if (m.isProtected() && m.checkLevel()) { - keywords.add(new KeywordEntry(m.name() + m.prettySignature(), - htmlPage + "#" + m.anchor(), - "method in " + qualifiedName)); - } - } - } - - // package private methods - if (DroidDoc.checkLevel(DroidDoc.SHOW_PACKAGE)) { - for (MethodInfo m: methods) { - if (m.isPackagePrivate() && m.checkLevel()) { - keywords.add(new KeywordEntry(m.name() + m.prettySignature(), - htmlPage + "#" + m.anchor(), - "method in " + qualifiedName)); - } - } - } - - // private methods - if (DroidDoc.checkLevel(DroidDoc.SHOW_PRIVATE)) { - for (MethodInfo m: methods) { - if (m.isPrivate() && m.checkLevel()) { - keywords.add(new KeywordEntry(m.name() + m.prettySignature(), - htmlPage + "#" + m.anchor(), - "method in " + qualifiedName)); - } - } - } - } - - public void makeLink(HDF data, String base) - { - data.setValue(base + ".label", this.name()); - if (!this.isPrimitive() && this.isIncluded() && this.checkLevel()) { - data.setValue(base + ".link", this.htmlPage()); - } - } - - public static void makeLinkListHDF(HDF data, String base, ClassInfo[] classes) { - final int N = classes.length; - for (int i=0; i superClasses = new Vector(); - superClasses.add(this); - ClassInfo supr = superclass(); - while (supr != null) { - superClasses.add(supr); - supr = supr.superclass(); - } - n = superClasses.size(); - for (i=0; i direct = new TreeMap(); - TreeMap indirect = new TreeMap(); - ClassInfo[] all = Converter.rootClasses(); - for (ClassInfo cl: all) { - if (cl.superclass() != null && cl.superclass().equals(this)) { - direct.put(cl.name(), cl); - } - else if (cl.isDerivedFrom(this)) { - indirect.put(cl.name(), cl); - } - } - // direct - i = 0; - for (ClassInfo cl: direct.values()) { - if (cl.checkLevel()) { - cl.makeShortDescrHDF(data, "class.subclasses.direct." + i); - } - i++; - } - // indirect - i = 0; - for (ClassInfo cl: indirect.values()) { - if (cl.checkLevel()) { - cl.makeShortDescrHDF(data, "class.subclasses.indirect." + i); - } - i++; - } - - // nested classes - i=0; - for (ClassInfo inner: inners) { - if (inner.checkLevel()) { - inner.makeShortDescrHDF(data, "class.inners." + i); - } - i++; - } - - // enum constants - i=0; - for (FieldInfo field: enumConstants) { - if (field.isConstant()) { - field.makeHDF(data, "class.enumConstants." + i); - i++; - } - } - - // constants - i=0; - for (FieldInfo field: fields) { - if (field.isConstant()) { - field.makeHDF(data, "class.constants." + i); - i++; - } - } - - // fields - i=0; - for (FieldInfo field: fields) { - if (!field.isConstant()) { - field.makeHDF(data, "class.fields." + i); - i++; - } - } - - // public constructors - i=0; - for (MethodInfo ctor: ctors) { - if (ctor.isPublic()) { - ctor.makeHDF(data, "class.ctors.public." + i); - i++; - } - } - - // protected constructors - if (DroidDoc.checkLevel(DroidDoc.SHOW_PROTECTED)) { - i=0; - for (MethodInfo ctor: ctors) { - if (ctor.isProtected()) { - ctor.makeHDF(data, "class.ctors.protected." + i); - i++; - } - } - } - - // package private constructors - if (DroidDoc.checkLevel(DroidDoc.SHOW_PACKAGE)) { - i=0; - for (MethodInfo ctor: ctors) { - if (ctor.isPackagePrivate()) { - ctor.makeHDF(data, "class.ctors.package." + i); - i++; - } - } - } - - // private constructors - if (DroidDoc.checkLevel(DroidDoc.SHOW_PRIVATE)) { - i=0; - for (MethodInfo ctor: ctors) { - if (ctor.isPrivate()) { - ctor.makeHDF(data, "class.ctors.private." + i); - i++; - } - } - } - - // public methods - i=0; - for (MethodInfo method: methods) { - if (method.isPublic()) { - method.makeHDF(data, "class.methods.public." + i); - i++; - } - } - - // protected methods - if (DroidDoc.checkLevel(DroidDoc.SHOW_PROTECTED)) { - i=0; - for (MethodInfo method: methods) { - if (method.isProtected()) { - method.makeHDF(data, "class.methods.protected." + i); - i++; - } - } - } - - // package private methods - if (DroidDoc.checkLevel(DroidDoc.SHOW_PACKAGE)) { - i=0; - for (MethodInfo method: methods) { - if (method.isPackagePrivate()) { - method.makeHDF(data, "class.methods.package." + i); - i++; - } - } - } - - // private methods - if (DroidDoc.checkLevel(DroidDoc.SHOW_PRIVATE)) { - i=0; - for (MethodInfo method: methods) { - if (method.isPrivate()) { - method.makeHDF(data, "class.methods.private." + i); - i++; - } - } - } - - // xml attributes - i=0; - for (AttributeInfo attr: selfAttributes) { - if (attr.checkLevel()) { - attr.makeHDF(data, "class.attrs." + i); - i++; - } - } - - // inherited methods - Set interfaces = new TreeSet(); - addInterfaces(interfaces(), interfaces); - ClassInfo cl = superclass(); - i=0; - while (cl != null) { - addInterfaces(cl.interfaces(), interfaces); - makeInheritedHDF(data, i, cl); - cl = cl.superclass(); - i++; - } - for (ClassInfo iface: interfaces) { - makeInheritedHDF(data, i, iface); - i++; - } - } - - private static void addInterfaces(ClassInfo[] ifaces, Set out) - { - for (ClassInfo cl: ifaces) { - out.add(cl); - addInterfaces(cl.interfaces(), out); - } - } - - private static void makeInheritedHDF(HDF data, int index, ClassInfo cl) - { - int i; - - String base = "class.inherited." + index; - data.setValue(base + ".qualified", cl.qualifiedName()); - if (cl.checkLevel()) { - data.setValue(base + ".link", cl.htmlPage()); - } - String kind = cl.kind(); - if (kind != null) { - data.setValue(base + ".kind", kind); - } - - if (cl.mIsIncluded) { - data.setValue(base + ".included", "true"); - } - - // xml attributes - i=0; - for (AttributeInfo attr: cl.selfAttributes()) { - attr.makeHDF(data, base + ".attrs." + i); - i++; - } - - // methods - i=0; - for (MethodInfo method: cl.selfMethods()) { - method.makeHDF(data, base + ".methods." + i); - i++; - } - - // fields - i=0; - for (FieldInfo field: cl.selfFields()) { - if (!field.isConstant()) { - field.makeHDF(data, base + ".fields." + i); - i++; - } - } - - // constants - i=0; - for (FieldInfo field: cl.selfFields()) { - if (field.isConstant()) { - field.makeHDF(data, base + ".constants." + i); - i++; - } - } - } - - @Override - public boolean isHidden() - { - int val = mHidden; - if (val >= 0) { - return val != 0; - } else { - boolean v = isHiddenImpl(); - mHidden = v ? 1 : 0; - return v; - } - } - - public boolean isHiddenImpl() - { - ClassInfo cl = this; - while (cl != null) { - PackageInfo pkg = cl.containingPackage(); - if (pkg != null && pkg.isHidden()) { - return true; - } - if (cl.comment().isHidden()) { - return true; - } - cl = cl.containingClass(); - } - return false; - } - - private MethodInfo matchMethod(MethodInfo[] methods, String name, - String[] params, String[] dimensions) - { - int len = methods.length; - for (int i=0; i hdfFiles = new ArrayList(); - - private static ArrayList mTemplateDirs = new ArrayList(); - private static boolean mTemplateDirSet = false; - - public static String outputDir = "docs"; - public static String htmlDir = null; - public static String toroot = null; - - public static void addTemplateDir(String dir) - { - mTemplateDirSet = true; - mTemplateDirs.add(dir); - - File hdfFile = new File(dir, "data.hdf"); - if (hdfFile.canRead()) { - hdfFiles.add(hdfFile.getPath()); - } - } - - private static int countSlashes(String s) - { - final int N = s.length(); - int slashcount = 0; - for (int i=0; i 0) { - toroot = ""; - for (int i=0; i maxsize ? maxsize : (int)sizel; - byte[] buf = new byte[size]; - while (true) { - try { - size = in.read(buf); - } - catch (IOException e) { - System.err.println(from.getAbsolutePath() - + ": error reading file"); - break; - } - if (size > 0) { - try { - out.write(buf, 0, size); - } - catch (IOException e) { - System.err.println(from.getAbsolutePath() - + ": error writing file"); - } - } else { - break; - } - } - try { - in.close(); - } - catch (IOException e) { - } - try { - out.close(); - } - catch (IOException e) { - } - } - - /** Takes a string that ends w/ .html and changes the .html to htmlExtension */ - public static String outputFilename(String htmlFile) { - if (!DroidDoc.htmlExtension.equals(".html") && htmlFile.endsWith(".html")) { - return htmlFile.substring(0, htmlFile.length()-5) + DroidDoc.htmlExtension; - } else { - return htmlFile; - } - } - -} diff --git a/tools/droiddoc/src/Comment.java b/tools/droiddoc/src/Comment.java deleted file mode 100644 index 553cdf20d..000000000 --- a/tools/droiddoc/src/Comment.java +++ /dev/null @@ -1,395 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.util.regex.Pattern; -import java.util.regex.Matcher; -import java.util.ArrayList; - -public class Comment -{ - static final Pattern LEADING_WHITESPACE = Pattern.compile( - "^[ \t\n\r]*(.*)$", - Pattern.DOTALL); - - static final Pattern TAG_BEGIN = Pattern.compile( - "[\r\n][\r\n \t]*@", - Pattern.DOTALL); - - static final Pattern TAG = Pattern.compile( - "(@[^ \t\r\n]+)[ \t\r\n]+(.*)", - Pattern.DOTALL); - - static final Pattern INLINE_TAG = Pattern.compile( - "(.*?)\\{(@[^ \t\r\n\\}]+)[ \t\r\n]*(.*?)\\}", - Pattern.DOTALL); - - static final Pattern FIRST_SENTENCE = Pattern.compile( - "((.*?)\\.)[ \t\r\n\\<](.*)", - Pattern.DOTALL); - - private static final String[] KNOWN_TAGS = new String[] { - "@author", - "@since", - "@version", - "@deprecated", - "@undeprecate", - "@docRoot", - "@sdkCurrent", - "@inheritDoc", - "@more", - "@code", - "@samplecode", - "@sample", - "@include", - "@serial", - "@com.intel.drl.spec_ref", - "@ar.org.fitc.spec_ref", - }; - - public Comment(String text, ContainerInfo base, SourcePositionInfo sp) - { - mText = text; - mBase = base; - // sp now points to the end of the text, not the beginning! - mPosition = SourcePositionInfo.findBeginning(sp, text); - } - - private void parseRegex(String text) - { - Matcher m; - - m = LEADING_WHITESPACE.matcher(text); - m.matches(); - text = m.group(1); - - m = TAG_BEGIN.matcher(text); - - int start = 0; - int end = 0; - while (m.find()) { - end = m.start(); - - tag(text, start, end); - - start = m.end()-1; // -1 is the @ - } - end = text.length(); - tag(text, start, end); - } - - private void tag(String text, int start, int end) - { - SourcePositionInfo pos = SourcePositionInfo.add(mPosition, mText, start); - - if (start >= 0 && end > 0 && (end-start) > 0) { - text = text.substring(start, end); - - Matcher m = TAG.matcher(text); - if (m.matches()) { - // out of line tag - tag(m.group(1), m.group(2), false, pos); - } else { - // look for inline tags - m = INLINE_TAG.matcher(text); - start = 0; - while (m.find()) { - String str = m.group(1); - String tagname = m.group(2); - String tagvalue = m.group(3); - tag(null, m.group(1), true, pos); - tag(tagname, tagvalue, true, pos); - start = m.end(); - } - int len = text.length(); - if (start != len) { - tag(null, text.substring(start), true, pos); - } - } - } - } - - private void tag(String name, String text, boolean isInline, SourcePositionInfo pos) - { - /* - String s = isInline ? "inline" : "outofline"; - System.out.println("---> " + s - + " name=[" + name + "] text=[" + text + "]"); - */ - if (name == null) { - mInlineTagsList.add(new TextTagInfo("Text", "Text", text, pos)); - } - else if (name.equals("@param")) { - mParamTagsList.add(new ParamTagInfo("@param", "@param", text, mBase, pos)); - } - else if (name.equals("@see")) { - mSeeTagsList.add(new SeeTagInfo("@see", "@see", text, mBase, pos)); - } - else if (name.equals("@link") || name.equals("@linkplain")) { - mInlineTagsList.add(new SeeTagInfo(name, "@see", text, mBase, pos)); - } - else if (name.equals("@throws") || name.equals("@exception")) { - mThrowsTagsList.add(new ThrowsTagInfo("@throws", "@throws", text, mBase, pos)); - } - else if (name.equals("@return")) { - mReturnTagsList.add(new ParsedTagInfo("@return", "@return", text, mBase, pos)); - } - else if (name.equals("@deprecated")) { - if (text.length() == 0) { - Errors.error(Errors.MISSING_COMMENT, pos, - "@deprecated tag with no explanatory comment"); - text = "No replacement."; - } - mDeprecatedTagsList.add(new ParsedTagInfo("@deprecated", "@deprecated", text, mBase, pos)); - } - else if (name.equals("@literal")) { - mInlineTagsList.add(new LiteralTagInfo(name, name, text, pos)); - } - else if (name.equals("@hide") || name.equals("@pending") || name.equals("@doconly")) { - // nothing - } - else if (name.equals("@attr")) { - AttrTagInfo tag = new AttrTagInfo("@attr", "@attr", text, mBase, pos); - mAttrTagsList.add(tag); - Comment c = tag.description(); - if (c != null) { - for (TagInfo t: c.tags()) { - mInlineTagsList.add(t); - } - } - } - else if (name.equals("@undeprecate")) { - mUndeprecateTagsList.add(new TextTagInfo("@undeprecate", "@undeprecate", text, pos)); - } - else if (name.equals("@include") || name.equals("@sample")) { - mInlineTagsList.add(new SampleTagInfo(name, "@include", text, mBase, pos)); - } - else { - boolean known = false; - for (String s: KNOWN_TAGS) { - if (s.equals(name)) { - known = true; - break; - } - } - if (!known) { - Errors.error(Errors.UNKNOWN_TAG, pos == null ? null : new SourcePositionInfo(pos), - "Unknown tag: " + name); - } - TagInfo t = new TextTagInfo(name, name, text, pos); - if (isInline) { - mInlineTagsList.add(t); - } else { - mTagsList.add(t); - } - } - } - - private void parseBriefTags() - { - int N = mInlineTagsList.size(); - - // look for "@more" tag, which means that we might go past the first sentence. - int more = -1; - for (int i=0; i= 0) { - for (int i=0; i results = new ArrayList(); - int N = mInlineTagsList.size(); - for (int i=0; i= 0) { - return mHidden != 0; - } else { - if (DroidDoc.checkLevel(DroidDoc.SHOW_HIDDEN)) { - mHidden = 0; - return false; - } - boolean b = mText.indexOf("@hide") >= 0 || mText.indexOf("@pending") >= 0; - mHidden = b ? 1 : 0; - return b; - } - } - - public boolean isDocOnly() { - if (mDocOnly >= 0) { - return mDocOnly != 0; - } else { - boolean b = (mText != null) && (mText.indexOf("@doconly") >= 0); - mDocOnly = b ? 1 : 0; - return b; - } - } - - private void init() - { - if (!mInitialized) { - initImpl(); - } - } - - private void initImpl() - { - isHidden(); - isDocOnly(); - parseRegex(mText); - parseBriefTags(); - mText = null; - mInitialized = true; - - mInlineTags = mInlineTagsList.toArray(new TagInfo[mInlineTagsList.size()]); - mParamTags = mParamTagsList.toArray(new ParamTagInfo[mParamTagsList.size()]); - mSeeTags = mSeeTagsList.toArray(new SeeTagInfo[mSeeTagsList.size()]); - mThrowsTags = mThrowsTagsList.toArray(new ThrowsTagInfo[mThrowsTagsList.size()]); - mReturnTags = ParsedTagInfo.joinTags(mReturnTagsList.toArray( - new ParsedTagInfo[mReturnTagsList.size()])); - mDeprecatedTags = ParsedTagInfo.joinTags(mDeprecatedTagsList.toArray( - new ParsedTagInfo[mDeprecatedTagsList.size()])); - mUndeprecateTags = mUndeprecateTagsList.toArray(new TagInfo[mUndeprecateTagsList.size()]); - mAttrTags = mAttrTagsList.toArray(new AttrTagInfo[mAttrTagsList.size()]); - mBriefTags = mBriefTagsList.toArray(new TagInfo[mBriefTagsList.size()]); - - mParamTagsList = null; - mSeeTagsList = null; - mThrowsTagsList = null; - mReturnTagsList = null; - mDeprecatedTagsList = null; - mUndeprecateTagsList = null; - mAttrTagsList = null; - mBriefTagsList = null; - } - - boolean mInitialized; - int mHidden = -1; - int mDocOnly = -1; - String mText; - ContainerInfo mBase; - SourcePositionInfo mPosition; - int mLine = 1; - - TagInfo[] mInlineTags; - TagInfo[] mTags; - ParamTagInfo[] mParamTags; - SeeTagInfo[] mSeeTags; - ThrowsTagInfo[] mThrowsTags; - TagInfo[] mBriefTags; - TagInfo[] mReturnTags; - TagInfo[] mDeprecatedTags; - TagInfo[] mUndeprecateTags; - AttrTagInfo[] mAttrTags; - - ArrayList mInlineTagsList = new ArrayList(); - ArrayList mTagsList = new ArrayList(); - ArrayList mParamTagsList = new ArrayList(); - ArrayList mSeeTagsList = new ArrayList(); - ArrayList mThrowsTagsList = new ArrayList(); - ArrayList mBriefTagsList = new ArrayList(); - ArrayList mReturnTagsList = new ArrayList(); - ArrayList mDeprecatedTagsList = new ArrayList(); - ArrayList mUndeprecateTagsList = new ArrayList(); - ArrayList mAttrTagsList = new ArrayList(); - - -} diff --git a/tools/droiddoc/src/ContainerInfo.java b/tools/droiddoc/src/ContainerInfo.java deleted file mode 100644 index b8a3e100c..000000000 --- a/tools/droiddoc/src/ContainerInfo.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -public interface ContainerInfo -{ - public String qualifiedName(); - public boolean checkLevel(); -} diff --git a/tools/droiddoc/src/Converter.java b/tools/droiddoc/src/Converter.java deleted file mode 100644 index ee911f429..000000000 --- a/tools/droiddoc/src/Converter.java +++ /dev/null @@ -1,755 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import com.sun.javadoc.*; -import com.sun.tools.doclets.*; -import org.clearsilver.HDF; -import org.clearsilver.CS; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; - -public class Converter -{ - private static RootDoc root; - - public static void makeInfo(RootDoc r) - { - root = r; - - int N, i; - - // create the objects - ClassDoc[] classDocs = r.classes(); - N = classDocs.length; - for (i=0; i classesNeedingInit2 = new ArrayList(); - // fill in the fields that reference other classes - while (mClassesNeedingInit.size() > 0) { - i = mClassesNeedingInit.size()-1; - ClassNeedingInit clni = mClassesNeedingInit.get(i); - mClassesNeedingInit.remove(i); - - initClass(clni.c, clni.cl); - classesNeedingInit2.add(clni.cl); - } - mClassesNeedingInit = null; - for (ClassInfo cl: classesNeedingInit2) { - cl.init2(); - } - - finishAnnotationValueInit(); - - // fill in the "root" stuff - mRootClasses = Converter.convertClasses(r.classes()); - } - - private static ClassInfo[] mRootClasses; - public static ClassInfo[] rootClasses() - { - return mRootClasses; - } - - public static ClassInfo[] allClasses() { - return (ClassInfo[])mClasses.all(); - } - - private static void initClass(ClassDoc c, ClassInfo cl) - { - MethodDoc[] annotationElements; - if (c instanceof AnnotationTypeDoc) { - annotationElements = ((AnnotationTypeDoc)c).elements(); - } else { - annotationElements = new MethodDoc[0]; - } - cl.init(Converter.obtainType(c), - Converter.convertClasses(c.interfaces()), - Converter.convertTypes(c.interfaceTypes()), - Converter.convertClasses(c.innerClasses()), - Converter.convertMethods(c.constructors(false)), - Converter.convertMethods(c.methods(false)), - Converter.convertMethods(annotationElements), - Converter.convertFields(c.fields(false)), - Converter.convertFields(c.enumConstants()), - Converter.obtainPackage(c.containingPackage()), - Converter.obtainClass(c.containingClass()), - Converter.obtainClass(c.superclass()), - Converter.obtainType(c.superclassType()), - Converter.convertAnnotationInstances(c.annotations()) - ); - cl.setHiddenMethods(Converter.getHiddenMethods(c.methods(false))); - cl.setNonWrittenConstructors(Converter.convertNonWrittenConstructors(c.constructors(false))); - cl.init3(Converter.convertTypes(c.typeParameters()), Converter.convertClasses(c.innerClasses(false))); - } - - public static ClassInfo obtainClass(String className) - { - return Converter.obtainClass(root.classNamed(className)); - } - - public static PackageInfo obtainPackage(String packageName) - { - return Converter.obtainPackage(root.packageNamed(packageName)); - } - - private static TagInfo convertTag(Tag tag) - { - return new TextTagInfo(tag.name(), tag.kind(), tag.text(), - Converter.convertSourcePosition(tag.position())); - } - - private static ThrowsTagInfo convertThrowsTag(ThrowsTag tag, - ContainerInfo base) - { - return new ThrowsTagInfo(tag.name(), tag.text(), tag.kind(), - Converter.obtainClass(tag.exception()), - tag.exceptionComment(), base, - Converter.convertSourcePosition(tag.position())); - } - - private static ParamTagInfo convertParamTag(ParamTag tag, - ContainerInfo base) - { - return new ParamTagInfo(tag.name(), tag.kind(), tag.text(), - tag.isTypeParameter(), tag.parameterComment(), - tag.parameterName(), - base, - Converter.convertSourcePosition(tag.position())); - } - - private static SeeTagInfo convertSeeTag(SeeTag tag, ContainerInfo base) - { - return new SeeTagInfo(tag.name(), tag.kind(), tag.text(), base, - Converter.convertSourcePosition(tag.position())); - } - - private static SourcePositionInfo convertSourcePosition(SourcePosition sp) - { - if (sp == null) { - return null; - } - return new SourcePositionInfo(sp.file().toString(), sp.line(), - sp.column()); - } - - public static TagInfo[] convertTags(Tag[] tags, ContainerInfo base) - { - int len = tags.length; - TagInfo[] out = new TagInfo[len]; - for (int i=0; i mClassesNeedingInit - = new ArrayList(); - - static ClassInfo obtainClass(ClassDoc o) - { - return (ClassInfo)mClasses.obtain(o); - } - private static Cache mClasses = new Cache() - { - @Override - protected Object make(Object o) - { - ClassDoc c = (ClassDoc)o; - ClassInfo cl = new ClassInfo( - c, - c.getRawCommentText(), - Converter.convertSourcePosition(c.position()), - c.isPublic(), - c.isProtected(), - c.isPackagePrivate(), - c.isPrivate(), - c.isStatic(), - c.isInterface(), - c.isAbstract(), - c.isOrdinaryClass(), - c.isException(), - c.isError(), - c.isEnum(), - (c instanceof AnnotationTypeDoc), - c.isFinal(), - c.isIncluded(), - c.name(), - c.qualifiedName(), - c.qualifiedTypeName(), - c.isPrimitive()); - if (mClassesNeedingInit != null) { - mClassesNeedingInit.add(new ClassNeedingInit(c, cl)); - } - return cl; - } - @Override - protected void made(Object o, Object r) - { - if (mClassesNeedingInit == null) { - initClass((ClassDoc)o, (ClassInfo)r); - ((ClassInfo)r).init2(); - } - } - @Override - ClassInfo[] all() - { - return (ClassInfo[])mCache.values().toArray(new ClassInfo[mCache.size()]); - } - }; - - private static MethodInfo[] getHiddenMethods(MethodDoc[] methods){ - if (methods == null) return null; - ArrayList out = new ArrayList(); - int N = methods.length; - for (int i=0; i out = new ArrayList(); - int N = methods.length; - for (int i=0; i out = new ArrayList(); - int N = methods.length; - for (int i=0; i out = new ArrayList(); - int N = methods.length; - for (int i=0; i out = new ArrayList(); - int N = fields.length; - for (int i=0; i mCache = new HashMap(); - protected abstract Object make(Object o); - protected void made(Object o, Object r) - { - } - protected Object keyFor(Object o) { return o; } - Object[] all() { return null; } - } - - // annotation values - private static HashMap mAnnotationValues = new HashMap(); - private static HashSet mAnnotationValuesNeedingInit = new HashSet(); - - private static AnnotationValueInfo obtainAnnotationValue(AnnotationValue o, MethodInfo element) - { - if (o == null) { - return null; - } - AnnotationValueInfo v = mAnnotationValues.get(o); - if (v != null) return v; - v = new AnnotationValueInfo(element); - mAnnotationValues.put(o, v); - if (mAnnotationValuesNeedingInit != null) { - mAnnotationValuesNeedingInit.add(o); - } else { - initAnnotationValue(o, v); - } - return v; - } - - private static void initAnnotationValue(AnnotationValue o, AnnotationValueInfo v) { - Object orig = o.value(); - Object converted; - if (orig instanceof Type) { - // class literal - converted = Converter.obtainType((Type)orig); - } - else if (orig instanceof FieldDoc) { - // enum constant - converted = Converter.obtainField((FieldDoc)orig); - } - else if (orig instanceof AnnotationDesc) { - // annotation instance - converted = Converter.obtainAnnotationInstance((AnnotationDesc)orig); - } - else if (orig instanceof AnnotationValue[]) { - AnnotationValue[] old = (AnnotationValue[])orig; - AnnotationValueInfo[] array = new AnnotationValueInfo[old.length]; - for (int i=0; i 0) { - HashSet set = mAnnotationValuesNeedingInit; - mAnnotationValuesNeedingInit = new HashSet(); - for (AnnotationValue o: set) { - AnnotationValueInfo v = mAnnotationValues.get(o); - initAnnotationValue(o, v); - } - depth++; - } - mAnnotationValuesNeedingInit = null; - } -} diff --git a/tools/droiddoc/src/DocFile.java b/tools/droiddoc/src/DocFile.java deleted file mode 100644 index cc7a8cfb8..000000000 --- a/tools/droiddoc/src/DocFile.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import org.clearsilver.HDF; -import org.clearsilver.CS; -import java.util.*; -import java.io.*; -import java.util.regex.Pattern; -import java.util.regex.Matcher; - - -public class DocFile -{ - private static final Pattern LINE = Pattern.compile("(.*)[\r]?\n", - Pattern.MULTILINE); - private static final Pattern PROP = Pattern.compile("([^=]+)=(.*)"); - - public static String readFile(String filename) - { - try { - File f = new File(filename); - int length = (int)f.length(); - FileInputStream is = new FileInputStream(f); - InputStreamReader reader = new InputStreamReader(is, "UTF-8"); - char[] buf = new char[length]; - int index = 0; - int amt; - while (true) { - amt = reader.read(buf, index, length-index); - - if (amt < 1) { - break; - } - - index += amt; - } - return new String(buf, 0, index); - } - catch (IOException e) { - return null; - } - } - - public static void writePage(String docfile, String relative, - String outfile) - { - HDF hdf = DroidDoc.makeHDF(); - - /* - System.out.println("docfile='" + docfile - + "' relative='" + relative + "'" - + "' outfile='" + outfile + "'"); - */ - - String filedata = readFile(docfile); - - // The document is properties up until the line "@jd:body". - // Any blank lines are ignored. - int start = -1; - int lineno = 1; - Matcher lines = LINE.matcher(filedata); - String line = null; - while (lines.find()) { - line = lines.group(1); - if (line.length() > 0) { - if (line.equals("@jd:body")) { - start = lines.end(); - break; - } - Matcher prop = PROP.matcher(line); - if (prop.matches()) { - String key = prop.group(1); - String value = prop.group(2); - hdf.setValue(key, value); - } else { - break; - } - } - lineno++; - } - if (start < 0) { - System.err.println(docfile + ":" + lineno + ": error parsing docfile"); - if (line != null) { - System.err.println(docfile + ":" + lineno + ":" + line); - } - System.exit(1); - } - - // if they asked to only be for a certain template, maybe skip it - String fromTemplate = hdf.getValue("template.which", ""); - String fromPage = hdf.getValue("page.onlyfortemplate", ""); - if (!"".equals(fromPage) && !fromTemplate.equals(fromPage)) { - return; - } - - // and the actual text after that - String commentText = filedata.substring(start); - - Comment comment = new Comment(commentText, null, - new SourcePositionInfo(docfile, lineno, 1)); - TagInfo[] tags = comment.tags(); - - TagInfo.makeHDF(hdf, "root.descr", tags); - - hdf.setValue("commentText", commentText); - - // write the page using the appropriate root template, based on the - // whichdoc value supplied by build - String fromWhichmodule = hdf.getValue("android.whichmodule", ""); - if (fromWhichmodule.equals("online-pdk")) { - //leaving this in just for temporary compatibility with pdk doc - hdf.setValue("online-pdk", "true"); - // add any conditional login for root template here (such as - // for custom left nav based on tab etc. - ClearPage.write(hdf, "docpage.cs", outfile); - } else { - if (outfile.indexOf("sdk/") != -1) { - hdf.setValue("sdk", "true"); - if ((outfile.indexOf("index.html") != -1) || (outfile.indexOf("features.html") != -1)) { - ClearPage.write(hdf, "sdkpage.cs", outfile); - } else { - ClearPage.write(hdf, "docpage.cs", outfile); - } - } else if (outfile.indexOf("guide/") != -1) { - hdf.setValue("guide", "true"); - ClearPage.write(hdf, "docpage.cs", outfile); - } else if (outfile.indexOf("resources/") != -1) { - hdf.setValue("resources", "true"); - ClearPage.write(hdf, "docpage.cs", outfile); - } else { - ClearPage.write(hdf, "nosidenavpage.cs", outfile); - } - } - } //writePage -} diff --git a/tools/droiddoc/src/DocInfo.java b/tools/droiddoc/src/DocInfo.java deleted file mode 100644 index 3abb36741..000000000 --- a/tools/droiddoc/src/DocInfo.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -public abstract class DocInfo -{ - public DocInfo(String rawCommentText, SourcePositionInfo sp) - { - mRawCommentText = rawCommentText; - mPosition = sp; - } - - public boolean isHidden() - { - return comment().isHidden(); - } - - public boolean isDocOnly() { - return comment().isDocOnly(); - } - - public String getRawCommentText() - { - return mRawCommentText; - } - - public Comment comment() - { - if (mComment == null) { - mComment = new Comment(mRawCommentText, parent(), mPosition); - } - return mComment; - } - - public SourcePositionInfo position() - { - return mPosition; - } - - public abstract ContainerInfo parent(); - - public void setSince(String since) { - mSince = since; - } - - public String getSince() { - return mSince; - } - - private String mRawCommentText; - Comment mComment; - SourcePositionInfo mPosition; - private String mSince; -} - diff --git a/tools/droiddoc/src/DroidDoc.java b/tools/droiddoc/src/DroidDoc.java deleted file mode 100644 index 4e9d6b162..000000000 --- a/tools/droiddoc/src/DroidDoc.java +++ /dev/null @@ -1,1385 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import com.sun.javadoc.*; - -import org.clearsilver.HDF; - -import java.util.*; -import java.io.*; -import java.lang.reflect.Proxy; -import java.lang.reflect.Array; -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -public class DroidDoc -{ - private static final String SDK_CONSTANT_ANNOTATION = "android.annotation.SdkConstant"; - private static final String SDK_CONSTANT_TYPE_ACTIVITY_ACTION = "android.annotation.SdkConstant.SdkConstantType.ACTIVITY_INTENT_ACTION"; - private static final String SDK_CONSTANT_TYPE_BROADCAST_ACTION = "android.annotation.SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION"; - private static final String SDK_CONSTANT_TYPE_SERVICE_ACTION = "android.annotation.SdkConstant.SdkConstantType.SERVICE_INTENT_ACTION"; - private static final String SDK_CONSTANT_TYPE_CATEGORY = "android.annotation.SdkConstant.SdkConstantType.INTENT_CATEGORY"; - private static final String SDK_CONSTANT_TYPE_FEATURE = "android.annotation.SdkConstant.SdkConstantType.FEATURE"; - private static final String SDK_WIDGET_ANNOTATION = "android.annotation.Widget"; - private static final String SDK_LAYOUT_ANNOTATION = "android.annotation.Layout"; - - private static final int TYPE_NONE = 0; - private static final int TYPE_WIDGET = 1; - private static final int TYPE_LAYOUT = 2; - private static final int TYPE_LAYOUT_PARAM = 3; - - public static final int SHOW_PUBLIC = 0x00000001; - public static final int SHOW_PROTECTED = 0x00000003; - public static final int SHOW_PACKAGE = 0x00000007; - public static final int SHOW_PRIVATE = 0x0000000f; - public static final int SHOW_HIDDEN = 0x0000001f; - - public static int showLevel = SHOW_PROTECTED; - - public static final String javadocDir = "reference/"; - public static String htmlExtension; - - public static RootDoc root; - public static ArrayList mHDFData = new ArrayList(); - public static Map escapeChars = new HashMap(); - public static String title = ""; - public static SinceTagger sinceTagger = new SinceTagger(); - - public static boolean checkLevel(int level) - { - return (showLevel & level) == level; - } - - public static boolean checkLevel(boolean pub, boolean prot, boolean pkgp, - boolean priv, boolean hidden) - { - int level = 0; - if (hidden && !checkLevel(SHOW_HIDDEN)) { - return false; - } - if (pub && checkLevel(SHOW_PUBLIC)) { - return true; - } - if (prot && checkLevel(SHOW_PROTECTED)) { - return true; - } - if (pkgp && checkLevel(SHOW_PACKAGE)) { - return true; - } - if (priv && checkLevel(SHOW_PRIVATE)) { - return true; - } - return false; - } - - public static boolean start(RootDoc r) - { - String keepListFile = null; - String proofreadFile = null; - String todoFile = null; - String sdkValuePath = null; - ArrayList sampleCodes = new ArrayList(); - String stubsDir = null; - //Create the dependency graph for the stubs directory - boolean apiXML = false; - boolean noDocs = false; - boolean offlineMode = false; - String apiFile = null; - String debugStubsFile = ""; - HashSet stubPackages = null; - - root = r; - - String[][] options = r.options(); - for (String[] a: options) { - if (a[0].equals("-d")) { - ClearPage.outputDir = a[1]; - } - else if (a[0].equals("-templatedir")) { - ClearPage.addTemplateDir(a[1]); - } - else if (a[0].equals("-hdf")) { - mHDFData.add(new String[] {a[1], a[2]}); - } - else if (a[0].equals("-toroot")) { - ClearPage.toroot = a[1]; - } - else if (a[0].equals("-samplecode")) { - sampleCodes.add(new SampleCode(a[1], a[2], a[3])); - } - else if (a[0].equals("-htmldir")) { - ClearPage.htmlDir = a[1]; - } - else if (a[0].equals("-title")) { - DroidDoc.title = a[1]; - } - else if (a[0].equals("-werror")) { - Errors.setWarningsAreErrors(true); - } - else if (a[0].equals("-error") || a[0].equals("-warning") - || a[0].equals("-hide")) { - try { - int level = -1; - if (a[0].equals("-error")) { - level = Errors.ERROR; - } - else if (a[0].equals("-warning")) { - level = Errors.WARNING; - } - else if (a[0].equals("-hide")) { - level = Errors.HIDDEN; - } - Errors.setErrorLevel(Integer.parseInt(a[1]), level); - } - catch (NumberFormatException e) { - // already printed below - return false; - } - } - else if (a[0].equals("-keeplist")) { - keepListFile = a[1]; - } - else if (a[0].equals("-proofread")) { - proofreadFile = a[1]; - } - else if (a[0].equals("-todo")) { - todoFile = a[1]; - } - else if (a[0].equals("-public")) { - showLevel = SHOW_PUBLIC; - } - else if (a[0].equals("-protected")) { - showLevel = SHOW_PROTECTED; - } - else if (a[0].equals("-package")) { - showLevel = SHOW_PACKAGE; - } - else if (a[0].equals("-private")) { - showLevel = SHOW_PRIVATE; - } - else if (a[0].equals("-hidden")) { - showLevel = SHOW_HIDDEN; - } - else if (a[0].equals("-stubs")) { - stubsDir = a[1]; - } - else if (a[0].equals("-stubpackages")) { - stubPackages = new HashSet(); - for (String pkg: a[1].split(":")) { - stubPackages.add(pkg); - } - } - else if (a[0].equals("-sdkvalues")) { - sdkValuePath = a[1]; - } - else if (a[0].equals("-apixml")) { - apiXML = true; - apiFile = a[1]; - } - else if (a[0].equals("-nodocs")) { - noDocs = true; - } - else if (a[0].equals("-since")) { - sinceTagger.addVersion(a[1], a[2]); - } - else if (a[0].equals("-offlinemode")) { - offlineMode = true; - } - } - - // read some prefs from the template - if (!readTemplateSettings()) { - return false; - } - - // Set up the data structures - Converter.makeInfo(r); - - if (!noDocs) { - long startTime = System.nanoTime(); - - // Apply @since tags from the XML file - sinceTagger.tagAll(Converter.rootClasses()); - - // Files for proofreading - if (proofreadFile != null) { - Proofread.initProofread(proofreadFile); - } - if (todoFile != null) { - TodoFile.writeTodoFile(todoFile); - } - - // HTML Pages - if (ClearPage.htmlDir != null) { - writeHTMLPages(); - } - - // Navigation tree - NavTree.writeNavTree(javadocDir); - - // Packages Pages - writePackages(javadocDir - + (ClearPage.htmlDir!=null - ? "packages" + htmlExtension - : "index" + htmlExtension)); - - // Classes - writeClassLists(); - writeClasses(); - writeHierarchy(); - // writeKeywords(); - - // Lists for JavaScript - writeLists(); - if (keepListFile != null) { - writeKeepList(keepListFile); - } - - // Sample Code - for (SampleCode sc: sampleCodes) { - sc.write(offlineMode); - } - - // Index page - writeIndex(); - - Proofread.finishProofread(proofreadFile); - - if (sdkValuePath != null) { - writeSdkValues(sdkValuePath); - } - - long time = System.nanoTime() - startTime; - System.out.println("DroidDoc took " + (time / 1000000000) + " sec. to write docs to " - + ClearPage.outputDir); - } - - // Stubs - if (stubsDir != null) { - Stubs.writeStubs(stubsDir, apiXML, apiFile, stubPackages); - } - - Errors.printErrors(); - return !Errors.hadError; - } - - private static void writeIndex() { - HDF data = makeHDF(); - ClearPage.write(data, "index.cs", javadocDir + "index" + htmlExtension); - } - - private static boolean readTemplateSettings() - { - HDF data = makeHDF(); - htmlExtension = data.getValue("template.extension", ".html"); - int i=0; - while (true) { - String k = data.getValue("template.escape." + i + ".key", ""); - String v = data.getValue("template.escape." + i + ".value", ""); - if ("".equals(k)) { - break; - } - if (k.length() != 1) { - System.err.println("template.escape." + i + ".key must have a length of 1: " + k); - return false; - } - escapeChars.put(k.charAt(0), v); - i++; - } - return true; - } - - public static String escape(String s) { - if (escapeChars.size() == 0) { - return s; - } - StringBuffer b = null; - int begin = 0; - final int N = s.length(); - for (int i=0; i 0) { - s += " - " + DroidDoc.title; - } - data.setValue("page.title", s); - } - - public static LanguageVersion languageVersion() - { - return LanguageVersion.JAVA_1_5; - } - - public static int optionLength(String option) - { - if (option.equals("-d")) { - return 2; - } - if (option.equals("-templatedir")) { - return 2; - } - if (option.equals("-hdf")) { - return 3; - } - if (option.equals("-toroot")) { - return 2; - } - if (option.equals("-samplecode")) { - return 4; - } - if (option.equals("-htmldir")) { - return 2; - } - if (option.equals("-title")) { - return 2; - } - if (option.equals("-werror")) { - return 1; - } - if (option.equals("-hide")) { - return 2; - } - if (option.equals("-warning")) { - return 2; - } - if (option.equals("-error")) { - return 2; - } - if (option.equals("-keeplist")) { - return 2; - } - if (option.equals("-proofread")) { - return 2; - } - if (option.equals("-todo")) { - return 2; - } - if (option.equals("-public")) { - return 1; - } - if (option.equals("-protected")) { - return 1; - } - if (option.equals("-package")) { - return 1; - } - if (option.equals("-private")) { - return 1; - } - if (option.equals("-hidden")) { - return 1; - } - if (option.equals("-stubs")) { - return 2; - } - if (option.equals("-stubpackages")) { - return 2; - } - if (option.equals("-sdkvalues")) { - return 2; - } - if (option.equals("-apixml")) { - return 2; - } - if (option.equals("-nodocs")) { - return 1; - } - if (option.equals("-since")) { - return 3; - } - if (option.equals("-offlinemode")) { - return 1; - } - return 0; - } - - public static boolean validOptions(String[][] options, DocErrorReporter r) - { - for (String[] a: options) { - if (a[0].equals("-error") || a[0].equals("-warning") - || a[0].equals("-hide")) { - try { - Integer.parseInt(a[1]); - } - catch (NumberFormatException e) { - r.printError("bad -" + a[0] + " value must be a number: " - + a[1]); - return false; - } - } - } - - return true; - } - - public static HDF makeHDF() - { - HDF data = new HDF(); - - for (String[] p: mHDFData) { - data.setValue(p[0], p[1]); - } - - try { - for (String p: ClearPage.hdfFiles) { - data.readFile(p); - } - } - catch (IOException e) { - throw new RuntimeException(e); - } - - return data; - } - - public static HDF makePackageHDF() - { - HDF data = makeHDF(); - ClassInfo[] classes = Converter.rootClasses(); - - SortedMap sorted = new TreeMap(); - for (ClassInfo cl: classes) { - PackageInfo pkg = cl.containingPackage(); - String name; - if (pkg == null) { - name = ""; - } else { - name = pkg.name(); - } - sorted.put(name, pkg); - } - - int i = 0; - for (String s: sorted.keySet()) { - PackageInfo pkg = sorted.get(s); - - if (pkg.isHidden()) { - continue; - } - Boolean allHidden = true; - int pass = 0; - ClassInfo[] classesToCheck = null; - while (pass < 5 ) { - switch(pass) { - case 0: - classesToCheck = pkg.ordinaryClasses(); - break; - case 1: - classesToCheck = pkg.enums(); - break; - case 2: - classesToCheck = pkg.errors(); - break; - case 3: - classesToCheck = pkg.exceptions(); - break; - case 4: - classesToCheck = pkg.interfaces(); - break; - default: - System.err.println("Error reading package: " + pkg.name()); - break; - } - for (ClassInfo cl : classesToCheck) { - if (!cl.isHidden()) { - allHidden = false; - break; - } - } - if (!allHidden) { - break; - } - pass++; - } - if (allHidden) { - continue; - } - - data.setValue("reference", "true"); - data.setValue("docs.packages." + i + ".name", s); - data.setValue("docs.packages." + i + ".link", pkg.htmlPage()); - data.setValue("docs.packages." + i + ".since", pkg.getSince()); - TagInfo.makeHDF(data, "docs.packages." + i + ".shortDescr", - pkg.firstSentenceTags()); - i++; - } - - sinceTagger.writeVersionNames(data); - return data; - } - - public static void writeDirectory(File dir, String relative) - { - File[] files = dir.listFiles(); - int i, count = files.length; - for (i=0; i 3 && ".cs".equals(templ.substring(len-3))) { - HDF data = makeHDF(); - String filename = templ.substring(0,len-3) + htmlExtension; - ClearPage.write(data, templ, filename); - } - else if (len > 3 && ".jd".equals(templ.substring(len-3))) { - String filename = templ.substring(0,len-3) + htmlExtension; - DocFile.writePage(f.getAbsolutePath(), relative, filename); - } - else { - ClearPage.copyFile(f, templ); - } - } - else if (f.isDirectory()) { - writeDirectory(f, relative + f.getName() + "/"); - } - } - } - - public static void writeHTMLPages() - { - File f = new File(ClearPage.htmlDir); - if (!f.isDirectory()) { - System.err.println("htmlDir not a directory: " + ClearPage.htmlDir); - } - writeDirectory(f, ""); - } - - public static void writeLists() - { - HDF data = makeHDF(); - - ClassInfo[] classes = Converter.rootClasses(); - - SortedMap sorted = new TreeMap(); - for (ClassInfo cl: classes) { - if (cl.isHidden()) { - continue; - } - sorted.put(cl.qualifiedName(), cl); - PackageInfo pkg = cl.containingPackage(); - String name; - if (pkg == null) { - name = ""; - } else { - name = pkg.name(); - } - sorted.put(name, pkg); - } - - int i = 0; - for (String s: sorted.keySet()) { - data.setValue("docs.pages." + i + ".id" , ""+i); - data.setValue("docs.pages." + i + ".label" , s); - - Object o = sorted.get(s); - if (o instanceof PackageInfo) { - PackageInfo pkg = (PackageInfo)o; - data.setValue("docs.pages." + i + ".link" , pkg.htmlPage()); - data.setValue("docs.pages." + i + ".type" , "package"); - } - else if (o instanceof ClassInfo) { - ClassInfo cl = (ClassInfo)o; - data.setValue("docs.pages." + i + ".link" , cl.htmlPage()); - data.setValue("docs.pages." + i + ".type" , "class"); - } - i++; - } - - ClearPage.write(data, "lists.cs", javadocDir + "lists.js"); - } - - public static void cantStripThis(ClassInfo cl, HashSet notStrippable) { - if (!notStrippable.add(cl)) { - // slight optimization: if it already contains cl, it already contains - // all of cl's parents - return; - } - ClassInfo supr = cl.superclass(); - if (supr != null) { - cantStripThis(supr, notStrippable); - } - for (ClassInfo iface: cl.interfaces()) { - cantStripThis(iface, notStrippable); - } - } - - private static String getPrintableName(ClassInfo cl) { - ClassInfo containingClass = cl.containingClass(); - if (containingClass != null) { - // This is an inner class. - String baseName = cl.name(); - baseName = baseName.substring(baseName.lastIndexOf('.') + 1); - return getPrintableName(containingClass) + '$' + baseName; - } - return cl.qualifiedName(); - } - - /** - * Writes the list of classes that must be present in order to - * provide the non-hidden APIs known to javadoc. - * - * @param filename the path to the file to write the list to - */ - public static void writeKeepList(String filename) { - HashSet notStrippable = new HashSet(); - ClassInfo[] all = Converter.allClasses(); - Arrays.sort(all); // just to make the file a little more readable - - // If a class is public and not hidden, then it and everything it derives - // from cannot be stripped. Otherwise we can strip it. - for (ClassInfo cl: all) { - if (cl.isPublic() && !cl.isHidden()) { - cantStripThis(cl, notStrippable); - } - } - PrintStream stream = null; - try { - stream = new PrintStream(filename); - for (ClassInfo cl: notStrippable) { - stream.println(getPrintableName(cl)); - } - } - catch (FileNotFoundException e) { - System.err.println("error writing file: " + filename); - } - finally { - if (stream != null) { - stream.close(); - } - } - } - - private static PackageInfo[] sVisiblePackages = null; - public static PackageInfo[] choosePackages() { - if (sVisiblePackages != null) { - return sVisiblePackages; - } - - ClassInfo[] classes = Converter.rootClasses(); - SortedMap sorted = new TreeMap(); - for (ClassInfo cl: classes) { - PackageInfo pkg = cl.containingPackage(); - String name; - if (pkg == null) { - name = ""; - } else { - name = pkg.name(); - } - sorted.put(name, pkg); - } - - ArrayList result = new ArrayList(); - - for (String s: sorted.keySet()) { - PackageInfo pkg = sorted.get(s); - - if (pkg.isHidden()) { - continue; - } - Boolean allHidden = true; - int pass = 0; - ClassInfo[] classesToCheck = null; - while (pass < 5 ) { - switch(pass) { - case 0: - classesToCheck = pkg.ordinaryClasses(); - break; - case 1: - classesToCheck = pkg.enums(); - break; - case 2: - classesToCheck = pkg.errors(); - break; - case 3: - classesToCheck = pkg.exceptions(); - break; - case 4: - classesToCheck = pkg.interfaces(); - break; - default: - System.err.println("Error reading package: " + pkg.name()); - break; - } - for (ClassInfo cl : classesToCheck) { - if (!cl.isHidden()) { - allHidden = false; - break; - } - } - if (!allHidden) { - break; - } - pass++; - } - if (allHidden) { - continue; - } - - result.add(pkg); - } - - sVisiblePackages = result.toArray(new PackageInfo[result.size()]); - return sVisiblePackages; - } - - public static void writePackages(String filename) - { - HDF data = makePackageHDF(); - - int i = 0; - for (PackageInfo pkg: choosePackages()) { - writePackage(pkg); - - data.setValue("docs.packages." + i + ".name", pkg.name()); - data.setValue("docs.packages." + i + ".link", pkg.htmlPage()); - TagInfo.makeHDF(data, "docs.packages." + i + ".shortDescr", - pkg.firstSentenceTags()); - - i++; - } - - setPageTitle(data, "Package Index"); - - TagInfo.makeHDF(data, "root.descr", - Converter.convertTags(root.inlineTags(), null)); - - ClearPage.write(data, "packages.cs", filename); - ClearPage.write(data, "package-list.cs", javadocDir + "package-list"); - - Proofread.writePackages(filename, - Converter.convertTags(root.inlineTags(), null)); - } - - public static void writePackage(PackageInfo pkg) - { - // these this and the description are in the same directory, - // so it's okay - HDF data = makePackageHDF(); - - String name = pkg.name(); - - data.setValue("package.name", name); - data.setValue("package.since", pkg.getSince()); - data.setValue("package.descr", "...description..."); - - makeClassListHDF(data, "package.interfaces", - ClassInfo.sortByName(pkg.interfaces())); - makeClassListHDF(data, "package.classes", - ClassInfo.sortByName(pkg.ordinaryClasses())); - makeClassListHDF(data, "package.enums", - ClassInfo.sortByName(pkg.enums())); - makeClassListHDF(data, "package.exceptions", - ClassInfo.sortByName(pkg.exceptions())); - makeClassListHDF(data, "package.errors", - ClassInfo.sortByName(pkg.errors())); - TagInfo.makeHDF(data, "package.shortDescr", - pkg.firstSentenceTags()); - TagInfo.makeHDF(data, "package.descr", pkg.inlineTags()); - - String filename = pkg.htmlPage(); - setPageTitle(data, name); - ClearPage.write(data, "package.cs", filename); - - filename = pkg.fullDescriptionHtmlPage(); - setPageTitle(data, name + " Details"); - ClearPage.write(data, "package-descr.cs", filename); - - Proofread.writePackage(filename, pkg.inlineTags()); - } - - public static void writeClassLists() - { - int i; - HDF data = makePackageHDF(); - - ClassInfo[] classes = PackageInfo.filterHidden( - Converter.convertClasses(root.classes())); - if (classes.length == 0) { - return ; - } - - Sorter[] sorted = new Sorter[classes.length]; - for (i=0; i keywords = new ArrayList(); - - ClassInfo[] classes = PackageInfo.filterHidden(Converter.convertClasses(root.classes())); - - for (ClassInfo cl: classes) { - cl.makeKeywordEntries(keywords); - } - - HDF data = makeHDF(); - - Collections.sort(keywords); - - int i=0; - for (KeywordEntry entry: keywords) { - String base = "keywords." + entry.firstChar() + "." + i; - entry.makeHDF(data, base); - i++; - } - - setPageTitle(data, "Index"); - ClearPage.write(data, "keywords.cs", javadocDir + "keywords" + htmlExtension); - } */ - - public static void writeHierarchy() - { - ClassInfo[] classes = Converter.rootClasses(); - ArrayList info = new ArrayList(); - for (ClassInfo cl: classes) { - if (!cl.isHidden()) { - info.add(cl); - } - } - HDF data = makePackageHDF(); - Hierarchy.makeHierarchy(data, info.toArray(new ClassInfo[info.size()])); - setPageTitle(data, "Class Hierarchy"); - ClearPage.write(data, "hierarchy.cs", javadocDir + "hierarchy" + htmlExtension); - } - - public static void writeClasses() - { - ClassInfo[] classes = Converter.rootClasses(); - - for (ClassInfo cl: classes) { - HDF data = makePackageHDF(); - if (!cl.isHidden()) { - writeClass(cl, data); - } - } - } - - public static void writeClass(ClassInfo cl, HDF data) - { - cl.makeHDF(data); - - setPageTitle(data, cl.name()); - ClearPage.write(data, "class.cs", cl.htmlPage()); - - Proofread.writeClass(cl.htmlPage(), cl); - } - - public static void makeClassListHDF(HDF data, String base, - ClassInfo[] classes) - { - for (int i=0; i