From e4438e407063620d770a4ffbb78364a222a516f0 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Thu, 5 Oct 2006 00:18:06 +0000 Subject: [PATCH] We need to notice and observe the @ActionScript(name="foo") annotations when slurping comments from Java source files. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4408 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../presents/tools/ActionScriptSource.java | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/java/com/threerings/presents/tools/ActionScriptSource.java b/src/java/com/threerings/presents/tools/ActionScriptSource.java index 051c1f9ff..b2b3292aa 100644 --- a/src/java/com/threerings/presents/tools/ActionScriptSource.java +++ b/src/java/com/threerings/presents/tools/ActionScriptSource.java @@ -515,6 +515,7 @@ public class ActionScriptSource String name = m.group(1); String comment = accum.toString(); accum.setLength(0); + // set the comment on the specified method updateComment(publicConstructors, name, comment); updateComment(protectedConstructors, name, comment); @@ -541,6 +542,24 @@ public class ActionScriptSource String name = m.group(1); String comment = accum.toString(); accum.setLength(0); + + // look through the comment for an @ActionScript + // annotation; oh the hackery + if (comment.indexOf("@ActionScript") != -1) { + StringBuilder combuf = new StringBuilder(); + for (String cline : StringUtil.split(comment, "\n")) { + if ((m = JANNOTATION.matcher(cline)).matches()) { + name = m.group(1); + } else { + if (combuf.length() > 0) { + combuf.append("\n"); + } + combuf.append(cline); + } + } + comment = combuf.toString(); + } + // set the comment on the specified method updateComment(publicStaticMethods, name, comment); updateComment(publicMethods, name, comment); @@ -718,7 +737,10 @@ public class ActionScriptSource !funcName.equals("writeObject")) { curmem.definition = line.trim(); } - curmem.setComment(accum.toString()); + String ncomment = accum.toString(); + if (!StringUtil.isBlank(ncomment)) { + curmem.setComment(ncomment); + } } accum.setLength(0); @@ -952,6 +974,9 @@ public class ActionScriptSource protected static Pattern JMETHOD = Pattern.compile( "\\s+(?:public|protected|private).* ([a-zA-Z]\\w*) \\(.*"); + protected static Pattern JANNOTATION = Pattern.compile( + ".*@ActionScript\\(name=\"(\\w+)\"\\).*"); + protected static Pattern ASFIELD = Pattern.compile( "\\s+(?:public|protected|private)" + "(?:\\s+static)?(?:\\s+var|\\s+const)?" +