You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2009/12/10 09:22:29 UTC
svn commit: r889132 - in
/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main:
java/org/apache/myfaces/tobago/apt/
java/org/apache/myfaces/tobago/apt/generate/
resources/org/apache/myfaces/tobago/apt/
Author: bommel
Date: Thu Dec 10 08:22:27 2009
New Revision: 889132
URL: http://svn.apache.org/viewvc?rev=889132&view=rev
Log:
(TOBAGO-836) Generated Classes should also contain deprecation tags
(TOBAGO-815) Type Measure doesn't work corretly with literals on JSPs
initial fix.
Modified:
myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/CreateComponentAnnotationVisitor.java
myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/TaglibAnnotationVisitor.java
myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/ComponentInfo.java
myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/PropertyInfo.java
myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.1.stg
myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.2.stg
Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/CreateComponentAnnotationVisitor.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/CreateComponentAnnotationVisitor.java?rev=889132&r1=889131&r2=889132&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/CreateComponentAnnotationVisitor.java (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/CreateComponentAnnotationVisitor.java Thu Dec 10 08:22:27 2009
@@ -20,6 +20,7 @@
import com.sun.mirror.apt.AnnotationProcessorEnvironment;
import com.sun.mirror.apt.Filer;
import com.sun.mirror.declaration.ClassDeclaration;
+import com.sun.mirror.declaration.Declaration;
import com.sun.mirror.declaration.InterfaceDeclaration;
import com.sun.mirror.declaration.MethodDeclaration;
import com.sun.mirror.declaration.TypeDeclaration;
@@ -173,6 +174,8 @@
= new ComponentInfo(decl.getQualifiedName(), componentTag.uiComponent(), componentTag.rendererType());
componentInfo.setSuperClass(componentTag.uiComponentBaseClass());
componentInfo.setComponentFamily(componentTag.componentFamily());
+ componentInfo.setDescription(getDescription(decl));
+ componentInfo.setDeprecated(decl.getAnnotation(Deprecated.class) != null);
List<String> elMethods = Collections.emptyList();
if (is12()) {
elMethods = checkForElMethods(componentInfo, componentTag.interfaces());
@@ -366,7 +369,7 @@
return;
}
PropertyInfo propertyInfo = new PropertyInfo(attributeStr);
- propertyInfo.setAllowdValues(uiComponentTagAttribute.allowedValues());
+ propertyInfo.setAllowedValues(uiComponentTagAttribute.allowedValues());
if (tagAttribute != null) {
propertyInfo.setBodyContent(tagAttribute.bodyContent());
propertyInfo.setTagAttribute(true);
@@ -399,10 +402,25 @@
uiComponentTagAttribute.defaultCode().length() > 0 ? uiComponentTagAttribute.defaultCode() : null);
propertyInfo.setMethodSignature(uiComponentTagAttribute.methodSignature());
propertyInfo.setDeprecated(decl.getAnnotation(Deprecated.class) != null);
+ propertyInfo.setDescription(getDescription(decl));
properties.add(propertyInfo);
}
}
}
+ private String getDescription(Declaration d) {
+ String comment = d.getDocComment();
+ if (comment != null) {
+ int index = comment.indexOf('@');
+ if (index != -1) {
+ comment = comment.substring(0, index);
+ }
+ comment = comment.trim();
+ if (comment.length() > 0) {
+ return comment;
+ }
+ }
+ return null;
+ }
protected void addPropertyForTagOnly(MethodDeclaration decl, List<PropertyInfo> properties) {
TagAttribute tagAttribute = decl.getAnnotation(TagAttribute.class);
Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/TaglibAnnotationVisitor.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/TaglibAnnotationVisitor.java?rev=889132&r1=889131&r2=889132&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/TaglibAnnotationVisitor.java (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/TaglibAnnotationVisitor.java Thu Dec 10 08:22:27 2009
@@ -319,13 +319,16 @@
}
UIComponentTagAttribute attributeTag = decl.getAnnotation(UIComponentTagAttribute.class);
if (attributeTag != null) {
- if (null != attributeTag.type() && attributeTag.type().length > 0) {
- description.append("<br />Type: <code>" + (attributeTag.type().length == 1
- ? attributeTag.type()[0] : Arrays.toString(attributeTag.type())) + "</code>");
- }
- if (StringUtils.isNotEmpty(attributeTag.defaultValue())) {
- description.append("<br />Default: <code>" + attributeTag.defaultValue() + "</code>");
- }
+ if (null != attributeTag.type() && attributeTag.type().length > 0) {
+ description.append("<br />Type: <code>" + (attributeTag.type().length == 1
+ ? attributeTag.type()[0] : Arrays.toString(attributeTag.type())) + "</code>");
+ }
+ if (StringUtils.isNotEmpty(attributeTag.defaultValue())) {
+ description.append("<br />Default: <code>" + attributeTag.defaultValue() + "</code>");
+ }
+ if (attributeTag.allowedValues().length > 0) {
+ description.append("<br />Allowed Values: <code>" + attributeTag.allowedValues() + "</code>");
+ }
}
ExtensionTag extensionTag = decl.getAnnotation(ExtensionTag.class);
if (extensionTag != null) {
@@ -449,7 +452,9 @@
Element deferredValue = document.createElement("deferred-value");
String type = "java.lang.Object";
if (componentTagAttribute.expression().isValueExpression()) {
- if (componentTagAttribute.type().length == 1) {
+ if (componentTagAttribute.type().length == 1
+ // XXX fix me hack
+ && !"org.apache.myfaces.tobago.layout.Measure".equals(componentTagAttribute.type()[0])) {
type = componentTagAttribute.type()[0];
}
} else {
Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/ComponentInfo.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/ComponentInfo.java?rev=889132&r1=889131&r2=889132&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/ComponentInfo.java (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/ComponentInfo.java Thu Dec 10 08:22:27 2009
@@ -24,6 +24,8 @@
public class ComponentInfo extends TagInfo {
private boolean invokeOnComponent;
private boolean messages;
+ private String description;
+ private boolean deprecated;
public ComponentInfo(String sourceClass, String qualifiedName, String rendererType) {
super(sourceClass, qualifiedName, rendererType);
@@ -44,4 +46,20 @@
public void setMessages(boolean messages) {
this.messages = messages;
}
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDeprecated(boolean deprecated) {
+ this.deprecated = deprecated;
+ }
+
+ public boolean isDeprecated() {
+ return deprecated;
+ }
}
Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/PropertyInfo.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/PropertyInfo.java?rev=889132&r1=889131&r2=889132&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/PropertyInfo.java (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/java/org/apache/myfaces/tobago/apt/generate/PropertyInfo.java Thu Dec 10 08:22:27 2009
@@ -22,7 +22,7 @@
public class PropertyInfo {
private String name;
private String type;
- private String[] allowdValues;
+ private String[] allowedValues;
private String[] methodSignature;
private String defaultValue;
private String defaultCode;
@@ -32,6 +32,7 @@
private boolean deprecated;
private boolean bodyContent;
private boolean tagAttribute;
+ private String description;
public PropertyInfo() {
}
@@ -123,12 +124,12 @@
return name;
}
- public String[] getAllowdValues() {
- return allowdValues;
+ public String[] getAllowedValues() {
+ return allowedValues;
}
- public void setAllowdValues(String[] allowdValues) {
- this.allowdValues = allowdValues;
+ public void setAllowedValues(String[] allowdValues) {
+ this.allowedValues = allowdValues;
}
public String[] getMethodSignature() {
@@ -199,7 +200,7 @@
public PropertyInfo fill(PropertyInfo info) {
info.setName(name);
info.setType(type);
- info.setAllowdValues(allowdValues);
+ info.setAllowedValues(allowedValues);
info.setDefaultValue(defaultValue);
info.setDeprecated(deprecated);
info.setMethodSignature(methodSignature);
@@ -208,6 +209,7 @@
info.setLiteralOnly(literalOnly);
info.setMethodExpressionRequired(methodExpressionRequired);
info.setTagAttribute(tagAttribute);
+ info.setDescription(description);
return info;
}
@@ -228,4 +230,12 @@
public int hashCode() {
return name.hashCode();
}
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getDescription() {
+ return description;
+ }
}
Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.1.stg
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.1.stg?rev=889132&r1=889131&r2=889132&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.1.stg (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.1.stg Thu Dec 10 08:22:27 2009
@@ -51,10 +51,20 @@
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
-/**
- * UIComponent class, generated from template {@code component1.1.stg} with class
- * {@link <componentInfo.sourceClass>}.
+/**
+ <if(componentInfo.description)>
+ <componentInfo.description>
+ <endif>
+ * UIComponent class, generated from template {@code component1.2.stg} with class
+ * {@link <componentInfo.sourceClass>}.
+ <if(componentInfo.deprecated)>
+ @deprecated
+ <endif>
*/
+<if(componentInfo.deprecated)>
+@Deprecated
+
+<endif>
public class <componentInfo.className>
extends <componentInfo.superClassName> <first(componentInfo.interfaces):{ n | implements <n>}><rest(componentInfo.interfaces):{ n |, <n>}> {
@@ -217,8 +227,37 @@
>>
+createDescription(property) ::= <<
+<if(property.description)>
+/**
+<property.description>
+<if(property.defaultValue)>
+\<br /\>Default: \<code\><property.defaultValue>\</code\>
+<endif>
+<if(property.allowedValues)>
+\<br /\>Allowed Values: \<code\><property.allowedValues:allowedValue(); separator=",">\</code\>
+<endif>
+
+<if(property.deprecated)>
+@deprecated
+<endif>
+*/
+<endif>
+>>
+
+checkDeprecated(property) ::= <<
+<if(property.deprecated)>
+@Deprecated
+<endif>
+>>
+
+allowedValue() ::= <<
+<it>
+>>
+
IntegerProperty(property) ::= <<
+<createDescription(property)>
public <property.type> get<property.upperCamelCaseName>() {
if (<property.propertyName> != null) {
return <property.propertyName>;
@@ -237,6 +276,7 @@
<endif>
}
+<checkDeprecated(property)>
public void set<property.upperCamelCaseName>(<property.type> <property.propertyName>) {
this.<property.propertyName> = <property.propertyName>;
}
@@ -244,6 +284,7 @@
ObjectProperty(property) ::= <<
+<createDescription(property)>
public <property.type> get<property.upperCamelCaseName>() {
if (<property.propertyName> != null) {
return <property.propertyName>;
@@ -255,6 +296,7 @@
return null;
}
+<checkDeprecated(property)>
public void set<property.upperCamelCaseName>(<property.type> <property.propertyName>) {
this.<property.propertyName> = <property.propertyName>;
}
@@ -262,6 +304,7 @@
StringArrayProperty(property) ::= <<
+<createDescription(property)>
public String[] get<property.upperCamelCaseName>() {
if (<property.propertyName> != null) {
return <property.propertyName>;
@@ -289,6 +332,7 @@
return ArrayUtils.EMPTY_STRING_ARRAY;
}
+<checkDeprecated(property)>
public void set<property.upperCamelCaseName>(String[] <property.propertyName>) {
this.<property.propertyName> = <property.propertyName>;
}
@@ -296,6 +340,7 @@
booleanProperty(property) ::= <<
+<createDescription(property)>
public boolean is<property.upperCamelCaseName>() {
if (<property.propertyName> != null) {
return <property.propertyName>;
@@ -314,6 +359,7 @@
<endif>
}
+<checkDeprecated(property)>
public void set<property.upperCamelCaseName>(boolean <property.propertyName>) {
this.<property.propertyName> = <property.propertyName>;
}
@@ -321,6 +367,7 @@
BooleanProperty(property) ::= <<
+<createDescription(property)>
public Boolean get<property.upperCamelCaseName>() {
if (<property.propertyName> != null) {
return <property.propertyName>;
@@ -339,6 +386,7 @@
<endif>
}
+<checkDeprecated(property)>
public void set<property.upperCamelCaseName>(Boolean <property.propertyName>) {
this.<property.propertyName> = <property.propertyName>;
}
@@ -381,6 +429,7 @@
NormalProperty(property) ::= <<
+<createDescription(property)>
public <property.type> get<property.upperCamelCaseName>() {
if (<property.propertyName> != null) {
return <property.propertyName>;
@@ -402,7 +451,7 @@
return null;
<endif>
}
-
+<checkDeprecated(property)>
public void set<property.upperCamelCaseName>(<property.type> <property.propertyName>) {
this.<property.propertyName> = <property.propertyName>;
}
@@ -410,6 +459,7 @@
MeasureProperty(property) ::= <<
+<createDescription(property)>
public Measure get<property.upperCamelCaseName>() {
if (<property.propertyName> != null) {
return <property.propertyName>;
@@ -435,6 +485,7 @@
<endif>
}
+<checkDeprecated(property)>
public void set<property.upperCamelCaseName>(Measure <property.propertyName>) {
this.<property.propertyName> = <property.propertyName>;
}
Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.2.stg
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.2.stg?rev=889132&r1=889131&r2=889132&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.2.stg (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.2.stg Thu Dec 10 08:22:27 2009
@@ -55,9 +55,19 @@
import javax.el.ValueExpression;
/**
- * UIComponent class, generated from template {@code component1.2.stg} with class
- * {@link <componentInfo.sourceClass>}.
+ <if(componentInfo.description)>
+ <componentInfo.description>
+ <endif>
+ * UIComponent class, generated from template {@code component1.2.stg} with class
+ * {@link <componentInfo.sourceClass>}.
+ <if(componentInfo.deprecated)>
+ @deprecated
+ <endif>
*/
+<if(componentInfo.deprecated)>
+@Deprecated
+
+<endif>
public class <componentInfo.className>
extends <componentInfo.superClassName> <first(componentInfo.interfaces):{ n | implements <n>}><rest(componentInfo.interfaces):{ n |, <n>}> {
@@ -111,8 +121,37 @@
}
>>
+createDescription(property) ::= <<
+<if(property.description)>
+/**
+<property.description>
+<if(property.defaultValue)>
+\<br /\>Default: \<code\><property.defaultValue>\</code\>
+<endif>
+<if(property.allowedValues)>
+\<br /\>Allowed Values: \<code\><property.allowedValues:allowedValue(); separator=",">\</code\>
+<endif>
+
+<if(property.deprecated)>
+@deprecated
+<endif>
+*/
+<endif>
+>>
+
+checkDeprecated(property) ::= <<
+<if(property.deprecated)>
+@Deprecated
+<endif>
+>>
+
+allowedValue() ::= <<
+<it>
+>>
+
IntegerProperty(property) ::= <<
+<createDescription(property)>
public <property.type> get<property.upperCamelCaseName>() {
if (<property.propertyName> != null) {
return <property.propertyName>;
@@ -135,6 +174,7 @@
<endif>
}
+<checkDeprecated(property)>
public void set<property.upperCamelCaseName>(<property.type> <property.propertyName>) {
this.<property.propertyName> = <property.propertyName>;
}
@@ -142,6 +182,8 @@
ObjectProperty(property) ::= <<
+<createDescription(property)>
+<checkDeprecated(property)>
public <property.type> get<property.upperCamelCaseName>() {
if (<property.propertyName> != null) {
return <property.propertyName>;
@@ -157,6 +199,7 @@
return null;
}
+<checkDeprecated(property)>
public void set<property.upperCamelCaseName>(<property.type> <property.propertyName>) {
this.<property.propertyName> = <property.propertyName>;
}
@@ -164,6 +207,8 @@
StringArrayProperty(property) ::= <<
+<createDescription(property)>
+<checkDeprecated(property)>
public String[] get<property.upperCamelCaseName>() {
if (<property.propertyName> != null) {
return <property.propertyName>;
@@ -195,6 +240,7 @@
return ArrayUtils.EMPTY_STRING_ARRAY;
}
+<checkDeprecated(property)>
public void set<property.upperCamelCaseName>(String[] <property.propertyName>) {
this.<property.propertyName> = <property.propertyName>;
}
@@ -202,6 +248,8 @@
booleanProperty(property) ::= <<
+<createDescription(property)>
+<checkDeprecated(property)>
public boolean is<property.upperCamelCaseName>() {
if (<property.propertyName> != null) {
return <property.propertyName>;
@@ -224,6 +272,7 @@
<endif>
}
+<checkDeprecated(property)>
public void set<property.upperCamelCaseName>(boolean <property.propertyName>) {
this.<property.propertyName> = <property.propertyName>;
}
@@ -231,6 +280,8 @@
BooleanProperty(property) ::= <<
+<createDescription(property)>
+<checkDeprecated(property)>
public Boolean get<property.upperCamelCaseName>() {
if (<property.propertyName> != null) {
return <property.propertyName>;
@@ -253,6 +304,7 @@
<endif>
}
+<checkDeprecated(property)>
public void set<property.upperCamelCaseName>(Boolean <property.propertyName>) {
this.<property.propertyName> = <property.propertyName>;
}
@@ -327,6 +379,8 @@
NormalProperty(property) ::= <<
+<createDescription(property)>
+<checkDeprecated(property)>
public <property.type> get<property.upperCamelCaseName>() {
if (<property.propertyName> != null) {
return <property.propertyName>;
@@ -353,6 +407,7 @@
<endif>
}
+<checkDeprecated(property)>
public void set<property.upperCamelCaseName>(<property.type> <property.propertyName>) {
this.<property.propertyName> = <property.propertyName>;
}
@@ -360,6 +415,7 @@
MeasureProperty(property) ::= <<
+<checkDeprecated(property)>
public <property.type> get<property.upperCamelCaseName>() {
if (<property.propertyName> != null) {
return <property.propertyName>;
@@ -389,6 +445,7 @@
<endif>
}
+<checkDeprecated(property)>
public void set<property.upperCamelCaseName>(<property.type> <property.propertyName>) {
this.<property.propertyName> = <property.propertyName>;
}