-
-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade to yaml-language-server 0.5.3 now seems to be successful, fur…
…ther testing required
- Loading branch information
1 parent
828f65d
commit ca6bbc0
Showing
6 changed files
with
207 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { JSONSchemaService } from "yaml-language-server/out/server/src/languageservice/services/jsonSchemaService"; | ||
import { TextDocument, TextEdit, Diagnostic, ColorInformation, ColorPresentation, DocumentSymbol } from "vscode-languageserver-types"; | ||
import { JSONValidation } from "vscode-json-languageservice/lib/umd/services/jsonValidation"; | ||
import { JSONHover } from "vscode-json-languageservice/lib/umd/services/jsonHover"; | ||
import { JSONDocumentSymbols } from "vscode-json-languageservice/lib/umd/services/jsonDocumentSymbols"; | ||
import { JSONWorkerContribution, SymbolInformation, Hover, CompletionItem, CompletionList, LanguageService, JSONDocument, Color, Position, Range, FormattingOptions, FoldingRange, SelectionRange, ASTNode, DocumentLanguageSettings, JSONSchema } from "vscode-json-languageservice"; | ||
import { LanguageSettings } from "yaml-language-server/out/server/src/languageservice/yamlLanguageService"; | ||
|
||
export class JsonLanguageService implements LanguageService { | ||
|
||
jsonValidation: JSONValidation; | ||
jsonHover: JSONHover; | ||
jsonDocumentSymbols: JSONDocumentSymbols; | ||
|
||
constructor(jsonSchemaService: JSONSchemaService, jsonWorkerContributions: JSONWorkerContribution[]) { | ||
this.jsonValidation = new JSONValidation(jsonSchemaService, Promise); | ||
this.jsonHover = new JSONHover(jsonSchemaService, jsonWorkerContributions, Promise); | ||
this.jsonDocumentSymbols = new JSONDocumentSymbols(jsonSchemaService); | ||
} | ||
|
||
public async doValidation(document: TextDocument, jsonDocument: JSONDocument, documentSettings?: DocumentLanguageSettings, schema?: JSONSchema): Promise<Diagnostic[]> { | ||
return await this.jsonValidation.doValidation(document, jsonDocument, documentSettings, schema); | ||
} | ||
|
||
public findDocumentSymbols(document: TextDocument, doc: JSONDocument): SymbolInformation[] { | ||
return this.jsonDocumentSymbols.findDocumentSymbols(document, doc); | ||
} | ||
|
||
public findDocumentSymbols2(document: TextDocument, doc: JSONDocument): DocumentSymbol[] { | ||
return this.jsonDocumentSymbols.findDocumentSymbols2(document, doc); | ||
} | ||
|
||
public async findColorSymbols(document: TextDocument, doc: JSONDocument): Promise<Range[]> { | ||
return await this.jsonDocumentSymbols.findColorSymbols(document, doc); | ||
} | ||
|
||
public async findDocumentColors(document: TextDocument, doc: JSONDocument): Promise<ColorInformation[]> { | ||
return await this.jsonDocumentSymbols.findDocumentColors(document, doc); | ||
} | ||
|
||
public getColorPresentations(document: TextDocument, doc: JSONDocument, color: Color, range: Range): ColorPresentation[] { | ||
return this.jsonDocumentSymbols.getColorPresentations(document, doc, color, range); | ||
} | ||
|
||
public async doHover(document: TextDocument, position: Position, doc: JSONDocument): Promise<Hover> { | ||
return await this.jsonHover.doHover(document, position, doc); | ||
} | ||
|
||
// Methods below are not implemented since the YAML Language Service does not use them | ||
|
||
configure(settings: LanguageSettings): void { | ||
throw new Error("Method not implemented."); | ||
} | ||
parseJSONDocument(document: TextDocument): JSONDocument { | ||
throw new Error("Method not implemented."); | ||
} | ||
newJSONDocument(rootNode: ASTNode, syntaxDiagnostics?: Diagnostic[]): JSONDocument { | ||
throw new Error("Method not implemented."); | ||
} | ||
resetSchema(uri: string): boolean { | ||
throw new Error("Method not implemented."); | ||
} | ||
doResolve(item: CompletionItem): Thenable<CompletionItem> { | ||
throw new Error("Method not implemented."); | ||
} | ||
doComplete(document: TextDocument, position: Position, doc: JSONDocument): Thenable<CompletionList> { | ||
throw new Error("Method not implemented."); | ||
} | ||
format(document: TextDocument, range: Range, options: FormattingOptions): TextEdit[] { | ||
throw new Error("Method not implemented."); | ||
} | ||
getFoldingRanges(document: TextDocument, context?: { rangeLimit?: number; }): FoldingRange[] { | ||
throw new Error("Method not implemented."); | ||
} | ||
getSelectionRanges(document: TextDocument, positions: Position[], doc: JSONDocument): SelectionRange[] { | ||
throw new Error("Method not implemented."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { YAMLDocumentSymbols } from "yaml-language-server/out/server/src/languageservice/services/documentSymbols"; | ||
import { JSONSchemaService } from "yaml-language-server/out/server/src/languageservice/services/jsonSchemaService"; | ||
import { YAMLCompletion } from "yaml-language-server/out/server/src/languageservice/services/yamlCompletion"; | ||
import { YAMLHover } from "yaml-language-server/out/server/src/languageservice/services/yamlHover"; | ||
import { YAMLValidation } from "yaml-language-server/out/server/src/languageservice/services/yamlValidation"; | ||
import { YAMLFormatter } from "yaml-language-server/out/server/src/languageservice/services/yamlFormatter"; | ||
import { TextDocument, TextEdit, Diagnostic } from "vscode-languageserver-types"; | ||
import { JSONWorkerContribution, SymbolInformation, Hover, CompletionItem, CompletionList } from "vscode-json-languageservice"; | ||
import { Includetype } from "./haConfig/dto"; | ||
import { LanguageSettings } from "yaml-language-server/out/server/src/languageservice/yamlLanguageService"; | ||
import { JsonLanguageService } from "./jsonLanguageService"; | ||
|
||
|
||
export class YamlLanguageService { | ||
|
||
private yamlValidation: YAMLValidation; | ||
private yamlDocumentSymbols: YAMLDocumentSymbols; | ||
private yamlCompletion: YAMLCompletion; | ||
private yamlHover: YAMLHover; | ||
private yamlFormatter: YAMLFormatter; | ||
|
||
constructor(jsonSchemaService: JSONSchemaService, jsonLanguageService: JsonLanguageService, completionContributions: JSONWorkerContribution[]) { | ||
|
||
var languageSettings = <LanguageSettings>{ | ||
validate: true, | ||
customTags: this.getValidYamlTags(), | ||
completion: true, | ||
format: true, | ||
hover: true, | ||
isKubernetes: false | ||
}; | ||
|
||
this.yamlValidation = new YAMLValidation(Promise, jsonLanguageService); | ||
this.yamlDocumentSymbols = new YAMLDocumentSymbols(jsonLanguageService); | ||
this.yamlCompletion = new YAMLCompletion(jsonSchemaService, completionContributions); | ||
this.yamlHover = new YAMLHover(Promise, jsonLanguageService); | ||
this.yamlFormatter = new YAMLFormatter(); | ||
|
||
this.yamlValidation.configure(languageSettings); | ||
// enables auto completion suggestions for tags like !include () | ||
// commeted because they end up at the top of the list which does not look nice :-) | ||
// this.yamlCompletion.configure(languageSettings, languageSettings.customTags); | ||
this.yamlHover.configure(languageSettings); | ||
this.yamlFormatter.configure(languageSettings); | ||
} | ||
|
||
public async doValidation(document: TextDocument): Promise<Diagnostic[]> { | ||
return await this.yamlValidation.doValidation(document); | ||
} | ||
|
||
public findDocumentSymbols(document: TextDocument): SymbolInformation[] { | ||
return this.yamlDocumentSymbols.findDocumentSymbols(document); | ||
} | ||
|
||
public doComplete = async (textDocument: TextDocument, position: any): Promise<CompletionList> => { | ||
return await this.yamlCompletion.doComplete(textDocument, position, false); | ||
} | ||
|
||
public doResolve(completionItem: any): Thenable<CompletionItem> { | ||
return this.yamlCompletion.doResolve(completionItem); | ||
} | ||
|
||
public doHover(document: TextDocument, position: any): Thenable<Hover> { | ||
return this.yamlHover.doHover(document, position); | ||
} | ||
|
||
public format = (document: TextDocument, options: any): TextEdit[] => { | ||
return this.yamlFormatter.format(document, options); | ||
} | ||
|
||
private getValidYamlTags(): string[] { | ||
var validTags: string[] = []; | ||
for (let item in Includetype) { | ||
if (isNaN(Number(item))) { | ||
validTags.push(`!${item} scalar`); | ||
} | ||
} | ||
validTags.push("!secret scalar"); | ||
return validTags; | ||
} | ||
} |
Oops, something went wrong.