codeconsole commented on code in PR #16134:
URL: https://github.com/apache/grails-core/pull/16134#discussion_r3793142483
##########
grails-mail/src/main/groovy/grails/plugins/mail/PlainTextMailTagLib.groovy:
##########
@@ -22,7 +22,7 @@ class PlainTextMailTagLib {
static namespace = 'text'
- def newLine = {
+ def newLine(Map attrs) {
Review Comment:
Fair — it had no test and no explanation. Both now.
`PlainTextMailTagLibSpec` covers `text:newLine`. I checked, and you were
right that nothing required the change: the closure form dispatches fine either
way. It was converted because declaring a tag as a closure is deprecated as of
this PR and now warns, and the framework's own tag libraries shouldn't trip a
warning the framework introduces. That reasoning is on the spec.
##########
grails-gsp/grails-taglib/src/main/groovy/org/grails/taglib/discovery/TagDiscoveryRules.java:
##########
@@ -0,0 +1,159 @@
+/*
+ * 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
+ *
+ * https://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.grails.taglib.discovery;
+
+import java.util.Set;
+
+/**
+ * Decides whether a method is a tag.
+ *
+ * <p>The single statement of those rules. Both the reflective discovery an
application performs at
+ * startup and the syntax-tree discovery a build performs while compiling a
tag library route through
+ * here, so the two cannot drift apart: a method is a tag for a compiler
exactly when it is a tag for
+ * the runtime.
+ *
+ * <p>The rules, in order:
+ * <ol>
+ * <li>plumbing — non-public, static, or compiler-generated methods are never
tags;</li>
+ * <li>{@code @NotATag} excludes, {@code @Tag} includes, each overriding
everything below;</li>
+ * <li>names belonging to Object, Groovy, or the framework traits are never
tags;</li>
+ * <li>property accessors are never tags;</li>
+ * <li>what remains is a tag if it can be called as {@code (attrs)} or {@code
(attrs, body)}.</li>
+ * </ol>
+ *
+ * @since 8.0.0
+ */
+public final class TagDiscoveryRules {
+
+ /**
+ * The name a {@link java.util.Map} parameter must carry to be the
attributes parameter, when the
+ * method retains parameter names.
+ */
+ public static final String ATTRS_PARAMETER_NAME = "attrs";
+
+ /**
+ * The name a {@link groovy.lang.Closure} parameter must carry to be the
body parameter, when the
+ * method retains parameter names.
+ */
+ public static final String BODY_PARAMETER_NAME = "body";
+
+ /**
+ * Names that are Groovy or Object plumbing on any class.
+ */
+ private static final Set<String> LANGUAGE_METHOD_NAMES = Set.of(
Review Comment:
Noted in the description, and the three differences are now pinned — an
`Object` member name, a non-boolean `is*` accessor, and a name containing `$` —
as rows in `TagDiscoveryRulesSpec`.
One correction: that spec isn't AST-only. Each row runs `classifyFromTree`
(`AstTagMethodView`) and `classifyFromClass` (`ReflectedTagMethodView`) over
the same source and asserts `fromTree == fromClass` before asserting the
verdict, so the "cannot drift apart" claim is already enforced across the
matrix — the new rows just extend it to these three.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]