Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 289d80ee authored by Jesse Wilson's avatar Jesse Wilson
Browse files

Adding version information to DroidDoc. Rather than pulling the version from

@since tags in the code, it's pulled from the API XML files also used by
apicheck.

The code now reads the apicheck XML, and applies it's versions to the DroidDoc
class models. The models output the version to HDF, and that's picked up by
the CS templates.

The clearsilver templates will be changed to be pretty in a follow up change.

Conflicts:
	tools/droiddoc/src/DroidDoc.java
parent 70a76816
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -127,7 +127,7 @@ droiddoc := \
	$(HOST_OUT_JAVA_LIBRARIES)/clearsilver$(COMMON_JAVA_PACKAGE_SUFFIX) \
	$(HOST_OUT_SHARED_LIBRARIES)/libclearsilver-jni$(HOST_JNILIB_SUFFIX)

$(full_target): PRIVATE_DOCLETPATH := $(HOST_OUT_JAVA_LIBRARIES)/clearsilver$(COMMON_JAVA_PACKAGE_SUFFIX):$(HOST_OUT_JAVA_LIBRARIES)/droiddoc$(COMMON_JAVA_PACKAGE_SUFFIX)
$(full_target): PRIVATE_DOCLETPATH := $(HOST_OUT_JAVA_LIBRARIES)/clearsilver$(COMMON_JAVA_PACKAGE_SUFFIX):$(HOST_OUT_JAVA_LIBRARIES)/droiddoc$(COMMON_JAVA_PACKAGE_SUFFIX):$(HOST_OUT_JAVA_LIBRARIES)/apicheck$(COMMON_JAVA_PACKAGE_SUFFIX)
$(full_target): PRIVATE_CURRENT_BUILD := -hdf page.build $(BUILD_ID)-$(BUILD_NUMBER)
$(full_target): PRIVATE_CURRENT_TIME :=  -hdf page.now "$(shell date "+%d %b %Y %k:%M")"
$(full_target): PRIVATE_TEMPLATE_DIR := $(LOCAL_DROIDDOC_TEMPLATE_DIR)
+46 −61
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import org.xml.sax.*;
import org.xml.sax.helpers.*;
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Stack;

