Author: Alex.Kolonitsky
Date: 2010-03-18 10:29:31 -0400 (Thu, 18 Mar 2010)
New Revision: 16596
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/BehaviorProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkAnnotationProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ConverterProcessor.java
Log:
RF-8232 Tags support
remove visitor
fix checkstyle errors
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java 2010-03-18
14:27:54 UTC (rev 16595)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java 2010-03-18
14:29:31 UTC (rev 16596)
@@ -1,8 +1,9 @@
package org.richfaces.cdk.apt;
-import java.lang.annotation.Annotation;
-import java.util.List;
-import java.util.Set;
+import com.google.common.collect.Sets;
+import org.richfaces.cdk.model.ClassName;
+import org.richfaces.cdk.model.InvalidNameException;
+import org.richfaces.cdk.util.PropertyUtils;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.Element;
@@ -14,13 +15,10 @@
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.ElementFilter;
+import java.lang.annotation.Annotation;
+import java.util.List;
+import java.util.Set;
-import org.richfaces.cdk.model.ClassName;
-import org.richfaces.cdk.model.InvalidNameException;
-import org.richfaces.cdk.util.PropertyUtils;
-
-import com.google.common.collect.Sets;
-
public class AptSourceUtils implements SourceUtils {
@@ -53,15 +51,16 @@
// Get all methods and fields annotated by annotation.
for (Element childElement : members) {
boolean annotated = (null != childElement.getAnnotation(annotation));
+ if (!annotated) {
+ continue;
+ }
// Have an annotation, infer property name.
if (ElementKind.METHOD.equals(childElement.getKind())) {
processMethod(properties, childElement, annotated);
} else if (ElementKind.FIELD.equals(childElement.getKind())) {
- if (annotated) {
- processFiled(properties, childElement);
- }
- }
+ processFiled(properties, childElement);
+ }
// TODO - merge properties with same name ?
}
@@ -69,6 +68,21 @@
return properties;
}
+ public Set<BeanProperty> getAbstractBeanProperties(ClassName type) {
+ Set<BeanProperty> properties = Sets.newHashSet();
+ List<? extends Element> members =
this.processingEnv.getElementUtils().getAllMembers(asTypeElement(type));
+
+ for (Element childElement : members) {
+ if (ElementKind.METHOD.equals(childElement.getKind())) {
+ processMethod(properties, childElement, false);
+ }
+
+ // TODO - merge properties with same name ?
+ }
+
+ return properties;
+ }
+
private void processFiled(Set<BeanProperty> properties, Element childElement)
{
AptBeanProperty property = new
AptBeanProperty(childElement.getSimpleName().toString());
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/BehaviorProcessor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/BehaviorProcessor.java 2010-03-18
14:27:54 UTC (rev 16595)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/BehaviorProcessor.java 2010-03-18
14:29:31 UTC (rev 16596)
@@ -25,12 +25,10 @@
import org.richfaces.cdk.CdkProcessingException;
import org.richfaces.cdk.annotations.JsfBehavior;
-import org.richfaces.cdk.annotations.JsfConverter;
import org.richfaces.cdk.model.BehaviorModel;
import org.richfaces.cdk.model.FacesId;
import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.faces.view.facelets.BehaviorHandler;
import javax.lang.model.element.TypeElement;
import java.lang.annotation.Annotation;
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkAnnotationProcessor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkAnnotationProcessor.java 2010-03-18
14:27:54 UTC (rev 16595)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkAnnotationProcessor.java 2010-03-18
14:29:31 UTC (rev 16596)
@@ -23,12 +23,11 @@
package org.richfaces.cdk.apt;
-import java.lang.annotation.Annotation;
+import org.richfaces.cdk.CdkProcessingException;
import javax.lang.model.element.TypeElement;
+import java.lang.annotation.Annotation;
-import org.richfaces.cdk.CdkProcessingException;
-
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java 2010-03-18
14:27:54 UTC (rev 16595)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java 2010-03-18
14:29:31 UTC (rev 16596)
@@ -23,8 +23,12 @@
package org.richfaces.cdk.apt;
-import java.util.Collections;
-import java.util.Set;
+import com.google.inject.Inject;
+import org.richfaces.cdk.CdkProcessingException;
+import org.richfaces.cdk.LibraryBuilder;
+import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.ModelBuilder;
+import org.richfaces.cdk.ModelValidator;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.ProcessingEnvironment;
@@ -33,15 +37,9 @@
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.TypeElement;
+import java.util.Collections;
+import java.util.Set;
-import org.richfaces.cdk.CdkProcessingException;
-import org.richfaces.cdk.LibraryBuilder;
-import org.richfaces.cdk.Logger;
-import org.richfaces.cdk.ModelBuilder;
-import org.richfaces.cdk.ModelValidator;
-
-import com.google.inject.Inject;
-
/**
* <p class="changed_added_4_0">
* Base class for all CDK Annotation processors. That class provides access to current
CDK context and utility methods
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java 2010-03-18
14:27:54 UTC (rev 16595)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java 2010-03-18
14:29:31 UTC (rev 16596)
@@ -25,21 +25,22 @@
package org.richfaces.cdk.apt;
-import com.google.common.collect.Lists;
import com.google.inject.Inject;
import com.google.inject.Injector;
import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.annotations.*;
-import org.richfaces.cdk.annotations.EventName;
+import org.richfaces.cdk.annotations.Event;
+import org.richfaces.cdk.annotations.Facet;
+import org.richfaces.cdk.annotations.JsfComponent;
+import org.richfaces.cdk.annotations.JsfRenderer;
+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.ComponentLibrary;
+import org.richfaces.cdk.model.ComponentModel;
+import org.richfaces.cdk.model.FacesId;
+import org.richfaces.cdk.model.FacetModel;
import org.richfaces.cdk.util.Strings;
-import org.richfaces.cdk.xmlconfig.CdkEntityResolver;
import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.faces.event.FacesEvent;
-import javax.faces.view.facelets.ComponentHandler;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.MirroredTypeException;
import javax.lang.model.type.MirroredTypesException;
@@ -113,22 +114,22 @@
facetModel.setDescription(beanProperty.getDocComment());
processFacet(facet, facetModel);
- if(!beanProperty.isExists()){
+ if (!beanProperty.isExists()) {
facetModel.setGenerate(true);
}
}
// @Facets annotation.
JsfComponent annotation = componentElement.getAnnotation(JsfComponent.class);
- for (Facet facet : annotation.facets()) {
- if (!Strings.isEmpty(facet.name())) {
- FacetModel facetModel = component.getOrCreateFacet(facet.name());
- processFacet(facet, facetModel);
- } else {
- // TODO - record error.
- throw new CdkException("Facet name should be set");
- }
+ for (Facet facet : annotation.facets()) {
+ if (!Strings.isEmpty(facet.name())) {
+ FacetModel facetModel = component.getOrCreateFacet(facet.name());
+ processFacet(facet, facetModel);
+ } else {
+ // TODO - record error.
+ throw new CdkException("Facet name should be set");
}
+ }
}
private void processFacet(Facet facet, FacetModel facetModel) {
@@ -157,19 +158,19 @@
private void setEvents(TypeElement componentElement, ComponentModel component) {
Event[] fires = componentElement.getAnnotation(JsfComponent.class).fires();
- for (Event event : fires) {
- try {
- component.addEvent(event.value().getName());
- } catch (MirroredTypesException mirror) {
- for (TypeMirror eventType : mirror.getTypeMirrors()) {
- component.addEvent(eventType.toString());
- // TODO - check does component already implement eventSource
interface
- }
- } catch (MirroredTypeException mirror) {
- component.addEvent(mirror.getTypeMirror().toString());
- }
+ for (Event event : fires) {
+ try {
+ component.addEvent(event.value().getName());
+ } catch (MirroredTypesException mirror) {
+ for (TypeMirror eventType : mirror.getTypeMirrors()) {
+ component.addEvent(eventType.toString());
+ // TODO - check does component already implement eventSource
interface
+ }
+ } catch (MirroredTypeException mirror) {
+ component.addEvent(mirror.getTypeMirror().toString());
+ }
- }
+ }
}
@Override
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ConverterProcessor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ConverterProcessor.java 2010-03-18
14:27:54 UTC (rev 16595)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ConverterProcessor.java 2010-03-18
14:29:31 UTC (rev 16596)
@@ -30,7 +30,6 @@
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.MirroredTypeException;
-import javax.faces.view.facelets.ConverterHandler;
import java.lang.annotation.Annotation;
/**
Show replies by date