async function activateYmlContributor()

in src/extension.ts [33:76]


async function activateYmlContributor(context: vscode.ExtensionContext) {
    const serverOptions: languageclient.ServerOptions = getServerOptions(context);
    const clientOptions: languageclient.LanguageClientOptions = getClientOptions();
    const client = new languageclient.LanguageClient('azure-pipelines', 'Azure Pipelines Language', serverOptions, clientOptions);

    const schemaAssociationService = new SchemaAssociationService(context.extensionPath);

    const disposable = client.start();
    context.subscriptions.push(disposable);

    const initialSchemaAssociations = schemaAssociationService.getSchemaAssociation();

    // If this throws, the telemetry event in activate() will catch & log it
    await client.onReady();

    // Notify the server which schemas to use.
    client.sendNotification(SchemaAssociationNotification.type, initialSchemaAssociations);

    // Fired whenever the server is about to validate a YAML file (e.g. on content change),
    // and allows us to return a custom schema to use for validation.
    client.onRequest(CUSTOM_SCHEMA_REQUEST, (resource: string) => {
        // TODO: Have a single instance for the extension but dont return a global from this namespace
        return schemaContributor.requestCustomSchema(resource);
    });

    // Fired whenever the server encounters a URI scheme that it doesn't recognize,
    // and allows us to use the URI to determine the schema's content.
    client.onRequest(CUSTOM_CONTENT_REQUEST, (uri: string) => {
        return schemaContributor.requestCustomSchemaContent(uri);
    });

    // TODO: Can we get rid of this since it's set in package.json?
    vscode.languages.setLanguageConfiguration('azure-pipelines', { wordPattern: /("(?:[^\\\"]*(?:\\.)?)*"?)|[^\s{}\[\],:]+/ });

    // Let the server know of any schema changes.
    // TODO: move to schema-association-service?
    vscode.workspace.onDidChangeConfiguration(event => {
        if (event.affectsConfiguration('azure-pipelines.customSchemaFile')) {
            schemaAssociationService.locateSchemaFile();
            const newSchema = schemaAssociationService.getSchemaAssociation();
            client.sendNotification(SchemaAssociationNotification.type, newSchema);
        }
    });
}