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 2017/08/07 22:32:18 UTC
[16/21] incubator-freemarker git commit: FREEMARKER-63: Removed
NestedContentNotSupportedException,
as TemplateDirectiveModel.isNestedContentSupported() now takes care of that
problem.
FREEMARKER-63: Removed NestedContentNotSupportedException, as TemplateDirectiveModel.isNestedContentSupported() now takes care of that problem.
Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/da4c3329
Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/da4c3329
Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/da4c3329
Branch: refs/heads/3
Commit: da4c33292d5d73cdfb53613ca64bd0834fcfb5fd
Parents: 5bd19ad
Author: ddekany <dd...@apache.org>
Authored: Sun Jul 30 23:20:34 2017 +0200
Committer: ddekany <dd...@apache.org>
Committed: Sun Jul 30 23:22:02 2017 +0200
----------------------------------------------------------------------
FM3-CHANGE-LOG.txt | 2 +
.../core/userpkg/NamedVarargsOnlyDirective.java | 2 -
.../userpkg/PositionalVarargsOnlyDirective.java | 2 -
.../NestedContentNotSupportedException.java | 57 --------------------
...nterruptionSupportTemplatePostProcessor.java | 8 ++-
.../test/templateutil/AssertDirective.java | 3 --
.../templateutil/AssertEqualsDirective.java | 3 --
7 files changed, 5 insertions(+), 72 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/da4c3329/FM3-CHANGE-LOG.txt
----------------------------------------------------------------------
diff --git a/FM3-CHANGE-LOG.txt b/FM3-CHANGE-LOG.txt
index 938f9bf..21ce533 100644
--- a/FM3-CHANGE-LOG.txt
+++ b/FM3-CHANGE-LOG.txt
@@ -424,6 +424,8 @@ Core / Miscellaneous
get(), to be more similar to the Java 8 API.
- Removed the legacy predefined shared variables: "html_escape", "normalize_newlines", "xml_escape", "capture_output",
"compress"
+- Removed `NestedContentNotSupportedException`, as `TemplateDirectiveModel.isNestedContentSupported()` now takes care
+ of that problem.
Build / development process changes
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/da4c3329/freemarker-core-test/src/test/java/org/apache/freemarker/core/userpkg/NamedVarargsOnlyDirective.java
----------------------------------------------------------------------
diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/userpkg/NamedVarargsOnlyDirective.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/userpkg/NamedVarargsOnlyDirective.java
index f978dbe..fed4bc7 100644
--- a/freemarker-core-test/src/test/java/org/apache/freemarker/core/userpkg/NamedVarargsOnlyDirective.java
+++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/userpkg/NamedVarargsOnlyDirective.java
@@ -23,7 +23,6 @@ import java.io.IOException;
import java.io.Writer;
import org.apache.freemarker.core.Environment;
-import org.apache.freemarker.core.NestedContentNotSupportedException;
import org.apache.freemarker.core.TemplateException;
import org.apache.freemarker.core.model.ArgumentArrayLayout;
import org.apache.freemarker.core.model.CallPlace;
@@ -46,7 +45,6 @@ public class NamedVarargsOnlyDirective extends TestTemplateDirectiveModel {
@Override
public void execute(TemplateModel[] args, CallPlace callPlace, Writer out, Environment env)
throws TemplateException, IOException {
- NestedContentNotSupportedException.check(callPlace);
out.write("#nvo(");
printParam("nVarargs", args[NAMED_VARARGS_ARG_IDX], out, true);
out.write(")");
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/da4c3329/freemarker-core-test/src/test/java/org/apache/freemarker/core/userpkg/PositionalVarargsOnlyDirective.java
----------------------------------------------------------------------
diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/userpkg/PositionalVarargsOnlyDirective.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/userpkg/PositionalVarargsOnlyDirective.java
index b9d2b92..540a641 100644
--- a/freemarker-core-test/src/test/java/org/apache/freemarker/core/userpkg/PositionalVarargsOnlyDirective.java
+++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/userpkg/PositionalVarargsOnlyDirective.java
@@ -23,7 +23,6 @@ import java.io.IOException;
import java.io.Writer;
import org.apache.freemarker.core.Environment;
-import org.apache.freemarker.core.NestedContentNotSupportedException;
import org.apache.freemarker.core.TemplateException;
import org.apache.freemarker.core.model.ArgumentArrayLayout;
import org.apache.freemarker.core.model.CallPlace;
@@ -44,7 +43,6 @@ public class PositionalVarargsOnlyDirective extends TestTemplateDirectiveModel {
@Override
public void execute(TemplateModel[] args, CallPlace callPlace, Writer out, Environment env)
throws TemplateException, IOException {
- NestedContentNotSupportedException.check(callPlace);
out.write("#pvo(");
printParam("pVarargs", args[ARGS_LAYOUT.getPositionalVarargsArgumentIndex()], out, true);
out.write(")");
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/da4c3329/freemarker-core/src/main/java/org/apache/freemarker/core/NestedContentNotSupportedException.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/NestedContentNotSupportedException.java b/freemarker-core/src/main/java/org/apache/freemarker/core/NestedContentNotSupportedException.java
deleted file mode 100644
index a6e6be5..0000000
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/NestedContentNotSupportedException.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.freemarker.core;
-
-import org.apache.freemarker.core.model.CallPlace;
-import org.apache.freemarker.core.model.TemplateDirectiveModel;
-import org.apache.freemarker.core.util._StringUtil;
-
-/**
- * Used in custom {@link TemplateDirectiveModel}-s to check if the directive invocation has no body. This is more
- * intelligent than a {@code null} check; for example, when the body only contains a thread interruption check node, it
- * treats it as valid.
- */
-public class NestedContentNotSupportedException extends TemplateException {
-
- public static void check(CallPlace body) throws NestedContentNotSupportedException {
- if (body.hasNestedContent()) {
- throw new NestedContentNotSupportedException(Environment.getCurrentEnvironment());
- }
- }
-
- private NestedContentNotSupportedException(Environment env) {
- this(null, null, env);
- }
-
- private NestedContentNotSupportedException(Exception cause, Environment env) {
- this(null, cause, env);
- }
-
- private NestedContentNotSupportedException(String description, Environment env) {
- this(description, null, env);
- }
-
- private NestedContentNotSupportedException(String description, Exception cause, Environment env) {
- super( "Nested content (body) not supported."
- + (description != null ? " " + _StringUtil.jQuote(description) : ""),
- cause, env);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/da4c3329/freemarker-core/src/main/java/org/apache/freemarker/core/ThreadInterruptionSupportTemplatePostProcessor.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ThreadInterruptionSupportTemplatePostProcessor.java b/freemarker-core/src/main/java/org/apache/freemarker/core/ThreadInterruptionSupportTemplatePostProcessor.java
index 687675c..71db276 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/ThreadInterruptionSupportTemplatePostProcessor.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ThreadInterruptionSupportTemplatePostProcessor.java
@@ -30,10 +30,6 @@ import org.apache.freemarker.core.model.TemplateDateModel;
* <p>
* Known compatibility risks when using this post-processor:
* <ul>
- * <li>{@link TemplateDateModel}-s that care to explicitly check if their nested content is {@code null} might start to
- * complain that you have specified a body despite that the directive doesn't support that. Directives should use
- * {@link NestedContentNotSupportedException#check(CallPlace)} instead of a simple
- * {@code null}-check to avoid this problem.</li>
* <li>
* Software that uses {@link CallPlace#isNestedOutputCacheable()} will always get {@code false}, because
* interruption checks ({@link ASTThreadInterruptionCheck} elements) are, obviously, not cacheable. This should only
@@ -41,7 +37,9 @@ import org.apache.freemarker.core.model.TemplateDateModel;
* <li>
* Software that investigates the AST will see the injected {@link ASTThreadInterruptionCheck} elements. As of this
* writing the AST API-s aren't published, also such software need to be able to deal with new kind of elements
- * anyway, so this shouldn't be a problem.
+ * anyway, so this shouldn't be a problem. When a {@link TemplateDateModel} checks if it has no nested content, it
+ * should always use {@link CallPlace#hasNestedContent()}, which will ignore nested content that only
+ * contains a {@link ASTThreadInterruptionCheck}.
* </ul>
*/
class ThreadInterruptionSupportTemplatePostProcessor extends TemplatePostProcessor {
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/da4c3329/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/AssertDirective.java
----------------------------------------------------------------------
diff --git a/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/AssertDirective.java b/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/AssertDirective.java
index ffb2c40..50ffe60 100644
--- a/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/AssertDirective.java
+++ b/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/AssertDirective.java
@@ -23,7 +23,6 @@ import java.io.IOException;
import java.io.Writer;
import org.apache.freemarker.core.Environment;
-import org.apache.freemarker.core.NestedContentNotSupportedException;
import org.apache.freemarker.core.TemplateException;
import org.apache.freemarker.core.model.ArgumentArrayLayout;
import org.apache.freemarker.core.model.CallPlace;
@@ -48,8 +47,6 @@ public class AssertDirective implements TemplateDirectiveModel {
@Override
public void execute(TemplateModel[] args, CallPlace callPlace, Writer out, Environment env)
throws TemplateException, IOException {
- NestedContentNotSupportedException.check(callPlace);
-
TemplateModel test = args[TEST_ARG_IDX];
if (test == null) {
throw new MissingRequiredParameterException(TEST_ARG_NAME, env);
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/da4c3329/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/AssertEqualsDirective.java
----------------------------------------------------------------------
diff --git a/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/AssertEqualsDirective.java b/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/AssertEqualsDirective.java
index 8334c20..fda0d22 100644
--- a/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/AssertEqualsDirective.java
+++ b/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/AssertEqualsDirective.java
@@ -23,7 +23,6 @@ import java.io.IOException;
import java.io.Writer;
import org.apache.freemarker.core.Environment;
-import org.apache.freemarker.core.NestedContentNotSupportedException;
import org.apache.freemarker.core.TemplateException;
import org.apache.freemarker.core.model.ArgumentArrayLayout;
import org.apache.freemarker.core.model.CallPlace;
@@ -60,8 +59,6 @@ public class AssertEqualsDirective implements TemplateDirectiveModel {
@Override
public void execute(TemplateModel[] args, CallPlace callPlace, Writer out, Environment env)
throws TemplateException, IOException {
- NestedContentNotSupportedException.check(callPlace);
-
TemplateModel actual = args[ACTUAL_ARG_IDX];
if (actual == null) {
throw new MissingRequiredParameterException(ACTUAL_ARG_NAME, env);