You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@freemarker.apache.org by dd...@apache.org on 2015/12/19 15:23:15 UTC
[6/8] incubator-freemarker git commit: Added back
FMParser.MixedContent and OptionalBlock products for backward compatibility
for those dared to call the parser directly. We don't use them.
Added back FMParser.MixedContent and OptionalBlock products for backward compatibility for those dared to call the parser directly. We don't use them.
Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/4fb95ebc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/4fb95ebc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/4fb95ebc
Branch: refs/heads/2.3
Commit: 4fb95ebc9339c488c64ef72ba03aa97f21c59cb8
Parents: f08867b
Author: ddekany <dd...@apache.org>
Authored: Fri Dec 18 21:58:03 2015 +0100
Committer: ddekany <dd...@apache.org>
Committed: Fri Dec 18 21:58:03 2015 +0100
----------------------------------------------------------------------
.../core/TemplateElementArrayBuilder.java | 4 ++
src/main/javacc/FTL.jj | 60 ++++++++++++++++++++
2 files changed, 64 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4fb95ebc/src/main/java/freemarker/core/TemplateElementArrayBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/TemplateElementArrayBuilder.java b/src/main/java/freemarker/core/TemplateElementArrayBuilder.java
index c18e48b..e44f12e 100644
--- a/src/main/java/freemarker/core/TemplateElementArrayBuilder.java
+++ b/src/main/java/freemarker/core/TemplateElementArrayBuilder.java
@@ -40,6 +40,10 @@ class TemplateElements {
int getCount() {
return count;
}
+
+ TemplateElement getFirst() {
+ return buffer != null ? buffer[0] : null;
+ }
TemplateElement getLast() {
return buffer != null ? buffer[count - 1] : null;
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4fb95ebc/src/main/javacc/FTL.jj
----------------------------------------------------------------------
diff --git a/src/main/javacc/FTL.jj b/src/main/javacc/FTL.jj
index 254c27a..ad81e08 100644
--- a/src/main/javacc/FTL.jj
+++ b/src/main/javacc/FTL.jj
@@ -4003,6 +4003,66 @@ TemplateElements MixedContentElements() :
}
/**
+ * Not used anymore; kept for backward compatibility.
+ *
+ * @deprecated Use {@link #MixedContentElements} instead.
+ */
+MixedContent MixedContent() :
+{
+ MixedContent mixedContent = new MixedContent();
+ TemplateElement elem, begin = null;
+ mixedContentNesting++;
+}
+{
+ (
+ LOOKAHEAD(1) // Just tells javacc that we know what we're doing.
+ (
+ elem = PCData()
+ |
+ elem = StringOutput()
+ |
+ elem = NumericalOutput()
+ |
+ elem = FreemarkerDirective()
+ )
+ {
+ if (begin == null) {
+ begin = elem;
+ }
+ mixedContent.addElement(elem);
+ }
+ )+
+ {
+ mixedContentNesting--;
+ mixedContent.setLocation(template, begin, elem);
+ return mixedContent;
+ }
+}
+
+/**
+ * Not used anymore; kept for backward compatibility.
+ *
+ * <p>A production for a block of optional content.
+ * Returns an empty Text block if there is no
+ * content.
+ *
+ * @deprecated Use {@link #MixedContentElements} instead.
+ */
+TemplateElement OptionalBlock() :
+{
+ TemplateElement tp = null;
+}
+{
+ [
+ LOOKAHEAD(1) // has no effect but to get rid of a spurious warning.
+ tp = MixedContent()
+ ]
+ {
+ return tp != null ? tp : new TextBlock(CollectionUtils.EMPTY_CHAR_ARRAY, false);
+ }
+}
+
+/**
* A production freemarker text that may contain
* ${...} and #{...} but no directives.
*/