diff --git a/grails-gsp/core/src/main/groovy/org/apache/grails/gsp/aot/PrecompiledPageRuntimeHints.java b/grails-gsp/core/src/main/groovy/org/apache/grails/gsp/aot/PrecompiledPageRuntimeHints.groovy
similarity index 69%
rename from grails-gsp/core/src/main/groovy/org/apache/grails/gsp/aot/PrecompiledPageRuntimeHints.java
rename to grails-gsp/core/src/main/groovy/org/apache/grails/gsp/aot/PrecompiledPageRuntimeHints.groovy
index 857ab6478af..4ee67435e7e 100644
--- a/grails-gsp/core/src/main/groovy/org/apache/grails/gsp/aot/PrecompiledPageRuntimeHints.java
+++ b/grails-gsp/core/src/main/groovy/org/apache/grails/gsp/aot/PrecompiledPageRuntimeHints.groovy
@@ -16,14 +16,14 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.grails.gsp.aot;
+package org.apache.grails.gsp.aot
-import org.jspecify.annotations.Nullable;
+import groovy.transform.CompileStatic
+import org.jspecify.annotations.Nullable
+import org.springframework.aot.hint.RuntimeHints
+import org.springframework.aot.hint.RuntimeHintsRegistrar
-import org.springframework.aot.hint.RuntimeHints;
-import org.springframework.aot.hint.RuntimeHintsRegistrar;
-
-import org.grails.gsp.GroovyPageMetaInfo;
+import org.grails.gsp.GroovyPageMetaInfo
/**
* Registers what a page compiled at build time is read from.
@@ -38,15 +38,17 @@
*
* @since 8.0
*/
-public class PrecompiledPageRuntimeHints implements RuntimeHintsRegistrar {
+@CompileStatic
+class PrecompiledPageRuntimeHints implements RuntimeHintsRegistrar {
/** Where the pages compiled at build time are listed, read to find them at all. */
- private static final String VIEWS = "gsp/views.properties";
+ private static final String VIEWS = 'gsp/views.properties'
@Override
- public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
- hints.resources().registerPattern(VIEWS);
- hints.resources().registerPattern("*" + GroovyPageMetaInfo.HTML_DATA_POSTFIX);
- hints.resources().registerPattern("*" + GroovyPageMetaInfo.LINENUMBERS_DATA_POSTFIX);
+ void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
+ hints.resources().registerPattern(VIEWS)
+ hints.resources().registerPattern('*' + GroovyPageMetaInfo.HTML_DATA_POSTFIX)
+ hints.resources().registerPattern('*' + GroovyPageMetaInfo.LINENUMBERS_DATA_POSTFIX)
}
+
}
diff --git a/grails-gsp/core/src/main/groovy/org/grails/gsp/GroovyPage.java b/grails-gsp/core/src/main/groovy/org/grails/gsp/GroovyPage.groovy
similarity index 53%
rename from grails-gsp/core/src/main/groovy/org/grails/gsp/GroovyPage.java
rename to grails-gsp/core/src/main/groovy/org/grails/gsp/GroovyPage.groovy
index db19c7a9928..f3e3f07caad 100644
--- a/grails-gsp/core/src/main/groovy/org/grails/gsp/GroovyPage.java
+++ b/grails-gsp/core/src/main/groovy/org/grails/gsp/GroovyPage.groovy
@@ -16,50 +16,37 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.grails.gsp;
-
-import java.io.Writer;
-import java.lang.reflect.Field;
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import groovy.lang.Binding;
-import groovy.lang.Closure;
-import groovy.lang.GroovyObject;
-import groovy.lang.MissingMethodException;
-import groovy.lang.Script;
-import org.codehaus.groovy.runtime.InvokerHelper;
-import org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import grails.core.GrailsApplication;
-import grails.util.CollectionUtils;
-import org.grails.buffer.GrailsPrintWriter;
-import org.grails.encoder.Encoder;
-import org.grails.exceptions.ExceptionUtils;
-import org.grails.gsp.jsp.JspTag;
-import org.grails.gsp.jsp.JspTagLib;
-import org.grails.gsp.jsp.TagLibraryResolver;
-import org.grails.taglib.AbstractTemplateVariableBinding;
-import org.grails.taglib.GrailsTagException;
-import org.grails.taglib.GroovyPageAttributes;
-import org.grails.taglib.TagBodyClosure;
-import org.grails.taglib.TagLibraryLookup;
-import org.grails.taglib.TagLibraryMetaUtils;
-import org.grails.taglib.TagMethodContext;
-import org.grails.taglib.TagMethodInvoker;
-import org.grails.taglib.TagOutput;
-import org.grails.taglib.encoder.OutputContext;
-import org.grails.taglib.encoder.OutputEncodingStack;
-import org.grails.taglib.encoder.OutputEncodingStackAttributes;
-import org.grails.taglib.encoder.WithCodecHelper;
+package org.grails.gsp
+
+import java.lang.reflect.Field
+
+import groovy.transform.CompileStatic
+import org.apache.commons.logging.Log
+import org.apache.commons.logging.LogFactory
+import org.codehaus.groovy.runtime.InvokerHelper
+import org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation
+
+import grails.core.GrailsApplication
+import grails.util.CollectionUtils
+import org.grails.buffer.GrailsPrintWriter
+import org.grails.encoder.Encoder
+import org.grails.exceptions.ExceptionUtils
+import org.grails.gsp.jsp.JspTag
+import org.grails.gsp.jsp.JspTagLib
+import org.grails.gsp.jsp.TagLibraryResolver
+import org.grails.taglib.AbstractTemplateVariableBinding
+import org.grails.taglib.GrailsTagException
+import org.grails.taglib.GroovyPageAttributes
+import org.grails.taglib.TagBodyClosure
+import org.grails.taglib.TagLibraryLookup
+import org.grails.taglib.TagLibraryMetaUtils
+import org.grails.taglib.TagMethodContext
+import org.grails.taglib.TagMethodInvoker
+import org.grails.taglib.TagOutput
+import org.grails.taglib.encoder.OutputContext
+import org.grails.taglib.encoder.OutputEncodingStack
+import org.grails.taglib.encoder.OutputEncodingStackAttributes
+import org.grails.taglib.encoder.WithCodecHelper
/**
*
NOTE: Based on work done by on the GSP standalone project (https://gsp.dev.java.net/)
@@ -71,137 +58,140 @@
* @author Graeme Rocher
* @author Lari Hotari
*/
-public abstract class GroovyPage extends Script {
- private static final String APPLY_CODEC_TAG_NAME = "applyCodec";
- public static final String ENCODE_AS_ATTRIBUTE_NAME = "encodeAs";
- public static final Closure> EMPTY_BODY_CLOSURE = TagOutput.EMPTY_BODY_CLOSURE;
-
- private static final Log LOG = LogFactory.getLog(GroovyPage.class);
-
- public static final String OUT = "out";
- public static final String EXPRESSION_OUT = "expressionOut";
- public static final String EXPRESSION_OUT_STATEMENT = EXPRESSION_OUT; // "getCodecOut()";
- public static final String OUT_STATEMENT = OUT; // "getOut()";
- public static final String CODEC_VARNAME = "Codec";
- public static final String PLUGIN_CONTEXT_PATH = "pluginContextPath";
- public static final String EXTENSION = ".gsp";
- public static final String DEFAULT_NAMESPACE = "g";
- public static final String LINK_NAMESPACE = "link";
- public static final String TEMPLATE_NAMESPACE = "tmpl";
- public static final String PAGE_SCOPE = "pageScope";
- private OutputEncodingStackAttributes.Builder attributesBuilder;
+@CompileStatic
+abstract class GroovyPage extends Script {
+
+ private static final String APPLY_CODEC_TAG_NAME = 'applyCodec'
+ public static final String ENCODE_AS_ATTRIBUTE_NAME = 'encodeAs'
+ public static final Closure> EMPTY_BODY_CLOSURE = TagOutput.EMPTY_BODY_CLOSURE
+
+ private static final Log LOG = LogFactory.getLog(GroovyPage)
+
+ public static final String OUT = 'out'
+ public static final String EXPRESSION_OUT = 'expressionOut'
+ public static final String EXPRESSION_OUT_STATEMENT = EXPRESSION_OUT // "getCodecOut()";
+ public static final String OUT_STATEMENT = OUT // "getOut()";
+ public static final String CODEC_VARNAME = 'Codec'
+ public static final String PLUGIN_CONTEXT_PATH = 'pluginContextPath'
+ public static final String EXTENSION = '.gsp'
+ public static final String DEFAULT_NAMESPACE = 'g'
+ public static final String LINK_NAMESPACE = 'link'
+ public static final String TEMPLATE_NAMESPACE = 'tmpl'
+ public static final String PAGE_SCOPE = 'pageScope'
+ private OutputEncodingStackAttributes.Builder attributesBuilder
public static final Collection RESERVED_NAMES = CollectionUtils.newSet(
OUT,
EXPRESSION_OUT,
CODEC_VARNAME,
PLUGIN_CONTEXT_PATH,
- PAGE_SCOPE);
-
- private static final String BINDING = "binding";
- private static final String BLANK_STRING = "";
- @SuppressWarnings("rawtypes")
- private Map jspTags = Collections.emptyMap();
- private TagLibraryResolver jspTagLibraryResolver;
- protected TagLibraryLookup gspTagLibraryLookup;
- private String[] htmlParts;
- private Set htmlPartsSet;
- private GrailsPrintWriter out;
- private GrailsPrintWriter staticOut;
- private GrailsPrintWriter expressionOut;
- private OutputEncodingStack outputStack;
- protected OutputContext outputContext;
- private String pluginContextPath;
- private Encoder rawEncoder;
-
- private final List> bodyClosures = new ArrayList<>(15);
-
- public GroovyPage() {
- init();
+ PAGE_SCOPE)
+
+ private static final String BINDING = 'binding'
+ private static final String BLANK_STRING = ''
+
+ @SuppressWarnings('rawtypes')
+ private Map jspTags = Collections.emptyMap()
+ private TagLibraryResolver jspTagLibraryResolver
+ protected TagLibraryLookup gspTagLibraryLookup
+ private String[] htmlParts
+ private Set htmlPartsSet
+ private GrailsPrintWriter out
+ private GrailsPrintWriter staticOut
+ private GrailsPrintWriter expressionOut
+ private OutputEncodingStack outputStack
+ protected OutputContext outputContext
+ private String pluginContextPath
+ private Encoder rawEncoder
+
+ private final List> bodyClosures = new ArrayList<>(15)
+
+ GroovyPage() {
+ init()
}
protected void init() {
// do nothing
}
- public final Writer getOut() {
- return out;
+ final Writer getOut() {
+ return out
}
- public final Writer getExpressionOut() {
- return expressionOut;
+ final Writer getExpressionOut() {
+ return expressionOut
}
- public void setOut(Writer newWriter) {
- throw new IllegalStateException("Setting out in page isn't allowed.");
+ void setOut(Writer newWriter) {
+ throw new IllegalStateException("Setting out in page isn't allowed.")
}
- public void initCommonRun(GroovyPageMetaInfo metaInfo) {
- attributesBuilder = new OutputEncodingStackAttributes.Builder();
+ void initCommonRun(GroovyPageMetaInfo metaInfo) {
+ attributesBuilder = new OutputEncodingStackAttributes.Builder()
if (metaInfo != null) {
- attributesBuilder.outEncoder(metaInfo.getOutEncoder());
- attributesBuilder.staticEncoder(metaInfo.getStaticEncoder());
- attributesBuilder.expressionEncoder(metaInfo.getExpressionEncoder());
- attributesBuilder.defaultTaglibEncoder(metaInfo.getTaglibEncoder());
- setHtmlParts(metaInfo.getHtmlParts());
- setHtmlPartsSet(metaInfo.getHtmlPartsSet());
- setJspTags(metaInfo.getJspTags());
- setJspTagLibraryResolver(metaInfo.getJspTagLibraryResolver());
- setGspTagLibraryLookup(metaInfo.getTagLibraryLookup());
- setPluginContextPath(metaInfo.getPluginPath());
+ attributesBuilder.outEncoder(metaInfo.getOutEncoder())
+ attributesBuilder.staticEncoder(metaInfo.getStaticEncoder())
+ attributesBuilder.expressionEncoder(metaInfo.getExpressionEncoder())
+ attributesBuilder.defaultTaglibEncoder(metaInfo.getTaglibEncoder())
+ setHtmlParts(metaInfo.getHtmlParts())
+ setHtmlPartsSet(metaInfo.getHtmlPartsSet())
+ setJspTags(metaInfo.getJspTags())
+ setJspTagLibraryResolver(metaInfo.getJspTagLibraryResolver())
+ setGspTagLibraryLookup(metaInfo.getTagLibraryLookup())
+ setPluginContextPath(metaInfo.getPluginPath())
}
- attributesBuilder.allowCreate(true).autoSync(false).pushTop(true);
- attributesBuilder.inheritPreviousEncoders(false);
+ attributesBuilder.allowCreate(true).autoSync(false).pushTop(true)
+ attributesBuilder.inheritPreviousEncoders(false)
}
- public void initRun(Writer target, OutputContext outputContext, GroovyPageMetaInfo metaInfo) {
+ void initRun(Writer target, OutputContext outputContext, GroovyPageMetaInfo metaInfo) {
if (metaInfo != null) {
- applyModelFieldsFromBinding(metaInfo.getModelFields());
+ applyModelFieldsFromBinding(metaInfo.getModelFields())
}
- attributesBuilder.outputContext(outputContext);
- attributesBuilder.topWriter(target);
- outputStack = OutputEncodingStack.currentStack(attributesBuilder.build());
+ attributesBuilder.outputContext(outputContext)
+ attributesBuilder.topWriter(target)
+ outputStack = OutputEncodingStack.currentStack(attributesBuilder.build())
- out = outputStack.getOutWriter();
- staticOut = outputStack.getStaticWriter();
- expressionOut = outputStack.getExpressionWriter();
+ out = outputStack.getOutWriter()
+ staticOut = outputStack.getStaticWriter()
+ expressionOut = outputStack.getExpressionWriter()
- this.outputContext = outputContext;
+ this.outputContext = outputContext
if (outputContext != null) {
- outputContext.setCurrentWriter(out);
- GrailsApplication grailsApplication = outputContext.getGrailsApplication();
+ outputContext.setCurrentWriter(out)
+ GrailsApplication grailsApplication = outputContext.getGrailsApplication()
if (grailsApplication != null) {
- rawEncoder = WithCodecHelper.lookupEncoder(grailsApplication, "Raw");
+ rawEncoder = WithCodecHelper.lookupEncoder(grailsApplication, 'Raw')
}
}
- setVariableDirectly(OUT, out);
- setVariableDirectly(EXPRESSION_OUT, expressionOut);
+ setVariableDirectly(OUT, out)
+ setVariableDirectly(EXPRESSION_OUT, expressionOut)
}
private void applyModelFieldsFromBinding(Iterable modelFields) {
- for (Field field : modelFields) {
- Object value = getProperty(field.getName());
+ for (Field field in modelFields) {
+ Object value = getProperty(field.getName())
if (value == null) {
- continue;
+ continue
}
- Object converted;
+ Object converted
try {
- converted = DefaultTypeTransformation.castToType(value, field.getType());
+ converted = DefaultTypeTransformation.castToType(value, field.getType())
} catch (RuntimeException e) {
- throw new GroovyPagesException("Model field '" + field.getName() + "' is declared as " +
- field.getType().getName() + " but the model supplied an instance of " +
- value.getClass().getName() + ", which cannot be converted to it.", e, -1, getGroovyPageFileName());
+ throw new GroovyPagesException("Model field '${field.getName()}' is declared as " +
+ "${field.getType().getName()} but the model supplied an instance of " +
+ "${value.getClass().getName()}, which cannot be converted to it.", e, -1, getGroovyPageFileName())
}
if (value instanceof Number && converted instanceof Number && !sameNumericValue((Number) value, (Number) converted)) {
- throw new GroovyPagesException("Model field '" + field.getName() + "' is declared as " +
- field.getType().getName() + ", which cannot hold the " + value.getClass().getName() + " " +
- value + " the model supplied without changing it.", null, -1, getGroovyPageFileName());
+ throw new GroovyPagesException("Model field '${field.getName()}' is declared as " +
+ "${field.getType().getName()}, which cannot hold the ${value.getClass().getName()} " +
+ "${value} the model supplied without changing it.", null, -1, getGroovyPageFileName())
}
try {
- field.set(this, converted);
+ field.set(this, converted)
} catch (IllegalAccessException e) {
- throw new GroovyPagesException("Error setting model field '" + field.getName() + "'", e, -1, getGroovyPageFileName());
+ throw new GroovyPagesException("Error setting model field '" + field.getName() + "'", e, -1, getGroovyPageFileName())
}
}
}
@@ -209,7 +199,7 @@ private void applyModelFieldsFromBinding(Iterable modelFields) {
private static boolean sameNumericValue(Number original, Number converted) {
if (isFloatingPoint(original) && isFloatingPoint(converted)) {
// Every float is exactly representable as a double, including NaN and infinities.
- return Double.compare(original.doubleValue(), converted.doubleValue()) == 0;
+ return Double.compare(original.doubleValue(), converted.doubleValue()) == 0
}
// A floating-point value prints as the shortest decimal that reads back to it, which is
// also the decimal Groovy converts it to, so comparing the decimal forms accepts exactly
@@ -217,64 +207,64 @@ private static boolean sameNumericValue(Number original, Number converted) {
// BigDecimal. A decimal with more digits than the type can carry prints differently
// once converted and is rejected.
try {
- return new BigDecimal(original.toString()).compareTo(new BigDecimal(converted.toString())) == 0;
- } catch (NumberFormatException e) {
+ return new BigDecimal(original.toString()).compareTo(new BigDecimal(converted.toString())) == 0
+ } catch (NumberFormatException ignored) {
// A non-finite floating-point value cannot equal a finite decimal or integer.
- return false;
+ return false
}
}
private static boolean isFloatingPoint(Number number) {
- return number instanceof Float || number instanceof Double;
+ return number instanceof Float || number instanceof Double
}
- public Object raw(Object value) {
+ Object raw(Object value) {
if (rawEncoder == null) {
- return InvokerHelper.invokeMethod(value, "encodeAsRaw", null);
+ return InvokerHelper.invokeMethod(value, 'encodeAsRaw', null)
}
- return rawEncoder.encode(value);
+ return rawEncoder.encode(value)
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings('unchecked')
private void setVariableDirectly(String name, Object value) {
- Binding binding = getBinding();
+ Binding binding = getBinding()
if (binding instanceof AbstractTemplateVariableBinding) {
- ((AbstractTemplateVariableBinding) binding).setVariableDirectly(name, value);
+ ((AbstractTemplateVariableBinding) binding).setVariableDirectly(name, value)
} else {
- binding.getVariables().put(name, value);
+ binding.getVariables().put(name, value)
}
}
- public String getPluginContextPath() {
- return pluginContextPath != null ? pluginContextPath : BLANK_STRING;
+ String getPluginContextPath() {
+ return pluginContextPath != null ? pluginContextPath : BLANK_STRING
}
- public void setPluginContextPath(String pluginContextPath) {
- this.pluginContextPath = pluginContextPath;
+ void setPluginContextPath(String pluginContextPath) {
+ this.pluginContextPath = pluginContextPath
}
- public void cleanup() {
- outputStack.pop(true);
+ void cleanup() {
+ outputStack.pop(true)
}
- public final void createClosureForHtmlPart(int partNumber, int bodyClosureIndex) {
- final String htmlPart = htmlParts[partNumber];
- setBodyClosure(bodyClosureIndex, new TagOutput.ConstantClosure(htmlPart));
+ final void createClosureForHtmlPart(int partNumber, int bodyClosureIndex) {
+ final String htmlPart = htmlParts[partNumber]
+ setBodyClosure(bodyClosureIndex, new TagOutput.ConstantClosure(htmlPart))
}
- public final void setBodyClosure(int index, Closure> bodyClosure) {
+ final void setBodyClosure(int index, Closure> bodyClosure) {
while (index >= bodyClosures.size()) {
- bodyClosures.add(null);
+ bodyClosures.add(null)
}
- bodyClosures.set(index, bodyClosure);
+ bodyClosures.set(index, bodyClosure)
}
- public final Closure> getBodyClosure(int index) {
+ final Closure> getBodyClosure(int index) {
if (index >= 0) {
- return bodyClosures.get(index);
+ return bodyClosures.get(index)
}
- return null;
+ return null
}
/**
@@ -282,8 +272,8 @@ public final Closure> getBodyClosure(int index) {
*
* @param jspTagLibraryResolver The JSP tag resolve
*/
- public void setJspTagLibraryResolver(TagLibraryResolver jspTagLibraryResolver) {
- this.jspTagLibraryResolver = jspTagLibraryResolver;
+ void setJspTagLibraryResolver(TagLibraryResolver jspTagLibraryResolver) {
+ this.jspTagLibraryResolver = jspTagLibraryResolver
}
/**
@@ -291,8 +281,8 @@ public void setJspTagLibraryResolver(TagLibraryResolver jspTagLibraryResolver) {
*
* @param gspTagLibraryLookup The class used to lookup a GSP tag library
*/
- public void setGspTagLibraryLookup(TagLibraryLookup gspTagLibraryLookup) {
- this.gspTagLibraryLookup = gspTagLibraryLookup;
+ void setGspTagLibraryLookup(TagLibraryLookup gspTagLibraryLookup) {
+ this.gspTagLibraryLookup = gspTagLibraryLookup
}
/**
@@ -304,8 +294,8 @@ public void setGspTagLibraryLookup(TagLibraryLookup gspTagLibraryLookup) {
* @return the lookup, or {@code null} before the page has been initialised
* @since 8.0.0
*/
- public TagLibraryLookup getTagLibraryLookup() {
- return this.gspTagLibraryLookup;
+ TagLibraryLookup getTagLibraryLookup() {
+ return this.gspTagLibraryLookup
}
/**
@@ -314,7 +304,7 @@ public TagLibraryLookup getTagLibraryLookup() {
* @return The JSP TagLibraryResolver instance
*/
TagLibraryResolver getTagLibraryResolver() {
- return jspTagLibraryResolver;
+ return jspTagLibraryResolver
}
/**
@@ -326,27 +316,27 @@ TagLibraryResolver getTagLibraryResolver() {
* @param evaluator The expression evaluator
* @return The result
*/
- public Object evaluate(String exprText, int lineNumber, Object outerIt, Closure> evaluator) {
+ Object evaluate(String exprText, int lineNumber, Object outerIt, Closure> evaluator) {
try {
- return evaluator.call(outerIt);
+ return evaluator.call(outerIt)
} catch (Exception e) {
- throw new GroovyPagesException("Error evaluating expression [" + exprText + "] on line [" +
- lineNumber + "]: " + e.getMessage(), e, lineNumber, getGroovyPageFileName());
+ throw new GroovyPagesException('Error evaluating expression [' + exprText + '] on line [' +
+ lineNumber + ']: ' + e.getMessage(), e, lineNumber, getGroovyPageFileName())
}
}
- public abstract String getGroovyPageFileName();
+ abstract String getGroovyPageFileName()
@Override
- public Object getProperty(String property) {
- if (OUT.equals(property)) return out;
- if (EXPRESSION_OUT.equals(property)) return expressionOut;
+ Object getProperty(String property) {
+ if (OUT.equals(property)) return out
+ if (EXPRESSION_OUT.equals(property)) return expressionOut
// in GSP we assume if a property doesn't exist that
// it is null rather than throw an error this works nicely
// with the Groovy Truth
- if (BINDING.equals(property)) return getBinding();
+ if (BINDING.equals(property)) return getBinding()
- return resolveProperty(property);
+ return resolveProperty(property)
}
/**
@@ -362,56 +352,56 @@ public Object getProperty(String property) {
* @return whatever the tag produces
* @throws MissingMethodException when there is no tag library lookup to resolve the name against
*/
- public Object methodMissing(String name, Object args) {
+ Object methodMissing(String name, Object args) {
if (gspTagLibraryLookup == null) {
// Without a lookup there is nothing to resolve the name against, which is a missing
// method. Dispatching anyway arrives at the same answer, but only because a dynamic call
// on a null receiver happens to yield no tag library rather than because anything says
// so; this states the contract for a field documented as null before initialisation.
- throw new MissingMethodException(name, getClass(), makeArgumentArray(args));
+ throw new MissingMethodException(name, getClass(), makeArgumentArray(args))
}
return TagLibraryMetaUtils.methodMissingForTagLib(getMetaClass(), getClass(), gspTagLibraryLookup,
- DEFAULT_NAMESPACE, name, args, false);
+ DEFAULT_NAMESPACE, name, args, false)
}
private static Object[] makeArgumentArray(Object args) {
if (args == null) {
- return new Object[0];
+ return new Object[0]
}
- return args instanceof Object[] ? (Object[]) args : new Object[] { args };
+ return args instanceof Object[] ? (Object[]) args : [args] as Object[]
}
protected Object resolveProperty(String property) {
- Object value = getBinding().getVariable(property);
+ Object value = getBinding().getVariable(property)
if (value != null) {
- return value;
+ return value
}
// check if a taglib can be found
- value = lookupTagDispatcher(property);
+ value = lookupTagDispatcher(property)
if (value == null) {
- value = lookupJspTagLib(property);
+ value = lookupJspTagLib(property)
}
if (value != null) {
// cache lookup for next execution
- setVariableDirectly(property, value);
+ setVariableDirectly(property, value)
}
- return value;
+ return value
}
protected Object lookupTagDispatcher(String namespace) {
- return gspTagLibraryLookup != null ? gspTagLibraryLookup.lookupNamespaceDispatcher(namespace) : null;
+ return gspTagLibraryLookup != null ? gspTagLibraryLookup.lookupNamespaceDispatcher(namespace) : null
}
protected JspTagLib lookupJspTagLib(String jspTagLibName) {
- String uri = (String) jspTags.get(jspTagLibName);
+ String uri = (String) jspTags.get(jspTagLibName)
if (uri != null) {
- TagLibraryResolver tagResolver = getTagLibraryResolver();
- return tagResolver.resolveTagLibrary(uri);
+ TagLibraryResolver tagResolver = getTagLibraryResolver()
+ return tagResolver.resolveTagLibrary(uri)
}
- return null;
+ return null
}
/* Static call for jsp tags resolution
@@ -420,13 +410,13 @@ protected JspTagLib lookupJspTagLib(String jspTagLibName) {
* @param name tag name
* @return resolved tag if any
*/
- public JspTag getJspTag(String uri, String name) {
+ JspTag getJspTag(String uri, String name) {
if (jspTagLibraryResolver == null) {
- return null;
+ return null
}
- JspTagLib tagLib = jspTagLibraryResolver.resolveTagLibrary(uri);
- return tagLib != null ? tagLib.getTag(name) : null;
+ JspTagLib tagLib = jspTagLibraryResolver.resolveTagLibrary(uri)
+ return tagLib != null ? tagLib.getTag(name) : null
}
/**
@@ -438,179 +428,179 @@ public JspTag getJspTag(String uri, String name) {
* @param attrs The tags attributes
* @param bodyClosureIndex The index of the body variable
*/
- @SuppressWarnings({"unchecked", "rawtypes"})
- public final void invokeTag(String tagName, String tagNamespace, int lineNumber, Map attrs, int bodyClosureIndex) {
- Closure body = getBodyClosure(bodyClosureIndex);
+ @SuppressWarnings(['unchecked', 'rawtypes'])
+ final void invokeTag(String tagName, String tagNamespace, int lineNumber, Map attrs, int bodyClosureIndex) {
+ Closure body = getBodyClosure(bodyClosureIndex)
// TODO custom namespace stuff needs to be generalized and pluggable
if (tagNamespace.equals(TEMPLATE_NAMESPACE) || tagNamespace.equals(LINK_NAMESPACE)) {
- final String tmpTagName = tagName;
- final Map tmpAttrs = attrs;
- Object encodeAs = tmpAttrs.remove(ENCODE_AS_ATTRIBUTE_NAME);
+ final String tmpTagName = tagName
+ final Map tmpAttrs = attrs
+ Object encodeAs = tmpAttrs.remove(ENCODE_AS_ATTRIBUTE_NAME)
if (tagNamespace.equals(TEMPLATE_NAMESPACE)) {
- tagName = "render";
- attrs = CollectionUtils.newMap("model", tmpAttrs, "template", tmpTagName);
+ tagName = 'render'
+ attrs = CollectionUtils.newMap('model', tmpAttrs, 'template', tmpTagName)
} else if (tagNamespace.equals(LINK_NAMESPACE)) {
- tagName = "link";
- attrs = CollectionUtils.newMap("mapping", tmpTagName);
+ tagName = 'link'
+ attrs = CollectionUtils.newMap('mapping', tmpTagName)
if (!tmpAttrs.isEmpty()) {
- attrs.put("params", tmpAttrs);
+ attrs.put('params', tmpAttrs)
}
}
if (encodeAs != null) {
- attrs.put(ENCODE_AS_ATTRIBUTE_NAME, encodeAs);
+ attrs.put(ENCODE_AS_ATTRIBUTE_NAME, encodeAs)
}
- tagNamespace = DEFAULT_NAMESPACE;
+ tagNamespace = DEFAULT_NAMESPACE
}
try {
- GroovyObject tagLib = getTagLib(tagNamespace, tagName);
+ GroovyObject tagLib = getTagLib(tagNamespace, tagName)
if (tagLib != null || (gspTagLibraryLookup != null && gspTagLibraryLookup.hasNamespace(tagNamespace))) {
if (tagLib != null) {
- boolean returnsObject = gspTagLibraryLookup.doesTagReturnObject(tagNamespace, tagName);
- Object tagLibClosure = TagMethodInvoker.getClosureTagProperty(tagLib, tagName);
+ boolean returnsObject = gspTagLibraryLookup.doesTagReturnObject(tagNamespace, tagName)
+ Object tagLibClosure = TagMethodInvoker.getClosureTagProperty(tagLib, tagName)
if (tagLibClosure instanceof Closure) {
- Map encodeAsForTag = gspTagLibraryLookup.getEncodeAsForTag(tagNamespace, tagName);
- invokeTagLibClosure(tagName, tagNamespace, (Closure) tagLibClosure, attrs, body, returnsObject, encodeAsForTag);
+ Map encodeAsForTag = gspTagLibraryLookup.getEncodeAsForTag(tagNamespace, tagName)
+ invokeTagLibClosure(tagName, tagNamespace, (Closure) tagLibClosure, attrs, body, returnsObject, encodeAsForTag)
} else if (TagMethodInvoker.hasInvokableTagMethod(tagLib, tagName)) {
- Map encodeAsForTag = gspTagLibraryLookup.getEncodeAsForTag(tagNamespace, tagName);
- invokeTagLibMethod(tagName, tagNamespace, tagLib, attrs, body, returnsObject, encodeAsForTag);
+ Map encodeAsForTag = gspTagLibraryLookup.getEncodeAsForTag(tagNamespace, tagName)
+ invokeTagLibMethod(tagName, tagNamespace, tagLib, attrs, body, returnsObject, encodeAsForTag)
} else {
- throw new GrailsTagException("Tag [" + tagName + "] does not exist in tag library [" + tagLib.getClass().getName() + "]", getGroovyPageFileName(), lineNumber);
+ throw new GrailsTagException('Tag [' + tagName + '] does not exist in tag library [' + tagLib.getClass().getName() + ']', getGroovyPageFileName(), lineNumber)
}
} else {
- throw new GrailsTagException("Tag [" + tagName + "] does not exist. No tag library found for namespace: " + tagNamespace, getGroovyPageFileName(), lineNumber);
+ throw new GrailsTagException('Tag [' + tagName + '] does not exist. No tag library found for namespace: ' + tagNamespace, getGroovyPageFileName(), lineNumber)
}
} else {
- staticOut.append('<').append(tagNamespace).append(':').append(tagName);
- for (Object o : attrs.entrySet()) {
- Map.Entry entry = (Map.Entry) o;
- staticOut.append(' ');
- staticOut.append(entry.getKey()).append('=');
- String value = String.valueOf(entry.getValue());
+ staticOut.append('<').append(tagNamespace).append(':').append(tagName)
+ for (Object o in attrs.entrySet()) {
+ Map.Entry entry = (Map.Entry) o
+ staticOut.append(' ')
+ staticOut.append(entry.getKey()).append('=')
+ String value = String.valueOf(entry.getValue())
// handle attribute value quotes & possible escaping " -> "
- boolean containsQuotes = (value.indexOf('"') > -1);
- boolean containsSingleQuote = (value.indexOf('\'') > -1);
+ boolean containsQuotes = (value.indexOf('"') > -1)
+ boolean containsSingleQuote = (value.indexOf('\'') > -1)
if (containsQuotes && !containsSingleQuote) {
- staticOut.append('\'').append(value).append('\'');
+ staticOut.append('\'').append(value).append('\'')
} else if (containsQuotes & containsSingleQuote) {
- staticOut.append('\"').append(value.replaceAll("\"", """)).append('\"');
+ staticOut.append('"').append(value.replaceAll('"', '"')).append('"')
} else {
- staticOut.append('\"').append(value).append('\"');
+ staticOut.append('\"').append(value).append('\"')
}
}
if (body == null) {
- staticOut.append("/>");
+ staticOut.append('/>')
} else {
- staticOut.append('>');
- Object bodyOutput = body.call();
- if (bodyOutput != null) staticOut.print(bodyOutput);
- staticOut.append("").append(tagNamespace).append(':').append(tagName).append('>');
+ staticOut.append('>')
+ Object bodyOutput = ((Closure
*/
- String[] pageScopeVariables() default {};
+ String[] pageScopeVariables() default []
/**
* Whether a name the page never declares, and a member read from something whose type is not
@@ -49,5 +50,6 @@
* has not declared the model of every page: what can be checked is checked, and what cannot is
* left to run as it always has. Turning it on asks for the guarantee instead.
*/
- boolean strict() default false;
+ boolean strict() default false
+
}
diff --git a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/PageScopeVariableScanner.java b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/PageScopeVariableScanner.groovy
similarity index 77%
rename from grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/PageScopeVariableScanner.java
rename to grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/PageScopeVariableScanner.groovy
index 4f1c0136f9b..8ac83be3c0b 100644
--- a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/PageScopeVariableScanner.java
+++ b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/PageScopeVariableScanner.groovy
@@ -16,9 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.grails.gsp.compiler;
+package org.grails.gsp.compiler
-import java.util.Set;
+import groovy.transform.CompileStatic
/**
* Finds the names a page introduces through the {@code var} and {@code status} attributes of the
@@ -39,6 +39,7 @@
* recursing once per character until the compiling thread runs out of stack. Here the work is linear
* in the page and the depth of the call stack is constant, whatever the page contains.
*/
+@CompileStatic
final class PageScopeVariableScanner {
private PageScopeVariableScanner() {
@@ -49,21 +50,21 @@ private PageScopeVariableScanner() {
* namespaced tag in {@code source}.
*/
static void collect(String source, Set names) {
- int length = source.length();
- int i = 0;
+ int length = source.length()
+ int i = 0
while (i < length) {
- int afterNamespace = source.charAt(i) == '<' ? namespaceEnd(source, i + 1) : -1;
- i = afterNamespace < 0 ? i + 1 : scanTag(source, afterNamespace, names);
+ int afterNamespace = source.charAt(i) == '<' ? namespaceEnd(source, i + 1) : -1
+ i = afterNamespace < 0 ? i + 1 : scanTag(source, afterNamespace, names)
}
}
/** The index just past {@code \w+:} starting at {@code from}, or -1 when there is none there. */
private static int namespaceEnd(String source, int from) {
- int i = from;
+ int i = from
while (i < source.length() && isWordChar(source.charAt(i))) {
- i++;
+ i++
}
- return i > from && i < source.length() && source.charAt(i) == ':' ? i + 1 : -1;
+ return i > from && i < source.length() && source.charAt(i) == ':' ? i + 1 : -1
}
/**
@@ -71,24 +72,24 @@ private static int namespaceEnd(String source, int from) {
* the index just past its closing {@code >}, or the end of the source when it has none.
*/
private static int scanTag(String source, int from, Set names) {
- int length = source.length();
- int i = from;
+ int length = source.length()
+ int i = from
while (i < length) {
- char c = source.charAt(i);
+ char c = source.charAt(i)
if (c == '>') {
- return i + 1;
+ return i + 1
}
if (isExpressionStart(source, i)) {
- i = skipExpression(source, i + 2);
+ i = skipExpression(source, i + 2)
} else if (c == '"' || c == '\'') {
- i = skipAttributeValue(source, i + 1, c);
+ i = skipAttributeValue(source, i + 1, c)
} else if (isWordChar(c) && !isWordChar(source.charAt(i - 1))) {
- i = readAttributeName(source, i, names);
+ i = readAttributeName(source, i, names)
} else {
- i++;
+ i++
}
}
- return length;
+ return length
}
/**
@@ -97,36 +98,36 @@ private static int scanTag(String source, int from, Set names) {
* leaving the value to be stepped over as any other quoted value is.
*/
private static int readAttributeName(String source, int from, Set names) {
- int length = source.length();
- int end = from;
+ int length = source.length()
+ int end = from
while (end < length && isWordChar(source.charAt(end))) {
- end++;
+ end++
}
- String name = source.substring(from, end);
- if (!name.equals("var") && !name.equals("status")) {
- return end;
+ String name = source.substring(from, end)
+ if (!name.equals('var') && !name.equals('status')) {
+ return end
}
- int i = skipWhitespace(source, end);
+ int i = skipWhitespace(source, end)
if (i >= length || source.charAt(i) != '=') {
- return end;
+ return end
}
- i = skipWhitespace(source, i + 1);
+ i = skipWhitespace(source, i + 1)
if (i >= length || (source.charAt(i) != '"' && source.charAt(i) != '\'')) {
- return end;
+ return end
}
- int identifierStart = i + 1;
- int identifierEnd = identifierStart;
+ int identifierStart = i + 1
+ int identifierEnd = identifierStart
if (identifierEnd < length && isIdentifierStart(source.charAt(identifierEnd))) {
- identifierEnd++;
+ identifierEnd++
while (identifierEnd < length && isIdentifierPart(source.charAt(identifierEnd))) {
- identifierEnd++;
+ identifierEnd++
}
- char closing = identifierEnd < length ? source.charAt(identifierEnd) : 0;
+ char closing = identifierEnd < length ? source.charAt(identifierEnd) : (char) 0
if (closing == '"' || closing == '\'') {
- names.add(source.substring(identifierStart, identifierEnd));
+ names.add(source.substring(identifierStart, identifierEnd))
}
}
- return end;
+ return end
}
/**
@@ -136,8 +137,8 @@ private static int readAttributeName(String source, int from, Set names)
* the source.
*/
private static int skipAttributeValue(String source, int from, char quote) {
- int end = new GroovyPageExpressionParser(source, from, quote, (char) 0, false).parse();
- return end < 0 ? source.length() : end + 1;
+ int end = new GroovyPageExpressionParser(source, from, quote, (char) 0, false).parse()
+ return end < 0 ? source.length() : end + 1
}
/**
@@ -146,32 +147,34 @@ private static int skipAttributeValue(String source, int from, char quote) {
* past the closing brace, or the end of the source.
*/
private static int skipExpression(String source, int from) {
- int end = new GroovyPageExpressionParser(source, from, '}', (char) 0, true).parse();
- return end < 0 ? source.length() : end + 1;
+ int end = new GroovyPageExpressionParser(source, from, (char) '}', (char) 0, true).parse()
+ return end < 0 ? source.length() : end + 1
}
private static boolean isExpressionStart(String source, int i) {
- return source.charAt(i) == '$' && i + 1 < source.length() && source.charAt(i + 1) == '{';
+ return source.charAt(i) == '$' && i + 1 < source.length() && source.charAt(i + 1) == '{'
}
private static int skipWhitespace(String source, int from) {
- int i = from;
+ int i = from
while (i < source.length() && Character.isWhitespace(source.charAt(i))) {
- i++;
+ i++
}
- return i;
+ return i
}
/** {@code \w} as a regular expression reads it: ASCII letters, digits and underscore. */
private static boolean isWordChar(char c) {
- return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_';
+ int code = (int) c
+ return (code >= 97 && code <= 122) || (code >= 65 && code <= 90) || (code >= 48 && code <= 57) || c == '_'
}
private static boolean isIdentifierStart(char c) {
- return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || c == '$';
+ int code = (int) c
+ return (code >= 97 && code <= 122) || (code >= 65 && code <= 90) || c == '_' || c == '$'
}
private static boolean isIdentifierPart(char c) {
- return isWordChar(c) || c == '$';
+ return isWordChar(c) || c == '$'
}
}
diff --git a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/Reverse.java b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/Reverse.groovy
similarity index 64%
rename from grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/Reverse.java
rename to grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/Reverse.groovy
index c4ab5a0cffc..110afd57b48 100644
--- a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/Reverse.java
+++ b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/Reverse.groovy
@@ -16,7 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.grails.gsp.compiler;
+package org.grails.gsp.compiler
+
+import groovy.transform.CompileStatic
/**
* NOTE: Based on work done by on the GSP standalone project (https://gsp.dev.java.net/)
@@ -25,40 +27,43 @@
*
* @author Troy Heninger
*/
+@CompileStatic
class Reverse implements CharSequence {
- private CharSequence text;
- private int start, end, anchor;
+
+ private CharSequence text
+ private int start, end, anchor
Reverse(CharSequence text) {
- this(text, 0, text.length());
+ this(text, 0, text.length())
}
Reverse(CharSequence text, int start, int end) {
- this.text = text;
- this.start = start;
- this.end = end;
- anchor = end - 1;
+ this.text = text
+ this.start = start
+ this.end = end
+ anchor = end - 1
}
- public char charAt(int index) {
- return text.charAt(anchor - index);
+ char charAt(int index) {
+ return text.charAt(anchor - index)
}
- public int length() {
- return end - start;
+ int length() {
+ return end - start
}
- public CharSequence subSequence(int start, int end) {
- return new Reverse(text, anchor - end, anchor - start);
+ CharSequence subSequence(int start, int end) {
+ return new Reverse(text, anchor - end, anchor - start)
}
@Override
- public String toString() {
- int len = length();
- StringBuilder buf = new StringBuilder(len);
+ String toString() {
+ int len = length()
+ StringBuilder buf = new StringBuilder(len)
for (int ix = anchor; ix >= start; ix--) {
- buf.append(text.charAt(ix));
+ buf.append(text.charAt(ix))
}
- return buf.toString();
+ return buf.toString()
}
+
}
diff --git a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/Strip.java b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/Strip.groovy
similarity index 56%
rename from grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/Strip.java
rename to grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/Strip.groovy
index 5f31f043d6b..ed1d5768749 100644
--- a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/Strip.java
+++ b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/Strip.groovy
@@ -16,10 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.grails.gsp.compiler;
+package org.grails.gsp.compiler
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+import java.util.regex.Matcher
+import java.util.regex.Pattern
+
+import groovy.transform.CompileStatic
/**
* NOTE: Based on work done by on the GSP standalone project (https://gsp.dev.java.net/)
@@ -29,51 +31,54 @@
* @author Troy Heninger
* Date: Jan 10, 2004
*/
+@CompileStatic
class Strip {
- private static Pattern stripTag = Pattern.compile("\\^([a-zA-Z]+)%\\{([^}]|\\}[^%])*\\}%");
- private static Pattern anyTag = Pattern.compile("((\\^[a-zA-Z])?%\\{([^}]|\\}[^%])*\\}%|[$@]\\{[^}]*\\})");
+
+ private static Pattern stripTag = Pattern.compile('\\^([a-zA-Z]+)%\\{([^}]|\\}[^%])*\\}%')
+ private static Pattern anyTag = Pattern.compile('((\\^[a-zA-Z])?%\\{([^}]|\\}[^%])*\\}%|[\$@]\\{[^}]*\\})')
// not thread-safe but only used in the GroovyPageScanner constructor
- private StringBuilder text;
+ private StringBuilder text
Strip(CharSequence text) {
- this.text = new StringBuilder(text.toString());
+ this.text = new StringBuilder(text.toString())
}
void strip(int index) {
- Matcher match = stripTag.matcher(text);
+ Matcher match = stripTag.matcher(text)
if (match.find(index)) {
- strip(match.end());
- String tag = match.group(1);
- int start = match.start() + 1 + tag.length(); // begin after '^tag'; at the '%{'
- int end = match.end();
- Pattern patAfter = Pattern.compile("" + tag + "(>|[^>a-zA-Z][^>]*>)\\s*", Pattern.CASE_INSENSITIVE);
- Matcher matchAfter = patAfter.matcher(text);
+ strip(match.end())
+ String tag = match.group(1)
+ int start = match.start() + 1 + tag.length() // begin after '^tag'; at the '%{'
+ int end = match.end()
+ Pattern patAfter = Pattern.compile('' + tag + '(>|[^>a-zA-Z][^>]*>)\\s*', Pattern.CASE_INSENSITIVE)
+ Matcher matchAfter = patAfter.matcher(text)
if (matchAfter.find(end)) {
- int end2 = matchAfter.end();
- Matcher matchAny = anyTag.matcher(text.subSequence(0, end2));
- if (matchAny.find(end)) end2 = matchAny.start();
- Pattern nextTagPat = Pattern.compile("<" + tag + "(\\s|>)", Pattern.CASE_INSENSITIVE);
- Matcher matchNext = nextTagPat.matcher(text.subSequence(0, end2));
- if (matchNext.find(end)) end2 = matchNext.start();
+ int end2 = matchAfter.end()
+ Matcher matchAny = anyTag.matcher(text.subSequence(0, end2))
+ if (matchAny.find(end)) end2 = matchAny.start()
+ Pattern nextTagPat = Pattern.compile('<' + tag + '(\\s|>)', Pattern.CASE_INSENSITIVE)
+ Matcher matchNext = nextTagPat.matcher(text.subSequence(0, end2))
+ if (matchNext.find(end)) end2 = matchNext.start()
// System.out.println("Stripping " + text.subSequence(end, end2));
- text.delete(end, end2);
+ text.delete(end, end2)
}
- Pattern patBefore = Pattern.compile(new Reverse("*s\\<" + tag).toString(),
- Pattern.CASE_INSENSITIVE);
- Matcher matchBefore = patBefore.matcher(new Reverse(text, 0, start));
+ Pattern patBefore = Pattern.compile(new Reverse('*s\\<' + tag).toString(),
+ Pattern.CASE_INSENSITIVE)
+ Matcher matchBefore = patBefore.matcher(new Reverse(text, 0, start))
if (matchBefore.find()) {
- int start2 = start - matchBefore.end();
- Matcher matchAny = anyTag.matcher(text.subSequence(0, start));
- if (matchAny.find(start2)) start2 = matchAny.end();
+ int start2 = start - matchBefore.end()
+ Matcher matchAny = anyTag.matcher(text.subSequence(0, start))
+ if (matchAny.find(start2)) start2 = matchAny.end()
// System.out.println("Stripping " + text.subSequence(start2, start));
- text.delete(start2, start);
+ text.delete(start2, start)
}
}
}
@Override
- public String toString() {
- return text.toString();
+ String toString() {
+ return text.toString()
}
+
}
diff --git a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/Tokens.java b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/Tokens.groovy
similarity index 69%
rename from grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/Tokens.java
rename to grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/Tokens.groovy
index 02499f8ae5d..633fbd6e171 100644
--- a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/Tokens.java
+++ b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/Tokens.groovy
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.grails.gsp.compiler;
+package org.grails.gsp.compiler
/**
* NOTE: Based on work done by on the GSP standalone project (https://gsp.dev.java.net/)
@@ -29,18 +29,20 @@
* Date: Jan 10, 2004
*/
interface Tokens {
- int EOF = -1;
- int HTML = 0;
- int JEXPR = 1; // <%= ... %>
- int JSCRIPT = 2; // <% .... %>
- int JDIRECT = 3; // <%@ ... %>
- int JDECLAR = 4; // <%! ... %>
- int GEXPR = 11; // ${ ... }
- int GSCRIPT = 12; // %{ ... }%
- int GDIRECT = 13; // @{ ... }
- int GDECLAR = 14; // !{ ... }!
- int GSTART_TAG = 15; //
- int GEND_TAG = 16; //
- int GTAG_EXPR = 17; // ${..}
- int GEND_EMPTY_TAG = 18;
+
+ int EOF = -1
+ int HTML = 0
+ int JEXPR = 1 // <%= ... %>
+ int JSCRIPT = 2 // <% .... %>
+ int JDIRECT = 3 // <%@ ... %>
+ int JDECLAR = 4 // <%! ... %>
+ int GEXPR = 11 // ${ ... }
+ int GSCRIPT = 12 // %{ ... }%
+ int GDIRECT = 13 // @{ ... }
+ int GDECLAR = 14 // !{ ... }!
+ int GSTART_TAG = 15 //
+ int GEND_TAG = 16 //
+ int GTAG_EXPR = 17 // ${..}
+ int GEND_EMPTY_TAG = 18
+
}
diff --git a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GrailsTag.java b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GrailsTag.groovy
similarity index 77%
rename from grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GrailsTag.java
rename to grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GrailsTag.groovy
index 8772f0014e8..4a6ffda0b95 100644
--- a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GrailsTag.java
+++ b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GrailsTag.groovy
@@ -16,10 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.grails.gsp.compiler.tags;
-
-import java.io.Writer;
-import java.util.Map;
+package org.grails.gsp.compiler.tags
/**
* Allows to tag implementation to be abstracted from the JSP custom tag spec.. hence allowing
@@ -27,43 +24,44 @@
*
* @author Graeme Rocher
*/
-public interface GrailsTag {
+interface GrailsTag {
- @SuppressWarnings("rawtypes")
- void init(Map tagContext);
+ @SuppressWarnings('rawtypes')
+ void init(Map tagContext)
/**
* Sets the writer that processes the tag
* @param w
*/
- void setWriter(Writer w);
+ void setWriter(Writer w)
/**
* Sets the attributes of the tag
* @param attributes
*/
- @SuppressWarnings("rawtypes")
- void setAttributes(Map attributes);
+ @SuppressWarnings('rawtypes')
+ void setAttributes(Map attributes)
/**
* Sets an attribute of the tag
* @param name
* @param value
*/
- void setAttribute(String name, Object value);
+ void setAttribute(String name, Object value)
/**
* Process the start tag
*/
- void doStartTag();
+ void doStartTag()
/**
* process the end tag
*/
- void doEndTag();
+ void doEndTag()
/**
* @return The name of the tag
*/
- String getName();
+ String getName()
+
}
diff --git a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GrailsTagRegistry.java b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GrailsTagRegistry.groovy
similarity index 61%
rename from grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GrailsTagRegistry.java
rename to grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GrailsTagRegistry.groovy
index 09d1d1c315d..78325b3ca34 100644
--- a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GrailsTagRegistry.java
+++ b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GrailsTagRegistry.groovy
@@ -16,76 +16,79 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.grails.gsp.compiler.tags;
+package org.grails.gsp.compiler.tags
-import java.lang.reflect.InvocationTargetException;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
+import java.lang.reflect.InvocationTargetException
+import java.util.concurrent.ConcurrentHashMap
-import org.grails.taglib.GrailsTagException;
+import groovy.transform.CompileStatic
+
+import org.grails.taglib.GrailsTagException
/**
* A registry for holding all Grails tag implementations.
*
* @author Graeme Rocher
*/
-public class GrailsTagRegistry {
+@CompileStatic
+class GrailsTagRegistry {
- private static GrailsTagRegistry instance = new GrailsTagRegistry();
+ private static GrailsTagRegistry instance = new GrailsTagRegistry()
- private static Map> tagRegistry = new ConcurrentHashMap<>();
+ private static Map> tagRegistry = new ConcurrentHashMap<>()
static {
- instance.registerTag(GroovyEachTag.TAG_NAME, GroovyEachTag.class);
- instance.registerTag(GroovyIfTag.TAG_NAME, GroovyIfTag.class);
- instance.registerTag(GroovyUnlessTag.TAG_NAME, GroovyUnlessTag.class);
- instance.registerTag(GroovyElseTag.TAG_NAME, GroovyElseTag.class);
- instance.registerTag(GroovyElseIfTag.TAG_NAME, GroovyElseIfTag.class);
- instance.registerTag(GroovyFindAllTag.TAG_NAME, GroovyFindAllTag.class);
- instance.registerTag(GroovyCollectTag.TAG_NAME, GroovyCollectTag.class);
- instance.registerTag(GroovyGrepTag.TAG_NAME, GroovyGrepTag.class);
- instance.registerTag(GroovyWhileTag.TAG_NAME, GroovyWhileTag.class);
- instance.registerTag(GroovyDefTag.TAG_NAME, GroovyDefTag.class);
+ instance.registerTag(GroovyEachTag.TAG_NAME, GroovyEachTag)
+ instance.registerTag(GroovyIfTag.TAG_NAME, GroovyIfTag)
+ instance.registerTag(GroovyUnlessTag.TAG_NAME, GroovyUnlessTag)
+ instance.registerTag(GroovyElseTag.TAG_NAME, GroovyElseTag)
+ instance.registerTag(GroovyElseIfTag.TAG_NAME, GroovyElseIfTag)
+ instance.registerTag(GroovyFindAllTag.TAG_NAME, GroovyFindAllTag)
+ instance.registerTag(GroovyCollectTag.TAG_NAME, GroovyCollectTag)
+ instance.registerTag(GroovyGrepTag.TAG_NAME, GroovyGrepTag)
+ instance.registerTag(GroovyWhileTag.TAG_NAME, GroovyWhileTag)
+ instance.registerTag(GroovyDefTag.TAG_NAME, GroovyDefTag)
}
private GrailsTagRegistry() {
// singleton
}
- public static GrailsTagRegistry getInstance() {
- return instance;
+ static GrailsTagRegistry getInstance() {
+ return instance
}
- public void registerTag(String tagName, Class> tag) {
- tagRegistry.put(tagName, tag);
+ void registerTag(String tagName, Class> tag) {
+ tagRegistry.put(tagName, tag)
}
- public boolean tagSupported(String tagName) {
- return tagRegistry.containsKey(tagName);
+ boolean tagSupported(String tagName) {
+ return tagRegistry.containsKey(tagName)
}
- public boolean isSyntaxTag(String tagName) {
+ boolean isSyntaxTag(String tagName) {
if (tagRegistry.containsKey(tagName)) {
- return GroovySyntaxTag.class.isAssignableFrom(tagRegistry.get(tagName));
+ return GroovySyntaxTag.isAssignableFrom(tagRegistry.get(tagName))
}
- return false;
+ return false
}
- public GrailsTag newTag(String tagName) {
+ GrailsTag newTag(String tagName) {
if (!tagRegistry.containsKey(tagName)) {
- throw new GrailsTagException("Tag [" + tagName + "] is not a a valid grails tag");
+ throw new GrailsTagException('Tag [' + tagName + '] is not a a valid grails tag')
}
- Class> tagClass = tagRegistry.get(tagName);
+ Class> tagClass = tagRegistry.get(tagName)
try {
- return (GrailsTag) tagClass.getDeclaredConstructor().newInstance();
+ return (GrailsTag) tagClass.getDeclaredConstructor().newInstance()
}
catch (InstantiationException | InvocationTargetException | NoSuchMethodException e) {
- throw new GrailsTagException("Instantiation error loading tag [" + tagName + "]: " + e.getMessage(), e);
+ throw new GrailsTagException('Instantiation error loading tag [' + tagName + ']: ' + e.getMessage(), e)
}
catch (IllegalAccessException e) {
- throw new GrailsTagException("Illegal access error loading tag [" + tagName + "]: " + e.getMessage(), e);
+ throw new GrailsTagException('Illegal access error loading tag [' + tagName + ']: ' + e.getMessage(), e)
}
}
+
}
diff --git a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyCollectTag.java b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyCollectTag.groovy
similarity index 64%
rename from grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyCollectTag.java
rename to grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyCollectTag.groovy
index 2e1945696ce..d79cbf72ef5 100644
--- a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyCollectTag.java
+++ b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyCollectTag.groovy
@@ -16,8 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/
+@SuppressWarnings('UnnecessarySemicolon')
package org.grails.gsp.compiler.tags;
+import groovy.transform.CompileStatic;
+
import grails.util.GrailsStringUtils;
import org.grails.taglib.GrailsTagException;
@@ -34,47 +37,51 @@
* @author Graeme Rocher
* @since 19-Jan-2006
*/
-public class GroovyCollectTag extends GroovySyntaxTag {
+// TODO(groovyism-cleanup): semicolons kept to preserve rename-similarity against the original .java (see matrei's review on #16576). Removed by the stacked groovyism-cleanup PR.
+@SuppressWarnings(['UnnecessarySemicolon'])
+@CompileStatic
+class GroovyCollectTag extends GroovySyntaxTag {
- public static final String TAG_NAME = "collect";
- private static final String ATTRIBUTE_EXPR = "expr";
+ public static final String TAG_NAME = 'collect';
+ private static final String ATTRIBUTE_EXPR = 'expr';
@Override
- public boolean isKeepPrecedingWhiteSpace() {
+ boolean isKeepPrecedingWhiteSpace() {
return true;
}
@Override
- public boolean isAllowPrecedingContent() {
+ boolean isAllowPrecedingContent() {
return true;
}
- public void doStartTag() {
+ void doStartTag() {
String in = attributes.get(ATTRIBUTE_IN);
if (GrailsStringUtils.isBlank(in)) {
- throw new GrailsTagException("Tag [" + TAG_NAME + "] missing required attribute [" + ATTRIBUTE_IN + "]", parser.getPageName(), parser.getCurrentOutputLineNumber());
+ throw new GrailsTagException('Tag [' + TAG_NAME + '] missing required attribute [' + ATTRIBUTE_IN + ']', parser.getPageName(), parser.getCurrentOutputLineNumber());
}
String expr = attributes.get(ATTRIBUTE_EXPR);
if (GrailsStringUtils.isBlank(expr)) {
- throw new GrailsTagException("Tag [" + TAG_NAME + "] missing required attribute [" + ATTRIBUTE_EXPR + "]", parser.getPageName(), parser.getCurrentOutputLineNumber());
+ throw new GrailsTagException('Tag [' + TAG_NAME + '] missing required attribute [' + ATTRIBUTE_EXPR + ']', parser.getPageName(), parser.getCurrentOutputLineNumber());
}
StringBuilder builder = new StringBuilder();
builder.append(in);
- builder.append(".collect {");
+ builder.append('.collect {');
expr = calculateExpression(expr);
builder.append(expr);
- builder.append("}");
+ builder.append('}');
doEachMethod(builder.toString());
}
- public void doEndTag() {
- out.println("}");
+ void doEndTag() {
+ out.println('}');
}
- public String getName() {
+ String getName() {
return TAG_NAME;
}
+
}
diff --git a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyConditionalTag.java b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyConditionalTag.groovy
similarity index 53%
rename from grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyConditionalTag.java
rename to grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyConditionalTag.groovy
index 72069715061..8f8af80a1b7 100644
--- a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyConditionalTag.java
+++ b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyConditionalTag.groovy
@@ -16,66 +16,70 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.grails.gsp.compiler.tags;
+package org.grails.gsp.compiler.tags
-import grails.util.GrailsStringUtils;
-import org.grails.taglib.GrailsTagException;
+import groovy.transform.CompileStatic
+import grails.util.GrailsStringUtils
+import org.grails.taglib.GrailsTagException
+
+@CompileStatic
abstract class GroovyConditionalTag extends GroovySyntaxTag {
- static final String ATTRIBUTE_TEST = "test";
- static final String ATTRIBUTE_ENV = "env";
+ static final String ATTRIBUTE_TEST = 'test'
+ static final String ATTRIBUTE_ENV = 'env'
- public void doStartTag() {
- String env = attributeValueOrNull(ATTRIBUTE_ENV);
- String test = attributeValueOrNull(ATTRIBUTE_TEST);
+ void doStartTag() {
+ String env = attributeValueOrNull(ATTRIBUTE_ENV)
+ String test = attributeValueOrNull(ATTRIBUTE_TEST)
if ((env == null) && (test == null)) {
- throw new GrailsTagException("Tag [" + getName() +
- "] must have one or both of the attributes [" +
- ATTRIBUTE_TEST + "] or [" + ATTRIBUTE_ENV + "]", parser.getPageName(), parser.getCurrentOutputLineNumber());
+ throw new GrailsTagException('Tag [' + getName() +
+ '] must have one or both of the attributes [' +
+ ATTRIBUTE_TEST + '] or [' + ATTRIBUTE_ENV + ']', parser.getPageName(), parser.getCurrentOutputLineNumber())
}
- String envExpression = environmentExpressionOrTrue(env);
- String testExpression = testExpressionOrTrue(test);
+ String envExpression = environmentExpressionOrTrue(env)
+ String testExpression = testExpressionOrTrue(test)
- outputStartTag(envExpression, testExpression);
+ outputStartTag(envExpression, testExpression)
}
- protected abstract void outputStartTag(String envExpression, String testExpression);
+ protected abstract void outputStartTag(String envExpression, String testExpression)
- public void doEndTag() {
- out.println("}");
+ void doEndTag() {
+ out.println('}')
}
protected String attributeValueOrNull(String attributeName) {
- String attributeValue = attributes.get(attributeName);
- return GrailsStringUtils.isBlank(attributeValue) ? null : attributeValue;
+ String attributeValue = attributes.get(attributeName)
+ return GrailsStringUtils.isBlank(attributeValue) ? null : attributeValue
}
private String environmentExpressionOrTrue(String envAttributeValue) {
- String expression = "true";
+ String expression = 'true'
if (envAttributeValue != null) {
- expression = "(grails.util.Environment.current.name == '" + calculateExpression(envAttributeValue) + "')";
+ expression = "(grails.util.Environment.current.name == '" + calculateExpression(envAttributeValue) + "')"
}
- return expression;
+ return expression
}
private String testExpressionOrTrue(String testAttributeValue) {
- String expression = "true";
+ String expression = 'true'
if (testAttributeValue != null) {
- expression = "(" + testAttributeValue + ")";
+ expression = '(' + testAttributeValue + ')'
}
- return expression;
+ return expression
}
@Override
- public boolean isKeepPrecedingWhiteSpace() {
- return true;
+ boolean isKeepPrecedingWhiteSpace() {
+ return true
}
@Override
- public boolean isAllowPrecedingContent() {
- return true;
+ boolean isAllowPrecedingContent() {
+ return true
}
+
}
diff --git a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyDefTag.java b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyDefTag.groovy
similarity index 52%
rename from grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyDefTag.java
rename to grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyDefTag.groovy
index 0397ac3dc61..c239900df05 100644
--- a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyDefTag.java
+++ b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyDefTag.groovy
@@ -16,53 +16,56 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.grails.gsp.compiler.tags;
+package org.grails.gsp.compiler.tags
-import grails.util.GrailsStringUtils;
-import org.grails.taglib.GrailsTagException;
+import groovy.transform.CompileStatic
+
+import grails.util.GrailsStringUtils
+import org.grails.taglib.GrailsTagException
/**
* Allows defining of variables within the page context.
*
* @author Graeme Rocher
*/
-public class GroovyDefTag extends GroovySyntaxTag {
+@CompileStatic
+class GroovyDefTag extends GroovySyntaxTag {
- public static final String TAG_NAME = "def";
- private static final String ATTRIBUTE_VALUE = "value";
- private static final String ATTRIBUTE_TYPE = "type";
+ public static final String TAG_NAME = 'def'
+ private static final String ATTRIBUTE_VALUE = 'value'
+ private static final String ATTRIBUTE_TYPE = 'type'
- public void doStartTag() {
- String expr = attributes.get(ATTRIBUTE_VALUE);
+ void doStartTag() {
+ String expr = attributes.get(ATTRIBUTE_VALUE)
if (GrailsStringUtils.isBlank(expr)) {
- throw new GrailsTagException("Tag [" + TAG_NAME + "] missing required attribute [" + ATTRIBUTE_VALUE + "]", parser.getPageName(), parser.getCurrentOutputLineNumber());
+ throw new GrailsTagException('Tag [' + TAG_NAME + '] missing required attribute [' + ATTRIBUTE_VALUE + ']', parser.getPageName(), parser.getCurrentOutputLineNumber())
}
- expr = groovyExpressionFor(expr);
+ expr = groovyExpressionFor(expr)
- String var = attributes.get(ATTRIBUTE_VAR);
+ String var = attributes.get(ATTRIBUTE_VAR)
if (GrailsStringUtils.isBlank(var)) {
- throw new GrailsTagException("Tag [" + TAG_NAME + "] missing required attribute [" + ATTRIBUTE_VAR + "]", parser.getPageName(), parser.getCurrentOutputLineNumber());
+ throw new GrailsTagException('Tag [' + TAG_NAME + '] missing required attribute [' + ATTRIBUTE_VAR + ']', parser.getPageName(), parser.getCurrentOutputLineNumber())
}
- var = extractAttributeValue(var);
+ var = extractAttributeValue(var)
- String typeName = attributes.get(ATTRIBUTE_TYPE);
+ String typeName = attributes.get(ATTRIBUTE_TYPE)
if (GrailsStringUtils.isBlank(typeName)) {
- typeName = "def";
+ typeName = 'def'
} else {
- typeName = extractAttributeValue(typeName);
+ typeName = extractAttributeValue(typeName)
}
- out.print(typeName + " ");
- out.print(var);
- out.print('=');
+ out.print(typeName + ' ')
+ out.print(var)
+ out.print('=')
- if (typeName.equals("def") || typeName.equals("Object")) {
- out.println(expr);
+ if (typeName.equals('def') || typeName.equals('Object')) {
+ out.println(expr)
} else {
// A Groovy cast rather than Class.cast, which only accepts what is already of the type
// and so rejects every conversion Groovy would otherwise have made. The expression is
// parenthesised because it is written by the page and may be a GString or an operation.
- out.println("(" + typeName + ") (" + expr + ")");
+ out.println('(' + typeName + ') (' + expr + ')')
}
}
@@ -74,31 +77,32 @@ public void doStartTag() {
* the quoting a plain value carries is undone here, so that naming a variable still reads it.
*/
private static String groovyExpressionFor(String value) {
- String text = value.trim();
- if (text.contains("${")) {
- return text;
+ String text = value.trim()
+ if (text.contains('\${')) {
+ return text
}
- if ((text.startsWith("\"") && text.endsWith("\"")) || (text.startsWith("'") && text.endsWith("'"))) {
- text = text.substring(1, text.length() - 1).trim();
+ if ((text.startsWith('"') && text.endsWith('"')) || (text.startsWith("'") && text.endsWith("'"))) {
+ text = text.substring(1, text.length() - 1).trim()
}
- return text;
+ return text
}
- public void doEndTag() {
+ void doEndTag() {
// do nothing
}
- public String getName() {
- return TAG_NAME;
+ String getName() {
+ return TAG_NAME
}
@Override
- public boolean isKeepPrecedingWhiteSpace() {
- return true;
+ boolean isKeepPrecedingWhiteSpace() {
+ return true
}
@Override
- public boolean isAllowPrecedingContent() {
- return true;
+ boolean isAllowPrecedingContent() {
+ return true
}
+
}
diff --git a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyEachTag.java b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyEachTag.groovy
similarity index 56%
rename from grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyEachTag.java
rename to grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyEachTag.groovy
index e45009bcdc9..aecafe8d348 100644
--- a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyEachTag.java
+++ b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyEachTag.groovy
@@ -16,42 +16,46 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.grails.gsp.compiler.tags;
+package org.grails.gsp.compiler.tags
-import grails.util.GrailsStringUtils;
-import org.grails.taglib.GrailsTagException;
+import groovy.transform.CompileStatic
+
+import grails.util.GrailsStringUtils
+import org.grails.taglib.GrailsTagException
/**
* @author Graeme Rocher
*/
-public class GroovyEachTag extends GroovySyntaxTag {
+@CompileStatic
+class GroovyEachTag extends GroovySyntaxTag {
- public static final String TAG_NAME = "each";
+ public static final String TAG_NAME = 'each'
- public void doStartTag() {
- String in = attributes.get(ATTRIBUTE_IN);
+ void doStartTag() {
+ String in = attributes.get(ATTRIBUTE_IN)
if (GrailsStringUtils.isBlank(in)) {
- throw new GrailsTagException("Tag [" + TAG_NAME + "] missing required attribute [" + ATTRIBUTE_IN + "]", parser.getPageName(), parser.getCurrentOutputLineNumber());
+ throw new GrailsTagException('Tag [' + TAG_NAME + '] missing required attribute [' + ATTRIBUTE_IN + ']', parser.getPageName(), parser.getCurrentOutputLineNumber())
}
- doEachMethod(in);
+ doEachMethod(in)
}
- public void doEndTag() {
- endEachMethod();
+ void doEndTag() {
+ endEachMethod()
}
- public String getName() {
- return TAG_NAME;
+ String getName() {
+ return TAG_NAME
}
@Override
- public boolean isKeepPrecedingWhiteSpace() {
- return true;
+ boolean isKeepPrecedingWhiteSpace() {
+ return true
}
@Override
- public boolean isAllowPrecedingContent() {
- return true;
+ boolean isAllowPrecedingContent() {
+ return true
}
+
}
diff --git a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyElseIfTag.java b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyElseIfTag.groovy
similarity index 64%
rename from grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyElseIfTag.java
rename to grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyElseIfTag.groovy
index 3236f67c1fa..d1151c6254f 100644
--- a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyElseIfTag.java
+++ b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyElseIfTag.groovy
@@ -16,37 +16,41 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.grails.gsp.compiler.tags;
+package org.grails.gsp.compiler.tags
-public class GroovyElseIfTag extends GroovyConditionalTag {
+import groovy.transform.CompileStatic
- public static final String TAG_NAME = "elseif";
+@CompileStatic
+class GroovyElseIfTag extends GroovyConditionalTag {
+
+ public static final String TAG_NAME = 'elseif'
@Override
protected void outputStartTag(String env, String test) {
- out.print("else if (");
- out.print(env);
- out.print(" && ");
- out.print(test);
- out.println(") {");
+ out.print('else if (')
+ out.print(env)
+ out.print(' && ')
+ out.print(test)
+ out.println(') {')
}
@Override
- public void doEndTag() {
- out.println("}");
+ void doEndTag() {
+ out.println('}')
}
- public String getName() {
- return TAG_NAME;
+ String getName() {
+ return TAG_NAME
}
@Override
- public boolean isKeepPrecedingWhiteSpace() {
- return false;
+ boolean isKeepPrecedingWhiteSpace() {
+ return false
}
@Override
- public boolean isAllowPrecedingContent() {
- return false;
+ boolean isAllowPrecedingContent() {
+ return false
}
+
}
diff --git a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyElseTag.java b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyElseTag.groovy
similarity index 66%
rename from grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyElseTag.java
rename to grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyElseTag.groovy
index 621c26ed4a5..c85b4bce675 100644
--- a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyElseTag.java
+++ b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyElseTag.groovy
@@ -16,34 +16,38 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.grails.gsp.compiler.tags;
+package org.grails.gsp.compiler.tags
+
+import groovy.transform.CompileStatic
/**
* @author Graeme Rocher
*/
-public class GroovyElseTag extends GroovySyntaxTag {
+@CompileStatic
+class GroovyElseTag extends GroovySyntaxTag {
- public static final String TAG_NAME = "else";
+ public static final String TAG_NAME = 'else'
- public void doStartTag() {
- out.println("else {");
+ void doStartTag() {
+ out.println('else {')
}
- public void doEndTag() {
- out.println("}");
+ void doEndTag() {
+ out.println('}')
}
- public String getName() {
- return TAG_NAME;
+ String getName() {
+ return TAG_NAME
}
@Override
- public boolean isKeepPrecedingWhiteSpace() {
- return false;
+ boolean isKeepPrecedingWhiteSpace() {
+ return false
}
@Override
- public boolean isAllowPrecedingContent() {
- return false;
+ boolean isAllowPrecedingContent() {
+ return false
}
+
}
diff --git a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyFindAllTag.java b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyFindAllTag.groovy
similarity index 65%
rename from grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyFindAllTag.java
rename to grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyFindAllTag.groovy
index a25e0ef1319..3478a86769d 100644
--- a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyFindAllTag.java
+++ b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyFindAllTag.groovy
@@ -16,8 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/
+@SuppressWarnings('UnnecessarySemicolon')
package org.grails.gsp.compiler.tags;
+import groovy.transform.CompileStatic;
+
import grails.util.GrailsStringUtils;
import org.grails.taglib.GrailsTagException;
@@ -25,7 +28,7 @@
* Example:
*
*
- * {@code
+ * {@code
*
* ${it}
*
@@ -35,46 +38,50 @@
* @author Graeme Rocher
* @since 19-Jan-2006
*/
-public class GroovyFindAllTag extends GroovySyntaxTag {
+// TODO(groovyism-cleanup): semicolons kept to preserve rename-similarity against the original .java (see matrei's review on #16576). Removed by the stacked groovyism-cleanup PR.
+@SuppressWarnings(['UnnecessarySemicolon'])
+@CompileStatic
+class GroovyFindAllTag extends GroovySyntaxTag {
- public static final String TAG_NAME = "findAll";
- private static final String ATTRIBUTE_EXPR = "expr";
+ public static final String TAG_NAME = 'findAll';
+ private static final String ATTRIBUTE_EXPR = 'expr';
@Override
- public boolean isKeepPrecedingWhiteSpace() {
+ boolean isKeepPrecedingWhiteSpace() {
return false;
}
@Override
- public boolean isAllowPrecedingContent() {
+ boolean isAllowPrecedingContent() {
return true;
}
- public void doStartTag() {
+ void doStartTag() {
String in = attributes.get(ATTRIBUTE_IN);
if (GrailsStringUtils.isBlank(in)) {
- throw new GrailsTagException("Tag [" + TAG_NAME + "] missing required attribute [" + ATTRIBUTE_IN + "]", parser.getPageName(), parser.getCurrentOutputLineNumber());
+ throw new GrailsTagException('Tag [' + TAG_NAME + '] missing required attribute [' + ATTRIBUTE_IN + ']', parser.getPageName(), parser.getCurrentOutputLineNumber());
}
String expr = attributes.get(ATTRIBUTE_EXPR);
if (GrailsStringUtils.isBlank(expr)) {
- throw new GrailsTagException("Tag [" + TAG_NAME + "] missing required attribute [" + ATTRIBUTE_EXPR + "]", parser.getPageName(), parser.getCurrentOutputLineNumber());
+ throw new GrailsTagException('Tag [' + TAG_NAME + '] missing required attribute [' + ATTRIBUTE_EXPR + ']', parser.getPageName(), parser.getCurrentOutputLineNumber());
}
StringBuilder builder = new StringBuilder();
builder.append(in);
- builder.append(".findAll {");
+ builder.append('.findAll {');
expr = calculateExpression(expr);
builder.append(expr);
- builder.append("}");
+ builder.append('}');
doEachMethod(builder.toString());
}
- public void doEndTag() {
+ void doEndTag() {
endEachMethod();
}
- public String getName() {
+ String getName() {
return TAG_NAME;
}
+
}
diff --git a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyGrepTag.java b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyGrepTag.groovy
similarity index 65%
rename from grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyGrepTag.java
rename to grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyGrepTag.groovy
index ba61314b7f1..c2de6d83656 100644
--- a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyGrepTag.java
+++ b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyGrepTag.groovy
@@ -16,8 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/
+@SuppressWarnings('UnnecessarySemicolon')
package org.grails.gsp.compiler.tags;
+import groovy.transform.CompileStatic;
+
import grails.util.GrailsStringUtils;
import org.grails.taglib.GrailsTagException;
@@ -26,7 +29,7 @@
* Example:
*
*
- * {@code
+ * {@code
*
* ${it}
*
@@ -35,46 +38,50 @@
*
* @author Graeme Rocher
*/
-public class GroovyGrepTag extends GroovySyntaxTag {
+// TODO(groovyism-cleanup): semicolons kept to preserve rename-similarity against the original .java (see matrei's review on #16576). Removed by the stacked groovyism-cleanup PR.
+@SuppressWarnings(['UnnecessarySemicolon'])
+@CompileStatic
+class GroovyGrepTag extends GroovySyntaxTag {
- public static final String TAG_NAME = "grep";
- private static final String ATTRIBUTE_FILTER = "filter";
+ public static final String TAG_NAME = 'grep';
+ private static final String ATTRIBUTE_FILTER = 'filter';
@Override
- public boolean isKeepPrecedingWhiteSpace() {
+ boolean isKeepPrecedingWhiteSpace() {
return false;
}
@Override
- public boolean isAllowPrecedingContent() {
+ boolean isAllowPrecedingContent() {
return true;
}
- public void doStartTag() {
+ void doStartTag() {
String in = attributes.get(ATTRIBUTE_IN);
if (GrailsStringUtils.isBlank(in)) {
- throw new GrailsTagException("Tag [" + TAG_NAME + "] missing required attribute [" + ATTRIBUTE_IN + "]", parser.getPageName(), parser.getCurrentOutputLineNumber());
+ throw new GrailsTagException('Tag [' + TAG_NAME + '] missing required attribute [' + ATTRIBUTE_IN + ']', parser.getPageName(), parser.getCurrentOutputLineNumber());
}
String filter = attributes.get(ATTRIBUTE_FILTER);
if (GrailsStringUtils.isBlank(filter)) {
- throw new GrailsTagException("Tag [" + TAG_NAME + "] missing required attribute [" + ATTRIBUTE_FILTER + "]", parser.getPageName(), parser.getCurrentOutputLineNumber());
+ throw new GrailsTagException('Tag [' + TAG_NAME + '] missing required attribute [' + ATTRIBUTE_FILTER + ']', parser.getPageName(), parser.getCurrentOutputLineNumber());
}
StringBuilder builder = new StringBuilder();
builder.append(in);
- builder.append(".grep(");
+ builder.append('.grep(');
filter = calculateExpression(filter);
builder.append(filter);
- builder.append(")");
+ builder.append(')');
doEachMethod(builder.toString());
}
- public void doEndTag() {
+ void doEndTag() {
endEachMethod();
}
- public String getName() {
+ String getName() {
return TAG_NAME;
}
+
}
diff --git a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyIfTag.java b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyIfTag.groovy
similarity index 71%
rename from grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyIfTag.java
rename to grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyIfTag.groovy
index ae67ba35117..f93b48a4fba 100644
--- a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyIfTag.java
+++ b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyIfTag.groovy
@@ -16,21 +16,26 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.grails.gsp.compiler.tags;
+package org.grails.gsp.compiler.tags
-public class GroovyIfTag extends GroovyConditionalTag {
- public static final String TAG_NAME = "if";
+import groovy.transform.CompileStatic
+
+@CompileStatic
+class GroovyIfTag extends GroovyConditionalTag {
+
+ public static final String TAG_NAME = 'if'
@Override
protected void outputStartTag(String envExpression, String testExpression) {
- out.print("if(");
- out.print(envExpression);
- out.print(" && ");
- out.print(testExpression);
- out.println(") {");
+ out.print('if(')
+ out.print(envExpression)
+ out.print(' && ')
+ out.print(testExpression)
+ out.println(') {')
}
- public String getName() {
- return TAG_NAME;
+ String getName() {
+ return TAG_NAME
}
+
}
diff --git a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovySyntaxTag.java b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovySyntaxTag.groovy
similarity index 66%
rename from grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovySyntaxTag.java
rename to grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovySyntaxTag.groovy
index b480f071485..e119003130b 100644
--- a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovySyntaxTag.java
+++ b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovySyntaxTag.groovy
@@ -16,14 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*/
+@SuppressWarnings('UnnecessarySemicolon')
package org.grails.gsp.compiler.tags;
-import java.io.PrintWriter;
-import java.io.Writer;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
+import groovy.transform.CompileStatic;
import org.springframework.util.Assert;
import grails.util.GrailsStringUtils;
@@ -40,14 +36,18 @@
*
* @author Graeme Rocher
*/
-public abstract class GroovySyntaxTag implements GrailsTag {
-
- private static final String ERROR_NO_VAR_WITH_STATUS = "When using with a [status] attribute, you must also define a [var]. eg. ";
- private static final String ERROR_NO_VAR_WITH_COMPILE_STATIC = "When using in CompileStatic mode, you must also define a [var]. eg. ";
- protected static final String ATTRIBUTE_IN = "in";
- protected static final String ATTRIBUTE_VAR = "var";
- protected static final String ATTRIBUTES_STATUS = "status";
- @SuppressWarnings("rawtypes")
+// TODO(groovyism-cleanup): semicolons kept to preserve rename-similarity against the original .java (see matrei's review on #16576). Removed by the stacked groovyism-cleanup PR.
+@SuppressWarnings(['UnnecessarySemicolon'])
+@CompileStatic
+abstract class GroovySyntaxTag implements GrailsTag {
+
+ private static final String ERROR_NO_VAR_WITH_STATUS = 'When using with a [status] attribute, you must also define a [var]. eg. ';
+ private static final String ERROR_NO_VAR_WITH_COMPILE_STATIC = 'When using in CompileStatic mode, you must also define a [var]. eg. ';
+ protected static final String ATTRIBUTE_IN = 'in';
+ protected static final String ATTRIBUTE_VAR = 'var';
+ protected static final String ATTRIBUTES_STATUS = 'status';
+
+ @SuppressWarnings('rawtypes')
protected Map tagContext;
protected PrintWriter out;
protected Map attributes = new HashMap<>();
@@ -55,10 +55,10 @@ public abstract class GroovySyntaxTag implements GrailsTag {
protected String foreachRenamedIt;
- @SuppressWarnings("rawtypes")
- public void init(Map context) {
+ @SuppressWarnings('rawtypes')
+ void init(Map context) {
tagContext = context;
- parser = (GroovyPageParser) context.get(GroovyPageParser.class);
+ parser = (GroovyPageParser) context.get(GroovyPageParser);
Object outObj = context.get(GroovyPage.OUT);
if (outObj instanceof PrintWriter) {
out = (PrintWriter) context.get(GroovyPage.OUT);
@@ -69,21 +69,21 @@ protected boolean isCompileStaticMode() {
return parser != null && parser.isCompileStaticMode();
}
- public void setWriter(Writer w) {
- Assert.isInstanceOf(PrintWriter.class, w, "A GroovySynax tag requires a java.io.PrintWriter instance");
+ void setWriter(Writer w) {
+ Assert.isInstanceOf(PrintWriter, w, 'A GroovySynax tag requires a java.io.PrintWriter instance');
out = (PrintWriter) w;
}
- @SuppressWarnings("rawtypes")
- public void setAttributes(Map attributes) {
+ @SuppressWarnings('rawtypes')
+ void setAttributes(Map attributes) {
for (Iterator i = attributes.keySet().iterator(); i.hasNext();) {
String attrName = (String) i.next();
setAttribute(attrName, attributes.get(attrName));
}
}
- public void setAttribute(String name, Object value) {
- Assert.isInstanceOf(String.class, value, "A GroovySyntax tag requires only string valued attributes");
+ void setAttribute(String name, Object value) {
+ Assert.isInstanceOf(String, value, 'A GroovySyntax tag requires only string valued attributes');
attributes.put(name.substring(1, name.length() - 1), (String) value);
}
@@ -94,7 +94,7 @@ public void setAttribute(String name, Object value) {
* previous tag, and need to swallow the whitespace between them.
* @return true if any whitespace immediately before the tag should be kept in the output - false if it is to be discarded
*/
- public abstract boolean isKeepPrecedingWhiteSpace();
+ abstract boolean isKeepPrecedingWhiteSpace();
/**
* Tags must return the correct value to indicate whether or not non-whitespace content is permitted before this tag.
@@ -103,18 +103,18 @@ public void setAttribute(String name, Object value) {
* TODO rework this and combine with isKeepPrecedingWhiteSpace as really they are used in the same situations
* @return true if any content is allowed immediately before the tag - false if it is an error to have such content before it
*/
- public abstract boolean isAllowPrecedingContent();
+ abstract boolean isAllowPrecedingContent();
protected String calculateExpression(String expr) {
- Assert.isTrue(!GrailsStringUtils.isBlank(expr), "Argument [expr] cannot be null or blank");
+ Assert.isTrue(!GrailsStringUtils.isBlank(expr), 'Argument [expr] cannot be null or blank');
expr = expr.trim();
- if ((expr.startsWith("\"") && expr.endsWith("\"")) ||
- (expr.startsWith("\'") && expr.endsWith("\'"))) {
+ if ((expr.startsWith('"') && expr.endsWith('"')) ||
+ (expr.startsWith("'") && expr.endsWith("'"))) {
expr = expr.substring(1, expr.length() - 1);
expr = expr.trim();
}
- if (expr.startsWith("${") && expr.endsWith("}")) {
+ if (expr.startsWith('\${') && expr.endsWith('}')) {
expr = expr.substring(2, expr.length() - 1);
expr = expr.trim();
}
@@ -124,6 +124,7 @@ protected String calculateExpression(String expr) {
/**
* @param in
*/
+ @SuppressWarnings('SpaceInsideParentheses')
protected void doEachMethod(String in) {
String var = attributes.get(ATTRIBUTE_VAR);
String status = attributes.get(ATTRIBUTES_STATUS);
@@ -137,39 +138,39 @@ protected void doEachMethod(String in) {
}
if (var.equals(status) && (hasStatus)) {
- throw new GrailsTagException("Attribute [" + ATTRIBUTE_VAR +
- "] cannot have the same value as attribute [" + ATTRIBUTES_STATUS + "]", parser.getPageName(), parser.getCurrentOutputLineNumber());
+ throw new GrailsTagException('Attribute [' + ATTRIBUTE_VAR +
+ '] cannot have the same value as attribute [' + ATTRIBUTES_STATUS + ']', parser.getPageName(), parser.getCurrentOutputLineNumber());
}
if (hasStatus) {
- out.println("loop:{");
- out.println("int " + status + " = 0");
+ out.println('loop:{');
+ out.println('int ' + status + ' = 0');
}
if (!hasVar) {
if (isCompileStaticMode()) {
throw new GrailsTagException(ERROR_NO_VAR_WITH_COMPILE_STATIC, parser.getPageName(), parser.getCurrentOutputLineNumber());
}
- var = "_it" + Math.abs(System.identityHashCode(this));
+ var = '_it' + Math.abs(System.identityHashCode(this));
foreachRenamedIt = var;
}
String[] entryVars = null;
if (hasVar && var.indexOf(',') > -1) {
- entryVars = var.split("\\s*,\\s*");
- var = "_entry" + Math.abs(System.identityHashCode(this));
+ entryVars = var.split('\\s*,\\s*');
+ var = '_entry' + Math.abs(System.identityHashCode(this));
}
- out.print("for( " + var);
- out.print(" in "); // dot de-reference
+ out.print('for( ' + var);
+ out.print(' in '); // dot de-reference
out.print(parser != null ? parser.getExpressionText(in, false) : extractAttributeValue(in)); // object
- out.print(" )"); // dot de-reference
- out.print(" {"); // start closure
+ out.print(' )'); // dot de-reference
+ out.print(' {'); // start closure
out.println();
if (!hasVar) {
- out.println("changeItVariable(" + foreachRenamedIt + ")");
+ out.println('changeItVariable(' + foreachRenamedIt + ')');
} else if (entryVars != null) {
- out.println("def " + entryVars[0].trim() + "=" + var + ".getKey()");
- out.println("def " + entryVars[1].trim() + "=" + var + ".getValue()");
+ out.println('def ' + entryVars[0].trim() + '=' + var + '.getKey()');
+ out.println('def ' + entryVars[1].trim() + '=' + var + '.getValue()');
}
}
@@ -179,26 +180,27 @@ protected void endEachMethod() {
boolean hasStatus = !GrailsStringUtils.isBlank(status);
if (hasStatus) {
- out.println(status + "++");
- out.println("}");
+ out.println(status + '++');
+ out.println('}');
}
- out.println("}");
+ out.println('}');
}
protected String extractAttributeValue(String attr) {
if (GrailsStringUtils.isBlank(attr)) {
- return "";
+ return '';
}
- if (((attr.startsWith("\"") && attr.endsWith("\"")) || (attr.startsWith("'") && attr.endsWith("'"))) && attr.length() > 1) {
+ if (((attr.startsWith('"') && attr.endsWith('"')) || (attr.startsWith("'") && attr.endsWith("'"))) && attr.length() > 1) {
attr = attr.substring(1, attr.length() - 1);
}
- if (attr.endsWith("?") && attr.length() > 1) {
+ if (attr.endsWith('?') && attr.length() > 1) {
attr = attr.substring(0, attr.length() - 1);
}
return attr;
}
- public String getForeachRenamedIt() {
+ String getForeachRenamedIt() {
return foreachRenamedIt;
}
+
}
diff --git a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyUnlessTag.java b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyUnlessTag.groovy
similarity index 70%
rename from grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyUnlessTag.java
rename to grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyUnlessTag.groovy
index 05b4dc8453b..ec3e729ddc8 100644
--- a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyUnlessTag.java
+++ b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyUnlessTag.groovy
@@ -16,21 +16,26 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.grails.gsp.compiler.tags;
+package org.grails.gsp.compiler.tags
-public class GroovyUnlessTag extends GroovyConditionalTag {
- public static final String TAG_NAME = "unless";
+import groovy.transform.CompileStatic
+
+@CompileStatic
+class GroovyUnlessTag extends GroovyConditionalTag {
+
+ public static final String TAG_NAME = 'unless'
@Override
protected void outputStartTag(String envExpression, String testExpression) {
- out.print("if(!(");
- out.print(envExpression);
- out.print(" && ");
- out.print(testExpression);
- out.println(")) {");
+ out.print('if(!(')
+ out.print(envExpression)
+ out.print(' && ')
+ out.print(testExpression)
+ out.println(')) {')
}
- public String getName() {
- return TAG_NAME;
+ String getName() {
+ return TAG_NAME
}
+
}
diff --git a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyWhileTag.java b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyWhileTag.groovy
similarity index 52%
rename from grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyWhileTag.java
rename to grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyWhileTag.groovy
index 390154946ac..a9d19104f05 100644
--- a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyWhileTag.java
+++ b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/tags/GroovyWhileTag.groovy
@@ -16,45 +16,49 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.grails.gsp.compiler.tags;
+package org.grails.gsp.compiler.tags
-import grails.util.GrailsStringUtils;
-import org.grails.taglib.GrailsTagException;
+import groovy.transform.CompileStatic
+
+import grails.util.GrailsStringUtils
+import org.grails.taglib.GrailsTagException
/**
* @author Graeme Rocher
*/
-public class GroovyWhileTag extends GroovySyntaxTag {
+@CompileStatic
+class GroovyWhileTag extends GroovySyntaxTag {
- public static final String TAG_NAME = "while";
- private static final String ATTRIBUTE_TEST = "test";
+ public static final String TAG_NAME = 'while'
+ private static final String ATTRIBUTE_TEST = 'test'
- public void doStartTag() {
- String test = attributes.get(ATTRIBUTE_TEST);
+ void doStartTag() {
+ String test = attributes.get(ATTRIBUTE_TEST)
if (GrailsStringUtils.isBlank(test)) {
- throw new GrailsTagException("Tag [" + TAG_NAME + "] missing required attribute [" +
- ATTRIBUTE_TEST + "]", parser.getPageName(), parser.getCurrentOutputLineNumber());
+ throw new GrailsTagException('Tag [' + TAG_NAME + '] missing required attribute [' +
+ ATTRIBUTE_TEST + ']', parser.getPageName(), parser.getCurrentOutputLineNumber())
}
- out.print("while(");
- out.print(test);
- out.println(") {");
+ out.print('while(')
+ out.print(test)
+ out.println(') {')
}
- public void doEndTag() {
- out.println("}");
+ void doEndTag() {
+ out.println('}')
}
- public String getName() {
- return TAG_NAME;
+ String getName() {
+ return TAG_NAME
}
@Override
- public boolean isKeepPrecedingWhiteSpace() {
- return true;
+ boolean isKeepPrecedingWhiteSpace() {
+ return true
}
@Override
- public boolean isAllowPrecedingContent() {
- return true;
+ boolean isAllowPrecedingContent() {
+ return true
}
+
}
diff --git a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/transform/GroovyPageBytecodeOptimizer.java b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/transform/GroovyPageBytecodeOptimizer.groovy
similarity index 54%
rename from grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/transform/GroovyPageBytecodeOptimizer.java
rename to grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/transform/GroovyPageBytecodeOptimizer.groovy
index f43edfd9e5c..594c3eb69de 100644
--- a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/transform/GroovyPageBytecodeOptimizer.java
+++ b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/transform/GroovyPageBytecodeOptimizer.groovy
@@ -16,49 +16,50 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.grails.gsp.compiler.transform;
+package org.grails.gsp.compiler.transform
-import java.net.URL;
+import groovy.transform.CompileStatic
+import org.codehaus.groovy.ast.ClassNode
+import org.codehaus.groovy.ast.MethodNode
+import org.codehaus.groovy.ast.Parameter
+import org.codehaus.groovy.ast.stmt.BlockStatement
+import org.codehaus.groovy.classgen.GeneratorContext
+import org.codehaus.groovy.control.SourceUnit
-import org.codehaus.groovy.ast.ClassNode;
-import org.codehaus.groovy.ast.MethodNode;
-import org.codehaus.groovy.ast.Parameter;
-import org.codehaus.groovy.ast.stmt.BlockStatement;
-import org.codehaus.groovy.classgen.GeneratorContext;
-import org.codehaus.groovy.control.SourceUnit;
-
-import grails.compiler.ast.AstTransformer;
-import grails.compiler.ast.GroovyPageInjector;
+import grails.compiler.ast.AstTransformer
+import grails.compiler.ast.GroovyPageInjector
@AstTransformer
-public class GroovyPageBytecodeOptimizer implements GroovyPageInjector {
+@CompileStatic
+class GroovyPageBytecodeOptimizer implements GroovyPageInjector {
- private final static String RUN_METHOD = "run";
+ private final static String RUN_METHOD = 'run'
- public void performInjection(SourceUnit source, GeneratorContext context, ClassNode classNode) {
+ void performInjection(SourceUnit source, GeneratorContext context, ClassNode classNode) {
// search run method in GSP script and get codeblock
- MethodNode runMethod = classNode.getMethod(RUN_METHOD, new Parameter[0]);
+ MethodNode runMethod = classNode.getMethod(RUN_METHOD, new Parameter[0])
if (runMethod != null && runMethod.getCode() instanceof BlockStatement) {
- BlockStatement block = (BlockStatement) runMethod.getCode();
+ BlockStatement block = (BlockStatement) runMethod.getCode()
//scan all MethodExpressionCalls to optimize them
- GroovyPageOptimizerVisitor groovyPageVisitor = new GroovyPageOptimizerVisitor(classNode);
- groovyPageVisitor.visitBlockStatement(block);
+ GroovyPageOptimizerVisitor groovyPageVisitor = new GroovyPageOptimizerVisitor(classNode)
+ groovyPageVisitor.visitBlockStatement(block)
}
}
- public void performInjection(SourceUnit source, ClassNode classNode) {
- performInjection(source, null, classNode);
+ void performInjection(SourceUnit source, ClassNode classNode) {
+ performInjection(source, null, classNode)
}
@Override
- public void performInjectionOnAnnotatedClass(SourceUnit source, ClassNode classNode) {
- performInjection(source, null, classNode);
+ void performInjectionOnAnnotatedClass(SourceUnit source, ClassNode classNode) {
+ performInjection(source, null, classNode)
}
//Avoid other injection
- public boolean shouldInject(URL url) {
- return false;
+ boolean shouldInject(URL url) {
+ return false
}
+
}
diff --git a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/transform/GroovyPageInjectionOperation.java b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/transform/GroovyPageInjectionOperation.groovy
similarity index 58%
rename from grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/transform/GroovyPageInjectionOperation.java
rename to grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/transform/GroovyPageInjectionOperation.groovy
index b046d2b1b3b..12aed21e64e 100644
--- a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/transform/GroovyPageInjectionOperation.java
+++ b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/transform/GroovyPageInjectionOperation.groovy
@@ -16,19 +16,17 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.grails.gsp.compiler.transform;
+package org.grails.gsp.compiler.transform
-import java.util.ArrayList;
-import java.util.List;
+import groovy.transform.CompileStatic
+import org.codehaus.groovy.ast.ClassNode
+import org.codehaus.groovy.classgen.GeneratorContext
+import org.codehaus.groovy.control.CompilationFailedException
+import org.codehaus.groovy.control.SourceUnit
-import org.codehaus.groovy.ast.ClassNode;
-import org.codehaus.groovy.classgen.GeneratorContext;
-import org.codehaus.groovy.control.CompilationFailedException;
-import org.codehaus.groovy.control.SourceUnit;
-
-import grails.compiler.ast.ClassInjector;
-import grails.compiler.ast.GroovyPageInjector;
-import org.grails.compiler.injection.GrailsAwareInjectionOperation;
+import grails.compiler.ast.ClassInjector
+import grails.compiler.ast.GroovyPageInjector
+import org.grails.compiler.injection.GrailsAwareInjectionOperation
/**
* A GroovyPage compiler injection operation that uses a specified array of ClassInjector instances to
@@ -37,33 +35,35 @@
* @author Stephane Maldini
* @since 2.0
*/
-public class GroovyPageInjectionOperation extends GrailsAwareInjectionOperation {
+@CompileStatic
+class GroovyPageInjectionOperation extends GrailsAwareInjectionOperation {
- private GroovyPageInjector[] groovyPageInjectors;
+ private GroovyPageInjector[] groovyPageInjectors
@Override
- public void call(SourceUnit source, GeneratorContext context, ClassNode classNode) throws CompilationFailedException {
- for (GroovyPageInjector classInjector : getGroovyPageInjectors()) {
+ void call(SourceUnit source, GeneratorContext context, ClassNode classNode) throws CompilationFailedException {
+ for (GroovyPageInjector classInjector in getGroovyPageInjectors()) {
try {
- classInjector.performInjection(source, context, classNode);
+ classInjector.performInjection(source, context, classNode)
} catch (RuntimeException e) {
- System.err.println("Error occurred calling AST injector [" + classInjector.getClass() + "]: " + e.getMessage());
- e.printStackTrace(System.err);
- throw e;
+ System.err.println('Error occurred calling AST injector [' + classInjector.getClass() + ']: ' + e.getMessage())
+ e.printStackTrace(System.err)
+ throw e
}
}
}
private GroovyPageInjector[] getGroovyPageInjectors() {
if (groovyPageInjectors == null) {
- List injectors = new ArrayList<>();
- for (ClassInjector ci : getClassInjectors()) {
+ List injectors = new ArrayList<>()
+ for (ClassInjector ci in getClassInjectors()) {
if (ci instanceof GroovyPageInjector) {
- injectors.add((GroovyPageInjector) ci);
+ injectors.add((GroovyPageInjector) ci)
}
}
- groovyPageInjectors = injectors.toArray(new GroovyPageInjector[injectors.size()]);
+ groovyPageInjectors = injectors.toArray(new GroovyPageInjector[injectors.size()])
}
- return groovyPageInjectors;
+ return groovyPageInjectors
}
+
}
diff --git a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/transform/GroovyPageOptimizerVisitor.java b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/transform/GroovyPageOptimizerVisitor.groovy
similarity index 59%
rename from grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/transform/GroovyPageOptimizerVisitor.java
rename to grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/transform/GroovyPageOptimizerVisitor.groovy
index df05be87c46..111641d6b5a 100644
--- a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/transform/GroovyPageOptimizerVisitor.java
+++ b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/transform/GroovyPageOptimizerVisitor.groovy
@@ -16,29 +16,26 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.grails.gsp.compiler.transform;
-
-import java.util.List;
-import java.util.Stack;
-
-import groovy.lang.Closure;
-import org.codehaus.groovy.ast.ClassNode;
-import org.codehaus.groovy.ast.CodeVisitorSupport;
-import org.codehaus.groovy.ast.MethodNode;
-import org.codehaus.groovy.ast.Parameter;
-import org.codehaus.groovy.ast.expr.ArgumentListExpression;
-import org.codehaus.groovy.ast.expr.ClosureExpression;
-import org.codehaus.groovy.ast.expr.DeclarationExpression;
-import org.codehaus.groovy.ast.expr.MethodCallExpression;
-import org.codehaus.groovy.ast.expr.VariableExpression;
-import org.codehaus.groovy.ast.stmt.BlockStatement;
-import org.codehaus.groovy.ast.stmt.ExpressionStatement;
-import org.codehaus.groovy.ast.stmt.Statement;
-import org.codehaus.groovy.syntax.Token;
-import org.codehaus.groovy.syntax.Types;
-
-import org.grails.buffer.GrailsPrintWriter;
-import org.grails.gsp.GroovyPage;
+package org.grails.gsp.compiler.transform
+
+import groovy.transform.CompileStatic
+import org.codehaus.groovy.ast.ClassNode
+import org.codehaus.groovy.ast.CodeVisitorSupport
+import org.codehaus.groovy.ast.MethodNode
+import org.codehaus.groovy.ast.Parameter
+import org.codehaus.groovy.ast.expr.ArgumentListExpression
+import org.codehaus.groovy.ast.expr.ClosureExpression
+import org.codehaus.groovy.ast.expr.DeclarationExpression
+import org.codehaus.groovy.ast.expr.MethodCallExpression
+import org.codehaus.groovy.ast.expr.VariableExpression
+import org.codehaus.groovy.ast.stmt.BlockStatement
+import org.codehaus.groovy.ast.stmt.ExpressionStatement
+import org.codehaus.groovy.ast.stmt.Statement
+import org.codehaus.groovy.syntax.Token
+import org.codehaus.groovy.syntax.Types
+
+import org.grails.buffer.GrailsPrintWriter
+import org.grails.gsp.GroovyPage
/**
* Scan MethodCallExpression in GSP to convert callsite calls into static calls (printHtmlPart ...)
@@ -46,36 +43,37 @@
* @author Stephane Maldini
* @since 2.0
*/
+@CompileStatic
class GroovyPageOptimizerVisitor extends CodeVisitorSupport {
- private static final ClassNode groovyPageClassNode = new ClassNode(GroovyPage.class);
- private static final MethodNode writerMethodNode = new ClassNode(GrailsPrintWriter.class).getMethod("print",
- new Parameter[]{new Parameter(new ClassNode(Object.class), "obj")});
+ private static final ClassNode groovyPageClassNode = new ClassNode(GroovyPage)
+ private static final MethodNode writerMethodNode = new ClassNode(GrailsPrintWriter).getMethod('print',
+ [new Parameter(new ClassNode(Object), 'obj')] as Parameter[])
- private static final String THIS_RECEIVER = "this";
- private static final String THISOBJECT = "thisObject";
- private static final String OUT_RECEIVER = "out";
- private static final String PRINT_METHOD = "print";
- private static final String EXPRESSIONOUT_RECEIVER = "expressionOut";
+ private static final String THIS_RECEIVER = 'this'
+ private static final String THISOBJECT = 'thisObject'
+ private static final String OUT_RECEIVER = 'out'
+ private static final String PRINT_METHOD = 'print'
+ private static final String EXPRESSIONOUT_RECEIVER = 'expressionOut'
- private Stack innerClosures = new Stack<>();
- private ClassNode targetGroovyPageNode;
+ private Stack innerClosures = new Stack<>()
+ private ClassNode targetGroovyPageNode
- private DeclarationExpression thisObjectDeclaration;
- private VariableExpression thisObjectVariable;
+ private DeclarationExpression thisObjectDeclaration
+ private VariableExpression thisObjectVariable
- public GroovyPageOptimizerVisitor(ClassNode targetGroovyPage) {
- this.targetGroovyPageNode = targetGroovyPage;
+ GroovyPageOptimizerVisitor(ClassNode targetGroovyPage) {
+ this.targetGroovyPageNode = targetGroovyPage
- MethodCallExpression thisObjectMethodCall = new MethodCallExpression(new VariableExpression(THIS_RECEIVER), "getThisObject", MethodCallExpression.NO_ARGUMENTS);
- thisObjectMethodCall.setMethodTarget(new ClassNode(Closure.class).getMethods("getThisObject").get(0));
+ MethodCallExpression thisObjectMethodCall = new MethodCallExpression(new VariableExpression(THIS_RECEIVER), 'getThisObject', MethodCallExpression.NO_ARGUMENTS)
+ thisObjectMethodCall.setMethodTarget(new ClassNode(Closure).getMethods('getThisObject').get(0))
- thisObjectVariable = new VariableExpression(THISOBJECT, targetGroovyPageNode);
+ thisObjectVariable = new VariableExpression(THISOBJECT, targetGroovyPageNode)
thisObjectDeclaration = new DeclarationExpression(
thisObjectVariable,
Token.newSymbol(Types.EQUALS, 0, 0),
- thisObjectMethodCall);
+ thisObjectMethodCall)
}
/*
@@ -89,59 +87,59 @@ public void visitClosureExpression(ClosureExpression expression) {
}
*/
- @SuppressWarnings("unused")
+ @SuppressWarnings('unused')
private void introduceThisObjectVariable(ClosureExpression closureExpression) {
if (closureExpression.getCode() instanceof BlockStatement) {
- List oldBlock = ((BlockStatement) closureExpression.getCode()).getStatements();
- BlockStatement newBlock = new BlockStatement();
+ List oldBlock = ((BlockStatement) closureExpression.getCode()).getStatements()
+ BlockStatement newBlock = new BlockStatement()
- newBlock.addStatement(new ExpressionStatement(thisObjectDeclaration));
- newBlock.addStatements(oldBlock);
+ newBlock.addStatement(new ExpressionStatement(thisObjectDeclaration))
+ newBlock.addStatements(oldBlock)
- closureExpression.setCode(newBlock);
+ closureExpression.setCode(newBlock)
}
}
@Override
- public void visitMethodCallExpression(MethodCallExpression call) {
+ void visitMethodCallExpression(MethodCallExpression call) {
if (isCallFromGroovyPageClass(call)) {
// TODO: Research why http://jira.grails.org/browse/GRAILS-8679 happens with this enabled. See ElvisAndClosureGroovyPageTests
//proceedCallFromGroovyPageClass(call);
} else if (isCallFromOutOrCodecOut(call)) {
- proceedCallFromOutOrCodecOut(call);
+ proceedCallFromOutOrCodecOut(call)
}
- super.visitMethodCallExpression(call);
+ super.visitMethodCallExpression(call)
}
private void proceedCallFromOutOrCodecOut(MethodCallExpression call) {
- call.setMethodTarget(writerMethodNode);
+ call.setMethodTarget(writerMethodNode)
}
private boolean isCallFromOutOrCodecOut(MethodCallExpression expression) {
return (expression.getObjectExpression().getText().equals(OUT_RECEIVER) ||
expression.getObjectExpression().getText().equals(EXPRESSIONOUT_RECEIVER)) &&
- expression.getMethodAsString().equals(PRINT_METHOD);
+ expression.getMethodAsString().equals(PRINT_METHOD)
}
- @SuppressWarnings("unused")
+ @SuppressWarnings('unused')
private void proceedCallFromGroovyPageClass(MethodCallExpression call) {
- List methodNodeList = groovyPageClassNode.getMethods(call.getMethodAsString());
+ List methodNodeList = groovyPageClassNode.getMethods(call.getMethodAsString())
if (methodNodeList.size() == 1) {
- call.setMethodTarget(methodNodeList.get(0));
- changeThisObjectExpressionIfInnerClosure(call);
+ call.setMethodTarget(methodNodeList.get(0))
+ changeThisObjectExpressionIfInnerClosure(call)
} else if (methodNodeList.size() > 1 && call.getArguments() instanceof ArgumentListExpression) {
//Special case for invokeTag
- ArgumentListExpression argsExpr = ((ArgumentListExpression) call.getArguments());
+ ArgumentListExpression argsExpr = ((ArgumentListExpression) call.getArguments())
- for (MethodNode methodNode : methodNodeList) {
+ for (MethodNode methodNode in methodNodeList) {
//No need for deep analysis as GroovyPage doesn't have multiple signatures for same args number
if (methodNode.getParameters().length == argsExpr.getExpressions().size()) {
- call.setMethodTarget(methodNode);
- changeThisObjectExpressionIfInnerClosure(call);
- break;
+ call.setMethodTarget(methodNode)
+ changeThisObjectExpressionIfInnerClosure(call)
+ break
}
}
}
@@ -149,12 +147,13 @@ private void proceedCallFromGroovyPageClass(MethodCallExpression call) {
private void changeThisObjectExpressionIfInnerClosure(MethodCallExpression call) {
if (!innerClosures.isEmpty()) {
- call.setObjectExpression(thisObjectVariable);
+ call.setObjectExpression(thisObjectVariable)
}
}
private boolean isCallFromGroovyPageClass(MethodCallExpression expression) {
return expression.getObjectExpression().getText().equals(THIS_RECEIVER) &&
- !groovyPageClassNode.getMethods(expression.getMethodAsString()).isEmpty();
+ !groovyPageClassNode.getMethods(expression.getMethodAsString()).isEmpty()
}
+
}
diff --git a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/transform/LineNumber.java b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/transform/LineNumber.groovy
similarity index 70%
rename from grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/transform/LineNumber.java
rename to grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/transform/LineNumber.groovy
index e064a085100..6962fd44105 100644
--- a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/transform/LineNumber.java
+++ b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/transform/LineNumber.groovy
@@ -16,22 +16,24 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.grails.gsp.compiler.transform;
+package org.grails.gsp.compiler.transform
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+import java.lang.annotation.ElementType
+import java.lang.annotation.Retention
+import java.lang.annotation.RetentionPolicy
+import java.lang.annotation.Target
-import org.codehaus.groovy.transform.GroovyASTTransformationClass;
+import org.codehaus.groovy.transform.GroovyASTTransformationClass
/**
* @author Andrew Eisenberg
*/
@Retention(RetentionPolicy.SOURCE)
-@Target({ ElementType.TYPE })
-@GroovyASTTransformationClass({"org.grails.gsp.compiler.transform.LineNumberTransform"})
-public @interface LineNumber {
- int[] lines();
- String sourceName();
+@Target([ ElementType.TYPE ])
+@GroovyASTTransformationClass(['org.grails.gsp.compiler.transform.LineNumberTransform'])
+@interface LineNumber {
+
+ int[] lines()
+ String sourceName()
+
}
diff --git a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/transform/LineNumberTransform.java b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/transform/LineNumberTransform.groovy
similarity index 72%
rename from grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/transform/LineNumberTransform.java
rename to grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/transform/LineNumberTransform.groovy
index 649ba72b5c3..afcb9579185 100644
--- a/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/transform/LineNumberTransform.java
+++ b/grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/transform/LineNumberTransform.groovy
@@ -16,61 +16,59 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.grails.gsp.compiler.transform;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.codehaus.groovy.ast.ASTNode;
-import org.codehaus.groovy.ast.AnnotationNode;
-import org.codehaus.groovy.ast.ClassCodeVisitorSupport;
-import org.codehaus.groovy.ast.ClassNode;
-import org.codehaus.groovy.ast.expr.ArgumentListExpression;
-import org.codehaus.groovy.ast.expr.ArrayExpression;
-import org.codehaus.groovy.ast.expr.AttributeExpression;
-import org.codehaus.groovy.ast.expr.BinaryExpression;
-import org.codehaus.groovy.ast.expr.BitwiseNegationExpression;
-import org.codehaus.groovy.ast.expr.BooleanExpression;
-import org.codehaus.groovy.ast.expr.CastExpression;
-import org.codehaus.groovy.ast.expr.ClassExpression;
-import org.codehaus.groovy.ast.expr.ClosureExpression;
-import org.codehaus.groovy.ast.expr.ClosureListExpression;
-import org.codehaus.groovy.ast.expr.ConstantExpression;
-import org.codehaus.groovy.ast.expr.ConstructorCallExpression;
-import org.codehaus.groovy.ast.expr.DeclarationExpression;
-import org.codehaus.groovy.ast.expr.ElvisOperatorExpression;
-import org.codehaus.groovy.ast.expr.Expression;
-import org.codehaus.groovy.ast.expr.FieldExpression;
-import org.codehaus.groovy.ast.expr.GStringExpression;
-import org.codehaus.groovy.ast.expr.ListExpression;
-import org.codehaus.groovy.ast.expr.MapEntryExpression;
-import org.codehaus.groovy.ast.expr.MapExpression;
-import org.codehaus.groovy.ast.expr.MethodCallExpression;
-import org.codehaus.groovy.ast.expr.MethodPointerExpression;
-import org.codehaus.groovy.ast.expr.NotExpression;
-import org.codehaus.groovy.ast.expr.PostfixExpression;
-import org.codehaus.groovy.ast.expr.PrefixExpression;
-import org.codehaus.groovy.ast.expr.PropertyExpression;
-import org.codehaus.groovy.ast.expr.RangeExpression;
-import org.codehaus.groovy.ast.expr.SpreadExpression;
-import org.codehaus.groovy.ast.expr.SpreadMapExpression;
-import org.codehaus.groovy.ast.expr.StaticMethodCallExpression;
-import org.codehaus.groovy.ast.expr.TernaryExpression;
-import org.codehaus.groovy.ast.expr.TupleExpression;
-import org.codehaus.groovy.ast.expr.UnaryMinusExpression;
-import org.codehaus.groovy.ast.expr.UnaryPlusExpression;
-import org.codehaus.groovy.ast.stmt.Statement;
-import org.codehaus.groovy.classgen.BytecodeExpression;
-import org.codehaus.groovy.control.CompilePhase;
-import org.codehaus.groovy.control.SourceUnit;
-import org.codehaus.groovy.transform.ASTTransformation;
-import org.codehaus.groovy.transform.GroovyASTTransformation;
-import org.codehaus.groovy.transform.TransformWithPriority;
-
-import org.springframework.util.ReflectionUtils;
-
-import org.apache.grails.common.compiler.GroovyTransformOrder;
+package org.grails.gsp.compiler.transform
+
+import java.lang.reflect.Field
+
+import groovy.transform.CompileStatic
+import org.codehaus.groovy.ast.ASTNode
+import org.codehaus.groovy.ast.AnnotationNode
+import org.codehaus.groovy.ast.ClassCodeVisitorSupport
+import org.codehaus.groovy.ast.ClassNode
+import org.codehaus.groovy.ast.expr.ArgumentListExpression
+import org.codehaus.groovy.ast.expr.ArrayExpression
+import org.codehaus.groovy.ast.expr.AttributeExpression
+import org.codehaus.groovy.ast.expr.BinaryExpression
+import org.codehaus.groovy.ast.expr.BitwiseNegationExpression
+import org.codehaus.groovy.ast.expr.BooleanExpression
+import org.codehaus.groovy.ast.expr.CastExpression
+import org.codehaus.groovy.ast.expr.ClassExpression
+import org.codehaus.groovy.ast.expr.ClosureExpression
+import org.codehaus.groovy.ast.expr.ClosureListExpression
+import org.codehaus.groovy.ast.expr.ConstantExpression
+import org.codehaus.groovy.ast.expr.ConstructorCallExpression
+import org.codehaus.groovy.ast.expr.DeclarationExpression
+import org.codehaus.groovy.ast.expr.ElvisOperatorExpression
+import org.codehaus.groovy.ast.expr.Expression
+import org.codehaus.groovy.ast.expr.FieldExpression
+import org.codehaus.groovy.ast.expr.GStringExpression
+import org.codehaus.groovy.ast.expr.ListExpression
+import org.codehaus.groovy.ast.expr.MapEntryExpression
+import org.codehaus.groovy.ast.expr.MapExpression
+import org.codehaus.groovy.ast.expr.MethodCallExpression
+import org.codehaus.groovy.ast.expr.MethodPointerExpression
+import org.codehaus.groovy.ast.expr.NotExpression
+import org.codehaus.groovy.ast.expr.PostfixExpression
+import org.codehaus.groovy.ast.expr.PrefixExpression
+import org.codehaus.groovy.ast.expr.PropertyExpression
+import org.codehaus.groovy.ast.expr.RangeExpression
+import org.codehaus.groovy.ast.expr.SpreadExpression
+import org.codehaus.groovy.ast.expr.SpreadMapExpression
+import org.codehaus.groovy.ast.expr.StaticMethodCallExpression
+import org.codehaus.groovy.ast.expr.TernaryExpression
+import org.codehaus.groovy.ast.expr.TupleExpression
+import org.codehaus.groovy.ast.expr.UnaryMinusExpression
+import org.codehaus.groovy.ast.expr.UnaryPlusExpression
+import org.codehaus.groovy.ast.stmt.Statement
+import org.codehaus.groovy.classgen.BytecodeExpression
+import org.codehaus.groovy.control.CompilePhase
+import org.codehaus.groovy.control.SourceUnit
+import org.codehaus.groovy.transform.ASTTransformation
+import org.codehaus.groovy.transform.GroovyASTTransformation
+import org.codehaus.groovy.transform.TransformWithPriority
+import org.springframework.util.ReflectionUtils
+
+import org.apache.grails.common.compiler.GroovyTransformOrder
/**
* Convert line number information to that based on the line number array passed
@@ -79,95 +77,96 @@
* @author Andrew Eisenberg
*/
@GroovyASTTransformation(phase = CompilePhase.SEMANTIC_ANALYSIS)
-public class LineNumberTransform implements ASTTransformation, TransformWithPriority {
+@CompileStatic
+class LineNumberTransform implements ASTTransformation, TransformWithPriority {
// LOG statements commented out because they were causing
// compilation problems when used outside of grails
// static final Log LOG = LogFactory.getLog(LineNumberTransform)
- public void visit(ASTNode[] nodes, SourceUnit source) {
- List classes = source.getAST().getClasses();
+ void visit(ASTNode[] nodes, SourceUnit source) {
+ List classes = source.getAST().getClasses()
- AnnotationNode annotation = null;
- for (ClassNode clazz : classes) {
- annotation = findAnnotation(clazz);
+ AnnotationNode annotation = null
+ for (ClassNode clazz in classes) {
+ annotation = findAnnotation(clazz)
if (annotation != null) {
- break;
+ break
}
}
if (annotation == null) {
- return;
+ return
}
- int[] array = extractLineNumberArray(annotation);
+ int[] array = extractLineNumberArray(annotation)
if (array != null) {
- LineNumberVisitor visitor = new LineNumberVisitor(array);
- for (ClassNode clazz : classes) {
- visitor.visitClass(clazz);
+ LineNumberVisitor visitor = new LineNumberVisitor(array)
+ for (ClassNode clazz in classes) {
+ visitor.visitClass(clazz)
}
}
- String sourceName = extractSourceName(annotation);
+ String sourceName = extractSourceName(annotation)
if (sourceName != null) {
- source.getAST().setDescription(sourceName);
+ source.getAST().setDescription(sourceName)
// source.name = sourceName
- Field field = ReflectionUtils.findField(SourceUnit.class, "name");
- field.setAccessible(true);
- ReflectionUtils.setField(field, source, sourceName);
+ Field field = ReflectionUtils.findField(SourceUnit, 'name')
+ field.setAccessible(true)
+ ReflectionUtils.setField(field, source, sourceName)
}
}
String extractSourceName(AnnotationNode node) {
- ConstantExpression newName = (ConstantExpression) node.getMember("sourceName");
- return (String) newName.getValue();
+ ConstantExpression newName = (ConstantExpression) node.getMember('sourceName')
+ return (String) newName.getValue()
}
AnnotationNode findAnnotation(ClassNode clazz) {
if (clazz != null) {
- for (AnnotationNode node : clazz.getAnnotations()) {
- if (node.getClassNode().getName().equals(LineNumber.class.getName())) {
+ for (AnnotationNode node in clazz.getAnnotations()) {
+ if (node.getClassNode().getName().equals(LineNumber.getName())) {
// LOG.debug "Transforming in ${clazz.name}"
- return node;
+ return node
}
}
}
- return null;
+ return null
}
int[] extractLineNumberArray(AnnotationNode node) {
- ListExpression lineNumberArray = (ListExpression) node.getMember("lines");
+ ListExpression lineNumberArray = (ListExpression) node.getMember('lines')
// make assumption that this is a simple array of constants
- List numbers = new ArrayList<>();
- for (Expression e : lineNumberArray.getExpressions()) {
+ List numbers = new ArrayList<>()
+ for (Expression e in lineNumberArray.getExpressions()) {
if (e instanceof ConstantExpression) {
- numbers.add((Integer) ((ConstantExpression) e).getValue());
+ numbers.add((Integer) ((ConstantExpression) e).getValue())
}
else {
- numbers.add(-1);
+ numbers.add(-1)
}
}
// LOG.debug "We have transformed: ${numbers}"
if (numbers.isEmpty()) {
- return null;
+ return null
}
- int[] array = new int[numbers.size()];
+ int[] array = new int[numbers.size()]
for (int i = 0, count = numbers.size(); i < count; i++) {
- array[i] = numbers.get(i);
+ array[i] = numbers.get(i)
}
- return array;
+ return array
}
@Override
- public int priority() {
- return GroovyTransformOrder.GSP_LINE_ORDER;
+ int priority() {
+ return GroovyTransformOrder.GSP_LINE_ORDER
}
class LineNumberVisitor extends ClassCodeVisitorSupport {
- int[] lineNumbers;
+ int[] lineNumbers
LineNumberVisitor(int[] lineNumbers) {
- this.lineNumbers = lineNumbers;
+ this.lineNumbers = lineNumbers
/*
if (LOG.isDebugEnabled()) {
String numbers = "Line numbers: ";
@@ -185,563 +184,564 @@ protected void visitStatement(Statement statement) {
if (statement.getLineNumber() >= 0 && statement.getLineNumber() < lineNumbers.length) {
// LOG.debug " start from ${statement.lineNumber} to ${lineNumbers[statement.lineNumber]}"
- statement.setLineNumber(lineNumbers[statement.getLineNumber() - 1]);
+ statement.setLineNumber(lineNumbers[statement.getLineNumber() - 1])
}
if (statement.getLastLineNumber() > 0 && statement.getLastLineNumber() < lineNumbers.length) {
// LOG.debug " end from ${statement.lastLineNumber} to ${lineNumbers[statement.lastLineNumber]}"
- statement.setLastLineNumber(lineNumbers[statement.getLastLineNumber() - 1]);
+ statement.setLastLineNumber(lineNumbers[statement.getLastLineNumber() - 1])
}
}
@Override
- public void visitMethodCallExpression(MethodCallExpression expression) {
+ void visitMethodCallExpression(MethodCallExpression expression) {
// LOG.debug "Transforming expression '${expression}':"
if (expression.getLineNumber() >= 0 && expression.getLineNumber() < lineNumbers.length) {
// LOG.debug " start from ${expression.lineNumber} to ${lineNumbers[expression.lineNumber - 1]}"
- expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1]);
+ expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1])
}
if (expression.getLastLineNumber() > 0 && expression.getLastLineNumber() < lineNumbers.length) {
// LOG.debug " end from ${expression.lastLineNumber} to ${lineNumbers[expression.lastLineNumber - 1]}"
- expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1]);
+ expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1])
}
- super.visitMethodCallExpression(expression);
+ super.visitMethodCallExpression(expression)
}
@Override
- public void visitStaticMethodCallExpression(StaticMethodCallExpression expression) {
+ void visitStaticMethodCallExpression(StaticMethodCallExpression expression) {
// LOG.debug "Transforming expression '${expression}':"
if (expression.getLineNumber() >= 0 && expression.getLineNumber() < lineNumbers.length) {
// LOG.debug " start from ${expression.lineNumber} to ${lineNumbers[expression.lineNumber - 1]}"
- expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1]);
+ expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1])
}
if (expression.getLastLineNumber() > 0 && expression.getLastLineNumber() < lineNumbers.length) {
// LOG.debug " end from ${expression.lastLineNumber} to ${lineNumbers[expression.lastLineNumber - 1]}"
- expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1]);
+ expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1])
}
- super.visitStaticMethodCallExpression(expression);
+ super.visitStaticMethodCallExpression(expression)
}
@Override
- public void visitConstructorCallExpression(ConstructorCallExpression expression) {
+ void visitConstructorCallExpression(ConstructorCallExpression expression) {
// LOG.debug "Transforming expression '${expression}':"
if (expression.getLineNumber() >= 0 && expression.getLineNumber() < lineNumbers.length) {
// LOG.debug " start from ${expression.lineNumber} to ${lineNumbers[expression.lineNumber - 1]}"
- expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1]);
+ expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1])
}
if (expression.getLastLineNumber() > 0 && expression.getLastLineNumber() < lineNumbers.length) {
// LOG.debug " end from ${expression.lastLineNumber} to ${lineNumbers[expression.lastLineNumber - 1]}"
- expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1]);
+ expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1])
}
- super.visitConstructorCallExpression(expression);
+ super.visitConstructorCallExpression(expression)
}
@Override
- public void visitBinaryExpression(BinaryExpression expression) {
+ void visitBinaryExpression(BinaryExpression expression) {
// LOG.debug "Transforming expression '${expression}':"
if (expression.getLineNumber() >= 0 && expression.getLineNumber() < lineNumbers.length) {
// LOG.debug " start from ${expression.lineNumber} to ${lineNumbers[expression.lineNumber - 1]}"
- expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1]);
+ expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1])
}
if (expression.getLastLineNumber() > 0 && expression.getLastLineNumber() < lineNumbers.length) {
// LOG.debug " end from ${expression.lastLineNumber} to ${lineNumbers[expression.lastLineNumber - 1]}"
- expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1]);
+ expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1])
}
- super.visitBinaryExpression(expression);
+ super.visitBinaryExpression(expression)
}
@Override
- public void visitTernaryExpression(TernaryExpression expression) {
+ void visitTernaryExpression(TernaryExpression expression) {
// LOG.debug "Transforming expression '${expression}':"
if (expression.getLineNumber() >= 0 && expression.getLineNumber() < lineNumbers.length) {
// LOG.debug " start from ${expression.lineNumber} to ${lineNumbers[expression.lineNumber - 1]}"
- expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1]);
+ expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1])
}
if (expression.getLastLineNumber() > 0 && expression.getLastLineNumber() < lineNumbers.length) {
// LOG.debug " end from ${expression.lastLineNumber} to ${lineNumbers[expression.lastLineNumber - 1]}"
- expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1]);
+ expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1])
}
- super.visitTernaryExpression(expression);
+ super.visitTernaryExpression(expression)
}
@Override
- public void visitShortTernaryExpression(ElvisOperatorExpression expression) {
+ void visitShortTernaryExpression(ElvisOperatorExpression expression) {
// LOG.debug "Transforming expression '${expression}':"
if (expression.getLineNumber() >= 0 && expression.getLineNumber() < lineNumbers.length) {
// LOG.debug " start from ${expression.lineNumber} to ${lineNumbers[expression.lineNumber - 1]}"
- expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1]);
+ expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1])
}
if (expression.getLastLineNumber() > 0 && expression.getLastLineNumber() < lineNumbers.length) {
// LOG.debug " end from ${expression.lastLineNumber} to ${lineNumbers[expression.lastLineNumber - 1]}"
- expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1]);
+ expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1])
}
- super.visitShortTernaryExpression(expression);
+ super.visitShortTernaryExpression(expression)
}
@Override
- public void visitPostfixExpression(PostfixExpression expression) {
+ void visitPostfixExpression(PostfixExpression expression) {
// LOG.debug "Transforming expression '${expression}':"
if (expression.getLineNumber() >= 0 && expression.getLineNumber() < lineNumbers.length) {
// LOG.debug " start from ${expression.lineNumber} to ${lineNumbers[expression.lineNumber - 1]}"
- expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1]);
+ expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1])
}
if (expression.getLastLineNumber() > 0 && expression.getLastLineNumber() < lineNumbers.length) {
// LOG.debug " end from ${expression.lastLineNumber} to ${lineNumbers[expression.lastLineNumber - 1]}"
- expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1]);
+ expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1])
}
- super.visitPostfixExpression(expression);
+ super.visitPostfixExpression(expression)
}
@Override
- public void visitPrefixExpression(PrefixExpression expression) {
+ void visitPrefixExpression(PrefixExpression expression) {
// LOG.debug "Transforming expression '${expression}':"
if (expression.getLineNumber() >= 0 && expression.getLineNumber() < lineNumbers.length) {
// LOG.debug " start from ${expression.lineNumber} to ${lineNumbers[expression.lineNumber - 1]}"
- expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1]);
+ expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1])
}
if (expression.getLastLineNumber() > 0 && expression.getLastLineNumber() < lineNumbers.length) {
// LOG.debug " end from ${expression.lastLineNumber} to ${lineNumbers[expression.lastLineNumber - 1]}"
- expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1]);
+ expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1])
}
- super.visitPrefixExpression(expression);
+ super.visitPrefixExpression(expression)
}
@Override
- public void visitBooleanExpression(BooleanExpression expression) {
+ void visitBooleanExpression(BooleanExpression expression) {
// LOG.debug "Transforming expression '${expression}':"
if (expression.getLineNumber() >= 0 && expression.getLineNumber() < lineNumbers.length) {
// LOG.debug " start from ${expression.lineNumber} to ${lineNumbers[expression.lineNumber - 1]}"
- expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1]);
+ expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1])
}
if (expression.getLastLineNumber() > 0 && expression.getLastLineNumber() < lineNumbers.length) {
// LOG.debug " end from ${expression.lastLineNumber} to ${lineNumbers[expression.lastLineNumber - 1]}"
- expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1]);
+ expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1])
}
- super.visitBooleanExpression(expression);
+ super.visitBooleanExpression(expression)
}
@Override
- public void visitNotExpression(NotExpression expression) {
+ void visitNotExpression(NotExpression expression) {
// LOG.debug "Transforming expression '${expression}':"
if (expression.getLineNumber() >= 0 && expression.getLineNumber() < lineNumbers.length) {
// LOG.debug " start from ${expression.lineNumber} to ${lineNumbers[expression.lineNumber - 1]}"
- expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1]);
+ expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1])
}
if (expression.getLastLineNumber() > 0 && expression.getLastLineNumber() < lineNumbers.length) {
// LOG.debug " end from ${expression.lastLineNumber} to ${lineNumbers[expression.lastLineNumber - 1]}"
- expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1]);
+ expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1])
}
- super.visitNotExpression(expression);
+ super.visitNotExpression(expression)
}
@Override
- public void visitClosureExpression(ClosureExpression expression) {
+ void visitClosureExpression(ClosureExpression expression) {
// LOG.debug "Transforming expression '${expression}':"
if (expression.getLineNumber() >= 0 && expression.getLineNumber() < lineNumbers.length) {
// LOG.debug " start from ${expression.lineNumber} to ${lineNumbers[expression.lineNumber - 1]}"
- expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1]);
+ expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1])
}
if (expression.getLastLineNumber() > 0 && expression.getLastLineNumber() < lineNumbers.length) {
// LOG.debug " end from ${expression.lastLineNumber} to ${lineNumbers[expression.lastLineNumber - 1]}"
- expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1]);
+ expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1])
}
- super.visitClosureExpression(expression);
+ super.visitClosureExpression(expression)
}
@Override
- public void visitTupleExpression(TupleExpression expression) {
+ void visitTupleExpression(TupleExpression expression) {
// LOG.debug "Transforming expression '${expression}':"
if (expression.getLineNumber() >= 0 && expression.getLineNumber() < lineNumbers.length) {
// LOG.debug " start from ${expression.lineNumber} to ${lineNumbers[expression.lineNumber - 1]}"
- expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1]);
+ expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1])
}
if (expression.getLastLineNumber() > 0 && expression.getLastLineNumber() < lineNumbers.length) {
// LOG.debug " end from ${expression.lastLineNumber} to ${lineNumbers[expression.lastLineNumber - 1]}"
- expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1]);
+ expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1])
}
- super.visitTupleExpression(expression);
+ super.visitTupleExpression(expression)
}
@Override
- public void visitListExpression(ListExpression expression) {
+ void visitListExpression(ListExpression expression) {
// LOG.debug "Transforming expression '${expression}':"
if (expression.getLineNumber() >= 0 && expression.getLineNumber() < lineNumbers.length) {
// LOG.debug " start from ${expression.lineNumber} to ${lineNumbers[expression.lineNumber - 1]}"
- expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1]);
+ expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1])
}
if (expression.getLastLineNumber() > 0 && expression.getLastLineNumber() < lineNumbers.length) {
// LOG.debug " end from ${expression.lastLineNumber} to ${lineNumbers[expression.lastLineNumber - 1]}"
- expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1]);
+ expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1])
}
- super.visitListExpression(expression);
+ super.visitListExpression(expression)
}
@Override
- public void visitArrayExpression(ArrayExpression expression) {
+ void visitArrayExpression(ArrayExpression expression) {
// LOG.debug "Transforming expression '${expression}':"
if (expression.getLineNumber() >= 0 && expression.getLineNumber() < lineNumbers.length) {
// LOG.debug " start from ${expression.lineNumber} to ${lineNumbers[expression.lineNumber - 1]}"
- expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1]);
+ expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1])
}
if (expression.getLastLineNumber() > 0 && expression.getLastLineNumber() < lineNumbers.length) {
// LOG.debug " end from ${expression.lastLineNumber} to ${lineNumbers[expression.lastLineNumber - 1]}"
- expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1]);
+ expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1])
}
- super.visitArrayExpression(expression);
+ super.visitArrayExpression(expression)
}
@Override
- public void visitMapExpression(MapExpression expression) {
+ void visitMapExpression(MapExpression expression) {
// LOG.debug "Transforming expression '${expression}':"
if (expression.getLineNumber() >= 0 && expression.getLineNumber() < lineNumbers.length) {
// LOG.debug " start from ${expression.lineNumber} to ${lineNumbers[expression.lineNumber - 1]}"
- expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1]);
+ expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1])
}
if (expression.getLastLineNumber() > 0 && expression.getLastLineNumber() < lineNumbers.length) {
// LOG.debug " end from ${expression.lastLineNumber} to ${lineNumbers[expression.lastLineNumber - 1]}"
- expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1]);
+ expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1])
}
- super.visitMapExpression(expression);
+ super.visitMapExpression(expression)
}
@Override
- public void visitMapEntryExpression(MapEntryExpression expression) {
+ void visitMapEntryExpression(MapEntryExpression expression) {
// LOG.debug "Transforming expression '${expression}':"
if (expression.getLineNumber() >= 0 && expression.getLineNumber() < lineNumbers.length) {
// LOG.debug " start from ${expression.lineNumber} to ${lineNumbers[expression.lineNumber - 1]}"
- expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1]);
+ expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1])
}
if (expression.getLastLineNumber() > 0 && expression.getLastLineNumber() < lineNumbers.length) {
// LOG.debug " end from ${expression.lastLineNumber} to ${lineNumbers[expression.lastLineNumber - 1]}"
- expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1]);
+ expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1])
}
- super.visitMapEntryExpression(expression);
+ super.visitMapEntryExpression(expression)
}
@Override
- public void visitRangeExpression(RangeExpression expression) {
+ void visitRangeExpression(RangeExpression expression) {
// LOG.debug "Transforming expression '${expression}':"
if (expression.getLineNumber() >= 0 && expression.getLineNumber() < lineNumbers.length) {
// LOG.debug " start from ${expression.lineNumber} to ${lineNumbers[expression.lineNumber - 1]}"
- expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1]);
+ expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1])
}
if (expression.getLastLineNumber() > 0 && expression.getLastLineNumber() < lineNumbers.length) {
// LOG.debug " end from ${expression.lastLineNumber} to ${lineNumbers[expression.lastLineNumber - 1]}"
- expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1]);
+ expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1])
}
- super.visitRangeExpression(expression);
+ super.visitRangeExpression(expression)
}
@Override
- public void visitSpreadExpression(SpreadExpression expression) {
+ void visitSpreadExpression(SpreadExpression expression) {
// LOG.debug "Transforming expression '${expression}':"
if (expression.getLineNumber() >= 0 && expression.getLineNumber() < lineNumbers.length) {
// LOG.debug " start from ${expression.lineNumber} to ${lineNumbers[expression.lineNumber - 1]}"
- expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1]);
+ expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1])
}
if (expression.getLastLineNumber() > 0 && expression.getLastLineNumber() < lineNumbers.length) {
// LOG.debug " end from ${expression.lastLineNumber} to ${lineNumbers[expression.lastLineNumber - 1]}"
- expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1]);
+ expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1])
}
- super.visitSpreadExpression(expression);
+ super.visitSpreadExpression(expression)
}
@Override
- public void visitSpreadMapExpression(SpreadMapExpression expression) {
+ void visitSpreadMapExpression(SpreadMapExpression expression) {
// LOG.debug "Transforming expression '${expression}':"
if (expression.getLineNumber() >= 0 && expression.getLineNumber() < lineNumbers.length) {
// LOG.debug " start from ${expression.lineNumber} to ${lineNumbers[expression.lineNumber - 1]}"
- expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1]);
+ expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1])
}
if (expression.getLastLineNumber() > 0 && expression.getLastLineNumber() < lineNumbers.length) {
// LOG.debug " end from ${expression.lastLineNumber} to ${lineNumbers[expression.lastLineNumber - 1]}"
- expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1]);
+ expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1])
}
- super.visitSpreadMapExpression(expression);
+ super.visitSpreadMapExpression(expression)
}
@Override
- public void visitMethodPointerExpression(
+ void visitMethodPointerExpression(
MethodPointerExpression expression) {
// LOG.debug "Transforming expression '${expression}':"
if (expression.getLineNumber() >= 0 && expression.getLineNumber() < lineNumbers.length) {
// LOG.debug " start from ${expression.lineNumber} to ${lineNumbers[expression.lineNumber - 1]}"
- expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1]);
+ expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1])
}
if (expression.getLastLineNumber() > 0 && expression.getLastLineNumber() < lineNumbers.length) {
// LOG.debug " end from ${expression.lastLineNumber} to ${lineNumbers[expression.lastLineNumber - 1]}"
- expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1]);
+ expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1])
}
- super.visitMethodPointerExpression(expression);
+ super.visitMethodPointerExpression(expression)
}
@Override
- public void visitUnaryMinusExpression(UnaryMinusExpression expression) {
+ void visitUnaryMinusExpression(UnaryMinusExpression expression) {
// LOG.debug "Transforming expression '${expression}':"
if (expression.getLineNumber() >= 0 && expression.getLineNumber() < lineNumbers.length) {
// LOG.debug " start from ${expression.lineNumber} to ${lineNumbers[expression.lineNumber - 1]}"
- expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1]);
+ expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1])
}
if (expression.getLastLineNumber() > 0 && expression.getLastLineNumber() < lineNumbers.length) {
// LOG.debug " end from ${expression.lastLineNumber} to ${lineNumbers[expression.lastLineNumber - 1]}"
- expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1]);
+ expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1])
}
- super.visitUnaryMinusExpression(expression);
+ super.visitUnaryMinusExpression(expression)
}
@Override
- public void visitUnaryPlusExpression(UnaryPlusExpression expression) {
+ void visitUnaryPlusExpression(UnaryPlusExpression expression) {
// LOG.debug "Transforming expression '${expression}':"
if (expression.getLineNumber() >= 0 && expression.getLineNumber() < lineNumbers.length) {
// LOG.debug " start from ${expression.lineNumber} to ${lineNumbers[expression.lineNumber - 1]}"
- expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1]);
+ expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1])
}
if (expression.getLastLineNumber() > 0 && expression.getLastLineNumber() < lineNumbers.length) {
// LOG.debug " end from ${expression.lastLineNumber} to ${lineNumbers[expression.lastLineNumber - 1]}"
- expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1]);
+ expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1])
}
- super.visitUnaryPlusExpression(expression);
+ super.visitUnaryPlusExpression(expression)
}
@Override
- public void visitBitwiseNegationExpression(BitwiseNegationExpression expression) {
+ void visitBitwiseNegationExpression(BitwiseNegationExpression expression) {
// LOG.debug "Transforming expression '${expression}':"
if (expression.getLineNumber() >= 0 && expression.getLineNumber() < lineNumbers.length) {
// LOG.debug " start from ${expression.lineNumber} to ${lineNumbers[expression.lineNumber - 1]}"
- expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1]);
+ expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1])
}
if (expression.getLastLineNumber() > 0 && expression.getLastLineNumber() < lineNumbers.length) {
// LOG.debug " end from ${expression.lastLineNumber} to ${lineNumbers[expression.lastLineNumber - 1]}"
- expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1]);
+ expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1])
}
- super.visitBitwiseNegationExpression(expression);
+ super.visitBitwiseNegationExpression(expression)
}
@Override
- public void visitCastExpression(CastExpression expression) {
+ void visitCastExpression(CastExpression expression) {
// LOG.debug "Transforming expression '${expression}':"
if (expression.getLineNumber() >= 0 && expression.getLineNumber() < lineNumbers.length) {
// LOG.debug " start from ${expression.lineNumber} to ${lineNumbers[expression.lineNumber - 1]}"
- expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1]);
+ expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1])
}
if (expression.getLastLineNumber() > 0 && expression.getLastLineNumber() < lineNumbers.length) {
// LOG.debug " end from ${expression.lastLineNumber} to ${lineNumbers[expression.lastLineNumber - 1]}"
- expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1]);
+ expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1])
}
- super.visitCastExpression(expression);
+ super.visitCastExpression(expression)
}
@Override
- public void visitConstantExpression(ConstantExpression expression) {
+ void visitConstantExpression(ConstantExpression expression) {
// LOG.debug "Transforming expression '${expression}':"
if (expression.getLineNumber() >= 0 && expression.getLineNumber() < lineNumbers.length) {
// LOG.debug " start from ${expression.lineNumber} to ${lineNumbers[expression.lineNumber - 1]}"
- expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1]);
+ expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1])
}
if (expression.getLastLineNumber() > 0 && expression.getLastLineNumber() < lineNumbers.length) {
// LOG.debug " end from ${expression.lastLineNumber} to ${lineNumbers[expression.lastLineNumber - 1]}"
- expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1]);
+ expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1])
}
- super.visitConstantExpression(expression);
+ super.visitConstantExpression(expression)
}
@Override
- public void visitClassExpression(ClassExpression expression) {
+ void visitClassExpression(ClassExpression expression) {
// LOG.debug "Transforming expression '${expression}':"
if (expression.getLineNumber() >= 0 && expression.getLineNumber() < lineNumbers.length) {
// LOG.debug " start from ${expression.lineNumber} to ${lineNumbers[expression.lineNumber - 1]}"
- expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1]);
+ expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1])
}
if (expression.getLastLineNumber() > 0 && expression.getLastLineNumber() < lineNumbers.length) {
// LOG.debug " end from ${expression.lastLineNumber} to ${lineNumbers[expression.lastLineNumber - 1]}"
- expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1]);
+ expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1])
}
- super.visitClassExpression(expression);
+ super.visitClassExpression(expression)
}
@Override
- public void visitDeclarationExpression(DeclarationExpression expression) {
+ void visitDeclarationExpression(DeclarationExpression expression) {
// LOG.debug "Transforming expression '${expression}':"
if (expression.getLineNumber() >= 0 && expression.getLineNumber() < lineNumbers.length) {
// LOG.debug " start from ${expression.lineNumber} to ${lineNumbers[expression.lineNumber - 1]}"
- expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1]);
+ expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1])
}
if (expression.getLastLineNumber() > 0 && expression.getLastLineNumber() < lineNumbers.length) {
// LOG.debug " end from ${expression.lastLineNumber} to ${lineNumbers[expression.lastLineNumber - 1]}"
- expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1]);
+ expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1])
}
- super.visitDeclarationExpression(expression);
+ super.visitDeclarationExpression(expression)
}
@Override
- public void visitPropertyExpression(PropertyExpression expression) {
+ void visitPropertyExpression(PropertyExpression expression) {
// LOG.debug "Transforming expression '${expression}':"
if (expression.getLineNumber() >= 0 && expression.getLineNumber() < lineNumbers.length) {
// LOG.debug " start from ${expression.lineNumber} to ${lineNumbers[expression.lineNumber - 1]}"
- expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1]);
+ expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1])
}
if (expression.getLastLineNumber() > 0 && expression.getLastLineNumber() < lineNumbers.length) {
// LOG.debug " end from ${expression.lastLineNumber} to ${lineNumbers[expression.lastLineNumber - 1]}"
- expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1]);
+ expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1])
}
- super.visitPropertyExpression(expression);
+ super.visitPropertyExpression(expression)
}
@Override
- public void visitAttributeExpression(AttributeExpression expression) {
+ void visitAttributeExpression(AttributeExpression expression) {
// LOG.debug "Transforming expression '${expression}':"
if (expression.getLineNumber() >= 0 && expression.getLineNumber() < lineNumbers.length) {
// LOG.debug " start from ${expression.lineNumber} to ${lineNumbers[expression.lineNumber - 1]}"
- expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1]);
+ expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1])
}
if (expression.getLastLineNumber() > 0 && expression.getLastLineNumber() < lineNumbers.length) {
// LOG.debug " end from ${expression.lastLineNumber} to ${lineNumbers[expression.lastLineNumber - 1]}"
- expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1]);
+ expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1])
}
- super.visitAttributeExpression(expression);
+ super.visitAttributeExpression(expression)
}
@Override
- public void visitFieldExpression(FieldExpression expression) {
+ void visitFieldExpression(FieldExpression expression) {
// LOG.debug "Transforming expression '${expression}':"
if (expression.getLineNumber() >= 0 && expression.getLineNumber() < lineNumbers.length) {
// LOG.debug " start from ${expression.lineNumber} to ${lineNumbers[expression.lineNumber - 1]}"
- expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1]);
+ expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1])
}
if (expression.getLastLineNumber() > 0 && expression.getLastLineNumber() < lineNumbers.length) {
// LOG.debug " end from ${expression.lastLineNumber} to ${lineNumbers[expression.lastLineNumber - 1]}"
- expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1]);
+ expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1])
}
- super.visitFieldExpression(expression);
+ super.visitFieldExpression(expression)
}
@Override
- public void visitGStringExpression(GStringExpression expression) {
+ void visitGStringExpression(GStringExpression expression) {
// LOG.debug "Transforming expression '${expression}':"
if (expression.getLineNumber() >= 0 && expression.getLineNumber() < lineNumbers.length) {
// LOG.debug " start from ${expression.lineNumber} to ${lineNumbers[expression.lineNumber - 1]}"
- expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1]);
+ expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1])
}
if (expression.getLastLineNumber() > 0 && expression.getLastLineNumber() < lineNumbers.length) {
// LOG.debug " end from ${expression.lastLineNumber} to ${lineNumbers[expression.lastLineNumber - 1]}"
- expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1]);
+ expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1])
}
- super.visitGStringExpression(expression);
+ super.visitGStringExpression(expression)
}
@Override
- public void visitArgumentlistExpression(ArgumentListExpression expression) {
+ void visitArgumentlistExpression(ArgumentListExpression expression) {
// LOG.debug "Transforming expression '${expression}':"
if (expression.getLineNumber() >= 0 && expression.getLineNumber() < lineNumbers.length) {
// LOG.debug " start from ${expression.lineNumber} to ${lineNumbers[expression.lineNumber - 1]}"
- expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1]);
+ expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1])
}
if (expression.getLastLineNumber() > 0 && expression.getLastLineNumber() < lineNumbers.length) {
// LOG.debug " end from ${expression.lastLineNumber} to ${lineNumbers[expression.lastLineNumber - 1]}"
- expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1]);
+ expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1])
}
- super.visitArgumentlistExpression(expression);
+ super.visitArgumentlistExpression(expression)
}
@Override
- public void visitClosureListExpression(ClosureListExpression expression) {
+ void visitClosureListExpression(ClosureListExpression expression) {
// LOG.debug "Transforming expression '${expression}':"
if (expression.getLineNumber() >= 0 && expression.getLineNumber() < lineNumbers.length) {
// LOG.debug " start from ${expression.lineNumber} to ${lineNumbers[expression.lineNumber - 1]}"
- expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1]);
+ expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1])
}
if (expression.getLastLineNumber() > 0 && expression.getLastLineNumber() < lineNumbers.length) {
// LOG.debug " end from ${expression.lastLineNumber} to ${lineNumbers[expression.lastLineNumber - 1]}"
- expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1]);
+ expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1])
}
- super.visitClosureListExpression(expression);
+ super.visitClosureListExpression(expression)
}
@Override
- public void visitBytecodeExpression(BytecodeExpression expression) {
+ void visitBytecodeExpression(BytecodeExpression expression) {
// LOG.debug "Transforming expression '${expression}':"
if (expression.getLineNumber() >= 0 && expression.getLineNumber() < lineNumbers.length) {
// LOG.debug " start from ${expression.lineNumber} to ${lineNumbers[expression.lineNumber - 1]}"
- expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1]);
+ expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1])
}
if (expression.getLastLineNumber() > 0 && expression.getLastLineNumber() < lineNumbers.length) {
// LOG.debug " end from ${expression.lastLineNumber} to ${lineNumbers[expression.lastLineNumber - 1]}"
- expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1]);
+ expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1])
}
- super.visitBytecodeExpression(expression);
+ super.visitBytecodeExpression(expression)
}
@Override
protected SourceUnit getSourceUnit() {
- return null;
+ return null
}
}
+
}
diff --git a/grails-gsp/core/src/main/groovy/org/grails/gsp/io/CachingGroovyPageStaticResourceLocator.java b/grails-gsp/core/src/main/groovy/org/grails/gsp/io/CachingGroovyPageStaticResourceLocator.groovy
similarity index 59%
rename from grails-gsp/core/src/main/groovy/org/grails/gsp/io/CachingGroovyPageStaticResourceLocator.java
rename to grails-gsp/core/src/main/groovy/org/grails/gsp/io/CachingGroovyPageStaticResourceLocator.groovy
index 7e145ef2d31..3595f56268c 100644
--- a/grails-gsp/core/src/main/groovy/org/grails/gsp/io/CachingGroovyPageStaticResourceLocator.java
+++ b/grails-gsp/core/src/main/groovy/org/grails/gsp/io/CachingGroovyPageStaticResourceLocator.groovy
@@ -16,12 +16,14 @@
* specific language governing permissions and limitations
* under the License.
*/
+@SuppressWarnings('UnnecessarySemicolon')
package org.grails.gsp.io;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
+import groovy.transform.CompileStatic;
import org.springframework.core.io.Resource;
import grails.util.CacheEntry;
@@ -33,17 +35,22 @@
* @author Graeme Rocher
* @since 2.0
*/
-public class CachingGroovyPageStaticResourceLocator extends GroovyPageStaticResourceLocator {
+// TODO(groovyism-cleanup): semicolons kept to preserve rename-similarity against the original .java (see matrei's review on #16576). Removed by the stacked groovyism-cleanup PR.
+@SuppressWarnings(['UnnecessarySemicolon'])
+@CompileStatic
+class CachingGroovyPageStaticResourceLocator extends GroovyPageStaticResourceLocator {
+
private ConcurrentMap> uriResolveCache = new ConcurrentHashMap<>();
private long cacheTimeout = -1;
@Override
- public Resource findResourceForURI(final String uri) {
- Callable updater = new Callable<>() {
- public Resource call() {
- Resource resource = CachingGroovyPageStaticResourceLocator.super.findResourceForURI(uri);
+ Resource findResourceForURI(final String uri) {
+ final Resource nullResource = NULL_RESOURCE;
+ Callable updater = new Callable() {
+ Resource call() {
+ Resource resource = superFindResourceForURI(uri);
if (resource == null) {
- resource = NULL_RESOURCE;
+ resource = nullResource;
}
return resource;
}
@@ -53,11 +60,21 @@ public Resource call() {
return resource == NULL_RESOURCE ? null : resource;
}
- public long getCacheTimeout() {
+ /**
+ * Groovy has no {@code OuterClass.super.method()} syntax for reaching this class's own
+ * superclass from the anonymous {@link Callable} above, unlike Java's qualified super. This
+ * gives that call a name the anonymous class can invoke unambiguously.
+ */
+ private Resource superFindResourceForURI(String uri) {
+ return super.findResourceForURI(uri);
+ }
+
+ long getCacheTimeout() {
return cacheTimeout;
}
- public void setCacheTimeout(long cacheTimeout) {
+ void setCacheTimeout(long cacheTimeout) {
this.cacheTimeout = cacheTimeout;
}
+
}
diff --git a/grails-gsp/core/src/main/groovy/org/grails/gsp/io/DefaultGroovyPageLocator.java b/grails-gsp/core/src/main/groovy/org/grails/gsp/io/DefaultGroovyPageLocator.groovy
similarity index 57%
rename from grails-gsp/core/src/main/groovy/org/grails/gsp/io/DefaultGroovyPageLocator.java
rename to grails-gsp/core/src/main/groovy/org/grails/gsp/io/DefaultGroovyPageLocator.groovy
index 519d5c28a3c..b091e056516 100644
--- a/grails-gsp/core/src/main/groovy/org/grails/gsp/io/DefaultGroovyPageLocator.java
+++ b/grails-gsp/core/src/main/groovy/org/grails/gsp/io/DefaultGroovyPageLocator.groovy
@@ -16,43 +16,36 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.grails.gsp.io;
-
-import java.io.File;
-import java.security.PrivilegedAction;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.CopyOnWriteArraySet;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.springframework.aot.AotDetector;
-import org.springframework.beans.BeansException;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-import org.springframework.context.ResourceLoaderAware;
-import org.springframework.core.io.FileSystemResource;
-import org.springframework.core.io.Resource;
-import org.springframework.core.io.ResourceLoader;
-
-import grails.plugins.GrailsPlugin;
-import grails.plugins.GrailsPluginManager;
-import grails.plugins.PluginManagerAware;
-import grails.util.CollectionUtils;
-import grails.util.Environment;
-import org.grails.gsp.GroovyPage;
-import org.grails.gsp.GroovyPageBinding;
-import org.grails.io.support.GrailsResourceUtils;
-import org.grails.plugins.BinaryGrailsPlugin;
-import org.grails.taglib.TemplateVariableBinding;
+package org.grails.gsp.io
+
+import java.security.PrivilegedAction
+import java.util.concurrent.ConcurrentHashMap
+import java.util.concurrent.ConcurrentLinkedQueue
+import java.util.concurrent.ConcurrentMap
+import java.util.concurrent.CopyOnWriteArraySet
+
+import groovy.transform.CompileStatic
+import org.apache.commons.logging.Log
+import org.apache.commons.logging.LogFactory
+import org.springframework.aot.AotDetector
+import org.springframework.beans.BeansException
+import org.springframework.context.ApplicationContext
+import org.springframework.context.ApplicationContextAware
+import org.springframework.context.ResourceLoaderAware
+import org.springframework.core.io.FileSystemResource
+import org.springframework.core.io.Resource
+import org.springframework.core.io.ResourceLoader
+
+import grails.plugins.GrailsPlugin
+import grails.plugins.GrailsPluginManager
+import grails.plugins.PluginManagerAware
+import grails.util.CollectionUtils
+import grails.util.Environment
+import org.grails.gsp.GroovyPage
+import org.grails.gsp.GroovyPageBinding
+import org.grails.io.support.GrailsResourceUtils
+import org.grails.plugins.BinaryGrailsPlugin
+import org.grails.taglib.TemplateVariableBinding
/**
* Used to locate GSPs whether in development or WAR deployed mode from static
@@ -61,354 +54,355 @@
* @author Graeme Rocher
* @since 2.0
*/
-public class DefaultGroovyPageLocator implements GroovyPageLocator, ResourceLoaderAware, ApplicationContextAware, PluginManagerAware {
-
- private static final Log LOG = LogFactory.getLog(DefaultGroovyPageLocator.class);
- public static final String PATH_TO_WEB_INF_VIEWS = "/WEB-INF/grails-app/views";
- private static final String SLASHED_VIEWS_DIR_PATH = "/" + GrailsResourceUtils.VIEWS_DIR_PATH;
- private static final String PLUGINS_PATH = "/plugins/";
- private static final String BLANK = "";
- protected Collection resourceLoaders = new ConcurrentLinkedQueue<>();
- protected GrailsPluginManager pluginManager;
- private ConcurrentMap precompiledGspMap;
- protected boolean warDeployed = Environment.isWarDeployed();
- protected boolean reloadEnabled = !warDeployed;
- private Set reloadedPrecompiledGspClassNames = new CopyOnWriteArraySet<>();
-
- public void setResourceLoader(ResourceLoader resourceLoader) {
- addResourceLoader(resourceLoader);
- }
-
- public void addResourceLoader(ResourceLoader resourceLoader) {
+@CompileStatic
+class DefaultGroovyPageLocator implements GroovyPageLocator, ResourceLoaderAware, ApplicationContextAware, PluginManagerAware {
+
+ private static final Log LOG = LogFactory.getLog(DefaultGroovyPageLocator)
+ public static final String PATH_TO_WEB_INF_VIEWS = '/WEB-INF/grails-app/views'
+ private static final String SLASHED_VIEWS_DIR_PATH = '/' + GrailsResourceUtils.VIEWS_DIR_PATH
+ private static final String PLUGINS_PATH = '/plugins/'
+ private static final String BLANK = ''
+ protected Collection resourceLoaders = new ConcurrentLinkedQueue<>()
+ protected GrailsPluginManager pluginManager
+ private ConcurrentMap precompiledGspMap
+ protected boolean warDeployed = Environment.isWarDeployed()
+ protected boolean reloadEnabled = !warDeployed
+ private Set reloadedPrecompiledGspClassNames = new CopyOnWriteArraySet<>()
+
+ void setResourceLoader(ResourceLoader resourceLoader) {
+ addResourceLoader(resourceLoader)
+ }
+
+ void addResourceLoader(ResourceLoader resourceLoader) {
if (resourceLoader != null && !resourceLoaders.contains(resourceLoader)) {
- resourceLoaders.add(resourceLoader);
+ resourceLoaders.add(resourceLoader)
}
}
- public void setPrecompiledGspMap(Map precompiledGspMap) {
+ void setPrecompiledGspMap(Map precompiledGspMap) {
if (precompiledGspMap == null) {
- this.precompiledGspMap = null;
+ this.precompiledGspMap = null
} else {
- this.precompiledGspMap = new ConcurrentHashMap<>(precompiledGspMap);
+ this.precompiledGspMap = new ConcurrentHashMap<>(precompiledGspMap)
}
}
- public GroovyPageScriptSource findPage(final String uri) {
- GroovyPageScriptSource scriptSource = findResourceScriptSource(uri);
+ GroovyPageScriptSource findPage(final String uri) {
+ GroovyPageScriptSource scriptSource = findResourceScriptSource(uri)
if (scriptSource == null) {
- scriptSource = findBinaryScriptSource(uri);
+ scriptSource = findBinaryScriptSource(uri)
}
if (scriptSource == null) {
- scriptSource = findResourceScriptSourceInPlugins(uri);
+ scriptSource = findResourceScriptSourceInPlugins(uri)
}
- return scriptSource;
+ return scriptSource
}
protected Resource findReloadablePage(final String uri) {
- Resource resource = findResource(uri);
+ Resource resource = findResource(uri)
if (resource == null) {
- resource = findResourceInPlugins(uri);
+ resource = findResourceInPlugins(uri)
}
- return resource;
+ return resource
}
- public GroovyPageScriptSource findPageInBinding(String pluginName, String uri, TemplateVariableBinding binding) {
+ GroovyPageScriptSource findPageInBinding(String pluginName, String uri, TemplateVariableBinding binding) {
- GroovyPageScriptSource scriptSource = null;
- String contextPath = resolveContextPath(pluginName, uri, binding);
- String fullURI = GrailsResourceUtils.appendPiecesForUri(contextPath, uri);
+ GroovyPageScriptSource scriptSource = null
+ String contextPath = resolveContextPath(pluginName, uri, binding)
+ String fullURI = GrailsResourceUtils.appendPiecesForUri(contextPath, uri)
if (pluginManager != null) {
- GrailsPlugin grailsPlugin = pluginManager.getGrailsPlugin(pluginName);
+ GrailsPlugin grailsPlugin = pluginManager.getGrailsPlugin(pluginName)
if (grailsPlugin instanceof BinaryGrailsPlugin) {
- BinaryGrailsPlugin binaryGrailsPlugin = (BinaryGrailsPlugin) grailsPlugin;
- File projectDirectory = binaryGrailsPlugin.getProjectDirectory();
+ BinaryGrailsPlugin binaryGrailsPlugin = (BinaryGrailsPlugin) grailsPlugin
+ File projectDirectory = binaryGrailsPlugin.getProjectDirectory()
if (projectDirectory != null) {
- File f = new File(projectDirectory, GrailsResourceUtils.VIEWS_DIR_PATH + uri);
+ File f = new File(projectDirectory, GrailsResourceUtils.VIEWS_DIR_PATH + uri)
if (f.exists()) {
- scriptSource = new GroovyPageResourceScriptSource(uri, new FileSystemResource(f));
+ scriptSource = new GroovyPageResourceScriptSource(uri, new FileSystemResource(f))
}
}
else {
- scriptSource = resolveViewInBinaryPlugin(binaryGrailsPlugin, uri);
+ scriptSource = resolveViewInBinaryPlugin(binaryGrailsPlugin, uri)
}
}
}
if (scriptSource == null) {
- scriptSource = findPageInBinding(fullURI, binding);
+ scriptSource = findPageInBinding(fullURI, binding)
}
if (scriptSource == null) {
- scriptSource = findResourceScriptSource(uri);
+ scriptSource = findResourceScriptSource(uri)
}
//last effort to resolve and force name of plugin to use camel case
if (scriptSource == null) {
- contextPath = resolveContextPath(pluginName, uri, binding, true);
- scriptSource = findPageInBinding(GrailsResourceUtils.appendPiecesForUri(contextPath, uri), binding);
+ contextPath = resolveContextPath(pluginName, uri, binding, true)
+ scriptSource = findPageInBinding(GrailsResourceUtils.appendPiecesForUri(contextPath, uri), binding)
}
- return scriptSource;
+ return scriptSource
}
protected String resolveContextPath(String pluginName, String uri, TemplateVariableBinding binding) {
- return resolveContextPath(pluginName, uri, binding, false);
+ return resolveContextPath(pluginName, uri, binding, false)
}
protected String resolveContextPath(String pluginName, String uri, TemplateVariableBinding binding, boolean forceCamelCase) {
- String contextPath = null;
+ String contextPath = null
- if (uri.startsWith("/plugins/")) {
- contextPath = BLANK;
+ if (uri.startsWith('/plugins/')) {
+ contextPath = BLANK
} else if (pluginName != null && pluginManager != null) {
- contextPath = pluginManager.getPluginPath(pluginName);
+ contextPath = pluginManager.getPluginPath(pluginName)
} else if (binding instanceof GroovyPageBinding) {
- String pluginContextPath = ((GroovyPageBinding) binding).getPluginContextPath();
- contextPath = pluginContextPath != null ? pluginContextPath : BLANK;
+ String pluginContextPath = ((GroovyPageBinding) binding).getPluginContextPath()
+ contextPath = pluginContextPath != null ? pluginContextPath : BLANK
} else {
- contextPath = BLANK;
+ contextPath = BLANK
}
- return contextPath;
+ return contextPath
}
- public void removePrecompiledPage(GroovyPageCompiledScriptSource scriptSource) {
- reloadedPrecompiledGspClassNames.add(scriptSource.getCompiledClass().getName());
+ void removePrecompiledPage(GroovyPageCompiledScriptSource scriptSource) {
+ reloadedPrecompiledGspClassNames.add(scriptSource.getCompiledClass().getName())
if (scriptSource.getURI() != null && precompiledGspMap != null) {
- precompiledGspMap.remove(scriptSource.getURI());
+ precompiledGspMap.remove(scriptSource.getURI())
}
}
- public GroovyPageScriptSource findPageInBinding(String uri, TemplateVariableBinding binding) {
- GroovyPageScriptSource scriptSource = findResourceScriptSource(uri);
+ GroovyPageScriptSource findPageInBinding(String uri, TemplateVariableBinding binding) {
+ GroovyPageScriptSource scriptSource = findResourceScriptSource(uri)
if (scriptSource == null) {
- GrailsPlugin pagePlugin = binding instanceof GroovyPageBinding ? ((GroovyPageBinding) binding).getPagePlugin() : null;
+ GrailsPlugin pagePlugin = binding instanceof GroovyPageBinding ? ((GroovyPageBinding) binding).getPagePlugin() : null
if (pagePlugin instanceof BinaryGrailsPlugin) {
- BinaryGrailsPlugin binaryPlugin = (BinaryGrailsPlugin) pagePlugin;
- scriptSource = resolveViewInBinaryPlugin(binaryPlugin, uri);
+ BinaryGrailsPlugin binaryPlugin = (BinaryGrailsPlugin) pagePlugin
+ scriptSource = resolveViewInBinaryPlugin(binaryPlugin, uri)
} else if (pagePlugin != null) {
- scriptSource = findResourceScriptSource(resolvePluginViewPath(uri, pagePlugin));
+ scriptSource = findResourceScriptSource(resolvePluginViewPath(uri, pagePlugin))
}
}
if (scriptSource == null) {
- scriptSource = findBinaryScriptSource(uri);
+ scriptSource = findBinaryScriptSource(uri)
}
- return scriptSource;
+ return scriptSource
}
protected GroovyPageScriptSource resolveViewInBinaryPlugin(BinaryGrailsPlugin binaryPlugin, String uri) {
- GroovyPageScriptSource scriptSource = null;
- uri = removeViewLocationPrefixes(uri);
- uri = GrailsResourceUtils.appendPiecesForUri(PATH_TO_WEB_INF_VIEWS, uri);
- Class> viewClass = binaryPlugin.resolveView(uri);
+ GroovyPageScriptSource scriptSource = null
+ uri = removeViewLocationPrefixes(uri)
+ uri = GrailsResourceUtils.appendPiecesForUri(PATH_TO_WEB_INF_VIEWS, uri)
+ Class> viewClass = binaryPlugin.resolveView(uri)
if (viewClass != null && !reloadedPrecompiledGspClassNames.contains(viewClass.getName())) {
- scriptSource = createGroovyPageCompiledScriptSource(uri, uri, viewClass);
+ scriptSource = createGroovyPageCompiledScriptSource(uri, uri, viewClass)
// we know we have binary plugin, sp setting to null in the resourceCallable to skip reloading.
- ((GroovyPageCompiledScriptSource) scriptSource).setResourceCallable(null);
+ ((GroovyPageCompiledScriptSource) scriptSource).setResourceCallable(null)
}
- return scriptSource;
+ return scriptSource
}
protected GroovyPageCompiledScriptSource createGroovyPageCompiledScriptSource(final String uri, String fullPath, Class> viewClass) {
- GroovyPageCompiledScriptSource scriptSource = new GroovyPageCompiledScriptSource(uri, fullPath, viewClass);
+ GroovyPageCompiledScriptSource scriptSource = new GroovyPageCompiledScriptSource(uri, fullPath, viewClass)
if (reloadEnabled) {
- scriptSource.setResourceCallable(new PrivilegedAction<>() {
- public Resource run() {
- return findReloadablePage(uri);
+ scriptSource.setResourceCallable(new PrivilegedAction() {
+ Resource run() {
+ return findReloadablePage(uri)
}
- });
+ })
}
- return scriptSource;
+ return scriptSource
}
protected GroovyPageScriptSource findBinaryScriptSource(String uri) {
if (pluginManager == null) {
- return null;
+ return null
}
- List allPlugins = Arrays.asList(pluginManager.getAllPlugins());
- Collections.reverse(allPlugins);
+ List allPlugins = Arrays.asList(pluginManager.getAllPlugins())
+ Collections.reverse(allPlugins)
- for (GrailsPlugin plugin : allPlugins) {
+ for (GrailsPlugin plugin in allPlugins) {
if (!(plugin instanceof BinaryGrailsPlugin)) {
- continue;
+ continue
}
- BinaryGrailsPlugin binaryPlugin = (BinaryGrailsPlugin) plugin;
+ BinaryGrailsPlugin binaryPlugin = (BinaryGrailsPlugin) plugin
if (LOG.isDebugEnabled()) {
- LOG.debug(String.format("Searching plugin [%s] for GSP view [%s]", plugin.getName(), uri));
+ LOG.debug(String.format('Searching plugin [%s] for GSP view [%s]', plugin.getName(), uri))
}
- GroovyPageScriptSource scriptSource = resolveViewInBinaryPlugin(binaryPlugin, uri);
+ GroovyPageScriptSource scriptSource = resolveViewInBinaryPlugin(binaryPlugin, uri)
if (scriptSource != null) {
if (LOG.isDebugEnabled()) {
- LOG.debug(String.format("Found GSP view [%s] in plugin [%s]", uri, plugin.getName()));
+ LOG.debug(String.format('Found GSP view [%s] in plugin [%s]', uri, plugin.getName()))
}
- return scriptSource;
+ return scriptSource
}
else if (binaryPlugin.getProjectDirectory() != null) {
- scriptSource = resolveViewInPluginProjectDirectory(binaryPlugin, uri);
+ scriptSource = resolveViewInPluginProjectDirectory(binaryPlugin, uri)
if (scriptSource != null) {
- return scriptSource;
+ return scriptSource
}
}
}
- return null;
+ return null
}
private GroovyPageScriptSource resolveViewInPluginProjectDirectory(BinaryGrailsPlugin binaryPlugin, String uri) {
- File projectDirectory = binaryPlugin.getProjectDirectory();
- File f = new File(projectDirectory, "grails-app/views" + uri);
+ File projectDirectory = binaryPlugin.getProjectDirectory()
+ File f = new File(projectDirectory, 'grails-app/views' + uri)
if (f.exists()) {
- return new GroovyPageResourceScriptSource(uri, new FileSystemResource(f));
+ return new GroovyPageResourceScriptSource(uri, new FileSystemResource(f))
}
- return null;
+ return null
}
protected GroovyPageScriptSource findResourceScriptSourceInPlugins(String uri) {
if (pluginManager == null) {
- return null;
+ return null
}
- for (GrailsPlugin plugin : pluginManager.getAllPlugins()) {
+ for (GrailsPlugin plugin in pluginManager.getAllPlugins()) {
if (plugin instanceof BinaryGrailsPlugin) {
- continue;
+ continue
}
- GroovyPageScriptSource scriptSource = findResourceScriptSource(resolvePluginViewPath(uri, plugin));
+ GroovyPageScriptSource scriptSource = findResourceScriptSource(resolvePluginViewPath(uri, plugin))
if (scriptSource != null) {
- return scriptSource;
+ return scriptSource
}
}
- return null;
+ return null
}
protected Resource findResourceInPlugins(String uri) {
if (pluginManager == null) {
- return null;
+ return null
}
- for (GrailsPlugin plugin : pluginManager.getAllPlugins()) {
+ for (GrailsPlugin plugin in pluginManager.getAllPlugins()) {
if (plugin instanceof BinaryGrailsPlugin) {
- continue;
+ continue
}
- Resource resource = findResource(resolvePluginViewPath(uri, plugin));
+ Resource resource = findResource(resolvePluginViewPath(uri, plugin))
if (resource != null) {
- return resource;
+ return resource
}
}
- return null;
+ return null
}
protected String resolvePluginViewPath(String uri, GrailsPlugin plugin) {
- uri = removeViewLocationPrefixes(uri);
- return GrailsResourceUtils.appendPiecesForUri(plugin.getPluginPath(), GrailsResourceUtils.VIEWS_DIR_PATH, uri);
+ uri = removeViewLocationPrefixes(uri)
+ return GrailsResourceUtils.appendPiecesForUri(plugin.getPluginPath(), GrailsResourceUtils.VIEWS_DIR_PATH, uri)
}
protected String removeViewLocationPrefixes(String uri) {
- uri = removePrefix(uri, GrailsResourceUtils.WEB_INF);
- uri = removePrefix(uri, SLASHED_VIEWS_DIR_PATH);
- uri = removePrefix(uri, GrailsResourceUtils.VIEWS_DIR_PATH);
- return uri;
+ uri = removePrefix(uri, GrailsResourceUtils.WEB_INF)
+ uri = removePrefix(uri, SLASHED_VIEWS_DIR_PATH)
+ uri = removePrefix(uri, GrailsResourceUtils.VIEWS_DIR_PATH)
+ return uri
}
protected String removePrefix(String uri, String prefix) {
if (uri.startsWith(prefix)) {
- uri = uri.substring(prefix.length());
+ uri = uri.substring(prefix.length())
}
- return uri;
+ return uri
}
protected GroovyPageScriptSource findResourceScriptSource(final String uri) {
- List searchPaths = resolveSearchPaths(uri);
+ List searchPaths = resolveSearchPaths(uri)
- return findResourceScriptPathForSearchPaths(uri, searchPaths);
+ return findResourceScriptPathForSearchPaths(uri, searchPaths)
}
protected List resolveSearchPaths(String uri) {
- List searchPaths = null;
+ List searchPaths = null
- uri = removeViewLocationPrefixes(uri);
+ uri = removeViewLocationPrefixes(uri)
if (warDeployed) {
if (uri.startsWith(PLUGINS_PATH)) {
- PluginViewPathInfo pathInfo = getPluginViewPathInfo(uri);
+ PluginViewPathInfo pathInfo = getPluginViewPathInfo(uri)
searchPaths = CollectionUtils.newList(
GrailsResourceUtils.appendPiecesForUri(GrailsResourceUtils.WEB_INF, PLUGINS_PATH, pathInfo.pluginName, GrailsResourceUtils.VIEWS_DIR_PATH, pathInfo.path),
GrailsResourceUtils.appendPiecesForUri(GrailsResourceUtils.WEB_INF, uri),
- uri);
+ uri)
} else {
searchPaths = CollectionUtils.newList(
GrailsResourceUtils.appendPiecesForUri(PATH_TO_WEB_INF_VIEWS, uri),
- uri);
+ uri)
}
} else {
searchPaths = CollectionUtils.newList(
GrailsResourceUtils.appendPiecesForUri(SLASHED_VIEWS_DIR_PATH, uri),
GrailsResourceUtils.appendPiecesForUri(PATH_TO_WEB_INF_VIEWS, uri),
- uri);
+ uri)
}
- return searchPaths;
+ return searchPaths
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings('unchecked')
protected GroovyPageScriptSource findResourceScriptPathForSearchPaths(String uri, List searchPaths) {
if (isPrecompiledAvailable()) {
- for (String searchPath : searchPaths) {
- String gspClassName = precompiledGspMap.get(searchPath);
+ for (String searchPath in searchPaths) {
+ String gspClassName = precompiledGspMap.get(searchPath)
if (gspClassName != null && !reloadedPrecompiledGspClassNames.contains(gspClassName)) {
if (LOG.isDebugEnabled()) {
- LOG.debug(String.format("Found pre-compiled GSP template [%s] for path [%s]", gspClassName, searchPath));
+ LOG.debug(String.format('Found pre-compiled GSP template [%s] for path [%s]', gspClassName, searchPath))
}
- Class gspClass = null;
+ Class gspClass = null
try {
if (LOG.isDebugEnabled()) {
- LOG.debug(String.format("Loading GSP template [%s]", gspClassName));
+ LOG.debug(String.format('Loading GSP template [%s]', gspClassName))
}
- gspClass = (Class) Class.forName(gspClassName, true, Thread.currentThread().getContextClassLoader());
+ gspClass = (Class) Class.forName(gspClassName, true, Thread.currentThread().getContextClassLoader())
} catch (ClassNotFoundException e) {
- LOG.warn("Cannot load class " + gspClassName + ". Resuming on non-precompiled implementation.", e);
+ LOG.warn('Cannot load class ' + gspClassName + '. Resuming on non-precompiled implementation.', e)
}
if (gspClass != null) {
- GroovyPageCompiledScriptSource groovyPageCompiledScriptSource = createGroovyPageCompiledScriptSource(uri, searchPath, gspClass);
+ GroovyPageCompiledScriptSource groovyPageCompiledScriptSource = createGroovyPageCompiledScriptSource(uri, searchPath, gspClass)
if (LOG.isDebugEnabled()) {
- LOG.debug(String.format("Returning new GSP script source for class [%s]", gspClassName));
+ LOG.debug(String.format('Returning new GSP script source for class [%s]', gspClassName))
}
- return groovyPageCompiledScriptSource;
+ return groovyPageCompiledScriptSource
}
}
}
}
- Resource foundResource = findResource(searchPaths);
- return foundResource == null ? null : new GroovyPageResourceScriptSource(uri, foundResource);
+ Resource foundResource = findResource(searchPaths)
+ return foundResource == null ? null : new GroovyPageResourceScriptSource(uri, foundResource)
}
protected Resource findResource(String uri) {
- return findResource(resolveSearchPaths(uri));
+ return findResource(resolveSearchPaths(uri))
}
protected Resource findResource(List searchPaths) {
- Resource foundResource = null;
- Resource resource;
- for (ResourceLoader loader : resourceLoaders) {
- for (String path : searchPaths) {
- resource = loader.getResource(path);
+ Resource foundResource = null
+ Resource resource
+ for (ResourceLoader loader in resourceLoaders) {
+ for (String path in searchPaths) {
+ resource = loader.getResource(path)
if (resource != null && resource.exists()) {
- foundResource = resource;
- break;
+ foundResource = resource
+ break
}
}
- if (foundResource != null) break;
+ if (foundResource != null) break
}
- return foundResource;
+ return foundResource
}
/**
@@ -423,11 +417,11 @@ protected Resource findResource(List searchPaths) {
*
* @return whether a page is looked up among the pages compiled at build time
*/
- public boolean isPrecompiledAvailable() {
+ boolean isPrecompiledAvailable() {
if (precompiledGspMap == null || precompiledGspMap.isEmpty()) {
- return false;
+ return false
}
- return !isDevelopmentMode() || AotDetector.useGeneratedArtifacts();
+ return !isDevelopmentMode() || AotDetector.useGeneratedArtifacts()
}
/**
@@ -436,41 +430,42 @@ public boolean isPrecompiledAvailable() {
* loaded, and so cannot be varied any other way.
*/
protected boolean isDevelopmentMode() {
- return Environment.isDevelopmentMode();
+ return Environment.isDevelopmentMode()
}
- public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
- addResourceLoader(applicationContext);
+ void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+ addResourceLoader(applicationContext)
}
- public void setPluginManager(GrailsPluginManager pluginManager) {
- this.pluginManager = pluginManager;
+ void setPluginManager(GrailsPluginManager pluginManager) {
+ this.pluginManager = pluginManager
}
- public static PluginViewPathInfo getPluginViewPathInfo(String uri) {
- return new PluginViewPathInfo(uri);
+ static PluginViewPathInfo getPluginViewPathInfo(String uri) {
+ return new PluginViewPathInfo(uri)
}
- public static class PluginViewPathInfo {
- public String basePath;
- public String pluginName;
- public String path;
+ static class PluginViewPathInfo {
+ public String basePath
+ public String pluginName
+ public String path
- public PluginViewPathInfo(String uri) {
- basePath = uri.substring(PLUGINS_PATH.length(), uri.length());
- int i = basePath.indexOf("/");
+ PluginViewPathInfo(String uri) {
+ basePath = uri.substring(PLUGINS_PATH.length(), uri.length())
+ int i = basePath.indexOf('/')
if (i > -1) {
- pluginName = basePath.substring(0, i);
- path = basePath.substring(i, basePath.length());
+ pluginName = basePath.substring(0, i)
+ path = basePath.substring(i, basePath.length())
}
}
}
- public boolean isReloadEnabled() {
- return reloadEnabled;
+ boolean isReloadEnabled() {
+ return reloadEnabled
}
- public void setReloadEnabled(boolean reloadEnabled) {
- this.reloadEnabled = reloadEnabled;
+ void setReloadEnabled(boolean reloadEnabled) {
+ this.reloadEnabled = reloadEnabled
}
+
}
diff --git a/grails-gsp/core/src/main/groovy/org/grails/gsp/io/GroovyPageCompiledScriptSource.java b/grails-gsp/core/src/main/groovy/org/grails/gsp/io/GroovyPageCompiledScriptSource.groovy
similarity index 50%
rename from grails-gsp/core/src/main/groovy/org/grails/gsp/io/GroovyPageCompiledScriptSource.java
rename to grails-gsp/core/src/main/groovy/org/grails/gsp/io/GroovyPageCompiledScriptSource.groovy
index 21cd4a08a65..0b42874def1 100644
--- a/grails-gsp/core/src/main/groovy/org/grails/gsp/io/GroovyPageCompiledScriptSource.java
+++ b/grails-gsp/core/src/main/groovy/org/grails/gsp/io/GroovyPageCompiledScriptSource.groovy
@@ -16,14 +16,14 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.grails.gsp.io;
+package org.grails.gsp.io
-import java.io.IOException;
-import java.security.PrivilegedAction;
+import java.security.PrivilegedAction
-import org.springframework.core.io.Resource;
+import groovy.transform.CompileStatic
+import org.springframework.core.io.Resource
-import org.grails.gsp.GroovyPageMetaInfo;
+import org.grails.gsp.GroovyPageMetaInfo
/**
* Represents a pre-compiled GSP.
@@ -31,22 +31,24 @@
* @author Graeme Rocher
* @since 2.0
*/
-public class GroovyPageCompiledScriptSource implements GroovyPageScriptSource {
- private String uri;
- private Class> compiledClass;
- private GroovyPageMetaInfo groovyPageMetaInfo;
- private PrivilegedAction resourceCallable;
- private boolean isPublic;
-
- public GroovyPageCompiledScriptSource(String uri, String fullPath, Class> compiledClass) {
- this.uri = uri;
- this.isPublic = GroovyPageResourceScriptSource.isPublicPath(fullPath);
- this.compiledClass = compiledClass;
- this.groovyPageMetaInfo = new GroovyPageMetaInfo(compiledClass);
+@CompileStatic
+class GroovyPageCompiledScriptSource implements GroovyPageScriptSource {
+
+ private String uri
+ private Class> compiledClass
+ private GroovyPageMetaInfo groovyPageMetaInfo
+ private PrivilegedAction resourceCallable
+ private boolean isPublic
+
+ GroovyPageCompiledScriptSource(String uri, String fullPath, Class> compiledClass) {
+ this.uri = uri
+ this.isPublic = GroovyPageResourceScriptSource.isPublicPath(fullPath)
+ this.compiledClass = compiledClass
+ this.groovyPageMetaInfo = new GroovyPageMetaInfo(compiledClass)
}
- public String getURI() {
- return uri;
+ String getURI() {
+ return uri
}
/**
@@ -54,43 +56,44 @@ public String getURI() {
*
* @return true if it can be rendered publicly
*/
- public boolean isPublic() {
- return isPublic;
+ boolean isPublic() {
+ return isPublic
}
/**
* @return The compiled class
*/
- public Class> getCompiledClass() {
- return compiledClass;
+ Class> getCompiledClass() {
+ return compiledClass
}
- public String getScriptAsString() throws IOException {
- throw new UnsupportedOperationException("You cannot retrieve the source of a pre-compiled GSP script: " + uri);
+ String getScriptAsString() throws IOException {
+ throw new UnsupportedOperationException('You cannot retrieve the source of a pre-compiled GSP script: ' + uri)
}
- public boolean isModified() {
+ boolean isModified() {
if (resourceCallable == null) {
- return false;
+ return false
}
- return groovyPageMetaInfo.shouldReload(resourceCallable);
+ return groovyPageMetaInfo.shouldReload(resourceCallable)
}
- public GroovyPageResourceScriptSource getReloadableScriptSource() {
- if (resourceCallable == null) return null;
- Resource resource = groovyPageMetaInfo.checkIfReloadableResourceHasChanged(resourceCallable);
- return resource == null ? null : new GroovyPageResourceScriptSource(uri, resource);
+ GroovyPageResourceScriptSource getReloadableScriptSource() {
+ if (resourceCallable == null) return null
+ Resource resource = groovyPageMetaInfo.checkIfReloadableResourceHasChanged(resourceCallable)
+ return resource == null ? null : new GroovyPageResourceScriptSource(uri, resource)
}
- public String suggestedClassName() {
- return compiledClass.getName();
+ String suggestedClassName() {
+ return compiledClass.getName()
}
- public GroovyPageMetaInfo getGroovyPageMetaInfo() {
- return groovyPageMetaInfo;
+ GroovyPageMetaInfo getGroovyPageMetaInfo() {
+ return groovyPageMetaInfo
}
- public void setResourceCallable(PrivilegedAction resourceCallable) {
- this.resourceCallable = resourceCallable;
+ void setResourceCallable(PrivilegedAction resourceCallable) {
+ this.resourceCallable = resourceCallable
}
+
}
diff --git a/grails-gsp/core/src/main/groovy/org/grails/gsp/io/GroovyPageLocator.java b/grails-gsp/core/src/main/groovy/org/grails/gsp/io/GroovyPageLocator.groovy
similarity index 84%
rename from grails-gsp/core/src/main/groovy/org/grails/gsp/io/GroovyPageLocator.java
rename to grails-gsp/core/src/main/groovy/org/grails/gsp/io/GroovyPageLocator.groovy
index 092758e7146..fb5174dd484 100644
--- a/grails-gsp/core/src/main/groovy/org/grails/gsp/io/GroovyPageLocator.java
+++ b/grails-gsp/core/src/main/groovy/org/grails/gsp/io/GroovyPageLocator.groovy
@@ -16,11 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.grails.gsp.io;
+package org.grails.gsp.io
-import org.springframework.core.io.ResourceLoader;
+import org.springframework.core.io.ResourceLoader
-import org.grails.taglib.TemplateVariableBinding;
+import org.grails.taglib.TemplateVariableBinding
/**
* Used to locate GSPs whether in development or WAR deployed mode.
@@ -28,14 +28,14 @@
* @author Graeme Rocher
* @since 2.0
*/
-public interface GroovyPageLocator {
+interface GroovyPageLocator {
/**
* Adds a new resource loader to search
*
* @param resourceLoader The resource loader to search
*/
- void addResourceLoader(ResourceLoader resourceLoader);
+ void addResourceLoader(ResourceLoader resourceLoader)
/**
* Finds a page for the given URI
@@ -43,7 +43,7 @@ public interface GroovyPageLocator {
* @param uri The URI
* @return A script source
*/
- GroovyPageScriptSource findPage(String uri);
+ GroovyPageScriptSource findPage(String uri)
/**
* Finds a page for the given URI
@@ -53,7 +53,7 @@ public interface GroovyPageLocator {
* @param binding The biding to use
* @return A script source
*/
- GroovyPageScriptSource findPageInBinding(String pluginName, String uri, TemplateVariableBinding binding);
+ GroovyPageScriptSource findPageInBinding(String pluginName, String uri, TemplateVariableBinding binding)
/**
* Finds a page for the URI and binding
@@ -62,12 +62,13 @@ public interface GroovyPageLocator {
* @param binding The binding
* @return The page source
*/
- GroovyPageScriptSource findPageInBinding(String uri, TemplateVariableBinding binding);
+ GroovyPageScriptSource findPageInBinding(String uri, TemplateVariableBinding binding)
/**
* Removes any precompiled pages for the given URI so that they can be replaced by dynamic pages
*
* @param compiledScriptSource The compiled script source
*/
- void removePrecompiledPage(GroovyPageCompiledScriptSource compiledScriptSource);
+ void removePrecompiledPage(GroovyPageCompiledScriptSource compiledScriptSource)
+
}
diff --git a/grails-gsp/core/src/main/groovy/org/grails/gsp/io/GroovyPageResourceScriptSource.java b/grails-gsp/core/src/main/groovy/org/grails/gsp/io/GroovyPageResourceScriptSource.groovy
similarity index 63%
rename from grails-gsp/core/src/main/groovy/org/grails/gsp/io/GroovyPageResourceScriptSource.java
rename to grails-gsp/core/src/main/groovy/org/grails/gsp/io/GroovyPageResourceScriptSource.groovy
index c0a0ffbcb2e..c5995a59fa6 100644
--- a/grails-gsp/core/src/main/groovy/org/grails/gsp/io/GroovyPageResourceScriptSource.java
+++ b/grails-gsp/core/src/main/groovy/org/grails/gsp/io/GroovyPageResourceScriptSource.groovy
@@ -16,20 +16,19 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.grails.gsp.io;
+package org.grails.gsp.io
-import java.io.IOException;
-import java.net.URL;
+import groovy.transform.CompileStatic
+import org.springframework.core.io.Resource
+import org.springframework.scripting.support.ResourceScriptSource
-import org.springframework.core.io.Resource;
-import org.springframework.scripting.support.ResourceScriptSource;
+import org.grails.io.support.GrailsResourceUtils
-import org.grails.io.support.GrailsResourceUtils;
+@CompileStatic
+class GroovyPageResourceScriptSource extends ResourceScriptSource implements GroovyPageScriptSource {
-public class GroovyPageResourceScriptSource extends ResourceScriptSource implements GroovyPageScriptSource {
-
- private String uri;
- private boolean isPublic;
+ private String uri
+ private boolean isPublic
/**
* Create a new ResourceScriptSource for the given resource.
@@ -37,28 +36,28 @@ public class GroovyPageResourceScriptSource extends ResourceScriptSource impleme
* @param uri The URI of the resource
* @param resource the Resource to load the script from
*/
- public GroovyPageResourceScriptSource(String uri, Resource resource) {
- super(resource);
- this.uri = uri;
+ GroovyPageResourceScriptSource(String uri, Resource resource) {
+ super(resource)
+ this.uri = uri
try {
- URL u = getResource().getURL();
+ URL u = getResource().getURL()
if (u == null) {
- isPublic = isPublicPath(uri);
+ isPublic = isPublicPath(uri)
}
else {
- isPublic = isPublicPath(u.getPath());
+ isPublic = isPublicPath(u.getPath())
}
} catch (IOException e) {
- isPublic = isPublicPath(uri);
+ isPublic = isPublicPath(uri)
}
}
- public static boolean isPublicPath(String path) {
- return !(path.contains(GrailsResourceUtils.WEB_INF) || path.contains(GrailsResourceUtils.VIEWS_DIR_PATH));
+ static boolean isPublicPath(String path) {
+ return !(path.contains(GrailsResourceUtils.WEB_INF) || path.contains(GrailsResourceUtils.VIEWS_DIR_PATH))
}
- public String getURI() {
- return uri;
+ String getURI() {
+ return uri
}
/**
@@ -66,7 +65,8 @@ public String getURI() {
*
* @return true if it can be rendered publicly
*/
- public boolean isPublic() {
- return isPublic;
+ boolean isPublic() {
+ return isPublic
}
+
}
diff --git a/grails-gsp/core/src/main/groovy/org/grails/gsp/io/GroovyPageScriptSource.java b/grails-gsp/core/src/main/groovy/org/grails/gsp/io/GroovyPageScriptSource.groovy
similarity index 85%
rename from grails-gsp/core/src/main/groovy/org/grails/gsp/io/GroovyPageScriptSource.java
rename to grails-gsp/core/src/main/groovy/org/grails/gsp/io/GroovyPageScriptSource.groovy
index a48b5a94d1f..b8358d39b64 100644
--- a/grails-gsp/core/src/main/groovy/org/grails/gsp/io/GroovyPageScriptSource.java
+++ b/grails-gsp/core/src/main/groovy/org/grails/gsp/io/GroovyPageScriptSource.groovy
@@ -16,25 +16,26 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.grails.gsp.io;
+package org.grails.gsp.io
-import org.springframework.scripting.ScriptSource;
+import org.springframework.scripting.ScriptSource
/**
* @author Graeme Rocher
* @since 2.0
*/
-public interface GroovyPageScriptSource extends ScriptSource {
+interface GroovyPageScriptSource extends ScriptSource {
/**
* @return The URI of the Groovy page
*/
- String getURI();
+ String getURI()
/**
* Whether the GSP is publicly accessible directly, or only usable using internal rendering
*
* @return true if it can be rendered publicly
*/
- boolean isPublic();
+ boolean isPublic()
+
}
diff --git a/grails-gsp/core/src/main/groovy/org/grails/gsp/io/GroovyPageStaticResourceLocator.java b/grails-gsp/core/src/main/groovy/org/grails/gsp/io/GroovyPageStaticResourceLocator.groovy
similarity index 67%
rename from grails-gsp/core/src/main/groovy/org/grails/gsp/io/GroovyPageStaticResourceLocator.java
rename to grails-gsp/core/src/main/groovy/org/grails/gsp/io/GroovyPageStaticResourceLocator.groovy
index dcec8c5f242..748837339bb 100644
--- a/grails-gsp/core/src/main/groovy/org/grails/gsp/io/GroovyPageStaticResourceLocator.java
+++ b/grails-gsp/core/src/main/groovy/org/grails/gsp/io/GroovyPageStaticResourceLocator.groovy
@@ -16,17 +16,18 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.grails.gsp.io;
+package org.grails.gsp.io
-import org.springframework.core.io.Resource;
+import groovy.transform.CompileStatic
+import org.springframework.core.io.Resource
-import grails.plugins.GrailsPlugin;
-import org.grails.core.io.DefaultResourceLocator;
-import org.grails.gsp.GroovyPageBinding;
-import org.grails.io.support.GrailsResourceUtils;
-import org.grails.taglib.AbstractTemplateVariableBinding;
-import org.grails.taglib.encoder.OutputContext;
-import org.grails.taglib.encoder.OutputContextLookupHelper;
+import grails.plugins.GrailsPlugin
+import org.grails.core.io.DefaultResourceLocator
+import org.grails.gsp.GroovyPageBinding
+import org.grails.io.support.GrailsResourceUtils
+import org.grails.taglib.AbstractTemplateVariableBinding
+import org.grails.taglib.encoder.OutputContext
+import org.grails.taglib.encoder.OutputContextLookupHelper
/**
*
@@ -38,45 +39,46 @@
* @author Graeme Rocher
* @since 2.0
*/
-public class GroovyPageStaticResourceLocator extends DefaultResourceLocator {
+@CompileStatic
+class GroovyPageStaticResourceLocator extends DefaultResourceLocator {
@Override
- public Resource findResourceForURI(String uri) {
- Resource resource = super.findResourceForURI(uri);
+ Resource findResourceForURI(String uri) {
+ Resource resource = super.findResourceForURI(uri)
if (resource == null || !resource.exists()) {
- AbstractTemplateVariableBinding binding = findBindingInOutputContext();
+ AbstractTemplateVariableBinding binding = findBindingInOutputContext()
if (binding instanceof GroovyPageBinding) {
- GrailsPlugin pagePlugin = ((GroovyPageBinding) binding).getPagePlugin();
+ GrailsPlugin pagePlugin = ((GroovyPageBinding) binding).getPagePlugin()
if (pagePlugin != null && pluginManager != null) {
- resource = findResourceForPlugin(pagePlugin, uri);
+ resource = findResourceForPlugin(pagePlugin, uri)
}
}
else if (pluginManager != null) {
// attempt brute force search of all plugins
- for (GrailsPlugin plugin : pluginManager.getAllPlugins()) {
- resource = findResourceForPlugin(plugin, uri);
- if (resource != null) break;
+ for (GrailsPlugin plugin in pluginManager.getAllPlugins()) {
+ resource = findResourceForPlugin(plugin, uri)
+ if (resource != null) break
}
}
}
- return resource;
+ return resource
}
private Resource findResourceForPlugin(GrailsPlugin plugin, String uri) {
- Resource resource;
- String pluginPath = pluginManager.getPluginPath(plugin.getName());
- String pluginUri = GrailsResourceUtils.appendPiecesForUri(pluginPath, uri);
- resource = super.findResourceForURI(pluginUri);
- return resource;
+ Resource resource
+ String pluginPath = pluginManager.getPluginPath(plugin.getName())
+ String pluginUri = GrailsResourceUtils.appendPiecesForUri(pluginPath, uri)
+ resource = super.findResourceForURI(pluginUri)
+ return resource
}
protected AbstractTemplateVariableBinding findBindingInOutputContext() {
- OutputContext outputContext = OutputContextLookupHelper.lookupOutputContext();
+ OutputContext outputContext = OutputContextLookupHelper.lookupOutputContext()
if (outputContext != null) {
- return outputContext.getBinding();
+ return outputContext.getBinding()
}
- return null;
+ return null
}
}
diff --git a/grails-gsp/core/src/main/groovy/org/grails/gsp/jsp/JspTag.java b/grails-gsp/core/src/main/groovy/org/grails/gsp/jsp/JspTag.groovy
similarity index 87%
rename from grails-gsp/core/src/main/groovy/org/grails/gsp/jsp/JspTag.java
rename to grails-gsp/core/src/main/groovy/org/grails/gsp/jsp/JspTag.groovy
index 827dd1b7698..ee1e3c93b82 100644
--- a/grails-gsp/core/src/main/groovy/org/grails/gsp/jsp/JspTag.java
+++ b/grails-gsp/core/src/main/groovy/org/grails/gsp/jsp/JspTag.groovy
@@ -16,17 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.grails.gsp.jsp;
-
-import java.io.Writer;
-import java.util.Map;
-
-import groovy.lang.Closure;
+package org.grails.gsp.jsp
/**
* An interface that represents a JSP tag that can be invoked by Grails
*/
-public interface JspTag {
+interface JspTag {
/**
* Main method to invoke a tag library and output to the target write
@@ -34,7 +29,7 @@ public interface JspTag {
* @param targetWriter The writer the tag should write to
* @param attributes The tag attributes
*/
- void doTag(Writer targetWriter, Map attributes);
+ void doTag(Writer targetWriter, Map attributes)
/**
* Invokes a tag with a closure representing the body of the tag
@@ -42,20 +37,21 @@ public interface JspTag {
* @param attributes The tag attributes
* @param body The body of the tag
*/
- void doTag(Writer targetWriter, Map attributes, Closure> body);
+ void doTag(Writer targetWriter, Map attributes, Closure> body)
/**
* @return Return true if the tag class implements the TryCatchFinally interface
*/
- boolean isTryCatchFinallyTag();
+ boolean isTryCatchFinallyTag()
/**
* @return Return true if the tag class implements the IterationTag interface
*/
- boolean isIterationTag();
+ boolean isIterationTag()
/**
* @return Return true if the tag class implements the BodyTag interface
*/
- boolean isBodyTag();
+ boolean isBodyTag()
+
}
diff --git a/grails-gsp/core/src/main/groovy/org/grails/gsp/jsp/JspTagLib.java b/grails-gsp/core/src/main/groovy/org/grails/gsp/jsp/JspTagLib.groovy
similarity index 91%
rename from grails-gsp/core/src/main/groovy/org/grails/gsp/jsp/JspTagLib.java
rename to grails-gsp/core/src/main/groovy/org/grails/gsp/jsp/JspTagLib.groovy
index 06fb2d309d0..b8655dbe323 100644
--- a/grails-gsp/core/src/main/groovy/org/grails/gsp/jsp/JspTagLib.java
+++ b/grails-gsp/core/src/main/groovy/org/grails/gsp/jsp/JspTagLib.groovy
@@ -16,19 +16,19 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.grails.gsp.jsp;
+package org.grails.gsp.jsp
/**
* An interface that represents a Jsp taglib
*
* @author Graeme Rocher
*/
-public interface JspTagLib {
+interface JspTagLib {
/**
* @return The URI of the tag library
*/
- String getURI();
+ String getURI()
/**
* Obtains a reference to a JspTag instance contained within the library
@@ -36,6 +36,6 @@ public interface JspTagLib {
* @param name The name of the tag
* @return A JspTag instance or null if it doesn't exist
*/
- JspTag getTag(String name);
+ JspTag getTag(String name)
}
diff --git a/grails-gsp/core/src/main/groovy/org/grails/gsp/jsp/TagLibraryResolver.java b/grails-gsp/core/src/main/groovy/org/grails/gsp/jsp/TagLibraryResolver.groovy
similarity index 88%
rename from grails-gsp/core/src/main/groovy/org/grails/gsp/jsp/TagLibraryResolver.java
rename to grails-gsp/core/src/main/groovy/org/grails/gsp/jsp/TagLibraryResolver.groovy
index f4c923fc99b..e6b2880f07f 100644
--- a/grails-gsp/core/src/main/groovy/org/grails/gsp/jsp/TagLibraryResolver.java
+++ b/grails-gsp/core/src/main/groovy/org/grails/gsp/jsp/TagLibraryResolver.groovy
@@ -17,10 +17,10 @@
* under the License.
*/
-package org.grails.gsp.jsp;
+package org.grails.gsp.jsp
-public interface TagLibraryResolver {
+interface TagLibraryResolver {
- JspTagLib resolveTagLibrary(String uri);
+ JspTagLib resolveTagLibrary(String uri)
}