in src/language/semantics/xsltTokenDiagnostics.ts [1881:1997]
private static appendDiagnosticsFromProblemTokens(
variableRefDiagnostics: vscode.Diagnostic[],
tokens: BaseToken[]
): vscode.Diagnostic[] {
tokens.forEach((token) => {
let line = token.line
let endChar = token.startCharacter + token.length
let tokenValue = token.value
let msg: string
let errCode = DiagnosticCode.none
let diagnosticMetadata: vscode.DiagnosticTag[] = []
let severity = vscode.DiagnosticSeverity.Error
switch (token.error) {
case ErrorType.AxisName:
msg = `XPath: Invalid axis name: '${tokenValue}`
break
case ErrorType.BracketNesting:
let matchingChar: any =
XsltTokenDiagnostics.getMatchingSymbol(tokenValue)
msg =
matchingChar.length === 0
? `XPath: No match found for '${tokenValue}'`
: `'${tokenValue}' has no matching '${matchingChar}'`
diagnosticMetadata = [vscode.DiagnosticTag.Unnecessary]
break
case ErrorType.ElementNesting:
msg = `XML: Start tag '${tokenValue}' has no matching close tag`
break
case ErrorType.ExpectedElseAfterThen:
msg = `XML: Expected 'else' but found '${tokenValue}'`
break
case ErrorType.ExpectedDollarAfterComma:
msg = `XML: Expected '$' but found '${tokenValue}'`
break
case ErrorType.EntityName:
msg = `XML: Invalid entity name '${tokenValue}'`
break
case ErrorType.XPathKeyword:
msg = `XPath: Found: '${tokenValue}' expected keyword or operator`
break
case ErrorType.DuplicateParameterName:
msg = `XSLT: Duplicate parameter name: '${tokenValue}'`
break
case ErrorType.XSLTKeyUnresolved:
msg = `XSLT: xsl:key declaration with name '${tokenValue}' not found`
break
case ErrorType.AccumulatorNameUnresolved:
msg = `XSLT: xsl:accumulator with name '${tokenValue}' not found`
break
case ErrorType.XPathUnexpected:
msg = `XPath: Expression context - unexpected token here: ${tokenValue} `
break
case ErrorType.XPathFunctionUnexpected:
msg = `XPath: Unexpected function after expression: '${tokenValue}()' `
break
case ErrorType.XPathName:
msg = `XPath: Invalid name: '${tokenValue}'`
break
case ErrorType.XPathOperatorUnexpected:
msg = `XPath: Operator unexpected at this position: '${tokenValue}'`
break
case ErrorType.XPathAwaiting:
msg = `XPath: Expected expression following: '${tokenValue}'`
break
case ErrorType.XPathStringLiteral:
msg = `String literal not terminated properly: ${tokenValue}`
break
case ErrorType.XPathFunction:
let parts = tokenValue.split('#')
msg = `XPath: Function: '${parts[0]}' with ${parts[1]} arguments not found`
break
case ErrorType.XPathTypeName:
msg = `XPath: Invalid type: '${tokenValue}'`
break
case ErrorType.XPathFunctionNamespace:
let partsNs = tokenValue.split('#')
msg = `XPath: Undeclared prefix in function: '${partsNs[0]}'`
break
case ErrorType.XPathExpectedComplex:
const expected = tokenValue === ':=' ? 'in' : ':='
msg = `XPath: '${tokenValue}' is invalid here, expected '${expected}'`
break
case ErrorType.XPathPrefix:
msg = `XPath: Undeclared prefix in name: '${tokenValue}'`
break
case ErrorType.DuplicateVarName:
msg = `XSLT: Duplicate global variable/parameter name: '${tokenValue}'`
break
case ErrorType.DuplicateFnName:
msg = `XSLT: Duplicate function name and arity: '${tokenValue}'`
break
case ErrorType.DuplicateTemplateName:
msg = `XSLT: Duplicate xsl:template name '${tokenValue}'`
break
case ErrorType.DuplicateAccumulatorName:
msg = `XSLT: Duplicate xsl:accumulator name '${tokenValue}'`
break
default:
msg = 'Unexepected Error'
break
}
if (token.startCharacter > -1 && endChar > -1) {
variableRefDiagnostics.push({
code: errCode,
message: msg,
range: new vscode.Range(
new vscode.Position(line, token.startCharacter),
new vscode.Position(line, endChar)
),
severity: severity,
tags: diagnosticMetadata,
source: '',
})
}
})
return variableRefDiagnostics
}