use of com.sun.javadoc.Tag in project jdk8u_jdk by JetBrains.
the class GenDocletBeanInfo method start.
/** @beaninfo
* bound:true
* constrained:false
* expert:true
* hidden:true
* preferred:false
* description: the description of this method can
* do all sorts of funky things. if it \n
* is indented like this, we have to remove
* all char spaces greater than 2 and also any hard-coded \n
* newline characters and all newlines
* displayname: theString
* propertyeditorclass: foo.bar.MyPropertyEditorClass
* customizerclass: foo.bar.MyCustomizerClass
* attribute:key1 value1
* attribute: key2 value2
*
*/
public static boolean start(RootDoc doc) {
readOptions(doc.options());
if (templateDir.length() == 0) {
System.err.println("-t option not specified");
return false;
}
if (fileDir.length() == 0) {
System.err.println("-d option not specified");
return false;
}
GenSwingBeanInfo generator = new GenSwingBeanInfo(fileDir, templateDir, DEBUG);
Hashtable dochash = new Hashtable();
DocBeanInfo dbi;
/* "javadoc Foo.java Bar.java" will return:
* "Foo Foo.I1 Foo.I2 Bar Bar.I1 Bar.I2"
* i.e., with all the innerclasses of classes specified in the command
* line. We don't want to generate BeanInfo for any of these inner
* classes, so we ignore these by remembering what the last outer
* class was. A hack, I admit, but makes the build faster.
*/
String previousClass = null;
ClassDoc[] classes = doc.classes();
for (int cnt = 0; cnt < classes.length; cnt++) {
String className = classes[cnt].qualifiedName();
if (previousClass != null && className.startsWith(previousClass) && className.charAt(previousClass.length()) == '.') {
continue;
}
previousClass = className;
// XXX - debug
System.out.println("\n>>> Generating beaninfo for " + className + "...");
// Examine the javadoc tags and look for the the @beaninfo tag
// This first block looks at the javadoc for the class
Tag[] tags = classes[cnt].tags();
for (int i = 0; i < tags.length; i++) {
if (tags[i].kind().equalsIgnoreCase("@beaninfo")) {
if (DEBUG)
System.out.println("GenDocletBeanInfo: found @beaninfo tagged Class: " + tags[i].text());
dbi = genDocletInfo(tags[i].text(), classes[cnt].name());
dochash.put(dbi.name, dbi);
break;
}
}
// This block looks at the javadoc for the class methods.
int startPos = -1;
MethodDoc[] methods = classes[cnt].methods();
for (int j = 0; j < methods.length; j++) {
// actually don't "introspect" - look for all
// methods with a @beaninfo tag
tags = methods[j].tags();
for (int x = 0; x < tags.length; x++) {
if (tags[x].kind().equalsIgnoreCase("@beaninfo")) {
if ((methods[j].name().startsWith("get")) || (methods[j].name().startsWith("set")))
startPos = 3;
else if (methods[j].name().startsWith("is"))
startPos = 2;
else
startPos = 0;
String propDesc = Introspector.decapitalize((methods[j].name()).substring(startPos));
if (DEBUG)
System.out.println("GenDocletBeanInfo: found @beaninfo tagged Method: " + tags[x].text());
dbi = genDocletInfo(tags[x].text(), propDesc);
dochash.put(dbi.name, dbi);
break;
}
}
}
if (DEBUG) {
// dump our classes doc beaninfo
System.out.println(">>>>DocletBeanInfo for class: " + classes[cnt].name());
Enumeration e = dochash.elements();
while (e.hasMoreElements()) {
DocBeanInfo db = (DocBeanInfo) e.nextElement();
System.out.println(db.toString());
}
}
// Use the generator to create the beaninfo code for the class.
generator.genBeanInfo(classes[cnt].containingPackage().name(), classes[cnt].name(), dochash);
// reset the values!
dochash.clear();
}
// end for loop
return true;
}
use of com.sun.javadoc.Tag in project cytoscape-api by cytoscape.
the class AbstractTagletTester method testToStringArray.
@Test
public void testToStringArray() {
Tag t = mock(Tag.class);
when(t.text()).thenReturn("test text");
Tag t2 = mock(Tag.class);
when(t2.text()).thenReturn("test text");
Tag[] tags = new Tag[] { t, t2 };
assertNotNull(taglet.toString(tags));
}
use of com.sun.javadoc.Tag in project cytoscape-api by cytoscape.
the class AbstractTagletTester method testToString.
@Test
public void testToString() {
Tag t = mock(Tag.class);
when(t.text()).thenReturn("test text");
assertNotNull(taglet.toString(t));
}
Aggregations