mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 18:49:00 +01:00
[html] use languageModes for language types
This commit is contained in:
@@ -6,10 +6,7 @@ import 'mocha';
|
||||
import * as assert from 'assert';
|
||||
import * as path from 'path';
|
||||
import { URI } from 'vscode-uri';
|
||||
import { getLanguageModes } from '../modes/languageModes';
|
||||
import { WorkspaceFolder } from 'vscode-languageserver';
|
||||
import { TextDocument, CompletionList, CompletionItemKind, ClientCapabilities } from 'vscode-html-languageservice';
|
||||
|
||||
import { getLanguageModes, WorkspaceFolder, TextDocument, CompletionList, CompletionItemKind, ClientCapabilities} from '../modes/languageModes';
|
||||
export interface ItemDescription {
|
||||
label: string;
|
||||
documentation?: string;
|
||||
|
||||
@@ -5,31 +5,32 @@
|
||||
import 'mocha';
|
||||
import * as assert from 'assert';
|
||||
import * as embeddedSupport from '../modes/embeddedSupport';
|
||||
import { getLanguageService, TextDocument } from 'vscode-html-languageservice';
|
||||
import { getLanguageService } from 'vscode-html-languageservice';
|
||||
import { TextDocument } from '../modes/languageModes';
|
||||
|
||||
suite('HTML Embedded Support', () => {
|
||||
|
||||
var htmlLanguageService = getLanguageService();
|
||||
const htmlLanguageService = getLanguageService();
|
||||
|
||||
function assertLanguageId(value: string, expectedLanguageId: string | undefined): void {
|
||||
let offset = value.indexOf('|');
|
||||
const offset = value.indexOf('|');
|
||||
value = value.substr(0, offset) + value.substr(offset + 1);
|
||||
|
||||
let document = TextDocument.create('test://test/test.html', 'html', 0, value);
|
||||
const document = TextDocument.create('test://test/test.html', 'html', 0, value);
|
||||
|
||||
let position = document.positionAt(offset);
|
||||
const position = document.positionAt(offset);
|
||||
|
||||
let docRegions = embeddedSupport.getDocumentRegions(htmlLanguageService, document);
|
||||
let languageId = docRegions.getLanguageAtPosition(position);
|
||||
const docRegions = embeddedSupport.getDocumentRegions(htmlLanguageService, document);
|
||||
const languageId = docRegions.getLanguageAtPosition(position);
|
||||
|
||||
assert.equal(languageId, expectedLanguageId);
|
||||
}
|
||||
|
||||
function assertEmbeddedLanguageContent(value: string, languageId: string, expectedContent: string): void {
|
||||
let document = TextDocument.create('test://test/test.html', 'html', 0, value);
|
||||
const document = TextDocument.create('test://test/test.html', 'html', 0, value);
|
||||
|
||||
let docRegions = embeddedSupport.getDocumentRegions(htmlLanguageService, document);
|
||||
let content = docRegions.getEmbeddedDocument(languageId);
|
||||
const docRegions = embeddedSupport.getDocumentRegions(htmlLanguageService, document);
|
||||
const content = docRegions.getEmbeddedDocument(languageId);
|
||||
assert.equal(content.getText(), expectedContent);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,13 +17,13 @@ interface ExpectedIndentRange {
|
||||
}
|
||||
|
||||
function assertRanges(lines: string[], expected: ExpectedIndentRange[], message?: string, nRanges?: number): void {
|
||||
let document = TextDocument.create('test://foo/bar.json', 'json', 1, lines.join('\n'));
|
||||
let workspace = {
|
||||
const document = TextDocument.create('test://foo/bar.json', 'json', 1, lines.join('\n'));
|
||||
const workspace = {
|
||||
settings: {},
|
||||
folders: [{ name: 'foo', uri: 'test://foo' }]
|
||||
};
|
||||
let languageModes = getLanguageModes({ css: true, javascript: true }, workspace, ClientCapabilities.LATEST);
|
||||
let actual = getFoldingRanges(languageModes, document, nRanges, null);
|
||||
const languageModes = getLanguageModes({ css: true, javascript: true }, workspace, ClientCapabilities.LATEST);
|
||||
const actual = getFoldingRanges(languageModes, document, nRanges, null);
|
||||
|
||||
let actualRanges = [];
|
||||
for (let i = 0; i < actual.length; i++) {
|
||||
@@ -40,7 +40,7 @@ function r(startLine: number, endLine: number, kind?: string): ExpectedIndentRan
|
||||
suite('HTML Folding', () => {
|
||||
|
||||
test('Embedded JavaScript', () => {
|
||||
let input = [
|
||||
const input = [
|
||||
/*0*/'<html>',
|
||||
/*1*/'<head>',
|
||||
/*2*/'<script>',
|
||||
@@ -54,7 +54,7 @@ suite('HTML Folding', () => {
|
||||
});
|
||||
|
||||
test('Embedded JavaScript - multiple areas', () => {
|
||||
let input = [
|
||||
const input = [
|
||||
/* 0*/'<html>',
|
||||
/* 1*/'<head>',
|
||||
/* 2*/'<script>',
|
||||
@@ -75,7 +75,7 @@ suite('HTML Folding', () => {
|
||||
});
|
||||
|
||||
test('Embedded JavaScript - incomplete', () => {
|
||||
let input = [
|
||||
const input = [
|
||||
/* 0*/'<html>',
|
||||
/* 1*/'<head>',
|
||||
/* 2*/'<script>',
|
||||
@@ -91,7 +91,7 @@ suite('HTML Folding', () => {
|
||||
});
|
||||
|
||||
test('Embedded JavaScript - regions', () => {
|
||||
let input = [
|
||||
const input = [
|
||||
/* 0*/'<html>',
|
||||
/* 1*/'<head>',
|
||||
/* 2*/'<script>',
|
||||
@@ -108,7 +108,7 @@ suite('HTML Folding', () => {
|
||||
});
|
||||
|
||||
test('Embedded CSS', () => {
|
||||
let input = [
|
||||
const input = [
|
||||
/* 0*/'<html>',
|
||||
/* 1*/'<head>',
|
||||
/* 2*/'<style>',
|
||||
@@ -124,7 +124,7 @@ suite('HTML Folding', () => {
|
||||
});
|
||||
|
||||
test('Embedded CSS - multiple areas', () => {
|
||||
let input = [
|
||||
const input = [
|
||||
/* 0*/'<html>',
|
||||
/* 1*/'<head style="color:red">',
|
||||
/* 2*/'<style>',
|
||||
@@ -145,7 +145,7 @@ suite('HTML Folding', () => {
|
||||
});
|
||||
|
||||
test('Embedded CSS - regions', () => {
|
||||
let input = [
|
||||
const input = [
|
||||
/* 0*/'<html>',
|
||||
/* 1*/'<head>',
|
||||
/* 2*/'<style>',
|
||||
@@ -163,7 +163,7 @@ suite('HTML Folding', () => {
|
||||
|
||||
|
||||
// test('Embedded JavaScript - multi line comment', () => {
|
||||
// let input = [
|
||||
// const input = [
|
||||
// /* 0*/'<html>',
|
||||
// /* 1*/'<head>',
|
||||
// /* 2*/'<script>',
|
||||
@@ -178,7 +178,7 @@ suite('HTML Folding', () => {
|
||||
// });
|
||||
|
||||
test('Test limit', () => {
|
||||
let input = [
|
||||
const input = [
|
||||
/* 0*/'<div>',
|
||||
/* 1*/' <span>',
|
||||
/* 2*/' <b>',
|
||||
|
||||
@@ -7,8 +7,7 @@ import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { getLanguageModes } from '../modes/languageModes';
|
||||
import { TextDocument, Range, FormattingOptions, ClientCapabilities } from 'vscode-html-languageservice';
|
||||
import { getLanguageModes, TextDocument, Range, FormattingOptions, ClientCapabilities } from '../modes/languageModes';
|
||||
|
||||
import { format } from '../modes/formatting';
|
||||
|
||||
@@ -168,7 +167,7 @@ suite('HTML Embedded Formatting', () => {
|
||||
}
|
||||
};
|
||||
|
||||
var content = [
|
||||
const content = [
|
||||
'<html>',
|
||||
'',
|
||||
'<body>',
|
||||
@@ -179,7 +178,7 @@ suite('HTML Embedded Formatting', () => {
|
||||
'</html>',
|
||||
].join('\n');
|
||||
|
||||
var expected = [
|
||||
const expected = [
|
||||
'<html>',
|
||||
'',
|
||||
'<body>',
|
||||
|
||||
@@ -5,10 +5,7 @@
|
||||
|
||||
import 'mocha';
|
||||
import * as assert from 'assert';
|
||||
import { SelectionRange } from 'vscode-languageserver-types';
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
import { getLanguageModes } from '../modes/languageModes';
|
||||
import { ClientCapabilities } from 'vscode-html-languageservice';
|
||||
import { getLanguageModes, ClientCapabilities, TextDocument, SelectionRange} from '../modes/languageModes';
|
||||
import { getSelectionRanges } from '../modes/selectionRanges';
|
||||
|
||||
function assertRanges(content: string, expected: (number | string)[][]): void {
|
||||
|
||||
Reference in New Issue
Block a user