Author: Alex.Kolonitsky
Date: 2010-03-18 10:38:25 -0400 (Thu, 18 Mar 2010)
New Revision: 16597
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java
Log:
RF-8232 Tags support
remove visitor
fix checkstyle errors
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java 2010-03-18
14:29:31 UTC (rev 16596)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java 2010-03-18
14:38:25 UTC (rev 16597)
@@ -3,18 +3,22 @@
import com.google.common.collect.Lists;
import com.google.inject.Inject;
import com.google.inject.Provider;
-
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.NamingConventions;
import org.richfaces.cdk.annotations.Attribute;
-import org.richfaces.cdk.annotations.DisplayName;
import org.richfaces.cdk.annotations.EventName;
import org.richfaces.cdk.annotations.Icon;
import org.richfaces.cdk.annotations.Signature;
import org.richfaces.cdk.annotations.Tag;
import org.richfaces.cdk.apt.SourceUtils.BeanProperty;
import org.richfaces.cdk.apt.SourceUtils.SuperTypeVisitor;
-import org.richfaces.cdk.model.*;
+import org.richfaces.cdk.model.BeanModelBase;
+import org.richfaces.cdk.model.ClassName;
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.DescriptionGroup;
+import org.richfaces.cdk.model.ModelElementBase;
+import org.richfaces.cdk.model.Property;
+import org.richfaces.cdk.model.TagModel;
import org.richfaces.cdk.util.Strings;
import org.richfaces.cdk.xmlconfig.CdkEntityResolver;
import org.richfaces.cdk.xmlconfig.FragmentParser;
@@ -24,7 +28,6 @@
import javax.lang.model.type.MirroredTypeException;
import javax.lang.model.type.MirroredTypesException;
import javax.lang.model.type.TypeMirror;
-
import java.util.Collection;
import java.util.List;
import java.util.Set;
@@ -32,7 +35,9 @@
public abstract class ProcessorBase {
private static final String TAG_HANDLER_DEFULT_CLASS =
Tag.DEFAULT.class.getName().replace('$', '.');
-
+
+ private static final String SIGNATURE_NONE_CLASS_NAME =
Signature.NONE.class.getName().replace('$', '.');
+
@Inject
private ComponentLibrary library;
@@ -114,7 +119,7 @@
// JavaDoc comments
component.setDescription(description);
- if (null != icon ) {
+ if (null != icon) {
setIcon(component, icon);
}
@@ -154,11 +159,6 @@
// Process XML files with standard attributes definitions.
- for (String attributesConfig : getAnnotationAttributes(componentElement)) {
- // process additional properties.
- component.getAttributes().addAll(parseProperties(attributesConfig));
- }
-
SourceUtils sourceUtils = getSourceUtils();
sourceUtils.visitSupertypes(asClassDesctiption(componentElement), new
SuperTypeVisitor() {
@@ -172,9 +172,11 @@
}
}
});
-
- Set<BeanProperty> properties =
sourceUtils.getBeanPropertiesAnnotatedWith(Attribute.class,
asClassDesctiption(componentElement));
-
+
+ ClassName componentClassName = asClassDesctiption(componentElement);
+ Set<BeanProperty> properties =
sourceUtils.getBeanPropertiesAnnotatedWith(Attribute.class, componentClassName);
+ properties.addAll(sourceUtils.getAbstractBeanProperties(componentClassName));
+
// TODO - encapsulate attribute builder into utility class.
for (BeanProperty beanProperty : properties) {
@@ -185,40 +187,59 @@
}
private void processAttribute(BeanProperty beanProperty, Property attribute) {
- // Flags
+ attribute.setType(beanProperty.getType());
+
Attribute attributeAnnotarion = beanProperty.getAnnotation(Attribute.class);
if (attributeAnnotarion == null) {
- return;
+ attribute.setGenerate(!beanProperty.isExists());
+ setDescription(attribute, null, beanProperty.getDocComment(), null);
+
+ } else {
+ attribute.setHidden(attributeAnnotarion.hidden());
+ attribute.setLiteral(attributeAnnotarion.literal());
+ attribute.setPassThrough(attributeAnnotarion.passThrough());
+ attribute.setRequired(attributeAnnotarion.required());
+ attribute.setReadOnly(attributeAnnotarion.readOnly());
+ attribute.setGenerate(attributeAnnotarion.generate() ||
!beanProperty.isExists());
+
+ setDescription(attribute, attributeAnnotarion.icon(),
beanProperty.getDocComment(), attributeAnnotarion.displayName());
+
+ // DefaultValues
+ String defaultValue = attributeAnnotarion.defaultValue();
+ if (!Strings.isEmpty(defaultValue)) {
+ attribute.setDefaultValue(defaultValue);
+ }
+
+ String suggestedValue = attributeAnnotarion.suggestedValue();
+ if (!Strings.isEmpty(suggestedValue)) {
+ attribute.setSuggestedValue(suggestedValue);
+ }
+
+ // MethodExpression call signature.
+ attribute.setSignature(getSignature(attributeAnnotarion.signature()));
+
+ for (EventName event : attributeAnnotarion.events()) {
+ setBehaviorEvent(attribute, event);
+ }
}
-
- attribute.setHidden(attributeAnnotarion.hidden());
- attribute.setLiteral(attributeAnnotarion.literal());
- attribute.setPassThrough(attributeAnnotarion.passThrough());
- attribute.setRequired(attributeAnnotarion.required());
- attribute.setReadOnly(attributeAnnotarion.readOnly());
- attribute.setGenerate(attributeAnnotarion.generate()||
!beanProperty.isExists());
-
- setDescription(attribute, attributeAnnotarion.icon(),
beanProperty.getDocComment(), attributeAnnotarion.displayName());
-
- // type.
- attribute.setType(beanProperty.getType());
-
- // DefaultValues
- String defaultValue = attributeAnnotarion.defaultValue();
- if (!Strings.isEmpty(defaultValue)) {
- attribute.setDefaultValue(defaultValue);
+ }
+
+ private List<ClassName> getSignature(Signature signature) {
+ if (signature == null) {
+ return null;
}
-
- String suggestedValue = attributeAnnotarion.suggestedValue();
- if (!Strings.isEmpty(suggestedValue)) {
- attribute.setSuggestedValue(suggestedValue);
+
+ String returnType;
+ try {
+ returnType = signature.returnType().getName();
+ } catch (MirroredTypeException e) {
+ TypeMirror returnTypeMirror = e.getTypeMirror();
+ returnType = returnTypeMirror.toString();
}
-
- // MethodExpression call signature.
- Signature signature = attributeAnnotarion.signature();
- if (null != signature && signature.returnType() != Signature.NONE.class)
{
+
+ if (signature != null && SIGNATURE_NONE_CLASS_NAME.equals(returnType)) {
List<ClassName> parameters = Lists.newArrayList();
-
+
try {
for (Class<?> parameterType : signature.parameters()) {
parameters.add(new ClassName(parameterType.getName()));
@@ -231,14 +252,13 @@
parameters.add(new ClassName(parameterType.toString()));
}
}
-
+
+ return parameters;
// signature parameters always should be replaced.
- attribute.setSignature(parameters);
// TODO - set method return type.
}
- for(EventName event : attributeAnnotarion.events()){
- setBehaviorEvent(attribute, event);
- }
+
+ return null;
}
private void setBehaviorEvent(Property attribute, EventName eventName) {
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java 2010-03-18
14:29:31 UTC (rev 16596)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java 2010-03-18
14:38:25 UTC (rev 16597)
@@ -23,11 +23,11 @@
package org.richfaces.cdk.apt;
+import org.richfaces.cdk.model.ClassName;
+
import java.lang.annotation.Annotation;
import java.util.Set;
-import org.richfaces.cdk.model.ClassName;
-
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
@@ -45,6 +45,12 @@
return null;
}
+ @Override
+ public Set<BeanProperty> getAbstractBeanProperties(ClassName type) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
/* (non-Javadoc)
* @see
org.richfaces.cdk.apt.SourceUtils#getConstant(org.richfaces.cdk.model.ClassName,
java.lang.String)
*/
Show replies by date