Skip to content

Commit 80ad81c

Browse files
committed
feedback: styling
1 parent 24db59d commit 80ad81c

File tree

13 files changed

+353
-364
lines changed

13 files changed

+353
-364
lines changed

grails-controllers/src/main/groovy/grails/artefact/controller/support/ResponseRenderer.groovy

Lines changed: 100 additions & 121 deletions
Large diffs are not rendered by default.

grails-gsp/core/src/main/groovy/org/grails/gsp/compiler/GroovyPageParser.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
import grails.io.IOUtils;
2323
import grails.util.Environment;
2424
import grails.util.GrailsStringUtils;
25-
import org.apache.commons.logging.Log;
26-
import org.apache.commons.logging.LogFactory;
25+
import org.slf4j.Logger;
26+
import org.slf4j.LoggerFactory;
2727
import org.codehaus.groovy.runtime.DefaultGroovyMethods;
2828
import org.grails.buffer.FastStringWriter;
2929
import org.grails.buffer.StreamByteBuffer;
@@ -44,7 +44,7 @@
4444

4545
/**
4646
* NOTE: Based on work done by the GSP standalone project (https://gsp.dev.java.net/).
47-
*
47+
* <p>
4848
* Parsing implementation for GSP files
4949
*
5050
* @author Troy Heninger
@@ -53,7 +53,7 @@
5353
*/
5454
public class GroovyPageParser implements Tokens {
5555

56-
public static final Log LOG = LogFactory.getLog(GroovyPageParser.class);
56+
public static final Logger LOG = LoggerFactory.getLogger(GroovyPageParser.class);
5757

5858
private static final Pattern PARA_BREAK = Pattern.compile(
5959
"/p>\\s*<p[^>]*>", Pattern.CASE_INSENSITIVE);
@@ -339,8 +339,7 @@ public InputStream parse() {
339339
new FileOutputStream(keepGeneratedFile),
340340
GROOVY_SOURCE_CHAR_ENCODING);
341341
} catch (IOException e) {
342-
LOG.warn("Cannot open keepgenerated file for writing. File's absolute path is '" +
343-
keepGeneratedFile.getAbsolutePath() + "'");
342+
LOG.warn("Cannot open keepgenerated file for writing. File's absolute path is '{}'", keepGeneratedFile.getAbsolutePath());
344343
keepGeneratedFile = null;
345344
}
346345
streamBuffer.connectTo(keepGeneratedWriter, true);
@@ -357,9 +356,7 @@ public InputStream parse() {
357356

358357
private void resolveKeepGeneratedDirectory() {
359358
if (keepGeneratedDirectory != null && !keepGeneratedDirectory.isDirectory()) {
360-
LOG.warn("The directory specified with " + CONFIG_PROPERTY_GSP_KEEPGENERATED_DIR +
361-
" config parameter doesn't exist or isn't a readable directory. Absolute path: '" +
362-
keepGeneratedDirectory.getAbsolutePath() + "' Keepgenerated will be disabled.");
359+
LOG.warn("The directory specified with {} config parameter doesn't exist or isn't a readable directory. Absolute path: '{}' Keepgenerated will be disabled.", CONFIG_PROPERTY_GSP_KEEPGENERATED_DIR, keepGeneratedDirectory.getAbsolutePath());
363360
keepGeneratedDirectory = null;
364361
}
365362
}
@@ -699,6 +696,7 @@ private void makeName(String uri) {
699696

700697
/**
701698
* find the simple name of this gsp
699+
*
702700
* @param filename the fully qualified file name
703701
*/
704702
private void makeSourceName(String filename) {
@@ -905,6 +903,7 @@ private boolean isModelRecordingModeEnabled() {
905903

906904
/**
907905
* Determines if the line numbers array should be added to the generated Groovy class.
906+
*
908907
* @return true if they should
909908
*/
910909
private boolean shouldAddLineNumbers() {
@@ -943,6 +942,7 @@ private void addLineNumbers() {
943942

944943
/**
945944
* Filters trailing 0s from the line number array
945+
*
946946
* @param lineNumbers the line number array
947947
* @return a new array that removes all 0s from the end of it
948948
*/

grails-gsp/plugin/src/main/groovy/org/grails/plugins/web/GroovyPagesGrailsPlugin.groovy

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,21 @@ import grails.util.GrailsUtil
2828
import grails.util.Metadata
2929
import grails.web.pages.GroovyPagesUriService
3030
import groovy.transform.CompileStatic
31-
import groovy.util.logging.Commons
31+
import groovy.util.logging.Slf4j
3232
import org.grails.core.artefact.gsp.TagLibArtefactHandler
3333
import org.grails.gsp.GroovyPageResourceLoader
3434
import org.grails.gsp.GroovyPagesTemplateEngine
3535
import org.grails.gsp.io.CachingGroovyPageStaticResourceLocator
3636
import org.grails.gsp.jsp.TagLibraryResolverImpl
37-
import org.grails.plugins.web.taglib.*
37+
import org.grails.plugins.web.taglib.ApplicationTagLib
38+
import org.grails.plugins.web.taglib.CountryTagLib
39+
import org.grails.plugins.web.taglib.FormTagLib
40+
import org.grails.plugins.web.taglib.FormatTagLib
41+
import org.grails.plugins.web.taglib.JavascriptTagLib
42+
import org.grails.plugins.web.taglib.PluginTagLib
43+
import org.grails.plugins.web.taglib.RenderTagLib
44+
import org.grails.plugins.web.taglib.UrlMappingTagLib
45+
import org.grails.plugins.web.taglib.ValidationTagLib
3846
import org.grails.spring.RuntimeSpringConfiguration
3947
import org.grails.taglib.TagLibraryLookup
4048
import org.grails.taglib.TagLibraryMetaUtils
@@ -58,7 +66,7 @@ import org.springframework.web.servlet.view.InternalResourceViewResolver
5866
* @author Graeme Rocher
5967
* @since 1.1
6068
*/
61-
@Commons
69+
@Slf4j
6270
class GroovyPagesGrailsPlugin extends Plugin {
6371

6472
public static final String GSP_RELOAD_INTERVAL = "grails.gsp.reload.interval"
@@ -68,7 +76,7 @@ class GroovyPagesGrailsPlugin extends Plugin {
6876
"file:./grails-app/taglib/**/*TagLib.groovy"]
6977

7078
def grailsVersion = "7.0.0-SNAPSHOT > *"
71-
def dependsOn = [core: GrailsUtil.getGrailsVersion(), i18n: GrailsUtil.getGrailsVersion()]
79+
def dependsOn = [core: GrailsUtil.grailsVersion, i18n: GrailsUtil.grailsVersion]
7280
def observe = ['controllers']
7381
def loadAfter = ['filters']
7482

@@ -101,10 +109,10 @@ class GroovyPagesGrailsPlugin extends Plugin {
101109
{ ->
102110
def application = grailsApplication
103111
Config config = application.config
104-
boolean developmentMode = isDevelopmentMode()
112+
boolean developmentMode = developmentMode
105113
Environment env = Environment.current
106114

107-
boolean enableReload = env.isReloadEnabled() ||
115+
boolean enableReload = env.reloadEnabled ||
108116
config.getProperty(GroovyPagesTemplateEngine.CONFIG_PROPERTY_GSP_ENABLE_RELOAD, Boolean, false) ||
109117
(developmentMode && env == Environment.DEVELOPMENT)
110118

@@ -134,7 +142,7 @@ class GroovyPagesGrailsPlugin extends Plugin {
134142
// as oppose to in WAR deployment where views are loaded from /WEB-INF
135143

136144
if (viewsDir) {
137-
log.info "Configuring GSP views directory as '${viewsDir}'"
145+
log.info("Configuring GSP views directory as '${}'", viewsDir)
138146
customResourceLoader = true
139147
groovyPageResourceLoader(GroovyPageResourceLoader) {
140148
baseResource = "file:${viewsDir}"
@@ -158,7 +166,7 @@ class GroovyPagesGrailsPlugin extends Plugin {
158166
}
159167
}
160168

161-
def deployed = !Metadata.getCurrent().isDevelopmentEnvironmentAvailable()
169+
def deployed = !Metadata.current.developmentEnvironmentAvailable
162170
groovyPageLocator(CachingGrailsConventionGroovyPageLocator) { bean ->
163171
bean.lazyInit = true
164172
if (customResourceLoader) {
@@ -187,15 +195,15 @@ class GroovyPagesGrailsPlugin extends Plugin {
187195
}
188196

189197
grailsResourceLocator(CachingGroovyPageStaticResourceLocator) { bean ->
190-
bean.parent = "abstractGrailsResourceLocator"
198+
bean.parent = 'abstractGrailsResourceLocator'
191199
if (enableReload) {
192200
cacheTimeout = gspCacheTimeout
193201
}
194202
}
195203

196204
// Setup the main templateEngine used to render GSPs
197205
groovyPagesTemplateEngine(GroovyPagesTemplateEngine) {
198-
classLoader = ref("classLoader")
206+
classLoader = ref('classLoader')
199207
groovyPageLocator = groovyPageLocator
200208
if (enableReload) {
201209
reloadEnabled = enableReload
@@ -209,7 +217,7 @@ class GroovyPagesGrailsPlugin extends Plugin {
209217

210218
spring.addAlias('groovyTemplateEngine', 'groovyPagesTemplateEngine')
211219

212-
groovyPageRenderer(PageRenderer, ref("groovyPagesTemplateEngine")) { bean ->
220+
groovyPageRenderer(PageRenderer, ref('groovyPagesTemplateEngine')) { bean ->
213221
bean.lazyInit = true
214222
groovyPageLocator = groovyPageLocator
215223
}
@@ -227,7 +235,7 @@ class GroovyPagesGrailsPlugin extends Plugin {
227235
}
228236

229237
boolean jstlPresent = ClassUtils.isPresent(
230-
"jakarta.servlet.jsp.jstl.core.Config", InternalResourceViewResolver.class.getClassLoader())
238+
'jakarta.servlet.jsp.jstl.core.Config', InternalResourceViewResolver.class.classLoader)
231239

232240
abstractViewResolver {
233241
prefix = GrailsApplicationAttributes.PATH_TO_VIEWS
@@ -242,7 +250,7 @@ class GroovyPagesGrailsPlugin extends Plugin {
242250
// Configure a Spring MVC view resolver
243251
jspViewResolver(GroovyPageViewResolver) { bean ->
244252
bean.lazyInit = true
245-
bean.parent = "abstractViewResolver"
253+
bean.parent = 'abstractViewResolver'
246254
}
247255

248256
// Now go through tag libraries and configure them in Spring too. With AOP proxies and so on
@@ -262,9 +270,9 @@ class GroovyPagesGrailsPlugin extends Plugin {
262270
errorsViewStackTracePrinter(ErrorsViewStackTracePrinter, ref('grailsResourceLocator'))
263271
filteringCodecsByContentTypeSettings(FilteringCodecsByContentTypeSettings, application)
264272

265-
groovyPagesServlet(ServletRegistrationBean, new GroovyPagesServlet(), "*.gsp") {
266-
if (Environment.isDevelopmentMode()) {
267-
initParameters = [showSource: "1"]
273+
groovyPagesServlet(ServletRegistrationBean, new GroovyPagesServlet(), '*.gsp') {
274+
if (Environment.developmentMode) {
275+
initParameters = [showSource: '1']
268276
}
269277
}
270278

@@ -273,7 +281,7 @@ class GroovyPagesGrailsPlugin extends Plugin {
273281
}
274282

275283
protected boolean isDevelopmentMode() {
276-
Metadata.getCurrent().isDevelopmentEnvironmentAvailable()
284+
Metadata.current.developmentEnvironmentAvailable
277285
}
278286

279287
static String transformToValidLocation(String location) {
@@ -298,7 +306,7 @@ class GroovyPagesGrailsPlugin extends Plugin {
298306
}
299307
}
300308

301-
// The tag library lookup class caches "tag -> taglib class"
309+
// The tag library lookup class caches 'tag -> taglib class'
302310
// so we need to update it now.
303311
def lookup = applicationContext.getBean('gspTagLibraryLookup', TagLibraryLookup)
304312
lookup.registerTagLib(taglibClass)

grails-gsp/plugin/src/test/groovy/org/grails/web/mapping/RestfulReverseUrlRenderingTests.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ class RestfulReverseUrlRenderingTests extends Specification implements UrlMappin
6262
@Artefact('UrlMappings')
6363
class RestfulReverseUrlMappings {
6464
static mappings = {
65-
"/car" (controller: "restfulCar", action: [GET: "create", POST: "save"])
65+
'/car' (controller: 'restfulCar', action: [GET: 'create', POST: 'save'])
6666
}
6767
}
6868

69-
@Artefact("Controller")
69+
@Artefact('Controller')
7070
class RestfulCarController {
7171
def create = {}
7272
def save = {}

0 commit comments

Comments
 (0)