mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 18:49:00 +01:00
move onDidRename to filesystem-events things, #43768
This commit is contained in:
@@ -576,8 +576,8 @@ export function createApiFactory(
|
||||
registerWorkspaceCommentProvider: proposedApiFunction(extension, (provider: vscode.WorkspaceCommentProvider) => {
|
||||
return exthostCommentProviders.registerWorkspaceCommentProvider(provider);
|
||||
}),
|
||||
onDidRenameResource: proposedApiFunction(extension, (listener, thisArg?, disposables?) => {
|
||||
return extHostDocuments.onDidRenameResource(listener, thisArg, disposables);
|
||||
onDidRenameFile: proposedApiFunction(extension, (listener, thisArg?, disposables?) => {
|
||||
return extHostFileSystemEvent.onDidRenameFile(listener, thisArg, disposables);
|
||||
})
|
||||
};
|
||||
|
||||
|
||||
@@ -614,7 +614,6 @@ export interface ExtHostDocumentsShape {
|
||||
$acceptModelSaved(strURL: UriComponents): void;
|
||||
$acceptDirtyStateChanged(strURL: UriComponents, isDirty: boolean): void;
|
||||
$acceptModelChanged(strURL: UriComponents, e: IModelChangedEvent, isDirty: boolean): void;
|
||||
$onDidRename(oldURL: UriComponents, newURL: UriComponents): void;
|
||||
}
|
||||
|
||||
export interface ExtHostDocumentSaveParticipantShape {
|
||||
@@ -698,6 +697,7 @@ export interface FileSystemEvents {
|
||||
}
|
||||
export interface ExtHostFileSystemEventServiceShape {
|
||||
$onFileEvent(events: FileSystemEvents): void;
|
||||
$onFileRename(oldUri: UriComponents, newUri: UriComponents): void;
|
||||
}
|
||||
|
||||
export interface ObjectIdentifier {
|
||||
|
||||
@@ -21,13 +21,11 @@ export class ExtHostDocuments implements ExtHostDocumentsShape {
|
||||
private _onDidRemoveDocument = new Emitter<vscode.TextDocument>();
|
||||
private _onDidChangeDocument = new Emitter<vscode.TextDocumentChangeEvent>();
|
||||
private _onDidSaveDocument = new Emitter<vscode.TextDocument>();
|
||||
private _onDidRenameResource = new Emitter<vscode.ResourceRenamedEvent>();
|
||||
|
||||
readonly onDidAddDocument: Event<vscode.TextDocument> = this._onDidAddDocument.event;
|
||||
readonly onDidRemoveDocument: Event<vscode.TextDocument> = this._onDidRemoveDocument.event;
|
||||
readonly onDidChangeDocument: Event<vscode.TextDocumentChangeEvent> = this._onDidChangeDocument.event;
|
||||
readonly onDidSaveDocument: Event<vscode.TextDocument> = this._onDidSaveDocument.event;
|
||||
readonly onDidRenameResource: Event<vscode.ResourceRenamedEvent> = this._onDidRenameResource.event;
|
||||
|
||||
private _toDispose: IDisposable[];
|
||||
private _proxy: MainThreadDocumentsShape;
|
||||
@@ -150,11 +148,4 @@ export class ExtHostDocuments implements ExtHostDocumentsShape {
|
||||
public setWordDefinitionFor(modeId: string, wordDefinition: RegExp): void {
|
||||
setWordDefinitionFor(modeId, wordDefinition);
|
||||
}
|
||||
|
||||
public $onDidRename(oldURL: UriComponents, newURL: UriComponents): void {
|
||||
const oldResource = URI.revive(oldURL);
|
||||
const newResource = URI.revive(newURL);
|
||||
this._onDidRenameResource.fire({ oldResource, newResource });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,18 +4,18 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { IRelativePattern, parse } from 'vs/base/common/glob';
|
||||
import URI, { UriComponents } from 'vs/base/common/uri';
|
||||
import * as vscode from 'vscode';
|
||||
import { ExtHostFileSystemEventServiceShape, FileSystemEvents } from './extHost.protocol';
|
||||
import { Disposable } from './extHostTypes';
|
||||
import { parse, IRelativePattern } from 'vs/base/common/glob';
|
||||
import { Uri, FileSystemWatcher as _FileSystemWatcher } from 'vscode';
|
||||
import { FileSystemEvents, ExtHostFileSystemEventServiceShape } from './extHost.protocol';
|
||||
import URI from 'vs/base/common/uri';
|
||||
|
||||
class FileSystemWatcher implements _FileSystemWatcher {
|
||||
class FileSystemWatcher implements vscode.FileSystemWatcher {
|
||||
|
||||
private _onDidCreate = new Emitter<Uri>();
|
||||
private _onDidChange = new Emitter<Uri>();
|
||||
private _onDidDelete = new Emitter<Uri>();
|
||||
private _onDidCreate = new Emitter<vscode.Uri>();
|
||||
private _onDidChange = new Emitter<vscode.Uri>();
|
||||
private _onDidDelete = new Emitter<vscode.Uri>();
|
||||
private _disposable: Disposable;
|
||||
private _config: number;
|
||||
|
||||
@@ -80,31 +80,38 @@ class FileSystemWatcher implements _FileSystemWatcher {
|
||||
this._disposable.dispose();
|
||||
}
|
||||
|
||||
get onDidCreate(): Event<Uri> {
|
||||
get onDidCreate(): Event<vscode.Uri> {
|
||||
return this._onDidCreate.event;
|
||||
}
|
||||
|
||||
get onDidChange(): Event<Uri> {
|
||||
get onDidChange(): Event<vscode.Uri> {
|
||||
return this._onDidChange.event;
|
||||
}
|
||||
|
||||
get onDidDelete(): Event<Uri> {
|
||||
get onDidDelete(): Event<vscode.Uri> {
|
||||
return this._onDidDelete.event;
|
||||
}
|
||||
}
|
||||
|
||||
export class ExtHostFileSystemEventService implements ExtHostFileSystemEventServiceShape {
|
||||
|
||||
private _emitter = new Emitter<FileSystemEvents>();
|
||||
private _onFileEvent = new Emitter<FileSystemEvents>();
|
||||
private _onDidRenameFile = new Emitter<vscode.FileRenameEvent>();
|
||||
|
||||
readonly onDidRenameFile: Event<vscode.FileRenameEvent> = this._onDidRenameFile.event;
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
public createFileSystemWatcher(globPattern: string | IRelativePattern, ignoreCreateEvents?: boolean, ignoreChangeEvents?: boolean, ignoreDeleteEvents?: boolean): _FileSystemWatcher {
|
||||
return new FileSystemWatcher(this._emitter.event, globPattern, ignoreCreateEvents, ignoreChangeEvents, ignoreDeleteEvents);
|
||||
public createFileSystemWatcher(globPattern: string | IRelativePattern, ignoreCreateEvents?: boolean, ignoreChangeEvents?: boolean, ignoreDeleteEvents?: boolean): vscode.FileSystemWatcher {
|
||||
return new FileSystemWatcher(this._onFileEvent.event, globPattern, ignoreCreateEvents, ignoreChangeEvents, ignoreDeleteEvents);
|
||||
}
|
||||
|
||||
$onFileEvent(events: FileSystemEvents) {
|
||||
this._emitter.fire(events);
|
||||
this._onFileEvent.fire(events);
|
||||
}
|
||||
|
||||
$onFileRename(oldUri: UriComponents, newUri: UriComponents) {
|
||||
this._onDidRenameFile.fire(Object.freeze({ oldUri: URI.revive(oldUri), newUri: URI.revive(newUri) }));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user