mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-12 02:58:31 -05:00
Merge from vscode 2b0b9136329c181a9e381463a1f7dc3a2d105a34 (#4880)
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { mapArrayOrNot } from 'vs/base/common/arrays';
|
||||
import { CancellationTokenSource } from 'vs/base/common/cancellation';
|
||||
@@ -9,12 +10,11 @@ import { isPromiseCanceledError } from 'vs/base/common/errors';
|
||||
import { dispose } from 'vs/base/common/lifecycle';
|
||||
import { joinPath } from 'vs/base/common/resources';
|
||||
import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
import * as extfs from 'vs/base/node/extfs';
|
||||
import { IFileMatch, IFileQuery, IPatternInfo, IRawFileMatch2, ISearchCompleteStats, ISearchQuery, ITextQuery, QueryType, resultIsMatch } from 'vs/workbench/services/search/common/search';
|
||||
import * as pfs from 'vs/base/node/pfs';
|
||||
import { MainContext, MainThreadSearchShape } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { ExtHostSearch } from 'vs/workbench/api/node/extHostSearch';
|
||||
import { Range } from 'vs/workbench/api/node/extHostTypes';
|
||||
import { extensionResultIsMatch } from 'vs/workbench/services/search/node/textSearchManager';
|
||||
import { IFileMatch, IFileQuery, IPatternInfo, IRawFileMatch2, ISearchCompleteStats, ISearchQuery, ITextQuery, QueryType, resultIsMatch } from 'vs/workbench/services/search/common/search';
|
||||
import { TestRPCProtocol } from 'vs/workbench/test/electron-browser/api/testRPCProtocol';
|
||||
import { TestLogService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import * as vscode from 'vscode';
|
||||
@@ -55,7 +55,11 @@ class MockMainThreadSearch implements MainThreadSearchShape {
|
||||
}
|
||||
}
|
||||
|
||||
let mockExtfs: Partial<typeof extfs>;
|
||||
let mockPFS: Partial<typeof pfs>;
|
||||
|
||||
export function extensionResultIsMatch(data: vscode.TextSearchResult): data is vscode.TextSearchMatch {
|
||||
return !!(<vscode.TextSearchMatch>data).preview;
|
||||
}
|
||||
|
||||
suite('ExtHostSearch', () => {
|
||||
async function registerTestTextSearchProvider(provider: vscode.TextSearchProvider, scheme = 'file'): Promise<void> {
|
||||
@@ -130,8 +134,8 @@ suite('ExtHostSearch', () => {
|
||||
|
||||
rpcProtocol.set(MainContext.MainThreadSearch, mockMainThreadSearch);
|
||||
|
||||
mockExtfs = {};
|
||||
extHostSearch = new ExtHostSearch(rpcProtocol, null!, logService, mockExtfs as typeof extfs);
|
||||
mockPFS = {};
|
||||
extHostSearch = new ExtHostSearch(rpcProtocol, null!, logService, mockPFS as any);
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
@@ -856,14 +860,14 @@ suite('ExtHostSearch', () => {
|
||||
});
|
||||
|
||||
test('basic sibling clause', async () => {
|
||||
mockExtfs.readdir = (_path: string, callback: (error: Error, files: string[]) => void) => {
|
||||
mockPFS.readdir = (_path: string) => {
|
||||
if (_path === rootFolderA.fsPath) {
|
||||
callback(null!, [
|
||||
return Promise.resolve([
|
||||
'file1.js',
|
||||
'file1.ts'
|
||||
]);
|
||||
} else {
|
||||
callback(new Error('Wrong path'), null!);
|
||||
return Promise.reject(new Error('Wrong path'));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -899,21 +903,21 @@ suite('ExtHostSearch', () => {
|
||||
});
|
||||
|
||||
test('multiroot sibling clause', async () => {
|
||||
mockExtfs.readdir = (_path: string, callback: (error: Error, files: string[]) => void) => {
|
||||
mockPFS.readdir = (_path: string) => {
|
||||
if (_path === joinPath(rootFolderA, 'folder').fsPath) {
|
||||
callback(null!, [
|
||||
return Promise.resolve([
|
||||
'fileA.scss',
|
||||
'fileA.css',
|
||||
'file2.css'
|
||||
]);
|
||||
} else if (_path === rootFolderB.fsPath) {
|
||||
callback(null!, [
|
||||
return Promise.resolve([
|
||||
'fileB.ts',
|
||||
'fileB.js',
|
||||
'file3.js'
|
||||
]);
|
||||
} else {
|
||||
callback(new Error('Wrong path'), null!);
|
||||
return Promise.reject(new Error('Wrong path'));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import { TestInstantiationService } from 'vs/platform/instantiation/test/common/
|
||||
import { MainThreadConfiguration } from 'vs/workbench/api/browser/mainThreadConfiguration';
|
||||
import { SingleProxyRPCProtocol } from './testRPCProtocol';
|
||||
import { IConfigurationService, ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
|
||||
import { WorkspaceService } from 'vs/workbench/services/configuration/node/configurationService';
|
||||
import { WorkspaceService } from 'vs/workbench/services/configuration/browser/configurationService';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
|
||||
suite('MainThreadConfiguration', function () {
|
||||
|
||||
@@ -48,7 +48,6 @@ import { IRecentlyOpened, IRecent } from 'vs/platform/history/common/history';
|
||||
import { ITextResourceConfigurationService, ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration';
|
||||
import { IPosition, Position as EditorPosition } from 'vs/editor/common/core/position';
|
||||
import { IMenuService, MenuId, IMenu, ISerializableCommandAction } from 'vs/platform/actions/common/actions';
|
||||
import { IHashService } from 'vs/workbench/services/hash/common/hashService';
|
||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { MockContextKeyService, MockKeybindingService } from 'vs/platform/keybinding/test/common/mockKeybindingService';
|
||||
import { ITextBufferFactory, DefaultEndOfLine, EndOfLinePreference, IModelDecorationOptions, ITextModel } from 'vs/editor/common/model';
|
||||
@@ -309,7 +308,6 @@ export function workbenchInstantiationService(): IInstantiationService {
|
||||
instantiationService.stub(ITextFileService, <ITextFileService>instantiationService.createInstance(TestTextFileService));
|
||||
instantiationService.stub(ITextModelService, <ITextModelService>instantiationService.createInstance(TextModelResolverService));
|
||||
instantiationService.stub(IThemeService, new TestThemeService());
|
||||
instantiationService.stub(IHashService, new TestHashService());
|
||||
instantiationService.stub(ILogService, new TestLogService());
|
||||
instantiationService.stub(IEditorGroupsService, new TestEditorGroupsService([new TestEditorGroup(0)]));
|
||||
instantiationService.stub(ILabelService, <ILabelService>instantiationService.createInstance(LabelService));
|
||||
@@ -897,6 +895,7 @@ export class TestFileService implements IFileService {
|
||||
private readonly _onAfterOperation: Emitter<FileOperationEvent>;
|
||||
|
||||
readonly onWillActivateFileSystemProvider = Event.None;
|
||||
readonly onError: Event<Error> = Event.None;
|
||||
|
||||
private content = 'Hello Html';
|
||||
|
||||
@@ -1026,16 +1025,14 @@ export class TestFileService implements IFileService {
|
||||
return resource.scheme === 'file';
|
||||
}
|
||||
|
||||
hasCapability(resource: URI, capability: FileSystemProviderCapabilities): Promise<boolean> { return Promise.resolve(false); }
|
||||
hasCapability(resource: URI, capability: FileSystemProviderCapabilities): boolean { return false; }
|
||||
|
||||
del(_resource: URI, _options?: { useTrash?: boolean, recursive?: boolean }): Promise<void> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
watch(_resource: URI): void {
|
||||
}
|
||||
|
||||
unwatch(_resource: URI): void {
|
||||
watch(_resource: URI): IDisposable {
|
||||
return Disposable.None;
|
||||
}
|
||||
|
||||
getWriteEncoding(_resource: URI): IResourceEncoding {
|
||||
@@ -1556,14 +1553,6 @@ export class TestTextResourcePropertiesService implements ITextResourcePropertie
|
||||
}
|
||||
|
||||
|
||||
export class TestHashService implements IHashService {
|
||||
_serviceBrand: any;
|
||||
|
||||
createSHA1(content: string): Thenable<string> {
|
||||
return Promise.resolve(content);
|
||||
}
|
||||
}
|
||||
|
||||
export class TestSharedProcessService implements ISharedProcessService {
|
||||
|
||||
_serviceBrand: ServiceIdentifier<any>;
|
||||
@@ -1582,7 +1571,9 @@ export class NullFileSystemProvider implements IFileSystemProvider {
|
||||
onDidChangeCapabilities: Event<void> = Event.None;
|
||||
onDidChangeFile: Event<IFileChange[]> = Event.None;
|
||||
|
||||
watch(resource: URI, opts: IWatchOptions): IDisposable { return Disposable.None; }
|
||||
constructor(private disposableFactory: () => IDisposable = () => Disposable.None) { }
|
||||
|
||||
watch(resource: URI, opts: IWatchOptions): IDisposable { return this.disposableFactory(); }
|
||||
stat(resource: URI): Promise<IStat> { return Promise.resolve(undefined!); }
|
||||
mkdir(resource: URI): Promise<void> { return Promise.resolve(undefined!); }
|
||||
readdir(resource: URI): Promise<[string, FileType][]> { return Promise.resolve(undefined!); }
|
||||
|
||||
Reference in New Issue
Block a user