import { DocumentSymbol , SymbolKind , InsertTextFormat , Range } from 'vscode-languageserver-types' ; import { CompletionItem , CompletionItemKind , SymbolInformation , Diagnostic , DiagnosticSeverity } from 'vscode-languageserver' ; import { ErrorCode } from 'vscode-json-languageservice' ; export function createExpectedError ( message , startLine , startCharacter , endLine , endCharacter , severity = 1 , source = 'YAML' , code = ErrorCode . Undefined ) { return Diagnostic . create ( Range . create ( startLine , startCharacter , endLine , endCharacter ) , message , severity , code , source ) ; } export function createDiagnosticWithData ( message , startLine , startCharacter , endLine , endCharacter , severity = 1 , source = 'YAML' , schemaUri ) { const diagnostic = createExpectedError ( message , startLine , startCharacter , endLine , endCharacter , severity , source ) ; diagnostic . data = { schemaUri : typeof schemaUri === 'string' ? [ schemaUri ] : schemaUri } ; return diagnostic ; } export function createExpectedSymbolInformation ( name , kind , containerName , uri , startLine , startCharacter , endLine , endCharacter ) { return { name , kind , containerName , location : { uri , range : { start : { line : startLine , character : startCharacter , } , end : { line : endLine , character : endCharacter , } , } , } , } ; } export function createExpectedDocumentSymbol ( name , kind , startLine , startCharacter , endLine , endCharacter , startLineSelection , startCharacterSelection , endLineSelection , endCharacterSelection , children = [ ] , detail ? ) { const docSymbol = DocumentSymbol . create ( name , detail , kind , Range . create ( startLine , startCharacter , endLine , endCharacter ) , Range . create ( startLineSelection , startCharacterSelection , endLineSelection , endCharacterSelection ) , children ) ; return docSymbol ; } export function createExpectedDocumentSymbolNoDetail ( name , kind , startLine , startCharacter , endLine , endCharacter , startLineSelection , startCharacterSelection , endLineSelection , endCharacterSelection , children = [ ] ) { const docSymbol = DocumentSymbol . create ( name , undefined , kind , Range . create ( startLine , startCharacter , endLine , endCharacter ) , Range . create ( startLineSelection , startCharacterSelection , endLineSelection , endCharacterSelection ) , children ) ; delete docSymbol . detail ; return docSymbol ; } export function createExpectedCompletion ( label , insertText , startLine , startCharacter , endLine , endCharacter , kind , insertTextFormat = 2 , extra = { } ) { return { ... { insertText , label , insertTextFormat , kind , textEdit : { newText : insertText , range : { start : { line : startLine , character : startCharacter , } , end : { line : endLine , character : endCharacter , } , } , } , } , ... extra , } ; }