You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlbeans.apache.org by pc...@apache.org on 2004/03/04 04:07:44 UTC
cvs commit: xml-xmlbeans/v2/test/src/jamtest/tests/org/apache/xmlbeans/test/jam JamTestBase.java
pcal 2004/03/03 19:07:43
Modified: v2 build.xml
v2/src/binding/org/apache/xmlbeans/impl/binding/compile
Java2SchemaTask.java
v2/src/jam java.g
v2/src/jam/org/apache/xmlbeans/impl/jam JElement.java
v2/src/jam/org/apache/xmlbeans/impl/jam/editable
EElement.java
v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl
EClassImpl.java EElementImpl.java
v2/src/jam/org/apache/xmlbeans/impl/jam/internal
BaseJElement.java BuiltinJClass.java
JPropertyImpl.java
v2/src/jam/org/apache/xmlbeans/impl/jam/provider
DefaultCommentProcessor.java
v2/test/src/jamtest build.xml
v2/test/src/jamtest/dummy15classes/org/apache/xmlbeans/test/jam/dummyclasses/jsr175
AnnotatedClass.java
v2/test/src/jamtest/dummyclasses/org/apache/xmlbeans/test/jam/dummyclasses
HeavilyCommented.java
v2/test/src/jamtest/tests/org/apache/xmlbeans/test/jam
JamTestBase.java
Added: v2/test/src/jamtest/dummy15classes/org/apache/xmlbeans/test/jam/dummyclasses/jsr175
RFEAnnotation.java RFEAnnotationImpl.java
Log:
jam: various updates
Revision Changes Path
1.46 +90 -85 xml-xmlbeans/v2/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/build.xml,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- build.xml 3 Mar 2004 22:56:38 -0000 1.45
+++ build.xml 4 Mar 2004 03:07:43 -0000 1.46
@@ -187,10 +187,6 @@
</junit>
</target>
- <target name="drtjam">
- <ant dir='test/src/jamtest' target='all' inheritAll='false' />
- </target>
-
<target name="builddrt" depends="drt.jar, random.jar, eric"/>
<target name="eric" depends="erictest.jar"/>
@@ -523,30 +519,6 @@
</copy>
</target>
- <target name="jamdocs" depends="xbean">
- <property name="docs.dir" value="build/docs" />
- <delete dir="${docs.dir}" />
- <mkdir dir="${docs.dir}" />
- <javadoc packagenames="*" classpath="${javadoc.path}" destdir="${docs.dir}/reference" windowtitle="XMLBeans Documentation" source="1.4" stylesheetfile="docs/stylesheet.css">
- <fileset dir="src" includes="**/jam/*.java,**/jeti/**/*.java" casesensitive="yes">
- <exclude name="**/*Test*" />
- </fileset>
- <link href="http://e-docs.bea.com/wls/docs81/javadocs/" />
- <link href="http://java.sun.com/j2se/1.4.2/docs/api/" />
- <link href="http://java.sun.com/j2ee/1.4/docs/api/" />
- <link href="http://xml.apache.org/xerces-j/apiDocs/" />
- <classpath>
- <pathelement location="build/ar/xbean.jar" />
- </classpath>
- </javadoc>
- <copy file="docs/xmlbeans.css" tofile="${docs.dir}/xmlbeans.css" />
- <copy todir="${docs.dir}/guide">
- <fileset dir="docs/guide" />
- </copy>
- <copy todir="${docs.dir}/images">
- <fileset dir="docs/images" />
- </copy>
- </target>
<!-- stream conformance tests ======================================= -->
@@ -780,63 +752,6 @@
</javac>
</target>
-
- <!-- jam target =============================================== -->
-
- <target name='jam' depends='jam.parser,jam.compile'/>
-
- <property name='jam_gendir' value='build/generatedsrc'/>
-
- <target name='jam.clean'>
- <delete dir='build/classes/jam'/>
- <delete dir='build/generatedsrc'/>
- </target>
-
- <target name="jam.parser.check">
- <uptodate property="jam.parser.notRequired" targetfile="${jam_gendir}/JavaParser.java">
- <srcfiles dir="src/jam" includes="java.g"/>
- </uptodate>
- </target>
-
- <target name='jam.parser' depends="jam.parser.check" unless="jam.parser.notRequired">
- <delete dir='${jam_gendir}'/>
- <mkdir dir='${jam_gendir}'/>
-
- <antlr outputdirectory='${jam_gendir}' target='src/jam/java.g'
- debug='false'>
- <classpath>
- <pathelement location='external/lib/antlr.jar'/>
- <pathelement path='${java.class.path}'/>
- <pathelement path='build/classes'/>
- </classpath>
- </antlr>
- </target>
-
- <target name="jam.compile.check">
- <uptodate property="jam.compile.notRequired" targetfile="build/classes/jam/.flagfile">
- <srcfiles dir="${jam_gendir}" includes="**/*"/>
- <srcfiles dir="src/jam" includes="**/*"/>
- </uptodate>
- </target>
-
- <target name='jam.compile' depends='dirs, jam.parser, jam.compile.check'
- unless="jam.compile.notRequired" >
-
- <mkdir dir='build/classes/jam'/>
-
- <javac srcdir='src/jam' destdir='build/classes/jam' source='1.4' debug='on'>
- <src path='src/jam'/>
- <src path='${jam_gendir}'/>
- <classpath>
- <pathelement location='external/lib/antlr.jar'/>
- <pathelement path='${java.class.path}'/>
- <pathelement path='build/classes'/>
- </classpath>
- </javac>
-
- <touch file="build/classes/jam/.flagfile" />
- </target>
-
<!-- binding target =============================================== -->
<target name="binding.classes" depends="dirs, repackage.classes, typeimpl.classes, xmlpublic.classes, typestore.classes, configschema.classes, xmlcomp.classes, jam, jsr173.jar">
@@ -1241,5 +1156,95 @@
-->
+
+ <!-- jam targets ============================================== -->
+
+ <target name='jam' depends='jam.parser,jam.compile'/>
+
+ <property name='jam_gendir' value='build/generatedsrc'/>
+
+ <target name='jam.clean'>
+ <delete dir='build/classes/jam'/>
+ <delete dir='build/generatedsrc'/>
+ </target>
+
+ <target name="jam.parser.check">
+ <uptodate property="jam.parser.notRequired" targetfile="${jam_gendir}/JavaParser.java">
+ <srcfiles dir="src/jam" includes="java.g"/>
+ </uptodate>
+ </target>
+
+ <target name='jam.parser' depends="jam.parser.check" unless="jam.parser.notRequired">
+ <delete dir='${jam_gendir}'/>
+ <mkdir dir='${jam_gendir}'/>
+
+ <antlr outputdirectory='${jam_gendir}' target='src/jam/java.g'
+ debug='false'>
+ <classpath>
+ <pathelement location='external/lib/antlr.jar'/>
+ <pathelement path='${java.class.path}'/>
+ <pathelement path='build/classes'/>
+ </classpath>
+ </antlr>
+ </target>
+
+ <target name="jam.compile.check">
+ <uptodate property="jam.compile.notRequired" targetfile="build/classes/jam/.flagfile">
+ <srcfiles dir="${jam_gendir}" includes="**/*"/>
+ <srcfiles dir="src/jam" includes="**/*"/>
+ </uptodate>
+ </target>
+
+ <target name='jam.compile' depends='dirs, jam.parser, jam.compile.check'
+ unless="jam.compile.notRequired" >
+
+ <mkdir dir='build/classes/jam'/>
+
+ <javac srcdir='src/jam' destdir='build/classes/jam' source='1.4' debug='on'>
+ <src path='src/jam'/>
+ <src path='${jam_gendir}'/>
+ <classpath>
+ <pathelement location='external/lib/antlr.jar'/>
+ <pathelement path='${java.class.path}'/>
+ <pathelement path='build/classes'/>
+ </classpath>
+ </javac>
+
+ <touch file="build/classes/jam/.flagfile" />
+ </target>
+
+ <target name="drtjam">
+ <ant dir='test/src/jamtest' target='all' inheritAll='false' />
+ </target>
+
+ <target name="jamdocs" depends="xbean">
+ <property name="docs.dir" value="build/docs" />
+ <delete dir="${docs.dir}" />
+ <mkdir dir="${docs.dir}" />
+ <javadoc packagenames="*" classpath="${javadoc.path}" destdir="${docs.dir}/reference" windowtitle="XMLBeans Documentation" source="1.4" stylesheetfile="docs/stylesheet.css">
+ <fileset dir="src" includes="**/jam/*.java,**/jeti/**/*.java" casesensitive="yes">
+ <exclude name="**/*Test*" />
+ </fileset>
+ <link href="http://e-docs.bea.com/wls/docs81/javadocs/" />
+ <link href="http://java.sun.com/j2se/1.4.2/docs/api/" />
+ <link href="http://java.sun.com/j2ee/1.4/docs/api/" />
+ <link href="http://xml.apache.org/xerces-j/apiDocs/" />
+ <classpath>
+ <pathelement location="build/ar/xbean.jar" />
+ </classpath>
+ </javadoc>
+ <copy file="docs/xmlbeans.css" tofile="${docs.dir}/xmlbeans.css" />
+ <copy todir="${docs.dir}/guide">
+ <fileset dir="docs/guide" />
+ </copy>
+ <copy todir="${docs.dir}/images">
+ <fileset dir="docs/images" />
+ </copy>
+ </target>
+
+ <target name='jam.jars' depends='jam'>
+ <jar jarfile="build/jam.jar" basedir="build/classes/jam"/>
+ <jar jarfile="build/jamsrc.jar" basedir="src/jam"/>
+ </target>
</project>
1.18 +3 -1 xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/Java2SchemaTask.java
Index: Java2SchemaTask.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/Java2SchemaTask.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- Java2SchemaTask.java 12 Feb 2004 20:06:07 -0000 1.17
+++ Java2SchemaTask.java 4 Mar 2004 03:07:43 -0000 1.18
@@ -24,6 +24,7 @@
import java.io.File;
import java.io.IOException;
+import java.util.StringTokenizer;
/**
* Ant task definition for binding in the start-with-java case.
@@ -118,7 +119,8 @@
if (list.length == 0) throw new BuildException("srcDir attribute required");
if (list.length > 1) throw new BuildException("multiple srcDirs NYI");
JFileSet fs = jf.createFileSet(new File(list[0]));
- fs.include(mIncludes);
+ StringTokenizer st = new StringTokenizer(mIncludes,",");
+ while(st.hasMoreTokens()) fs.include(st.nextToken().trim());
String classpathString = null;
if (mClasspath != null) {
//this will be removed after jam factory is refactored
1.9 +1 -1 xml-xmlbeans/v2/src/jam/java.g
Index: java.g
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/java.g,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- java.g 3 Mar 2004 08:25:26 -0000 1.8
+++ java.g 4 Mar 2004 03:07:43 -0000 1.9
@@ -214,7 +214,7 @@
private void applyJavadocs(EMember member) {
if (mLastJavadoc != null) {
- member.addNewComment().setText(mLastJavadoc);
+ member.createComment().setText(mLastJavadoc);
if (VERBOSE) {
System.out.println("adding javadocs to "+member.getSimpleName()+":");
System.out.println(mLastJavadoc);
1.6 +12 -3 xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/JElement.java
Index: JElement.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/JElement.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- JElement.java 3 Mar 2004 03:57:49 -0000 1.5
+++ JElement.java 4 Mar 2004 03:07:43 -0000 1.6
@@ -97,10 +97,10 @@
public JElement getParent();
/**
- * <p>Returns the comments associated with this abstraction.
- * Returns an empty array if there are no comments.</p>
+ * <p>Returns the comment associated with this abstraction.
+ * Returns null if it has no comment.</p>
*/
- public JComment[] getComments();
+ public JComment getComment();
/**
* <p>Returns a simple name of this abstraction. The exact format
@@ -138,5 +138,14 @@
* we get to 175-land.
*/
public JAnnotation[] getAnnotations(String named);
+
+ /**
+ * @deprecated multiple comments per element are no longer supported.
+ * This always returns an array of length 1 containing the comment
+ * returned by getComment(), or an empty array if there is no comment.
+ * This method will soon be removed.
+ */
+ public JComment[] getComments();
+
}
1.7 +3 -3 xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/EElement.java
Index: EElement.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/EElement.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- EElement.java 3 Mar 2004 08:25:26 -0000 1.6
+++ EElement.java 4 Mar 2004 03:07:43 -0000 1.7
@@ -23,11 +23,11 @@
*/
public interface EElement extends JElement {
- public EComment[] getEditableComments();
+ public EComment getEditableComment();
- public EComment addNewComment();
+ public EComment createComment();
- public void removeComment(EComment comment);
+ public void removeComment();
public void setSimpleName(String name);
1.9 +1 -1 xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EClassImpl.java
Index: EClassImpl.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EClassImpl.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- EClassImpl.java 3 Mar 2004 03:57:49 -0000 1.8
+++ EClassImpl.java 4 Mar 2004 03:07:43 -0000 1.9
@@ -27,7 +27,7 @@
/**
*
- * @author Patrick Calahan <pc...@bea.com>
+ * @author Patrick Calahan <jd...@bea.com>
*/
public class EClassImpl extends EMemberImpl
implements EClass, JClassRef, JClassRefContext
1.9 +15 -17 xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EElementImpl.java
Index: EElementImpl.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EElementImpl.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- EElementImpl.java 3 Mar 2004 08:25:26 -0000 1.8
+++ EElementImpl.java 4 Mar 2004 03:07:43 -0000 1.9
@@ -34,7 +34,7 @@
private ESourcePosition mPosition = null;
private JClassLoader mClassLoader;
private List mAnnotations = null;
- private List mComments = null;
+ private EComment mComment = null;
// ========================================================================
// Constructors
@@ -63,10 +63,6 @@
return mPosition;
}
- public JComment[] getComments() {
- return getEditableComments();
- }
-
public JAnnotation[] getAnnotations() {
return getEditableAnnotations();
}
@@ -75,25 +71,23 @@
return getEditableAnnotation(named);
}
+ public JComment getComment() {
+ return getEditableComment();
+ }
+
// ========================================================================
// EElement implementation
- public EComment[] getEditableComments() {
- if (mComments == null) mComments = new ArrayList();
- EComment[] out = new EComment[mComments.size()];
- mComments.toArray(out);
- return out;
+ public EComment getEditableComment() {
+ return mComment;
}
- public EComment addNewComment() {
- if (mComments == null) mComments = new ArrayList();
- EComment out = new ECommentImpl();
- mComments.add(out);
- return out;
+ public EComment createComment() {
+ return mComment = new ECommentImpl();
}
- public void removeComment(EComment comment) {
- if (mComments != null) mComments.remove(comment);
+ public void removeComment() {
+ mComment = null;
}
public void setSimpleName(String name) {
@@ -181,4 +175,8 @@
return getAnnotations(); //FIXME remove this method please
}
+ public JComment[] getComments() {
+ JComment c = getComment();
+ return (c == null) ? new JComment[0] : new JComment[] {c};
+ }
}
1.7 +27 -16 xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/internal/BaseJElement.java
Index: BaseJElement.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/internal/BaseJElement.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- BaseJElement.java 12 Feb 2004 20:06:15 -0000 1.6
+++ BaseJElement.java 4 Mar 2004 03:07:43 -0000 1.7
@@ -119,28 +119,18 @@
return out;
}
- public final JComment[] getComments() {
- if (mComments == null) {
- List list = getTempList();
- getLocalComments(list);
- /* if (mContext.getExtraMarkupStore() != null) {
- mContext.getExtraMarkupStore().getComments(this,list);
- }*/
- if (list.size() == 0) {
- mComments = NO_COMMENT;
- } else {
- mComments = new JComment[list.size()];
- list.toArray(mComments);
- }
- }
- return mComments; // FIXME do we need to return a copy?
- }
public final JAnnotation getAnnotation(String named) {
JAnnotation[] anns = getAnnotations(named);
return (anns.length == 0) ? null : anns[0];
}
+ public JComment getComment() {
+ JComment[] out = getComments();
+ if (out.length == 0) return null;
+ return out[0];
+ }
+
// ========================================================================
// Object implementation
@@ -204,5 +194,26 @@
public int hashCode() {
return getQualifiedName().hashCode();
}
+
+ // ========================================================================
+ // Deprecated method impls
+
+ public final JComment[] getComments() {
+ if (mComments == null) {
+ List list = getTempList();
+ getLocalComments(list);
+ /* if (mContext.getExtraMarkupStore() != null) {
+ mContext.getExtraMarkupStore().getComments(this,list);
+ }*/
+ if (list.size() == 0) {
+ mComments = NO_COMMENT;
+ } else {
+ mComments = new JComment[list.size()];
+ list.toArray(mComments);
+ }
+ }
+ return mComments; // FIXME do we need to return a copy?
+ }
+
}
1.5 +2 -0 xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/internal/BuiltinJClass.java
Index: BuiltinJClass.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/internal/BuiltinJClass.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- BuiltinJClass.java 12 Feb 2004 20:06:15 -0000 1.4
+++ BuiltinJClass.java 4 Mar 2004 03:07:43 -0000 1.5
@@ -65,6 +65,8 @@
public JComment[] getComments() { return BaseJElement.NO_COMMENT; }
+ public JComment getComment() { return null; }
+
// ========================================================================
// JMember implementation
1.4 +52 -47 xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/internal/JPropertyImpl.java
Index: JPropertyImpl.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/internal/JPropertyImpl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- JPropertyImpl.java 12 Feb 2004 20:06:15 -0000 1.3
+++ JPropertyImpl.java 4 Mar 2004 03:07:43 -0000 1.4
@@ -53,49 +53,49 @@
// process getters
//
if (name.startsWith("get") && name.length() > 3 || name.startsWith("is") && name.length() > 2) {
- JClass type = methods[i].getReturnType();
- if (type == null) continue; // must have a type and have
- if (methods[i].getParameters().length > 0) continue; //no params
+ JClass type = methods[i].getReturnType();
+ if (type == null) continue; // must have a type and have
+ if (methods[i].getParameters().length > 0) continue; //no params
if (name.startsWith("get"))
name = name.substring(3);
else
name = name.substring(2);
- JPropertyImpl prop = (JPropertyImpl)name2prop.get(name);
- if (prop == null) {
- prop = new JPropertyImpl(name,methods[i],null,type);
- name2prop.put(name,prop);
- } else {
- if (type.equals(prop.getType())) {
- // if it's the same type, cool - just add the getter
- prop.mGetter = methods[i];
- } else {
- // Otherwise, getter/setter types are mismatched and we
- // don't have a property. REVIEW ok?
- name2prop.remove(name);
- }
- }
+ JPropertyImpl prop = (JPropertyImpl)name2prop.get(name);
+ if (prop == null) {
+ prop = new JPropertyImpl(name,methods[i],null,type);
+ name2prop.put(name,prop);
+ } else {
+ if (type.equals(prop.getType())) {
+ // if it's the same type, cool - just add the getter
+ prop.mGetter = methods[i];
+ } else {
+ // Otherwise, getter/setter types are mismatched and we
+ // don't have a property. REVIEW ok?
+ name2prop.remove(name);
+ }
+ }
}
//
// process setters
//
if (name.startsWith("set") && name.length() > 3) {
- if (methods[i].getParameters().length != 1) continue; //1 param reqd
- JClass type = methods[i].getParameters()[0].getType();
- name = name.substring(3);
- JPropertyImpl prop = (JPropertyImpl)name2prop.get(name);
- if (prop == null) {
- prop = new JPropertyImpl(name,null,methods[i],type);
- name2prop.put(name,prop);
- } else {
- if (type.equals(prop.getType())) {
- // if it's the same type, cool - just add the getter
- prop.mSetter = methods[i];
- } else {
- // Otherwise, getter/setter types are mismatched and we
- // don't have a property. REVIEW ok?
- name2prop.remove(name);
- }
- }
+ if (methods[i].getParameters().length != 1) continue; //1 param reqd
+ JClass type = methods[i].getParameters()[0].getType();
+ name = name.substring(3);
+ JPropertyImpl prop = (JPropertyImpl)name2prop.get(name);
+ if (prop == null) {
+ prop = new JPropertyImpl(name,null,methods[i],type);
+ name2prop.put(name,prop);
+ } else {
+ if (type.equals(prop.getType())) {
+ // if it's the same type, cool - just add the getter
+ prop.mSetter = methods[i];
+ } else {
+ // Otherwise, getter/setter types are mismatched and we
+ // don't have a property. REVIEW ok?
+ name2prop.remove(name);
+ }
+ }
}
}
JProperty[] out = new JProperty[name2prop.values().size()];
@@ -114,9 +114,9 @@
* case.</p>
*/
public JPropertyImpl(String name,
- JMethod getter,
- JMethod setter,
- JClass type)
+ JMethod getter,
+ JMethod setter,
+ JClass type)
{
mName = name;
mGetter = getter;
@@ -170,9 +170,9 @@
*/
public JAnnotation[] getAnnotations() {
return combine((mGetter == null) ?
- BaseJElement.NO_ANNOTATION : mGetter.getAnnotations(),
- (mSetter == null) ?
- BaseJElement.NO_ANNOTATION : mSetter.getAnnotations());
+ BaseJElement.NO_ANNOTATION : mGetter.getAnnotations(),
+ (mSetter == null) ?
+ BaseJElement.NO_ANNOTATION : mSetter.getAnnotations());
}
/**
@@ -181,9 +181,9 @@
*/
public JAnnotation[] getAnnotations(String named) {
return combine((mGetter == null) ?
- BaseJElement.NO_ANNOTATION : mGetter.getAnnotations(named),
- (mSetter == null) ?
- BaseJElement.NO_ANNOTATION : mSetter.getAnnotations(named));
+ BaseJElement.NO_ANNOTATION : mGetter.getAnnotations(named),
+ (mSetter == null) ?
+ BaseJElement.NO_ANNOTATION : mSetter.getAnnotations(named));
}
/**
@@ -200,11 +200,16 @@
}
}
+ public JComment getComment() {
+ JComment[] c = getComments();
+ return (c == null) ? null : c[0];
+ }
+
public JComment[] getComments() {
return combine((mGetter == null) ?
- BaseJElement.NO_COMMENT : mGetter.getComments(),
- (mSetter == null) ?
- BaseJElement.NO_COMMENT : mSetter.getComments());
+ BaseJElement.NO_COMMENT : mGetter.getComments(),
+ (mSetter == null) ?
+ BaseJElement.NO_COMMENT : mSetter.getComments());
}
public JElement getParent() {
@@ -213,7 +218,7 @@
public JSourcePosition getSourcePosition() {
return mGetter != null ?
- mGetter.getSourcePosition() : mSetter.getSourcePosition();
+ mGetter.getSourcePosition() : mSetter.getSourcePosition();
}
// ========================================================================
1.3 +73 -27 xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/provider/DefaultCommentProcessor.java
Index: DefaultCommentProcessor.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/provider/DefaultCommentProcessor.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DefaultCommentProcessor.java 3 Mar 2004 08:25:26 -0000 1.2
+++ DefaultCommentProcessor.java 4 Mar 2004 03:07:43 -0000 1.3
@@ -56,35 +56,81 @@
// Protected methods
protected void visit(EElement element) {
- EComment[] comments = element.getEditableComments();
- if (comments == null || comments.length == 0) return;
- for(int i=0; i<comments.length; i++) {
- String text = comments[i].getText().trim();
- if (!text.startsWith("/*")) {
- element.removeComment(comments[i]);
- } else {
- StringWriter out = new StringWriter();
- BufferedReader in = new BufferedReader(new StringReader(text));
- String line;
- boolean addBreak = false;
- try {
- while((line = in.readLine()) != null) {
- line = line.trim();
- if (line.equals("*/")) continue;
- int offset = line.indexOf('*');
- do {
- offset++;
- } while(offset < line.length() && line.charAt(offset) == '*');
- if (addBreak) out.write('\n');
- if (offset >= line.length()) continue;
- out.write(line.substring(offset+1).trim());
- addBreak = true;
+ EComment comment = element.getEditableComment();
+ if (comment == null) return;
+ String text = comment.getText().trim();
+ if (!text.startsWith("/*")) {
+ element.removeComment();
+ return;
+ }
+ BufferedReader in = new BufferedReader(new StringReader(text));
+ StringWriter commentText = new StringWriter();
+ String nextLine = eatDocChunk(in,commentText);
+ processComment(element,commentText.toString());
+ while(nextLine != null) {
+ StringWriter tagText = new StringWriter();
+ tagText.write(nextLine);
+ tagText.write('\n');
+ nextLine = eatDocChunk(in,tagText);
+ processJavadocTag(element,tagText.toString());
+ }
+ }
+
+ protected void processJavadocTag(EElement element, String tagline) {
+
+ }
+
+ protected void processComment(EElement commentedElement,
+ String trimmedComment) {
+ commentedElement.getEditableComment().setText(trimmedComment);
+ }
+
+ // ========================================================================
+ // Private methods
+
+ /**
+ * <p>Writes the trimmed contents of the comment text provided by the
+ * BufferedReader in the given BufferedWriter, until either a javadoc
+ * tag is encountered (line starting with '@') or the end of the comment
+ * section is encountered.</p>
+ *
+ * @return The next line read off of the input buffer which starts
+ * a new section (starting with '@'), or null if the end of the comment
+ * was reached.
+ */
+ private String eatDocChunk(BufferedReader in, Writer out) {
+ String line;
+ boolean firstLineYet = false;
+ int breaksToAdd = 0;
+ try {
+ while((line = in.readLine()) != null) {
+ line = getTrimmedLine(line);
+ if (line.startsWith("@")) { // are we starting a javadoc tag?
+ return line;
+ } else {
+ if (firstLineYet) breaksToAdd++;
+ if (line.length() > 0) {
+ firstLineYet = true;
+ for(int i=0; i<breaksToAdd; i++) out.write('\n');
+ breaksToAdd = 0;
+ out.write(line);
}
- comments[i].setText(out.toString());
- } catch(IOException veryUnexpected) {
- veryUnexpected.printStackTrace();
}
}
+ } catch(IOException veryUnexpected) {
+ veryUnexpected.printStackTrace();
}
+ return null;
+ }
+
+ private String getTrimmedLine(String rawLine) {
+ rawLine = rawLine.trim();
+ int offset = rawLine.indexOf('*');
+ if (offset == -1) return rawLine;
+ do {
+ offset++;
+ } while(offset < rawLine.length() && rawLine.charAt(offset) == '*');
+ if (offset >= rawLine.length()) return "";
+ return rawLine.substring(offset+1).trim();
}
-}
+}
\ No newline at end of file
1.9 +5 -2 xml-xmlbeans/v2/test/src/jamtest/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/test/src/jamtest/build.xml,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- build.xml 3 Mar 2004 00:01:43 -0000 1.8
+++ build.xml 4 Mar 2004 03:07:43 -0000 1.9
@@ -57,9 +57,7 @@
</classpath>
<formatter type='plain' usefile='false'/>
-
<test name='org.apache.xmlbeans.test.jam.ParserJamTest'/>
-
<test name='org.apache.xmlbeans.test.jam.SourcesJamTest'/>
<test name='org.apache.xmlbeans.test.jam.ClassesJamTest'/>
@@ -72,9 +70,14 @@
<target name='tiger' depends='tiger.build,tiger.run'/>
+ <target name='tiger.clean' >
+ <delete dir='${dummy-dir}'/>
+ </target>
+
<target name='tiger.build' >
<mkdir dir='${dummy-dir}'/>
<javac
+ source='1.5'
srcdir='dummy15classes'
destdir='${dummy-dir}'
classpathref='classpath'
1.2 +3 -7 xml-xmlbeans/v2/test/src/jamtest/dummy15classes/org/apache/xmlbeans/test/jam/dummyclasses/jsr175/AnnotatedClass.java
Index: AnnotatedClass.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/test/src/jamtest/dummy15classes/org/apache/xmlbeans/test/jam/dummyclasses/jsr175/AnnotatedClass.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AnnotatedClass.java 1 Mar 2004 00:10:19 -0000 1.1
+++ AnnotatedClass.java 4 Mar 2004 03:07:43 -0000 1.2
@@ -1,13 +1,9 @@
package org.apache.xmlbeans.test.jam.dummyclasses.jsr175;
-public @interface RequestForEnhancement {
- int id(); // Unique ID number associated with RFE
- String synopsis(); // Synopsis of RFE
- String engineer() default "[unassigned]";
- String date() default "[unimplemented]";
-}
-@RequestForEnhancement(
+import org.apache.xmlbeans.test.jam.dummyclasses.jsr175.RFEAnnotation;
+
+@RFEAnnotation(
id = 4561414,
synopsis = "Balance the federal budget"
)
1.1 xml-xmlbeans/v2/test/src/jamtest/dummy15classes/org/apache/xmlbeans/test/jam/dummyclasses/jsr175/RFEAnnotation.java
Index: RFEAnnotation.java
===================================================================
/* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.xmlbeans.test.jam.dummyclasses.jsr175;
/**
*
* @author Patrick Calahan <pc...@bea.com>
*/
public @interface RFEAnnotation {
int id(); // Unique ID number associated with RFE
String synopsis(); // Synopsis of RFE
String engineer() default "[unassigned]";
String date() default "[unimplemented]";
}
1.1 xml-xmlbeans/v2/test/src/jamtest/dummy15classes/org/apache/xmlbeans/test/jam/dummyclasses/jsr175/RFEAnnotationImpl.java
Index: RFEAnnotationImpl.java
===================================================================
/* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.xmlbeans.test.jam.dummyclasses.jsr175;
/**
*
* @author Patrick Calahan <pc...@bea.com>
*/
public class RFEAnnotationImpl implements RFEAnnotation {
public int id() { return 0;}
public String synopsis() { return null;}
public String engineer() { return null; }
public String date() { return null;}
public java.lang.Class annotationType() { return getClass(); }
}
1.2 +0 -4 xml-xmlbeans/v2/test/src/jamtest/dummyclasses/org/apache/xmlbeans/test/jam/dummyclasses/HeavilyCommented.java
Index: HeavilyCommented.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/test/src/jamtest/dummyclasses/org/apache/xmlbeans/test/jam/dummyclasses/HeavilyCommented.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- HeavilyCommented.java 3 Mar 2004 08:25:26 -0000 1.1
+++ HeavilyCommented.java 4 Mar 2004 03:07:43 -0000 1.2
@@ -14,10 +14,6 @@
*/
package org.apache.xmlbeans.test.jam.dummyclasses;
-import org.apache.xmlbeans.test.jam.dummyclasses.ejb.MyEjbException;
-
-import java.net.MalformedURLException;
-
/**
*
* @author Patrick Calahan <pc...@bea.com>
1.10 +0 -1 xml-xmlbeans/v2/test/src/jamtest/tests/org/apache/xmlbeans/test/jam/JamTestBase.java
Index: JamTestBase.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/test/src/jamtest/tests/org/apache/xmlbeans/test/jam/JamTestBase.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- JamTestBase.java 3 Mar 2004 08:25:26 -0000 1.9
+++ JamTestBase.java 4 Mar 2004 03:07:43 -0000 1.10
@@ -137,7 +137,6 @@
private static final boolean VERBOSE = false;
-
// ========================================================================
// Variables
---------------------------------------------------------------------
To unsubscribe, e-mail: xmlbeans-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-cvs-help@xml.apache.org