public class ApiCheck {
@@ -83,62 +82,62 @@ public class ApiCheck {
                }
            }

            String xmlFileName = args.get(0);
            String xmlFileNameNew = args.get(1);
            XMLReader xmlreader = null;
            try {
                // parse the XML files into our data structures
                xmlreader = XMLReaderFactory.createXMLReader();
            ApiCheck acheck = new ApiCheck();
                MakeHandler handler = acheck.new MakeHandler();
                xmlreader.setContentHandler(handler);
                xmlreader.setErrorHandler(handler);
                FileReader filereader = new FileReader(xmlFileName);
                xmlreader.parse(new InputSource(filereader));
                FileReader filereaderNew = new FileReader(xmlFileNameNew);
                xmlreader.parse(new InputSource(filereaderNew));

                // establish the superclass relationships
                handler.getOldApi().resolveSuperclasses();
                handler.getNewApi().resolveSuperclasses();
            ApiInfo oldApi = acheck.parseApi(args.get(0));
            ApiInfo newApi = acheck.parseApi(args.get(1));

                // finally, run the consistency check
                handler.getOldApi().isConsistent(handler.getNewApi());
            // 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();
            return apiInfo;
        } catch (SAXParseException e) {
            Errors.error(Errors.PARSE_ERROR,
                        new SourcePositionInfo(xmlFileName, e.getLineNumber(), 0),
                    new SourcePositionInfo(xmlFile, e.getLineNumber(), 0),
                    e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            Errors.error(Errors.PARSE_ERROR,
                        new SourcePositionInfo(xmlFileName, 0, 0),
                        e.getMessage());
                    new SourcePositionInfo(xmlFile, 0, 0), e.getMessage());
        } finally {
            if (fileReader != null) {
                try {
                    fileReader.close();
                } catch (IOException ignored) {}
            }

            Errors.printErrors();
            System.exit(Errors.hadError ? 1 : 0);
        }
        return null;
    }

        private class MakeHandler extends DefaultHandler {
    private static class MakeHandler extends DefaultHandler {
            
            private Integer mWarningCount;
            private ApiInfo mOriginalApi;
            private ApiInfo mNewApi;
            private boolean mOldApi;
            private ApiInfo mApi;
            private PackageInfo mCurrentPackage;
            private ClassInfo mCurrentClass;
            private AbstractMethodInfo mCurrentMethod;
            private ConstructorInfo mCurrentConstructor;
            private Stack<ClassInfo> mClassScope = new Stack<ClassInfo>();


            public MakeHandler() {
                super();
                mOriginalApi = new ApiInfo();
                mNewApi = new ApiInfo();
                mOldApi = true;
                
                mApi = new ApiInfo();
            }
            
            public void startElement(String uri, String localName, String qName, 
@@ -229,25 +228,11 @@ public class ApiCheck {
                    mCurrentPackage.addClass(mCurrentClass);
                    mCurrentClass = mClassScope.pop();
                } else if (qName.equals("package")){
                    if (mOldApi) {
                        mOriginalApi.addPackage(mCurrentPackage);
                    } else {
                        mNewApi.addPackage(mCurrentPackage);
                    }
                    mApi.addPackage(mCurrentPackage);
                }
            }
            public void endDocument() {
                mOldApi = !mOldApi;
            public ApiInfo getApi() {
                return mApi;
            }
            
            public ApiInfo getOldApi() {
                return mOriginalApi;
            }
            
            public ApiInfo getNewApi() {
                return mNewApi;
            }


        }
}
+25 −3
Original line number Diff line number Diff line
@@ -187,8 +187,8 @@ public class ClassInfo {
        }
        
        for (FieldInfo mInfo : mFields.values()) {
          if (cl.mFields.containsKey(mInfo.qualifiedName())) {
              if (!mInfo.isConsistent(cl.mFields.get(mInfo.qualifiedName()))) {
          if (cl.mFields.containsKey(mInfo.name())) {
              if (!mInfo.isConsistent(cl.mFields.get(mInfo.name()))) {
                  consistent = false;
              }
          } else {
@@ -267,7 +267,7 @@ public class ClassInfo {
    }
    
    public void addField(FieldInfo fInfo) {
        mFields.put(fInfo.qualifiedName(), fInfo);
        mFields.put(fInfo.name(), fInfo);
      
    }
    
@@ -279,4 +279,26 @@ public class ClassInfo {
        return mExistsInBoth;
    }

    public Map<String, ConstructorInfo> allConstructors() {
        return mConstructors;
    }

    public Map<String, FieldInfo> allFields() {
        return mFields;
    }

    public Map<String, MethodInfo> allMethods() {
        return mMethods;
    }

    /**
     * Returns the class hierarchy for this class, starting with this class.
     */
    public Iterable<ClassInfo> hierarchy() {
        List<ClassInfo> result = new ArrayList<ClassInfo>(4);
        for (ClassInfo c  = this; c != null; c = c.mSuperClass) {
            result.add(c);
        }
        return result;
    }
}
+4 −3
Original line number Diff line number Diff line
@@ -55,11 +55,12 @@ public class ConstructorInfo implements AbstractMethodInfo {
    }
    
    public String getHashableName() {
      String returnString = qualifiedName();
      StringBuilder result = new StringBuilder();
      result.append(name());
      for (ParameterInfo pInfo : mParameters) {
          returnString += ":" + pInfo.getType();
          result.append(":").append(pInfo.getType());
      }
      return returnString;
      return result.toString();
    }
    
    public boolean isInBoth() {
+1 −1
Original line number Diff line number Diff line
@@ -195,7 +195,7 @@ public class MethodInfo implements AbstractMethodInfo {
    }
    
    public String getHashableName() {
        return qualifiedName() + getParameterHash();
        return name() + getParameterHash();
    }
    
    public String getSignature() {
Loading