mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-26 03:29:00 +01:00
Merge with master
This commit is contained in:
@@ -115,7 +115,7 @@ export function createApiFactory(
|
||||
const extHostTerminalService = rpcProtocol.set(ExtHostContext.ExtHostTerminalService, new ExtHostTerminalService(rpcProtocol, extHostConfiguration, extHostLogService));
|
||||
const extHostDebugService = rpcProtocol.set(ExtHostContext.ExtHostDebugService, new ExtHostDebugService(rpcProtocol, extHostWorkspace, extensionService, extHostDocumentsAndEditors, extHostConfiguration, extHostTerminalService, extHostCommands));
|
||||
const extHostSCM = rpcProtocol.set(ExtHostContext.ExtHostSCM, new ExtHostSCM(rpcProtocol, extHostCommands, extHostLogService));
|
||||
const extHostSearch = rpcProtocol.set(ExtHostContext.ExtHostSearch, new ExtHostSearch(rpcProtocol, schemeTransformer, extHostLogService, extHostConfiguration));
|
||||
const extHostSearch = rpcProtocol.set(ExtHostContext.ExtHostSearch, new ExtHostSearch(rpcProtocol, schemeTransformer, extHostLogService));
|
||||
const extHostTask = rpcProtocol.set(ExtHostContext.ExtHostTask, new ExtHostTask(rpcProtocol, extHostWorkspace, extHostDocumentsAndEditors, extHostConfiguration, extHostTerminalService));
|
||||
const extHostWindow = rpcProtocol.set(ExtHostContext.ExtHostWindow, new ExtHostWindow(rpcProtocol));
|
||||
rpcProtocol.set(ExtHostContext.ExtHostExtensionService, extensionService);
|
||||
@@ -497,6 +497,9 @@ export function createApiFactory(
|
||||
createInputBox(): vscode.InputBox {
|
||||
return extHostQuickOpen.createInputBox(extension.identifier);
|
||||
},
|
||||
open: proposedApiFunction(extension, (uri: URI) => {
|
||||
return extHostWindow.openUri(uri);
|
||||
})
|
||||
};
|
||||
|
||||
// namespace: workspace
|
||||
|
||||
@@ -21,7 +21,7 @@ import { ICommandHandlerDescription } from 'vs/platform/commands/common/commands
|
||||
import { ConfigurationTarget, IConfigurationData, IConfigurationModel } from 'vs/platform/configuration/common/configuration';
|
||||
import { ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry';
|
||||
import { FileChangeType, FileDeleteOptions, FileOverwriteOptions, FileSystemProviderCapabilities, FileType, FileWriteOptions, IStat, IWatchOptions } from 'vs/platform/files/common/files';
|
||||
import { LabelRules } from 'vs/platform/label/common/label';
|
||||
import { ResourceLabelFormatter } from 'vs/platform/label/common/label';
|
||||
import { LogLevel } from 'vs/platform/log/common/log';
|
||||
import { IMarkerData } from 'vs/platform/markers/common/markers';
|
||||
import { IPickOptions, IQuickInputButton, IQuickPickItem } from 'vs/platform/quickinput/common/quickInput';
|
||||
@@ -512,7 +512,7 @@ export interface IFileChangeDto {
|
||||
export interface MainThreadFileSystemShape extends IDisposable {
|
||||
$registerFileSystemProvider(handle: number, scheme: string, capabilities: FileSystemProviderCapabilities): void;
|
||||
$unregisterProvider(handle: number): void;
|
||||
$setUriFormatter(scheme: string, formatter: LabelRules): void;
|
||||
$setUriFormatter(formatter: ResourceLabelFormatter): void;
|
||||
$onFileSystemChange(handle: number, resource: IFileChangeDto[]): void;
|
||||
}
|
||||
|
||||
@@ -623,6 +623,7 @@ export interface MainThreadDebugServiceShape extends IDisposable {
|
||||
|
||||
export interface MainThreadWindowShape extends IDisposable {
|
||||
$getWindowVisibility(): Promise<boolean>;
|
||||
$openUri(uri: UriComponents): Promise<any>;
|
||||
}
|
||||
|
||||
// -- extension host
|
||||
@@ -727,8 +728,8 @@ export interface ExtHostFileSystemShape {
|
||||
$unwatch(handle: number, session: number): void;
|
||||
$open(handle: number, resource: UriComponents): Promise<number>;
|
||||
$close(handle: number, fd: number): Promise<void>;
|
||||
$read(handle: number, fd: number, pos: number, data: Buffer, offset: number, length: number): Promise<number>;
|
||||
$write(handle: number, fd: number, pos: number, data: Buffer, offset: number, length: number): Promise<number>;
|
||||
$read(handle: number, fd: number, pos: number, length: number): Promise<Buffer>;
|
||||
$write(handle: number, fd: number, pos: number, data: Buffer): Promise<number>;
|
||||
}
|
||||
|
||||
export interface ExtHostSearchShape {
|
||||
@@ -741,6 +742,9 @@ export interface ExtHostExtensionServiceShape {
|
||||
$resolveAuthority(remoteAuthority: string): Promise<ResolvedAuthority>;
|
||||
$startExtensionHost(enabledExtensionIds: ExtensionIdentifier[]): Promise<void>;
|
||||
$activateByEvent(activationEvent: string): Promise<void>;
|
||||
$activate(extensionId: ExtensionIdentifier, activationEvent: string): Promise<void>;
|
||||
|
||||
$deltaExtensions(toAdd: IExtensionDescription[], toRemove: ExtensionIdentifier[]): Promise<void>;
|
||||
|
||||
$test_latency(n: number): Promise<number>;
|
||||
$test_up(b: Buffer): Promise<number>;
|
||||
@@ -862,6 +866,7 @@ export interface CodeActionDto {
|
||||
diagnostics?: IMarkerData[];
|
||||
command?: modes.Command;
|
||||
kind?: string;
|
||||
canAutoApply?: boolean;
|
||||
}
|
||||
|
||||
export interface ExtHostLanguageFeaturesShape {
|
||||
|
||||
@@ -662,6 +662,19 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
|
||||
);
|
||||
}
|
||||
|
||||
public $activate(extensionId: ExtensionIdentifier, activationEvent: string): Promise<void> {
|
||||
return (
|
||||
this._barrier.wait()
|
||||
.then(_ => this._activateById(extensionId, new ExtensionActivatedByEvent(false, activationEvent)))
|
||||
);
|
||||
}
|
||||
|
||||
public $deltaExtensions(toAdd: IExtensionDescription[], toRemove: ExtensionIdentifier[]): Promise<void> {
|
||||
toAdd.forEach((extension) => (<any>extension).extensionLocation = URI.revive(extension.extensionLocation));
|
||||
this._registry.deltaExtensions(toAdd, toRemove);
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
public async $test_latency(n: number): Promise<number> {
|
||||
return n;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import { FileChangeType, DocumentLink } from 'vs/workbench/api/node/extHostTypes
|
||||
import * as typeConverter from 'vs/workbench/api/node/extHostTypeConverters';
|
||||
import { ExtHostLanguageFeatures } from 'vs/workbench/api/node/extHostLanguageFeatures';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { LabelRules } from 'vs/platform/label/common/label';
|
||||
import { ResourceLabelFormatter } from 'vs/platform/label/common/label';
|
||||
import { State, StateMachine, LinkComputer } from 'vs/editor/common/modes/linkComputer';
|
||||
import { commonPrefixLength } from 'vs/base/common/strings';
|
||||
import { CharCode } from 'vs/base/common/charCode';
|
||||
@@ -127,6 +127,7 @@ export class ExtHostFileSystem implements ExtHostFileSystemShape {
|
||||
this._usedSchemes.add(Schemas.https);
|
||||
this._usedSchemes.add(Schemas.mailto);
|
||||
this._usedSchemes.add(Schemas.data);
|
||||
this._usedSchemes.add(Schemas.command);
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
@@ -205,8 +206,8 @@ export class ExtHostFileSystem implements ExtHostFileSystemShape {
|
||||
});
|
||||
}
|
||||
|
||||
setUriFormatter(scheme: string, formatter: LabelRules): void {
|
||||
this._proxy.$setUriFormatter(scheme, formatter);
|
||||
setUriFormatter(formatter: ResourceLabelFormatter): void {
|
||||
this._proxy.$setUriFormatter(formatter);
|
||||
}
|
||||
|
||||
private static _asIStat(stat: vscode.FileStat): files.IStat {
|
||||
@@ -289,14 +290,17 @@ export class ExtHostFileSystem implements ExtHostFileSystemShape {
|
||||
return Promise.resolve(this._fsProvider.get(handle).close(fd));
|
||||
}
|
||||
|
||||
$read(handle: number, fd: number, pos: number, data: Buffer, offset: number, length: number): Promise<number> {
|
||||
$read(handle: number, fd: number, pos: number, length: number): Promise<Buffer> {
|
||||
this._checkProviderExists(handle);
|
||||
return Promise.resolve(this._fsProvider.get(handle).read(fd, pos, data, offset, length));
|
||||
const data = Buffer.allocUnsafe(length);
|
||||
return Promise.resolve(this._fsProvider.get(handle).read(fd, pos, data, 0, length)).then(read => {
|
||||
return data.slice(0, read); // don't send zeros
|
||||
});
|
||||
}
|
||||
|
||||
$write(handle: number, fd: number, pos: number, data: Buffer, offset: number, length: number): Promise<number> {
|
||||
$write(handle: number, fd: number, pos: number, data: Buffer): Promise<number> {
|
||||
this._checkProviderExists(handle);
|
||||
return Promise.resolve(this._fsProvider.get(handle).write(fd, pos, data, offset, length));
|
||||
return Promise.resolve(this._fsProvider.get(handle).write(fd, pos, data, 0, data.length));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -282,6 +282,7 @@ export interface CustomCodeAction extends CodeActionDto {
|
||||
}
|
||||
|
||||
class CodeActionAdapter {
|
||||
private static readonly _maxCodeActionsPerFile: number = 1000;
|
||||
|
||||
constructor(
|
||||
private readonly _documents: ExtHostDocuments,
|
||||
@@ -302,7 +303,10 @@ class CodeActionAdapter {
|
||||
|
||||
for (const diagnostic of this._diagnostics.getDiagnostics(resource)) {
|
||||
if (ran.intersection(diagnostic.range)) {
|
||||
allDiagnostics.push(diagnostic);
|
||||
const newLen = allDiagnostics.push(diagnostic);
|
||||
if (newLen > CodeActionAdapter._maxCodeActionsPerFile) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,7 +346,8 @@ class CodeActionAdapter {
|
||||
command: candidate.command && this._commands.toInternal(candidate.command),
|
||||
diagnostics: candidate.diagnostics && candidate.diagnostics.map(typeConvert.Diagnostic.from),
|
||||
edit: candidate.edit && typeConvert.WorkspaceEdit.from(candidate.edit),
|
||||
kind: candidate.kind && candidate.kind.value
|
||||
kind: candidate.kind && candidate.kind.value,
|
||||
canAutoApply: candidate.canAutoApply,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
import * as extfs from 'vs/base/node/extfs';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { IFileQuery, IFolderQuery, IRawFileQuery, IRawQuery, IRawTextQuery, ISearchCompleteStats, ITextQuery } from 'vs/platform/search/common/search';
|
||||
import { ExtHostConfiguration, ExtHostConfigProvider } from 'vs/workbench/api/node/extHostConfiguration';
|
||||
import { FileIndexSearchManager } from 'vs/workbench/api/node/extHostSearch.fileIndex';
|
||||
import { FileSearchManager } from 'vs/workbench/services/search/node/fileSearchManager';
|
||||
import { SearchService } from 'vs/workbench/services/search/node/rawSearchService';
|
||||
@@ -41,14 +40,10 @@ export class ExtHostSearch implements ExtHostSearchShape {
|
||||
private _fileSearchManager: FileSearchManager;
|
||||
private _fileIndexSearchManager: FileIndexSearchManager;
|
||||
|
||||
constructor(mainContext: IMainContext, private _schemeTransformer: ISchemeTransformer, private _logService: ILogService, configService: ExtHostConfiguration, private _extfs = extfs) {
|
||||
constructor(mainContext: IMainContext, private _schemeTransformer: ISchemeTransformer, private _logService: ILogService, private _extfs = extfs) {
|
||||
this._proxy = mainContext.getProxy(MainContext.MainThreadSearch);
|
||||
this._fileSearchManager = new FileSearchManager();
|
||||
this._fileIndexSearchManager = new FileIndexSearchManager();
|
||||
|
||||
configService.getConfigProvider().then((configProvider) => {
|
||||
registerEHProviders(this, _logService, configProvider);
|
||||
});
|
||||
}
|
||||
|
||||
private _transformScheme(scheme: string): string {
|
||||
@@ -60,7 +55,7 @@ export class ExtHostSearch implements ExtHostSearchShape {
|
||||
|
||||
registerTextSearchProvider(scheme: string, provider: vscode.TextSearchProvider): IDisposable {
|
||||
if (this._textSearchUsedSchemes.has(scheme)) {
|
||||
throw new Error(`a provider for the scheme '${scheme}' is already registered`);
|
||||
throw new Error(`a text search provider for the scheme '${scheme}' is already registered`);
|
||||
}
|
||||
|
||||
this._textSearchUsedSchemes.add(scheme);
|
||||
@@ -76,7 +71,7 @@ export class ExtHostSearch implements ExtHostSearchShape {
|
||||
|
||||
registerFileSearchProvider(scheme: string, provider: vscode.FileSearchProvider): IDisposable {
|
||||
if (this._fileSearchUsedSchemes.has(scheme)) {
|
||||
throw new Error(`a provider for the scheme '${scheme}' is already registered`);
|
||||
throw new Error(`a file search provider for the scheme '${scheme}' is already registered`);
|
||||
}
|
||||
|
||||
this._fileSearchUsedSchemes.add(scheme);
|
||||
@@ -178,13 +173,10 @@ export class ExtHostSearch implements ExtHostSearchShape {
|
||||
}
|
||||
}
|
||||
|
||||
function registerEHProviders(extHostSearch: ExtHostSearch, logService: ILogService, configService: ExtHostConfigProvider) {
|
||||
if (configService.getConfiguration('searchRipgrep').enable || configService.getConfiguration('search').runInExtensionHost) {
|
||||
const outputChannel = new OutputChannel(logService);
|
||||
extHostSearch.registerTextSearchProvider('file', new RipgrepSearchProvider(outputChannel));
|
||||
|
||||
extHostSearch.registerInternalFileSearchProvider('file', new SearchService());
|
||||
}
|
||||
export function registerEHSearchProviders(extHostSearch: ExtHostSearch, logService: ILogService): void {
|
||||
const outputChannel = new OutputChannel(logService);
|
||||
extHostSearch.registerTextSearchProvider('file', new RipgrepSearchProvider(outputChannel));
|
||||
extHostSearch.registerInternalFileSearchProvider('file', new SearchService());
|
||||
}
|
||||
|
||||
function reviveQuery<U extends IRawQuery>(rawQuery: U): U extends IRawTextQuery ? ITextQuery : IFileQuery {
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { ExtHostWindowShape, MainContext, MainThreadWindowShape, IMainContext } from './extHost.protocol';
|
||||
import { WindowState } from 'vscode';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
|
||||
export class ExtHostWindow implements ExtHostWindowShape {
|
||||
|
||||
@@ -34,4 +35,8 @@ export class ExtHostWindow implements ExtHostWindowShape {
|
||||
this._state = { ...this._state, focused };
|
||||
this._onDidChangeWindowState.fire(this._state);
|
||||
}
|
||||
|
||||
openUri(uri: URI): Promise<boolean> {
|
||||
return this._proxy.$openUri(uri);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user