Author: nbelaevski
Date: 2010-02-18 18:48:59 -0500 (Thu, 18 Feb 2010)
New Revision: 16468
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELNodeConstants.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFunctionTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/MethodBodyTemplateModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Attribute.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Template.java
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-composite.xsd
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-template.xsd
Log:
TODOs & fixes for CDK
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELNodeConstants.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELNodeConstants.java 2010-02-18
11:26:25 UTC (rev 16467)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELNodeConstants.java 2010-02-18
23:48:59 UTC (rev 16468)
@@ -60,6 +60,7 @@
public static final String RIGHT_BRACKET = ")";
public static final String RIGHT_SQUARE_BRACKET = "]";
public static final String THIS_PREFIX = "this";
+ public static final String SUPER_PREFIX = "super";
public static final String GETTER_PREFIX = "get";
public static final String IS_EMPTY_FUNCTION = "isEmpty";
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFunctionTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFunctionTreeNode.java 2010-02-18
11:26:25 UTC (rev 16467)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFunctionTreeNode.java 2010-02-18
23:48:59 UTC (rev 16468)
@@ -19,8 +19,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
-
package org.richfaces.cdk.parser.el.node;
import java.util.Map;
@@ -35,12 +33,12 @@
/**
* This class extend AbstractTreeNode and wrap AstFunction node.
- *
+ *
* @author amarkhel
- *
+ *
*/
public class AstFunctionTreeNode extends AbstractMethodTreeNode {
-
+
public AstFunctionTreeNode(Node node) {
super(node);
}
@@ -53,14 +51,14 @@
String identifierName;
if (!Strings.isEmpty(functionPrefix)) {
- //TODO: this should be a property getter, not property name. NB:
'this' & 'super' keywords
+ // TODO: this should be a property getter, not property name. NB:
'this' & 'super' keywords
identifierName = functionPrefix;
} else {
identifierName = ELNodeConstants.THIS_PREFIX;
}
sb.append(identifierName);
-
+
Type identifierType = getIdentifierFromContext(context, identifierName);
visitor.setVariableType(identifierType);
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/MethodBodyTemplateModel.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/MethodBodyTemplateModel.java 2010-02-18
11:26:25 UTC (rev 16467)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/MethodBodyTemplateModel.java 2010-02-18
23:48:59 UTC (rev 16468)
@@ -36,6 +36,8 @@
*/
public class MethodBodyTemplateModel extends BeanModel implements TemplateModel {
+ private static final String CODE_ATTRIBUTE_NAME = "code";
+
private final MethodBodyStatement statement;
private final JavaClassModelWrapper modelWrapper;
@@ -53,9 +55,9 @@
@Override
public TemplateModel get(String key) throws TemplateModelException {
- if ("code".equals(key)) {
- //TODO - ?
- return
modelWrapper.wrap(statement.getCode(modelWrapper.getConfiguration()));
+ if (CODE_ATTRIBUTE_NAME.equals(key)) {
+ String statementCode = statement.getCode(modelWrapper.getConfiguration());
+ return modelWrapper.wrap(statementCode);
}
return super.get(key);
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-02-18
11:26:25 UTC (rev 16467)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-02-18
23:48:59 UTC (rev 16468)
@@ -95,6 +95,11 @@
public class RendererClassVisitor implements TemplateVisitor {
/**
+ *
+ */
+ // TODO externalize
+ static final String RENDER_KIT_UTILS_CLASS_NAME =
"org.richfaces.renderkit.RenderKitUtils";
+ /**
*
*/
static final String RESPONSE_WRITER_VARIABLE = "responseWriter";
@@ -273,8 +278,7 @@
return parsedExpression + "/* " + expression.trim() + "
*/";
} catch (ParsingException e) {
// TODO Auto-generated catch block
- e.printStackTrace();
- throw new RuntimeException(e.getMessage());
+ throw new RuntimeException(e.getMessage(), e);
}
}
@@ -375,7 +379,7 @@
passThroughField.addModifier(JavaModifier.FINAL);
generatedClass.addImport("org.richfaces.renderkit.ComponentAttribute");
- generatedClass.addImport("org.richfaces.renderkit.RenderKitUtils");
+ generatedClass.addImport(RENDER_KIT_UTILS_CLASS_NAME);
generatedClass.addImport(Collections.class);
// TODO - get rid of FQNs for classes via imports
@@ -541,8 +545,7 @@
} else {
String attributeLocalName = attributeName.getLocalPart();
if (writtenAttributes.add(attributeLocalName)) {
- // TODO externalize
-
generatedClass.addImport("org.richfaces.renderkit.RenderKitUtils");
+ generatedClass.addImport(RENDER_KIT_UTILS_CLASS_NAME);
currentStatement.addStatement(new
WriteAttributeStatement(attributeLocalName, compileEl(
attributeValue.toString(), String.class)));
}
@@ -569,8 +572,7 @@
if (!actualAttributesMap.isEmpty()) {
JavaField passThroughField =
createPassThroughField(actualAttributesMap);
generatedClass.addField(passThroughField);
- // TODO externalize
-
generatedClass.addImport("org.richfaces.renderkit.RenderKitUtils");
+ generatedClass.addImport(RENDER_KIT_UTILS_CLASS_NAME);
currentStatement.addStatement(new
WriteAttributesSetStatement(passThroughField.getName()));
}
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Attribute.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Attribute.java 2010-02-18
11:26:25 UTC (rev 16467)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Attribute.java 2010-02-18
23:48:59 UTC (rev 16468)
@@ -238,7 +238,6 @@
*
* @return the type
*/
- //TODO: add handling
public String getType() {
return type;
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Template.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Template.java 2010-02-18
11:26:25 UTC (rev 16467)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Template.java 2010-02-18
23:48:59 UTC (rev 16468)
@@ -34,7 +34,6 @@
* @author asmirnov(a)exadel.com
*/
@XmlRootElement(name = "root", namespace = Template.CDK_NAMESPACE)
-//TODO add support for attribute files imports
public class Template implements Serializable {
public static final String JSTL_CORE_NAMESPACE =
"http://richfaces.org/cdk/jstl/core";
Modified:
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-composite.xsd
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-composite.xsd 2010-02-18
11:26:25 UTC (rev 16467)
+++
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-composite.xsd 2010-02-18
23:48:59 UTC (rev 16468)
@@ -31,7 +31,7 @@
</xs:annotation>
<xs:attributeGroup name="beanDescriptorAttributes">
- <xs:attribute name="displayName">
+ <xs:attribute name="displayName" type="xs:string">
<xs:annotation>
<xs:documentation>
<p>
@@ -66,7 +66,7 @@
</xs:documentation>
</xs:annotation>
</xs:attribute>
- <xs:attribute name="shortDescription">
+ <xs:attribute name="shortDescription" type="xs:string">
<xs:annotation>
<xs:documentation>
<p>
@@ -83,7 +83,7 @@
<xs:complexType name="attributeExtensionType">
<xs:group ref="cc:compositeTagsGroup" />
- <xs:attribute name="name" use="required">
+ <xs:attribute name="name" use="required"
type="xs:string">
<xs:annotation>
<xs:documentation>
<p>
@@ -106,7 +106,7 @@
</xs:documentation>
</xs:annotation>
</xs:attribute>
- <xs:attribute name="targets">
+ <xs:attribute name="targets" type="xs:NMTOKENS">
<xs:annotation>
<xs:documentation>
<p>
@@ -131,7 +131,7 @@
</xs:documentation>
</xs:annotation>
</xs:attribute>
- <xs:attribute name="default">
+ <xs:attribute name="default" type="xs:string">
<xs:annotation>
<xs:documentation>
<p>
@@ -153,7 +153,7 @@
</xs:documentation>
</xs:annotation>
</xs:attribute>
- <xs:attribute name="method-signature">
+ <xs:attribute name="method-signature" type="xs:string">
<xs:annotation>
<xs:documentation>
Declares that this attribute must be a
@@ -212,7 +212,7 @@
</xs:documentation>
</xs:annotation>
</xs:attribute>
- <xs:attribute name="type">
+ <xs:attribute name="type" type="xs:string">
<xs:annotation>
<xs:documentation>
<p>
@@ -230,7 +230,7 @@
</xs:complexType>
<xs:complexType name="clientBehaviorExtensionType">
- <xs:attribute name="event">
+ <xs:attribute name="event" type="xs:string">
<xs:annotation>
<xs:documentation>
<p>
Modified:
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-template.xsd
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-template.xsd 2010-02-18
11:26:25 UTC (rev 16467)
+++
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-template.xsd 2010-02-18
23:48:59 UTC (rev 16468)
@@ -78,12 +78,12 @@
</xs:complexType>
<xs:complexType name="resourceDependencyType">
- <xs:attribute name="name" use="required"
form="unqualified">
+ <xs:attribute name="name" use="required"
form="unqualified" type="xs:string">
<xs:annotation>
<xs:documentation><p>The resourceName of the resource pointed to by this
ResourceDependency.</p></xs:documentation>
</xs:annotation>
</xs:attribute>
- <xs:attribute name="library" form="unqualified">
+ <xs:attribute name="library" form="unqualified"
type="xs:string">
<xs:annotation>
<xs:documentation>
<p>The libraryName in which the resource pointed to by this ResourceDependency
resides.
@@ -388,7 +388,7 @@
</xs:documentation>
</xs:annotation>
<xs:complexType mixed="true">
- <xs:attribute name="expression" form="unqualified">
+ <xs:attribute name="expression" form="unqualified"
type="xs:string">
<xs:annotation>
<xs:documentation>
<p>Method invocation expression. If this attribute is ommitted, body of the
tag is used instead.</p>
@@ -438,7 +438,7 @@
</xs:documentation>
</xs:annotation>
</xs:attribute>
- <xs:attribute name="value" form="unqualified">
+ <xs:attribute name="value" form="unqualified"
type="xs:string">
<xs:annotation>
<xs:documentation>
<p>EL-expression specifying initial value of the variable. If this
attribute
@@ -455,7 +455,7 @@
</xs:documentation>
</xs:annotation>
</xs:attribute>
- <xs:attribute name="type" form="unqualified">
+ <xs:attribute name="type" form="unqualified"
type="xs:string">
<xs:annotation>
<xs:documentation>
<p>Variable type name. CDK automatically resolves simple names for
primitive types,
@@ -473,7 +473,7 @@
</xs:documentation>
</xs:annotation>
</xs:attribute>
- <xs:attribute name="type-arguments" form="unqualified">
+ <xs:attribute name="type-arguments" form="unqualified"
type="xs:string">
<xs:annotation>
<xs:documentation>
<p>Comma-separated list of generic type arguments for usage with types like