Added Results.Errors to Context constructor and Context.with(Identifier)

This commit is contained in:
moandji.ezana 2015-02-12 08:33:43 +02:00
parent 786529fce6
commit 7292fe5468
2 changed files with 9 additions and 3 deletions

View file

@ -5,9 +5,15 @@ import java.util.concurrent.atomic.AtomicInteger;
class Context {
final Identifier identifier;
final AtomicInteger line;
final Results.Errors errors;
public Context(Identifier identifier, AtomicInteger line) {
public Context(Identifier identifier, AtomicInteger line, Results.Errors errors) {
this.identifier = identifier;
this.line = line;
this.errors = errors;
}
public Context with(Identifier identifier) {
return new Context(identifier, line, errors);
}
}

View file

@ -37,7 +37,7 @@ class InlineTableConverter implements ValueConverter {
} else if (quoted) {
currentKey.append(c);
} else if (inValue && !Character.isWhitespace(c)) {
Object converted = CONVERTERS.convert(s, sharedIndex, new Context(new Identifier(currentKey.toString()), context.line));
Object converted = CONVERTERS.convert(s, sharedIndex, context.with(new Identifier(currentKey.toString())));
if (converted instanceof Results.Errors) {
errors.add((Results.Errors) converted);
@ -49,7 +49,7 @@ class InlineTableConverter implements ValueConverter {
inValue = false;
} else if (c == '{') {
sharedIndex.incrementAndGet();
Object converted = convert(s, sharedIndex, new Context(new Identifier(currentKey.toString()), context.line));
Object converted = convert(s, sharedIndex, context.with(new Identifier(currentKey.toString())));
if (converted instanceof Results.Errors) {
errors.add((Results.Errors) converted);