Fix location information for programs
There appears to be a bug in our use of jison causing the parent location information to be reported to programs. I wasn’t able to work through what might be causing this so instead using the location information of the statements collection to generate the proper location information. This is a bit of a hack but we are very far behind on the Jison release train and upgrading will likely be a less than pleasant task that doesn’t provide us much benefit. Fixes #1024
This commit is contained in:
@@ -121,3 +121,28 @@ export function prepareBlock(openBlock, program, inverseAndProgram, close, inver
|
||||
openBlock.strip, inverseStrip, close && close.strip,
|
||||
this.locInfo(locInfo));
|
||||
}
|
||||
|
||||
export function prepareProgram(statements, loc) {
|
||||
if (!loc && statements.length) {
|
||||
const first = statements[0].loc,
|
||||
last = statements[statements.length - 1].loc;
|
||||
|
||||
if (first && last) {
|
||||
loc = {
|
||||
source: first.source,
|
||||
start: {
|
||||
line: first.start.line,
|
||||
column: first.start.column
|
||||
},
|
||||
end: {
|
||||
line: last.end.line,
|
||||
column: last.end.column
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return new this.Program(statements, null, {}, loc);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user