Skip to content

Commit

Permalink
build: update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmlnc committed May 6, 2021
1 parent 36cf77c commit 17c3e8b
Show file tree
Hide file tree
Showing 11 changed files with 725 additions and 685 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ npm-debug.log*

# Dependency directory
node_modules/
!fixtures/e2e/node_modules
!fixtures/e2e/completion/node_modules/

# Compiled and temporary files
out/
Expand Down
1 change: 1 addition & 0 deletions fixtures/e2e/completion/node_modules/foo/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1,295 changes: 689 additions & 606 deletions package-lock.json

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"publisher": "mrmlnc",
"license": "MIT",
"engines": {
"vscode": "^1.43.0"
"vscode": "^1.53.0"
},
"icon": "icon.png",
"homepage": "https://github.com/mrmlnc/vscode-scss/blob/master/README.md",
Expand Down Expand Up @@ -96,32 +96,32 @@
}
},
"devDependencies": {
"@nodelib/fs.macchiato": "1.0.2",
"@nodelib/fs.macchiato": "1.0.3",
"@types/color": "3.0.1",
"@types/color-name": "1.1.1",
"@types/mocha": "7.0.2",
"@types/node": "10.17.17",
"@types/sinon": "7.5.2",
"@types/vscode": "1.43.0",
"eslint": "7.24.0",
"@types/mocha": "8.2.2",
"@types/node": "12.20.12",
"@types/sinon": "10.0.0",
"@types/vscode": "1.53.0",
"eslint": "7.25.0",
"eslint-config-mrmlnc": "2.0.0",
"mocha": "7.1.1",
"mocha": "8.3.2",
"rimraf": "3.0.2",
"sinon": "9.0.1",
"sinon": "10.0.0",
"typescript": "4.2.4",
"vscode-test": "1.3.0"
"vscode-test": "1.5.2"
},
"dependencies": {
"color": "3.1.2",
"color": "3.1.3",
"color-name": "1.1.4",
"fast-glob": "3.2.5",
"scss-symbols-parser": "2.0.1",
"vscode-css-languageservice": "4.1.1",
"vscode-languageclient": "6.1.3",
"vscode-languageserver": "6.1.1",
"vscode-css-languageservice": "5.1.1",
"vscode-languageclient": "7.0.0",
"vscode-languageserver": "7.0.0",
"vscode-languageserver-textdocument": "1.0.1",
"vscode-languageserver-types": "3.15.1",
"vscode-uri": "2.1.1"
"vscode-languageserver-types": "3.16.0",
"vscode-uri": "3.0.2"
},
"scripts": {
"clean": "rimraf out",
Expand Down
4 changes: 2 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import * as path from 'path';

import * as vscode from 'vscode';
import type { URI } from 'vscode-uri';
import type { LanguageClientOptions, NodeModule, ServerOptions } from 'vscode-languageclient';
import { LanguageClient, TransportKind, RevealOutputChannelOn } from 'vscode-languageclient';
import type { LanguageClientOptions, NodeModule, ServerOptions } from 'vscode-languageclient/node';
import { LanguageClient, TransportKind, RevealOutputChannelOn } from 'vscode-languageclient/node';
import { EXTENSION_ID, EXTENSION_NAME } from './constants';

const EXTENSION_SERVER_MODULE_PATH = path.join(__dirname, './unsafe/server.js');
Expand Down
6 changes: 3 additions & 3 deletions src/unsafe/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import {
createConnection,
IConnection,
Connection,
IPCMessageReader,
IPCMessageWriter,
TextDocuments,
InitializeParams,
InitializeResult,
TextDocumentSyncKind
} from 'vscode-languageserver';
} from 'vscode-languageserver/node';
import { TextDocument } from 'vscode-languageserver-textdocument';

import type { ISettings } from './types/settings';
Expand Down Expand Up @@ -37,7 +37,7 @@ let storageService: StorageService;
let scannerService: ScannerService;

// Create a connection for the server
const connection: IConnection = createConnection(new IPCMessageReader(process), new IPCMessageWriter(process));
const connection: Connection = createConnection(new IPCMessageReader(process), new IPCMessageWriter(process));

console.log = connection.console.log.bind(connection.console);
console.error = connection.console.error.bind(connection.console);
Expand Down
5 changes: 1 addition & 4 deletions src/unsafe/services/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ async function findDocumentSymbols(document: TextDocument, ast: INode): Promise<
}

