Permalink
Browse files

Fix Deprecated method identification.

The comparison needs to be somewhat hacky. It should mostly work.
  • Loading branch information...
1 parent 81c9631 commit d3e0e98ab630b4028d32663befe4fff8d9d22d95 @atsushieno atsushieno committed Aug 18, 2011
Showing with 32 additions and 10 deletions.
  1. +14 −6 JavaClass.java
  2. +5 −0 README
  3. +1 −1 scraper-collector.sh
  4. +1 −1 scraper-main.sh
  5. +11 −2 scraper.cs
View
@@ -116,7 +116,7 @@ void appendCtor (Constructor ctor, Document doc, Element parent)
e.setAttribute ("final", Modifier.isFinal (mods) ? "true" : "false");
e.setAttribute ("static", Modifier.isStatic (mods) ? "true" : "false");
e.setAttribute ("visibility", Modifier.isPublic (mods) ? "public" : "protected");
- setDeprecatedAttr (e, ctor.getDeclaredAnnotations ());
+ setDeprecatedAttr (e, ctor.getDeclaredAnnotations (), e.getAttribute ("name"));
appendParameters (parent.getAttribute ("name"), ctor.getGenericParameterTypes (), getConstructorParameterOffset (ctor), ctor.isVarArgs (), doc, e);
e.appendChild (doc.createTextNode ("\n"));
@@ -152,7 +152,7 @@ void appendField (Field field, Document doc, Element parent)
e.setAttribute ("transient", Modifier.isTransient (mods) ? "true" : "false");
e.setAttribute ("visibility", Modifier.isPublic (mods) ? "public" : "protected");
e.setAttribute ("volatile", Modifier.isVolatile (mods) ? "true" : "false");
- setDeprecatedAttr (e, field.getDeclaredAnnotations ());
+ setDeprecatedAttr (e, field.getDeclaredAnnotations (), e.getAttribute ("name"));
if (Modifier.isStatic (mods) && Modifier.isFinal (mods) && Modifier.isPublic (mods)) {
String type = e.getAttribute ("type");
try {
@@ -225,7 +225,14 @@ void appendMethod (Method method, Document doc, Element parent)
e.setAttribute ("native", Modifier.isNative (mods) ? "true" : "false");
e.setAttribute ("synchronized", Modifier.isSynchronized (mods) ? "true" : "false");
e.setAttribute ("visibility", Modifier.isPublic (mods) ? "public" : "protected");
- setDeprecatedAttr (e, method.getDeclaredAnnotations ());
+
+ String easyName = method.getName () + "(";
+ Class [] ptypes = method.getParameterTypes ();
+ for (int idx = 0; idx < ptypes.length; idx++)
+ easyName += (idx > 0 ? "," : "") + ptypes [idx].getSimpleName ();
+ easyName += ")";
+ setDeprecatedAttr (e, method.getDeclaredAnnotations (), easyName);
+
appendParameters (method.getName (), method.getGenericParameterTypes (), 0, method.isVarArgs (), doc, e);
Class [] excTypes = method.getExceptionTypes ();
@@ -374,7 +381,7 @@ public void appendToDocument (Document doc, Element parent)
if (typeParameters != null)
e.appendChild (typeParameters);
- setDeprecatedAttr (e, jclass.getDeclaredAnnotations ());
+ setDeprecatedAttr (e, jclass.getDeclaredAnnotations (), e.getAttribute ("name"));
// FIXME: at some stage we'd like to use generic name.
//Type [] ifaces = jclass.getGenericInterfaces ();
Class [] ifaces = jclass.getInterfaces ();
@@ -524,12 +531,13 @@ else if (name.charAt (0) == 'L')
static final Pattern duplicatePackageAndClass = Pattern.compile ("([a-z0-9.]+[A-Z][a-z0-9]+)\\.\\1");
- void setDeprecatedAttr (Element elem, Annotation[] annotations)
+ void setDeprecatedAttr (Element elem, Annotation[] annotations, String name)
{
boolean isDeprecated = false;
// by reference document (they may be excessive on old versions though)
- isDeprecated = deprecatedFields != null && deprecatedFields.indexOf (elem.getAttribute ("name")) >= 0;
+ isDeprecated = deprecatedFields != null && deprecatedFields.indexOf (name) >= 0
+ || deprecatedMethods != null && deprecatedMethods.indexOf (name) >= 0;
// by annotations (they might not exist though)
for (Annotation a : annotations)
View
5 README
@@ -126,6 +126,11 @@ detailed arguments. You should rather check Makefile to see what it does.
This likely has to be resolved by bytecode engineering (such as ASM).
+- There are some classes that have extraneous "CompareTo(Object)" method
+ - Android.Net.Uri,
+- In some classes, ToString() override is missing:
+ - Android.Net.Uri
+
* Notes on Annotations
View
@@ -15,7 +15,7 @@ do
xmllint --html --xmlout $f 2>/dev/null | xmlstarlet sel -t -c "//p[@class='caution']/../../h4[@class='jd-details-title']/text()"
echo "</fields>"
echo "<methods>"
- xmllint --html --xmlout $f 2>/dev/null | xmlstarlet sel -t -c "translate (string(//p[@class='caution']/ancestor::div[h4/@class='jd-details-title']/h4), '&#xA;', ' ')"
+ xmllint --html --xmlout $f 2>/dev/null | xmlstarlet sel -t -c "//p[@class='caution']/ancestor::div[h4/@class='jd-details-title' and h4/span/@class='sympad']/h4/descendant::text()"
echo "</methods>"
echo "</file>"
done
View
@@ -1,4 +1,4 @@
#!/bin/bash
echo "<deprecated>"
-bash scraper-collector.sh "$1" | xmlstarlet sel -t -c "//file[normalize-space(fields/text()) or normalize-space(methods/text())]"
+bash scraper-collector.sh "$1" | xmlstarlet sel -t -c "//file"
echo "</deprecated>"
View
@@ -15,6 +15,8 @@ public static int Main (string [] args)
Console.WriteLine ("<deprecated>");
char [] sep = new char [] {' '};
char [] fsep = new char [] {')'};
+ char [] fsep2 = new char [] {'('};
+ char [] psep = new char [] {','};
foreach (XmlElement file in doc.SelectNodes ("/deprecated/file")) {
string output = "";
foreach (XmlElement field in file.SelectNodes ("fields")) {
@@ -31,8 +33,15 @@ public static int Main (string [] args)
// once remove whitespaces, join them.
string all = String.Join (" ", items);
items = all.Split (fsep, StringSplitOptions.RemoveEmptyEntries); // split at ')' to tokenize all function definitions (which should end at ')')
- foreach (var item in items)
- output += " <method>" + item.Replace ("<", "&lt;") + ")</method>\n";
+ foreach (var item in items) {
+ // drop parameter name (i.e. keep only parameter type)
+ string [] fnp = (item.Trim ()).Split (fsep2, StringSplitOptions.RemoveEmptyEntries);
+ string [] signame = fnp [0].Trim ().Split (sep);
+ string [] prms = fnp.Length > 1 ? fnp [1].Split (psep, StringSplitOptions.RemoveEmptyEntries) : new string [0];
+ for (int i = 0; i < prms.Length; i++)
+ prms [i] = prms [i].Trim ().Split (sep) [0];
+ output += " <method>" + signame [signame.Length - 1] + "(" + String.Join (",", prms).Replace ("<", "&lt;") + ")</method>\n";
+ }
}
if (output.Length == 0)
continue;

0 comments on commit d3e0e98

Please sign in to comment.