aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/lombok/core/configuration/ConfigurationApp.java69
-rw-r--r--src/core/lombok/core/configuration/ConfigurationFile.java5
-rw-r--r--test/configuration/resource/configurationRoot/d1/d11/d111/import1.config5
-rw-r--r--test/configuration/resource/configurationRoot/d1/d11/d111/lombok.config1
-rw-r--r--test/configuration/resource/configurationRoot/err.txt2
-rw-r--r--test/configuration/resource/configurationRoot/out.txt48
6 files changed, 74 insertions, 56 deletions
diff --git a/src/core/lombok/core/configuration/ConfigurationApp.java b/src/core/lombok/core/configuration/ConfigurationApp.java
index 46711178..0b9ba078 100644
--- a/src/core/lombok/core/configuration/ConfigurationApp.java
+++ b/src/core/lombok/core/configuration/ConfigurationApp.java
@@ -25,11 +25,13 @@ import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.net.URI;
+import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
+import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -221,8 +223,8 @@ public class ConfigurationApp extends LombokApp {
}
if (!problems.isEmpty()) {
- out.printf("%nProblems in the configuration files: %n");
- for (String problem : problems) out.printf("- %s%n", problem);
+ err.printf("Problems in the configuration files:%n");
+ for (String problem : problems) err.printf("- %s%n", problem);
}
return 0;
@@ -253,33 +255,42 @@ public class ConfigurationApp extends LombokApp {
Set<ConfigurationKey<?>> used = new HashSet<ConfigurationKey<?>>();
boolean stopBubbling = false;
- String previousDescription = null;
- for (File currentDirectory = new File(directory); currentDirectory != null && !stopBubbling; currentDirectory = currentDirectory.getParentFile()) {
- ConfigurationFile context = ConfigurationFile.forDirectory(currentDirectory);
+ Collection<ConfigurationFile> visited = new HashSet<ConfigurationFile>();
+ for (ConfigurationFile context = ConfigurationFile.forDirectory(new File(directory)); context != null && !stopBubbling; context = context.parent()) {
if (!context.exists()) continue;
- Map<ConfigurationKey<?>, List<String>> traces = trace(context, keys);
+ Deque<Source> round = new ArrayDeque<Source>();
+ round.push(new Source(context, context.description()));
- stopBubbling = stopBubbling(traces.get(ConfigurationKeys.STOP_BUBBLING));
- for (ConfigurationKey<?> key : keys) {
- List<String> modifications = traces.get(key);
- if (modifications == null) {
- modifications = new ArrayList<String>();
- modifications.add(" <'" + key.getKeyName() + "' not mentioned>");
- } else {
- used.add(key);
- }
- if (previousDescription != null) {
- modifications.add("");
- modifications.add(previousDescription + ":");
+ while (!round.isEmpty()) {
+ Source current = round.pop();
+ if (current == null || !visited.add(current.file) || !current.file.exists()) continue;
+
+ Map<ConfigurationKey<?>, List<String>> traces = trace(current.file, keys, round);
+
+ stopBubbling = stopBubbling(traces.get(ConfigurationKeys.STOP_BUBBLING));
+ for (ConfigurationKey<?> key : keys) {
+ List<String> modifications = traces.get(key);
+ if (modifications == null) {
+ modifications = new ArrayList<String>();
+ modifications.add(" <'" + key.getKeyName() + "' not mentioned>");
+ } else {
+ used.add(key);
+ }
+ modifications.add(0, current.description + ":");
+ modifications.add(0, "");
+ result.get(key).addAll(0, modifications);
}
- result.get(key).addAll(0, modifications);
}
- previousDescription = context.description();
}
for (ConfigurationKey<?> key : keys) {
if (used.contains(key)) {
- result.get(key).add(0, previousDescription + (stopBubbling ? " (stopped bubbling):" : ":"));
+ List<String> modifications = result.get(key);
+ modifications.remove(0);
+ if (stopBubbling) {
+ String mostRecent = modifications.get(0);
+ modifications.set(0, mostRecent.substring(0, mostRecent.length() - 1) + " (stopped bubbling):");
+ }
} else {
result.put(key, Collections.<String>emptyList());
}
@@ -287,12 +298,22 @@ public class ConfigurationApp extends LombokApp {
return result;
}
- private Map<ConfigurationKey<?>, List<String>> trace(ConfigurationFile context, final Collection<ConfigurationKey<?>> keys) throws IOException {
+ private static final class Source {
+ final ConfigurationFile file;
+ final String description;
+
+ Source(ConfigurationFile file, String description) {
+ this.file = file;
+ this.description = description;
+ }
+ }
+
+ private Map<ConfigurationKey<?>, List<String>> trace(ConfigurationFile context, final Collection<ConfigurationKey<?>> keys, final Deque<Source> round) throws IOException {
final Map<ConfigurationKey<?>, List<String>> result = new HashMap<ConfigurationKey<?>, List<String>>();
Collector collector = new Collector() {
@Override public void addImport(ConfigurationFile importFile, ConfigurationFile context, int lineNumber) {
- // nothing to display here
+ round.push(new Source(importFile, importFile.description() + " (imported from " + context.description() + ":" + lineNumber + ")"));
}
@Override public void clear(ConfigurationKey<?> key, ConfigurationFile context, int lineNumber) {
trace(key, "clear " + key.getKeyName(), lineNumber);
@@ -311,7 +332,7 @@ public class ConfigurationApp extends LombokApp {
}
private void trace(ConfigurationKey<?> key, String message, int lineNumber) {
- if (!keys.contains(key)) return;
+ if (!keys.contains(key) && key != ConfigurationKeys.STOP_BUBBLING) return;
List<String> traces = result.get(key);
if (traces == null) {
traces = new ArrayList<String>();
diff --git a/src/core/lombok/core/configuration/ConfigurationFile.java b/src/core/lombok/core/configuration/ConfigurationFile.java
index 021c3c97..218fa73b 100644
--- a/src/core/lombok/core/configuration/ConfigurationFile.java
+++ b/src/core/lombok/core/configuration/ConfigurationFile.java
@@ -35,14 +35,13 @@ public abstract class ConfigurationFile {
return new byte[65536];
}
};
-
+
private final String identifier;
public static ConfigurationFile forFile(File file) {
return new RegularConfigurationFile(file);
}
-
public static ConfigurationFile forDirectory(File directory) {
return ConfigurationFile.forFile(new File(directory, LOMBOK_CONFIG_FILENAME));
}
@@ -82,7 +81,7 @@ public abstract class ConfigurationFile {
private static boolean fileExists(File file) {
return file.exists() && file.isFile();
}
-
+
private static String read(InputStream is) throws IOException {
byte[] b = buffers.get();
try {
diff --git a/test/configuration/resource/configurationRoot/d1/d11/d111/import1.config b/test/configuration/resource/configurationRoot/d1/d11/d111/import1.config
new file mode 100644
index 00000000..2a38bda5
--- /dev/null
+++ b/test/configuration/resource/configurationRoot/d1/d11/d111/import1.config
@@ -0,0 +1,5 @@
+import missing
+import import1.config
+import ../d111/import1.config
+lombok.accessors.prefix += z_
+lombok.accessors.prefix += f \ No newline at end of file
diff --git a/test/configuration/resource/configurationRoot/d1/d11/d111/lombok.config b/test/configuration/resource/configurationRoot/d1/d11/d111/lombok.config
index abf7eea0..fefcea42 100644
--- a/test/configuration/resource/configurationRoot/d1/d11/d111/lombok.config
+++ b/test/configuration/resource/configurationRoot/d1/d11/d111/lombok.config
@@ -1,2 +1,3 @@
+import import1.config
clear lombok.accessors.chain
lombok.accessors.prefix += m_ \ No newline at end of file
diff --git a/test/configuration/resource/configurationRoot/err.txt b/test/configuration/resource/configurationRoot/err.txt
index e69de29b..a9b3f8af 100644
--- a/test/configuration/resource/configurationRoot/err.txt
+++ b/test/configuration/resource/configurationRoot/err.txt
@@ -0,0 +1,2 @@
+Problems in the configuration files:
+- Imported file does not exist: import missing (BASE/d1/d11/d111/import1.config:1) \ No newline at end of file
diff --git a/test/configuration/resource/configurationRoot/out.txt b/test/configuration/resource/configurationRoot/out.txt
index 8100fadb..8cdd9bca 100644
--- a/test/configuration/resource/configurationRoot/out.txt
+++ b/test/configuration/resource/configurationRoot/out.txt
@@ -2,26 +2,17 @@ Configuration for 'BASE/d1/d11'.
# Emit a warning or error if @Accessors is used.
lombok.accessors.flagUsage = ERROR
-# BASE/d1/lombok.config:
-# <'lombok.accessors.flagUsage' not mentioned>
-#
-# BASE/d1/d11/lombok.config:
+# BASE/d1/d11/lombok.config (stopped bubbling):
# 4: lombok.accessors.flagUsage = ERROR
# Generate setters that return 'this' instead of 'void' (default: false).
lombok.accessors.chain = false
-# BASE/d1/lombok.config:
-# <'lombok.accessors.chain' not mentioned>
-#
-# BASE/d1/d11/lombok.config:
+# BASE/d1/d11/lombok.config (stopped bubbling):
# 3: lombok.accessors.chain = false
# Strip this field prefix, like 'f' or 'm_', from the names of generated getters and setters.
lombok.accessors.prefix += f
-# BASE/d1/lombok.config:
-# <'lombok.accessors.prefix' not mentioned>
-#
-# BASE/d1/d11/lombok.config:
+# BASE/d1/d11/lombok.config (stopped bubbling):
# 5: lombok.accessors.prefix += f
# Use this name for the generated logger fields (default: 'log').
@@ -34,37 +25,39 @@ Configuration for:
# Emit a warning or error if @Accessors is used.
lombok.accessors.flagUsage = ERROR
-# BASE/d1/lombok.config:
-# <'lombok.accessors.flagUsage' not mentioned>
-#
-# BASE/d1/d11/lombok.config:
+# BASE/d1/d11/lombok.config (stopped bubbling):
# 4: lombok.accessors.flagUsage = ERROR
#
+# BASE/d1/d11/d111/import1.config (imported from BASE/d1/d11/d111/lombok.config:1):
+# <'lombok.accessors.flagUsage' not mentioned>
+#
# BASE/d1/d11/d111/lombok.config:
# <'lombok.accessors.flagUsage' not mentioned>
# Generate setters that return 'this' instead of 'void' (default: false).
clear lombok.accessors.chain
-# BASE/d1/lombok.config:
-# <'lombok.accessors.chain' not mentioned>
-#
-# BASE/d1/d11/lombok.config:
+# BASE/d1/d11/lombok.config (stopped bubbling):
# 3: lombok.accessors.chain = false
#
+# BASE/d1/d11/d111/import1.config (imported from BASE/d1/d11/d111/lombok.config:1):
+# <'lombok.accessors.chain' not mentioned>
+#
# BASE/d1/d11/d111/lombok.config:
-# 1: clear lombok.accessors.chain
+# 2: clear lombok.accessors.chain
# Strip this field prefix, like 'f' or 'm_', from the names of generated getters and setters.
+lombok.accessors.prefix += z_
lombok.accessors.prefix += f
lombok.accessors.prefix += m_
-# BASE/d1/lombok.config:
-# <'lombok.accessors.prefix' not mentioned>
+# BASE/d1/d11/lombok.config (stopped bubbling):
+# 5: lombok.accessors.prefix += f
#
-# BASE/d1/d11/lombok.config:
+# BASE/d1/d11/d111/import1.config (imported from BASE/d1/d11/d111/lombok.config:1):
+# 4: lombok.accessors.prefix += z_
# 5: lombok.accessors.prefix += f
#
# BASE/d1/d11/d111/lombok.config:
-# 2: lombok.accessors.prefix += m_
+# 3: lombok.accessors.prefix += m_
# Use this name for the generated logger fields (default: 'log').
clear lombok.log.fieldName
@@ -77,10 +70,7 @@ clear lombok.accessors.flagUsage
# Generate setters that return 'this' instead of 'void' (default: false).
lombok.accessors.chain = true
-# BASE/d1/lombok.config:
-# <'lombok.accessors.chain' not mentioned>
-#
-# BASE/d1/d12/lombok.config:
+# BASE/d1/d12/lombok.config (stopped bubbling):
# 3: lombok.accessors.chain = true
# Strip this field prefix, like 'f' or 'm_', from the names of generated getters and setters.