async function findDocumentLinks(document: TextDocument, ast: INode): Promise<DocumentLink[]> {
// The `findDocumentLinks2` method requires URI.
const uri = document.uri.startsWith('file:') ? document.uri : URI.file(document.uri).toString();

const links = await ls.findDocumentLinks2(document, ast, buildDocumentContext(uri));
const links = await ls.findDocumentLinks2(document, ast, buildDocumentContext(document.uri));

const result: DocumentLink[] = [];

Expand Down
9 changes: 6 additions & 3 deletions src/unsafe/services/scanner.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as path from 'path';

import { TextDocument } from 'vscode-languageserver-textdocument';
import { URI } from 'vscode-uri';

import type { ISettings } from '../types/settings';
import { readFile, fileExists } from '../utils/fs';
Expand All @@ -17,19 +18,21 @@ export default class ScannerService {
// Cast to the system file path style
filepath = path.normalize(filepath);

const uri = URI.file(filepath).toString();

const isExistFile = await this._fileExists(filepath);

if (!isExistFile) {
this._storage.delete(filepath);
this._storage.delete(uri);

continue;
}

const content = await this._readFile(filepath);
const document = TextDocument.create(filepath, 'scss', 1, content);
const document = TextDocument.create(uri, 'scss', 1, content);
const { symbols } = await parseDocument(document, null);

this._storage.set(filepath, { ...symbols, filepath });
this._storage.set(uri, { ...symbols, filepath });

if (!recursive || !this._settings.scanImportedFiles) {
continue;
Expand Down
12 changes: 6 additions & 6 deletions src/unsafe/test/e2e/suite/hover/hover.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,37 @@ describe('SCSS Hover Test', () => {

it('shows hover for variables', async () => {
await testHover(docUri, position(2, 13), {
contents: ['\n```scss\n$variable: \'value\';\n@import "../_variables.scss" (implicitly)\n```\n']
contents: ['```scss\n$variable: \'value\';\n@import "../_variables.scss" (implicitly)\n```']
});
});

it('shows hover for functions', async () => {
await testHover(docUri, position(2, 24), {
contents: ['\n```scss\n@function function() {…}\n@import "../_functions.scss" (implicitly)\n```\n']
contents: ['```scss\n@function function() {…}\n@import "../_functions.scss" (implicitly)\n```']
});
});

it('shows hover for mixins', async () => {
await testHover(docUri, position(4, 12), {
contents: ['\n```scss\n@mixin mixin() {…}\n@import "../_mixins.scss" (implicitly)\n```\n']
contents: ['```scss\n@mixin mixin() {…}\n@import "../_mixins.scss" (implicitly)\n```']
});
});

it('shows hover for variables on vue file', async () => {
await testHover(vueDocUri, position(13, 13), {
contents: ['\n```scss\n$variable: \'value\';\n@import "../_variables.scss" (implicitly)\n```\n']
contents: ['```scss\n$variable: \'value\';\n@import "../_variables.scss" (implicitly)\n```']
});
});

it('shows hover for functions on vue file', async () => {
await testHover(vueDocUri, position(13, 24), {
contents: ['\n```scss\n@function function() {…}\n@import "../_functions.scss" (implicitly)\n```\n']
contents: ['```scss\n@function function() {…}\n@import "../_functions.scss" (implicitly)\n```']
});
});

it('shows hover for mixins on vue file', async () => {
await testHover(vueDocUri, position(15, 12), {
contents: ['\n```scss\n@mixin mixin() {…}\n@import "../_mixins.scss" (implicitly)\n```\n']
contents: ['```scss\n@mixin mixin() {…}\n@import "../_mixins.scss" (implicitly)\n```']
});
});
});
2 changes: 0 additions & 2 deletions src/unsafe/test/e2e/suite/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ export async function run(): Promise<void> {
timeout: ONE_SECOND_IN_MS * 10
});

mocha.useColors(true);

const files = await fg('**/*.test.js', {
cwd: path.resolve(__dirname, '..'),
absolute: true
Expand Down
42 changes: 0 additions & 42 deletions src/unsafe/utils/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import * as path from 'path';
import * as url from 'url';

import type { DocumentContext } from 'vscode-css-languageservice';
import { URI } from 'vscode-uri';
import { fileExistsSync } from '../utils/fs';

/**
* Returns the path to the document, relative to the current document.
Expand All @@ -32,47 +30,7 @@ export function getDocumentPath(currentPath: string, symbolsPath: string | undef
export function buildDocumentContext(base: string): DocumentContext {
return {
resolveReference: ref => {
// Following [css-loader](https://github.com/webpack-contrib/css-loader#url)
// And [sass-loader's](https://github.com/webpack-contrib/sass-loader#imports)
// Convention, if an import path starts with ~ then use node module resolution
// *unless* it starts with "~/" as this refers to the user's home directory.
if (ref[0] === '~' && ref[1] !== '/') {
ref = ref.substring(1);

if (base.startsWith('file:')) {
const moduleName = getModuleNameFromPath(ref);
const modulePath = resolvePathToModule(moduleName, base);

if (modulePath) {
return url.resolve(modulePath, ref);
}
}
}

return url.resolve(base, ref);
}
};
}

export function getModuleNameFromPath(filepath: string) {
/**
* If a scoped module (starts with @) then get up until second instance of '/',
* otherwise get until first instance of '/'.
*/
if (filepath[0] === '@') {
return filepath.substring(0, filepath.indexOf('/', filepath.indexOf('/') + 1));
}

return filepath.substring(0, filepath.indexOf('/'));
}

export function resolvePathToModule(moduleName: string, relativeTo: string): string | undefined {
const documentFolder = path.dirname(URI.parse(relativeTo).fsPath);
const packageDirectory = path.join(documentFolder, 'node_modules', moduleName);

if (fileExistsSync(packageDirectory)) {
return URI.file(packageDirectory).toString();
}

return undefined;
}

0 comments on commit 17c3e8b

Please sign in to comment.