update css service/server

This commit is contained in:
Martin Aeschlimann
2019-09-30 22:55:31 +02:00
parent b8a75a33dd
commit ecba37c6ef
9 changed files with 549 additions and 119 deletions

View File

@@ -6,7 +6,7 @@
import {
createConnection, IConnection, TextDocuments, InitializeParams, InitializeResult, ServerCapabilities, ConfigurationRequest, WorkspaceFolder
} from 'vscode-languageserver';
import URI from 'vscode-uri';
import { URI } from 'vscode-uri';
import { TextDocument, CompletionList, Position } from 'vscode-languageserver-types';
import { stat as fsStat } from 'fs';
@@ -390,4 +390,4 @@ connection.onSelectionRanges((params, token) => {
// Listen on the connection
connection.listen();
connection.listen();

View File

@@ -5,7 +5,7 @@
import * as path from 'path';
import * as fs from 'fs';
import URI from 'vscode-uri';
import { URI } from 'vscode-uri';
import { TextDocument, CompletionList, CompletionItemKind, CompletionItem, TextEdit, Range, Position } from 'vscode-languageserver-types';
import { WorkspaceFolder } from 'vscode-languageserver';

View File

@@ -5,7 +5,7 @@
import 'mocha';
import * as assert from 'assert';
import * as path from 'path';
import Uri from 'vscode-uri';
import { URI } from 'vscode-uri';
import { TextDocument, CompletionList } from 'vscode-languageserver-types';
import { WorkspaceFolder } from 'vscode-languageserver-protocol';
import { getPathCompletionParticipant } from '../pathCompletion';
@@ -60,8 +60,8 @@ suite('Completions', () => {
}
test('CSS url() Path completion', function () {
let testUri = Uri.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/about/about.css')).toString();
let folders = [{ name: 'x', uri: Uri.file(path.resolve(__dirname, '../../test')).toString() }];
let testUri = URI.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/about/about.css')).toString();
let folders = [{ name: 'x', uri: URI.file(path.resolve(__dirname, '../../test')).toString() }];
assertCompletions('html { background-image: url("./|")', {
items: [
@@ -119,8 +119,8 @@ suite('Completions', () => {
});
test('CSS url() Path Completion - Unquoted url', function () {
let testUri = Uri.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/about/about.css')).toString();
let folders = [{ name: 'x', uri: Uri.file(path.resolve(__dirname, '../../test')).toString() }];
let testUri = URI.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/about/about.css')).toString();
let folders = [{ name: 'x', uri: URI.file(path.resolve(__dirname, '../../test')).toString() }];
assertCompletions('html { background-image: url(./|)', {
items: [
@@ -148,8 +148,8 @@ suite('Completions', () => {
});
test('CSS @import Path completion', function () {
let testUri = Uri.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/about/about.css')).toString();
let folders = [{ name: 'x', uri: Uri.file(path.resolve(__dirname, '../../test')).toString() }];
let testUri = URI.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/about/about.css')).toString();
let folders = [{ name: 'x', uri: URI.file(path.resolve(__dirname, '../../test')).toString() }];
assertCompletions(`@import './|'`, {
items: [
@@ -171,8 +171,8 @@ suite('Completions', () => {
* For SCSS, `@import 'foo';` can be used for importing partial file `_foo.scss`
*/
test('SCSS @import Path completion', function () {
let testCSSUri = Uri.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/about/about.css')).toString();
let folders = [{ name: 'x', uri: Uri.file(path.resolve(__dirname, '../../test')).toString() }];
let testCSSUri = URI.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/about/about.css')).toString();
let folders = [{ name: 'x', uri: URI.file(path.resolve(__dirname, '../../test')).toString() }];
/**
* We are in a CSS file, so no special treatment for SCSS partial files
@@ -184,7 +184,7 @@ suite('Completions', () => {
]
}, testCSSUri, folders);
let testSCSSUri = Uri.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/scss/main.scss')).toString();
let testSCSSUri = URI.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/scss/main.scss')).toString();
assertCompletions(`@import './|'`, {
items: [
{ label: '_foo.scss', resultText: `@import './foo'` }
@@ -193,12 +193,12 @@ suite('Completions', () => {
});
test('Completion should ignore files/folders starting with dot', function () {
let testUri = Uri.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/about/about.css')).toString();
let folders = [{ name: 'x', uri: Uri.file(path.resolve(__dirname, '../../test')).toString() }];
let testUri = URI.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/about/about.css')).toString();
let folders = [{ name: 'x', uri: URI.file(path.resolve(__dirname, '../../test')).toString() }];
assertCompletions('html { background-image: url("../|")', {
count: 4
}, testUri, folders);
});
});
});

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import 'mocha';
import * as assert from 'assert';
import Uri from 'vscode-uri';
import { URI } from 'vscode-uri';
import { resolve } from 'path';
import { TextDocument, DocumentLink } from 'vscode-languageserver-types';
import { WorkspaceFolder } from 'vscode-languageserver-protocol';
@@ -54,7 +54,7 @@ suite('Links', () => {
}
function getTestResource(path: string) {
return Uri.file(resolve(__dirname, '../../test/linksTestFixtures', path)).toString();
return URI.file(resolve(__dirname, '../../test/linksTestFixtures', path)).toString();
}
test('url links', function () {
@@ -76,4 +76,4 @@ suite('Links', () => {
[{ offset: 29, value: '"~foo/hello.html"', target: getTestResource('node_modules/foo/hello.html') }], testUri, folders
);
});
});
});

View File

@@ -7,7 +7,7 @@ import { DocumentContext } from 'vscode-css-languageservice';
import { endsWith, startsWith } from '../utils/strings';
import * as url from 'url';
import { WorkspaceFolder } from 'vscode-languageserver';
import URI from 'vscode-uri';
import { URI } from 'vscode-uri';
import { join, dirname } from 'path';
import { existsSync } from 'fs';