function requestYamlSchemaUriCallback()

in client/src/yaml-support/yaml-schema.ts [33:57]


function requestYamlSchemaUriCallback(resource: string): string | undefined {
	const textEditor = vscode.window.visibleTextEditors.find((editor) => editor.document.uri.toString() === resource);
	if (textEditor) {
		const yamlDocs = yamlLocator.getYamlDocuments(textEditor.document);
		var found: boolean = false;

		yamlDocs.forEach((doc: any) => {
			// if the yaml document contains AWSTemplateFormatVersion or Resources at the main level it will
			// register as CloudFormation
			const topLevelMapping = <YamlMap>doc.nodes.find((node: any) => node.kind === 'MAPPING');
			if (topLevelMapping) {
				// if the overall yaml is an map, find the apiVersion and kind properties in yaml
				const cfnTemplateVersion = util.getYamlMappingValue(topLevelMapping, 'AWSTemplateFormatVersion');
				const cfnResources = util.getYamlMappingNode(topLevelMapping, 'Resources');
				if (cfnTemplateVersion || cfnResources) {
					found = true;
				}
			}
		});
		if (found) {
			return CLOUDFORMATION_SCHEMA_PREFIX + 'cloudformation';
		}
	}
	return undefined;
}