private void calculatePosition() {
synchronized (lock) {
if (!positionsCalculated) {
// The expressions is the argument of the template element, so we prefer it as it's more specific.
TemplateObject templateObject = blamedExpression != null
? (TemplateObject) blamedExpression
: (
ftlInstructionStackSnapshot != null && ftlInstructionStackSnapshot.length != 0
? ftlInstructionStackSnapshot[0] : null);
// Line number blow 0 means no info, negative means position in ?eval-ed value that we won't use here.
if (templateObject != null && templateObject.getBeginLine() > 0) {
final Template template = templateObject.getTemplate();
templateName = template != null ? template.getName() : null;
lineNumber = new Integer(templateObject.getBeginLine());
columnNumber = new Integer(templateObject.getBeginColumn());
endLineNumber = new Integer(templateObject.getEndLine());
endColumnNumber = new Integer(templateObject.getEndColumn());
}
positionsCalculated = true;
deleteFTLInstructionStackSnapshotIfNotNeeded();
}
}