mirror of
https://github.com/lightbend/config.git
synced 2025-03-22 23:30:27 +08:00
add test conf file and remove unneeded arrayCount
This commit is contained in:
parent
2ea5e21511
commit
2506f745f7
@ -34,11 +34,6 @@ final class ConfigParser {
|
|||||||
final private ConfigOrigin baseOrigin;
|
final private ConfigOrigin baseOrigin;
|
||||||
final private LinkedList<Path> pathStack;
|
final private LinkedList<Path> pathStack;
|
||||||
|
|
||||||
// the number of lists we are inside; this is used to detect the "cannot
|
|
||||||
// generate a reference to a list element" problem, and once we fix that
|
|
||||||
// problem we should be able to get rid of this variable.
|
|
||||||
int arrayCount;
|
|
||||||
|
|
||||||
ParseContext(ConfigSyntax flavor, ConfigOrigin origin, ConfigNodeRoot document,
|
ParseContext(ConfigSyntax flavor, ConfigOrigin origin, ConfigNodeRoot document,
|
||||||
FullIncluder includer, ConfigIncludeContext includeContext) {
|
FullIncluder includer, ConfigIncludeContext includeContext) {
|
||||||
lineNumber = 1;
|
lineNumber = 1;
|
||||||
@ -48,7 +43,6 @@ final class ConfigParser {
|
|||||||
this.includer = includer;
|
this.includer = includer;
|
||||||
this.includeContext = includeContext;
|
this.includeContext = includeContext;
|
||||||
this.pathStack = new LinkedList<Path>();
|
this.pathStack = new LinkedList<Path>();
|
||||||
this.arrayCount = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// merge a bunch of adjacent values into one
|
// merge a bunch of adjacent values into one
|
||||||
@ -95,8 +89,6 @@ final class ConfigParser {
|
|||||||
private AbstractConfigValue parseValue(AbstractConfigNodeValue n, List<String> comments) {
|
private AbstractConfigValue parseValue(AbstractConfigNodeValue n, List<String> comments) {
|
||||||
AbstractConfigValue v;
|
AbstractConfigValue v;
|
||||||
|
|
||||||
int startingArrayCount = arrayCount;
|
|
||||||
|
|
||||||
if (n instanceof ConfigNodeSimpleValue) {
|
if (n instanceof ConfigNodeSimpleValue) {
|
||||||
v = ((ConfigNodeSimpleValue) n).value();
|
v = ((ConfigNodeSimpleValue) n).value();
|
||||||
} else if (n instanceof ConfigNodeObject) {
|
} else if (n instanceof ConfigNodeObject) {
|
||||||
@ -114,9 +106,6 @@ final class ConfigParser {
|
|||||||
comments.clear();
|
comments.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arrayCount != startingArrayCount)
|
|
||||||
throw new ConfigException.BugOrBroken("Bug in config parser: unbalanced array count");
|
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,9 +221,6 @@ final class ConfigParser {
|
|||||||
|
|
||||||
// path must be on-stack while we parse the value
|
// path must be on-stack while we parse the value
|
||||||
pathStack.push(path);
|
pathStack.push(path);
|
||||||
if (((ConfigNodeField) node).separator() == Tokens.PLUS_EQUALS) {
|
|
||||||
arrayCount += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
AbstractConfigNodeValue valueNode;
|
AbstractConfigNodeValue valueNode;
|
||||||
AbstractConfigValue newValue;
|
AbstractConfigValue newValue;
|
||||||
@ -245,7 +231,6 @@ final class ConfigParser {
|
|||||||
newValue = parseValue(valueNode, comments);
|
newValue = parseValue(valueNode, comments);
|
||||||
|
|
||||||
if (((ConfigNodeField) node).separator() == Tokens.PLUS_EQUALS) {
|
if (((ConfigNodeField) node).separator() == Tokens.PLUS_EQUALS) {
|
||||||
arrayCount -= 1;
|
|
||||||
|
|
||||||
List<AbstractConfigValue> concat = new ArrayList<AbstractConfigValue>(2);
|
List<AbstractConfigValue> concat = new ArrayList<AbstractConfigValue>(2);
|
||||||
AbstractConfigValue previousRef = new ConfigReference(newValue.origin(),
|
AbstractConfigValue previousRef = new ConfigReference(newValue.origin(),
|
||||||
@ -326,7 +311,6 @@ final class ConfigParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private SimpleConfigList parseArray(ConfigNodeArray n) {
|
private SimpleConfigList parseArray(ConfigNodeArray n) {
|
||||||
arrayCount += 1;
|
|
||||||
|
|
||||||
SimpleConfigOrigin arrayOrigin = lineOrigin();
|
SimpleConfigOrigin arrayOrigin = lineOrigin();
|
||||||
List<AbstractConfigValue> values = new ArrayList<AbstractConfigValue>();
|
List<AbstractConfigValue> values = new ArrayList<AbstractConfigValue>();
|
||||||
@ -367,7 +351,6 @@ final class ConfigParser {
|
|||||||
if (v != null) {
|
if (v != null) {
|
||||||
values.add(v.withOrigin(v.origin().appendComments(new ArrayList<String>(comments))));
|
values.add(v.withOrigin(v.origin().appendComments(new ArrayList<String>(comments))));
|
||||||
}
|
}
|
||||||
arrayCount -= 1;
|
|
||||||
return new SimpleConfigList(arrayOrigin, values);
|
return new SimpleConfigList(arrayOrigin, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
3
config/src/test/resources/test12.conf
Normal file
3
config/src/test/resources/test12.conf
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
// This file is included by include-from-list.conf to verify that includes with substitutions work in arrays
|
||||||
|
|
||||||
|
replace-me: ${replace-key}
|
Loading…
Reference in New Issue
Block a user