Change parent class of ConfigNodeInclude

Modify the parent class of ConfigNodeInclude to be
AbstractConfigNode instead of ConfigNodeComplexValue, as an
include statement is not a value.
This commit is contained in:
Preben Ingvaldsen 2015-04-01 16:06:02 -07:00
parent dc567e8489
commit deb32bcab0
3 changed files with 16 additions and 9 deletions

View File

@ -35,10 +35,10 @@ abstract class ConfigNodeComplexValue extends AbstractConfigNodeValue {
i++;
} else if (child instanceof ConfigNodeField) {
AbstractConfigNode value = ((ConfigNodeField) child).value();
if (value instanceof ConfigNodeComplexValue && !(value instanceof ConfigNodeInclude)) {
if (value instanceof ConfigNodeComplexValue) {
childrenCopy.set(i, ((ConfigNodeField) child).replaceValue(((ConfigNodeComplexValue) value).indentText(indentation)));
}
} else if (child instanceof ConfigNodeComplexValue && !(child instanceof ConfigNodeInclude)) {
} else if (child instanceof ConfigNodeComplexValue) {
childrenCopy.set(i, ((ConfigNodeComplexValue) child).indentText(indentation));
}
}

View File

@ -1,20 +1,28 @@
package com.typesafe.config.impl;
import com.typesafe.config.ConfigException;
import java.util.ArrayList;
import java.util.Collection;
final class ConfigNodeInclude extends ConfigNodeComplexValue {
final class ConfigNodeInclude extends AbstractConfigNode {
final private ArrayList<AbstractConfigNode> children;
final private ConfigIncludeKind kind;
ConfigNodeInclude(Collection<AbstractConfigNode> children, ConfigIncludeKind kind) {
super(children);
this.children = new ArrayList<AbstractConfigNode>(children);
this.kind = kind;
}
final public Collection<AbstractConfigNode> children() {
return children;
}
@Override
protected ConfigNodeInclude newNode(Collection<AbstractConfigNode> nodes) {
throw new ConfigException.BugOrBroken("Tried to indent an include node");
protected Collection<Token> tokens() {
ArrayList<Token> tokens = new ArrayList();
for (AbstractConfigNode child : children) {
tokens.addAll(child.tokens());
}
return tokens;
}
protected ConfigIncludeKind kind() {

View File

@ -270,7 +270,6 @@ final class ConfigParser {
valueNode = ((ConfigNodeField) node).value();
// comments from the key token go to the value token
//newValue = parseValue(valueToken.prepend(keyToken.comments));
newValue = parseValue(valueNode, comments);
if (((ConfigNodeField) node).separator() == Tokens.PLUS_EQUALS) {