minor refactoring of CommentParser.java
This commit is contained in:
parent
2896938879
commit
0d66568ba3
12 changed files with 57 additions and 42 deletions
|
|
@ -11,8 +11,8 @@ import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|
||||||
public class commentParser {
|
public class CommentParser {
|
||||||
static HashMap<String, String> parsedComments = new HashMap<String, String>();
|
private static Map<String, String> m_parsedComments = new HashMap<String, String>();
|
||||||
|
|
||||||
public static boolean start(RootDoc root) {
|
public static boolean start(RootDoc root) {
|
||||||
|
|
||||||
|
|
@ -24,31 +24,31 @@ public class commentParser {
|
||||||
for (ClassDoc classDoc : root.classes()) {
|
for (ClassDoc classDoc : root.classes()) {
|
||||||
|
|
||||||
if (classDoc.getRawCommentText().length() > 0)
|
if (classDoc.getRawCommentText().length() > 0)
|
||||||
parsedComments.put(classDoc.qualifiedName(), classDoc.getRawCommentText());
|
m_parsedComments.put(classDoc.qualifiedName(), classDoc.getRawCommentText());
|
||||||
|
|
||||||
for (FieldDoc f : classDoc.enumConstants()) {
|
for (FieldDoc f : classDoc.enumConstants()) {
|
||||||
if (f.getRawCommentText().length() > 0)
|
if (f.getRawCommentText().length() > 0)
|
||||||
parsedComments.put(f.qualifiedName(), f.getRawCommentText());
|
m_parsedComments.put(f.qualifiedName(), f.getRawCommentText());
|
||||||
}
|
}
|
||||||
for (FieldDoc f : classDoc.fields()) {
|
for (FieldDoc f : classDoc.fields()) {
|
||||||
if (f.getRawCommentText().length() > 0)
|
if (f.getRawCommentText().length() > 0)
|
||||||
parsedComments.put(f.qualifiedName(), f.getRawCommentText());
|
m_parsedComments.put(f.qualifiedName(), f.getRawCommentText());
|
||||||
}
|
}
|
||||||
for (MethodDoc m : classDoc.methods()) {
|
for (MethodDoc m : classDoc.methods()) {
|
||||||
if (m.getRawCommentText().length() > 0)
|
if (m.getRawCommentText().length() > 0)
|
||||||
parsedComments.put(m.toString(), m.getRawCommentText());
|
m_parsedComments.put(m.toString(), m.getRawCommentText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static int check(HashMap<String, String> wantedComments) {
|
public int check(Map<String, String> wantedComments) {
|
||||||
int errorCount=0;
|
int errorCount=0;
|
||||||
Iterator< Entry<String, String> > it = parsedComments.entrySet().iterator();
|
Iterator<Entry<String, String>> it = m_parsedComments.entrySet().iterator();
|
||||||
|
|
||||||
|
while (it.hasNext()) {
|
||||||
|
|
||||||
while (it.hasNext())
|
|
||||||
{
|
|
||||||
Entry<String, String> e = (Entry<String, String>) it.next();
|
Entry<String, String> e = (Entry<String, String>) it.next();
|
||||||
String actualStr = e.getValue();
|
String actualStr = e.getValue();
|
||||||
String wantedStr = wantedComments.get(e.getKey());
|
String wantedStr = wantedComments.get(e.getKey());
|
||||||
|
|
@ -102,14 +102,14 @@ public class commentParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parsedComments.size() != wantedComments.size()) {
|
if (m_parsedComments.size() != wantedComments.size()) {
|
||||||
System.out.println("Mismatch in the number of comments!\n Expected: " +
|
System.out.println("Mismatch in the number of comments!\n Expected: " +
|
||||||
wantedComments.size() + "\n Parsed: " +
|
wantedComments.size() + "\n Parsed: " +
|
||||||
parsedComments.size());
|
m_parsedComments.size());
|
||||||
System.out.println("Expected keys: ");
|
System.out.println("Expected keys: ");
|
||||||
printKeys(wantedComments);
|
printKeys(wantedComments);
|
||||||
System.out.println("Parsed keys: ");
|
System.out.println("Parsed keys: ");
|
||||||
printKeys(parsedComments);
|
printKeys(m_parsedComments);
|
||||||
|
|
||||||
errorCount++;
|
errorCount++;
|
||||||
}
|
}
|
||||||
|
|
@ -118,7 +118,8 @@ public class commentParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void printKeys(Map map) {
|
private void printKeys(Map<String, String> map) {
|
||||||
|
|
||||||
Set<String> keys = map.keySet();
|
Set<String> keys = map.keySet();
|
||||||
for (String key : keys) {
|
for (String key : keys) {
|
||||||
System.out.println(" " + key);
|
System.out.println(" " + key);
|
||||||
|
|
@ -127,9 +128,11 @@ public class commentParser {
|
||||||
|
|
||||||
|
|
||||||
public static void printCommentListForJavaSource() {
|
public static void printCommentListForJavaSource() {
|
||||||
Iterator< Entry<String, String> > it = parsedComments.entrySet().iterator();
|
|
||||||
while (it.hasNext())
|
Iterator< Entry<String, String> > it = m_parsedComments.entrySet().iterator();
|
||||||
{
|
|
||||||
|
while (it.hasNext()) {
|
||||||
|
|
||||||
Entry<String, String> e = (Entry<String, String>) it.next();
|
Entry<String, String> e = (Entry<String, String>) it.next();
|
||||||
String commentText = e.getValue();
|
String commentText = e.getValue();
|
||||||
commentText = commentText.replace("\\", "\\\\");
|
commentText = commentText.replace("\\", "\\\\");
|
||||||
|
|
@ -143,12 +146,12 @@ public class commentParser {
|
||||||
public static void main(String argv[]) {
|
public static void main(String argv[]) {
|
||||||
|
|
||||||
if (argv.length<1) {
|
if (argv.length<1) {
|
||||||
System.out.format("Usage:\n\tcommentParsing <package to parse>\n");
|
System.out.format("Usage:\n\tCommentParser <package to parse>\n");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
com.sun.tools.javadoc.Main.execute("The comment parser program",
|
com.sun.tools.javadoc.Main.execute("The comment parser program",
|
||||||
"commentParser", new String[]{"-quiet", argv[0]});
|
"CommentParser", new String[]{"-quiet", argv[0]});
|
||||||
|
|
||||||
// if we are run as standalone app, print the list of found comments as it would appear in java source
|
// if we are run as standalone app, print the list of found comments as it would appear in java source
|
||||||
|
|
||||||
|
|
@ -19,9 +19,10 @@ public class doxygen_basic_notranslate_runme {
|
||||||
Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
|
Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
|
||||||
and calls the start() method of that class with parsed information.
|
and calls the start() method of that class with parsed information.
|
||||||
*/
|
*/
|
||||||
commentParser parser = new commentParser();
|
CommentParser parser = new CommentParser();
|
||||||
com.sun.tools.javadoc.Main.execute("doxygen_basic_notranslate runtime test",
|
com.sun.tools.javadoc.Main.execute("doxygen_basic_notranslate runtime test",
|
||||||
"commentParser", new String[]{"-quiet", "doxygen_basic_notranslate"});
|
"CommentParser",
|
||||||
|
new String[]{"-quiet", "doxygen_basic_notranslate"});
|
||||||
|
|
||||||
HashMap<String, String> wantedComments = new HashMap<String, String>();
|
HashMap<String, String> wantedComments = new HashMap<String, String>();
|
||||||
wantedComments.put("doxygen_basic_notranslate.doxygen_basic_notranslate.function3(int)",
|
wantedComments.put("doxygen_basic_notranslate.doxygen_basic_notranslate.function3(int)",
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,10 @@ public class doxygen_basic_translate_runme {
|
||||||
Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
|
Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
|
||||||
and calls the start() method of that class with parsed information.
|
and calls the start() method of that class with parsed information.
|
||||||
*/
|
*/
|
||||||
commentParser parser = new commentParser();
|
CommentParser parser = new CommentParser();
|
||||||
com.sun.tools.javadoc.Main.execute("doxygen_basic_translate runtime test",
|
com.sun.tools.javadoc.Main.execute("doxygen_basic_translate runtime test",
|
||||||
"commentParser", new String[]{"-quiet", "doxygen_basic_translate"});
|
"CommentParser",
|
||||||
|
new String[]{"-quiet", "doxygen_basic_translate"});
|
||||||
|
|
||||||
HashMap<String, String> wantedComments = new HashMap<String, String>();
|
HashMap<String, String> wantedComments = new HashMap<String, String>();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,10 @@ public class doxygen_misc_constructs_runme {
|
||||||
Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
|
Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
|
||||||
and calls the start() method of that class with parsed information.
|
and calls the start() method of that class with parsed information.
|
||||||
*/
|
*/
|
||||||
commentParser parser = new commentParser();
|
CommentParser parser = new CommentParser();
|
||||||
com.sun.tools.javadoc.Main.execute("doxygen_misc_constructs runtime test",
|
com.sun.tools.javadoc.Main.execute("doxygen_misc_constructs runtime test",
|
||||||
"commentParser", new String[]{"-quiet", "doxygen_misc_constructs"});
|
"CommentParser",
|
||||||
|
new String[]{"-quiet", "doxygen_misc_constructs"});
|
||||||
|
|
||||||
HashMap<String, String> wantedComments = new HashMap<String, String>();
|
HashMap<String, String> wantedComments = new HashMap<String, String>();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,10 @@ public class doxygen_parsing_enums_proper_runme {
|
||||||
Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
|
Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
|
||||||
and calls the start() method of that class with parsed information.
|
and calls the start() method of that class with parsed information.
|
||||||
*/
|
*/
|
||||||
commentParser parser = new commentParser();
|
CommentParser parser = new CommentParser();
|
||||||
com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_proper runtime test",
|
com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_proper runtime test",
|
||||||
"commentParser", new String[]{"-quiet", "doxygen_parsing_enums_proper"});
|
"CommentParser",
|
||||||
|
new String[]{"-quiet", "doxygen_parsing_enums_proper"});
|
||||||
|
|
||||||
HashMap<String, String> wantedComments = new HashMap<String, String>();
|
HashMap<String, String> wantedComments = new HashMap<String, String>();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,10 @@ public class doxygen_parsing_enums_simple_runme {
|
||||||
Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
|
Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
|
||||||
and calls the start() method of that class with parsed information.
|
and calls the start() method of that class with parsed information.
|
||||||
*/
|
*/
|
||||||
commentParser parser = new commentParser();
|
CommentParser parser = new CommentParser();
|
||||||
com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_simple runtime test",
|
com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_simple runtime test",
|
||||||
"commentParser", new String[]{"-quiet", "doxygen_parsing_enums_simple"});
|
"CommentParser",
|
||||||
|
new String[]{"-quiet", "doxygen_parsing_enums_simple"});
|
||||||
|
|
||||||
HashMap<String, String> wantedComments = new HashMap<String, String>();
|
HashMap<String, String> wantedComments = new HashMap<String, String>();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,10 @@ public class doxygen_parsing_enums_typesafe_runme {
|
||||||
Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
|
Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
|
||||||
and calls the start() method of that class with parsed information.
|
and calls the start() method of that class with parsed information.
|
||||||
*/
|
*/
|
||||||
commentParser parser = new commentParser();
|
CommentParser parser = new CommentParser();
|
||||||
com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_typesafe runtime test",
|
com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_typesafe runtime test",
|
||||||
"commentParser", new String[]{"-quiet", "doxygen_parsing_enums_typesafe"});
|
"CommentParser",
|
||||||
|
new String[]{"-quiet", "doxygen_parsing_enums_typesafe"});
|
||||||
|
|
||||||
HashMap<String, String> wantedComments = new HashMap<String, String>();
|
HashMap<String, String> wantedComments = new HashMap<String, String>();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,10 @@ public class doxygen_parsing_enums_typeunsafe_runme {
|
||||||
Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
|
Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
|
||||||
and calls the start() method of that class with parsed information.
|
and calls the start() method of that class with parsed information.
|
||||||
*/
|
*/
|
||||||
commentParser parser = new commentParser();
|
CommentParser parser = new CommentParser();
|
||||||
com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_typeunsafe runtime test",
|
com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_typeunsafe runtime test",
|
||||||
"commentParser", new String[]{"-quiet", "doxygen_parsing_enums_typeunsafe"});
|
"CommentParser",
|
||||||
|
new String[]{"-quiet", "doxygen_parsing_enums_typeunsafe"});
|
||||||
|
|
||||||
HashMap<String, String> wantedComments = new HashMap<String, String>();
|
HashMap<String, String> wantedComments = new HashMap<String, String>();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,10 @@ public class doxygen_parsing_runme {
|
||||||
Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
|
Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
|
||||||
and calls the start() method of that class with parsed information.
|
and calls the start() method of that class with parsed information.
|
||||||
*/
|
*/
|
||||||
commentParser parser = new commentParser();
|
CommentParser parser = new CommentParser();
|
||||||
com.sun.tools.javadoc.Main.execute("doxygen_parsing runtime test",
|
com.sun.tools.javadoc.Main.execute("doxygen_parsing runtime test",
|
||||||
"commentParser", new String[]{"-quiet", "doxygen_parsing"});
|
"CommentParser",
|
||||||
|
new String[]{"-quiet", "doxygen_parsing"});
|
||||||
|
|
||||||
HashMap<String, String> wantedComments = new HashMap<String, String>();
|
HashMap<String, String> wantedComments = new HashMap<String, String>();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,10 @@ public class doxygen_translate_all_tags_runme {
|
||||||
Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
|
Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
|
||||||
and calls the start() method of that class with parsed information.
|
and calls the start() method of that class with parsed information.
|
||||||
*/
|
*/
|
||||||
commentParser parser = new commentParser();
|
CommentParser parser = new CommentParser();
|
||||||
com.sun.tools.javadoc.Main.execute("doxygen_translate_all_tags runtime test",
|
com.sun.tools.javadoc.Main.execute("doxygen_translate_all_tags runtime test",
|
||||||
"commentParser", new String[]{"-quiet", "doxygen_translate_all_tags"});
|
"CommentParser",
|
||||||
|
new String[]{"-quiet", "doxygen_translate_all_tags"});
|
||||||
|
|
||||||
HashMap<String, String> wantedComments = new HashMap<String, String>();
|
HashMap<String, String> wantedComments = new HashMap<String, String>();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,10 @@ public class doxygen_translate_links_runme {
|
||||||
Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
|
Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
|
||||||
and calls the start() method of that class with parsed information.
|
and calls the start() method of that class with parsed information.
|
||||||
*/
|
*/
|
||||||
commentParser parser = new commentParser();
|
CommentParser parser = new CommentParser();
|
||||||
com.sun.tools.javadoc.Main.execute("doxygen_translate_links runtime test",
|
com.sun.tools.javadoc.Main.execute("doxygen_translate_links runtime test",
|
||||||
"commentParser", new String[]{"-quiet", "doxygen_translate_links"});
|
"CommentParser",
|
||||||
|
new String[]{"-quiet", "doxygen_translate_links"});
|
||||||
|
|
||||||
HashMap<String, String> wantedComments = new HashMap<String, String>();
|
HashMap<String, String> wantedComments = new HashMap<String, String>();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
import doxygen_translate.*;
|
import doxygen_translate.*;
|
||||||
import com.sun.javadoc.*;
|
import com.sun.javadoc.*;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class doxygen_translate_runme {
|
public class doxygen_translate_runme {
|
||||||
static {
|
static {
|
||||||
|
|
@ -19,11 +20,12 @@ public class doxygen_translate_runme {
|
||||||
Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
|
Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
|
||||||
and calls the start() method of that class with parsed information.
|
and calls the start() method of that class with parsed information.
|
||||||
*/
|
*/
|
||||||
commentParser parser = new commentParser();
|
CommentParser parser = new CommentParser();
|
||||||
com.sun.tools.javadoc.Main.execute("doxygen_translate runtime test",
|
com.sun.tools.javadoc.Main.execute("doxygen_translate runtime test",
|
||||||
"commentParser", new String[]{"-quiet", "doxygen_translate"});
|
"CommentParser",
|
||||||
|
new String[]{"-quiet", "doxygen_translate"});
|
||||||
|
|
||||||
HashMap<String, String> wantedComments = new HashMap<String, String>();
|
Map<String, String> wantedComments = new HashMap<String, String>();
|
||||||
|
|
||||||
wantedComments.put("doxygen_translate.doxygen_translate.function(int, float)",
|
wantedComments.put("doxygen_translate.doxygen_translate.function(int, float)",
|
||||||
" <i>Hello </i>\n" +
|
" <i>Hello </i>\n" +
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue