Skip to content

Commit

Permalink
This change likely makes it possible to retrieve parameter names from…
Browse files Browse the repository at this point in the history
… compatibility docs from developer.android.com (wget).
  • Loading branch information
Atsushi Eno committed Jan 27, 2012
1 parent 17bc988 commit 4c724cf
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 30 deletions.
65 changes: 36 additions & 29 deletions AndroidDocScraper.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected AndroidDocScraper (File dir, String patternHead, String resetPatternHe

root = dir;

File packageList = new File (dir.getAbsolutePath() + "/package-list");
File packageList = new File (dir.getAbsolutePath() + "/packages.html");
if (!packageList.isFile())
throw new IllegalArgumentException (dir.getAbsolutePath() + " does not appear to be an android doc reference directory.");
}
Expand All @@ -84,8 +84,10 @@ public String[] getParameterNames (ClassNode asm, String name, Type[] ptypes, bo
{
String path = asm.name.replace ('$', '.') + ".html";
File file = new File(root.getPath() + "/" + path);
if (!file.isFile ())
if (!file.isFile ()) {
// System.err.println ("Warning: no document found : " + file);
return null;
}

StringBuffer buffer = new StringBuffer ();
buffer.append (pattern_head);
Expand All @@ -106,40 +108,45 @@ public String[] getParameterNames (ClassNode asm, String name, Type[] ptypes, bo

try {
FileInputStream stream = new FileInputStream (file);
InputStreamReader rdr;
rdr = new InputStreamReader (stream, "UTF-8");
BufferedReader br = new BufferedReader (rdr);
String text = "";
String prev = null;
while ((text = br.readLine ()) != null) {
if (prev != null)
prev = text = prev + text;
Matcher matcher = pattern.matcher (text);
if (matcher.find ()) {
String plist = matcher.group (1);
String[] parms = plist.split (", ");
if (parms.length != ptypes.length)
System.err.println ("failed matching " + buffer.toString ());
String[] result = new String [ptypes.length];
for (int i = 0; i < ptypes.length; i++) {
String[] toks = parms [i].split (parameter_pair_splitter);
result [i] = toks [toks.length - 1];
try {
InputStreamReader rdr;
rdr = new InputStreamReader (stream, "UTF-8");
BufferedReader br = new BufferedReader (rdr);
String text = "";
String prev = null;
while ((text = br.readLine ()) != null) {
if (prev != null)
prev = text = prev + text;
Matcher matcher = pattern.matcher (text);
if (matcher.find ()) {
String plist = matcher.group (1);
String[] parms = plist.split (", ");
if (parms.length != ptypes.length)
System.err.println ("failed matching " + buffer.toString ());
String[] result = new String [ptypes.length];
for (int i = 0; i < ptypes.length; i++) {
String[] toks = parms [i].split (parameter_pair_splitter);
result [i] = toks [toks.length - 1];
}
stream.close();
return result;
}
stream.close();
return result;
// sometimes we get incomplete tag, so cache it until it gets complete or matched.
// I *know* this is a hack.
if (reset_pattern_head == null || text.endsWith (">") || !text.startsWith (reset_pattern_head))
prev = null;
else
prev = text;
}
// sometimes we get incomplete tag, so cache it until it gets complete or matched.
// I *know* this is a hack.
if (reset_pattern_head == null || text.endsWith (">") || !text.startsWith (reset_pattern_head))
prev = null;
else
prev = text;
} finally {
stream.close();
}
stream.close();
} catch (Exception e) {
// System.err.println ("ERROR " + e);
return new String [0];
}

// System.err.println ("Warning : no match for " + asm.name + " :: " + name);
return new String [0];
}

Expand Down
2 changes: 1 addition & 1 deletion JavaClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ else if (iface instanceof ParameterizedType) {
int mmods = method.getModifiers ();

if (!Modifier.isPublic (mods) && (mmods & 0x1000) != 0) {
System.err.println ("Skipped doubtful method " + method);
System.err.println ("Skipped method " + method + " (unusual access modifier)");
continue; // Some non-standard flag seems to detect non-declared method on the source e.g. AbstractStringBuilder.append(char)
}

Expand Down

0 comments on commit 4c724cf

Please sign in to comment.