diff --git a/extensions/markdown-language-features/src/languageFeatures/diagnostics.ts b/extensions/markdown-language-features/src/languageFeatures/diagnostics.ts index ef2d6733712..5ca5a22d063 100644 --- a/extensions/markdown-language-features/src/languageFeatures/diagnostics.ts +++ b/extensions/markdown-language-features/src/languageFeatures/diagnostics.ts @@ -7,8 +7,8 @@ import * as vscode from 'vscode'; import * as nls from 'vscode-nls'; import { MarkdownEngine } from '../markdownEngine'; import { TableOfContents } from '../tableOfContents'; -import { noopToken } from '../test/util'; import { Delayer } from '../util/async'; +import { noopToken } from '../util/cancellation'; import { Disposable } from '../util/dispose'; import { isMarkdownFile } from '../util/file'; import { MdWorkspaceContents, SkinnyTextDocument } from '../workspaceContents'; diff --git a/extensions/markdown-language-features/src/languageFeatures/references.ts b/extensions/markdown-language-features/src/languageFeatures/references.ts index b62de0b19ac..7695d5e4ba3 100644 --- a/extensions/markdown-language-features/src/languageFeatures/references.ts +++ b/extensions/markdown-language-features/src/languageFeatures/references.ts @@ -7,7 +7,7 @@ import * as uri from 'vscode-uri'; import { MarkdownEngine } from '../markdownEngine'; import { Slugifier } from '../slugify'; import { TableOfContents, TocEntry } from '../tableOfContents'; -import { noopToken } from '../test/util'; +import { noopToken } from '../util/cancellation'; import { Disposable } from '../util/dispose'; import { MdWorkspaceContents, SkinnyTextDocument } from '../workspaceContents'; import { InternalHref, MdLink, MdLinkProvider } from './documentLinkProvider'; diff --git a/extensions/markdown-language-features/src/test/definitionProvider.test.ts b/extensions/markdown-language-features/src/test/definitionProvider.test.ts index 735a074876a..23379965264 100644 --- a/extensions/markdown-language-features/src/test/definitionProvider.test.ts +++ b/extensions/markdown-language-features/src/test/definitionProvider.test.ts @@ -10,11 +10,12 @@ import { MdDefinitionProvider } from '../languageFeatures/definitionProvider'; import { MdLinkProvider } from '../languageFeatures/documentLinkProvider'; import { MdReferencesProvider } from '../languageFeatures/references'; import { githubSlugifier } from '../slugify'; +import { noopToken } from '../util/cancellation'; import { InMemoryDocument } from '../util/inMemoryDocument'; import { MdWorkspaceContents } from '../workspaceContents'; import { createNewMarkdownEngine } from './engine'; import { InMemoryWorkspaceMarkdownDocuments } from './inMemoryWorkspace'; -import { joinLines, noopToken, workspacePath } from './util'; +import { joinLines, workspacePath } from './util'; function getDefinition(doc: InMemoryDocument, pos: vscode.Position, workspaceContents: MdWorkspaceContents) { diff --git a/extensions/markdown-language-features/src/test/diagnostic.test.ts b/extensions/markdown-language-features/src/test/diagnostic.test.ts index 6f5556ad25f..5b631f334de 100644 --- a/extensions/markdown-language-features/src/test/diagnostic.test.ts +++ b/extensions/markdown-language-features/src/test/diagnostic.test.ts @@ -4,15 +4,16 @@ *--------------------------------------------------------------------------------------------*/ import * as assert from 'assert'; -import * as vscode from 'vscode'; import 'mocha'; +import * as vscode from 'vscode'; import { DiagnosticComputer, DiagnosticConfiguration, DiagnosticLevel, DiagnosticManager, DiagnosticOptions } from '../languageFeatures/diagnostics'; import { MdLinkProvider } from '../languageFeatures/documentLinkProvider'; +import { noopToken } from '../util/cancellation'; import { InMemoryDocument } from '../util/inMemoryDocument'; import { MdWorkspaceContents } from '../workspaceContents'; import { createNewMarkdownEngine } from './engine'; import { InMemoryWorkspaceMarkdownDocuments } from './inMemoryWorkspace'; -import { assertRangeEqual, joinLines, noopToken, workspacePath } from './util'; +import { assertRangeEqual, joinLines, workspacePath } from './util'; function getComputedDiagnostics(doc: InMemoryDocument, workspaceContents: MdWorkspaceContents) { diff --git a/extensions/markdown-language-features/src/test/documentLinkProvider.test.ts b/extensions/markdown-language-features/src/test/documentLinkProvider.test.ts index b7e43bf3a6e..7b504f24d6d 100644 --- a/extensions/markdown-language-features/src/test/documentLinkProvider.test.ts +++ b/extensions/markdown-language-features/src/test/documentLinkProvider.test.ts @@ -7,9 +7,10 @@ import * as assert from 'assert'; import 'mocha'; import * as vscode from 'vscode'; import { MdLinkProvider } from '../languageFeatures/documentLinkProvider'; -import { createNewMarkdownEngine } from './engine'; +import { noopToken } from '../util/cancellation'; import { InMemoryDocument } from '../util/inMemoryDocument'; -import { assertRangeEqual, joinLines, noopToken } from './util'; +import { createNewMarkdownEngine } from './engine'; +import { assertRangeEqual, joinLines } from './util'; const testFile = vscode.Uri.joinPath(vscode.workspace.workspaceFolders![0].uri, 'x.md'); diff --git a/extensions/markdown-language-features/src/test/fileReferences.test.ts b/extensions/markdown-language-features/src/test/fileReferences.test.ts index b949f7e51bf..7857f7364f9 100644 --- a/extensions/markdown-language-features/src/test/fileReferences.test.ts +++ b/extensions/markdown-language-features/src/test/fileReferences.test.ts @@ -9,11 +9,12 @@ import * as vscode from 'vscode'; import { MdLinkProvider } from '../languageFeatures/documentLinkProvider'; import { MdReference, MdReferencesProvider } from '../languageFeatures/references'; import { githubSlugifier } from '../slugify'; +import { noopToken } from '../util/cancellation'; import { InMemoryDocument } from '../util/inMemoryDocument'; import { MdWorkspaceContents } from '../workspaceContents'; import { createNewMarkdownEngine } from './engine'; import { InMemoryWorkspaceMarkdownDocuments } from './inMemoryWorkspace'; -import { joinLines, noopToken, workspacePath } from './util'; +import { joinLines, workspacePath } from './util'; function getFileReferences(resource: vscode.Uri, workspaceContents: MdWorkspaceContents) { diff --git a/extensions/markdown-language-features/src/test/pathCompletion.test.ts b/extensions/markdown-language-features/src/test/pathCompletion.test.ts index e8477bfda06..c5889627167 100644 --- a/extensions/markdown-language-features/src/test/pathCompletion.test.ts +++ b/extensions/markdown-language-features/src/test/pathCompletion.test.ts @@ -8,9 +8,10 @@ import 'mocha'; import * as vscode from 'vscode'; import { MdLinkProvider } from '../languageFeatures/documentLinkProvider'; import { MdPathCompletionProvider } from '../languageFeatures/pathCompletions'; +import { noopToken } from '../util/cancellation'; import { InMemoryDocument } from '../util/inMemoryDocument'; import { createNewMarkdownEngine } from './engine'; -import { CURSOR, getCursorPositions, joinLines, noopToken, workspacePath } from './util'; +import { CURSOR, getCursorPositions, joinLines, workspacePath } from './util'; function getCompletionsAtCursor(resource: vscode.Uri, fileContents: string) { diff --git a/extensions/markdown-language-features/src/test/references.test.ts b/extensions/markdown-language-features/src/test/references.test.ts index 3feed25fd9e..5eb8c54c5fd 100644 --- a/extensions/markdown-language-features/src/test/references.test.ts +++ b/extensions/markdown-language-features/src/test/references.test.ts @@ -9,11 +9,12 @@ import * as vscode from 'vscode'; import { MdLinkProvider } from '../languageFeatures/documentLinkProvider'; import { MdReferencesProvider } from '../languageFeatures/references'; import { githubSlugifier } from '../slugify'; +import { noopToken } from '../util/cancellation'; import { InMemoryDocument } from '../util/inMemoryDocument'; import { MdWorkspaceContents } from '../workspaceContents'; import { createNewMarkdownEngine } from './engine'; import { InMemoryWorkspaceMarkdownDocuments } from './inMemoryWorkspace'; -import { joinLines, noopToken, workspacePath } from './util'; +import { joinLines, workspacePath } from './util'; function getReferences(doc: InMemoryDocument, pos: vscode.Position, workspaceContents: MdWorkspaceContents) { diff --git a/extensions/markdown-language-features/src/test/rename.test.ts b/extensions/markdown-language-features/src/test/rename.test.ts index e34af63cd20..53839071ea4 100644 --- a/extensions/markdown-language-features/src/test/rename.test.ts +++ b/extensions/markdown-language-features/src/test/rename.test.ts @@ -10,11 +10,12 @@ import { MdLinkProvider } from '../languageFeatures/documentLinkProvider'; import { MdReferencesProvider } from '../languageFeatures/references'; import { MdRenameProvider, MdWorkspaceEdit } from '../languageFeatures/rename'; import { githubSlugifier } from '../slugify'; +import { noopToken } from '../util/cancellation'; import { InMemoryDocument } from '../util/inMemoryDocument'; import { MdWorkspaceContents } from '../workspaceContents'; import { createNewMarkdownEngine } from './engine'; import { InMemoryWorkspaceMarkdownDocuments } from './inMemoryWorkspace'; -import { assertRangeEqual, joinLines, noopToken, workspacePath } from './util'; +import { assertRangeEqual, joinLines, workspacePath } from './util'; /** diff --git a/extensions/markdown-language-features/src/test/util.ts b/extensions/markdown-language-features/src/test/util.ts index 9d83e488651..d2b4760e9d7 100644 --- a/extensions/markdown-language-features/src/test/util.ts +++ b/extensions/markdown-language-features/src/test/util.ts @@ -10,12 +10,6 @@ import { InMemoryDocument } from '../util/inMemoryDocument'; export const joinLines = (...args: string[]) => args.join(os.platform() === 'win32' ? '\r\n' : '\n'); -export const noopToken = new class implements vscode.CancellationToken { - _onCancellationRequestedEmitter = new vscode.EventEmitter(); - onCancellationRequested = this._onCancellationRequestedEmitter.event; - - get isCancellationRequested() { return false; } -}; export const CURSOR = '$$CURSOR$$'; diff --git a/extensions/markdown-language-features/src/util/cancellation.ts b/extensions/markdown-language-features/src/util/cancellation.ts new file mode 100644 index 00000000000..c0444de9abf --- /dev/null +++ b/extensions/markdown-language-features/src/util/cancellation.ts @@ -0,0 +1,13 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import * as vscode from 'vscode'; + +export const noopToken = new class implements vscode.CancellationToken { + _onCancellationRequestedEmitter = new vscode.EventEmitter(); + onCancellationRequested = this._onCancellationRequestedEmitter.event; + + get isCancellationRequested() { return false; } +};