Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

whitespace, cleanup

  • Loading branch information...
commit 4fd2ac3933b6a4abb8c579fbe113f688dd22c0b1 1 parent 2d24645
@burtbeckwith burtbeckwith authored
View
55 grails-bootstrap/src/main/groovy/grails/build/logging/GrailsConsole.java
@@ -57,7 +57,6 @@
public static final String CATEGORY_SEPARATOR = "|";
public static final String PROMPT = "grails> ";
public static final String SPACE = " ";
- private static final String ERROR_REGEX = ".*?(ERROR|FATAL).*?";
private StringBuilder maxIndicatorString;
private int cursorMove;
@@ -117,7 +116,7 @@ protected GrailsConsole() throws IOException {
if (isWindows()) {
terminal = new WindowsTerminal() {
@Override
- public boolean isANSISupported() {
+ public boolean isANSISupported() {
return true;
}
};
@@ -168,7 +167,7 @@ public void setAnsiEnabled(boolean ansiEnabled) {
* @param verbose Sets whether verbose output should be used
*/
public void setVerbose(boolean verbose) {
- if(verbose) {
+ if (verbose) {
// enable big traces in verbose mode
System.setProperty("grails.full.stacktrace", "true");
}
@@ -223,14 +222,14 @@ public void indicateProgress() {
progressIndicatorActive = true;
if (isAnsiEnabled()) {
if (StringUtils.hasText(lastMessage)) {
- if (!lastMessage.contains(maxIndicatorString))
+ if (!lastMessage.contains(maxIndicatorString)) {
updateStatus(lastMessage + indicator);
+ }
}
}
else {
out.print(indicator);
}
-
}
/**
@@ -304,7 +303,7 @@ public void updateStatus(String msg) {
}
private void outputMessage(String msg, int replaceCount) {
- if(msg == null || msg.trim().length() == 0) return;
+ if (msg == null || msg.trim().length() == 0) return;
try {
if (hasNewLines(msg)) {
printMessageOnNewLine(msg);
@@ -318,13 +317,14 @@ private void outputMessage(String msg, int replaceCount) {
out.println(lastStatus);
cursorMove = replaceCount;
} else {
- if(lastMessage != null && lastMessage.equals(msg)) return;
+ if (lastMessage != null && lastMessage.equals(msg)) return;
- if(progressIndicatorActive) {
+ if (progressIndicatorActive) {
out.println();
}
- out.println(CATEGORY_SEPARATOR + msg);
+ out.print(CATEGORY_SEPARATOR);
+ out.println(msg);
}
lastMessage = msg;
}
@@ -334,20 +334,22 @@ private void outputMessage(String msg, int replaceCount) {
}
private void postPrintMessage() {
- if(!progressIndicatorActive) {
+ if (!progressIndicatorActive) {
replayPromptIfActive();
}
progressIndicatorActive = false;
}
private void replayPromptIfActive() {
- if(userInputActive) {
- if(isAnsiEnabled()) {
- out.println(ansiPrompt(PROMPT));
- }
- else {
- out.println(PROMPT);
- }
+ if (!userInputActive) {
+ return;
+ }
+
+ if (isAnsiEnabled()) {
+ out.println(ansiPrompt(PROMPT));
+ }
+ else {
+ out.println(PROMPT);
}
}
@@ -370,14 +372,14 @@ public void error(String msg) {
cursorMove = 0;
if (isAnsiEnabled()) {
Ansi ansi;
- if(msg.contains("ERROR") || msg.contains("FATAL")) {
+ if (msg.contains("ERROR") || msg.contains("FATAL")) {
ansi = outputErrorLabel(ansi(), "Error").a(msg).reset();
}
else {
ansi = outputErrorLabel(ansi(), "").a(msg).reset();
}
- if(msg.endsWith(LINE_SEPARATOR)) {
+ if (msg.endsWith(LINE_SEPARATOR)) {
out.print(ansi);
}
else {
@@ -390,12 +392,12 @@ public void error(String msg) {
} finally {
postPrintMessage();
}
-
}
private void logSimpleError(String msg) {
- if(progressIndicatorActive)
+ if (progressIndicatorActive) {
out.println();
+ }
out.println(CATEGORY_SEPARATOR);
out.println(msg);
}
@@ -453,7 +455,7 @@ private void printStackTrace(String message, Throwable error) {
*/
public void log(String msg) {
try {
- if(msg.endsWith(LINE_SEPARATOR)) {
+ if (msg.endsWith(LINE_SEPARATOR)) {
out.print(msg);
}
else {
@@ -504,12 +506,10 @@ private String showPrompt() {
cursorMove = 0;
userInputActive = true;
try {
- if(isAnsiEnabled()) {
+ if (isAnsiEnabled()) {
return reader.readLine(ansiPrompt(PROMPT).toString());
}
- else {
- return reader.readLine(PROMPT);
- }
+ return reader.readLine(PROMPT);
} finally {
userInputActive = false;
}
@@ -593,7 +593,6 @@ private Ansi outputErrorLabel(Ansi ansi, String label) {
.fg(Color.DEFAULT);
}
-
private Ansi erasePreviousLine(String categoryName) {
if (cursorMove > 0) {
return ansi()
@@ -608,7 +607,7 @@ private Ansi erasePreviousLine(String categoryName) {
public void error(String label, String message) {
cursorMove = 0;
try {
- if(isAnsiEnabled()) {
+ if (isAnsiEnabled()) {
out.println(outputErrorLabel(ansi(), label).a(message));
}
else {
View
30 grails-core/src/main/groovy/grails/persistence/Event.java
@@ -1,25 +1,25 @@
/*
-* Copyright 2004-2005 the original author or authors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Copyright 2004-2005 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package grails.persistence;
import java.util.ArrayList;
import java.util.List;
/**
- * Enum of the available events that Grails triggers
+ * Enum of the available events that Grails triggers.
*
* @author Graeme Rocher
* @since 1.2
View
30 grails-core/src/main/groovy/org/codehaus/groovy/grails/compiler/DirectoryWatcher.java
@@ -86,30 +86,30 @@ public void addWatchFile(File fileToWatch) {
}
/**
- * Adds a directory to watch for the given file and extensions
+ * Adds a directory to watch for the given file and extensions.
*
* @param dir The directory
- * @param extensions The extensions
+ * @param fileExtensions The extensions
*/
- public void addWatchDirectory(File dir, List<String> extensions) {
- cacheFilesForDirectory(dir, extensions, false);
+ public void addWatchDirectory(File dir, List<String> fileExtensions) {
+ cacheFilesForDirectory(dir, fileExtensions, false);
}
/**
- * Adds a directory to watch for the given file and extensions
+ * Adds a directory to watch for the given file and extensions.
*
* @param dir The directory
* @param extension The extension
*/
public void addWatchDirectory(File dir, String extension) {
- List<String> extensions = new ArrayList<String>();
+ List<String> fileExtensions = new ArrayList<String>();
if (extension == null) {
- extensions.add("*");
+ fileExtensions.add("*");
}
else {
- extensions.add(extension);
+ fileExtensions.add(extension);
}
- cacheFilesForDirectory(dir, extensions, false);
+ cacheFilesForDirectory(dir, fileExtensions, false);
}
/**
@@ -173,8 +173,8 @@ private void checkForNewFiles() {
}
}
- private void cacheFilesForDirectory(File directory, Collection<String> extensions, boolean fireEvent) {
- addExtensions(extensions);
+ private void cacheFilesForDirectory(File directory, Collection<String> fileExtensions, boolean fireEvent) {
+ addExtensions(fileExtensions);
directoryWatch.put(directory, directory.lastModified());
File[] files = directory.listFiles();
@@ -184,9 +184,9 @@ private void cacheFilesForDirectory(File directory, Collection<String> extension
for (File file : files) {
if (file.isDirectory()) {
- cacheFilesForDirectory(file, extensions, fireEvent);
+ cacheFilesForDirectory(file, fileExtensions, fireEvent);
}
- else if (isValidFileToMonitor(file.getName(), extensions)) {
+ else if (isValidFileToMonitor(file.getName(), fileExtensions)) {
if (!lastModifiedMap.containsKey(file) && fireEvent) {
for (FileChangeListener listener : listeners) {
listener.onNew(file);
@@ -205,7 +205,7 @@ private void addExtensions(Collection<String> toAdd) {
}
}
- private boolean isValidFileToMonitor(String name, Collection<String> extensions) {
- return extensions.contains("*") || extensions.contains(StringUtils.getFilenameExtension(name));
+ private boolean isValidFileToMonitor(String name, Collection<String> fileExtensions) {
+ return fileExtensions.contains("*") || fileExtensions.contains(StringUtils.getFilenameExtension(name));
}
}
View
11 scripts/Shell.groovy
@@ -22,9 +22,10 @@
* @since 0.4
*/
-import org.codehaus.groovy.grails.support.*
-import org.codehaus.groovy.tools.shell.*
-import org.codehaus.groovy.grails.cli.logging.*
+import org.codehaus.groovy.grails.compiler.GrailsProjectWatcher
+import org.codehaus.groovy.grails.support.PersistenceContextInterceptor
+import org.codehaus.groovy.tools.shell.Groovysh
+import org.codehaus.groovy.tools.shell.IO
includeTargets << grailsScript("_GrailsBootstrap")
@@ -37,14 +38,14 @@ target(shell:"The shell implementation target") {
loadApp()
configureApp()
+
def b = new Binding(ctx: appCtx, grailsApplication: grailsApp)
def listeners = appCtx.getBeansOfType(PersistenceContextInterceptor)
listeners?.each { key, listener -> listener.init() }
def shell = new Groovysh(classLoader,b, new IO(grailsConsole.input, System.out, System.err))
- def watcher = new org.codehaus.groovy.grails.compiler.GrailsProjectWatcher(projectCompiler, pluginManager)
- watcher.start()
+ new GrailsProjectWatcher(projectCompiler, pluginManager).start()
shell.run([] as String[])
listeners?.each { key, listener ->
View
7 scripts/_GrailsRun.groovy
@@ -22,9 +22,10 @@ import grails.web.container.EmbeddableServerFactory
import java.net.ServerSocket
import org.codehaus.groovy.grails.cli.interactive.InteractiveMode
+import org.codehaus.groovy.grails.compiler.GrailsProjectWatcher
/**
- * Gant script that executes Grails using an embedded server
+ * Gant script that executes Grails using an embedded server.
*
* @author Graeme Rocher
*
@@ -76,7 +77,6 @@ target (runWar : "Main implementation that executes a Grails application WAR") {
runWar(SCHEME_HTTP, serverHost, serverPort, serverPortHttps)
}
-
/**
* Runs the application over HTTPS using the WAR file directly.
*/
@@ -189,8 +189,7 @@ runServer = { Map args ->
* want changes to artifacts automatically detected and loaded.
*/
target(startPluginScanner: "Starts the plugin manager's scanner that detects changes to artifacts.") {
- def watcher = new org.codehaus.groovy.grails.compiler.GrailsProjectWatcher(projectCompiler, pluginManager)
- watcher.start()
+ new GrailsProjectWatcher(projectCompiler, pluginManager).start()
}
target(stopPluginScanner: "Stops the plugin manager's scanner that detects changes to artifacts.") {
Please sign in to comment.
Something went wrong with that request. Please try again.