How to use the vscode-html-languageservice.TokenType.Script function in vscode-html-languageservice

To help you get started, we’ve selected a few vscode-html-languageservice examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / typescript-lit-html-plugin / src / embeddedSupport.ts View on Github external
while (token !== TokenType.EOS) {
        switch (token) {
            case TokenType.StartTag:
                lastTagName = scanner.getTokenText();
                lastAttributeName = null;
                languageIdFromType = 'javascript';
                break;
            case TokenType.Styles:
                regions.push({
                    languageId: 'css',
                    start: scanner.getTokenOffset(),
                    end: scanner.getTokenEnd(),
                    onlyPlaceholders: onlyPlaceholdersRegex.test(scanner.getTokenText()),
                });
                break;
            case TokenType.Script:
                regions.push({
                    languageId: languageIdFromType,
                    start: scanner.getTokenOffset(),
                    end: scanner.getTokenEnd(),
                    onlyPlaceholders: onlyPlaceholdersRegex.test(scanner.getTokenText()),
                });
                break;
            case TokenType.AttributeName:
                lastAttributeName = scanner.getTokenText();
                break;
            case TokenType.AttributeValue:
                if (
                    lastAttributeName === 'src' &&
                    lastTagName.toLowerCase() === 'script'
                ) {
                    let value = scanner.getTokenText();
github neoclide / coc-html / server / modes / embeddedSupport.ts View on Github external
let lastAttributeName: string | null = null;
	let languageIdFromType: string | undefined = undefined;
	let importedScripts: string[] = [];

	let token = scanner.scan();
	while (token !== TokenType.EOS) {
		switch (token) {
			case TokenType.StartTag:
				lastTagName = scanner.getTokenText();
				lastAttributeName = null;
				languageIdFromType = 'javascript';
				break;
			case TokenType.Styles:
				regions.push({ languageId: 'css', start: scanner.getTokenOffset(), end: scanner.getTokenEnd() });
				break;
			case TokenType.Script:
				regions.push({ languageId: languageIdFromType, start: scanner.getTokenOffset(), end: scanner.getTokenEnd() });
				break;
			case TokenType.AttributeName:
				lastAttributeName = scanner.getTokenText();
				break;
			case TokenType.AttributeValue:
				if (lastAttributeName === 'src' && lastTagName.toLowerCase() === 'script') {
					let value = scanner.getTokenText();
					if (value[0] === '\'' || value[0] === '"') {
						value = value.substr(1, value.length - 1);
					}
					importedScripts.push(value);
				} else if (lastAttributeName === 'type' && lastTagName.toLowerCase() === 'script') {
					if (/["'](module|(text|application)\/(java|ecma)script)["']/.test(scanner.getTokenText())) {
						languageIdFromType = 'javascript';
					} else {