mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-14 18:46:34 -05:00
Merge from vscode 8e0f348413f4f616c23a88ae30030efa85811973 (#6381)
* Merge from vscode 8e0f348413f4f616c23a88ae30030efa85811973 * disable strict null check
This commit is contained in:
@@ -3,13 +3,13 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { addClasses, createCSSRule, removeClasses } from 'vs/base/browser/dom';
|
||||
import { addClasses, createCSSRule, removeClasses, asDomUri } from 'vs/base/browser/dom';
|
||||
import { domEvent } from 'vs/base/browser/event';
|
||||
import { ActionViewItem, Separator } from 'vs/base/browser/ui/actionbar/actionbar';
|
||||
import { IAction } from 'vs/base/common/actions';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { IdGenerator } from 'vs/base/common/idGenerator';
|
||||
import { dispose, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IDisposable, toDisposable, MutableDisposable, DisposableStore, dispose } from 'vs/base/common/lifecycle';
|
||||
import { isLinux, isWindows } from 'vs/base/common/platform';
|
||||
import { localize } from 'vs/nls';
|
||||
import { ICommandAction, IMenu, IMenuActionOptions, MenuItemAction, SubmenuItemAction } from 'vs/platform/actions/common/actions';
|
||||
@@ -20,7 +20,7 @@ import { INotificationService } from 'vs/platform/notification/common/notificati
|
||||
// The alternative key on all platforms is alt. On windows we also support shift as an alternative key #44136
|
||||
class AlternativeKeyEmitter extends Emitter<boolean> {
|
||||
|
||||
private _subscriptions: IDisposable[] = [];
|
||||
private readonly _subscriptions = new DisposableStore();
|
||||
private _isPressed: boolean;
|
||||
private static instance: AlternativeKeyEmitter;
|
||||
private _suppressAltKeyUp: boolean = false;
|
||||
@@ -28,10 +28,10 @@ class AlternativeKeyEmitter extends Emitter<boolean> {
|
||||
private constructor(contextMenuService: IContextMenuService) {
|
||||
super();
|
||||
|
||||
this._subscriptions.push(domEvent(document.body, 'keydown')(e => {
|
||||
this._subscriptions.add(domEvent(document.body, 'keydown')(e => {
|
||||
this.isPressed = e.altKey || ((isWindows || isLinux) && e.shiftKey);
|
||||
}));
|
||||
this._subscriptions.push(domEvent(document.body, 'keyup')(e => {
|
||||
this._subscriptions.add(domEvent(document.body, 'keyup')(e => {
|
||||
if (this.isPressed) {
|
||||
if (this._suppressAltKeyUp) {
|
||||
e.preventDefault();
|
||||
@@ -41,10 +41,10 @@ class AlternativeKeyEmitter extends Emitter<boolean> {
|
||||
this._suppressAltKeyUp = false;
|
||||
this.isPressed = false;
|
||||
}));
|
||||
this._subscriptions.push(domEvent(document.body, 'mouseleave')(e => this.isPressed = false));
|
||||
this._subscriptions.push(domEvent(document.body, 'blur')(e => this.isPressed = false));
|
||||
this._subscriptions.add(domEvent(document.body, 'mouseleave')(e => this.isPressed = false));
|
||||
this._subscriptions.add(domEvent(document.body, 'blur')(e => this.isPressed = false));
|
||||
// Workaround since we do not get any events while a context menu is shown
|
||||
this._subscriptions.push(contextMenuService.onDidContextMenu(() => this.isPressed = false));
|
||||
this._subscriptions.add(contextMenuService.onDidContextMenu(() => this.isPressed = false));
|
||||
}
|
||||
|
||||
get isPressed(): boolean {
|
||||
@@ -72,25 +72,36 @@ class AlternativeKeyEmitter extends Emitter<boolean> {
|
||||
|
||||
dispose() {
|
||||
super.dispose();
|
||||
this._subscriptions = dispose(this._subscriptions);
|
||||
this._subscriptions.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
export function fillInContextMenuActions(menu: IMenu, options: IMenuActionOptions | undefined, target: IAction[] | { primary: IAction[]; secondary: IAction[]; }, contextMenuService: IContextMenuService, isPrimaryGroup?: (group: string) => boolean): void {
|
||||
export function createAndFillInContextMenuActions(menu: IMenu, options: IMenuActionOptions | undefined, target: IAction[] | { primary: IAction[]; secondary: IAction[]; }, contextMenuService: IContextMenuService, isPrimaryGroup?: (group: string) => boolean): IDisposable {
|
||||
const groups = menu.getActions(options);
|
||||
const getAlternativeActions = AlternativeKeyEmitter.getInstance(contextMenuService).isPressed;
|
||||
|
||||
fillInActions(groups, target, getAlternativeActions, isPrimaryGroup);
|
||||
const useAlternativeActions = AlternativeKeyEmitter.getInstance(contextMenuService).isPressed;
|
||||
fillInActions(groups, target, useAlternativeActions, isPrimaryGroup);
|
||||
return asDisposable(groups);
|
||||
}
|
||||
|
||||
export function fillInActionBarActions(menu: IMenu, options: IMenuActionOptions | undefined, target: IAction[] | { primary: IAction[]; secondary: IAction[]; }, isPrimaryGroup?: (group: string) => boolean): void {
|
||||
export function createAndFillInActionBarActions(menu: IMenu, options: IMenuActionOptions | undefined, target: IAction[] | { primary: IAction[]; secondary: IAction[]; }, isPrimaryGroup?: (group: string) => boolean): IDisposable {
|
||||
const groups = menu.getActions(options);
|
||||
// Action bars handle alternative actions on their own so the alternative actions should be ignored
|
||||
fillInActions(groups, target, false, isPrimaryGroup);
|
||||
return asDisposable(groups);
|
||||
}
|
||||
|
||||
function asDisposable(groups: ReadonlyArray<[string, ReadonlyArray<MenuItemAction | SubmenuItemAction>]>): IDisposable {
|
||||
const disposables = new DisposableStore();
|
||||
for (const [, actions] of groups) {
|
||||
for (const action of actions) {
|
||||
disposables.add(action);
|
||||
}
|
||||
}
|
||||
return disposables;
|
||||
}
|
||||
|
||||
// {{SQL CARBON EDIT}} add export modifier
|
||||
export function fillInActions(groups: [string, Array<MenuItemAction | SubmenuItemAction>][], target: IAction[] | { primary: IAction[]; secondary: IAction[]; }, useAlternativeActions: boolean, isPrimaryGroup: (group: string) => boolean = group => group === 'navigation'): void {
|
||||
export function fillInActions(groups: ReadonlyArray<[string, ReadonlyArray<MenuItemAction | SubmenuItemAction>]>, target: IAction[] | { primary: IAction[]; secondary: IAction[]; }, useAlternativeActions: boolean, isPrimaryGroup: (group: string) => boolean = group => group === 'navigation'): void {
|
||||
for (let tuple of groups) {
|
||||
let [group, actions] = tuple;
|
||||
if (useAlternativeActions) {
|
||||
@@ -128,7 +139,7 @@ export class MenuEntryActionViewItem extends ActionViewItem {
|
||||
static readonly ICON_PATH_TO_CSS_RULES: Map<string /* path*/, string /* CSS rule */> = new Map<string, string>();
|
||||
|
||||
private _wantsAltCommand: boolean;
|
||||
private _itemClassDispose?: IDisposable;
|
||||
private readonly _itemClassDispose = this._register(new MutableDisposable());
|
||||
private readonly _altKey: AlternativeKeyEmitter;
|
||||
|
||||
constructor(
|
||||
@@ -223,8 +234,7 @@ export class MenuEntryActionViewItem extends ActionViewItem {
|
||||
}
|
||||
|
||||
_updateItemClass(item: ICommandAction): void {
|
||||
dispose(this._itemClassDispose);
|
||||
this._itemClassDispose = undefined;
|
||||
this._itemClassDispose.value = undefined;
|
||||
|
||||
if (item.iconLocation) {
|
||||
let iconClass: string;
|
||||
@@ -235,24 +245,15 @@ export class MenuEntryActionViewItem extends ActionViewItem {
|
||||
iconClass = MenuEntryActionViewItem.ICON_PATH_TO_CSS_RULES.get(iconPathMapKey)!;
|
||||
} else {
|
||||
iconClass = ids.nextId();
|
||||
createCSSRule(`.icon.${iconClass}`, `background-image: url("${(item.iconLocation.light || item.iconLocation.dark).toString()}")`);
|
||||
createCSSRule(`.vs-dark .icon.${iconClass}, .hc-black .icon.${iconClass}`, `background-image: url("${item.iconLocation.dark.toString()}")`);
|
||||
createCSSRule(`.icon.${iconClass}`, `background-image: url("${asDomUri(item.iconLocation.light || item.iconLocation.dark).toString()}")`);
|
||||
createCSSRule(`.vs-dark .icon.${iconClass}, .hc-black .icon.${iconClass}`, `background-image: url("${asDomUri(item.iconLocation.dark).toString()}")`);
|
||||
MenuEntryActionViewItem.ICON_PATH_TO_CSS_RULES.set(iconPathMapKey, iconClass);
|
||||
}
|
||||
|
||||
addClasses(this.label, 'icon', iconClass);
|
||||
this._itemClassDispose = toDisposable(() => removeClasses(this.label, 'icon', iconClass));
|
||||
this._itemClassDispose.value = toDisposable(() => removeClasses(this.label, 'icon', iconClass));
|
||||
}
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
if (this._itemClassDispose) {
|
||||
dispose(this._itemClassDispose);
|
||||
this._itemClassDispose = undefined;
|
||||
}
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
// Need to subclass MenuEntryActionViewItem in order to respect
|
||||
|
||||
@@ -103,7 +103,8 @@ export const enum MenuId {
|
||||
CommentThreadTitle,
|
||||
CommentThreadActions,
|
||||
CommentTitle,
|
||||
CommentActions
|
||||
CommentActions,
|
||||
GlobalActivity
|
||||
}
|
||||
|
||||
export interface IMenuActionOptions {
|
||||
@@ -125,64 +126,61 @@ export interface IMenuService {
|
||||
createMenu(id: MenuId, scopedKeybindingService: IContextKeyService): IMenu;
|
||||
}
|
||||
|
||||
export type ICommandsMap = Map<string, ICommandAction>;
|
||||
|
||||
export interface IMenuRegistry {
|
||||
addCommand(userCommand: ICommandAction): IDisposable;
|
||||
getCommand(id: string): ICommandAction;
|
||||
getCommand(id: string): ICommandAction | undefined;
|
||||
getCommands(): ICommandsMap;
|
||||
appendMenuItem(menu: MenuId, item: IMenuItem | ISubmenuItem): IDisposable;
|
||||
getMenuItems(loc: MenuId): Array<IMenuItem | ISubmenuItem>;
|
||||
readonly onDidChangeMenu: Event<MenuId>;
|
||||
}
|
||||
|
||||
export interface ICommandsMap {
|
||||
[id: string]: ICommandAction;
|
||||
}
|
||||
|
||||
export const MenuRegistry: IMenuRegistry = new class implements IMenuRegistry {
|
||||
|
||||
private readonly _commands: { [id: string]: ICommandAction } = Object.create(null);
|
||||
private readonly _menuItems: { [loc: number]: Array<IMenuItem | ISubmenuItem> } = Object.create(null);
|
||||
private readonly _commands = new Map<string, ICommandAction>();
|
||||
private readonly _menuItems = new Map<number, Array<IMenuItem | ISubmenuItem>>();
|
||||
private readonly _onDidChangeMenu = new Emitter<MenuId>();
|
||||
|
||||
readonly onDidChangeMenu: Event<MenuId> = this._onDidChangeMenu.event;
|
||||
|
||||
addCommand(command: ICommandAction): IDisposable {
|
||||
this._commands[command.id] = command;
|
||||
this._commands.set(command.id, command);
|
||||
this._onDidChangeMenu.fire(MenuId.CommandPalette);
|
||||
return {
|
||||
dispose: () => {
|
||||
if (delete this._commands[command.id]) {
|
||||
if (this._commands.delete(command.id)) {
|
||||
this._onDidChangeMenu.fire(MenuId.CommandPalette);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
getCommand(id: string): ICommandAction {
|
||||
return this._commands[id];
|
||||
getCommand(id: string): ICommandAction | undefined {
|
||||
return this._commands.get(id);
|
||||
}
|
||||
|
||||
getCommands(): ICommandsMap {
|
||||
const result: ICommandsMap = Object.create(null);
|
||||
for (const key in this._commands) {
|
||||
result[key] = this.getCommand(key);
|
||||
}
|
||||
return result;
|
||||
const map = new Map<string, ICommandAction>();
|
||||
this._commands.forEach((value, key) => map.set(key, value));
|
||||
return map;
|
||||
}
|
||||
|
||||
appendMenuItem(id: MenuId, item: IMenuItem | ISubmenuItem): IDisposable {
|
||||
let array = this._menuItems[id];
|
||||
let array = this._menuItems.get(id);
|
||||
if (!array) {
|
||||
this._menuItems[id] = array = [item];
|
||||
array = [item];
|
||||
this._menuItems.set(id, array);
|
||||
} else {
|
||||
array.push(item);
|
||||
}
|
||||
this._onDidChangeMenu.fire(id);
|
||||
return {
|
||||
dispose: () => {
|
||||
const idx = array.indexOf(item);
|
||||
const idx = array!.indexOf(item);
|
||||
if (idx >= 0) {
|
||||
array.splice(idx, 1);
|
||||
array!.splice(idx, 1);
|
||||
this._onDidChangeMenu.fire(id);
|
||||
}
|
||||
}
|
||||
@@ -190,7 +188,7 @@ export const MenuRegistry: IMenuRegistry = new class implements IMenuRegistry {
|
||||
}
|
||||
|
||||
getMenuItems(id: MenuId): Array<IMenuItem | ISubmenuItem> {
|
||||
const result = (this._menuItems[id] || []).slice(0);
|
||||
const result = (this._menuItems.get(id) || []).slice(0);
|
||||
|
||||
if (id === MenuId.CommandPalette) {
|
||||
// CommandPalette is special because it shows
|
||||
@@ -211,11 +209,11 @@ export const MenuRegistry: IMenuRegistry = new class implements IMenuRegistry {
|
||||
set.add(alt.id);
|
||||
}
|
||||
}
|
||||
for (let id in this._commands) {
|
||||
this._commands.forEach((command, id) => {
|
||||
if (!set.has(id)) {
|
||||
result.push({ command: this._commands[id] });
|
||||
result.push({ command });
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -268,6 +266,13 @@ export class MenuItemAction extends ExecuteCommandAction {
|
||||
this.alt = alt ? new MenuItemAction(alt, undefined, this._options, contextKeyService, commandService) : undefined;
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
if (this.alt) {
|
||||
this.alt.dispose();
|
||||
}
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
run(...args: any[]): Promise<any> {
|
||||
let runArgs: any[] = [];
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IMenu, IMenuActionOptions, IMenuItem, IMenuService, isIMenuItem, ISubmenuItem, MenuId, MenuItemAction, MenuRegistry, SubmenuItemAction } from 'vs/platform/actions/common/actions';
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { ContextKeyExpr, IContextKeyService, IContextKeyChangeEvent } from 'vs/platform/contextkey/common/contextkey';
|
||||
@@ -27,10 +27,9 @@ export class MenuService implements IMenuService {
|
||||
|
||||
type MenuItemGroup = [string, Array<IMenuItem | ISubmenuItem>];
|
||||
|
||||
class Menu implements IMenu {
|
||||
class Menu extends Disposable implements IMenu {
|
||||
|
||||
private readonly _onDidChange = new Emitter<IMenu | undefined>();
|
||||
private readonly _disposables: IDisposable[] = [];
|
||||
private readonly _onDidChange = this._register(new Emitter<IMenu | undefined>());
|
||||
|
||||
private _menuGroups: MenuItemGroup[];
|
||||
private _contextKeys: Set<string>;
|
||||
@@ -40,23 +39,24 @@ class Menu implements IMenu {
|
||||
@ICommandService private readonly _commandService: ICommandService,
|
||||
@IContextKeyService private readonly _contextKeyService: IContextKeyService
|
||||
) {
|
||||
super();
|
||||
this._build();
|
||||
|
||||
// rebuild this menu whenever the menu registry reports an
|
||||
// event for this MenuId
|
||||
Event.debounce(
|
||||
this._register(Event.debounce(
|
||||
Event.filter(MenuRegistry.onDidChangeMenu, menuId => menuId === this._id),
|
||||
() => { },
|
||||
50
|
||||
)(this._build, this, this._disposables);
|
||||
)(this._build, this));
|
||||
|
||||
// when context keys change we need to check if the menu also
|
||||
// has changed
|
||||
Event.debounce<IContextKeyChangeEvent, boolean>(
|
||||
this._register(Event.debounce<IContextKeyChangeEvent, boolean>(
|
||||
this._contextKeyService.onDidChangeContext,
|
||||
(last, event) => last || event.affectsSome(this._contextKeys),
|
||||
50
|
||||
)(e => e && this._onDidChange.fire(undefined), this, this._disposables);
|
||||
)(e => e && this._onDidChange.fire(undefined), this));
|
||||
}
|
||||
|
||||
private _build(): void {
|
||||
@@ -95,11 +95,6 @@ class Menu implements IMenu {
|
||||
this._onDidChange.fire(this);
|
||||
}
|
||||
|
||||
dispose() {
|
||||
dispose(this._disposables);
|
||||
this._onDidChange.dispose();
|
||||
}
|
||||
|
||||
get onDidChange(): Event<IMenu | undefined> {
|
||||
return this._onDidChange.event;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import * as assert from 'assert';
|
||||
import { MenuRegistry, MenuId, isIMenuItem } from 'vs/platform/actions/common/actions';
|
||||
import { MenuService } from 'vs/platform/actions/common/menuService';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { NullCommandService } from 'vs/platform/commands/common/commands';
|
||||
import { MockContextKeyService } from 'vs/platform/keybinding/test/common/mockKeybindingService';
|
||||
|
||||
@@ -23,42 +23,42 @@ const contextKeyService = new class extends MockContextKeyService {
|
||||
suite('MenuService', function () {
|
||||
|
||||
let menuService: MenuService;
|
||||
let disposables: IDisposable[];
|
||||
const disposables = new DisposableStore();
|
||||
let testMenuId: MenuId;
|
||||
|
||||
setup(function () {
|
||||
menuService = new MenuService(NullCommandService);
|
||||
testMenuId = Math.PI;
|
||||
disposables = [];
|
||||
disposables.clear();
|
||||
});
|
||||
|
||||
teardown(function () {
|
||||
dispose(disposables);
|
||||
disposables.clear();
|
||||
});
|
||||
|
||||
test('group sorting', function () {
|
||||
|
||||
disposables.push(MenuRegistry.appendMenuItem(testMenuId, {
|
||||
disposables.add(MenuRegistry.appendMenuItem(testMenuId, {
|
||||
command: { id: 'one', title: 'FOO' },
|
||||
group: '0_hello'
|
||||
}));
|
||||
|
||||
disposables.push(MenuRegistry.appendMenuItem(testMenuId, {
|
||||
disposables.add(MenuRegistry.appendMenuItem(testMenuId, {
|
||||
command: { id: 'two', title: 'FOO' },
|
||||
group: 'hello'
|
||||
}));
|
||||
|
||||
disposables.push(MenuRegistry.appendMenuItem(testMenuId, {
|
||||
disposables.add(MenuRegistry.appendMenuItem(testMenuId, {
|
||||
command: { id: 'three', title: 'FOO' },
|
||||
group: 'Hello'
|
||||
}));
|
||||
|
||||
disposables.push(MenuRegistry.appendMenuItem(testMenuId, {
|
||||
disposables.add(MenuRegistry.appendMenuItem(testMenuId, {
|
||||
command: { id: 'four', title: 'FOO' },
|
||||
group: ''
|
||||
}));
|
||||
|
||||
disposables.push(MenuRegistry.appendMenuItem(testMenuId, {
|
||||
disposables.add(MenuRegistry.appendMenuItem(testMenuId, {
|
||||
command: { id: 'five', title: 'FOO' },
|
||||
group: 'navigation'
|
||||
}));
|
||||
@@ -77,17 +77,17 @@ suite('MenuService', function () {
|
||||
|
||||
test('in group sorting, by title', function () {
|
||||
|
||||
disposables.push(MenuRegistry.appendMenuItem(testMenuId, {
|
||||
disposables.add(MenuRegistry.appendMenuItem(testMenuId, {
|
||||
command: { id: 'a', title: 'aaa' },
|
||||
group: 'Hello'
|
||||
}));
|
||||
|
||||
disposables.push(MenuRegistry.appendMenuItem(testMenuId, {
|
||||
disposables.add(MenuRegistry.appendMenuItem(testMenuId, {
|
||||
command: { id: 'b', title: 'fff' },
|
||||
group: 'Hello'
|
||||
}));
|
||||
|
||||
disposables.push(MenuRegistry.appendMenuItem(testMenuId, {
|
||||
disposables.add(MenuRegistry.appendMenuItem(testMenuId, {
|
||||
command: { id: 'c', title: 'zzz' },
|
||||
group: 'Hello'
|
||||
}));
|
||||
@@ -106,24 +106,24 @@ suite('MenuService', function () {
|
||||
|
||||
test('in group sorting, by title and order', function () {
|
||||
|
||||
disposables.push(MenuRegistry.appendMenuItem(testMenuId, {
|
||||
disposables.add(MenuRegistry.appendMenuItem(testMenuId, {
|
||||
command: { id: 'a', title: 'aaa' },
|
||||
group: 'Hello',
|
||||
order: 10
|
||||
}));
|
||||
|
||||
disposables.push(MenuRegistry.appendMenuItem(testMenuId, {
|
||||
disposables.add(MenuRegistry.appendMenuItem(testMenuId, {
|
||||
command: { id: 'b', title: 'fff' },
|
||||
group: 'Hello'
|
||||
}));
|
||||
|
||||
disposables.push(MenuRegistry.appendMenuItem(testMenuId, {
|
||||
disposables.add(MenuRegistry.appendMenuItem(testMenuId, {
|
||||
command: { id: 'c', title: 'zzz' },
|
||||
group: 'Hello',
|
||||
order: -1
|
||||
}));
|
||||
|
||||
disposables.push(MenuRegistry.appendMenuItem(testMenuId, {
|
||||
disposables.add(MenuRegistry.appendMenuItem(testMenuId, {
|
||||
command: { id: 'd', title: 'yyy' },
|
||||
group: 'Hello',
|
||||
order: -1
|
||||
@@ -145,19 +145,19 @@ suite('MenuService', function () {
|
||||
|
||||
test('in group sorting, special: navigation', function () {
|
||||
|
||||
disposables.push(MenuRegistry.appendMenuItem(testMenuId, {
|
||||
disposables.add(MenuRegistry.appendMenuItem(testMenuId, {
|
||||
command: { id: 'a', title: 'aaa' },
|
||||
group: 'navigation',
|
||||
order: 1.3
|
||||
}));
|
||||
|
||||
disposables.push(MenuRegistry.appendMenuItem(testMenuId, {
|
||||
disposables.add(MenuRegistry.appendMenuItem(testMenuId, {
|
||||
command: { id: 'b', title: 'fff' },
|
||||
group: 'navigation',
|
||||
order: 1.2
|
||||
}));
|
||||
|
||||
disposables.push(MenuRegistry.appendMenuItem(testMenuId, {
|
||||
disposables.add(MenuRegistry.appendMenuItem(testMenuId, {
|
||||
command: { id: 'c', title: 'zzz' },
|
||||
group: 'navigation',
|
||||
order: 1.1
|
||||
@@ -177,7 +177,7 @@ suite('MenuService', function () {
|
||||
|
||||
test('special MenuId palette', function () {
|
||||
|
||||
disposables.push(MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
|
||||
disposables.add(MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
|
||||
command: { id: 'a', title: 'Explicit' }
|
||||
}));
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ export class BackupMainService implements IBackupMainService {
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService,
|
||||
@ILogService private readonly logService: ILogService
|
||||
) {
|
||||
this.backupHome = environmentService.backupHome;
|
||||
this.backupHome = environmentService.backupHome.fsPath;
|
||||
this.workspacesJsonPath = environmentService.backupWorkspacesPath;
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ export class BackupMainService implements IBackupMainService {
|
||||
return [];
|
||||
}
|
||||
|
||||
const seenIds: { [id: string]: boolean } = Object.create(null);
|
||||
const seenIds: Set<string> = new Set();
|
||||
const result: IWorkspaceBackupInfo[] = [];
|
||||
|
||||
// Validate Workspaces
|
||||
@@ -254,8 +254,8 @@ export class BackupMainService implements IBackupMainService {
|
||||
return []; // wrong format, skip all entries
|
||||
}
|
||||
|
||||
if (!seenIds[workspace.id]) {
|
||||
seenIds[workspace.id] = true;
|
||||
if (!seenIds.has(workspace.id)) {
|
||||
seenIds.add(workspace.id);
|
||||
|
||||
const backupPath = this.getBackupPath(workspace.id);
|
||||
const hasBackups = await this.hasBackups(backupPath);
|
||||
@@ -283,11 +283,11 @@ export class BackupMainService implements IBackupMainService {
|
||||
}
|
||||
|
||||
const result: URI[] = [];
|
||||
const seen: { [id: string]: boolean } = Object.create(null);
|
||||
const seenIds: Set<string> = new Set();
|
||||
for (let folderURI of folderWorkspaces) {
|
||||
const key = getComparisonKey(folderURI);
|
||||
if (!seen[key]) {
|
||||
seen[key] = true;
|
||||
if (!seenIds.has(key)) {
|
||||
seenIds.add(key);
|
||||
|
||||
const backupPath = this.getBackupPath(this.getFolderHash(folderURI));
|
||||
const hasBackups = await this.hasBackups(backupPath);
|
||||
@@ -315,7 +315,7 @@ export class BackupMainService implements IBackupMainService {
|
||||
}
|
||||
|
||||
const result: IEmptyWindowBackupInfo[] = [];
|
||||
const seen: { [id: string]: boolean } = Object.create(null);
|
||||
const seenIds: Set<string> = new Set();
|
||||
|
||||
// Validate Empty Windows
|
||||
for (let backupInfo of emptyWorkspaces) {
|
||||
@@ -324,8 +324,8 @@ export class BackupMainService implements IBackupMainService {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (!seen[backupFolder]) {
|
||||
seen[backupFolder] = true;
|
||||
if (!seenIds.has(backupFolder)) {
|
||||
seenIds.add(backupFolder);
|
||||
|
||||
const backupPath = this.getBackupPath(backupFolder);
|
||||
if (await this.hasBackups(backupPath)) {
|
||||
|
||||
49
src/vs/platform/clipboard/browser/clipboardService.ts
Normal file
49
src/vs/platform/clipboard/browser/clipboardService.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
export class BrowserClipboardService implements IClipboardService {
|
||||
|
||||
_serviceBrand: ServiceIdentifier<IClipboardService>;
|
||||
|
||||
private _internalResourcesClipboard: URI[] | undefined;
|
||||
|
||||
async writeText(text: string, type?: string): Promise<void> {
|
||||
return navigator.clipboard.writeText(text);
|
||||
}
|
||||
|
||||
async readText(type?: string): Promise<string> {
|
||||
return navigator.clipboard.readText();
|
||||
}
|
||||
|
||||
readTextSync(): string | undefined {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
readFindText(): string {
|
||||
// @ts-ignore
|
||||
return undefined;
|
||||
}
|
||||
|
||||
writeFindText(text: string): void { }
|
||||
|
||||
writeResources(resources: URI[]): void {
|
||||
this._internalResourcesClipboard = resources;
|
||||
}
|
||||
|
||||
readResources(): URI[] {
|
||||
return this._internalResourcesClipboard || [];
|
||||
}
|
||||
|
||||
hasResources(): boolean {
|
||||
return this._internalResourcesClipboard !== undefined && this._internalResourcesClipboard.length > 0;
|
||||
}
|
||||
}
|
||||
|
||||
registerSingleton(IClipboardService, BrowserClipboardService, true);
|
||||
@@ -15,12 +15,14 @@ export interface IClipboardService {
|
||||
/**
|
||||
* Writes text to the system clipboard.
|
||||
*/
|
||||
writeText(text: string, type?: string): void;
|
||||
writeText(text: string, type?: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* Reads the content of the clipboard in plain text
|
||||
*/
|
||||
readText(type?: string): string;
|
||||
readText(type?: string): Promise<string>;
|
||||
|
||||
readTextSync(): string | undefined;
|
||||
|
||||
/**
|
||||
* Reads text from the system find pasteboard.
|
||||
|
||||
@@ -14,14 +14,18 @@ export class ClipboardService implements IClipboardService {
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
writeText(text: string, type?: string): void {
|
||||
async writeText(text: string, type?: 'selection' | 'clipboard'): Promise<void> {
|
||||
clipboard.writeText(text, type);
|
||||
}
|
||||
|
||||
readText(type?: string): string {
|
||||
async readText(type?: 'selection' | 'clipboard'): Promise<string> {
|
||||
return clipboard.readText(type);
|
||||
}
|
||||
|
||||
readTextSync(): string {
|
||||
return clipboard.readText();
|
||||
}
|
||||
|
||||
readFindText(): string {
|
||||
if (isMacintosh) {
|
||||
return clipboard.readFindText();
|
||||
|
||||
@@ -9,6 +9,7 @@ import { ServicesAccessor, createDecorator } from 'vs/platform/instantiation/com
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { LinkedList } from 'vs/base/common/linkedList';
|
||||
import { IJSONSchema } from 'vs/base/common/jsonSchema';
|
||||
import { keys } from 'vs/base/common/map';
|
||||
|
||||
export const ICommandService = createDecorator<ICommandService>('commandService');
|
||||
|
||||
@@ -22,9 +23,7 @@ export interface ICommandService {
|
||||
executeCommand<T = any>(commandId: string, ...args: any[]): Promise<T | undefined>;
|
||||
}
|
||||
|
||||
export interface ICommandsMap {
|
||||
[id: string]: ICommand;
|
||||
}
|
||||
export type ICommandsMap = Map<string, ICommand>;
|
||||
|
||||
export interface ICommandHandler {
|
||||
(accessor: ServicesAccessor, ...args: any[]): void;
|
||||
@@ -122,10 +121,13 @@ export const CommandsRegistry: ICommandRegistry = new class implements ICommandR
|
||||
}
|
||||
|
||||
getCommands(): ICommandsMap {
|
||||
const result: ICommandsMap = Object.create(null);
|
||||
this._commands.forEach((value, key) => {
|
||||
result[key] = this.getCommand(key)!;
|
||||
});
|
||||
const result = new Map<string, ICommand>();
|
||||
for (const key of keys(this._commands)) {
|
||||
const command = this.getCommand(key);
|
||||
if (command) {
|
||||
result.set(key, command);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -68,10 +68,10 @@ suite('Command Tests', function () {
|
||||
}
|
||||
});
|
||||
|
||||
CommandsRegistry.getCommands()['test'].handler.apply(undefined, [undefined!, 'string']);
|
||||
CommandsRegistry.getCommands()['test2'].handler.apply(undefined, [undefined!, 'string']);
|
||||
assert.throws(() => CommandsRegistry.getCommands()['test3'].handler.apply(undefined, [undefined!, 'string']));
|
||||
assert.equal(CommandsRegistry.getCommands()['test3'].handler.apply(undefined, [undefined!, 1]), true);
|
||||
CommandsRegistry.getCommands().get('test')!.handler.apply(undefined, [undefined!, 'string']);
|
||||
CommandsRegistry.getCommands().get('test2')!.handler.apply(undefined, [undefined!, 'string']);
|
||||
assert.throws(() => CommandsRegistry.getCommands().get('test3')!.handler.apply(undefined, [undefined!, 'string']));
|
||||
assert.equal(CommandsRegistry.getCommands().get('test3')!.handler.apply(undefined, [undefined!, 1]), true);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -148,7 +148,7 @@ export function toOverrides(raw: any, conflictReporter: (message: string) => voi
|
||||
const configurationProperties = Registry.as<IConfigurationRegistry>(Extensions.Configuration).getConfigurationProperties();
|
||||
for (const key of Object.keys(raw)) {
|
||||
if (OVERRIDE_PROPERTY_PATTERN.test(key)) {
|
||||
const overrideRaw = {};
|
||||
const overrideRaw: any = {};
|
||||
for (const keyInOverrideRaw in raw[key]) {
|
||||
if (configurationProperties[keyInOverrideRaw] && configurationProperties[keyInOverrideRaw].overridable) {
|
||||
overrideRaw[keyInOverrideRaw] = raw[key][keyInOverrideRaw];
|
||||
|
||||
@@ -53,7 +53,7 @@ export class ConfigurationModel implements IConfigurationModel {
|
||||
return this;
|
||||
}
|
||||
|
||||
let contents = {};
|
||||
let contents: any = {};
|
||||
for (const key of arrays.distinct([...Object.keys(this.contents), ...Object.keys(overrideContents)])) {
|
||||
|
||||
let contentsForKey = this.contents[key];
|
||||
@@ -297,8 +297,8 @@ export class ConfigurationModelParser {
|
||||
return { contents, keys, overrides };
|
||||
}
|
||||
|
||||
private filterByScope(properties: {}, configurationProperties: { [qualifiedKey: string]: IConfigurationPropertySchema }, filterOverriddenProperties: boolean, scopes: ConfigurationScope[]): {} {
|
||||
const result = {};
|
||||
private filterByScope(properties: any, configurationProperties: { [qualifiedKey: string]: IConfigurationPropertySchema }, filterOverriddenProperties: boolean, scopes: ConfigurationScope[]): {} {
|
||||
const result: any = {};
|
||||
for (let key in properties) {
|
||||
if (OVERRIDE_PROPERTY_PATTERN.test(key) && filterOverriddenProperties) {
|
||||
result[key] = this.filterByScope(properties[key], configurationProperties, false, scopes);
|
||||
|
||||
@@ -131,11 +131,13 @@ export interface IDefaultConfigurationExtension {
|
||||
defaults: { [key: string]: {} };
|
||||
}
|
||||
|
||||
export const allSettings: { properties: {}, patternProperties: {} } = { properties: {}, patternProperties: {} };
|
||||
export const applicationSettings: { properties: {}, patternProperties: {} } = { properties: {}, patternProperties: {} };
|
||||
export const machineSettings: { properties: {}, patternProperties: {} } = { properties: {}, patternProperties: {} };
|
||||
export const windowSettings: { properties: {}, patternProperties: {} } = { properties: {}, patternProperties: {} };
|
||||
export const resourceSettings: { properties: {}, patternProperties: {} } = { properties: {}, patternProperties: {} };
|
||||
type SettingProperties = { [key: string]: any };
|
||||
|
||||
export const allSettings: { properties: SettingProperties, patternProperties: SettingProperties } = { properties: {}, patternProperties: {} };
|
||||
export const applicationSettings: { properties: SettingProperties, patternProperties: SettingProperties } = { properties: {}, patternProperties: {} };
|
||||
export const machineSettings: { properties: SettingProperties, patternProperties: SettingProperties } = { properties: {}, patternProperties: {} };
|
||||
export const windowSettings: { properties: SettingProperties, patternProperties: SettingProperties } = { properties: {}, patternProperties: {} };
|
||||
export const resourceSettings: { properties: SettingProperties, patternProperties: SettingProperties } = { properties: {}, patternProperties: {} };
|
||||
|
||||
export const editorConfigurationSchemaId = 'vscode://schemas/settings/editor';
|
||||
const contributionRegistry = Registry.as<IJSONContributionRegistry>(JSONExtensions.JSONContribution);
|
||||
@@ -468,13 +470,13 @@ export function validateProperty(property: string): string | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
export function getScopes(): { [key: string]: ConfigurationScope } {
|
||||
const scopes = {};
|
||||
export function getScopes(): [string, ConfigurationScope | undefined][] {
|
||||
const scopes: [string, ConfigurationScope | undefined][] = [];
|
||||
const configurationProperties = configurationRegistry.getConfigurationProperties();
|
||||
for (const key of Object.keys(configurationProperties)) {
|
||||
scopes[key] = configurationProperties[key].scope;
|
||||
scopes.push([key, configurationProperties[key].scope]);
|
||||
}
|
||||
scopes['launch'] = ConfigurationScope.RESOURCE;
|
||||
scopes['task'] = ConfigurationScope.RESOURCE;
|
||||
scopes.push(['launch', ConfigurationScope.RESOURCE]);
|
||||
scopes.push(['task', ConfigurationScope.RESOURCE]);
|
||||
return scopes;
|
||||
}
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { ConfigurationModelParser, ConfigurationModel } from 'vs/platform/configuration/common/configurationModels';
|
||||
import { ConfigWatcher } from 'vs/base/node/config';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
|
||||
export class NodeBasedUserConfiguration extends Disposable {
|
||||
|
||||
private userConfigModelWatcher: ConfigWatcher<ConfigurationModelParser>;
|
||||
private initializePromise: Promise<void>;
|
||||
|
||||
private readonly _onDidChangeConfiguration: Emitter<ConfigurationModel> = this._register(new Emitter<ConfigurationModel>());
|
||||
readonly onDidChangeConfiguration: Event<ConfigurationModel> = this._onDidChangeConfiguration.event;
|
||||
|
||||
constructor(private settingsPath: string) {
|
||||
super();
|
||||
}
|
||||
|
||||
initialize(): Promise<ConfigurationModel> {
|
||||
if (!this.initializePromise) {
|
||||
this.initializePromise = new Promise<void>((c, e) => {
|
||||
this.userConfigModelWatcher = new ConfigWatcher(this.settingsPath, {
|
||||
changeBufferDelay: 300, onError: error => onUnexpectedError(error), defaultConfig: new ConfigurationModelParser(this.settingsPath), parse: (content: string, parseErrors: any[]) => {
|
||||
const userConfigModelParser = new ConfigurationModelParser(this.settingsPath);
|
||||
userConfigModelParser.parseContent(content);
|
||||
parseErrors = [...userConfigModelParser.errors];
|
||||
return userConfigModelParser;
|
||||
}, initCallback: () => c(undefined)
|
||||
});
|
||||
this._register(this.userConfigModelWatcher);
|
||||
|
||||
// Listeners
|
||||
this._register(this.userConfigModelWatcher.onDidUpdateConfiguration(() => this._onDidChangeConfiguration.fire(this.userConfigModelWatcher.getConfig().configurationModel)));
|
||||
});
|
||||
}
|
||||
return this.initializePromise.then(() => this.userConfigModelWatcher.getConfig().configurationModel);
|
||||
}
|
||||
|
||||
initializeSync(): ConfigurationModel {
|
||||
this.initialize();
|
||||
return this.userConfigModelWatcher.getConfig().configurationModel;
|
||||
}
|
||||
|
||||
reload(): Promise<ConfigurationModel> {
|
||||
return this.initialize().then(() => new Promise<ConfigurationModel>(c => this.userConfigModelWatcher.reload(userConfigModelParser => c(userConfigModelParser.configurationModel))));
|
||||
}
|
||||
|
||||
getConfigurationModel(): ConfigurationModel {
|
||||
return this.userConfigModelWatcher.getConfig().configurationModel;
|
||||
}
|
||||
}
|
||||
@@ -7,40 +7,54 @@ import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { IConfigurationRegistry, Extensions } from 'vs/platform/configuration/common/configurationRegistry';
|
||||
import { IDisposable, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IConfigurationService, IConfigurationChangeEvent, IConfigurationOverrides, ConfigurationTarget, compare, isConfigurationOverrides, IConfigurationData } from 'vs/platform/configuration/common/configuration';
|
||||
import { DefaultConfigurationModel, Configuration, ConfigurationChangeEvent, ConfigurationModel } from 'vs/platform/configuration/common/configurationModels';
|
||||
import { DefaultConfigurationModel, Configuration, ConfigurationChangeEvent, ConfigurationModel, ConfigurationModelParser } from 'vs/platform/configuration/common/configurationModels';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
|
||||
import { NodeBasedUserConfiguration } from 'vs/platform/configuration/node/configuration';
|
||||
import { ConfigWatcher } from 'vs/base/node/config';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
|
||||
export class ConfigurationService extends Disposable implements IConfigurationService, IDisposable {
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
private _configuration: Configuration;
|
||||
private userConfiguration: NodeBasedUserConfiguration;
|
||||
private configuration: Configuration;
|
||||
private userConfigModelWatcher: ConfigWatcher<ConfigurationModelParser> | undefined;
|
||||
|
||||
private readonly _onDidChangeConfiguration: Emitter<IConfigurationChangeEvent> = this._register(new Emitter<IConfigurationChangeEvent>());
|
||||
readonly onDidChangeConfiguration: Event<IConfigurationChangeEvent> = this._onDidChangeConfiguration.event;
|
||||
|
||||
constructor(
|
||||
configurationPath: string
|
||||
private readonly settingsResource: URI
|
||||
) {
|
||||
super();
|
||||
|
||||
this.userConfiguration = this._register(new NodeBasedUserConfiguration(configurationPath));
|
||||
|
||||
// Initialize
|
||||
const defaults = new DefaultConfigurationModel();
|
||||
const user = this.userConfiguration.initializeSync();
|
||||
this._configuration = new Configuration(defaults, user);
|
||||
|
||||
// Listeners
|
||||
this._register(this.userConfiguration.onDidChangeConfiguration(userConfigurationModel => this.onDidChangeUserConfiguration(userConfigurationModel)));
|
||||
this.configuration = new Configuration(new DefaultConfigurationModel(), new ConfigurationModel());
|
||||
this._register(Registry.as<IConfigurationRegistry>(Extensions.Configuration).onDidUpdateConfiguration(configurationProperties => this.onDidDefaultConfigurationChange(configurationProperties)));
|
||||
}
|
||||
|
||||
get configuration(): Configuration {
|
||||
return this._configuration;
|
||||
initialize(): Promise<void> {
|
||||
if (this.userConfigModelWatcher) {
|
||||
this.userConfigModelWatcher.dispose();
|
||||
}
|
||||
|
||||
if (this.settingsResource.scheme !== Schemas.file) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
return new Promise<void>((c, e) => {
|
||||
this.userConfigModelWatcher = this._register(new ConfigWatcher(this.settingsResource.fsPath, {
|
||||
changeBufferDelay: 300, onError: error => onUnexpectedError(error), defaultConfig: new ConfigurationModelParser(this.settingsResource.fsPath), parse: (content: string, parseErrors: any[]) => {
|
||||
const userConfigModelParser = new ConfigurationModelParser(this.settingsResource.fsPath);
|
||||
userConfigModelParser.parseContent(content);
|
||||
parseErrors = [...userConfigModelParser.errors];
|
||||
return userConfigModelParser;
|
||||
}, initCallback: () => {
|
||||
this.configuration = new Configuration(new DefaultConfigurationModel(), this.userConfigModelWatcher!.getConfig().configurationModel);
|
||||
this._register(this.userConfigModelWatcher!.onDidUpdateConfiguration(() => this.onDidChangeUserConfiguration(this.userConfigModelWatcher!.getConfig().configurationModel)));
|
||||
c();
|
||||
}
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
getConfigurationData(): IConfigurationData {
|
||||
@@ -85,21 +99,26 @@ export class ConfigurationService extends Disposable implements IConfigurationSe
|
||||
}
|
||||
|
||||
reloadConfiguration(folder?: IWorkspaceFolder): Promise<void> {
|
||||
return folder ? Promise.resolve(undefined) :
|
||||
this.userConfiguration.reload().then(userConfigurationModel => this.onDidChangeUserConfiguration(userConfigurationModel));
|
||||
if (this.userConfigModelWatcher) {
|
||||
return new Promise<void>(c => this.userConfigModelWatcher!.reload(userConfigModelParser => {
|
||||
this.onDidChangeUserConfiguration(userConfigModelParser.configurationModel);
|
||||
c();
|
||||
}));
|
||||
}
|
||||
return this.initialize();
|
||||
}
|
||||
|
||||
private onDidChangeUserConfiguration(userConfigurationModel: ConfigurationModel): void {
|
||||
const { added, updated, removed } = compare(this._configuration.localUserConfiguration, userConfigurationModel);
|
||||
const { added, updated, removed } = compare(this.configuration.localUserConfiguration, userConfigurationModel);
|
||||
const changedKeys = [...added, ...updated, ...removed];
|
||||
if (changedKeys.length) {
|
||||
this._configuration.updateLocalUserConfiguration(userConfigurationModel);
|
||||
this.configuration.updateLocalUserConfiguration(userConfigurationModel);
|
||||
this.trigger(changedKeys, ConfigurationTarget.USER);
|
||||
}
|
||||
}
|
||||
|
||||
private onDidDefaultConfigurationChange(keys: string[]): void {
|
||||
this._configuration.updateDefaultConfiguration(new DefaultConfigurationModel());
|
||||
this.configuration.updateDefaultConfiguration(new DefaultConfigurationModel());
|
||||
this.trigger(keys, ConfigurationTarget.DEFAULT);
|
||||
}
|
||||
|
||||
@@ -110,9 +129,9 @@ export class ConfigurationService extends Disposable implements IConfigurationSe
|
||||
private getTargetConfiguration(target: ConfigurationTarget): any {
|
||||
switch (target) {
|
||||
case ConfigurationTarget.DEFAULT:
|
||||
return this._configuration.defaults.contents;
|
||||
return this.configuration.defaults.contents;
|
||||
case ConfigurationTarget.USER:
|
||||
return this._configuration.localUserConfiguration.contents;
|
||||
return this.configuration.localUserConfiguration.contents;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ suite('Configuration', () => {
|
||||
assert.deepEqual(target, { 'a': { 'b': 2 } });
|
||||
});
|
||||
|
||||
test('removeFromValueTree: remove a single segemented key', () => {
|
||||
test('removeFromValueTree: remove a single segmented key', () => {
|
||||
let target = { 'a': 1 };
|
||||
|
||||
removeFromValueTree(target, 'a');
|
||||
@@ -40,7 +40,7 @@ suite('Configuration', () => {
|
||||
assert.deepEqual(target, {});
|
||||
});
|
||||
|
||||
test('removeFromValueTree: remove a single segemented key when its value is undefined', () => {
|
||||
test('removeFromValueTree: remove a single segmented key when its value is undefined', () => {
|
||||
let target = { 'a': undefined };
|
||||
|
||||
removeFromValueTree(target, 'a');
|
||||
@@ -48,7 +48,7 @@ suite('Configuration', () => {
|
||||
assert.deepEqual(target, {});
|
||||
});
|
||||
|
||||
test('removeFromValueTree: remove a multi segemented key when its value is undefined', () => {
|
||||
test('removeFromValueTree: remove a multi segmented key when its value is undefined', () => {
|
||||
let target = { 'a': { 'b': 1 } };
|
||||
|
||||
removeFromValueTree(target, 'a.b');
|
||||
@@ -56,7 +56,7 @@ suite('Configuration', () => {
|
||||
assert.deepEqual(target, {});
|
||||
});
|
||||
|
||||
test('removeFromValueTree: remove a multi segemented key when its value is array', () => {
|
||||
test('removeFromValueTree: remove a multi segmented key when its value is array', () => {
|
||||
let target = { 'a': { 'b': [1] } };
|
||||
|
||||
removeFromValueTree(target, 'a.b');
|
||||
@@ -64,7 +64,7 @@ suite('Configuration', () => {
|
||||
assert.deepEqual(target, {});
|
||||
});
|
||||
|
||||
test('removeFromValueTree: remove a multi segemented key first segment value is array', () => {
|
||||
test('removeFromValueTree: remove a multi segmented key first segment value is array', () => {
|
||||
let target = { 'a': [1] };
|
||||
|
||||
removeFromValueTree(target, 'a.0');
|
||||
@@ -80,7 +80,7 @@ suite('Configuration', () => {
|
||||
assert.deepEqual(target, {});
|
||||
});
|
||||
|
||||
test('removeFromValueTree: remove a multi segemented key when the first node has more values', () => {
|
||||
test('removeFromValueTree: remove a multi segmented key when the first node has more values', () => {
|
||||
let target = { 'a': { 'b': { 'c': 1 }, 'd': 1 } };
|
||||
|
||||
removeFromValueTree(target, 'a.b.c');
|
||||
@@ -88,7 +88,7 @@ suite('Configuration', () => {
|
||||
assert.deepEqual(target, { 'a': { 'd': 1 } });
|
||||
});
|
||||
|
||||
test('removeFromValueTree: remove a multi segemented key when in between node has more values', () => {
|
||||
test('removeFromValueTree: remove a multi segmented key when in between node has more values', () => {
|
||||
let target = { 'a': { 'b': { 'c': { 'd': 1 }, 'd': 1 } } };
|
||||
|
||||
removeFromValueTree(target, 'a.b.c.d');
|
||||
@@ -96,7 +96,7 @@ suite('Configuration', () => {
|
||||
assert.deepEqual(target, { 'a': { 'b': { 'd': 1 } } });
|
||||
});
|
||||
|
||||
test('removeFromValueTree: remove a multi segemented key when the last but one node has more values', () => {
|
||||
test('removeFromValueTree: remove a multi segmented key when the last but one node has more values', () => {
|
||||
let target = { 'a': { 'b': { 'c': 1, 'd': 1 } } };
|
||||
|
||||
removeFromValueTree(target, 'a.b.c');
|
||||
|
||||
@@ -82,7 +82,7 @@ suite('ConfigurationModel', () => {
|
||||
assert.deepEqual(testObject.keys, ['a.b']);
|
||||
});
|
||||
|
||||
test('removeValue: remove a single segemented key', () => {
|
||||
test('removeValue: remove a single segmented key', () => {
|
||||
let testObject = new ConfigurationModel({ 'a': 1 }, ['a']);
|
||||
|
||||
testObject.removeValue('a');
|
||||
@@ -91,7 +91,7 @@ suite('ConfigurationModel', () => {
|
||||
assert.deepEqual(testObject.keys, []);
|
||||
});
|
||||
|
||||
test('removeValue: remove a multi segemented key', () => {
|
||||
test('removeValue: remove a multi segmented key', () => {
|
||||
let testObject = new ConfigurationModel({ 'a': { 'b': 1 } }, ['a.b']);
|
||||
|
||||
testObject.removeValue('a.b');
|
||||
|
||||
@@ -13,6 +13,7 @@ import { ConfigurationService } from 'vs/platform/configuration/node/configurati
|
||||
import * as uuid from 'vs/base/common/uuid';
|
||||
import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry';
|
||||
import { testFile } from 'vs/base/test/node/utils';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
|
||||
suite('ConfigurationService - Node', () => {
|
||||
|
||||
@@ -20,7 +21,8 @@ suite('ConfigurationService - Node', () => {
|
||||
const res = await testFile('config', 'config.json');
|
||||
fs.writeFileSync(res.testFile, '{ "foo": "bar" }');
|
||||
|
||||
const service = new ConfigurationService(res.testFile);
|
||||
const service = new ConfigurationService(URI.file(res.testFile));
|
||||
await service.initialize();
|
||||
const config = service.getValue<{
|
||||
foo: string;
|
||||
}>();
|
||||
@@ -37,7 +39,8 @@ suite('ConfigurationService - Node', () => {
|
||||
|
||||
fs.writeFileSync(res.testFile, '{ "testworkbench.editor.tabs": true }');
|
||||
|
||||
const service = new ConfigurationService(res.testFile);
|
||||
const service = new ConfigurationService(URI.file(res.testFile));
|
||||
await service.initialize();
|
||||
const config = service.getValue<{
|
||||
testworkbench: {
|
||||
editor: {
|
||||
@@ -59,7 +62,8 @@ suite('ConfigurationService - Node', () => {
|
||||
|
||||
fs.writeFileSync(res.testFile, ',,,,');
|
||||
|
||||
const service = new ConfigurationService(res.testFile);
|
||||
const service = new ConfigurationService(URI.file(res.testFile));
|
||||
await service.initialize();
|
||||
const config = service.getValue<{
|
||||
foo: string;
|
||||
}>();
|
||||
@@ -69,13 +73,14 @@ suite('ConfigurationService - Node', () => {
|
||||
return res.cleanUp();
|
||||
});
|
||||
|
||||
test('missing file does not explode', () => {
|
||||
test('missing file does not explode', async () => {
|
||||
const id = uuid.generateUuid();
|
||||
const parentDir = path.join(os.tmpdir(), 'vsctests', id);
|
||||
const newDir = path.join(parentDir, 'config', id);
|
||||
const testFile = path.join(newDir, 'config.json');
|
||||
|
||||
const service = new ConfigurationService(testFile);
|
||||
const service = new ConfigurationService(URI.file(testFile));
|
||||
await service.initialize();
|
||||
|
||||
const config = service.getValue<{ foo: string }>();
|
||||
assert.ok(config);
|
||||
@@ -86,7 +91,8 @@ suite('ConfigurationService - Node', () => {
|
||||
test('trigger configuration change event', async () => {
|
||||
const res = await testFile('config', 'config.json');
|
||||
|
||||
const service = new ConfigurationService(res.testFile);
|
||||
const service = new ConfigurationService(URI.file(res.testFile));
|
||||
await service.initialize();
|
||||
return new Promise((c, e) => {
|
||||
service.onDidChangeConfiguration(() => {
|
||||
assert.equal(service.getValue('foo'), 'bar');
|
||||
@@ -103,7 +109,8 @@ suite('ConfigurationService - Node', () => {
|
||||
|
||||
fs.writeFileSync(res.testFile, '{ "foo": "bar" }');
|
||||
|
||||
const service = new ConfigurationService(res.testFile);
|
||||
const service = new ConfigurationService(URI.file(res.testFile));
|
||||
await service.initialize();
|
||||
let config = service.getValue<{
|
||||
foo: string;
|
||||
}>();
|
||||
@@ -130,7 +137,7 @@ suite('ConfigurationService - Node', () => {
|
||||
return res.cleanUp();
|
||||
});
|
||||
|
||||
test('model defaults', () => {
|
||||
test('model defaults', async () => {
|
||||
interface ITestSetting {
|
||||
configuration: {
|
||||
service: {
|
||||
@@ -151,7 +158,8 @@ suite('ConfigurationService - Node', () => {
|
||||
}
|
||||
});
|
||||
|
||||
let serviceWithoutFile = new ConfigurationService('__testFile');
|
||||
let serviceWithoutFile = new ConfigurationService(URI.file('__testFile'));
|
||||
await serviceWithoutFile.initialize();
|
||||
let setting = serviceWithoutFile.getValue<ITestSetting>();
|
||||
|
||||
assert.ok(setting);
|
||||
@@ -160,7 +168,7 @@ suite('ConfigurationService - Node', () => {
|
||||
return testFile('config', 'config.json').then(async res => {
|
||||
fs.writeFileSync(res.testFile, '{ "testworkbench.editor.tabs": true }');
|
||||
|
||||
const service = new ConfigurationService(res.testFile);
|
||||
const service = new ConfigurationService(URI.file(res.testFile));
|
||||
|
||||
let setting = service.getValue<ITestSetting>();
|
||||
|
||||
@@ -193,7 +201,9 @@ suite('ConfigurationService - Node', () => {
|
||||
});
|
||||
|
||||
const r = await testFile('config', 'config.json');
|
||||
const service = new ConfigurationService(r.testFile);
|
||||
const service = new ConfigurationService(URI.file(r.testFile));
|
||||
service.initialize();
|
||||
|
||||
let res = service.inspect('something.missing');
|
||||
assert.strictEqual(res.value, undefined);
|
||||
assert.strictEqual(res.default, undefined);
|
||||
@@ -229,7 +239,9 @@ suite('ConfigurationService - Node', () => {
|
||||
});
|
||||
|
||||
const r = await testFile('config', 'config.json');
|
||||
const service = new ConfigurationService(r.testFile);
|
||||
const service = new ConfigurationService(URI.file(r.testFile));
|
||||
service.initialize();
|
||||
|
||||
let res = service.inspect('lookup.service.testNullSetting');
|
||||
assert.strictEqual(res.default, null);
|
||||
assert.strictEqual(res.value, null);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Emitter, Event, PauseableEmitter } from 'vs/base/common/event';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { IDisposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { keys } from 'vs/base/common/map';
|
||||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { ConfigurationTarget, IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
@@ -323,7 +323,7 @@ export class ContextKeyService extends AbstractContextKeyService implements ICon
|
||||
private _lastContextId: number;
|
||||
private readonly _contexts = new Map<number, Context>();
|
||||
|
||||
private _toDispose: IDisposable[] = [];
|
||||
private readonly _toDispose = new DisposableStore();
|
||||
|
||||
constructor(@IConfigurationService configurationService: IConfigurationService) {
|
||||
super(0);
|
||||
@@ -332,7 +332,7 @@ export class ContextKeyService extends AbstractContextKeyService implements ICon
|
||||
|
||||
const myContext = new ConfigAwareContextValuesContainer(this._myContextId, configurationService, this._onDidChangeContext);
|
||||
this._contexts.set(this._myContextId, myContext);
|
||||
this._toDispose.push(myContext);
|
||||
this._toDispose.add(myContext);
|
||||
|
||||
// Uncomment this to see the contexts continuously logged
|
||||
// let lastLoggedValue: string | null = null;
|
||||
@@ -348,7 +348,7 @@ export class ContextKeyService extends AbstractContextKeyService implements ICon
|
||||
|
||||
public dispose(): void {
|
||||
this._isDisposed = true;
|
||||
this._toDispose = dispose(this._toDispose);
|
||||
this._toDispose.dispose();
|
||||
}
|
||||
|
||||
public getContextValuesContainer(contextId: number): Context {
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { RawContextKey, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
|
||||
export const InputFocusedContextKey = 'inputFocus';
|
||||
export const InputFocusedContext = new RawContextKey<boolean>(InputFocusedContextKey, false);
|
||||
|
||||
export const FalseContext: ContextKeyExpr = new RawContextKey<boolean>('__false', false);
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
import 'vs/css!./contextMenuHandler';
|
||||
|
||||
import { combinedDisposable, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { ActionRunner, IRunEvent } from 'vs/base/common/actions';
|
||||
import { ActionRunner, IRunEvent, WorkbenchActionExecutedEvent, WorkbenchActionExecutedClassification } from 'vs/base/common/actions';
|
||||
import { combinedDisposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { Menu } from 'vs/base/browser/ui/menu/menu';
|
||||
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
@@ -67,7 +67,7 @@ export class ContextMenuHandler {
|
||||
this.block = container.appendChild($('.context-view-block'));
|
||||
}
|
||||
|
||||
const menuDisposables: IDisposable[] = [];
|
||||
const menuDisposables = new DisposableStore();
|
||||
|
||||
const actionRunner = delegate.actionRunner || new ActionRunner();
|
||||
actionRunner.onDidBeforeRun(this.onActionRun, this, menuDisposables);
|
||||
@@ -79,7 +79,7 @@ export class ContextMenuHandler {
|
||||
getKeyBinding: delegate.getKeyBinding ? delegate.getKeyBinding : action => this.keybindingService.lookupKeybinding(action.id)
|
||||
});
|
||||
|
||||
menuDisposables.push(attachMenuStyler(menu, this.themeService));
|
||||
menuDisposables.add(attachMenuStyler(menu, this.themeService));
|
||||
|
||||
menu.onDidCancel(() => this.contextViewService.hideContextView(true), null, menuDisposables);
|
||||
menu.onDidBlur(() => this.contextViewService.hideContextView(true), null, menuDisposables);
|
||||
@@ -104,7 +104,7 @@ export class ContextMenuHandler {
|
||||
this.contextViewService.hideContextView(true);
|
||||
}, null, menuDisposables);
|
||||
|
||||
return combinedDisposable([...menuDisposables, menu]);
|
||||
return combinedDisposable(menuDisposables, menu);
|
||||
},
|
||||
|
||||
focus: () => {
|
||||
@@ -132,13 +132,7 @@ export class ContextMenuHandler {
|
||||
|
||||
private onActionRun(e: IRunEvent): void {
|
||||
if (this.telemetryService) {
|
||||
/* __GDPR__
|
||||
"workbenchActionExecuted" : {
|
||||
"id" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
|
||||
"from": { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
|
||||
}
|
||||
*/
|
||||
this.telemetryService.publicLog('workbenchActionExecuted', { id: e.action.id, from: 'contextMenu' });
|
||||
this.telemetryService.publicLog2<WorkbenchActionExecutedEvent, WorkbenchActionExecutedClassification>('workbenchActionExecuted', { id: e.action.id, from: 'contextMenu' });
|
||||
}
|
||||
|
||||
this.contextViewService.hideContextView(false);
|
||||
|
||||
@@ -17,7 +17,7 @@ export class ContextMenuService extends Disposable implements IContextMenuServic
|
||||
_serviceBrand: any;
|
||||
|
||||
private _onDidContextMenu = this._register(new Emitter<void>());
|
||||
get onDidContextMenu(): Event<void> { return this._onDidContextMenu.event; }
|
||||
readonly onDidContextMenu: Event<void> = this._onDidContextMenu.event;
|
||||
|
||||
private contextMenuHandler: ContextMenuHandler;
|
||||
|
||||
|
||||
16
src/vs/platform/credentials/common/credentials.ts
Normal file
16
src/vs/platform/credentials/common/credentials.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
export const ICredentialsService = createDecorator<ICredentialsService>('ICredentialsService');
|
||||
|
||||
export interface ICredentialsService {
|
||||
_serviceBrand: any;
|
||||
getPassword(service: string, account: string): Promise<string | null>;
|
||||
setPassword(service: string, account: string, password: string): Promise<void>;
|
||||
deletePassword(service: string, account: string): Promise<boolean>;
|
||||
findPassword(service: string): Promise<string | null>;
|
||||
}
|
||||
41
src/vs/platform/credentials/node/credentialsService.ts
Normal file
41
src/vs/platform/credentials/node/credentialsService.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ICredentialsService } from 'vs/platform/credentials/common/credentials';
|
||||
import { IdleValue } from 'vs/base/common/async';
|
||||
|
||||
type KeytarModule = {
|
||||
getPassword(service: string, account: string): Promise<string | null>;
|
||||
setPassword(service: string, account: string, password: string): Promise<void>;
|
||||
deletePassword(service: string, account: string): Promise<boolean>;
|
||||
findPassword(service: string): Promise<string | null>;
|
||||
};
|
||||
|
||||
export class KeytarCredentialsService implements ICredentialsService {
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
private readonly _keytar = new IdleValue<Promise<KeytarModule>>(() => import('keytar'));
|
||||
|
||||
async getPassword(service: string, account: string): Promise<string | null> {
|
||||
const keytar = await this._keytar.getValue();
|
||||
return keytar.getPassword(service, account);
|
||||
}
|
||||
|
||||
async setPassword(service: string, account: string, password: string): Promise<void> {
|
||||
const keytar = await this._keytar.getValue();
|
||||
return keytar.setPassword(service, account, password);
|
||||
}
|
||||
|
||||
async deletePassword(service: string, account: string): Promise<boolean> {
|
||||
const keytar = await this._keytar.getValue();
|
||||
return keytar.deletePassword(service, account);
|
||||
}
|
||||
|
||||
async findPassword(service: string): Promise<string | null> {
|
||||
const keytar = await this._keytar.getValue();
|
||||
return keytar.findPassword(service);
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,10 @@
|
||||
|
||||
import { UriComponents } from 'vs/base/common/uri';
|
||||
import { ProcessItem } from 'vs/base/common/processes';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IMainProcessInfo } from 'vs/platform/launch/common/launchService';
|
||||
import { IWorkspace } from 'vs/platform/workspace/common/workspace';
|
||||
import { IStringDictionary } from 'vs/base/common/collections';
|
||||
|
||||
export interface IMachineInfo {
|
||||
os: string;
|
||||
@@ -15,7 +19,7 @@ export interface IMachineInfo {
|
||||
|
||||
export interface IDiagnosticInfo {
|
||||
machineInfo: IMachineInfo;
|
||||
workspaceMetadata?: { [key: string]: WorkspaceStats };
|
||||
workspaceMetadata?: IStringDictionary<WorkspaceStats>;
|
||||
processes?: ProcessItem;
|
||||
}
|
||||
export interface SystemInfo extends IMachineInfo {
|
||||
@@ -51,6 +55,24 @@ export interface WorkspaceStats {
|
||||
configFiles: WorkspaceStatItem[];
|
||||
fileCount: number;
|
||||
maxFilesReached: boolean;
|
||||
launchConfigFiles: WorkspaceStatItem[];
|
||||
}
|
||||
|
||||
export interface PerformanceInfo {
|
||||
processInfo?: string;
|
||||
workspaceInfo?: string;
|
||||
}
|
||||
|
||||
export const ID = 'diagnosticsService';
|
||||
export const IDiagnosticsService = createDecorator<IDiagnosticsService>(ID);
|
||||
|
||||
export interface IDiagnosticsService {
|
||||
_serviceBrand: any;
|
||||
|
||||
getPerformanceInfo(mainProcessInfo: IMainProcessInfo, remoteInfo: (IRemoteDiagnosticInfo | IRemoteDiagnosticError)[]): Promise<PerformanceInfo>;
|
||||
getSystemInfo(mainProcessInfo: IMainProcessInfo, remoteInfo: (IRemoteDiagnosticInfo | IRemoteDiagnosticError)[]): Promise<SystemInfo>;
|
||||
getDiagnostics(mainProcessInfo: IMainProcessInfo, remoteInfo: (IRemoteDiagnosticInfo | IRemoteDiagnosticError)[]): Promise<string>;
|
||||
reportWorkspaceStats(workspace: IWorkspace): Promise<void>;
|
||||
}
|
||||
|
||||
export function isRemoteDiagnosticError(x: any): x is IRemoteDiagnosticError {
|
||||
|
||||
@@ -1,389 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IMainProcessInfo, ILaunchService } from 'vs/platform/launch/electron-main/launchService';
|
||||
import { listProcesses } from 'vs/base/node/ps';
|
||||
import product from 'vs/platform/product/node/product';
|
||||
import pkg from 'vs/platform/product/node/package';
|
||||
import * as osLib from 'os';
|
||||
import { virtualMachineHint } from 'vs/base/node/id';
|
||||
import { repeat, pad } from 'vs/base/common/strings';
|
||||
import { isWindows } from 'vs/base/common/platform';
|
||||
import { app } from 'electron';
|
||||
import { basename } from 'vs/base/common/path';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IMachineInfo, WorkspaceStats, SystemInfo, IRemoteDiagnosticInfo, isRemoteDiagnosticError } from 'vs/platform/diagnostics/common/diagnosticsService';
|
||||
import { collectWorkspaceStats, getMachineInfo } from 'vs/platform/diagnostics/node/diagnosticsService';
|
||||
import { ProcessItem } from 'vs/base/common/processes';
|
||||
|
||||
export const ID = 'diagnosticsService';
|
||||
export const IDiagnosticsService = createDecorator<IDiagnosticsService>(ID);
|
||||
|
||||
export interface IDiagnosticsService {
|
||||
_serviceBrand: any;
|
||||
|
||||
getPerformanceInfo(launchService: ILaunchService): Promise<PerformanceInfo>;
|
||||
getSystemInfo(launchService: ILaunchService): Promise<SystemInfo>;
|
||||
getDiagnostics(launchService: ILaunchService): Promise<string>;
|
||||
}
|
||||
|
||||
export interface VersionInfo {
|
||||
vscodeVersion: string;
|
||||
os: string;
|
||||
}
|
||||
|
||||
export interface ProcessInfo {
|
||||
cpu: number;
|
||||
memory: number;
|
||||
pid: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface PerformanceInfo {
|
||||
processInfo?: string;
|
||||
workspaceInfo?: string;
|
||||
}
|
||||
export class DiagnosticsService implements IDiagnosticsService {
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
private formatMachineInfo(info: IMachineInfo): string {
|
||||
const output: string[] = [];
|
||||
output.push(`OS Version: ${info.os}`);
|
||||
output.push(`CPUs: ${info.cpus}`);
|
||||
output.push(`Memory (System): ${info.memory}`);
|
||||
output.push(`VM: ${info.vmHint}`);
|
||||
|
||||
return output.join('\n');
|
||||
}
|
||||
|
||||
private formatEnvironment(info: IMainProcessInfo): string {
|
||||
const MB = 1024 * 1024;
|
||||
const GB = 1024 * MB;
|
||||
|
||||
const output: string[] = [];
|
||||
output.push(`Version: ${pkg.name} ${pkg.version} (${product.commit || 'Commit unknown'}, ${product.date || 'Date unknown'})`);
|
||||
output.push(`OS Version: ${osLib.type()} ${osLib.arch()} ${osLib.release()}`);
|
||||
const cpus = osLib.cpus();
|
||||
if (cpus && cpus.length > 0) {
|
||||
output.push(`CPUs: ${cpus[0].model} (${cpus.length} x ${cpus[0].speed})`);
|
||||
}
|
||||
output.push(`Memory (System): ${(osLib.totalmem() / GB).toFixed(2)}GB (${(osLib.freemem() / GB).toFixed(2)}GB free)`);
|
||||
if (!isWindows) {
|
||||
output.push(`Load (avg): ${osLib.loadavg().map(l => Math.round(l)).join(', ')}`); // only provided on Linux/macOS
|
||||
}
|
||||
output.push(`VM: ${Math.round((virtualMachineHint.value() * 100))}%`);
|
||||
output.push(`Screen Reader: ${app.isAccessibilitySupportEnabled() ? 'yes' : 'no'}`);
|
||||
output.push(`Process Argv: ${info.mainArguments.join(' ')}`);
|
||||
output.push(`GPU Status: ${this.expandGPUFeatures()}`);
|
||||
|
||||
return output.join('\n');
|
||||
}
|
||||
|
||||
async getPerformanceInfo(launchService: ILaunchService): Promise<PerformanceInfo> {
|
||||
const info = await launchService.getMainProcessInfo();
|
||||
return Promise.all<ProcessItem, string>([listProcesses(info.mainPID), this.formatWorkspaceMetadata(info)]).then(async result => {
|
||||
let [rootProcess, workspaceInfo] = result;
|
||||
let processInfo = this.formatProcessList(info, rootProcess);
|
||||
|
||||
try {
|
||||
const remoteData = await launchService.getRemoteDiagnostics({ includeProcesses: true, includeWorkspaceMetadata: true });
|
||||
remoteData.forEach(diagnostics => {
|
||||
if (isRemoteDiagnosticError(diagnostics)) {
|
||||
processInfo += `\n${diagnostics.errorMessage}`;
|
||||
workspaceInfo += `\n${diagnostics.errorMessage}`;
|
||||
} else {
|
||||
processInfo += `\n\nRemote: ${diagnostics.hostName}`;
|
||||
if (diagnostics.processes) {
|
||||
processInfo += `\n${this.formatProcessList(info, diagnostics.processes)}`;
|
||||
}
|
||||
|
||||
if (diagnostics.workspaceMetadata) {
|
||||
workspaceInfo += `\n| Remote: ${diagnostics.hostName}`;
|
||||
for (const folder of Object.keys(diagnostics.workspaceMetadata)) {
|
||||
const metadata = diagnostics.workspaceMetadata[folder];
|
||||
|
||||
let countMessage = `${metadata.fileCount} files`;
|
||||
if (metadata.maxFilesReached) {
|
||||
countMessage = `more than ${countMessage}`;
|
||||
}
|
||||
|
||||
workspaceInfo += `| Folder (${folder}): ${countMessage}`;
|
||||
workspaceInfo += this.formatWorkspaceStats(metadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
processInfo += `\nFetching remote data failed: ${e}`;
|
||||
workspaceInfo += `\nFetching remote data failed: ${e}`;
|
||||
}
|
||||
|
||||
return {
|
||||
processInfo,
|
||||
workspaceInfo
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
async getSystemInfo(launchService: ILaunchService): Promise<SystemInfo> {
|
||||
const info = await launchService.getMainProcessInfo();
|
||||
const { memory, vmHint, os, cpus } = getMachineInfo();
|
||||
const systemInfo: SystemInfo = {
|
||||
os,
|
||||
memory,
|
||||
cpus,
|
||||
vmHint,
|
||||
processArgs: `${info.mainArguments.join(' ')}`,
|
||||
gpuStatus: app.getGPUFeatureStatus(),
|
||||
screenReader: `${app.isAccessibilitySupportEnabled() ? 'yes' : 'no'}`,
|
||||
remoteData: (await launchService.getRemoteDiagnostics({ includeProcesses: false, includeWorkspaceMetadata: false })).filter((x): x is IRemoteDiagnosticInfo => !(x instanceof Error))
|
||||
};
|
||||
|
||||
|
||||
if (!isWindows) {
|
||||
systemInfo.load = `${osLib.loadavg().map(l => Math.round(l)).join(', ')}`;
|
||||
}
|
||||
|
||||
return Promise.resolve(systemInfo);
|
||||
}
|
||||
|
||||
async getDiagnostics(launchService: ILaunchService): Promise<string> {
|
||||
const output: string[] = [];
|
||||
const info = await launchService.getMainProcessInfo();
|
||||
return listProcesses(info.mainPID).then(async rootProcess => {
|
||||
|
||||
// Environment Info
|
||||
output.push('');
|
||||
output.push(this.formatEnvironment(info));
|
||||
|
||||
// Process List
|
||||
output.push('');
|
||||
output.push(this.formatProcessList(info, rootProcess));
|
||||
|
||||
// Workspace Stats
|
||||
if (info.windows.some(window => window.folderURIs && window.folderURIs.length > 0 && !window.remoteAuthority)) {
|
||||
output.push('');
|
||||
output.push('Workspace Stats: ');
|
||||
output.push(await this.formatWorkspaceMetadata(info));
|
||||
}
|
||||
|
||||
try {
|
||||
const data = await launchService.getRemoteDiagnostics({ includeProcesses: true, includeWorkspaceMetadata: true });
|
||||
data.forEach(diagnostics => {
|
||||
if (isRemoteDiagnosticError(diagnostics)) {
|
||||
output.push(`\n${diagnostics.errorMessage}`);
|
||||
} else {
|
||||
output.push('\n\n');
|
||||
output.push(`Remote: ${diagnostics.hostName}`);
|
||||
output.push(this.formatMachineInfo(diagnostics.machineInfo));
|
||||
|
||||
if (diagnostics.processes) {
|
||||
output.push(this.formatProcessList(info, diagnostics.processes));
|
||||
}
|
||||
|
||||
if (diagnostics.workspaceMetadata) {
|
||||
for (const folder of Object.keys(diagnostics.workspaceMetadata)) {
|
||||
const metadata = diagnostics.workspaceMetadata[folder];
|
||||
|
||||
let countMessage = `${metadata.fileCount} files`;
|
||||
if (metadata.maxFilesReached) {
|
||||
countMessage = `more than ${countMessage}`;
|
||||
}
|
||||
|
||||
output.push(`Folder (${folder}): ${countMessage}`);
|
||||
output.push(this.formatWorkspaceStats(metadata));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
output.push('\n\n');
|
||||
output.push(`Fetching status information from remotes failed: ${e.message}`);
|
||||
}
|
||||
|
||||
output.push('');
|
||||
output.push('');
|
||||
|
||||
return output.join('\n');
|
||||
});
|
||||
}
|
||||
|
||||
private formatWorkspaceStats(workspaceStats: WorkspaceStats): string {
|
||||
const output: string[] = [];
|
||||
const lineLength = 60;
|
||||
let col = 0;
|
||||
|
||||
const appendAndWrap = (name: string, count: number) => {
|
||||
const item = ` ${name}(${count})`;
|
||||
|
||||
if (col + item.length > lineLength) {
|
||||
output.push(line);
|
||||
line = '| ';
|
||||
col = line.length;
|
||||
}
|
||||
else {
|
||||
col += item.length;
|
||||
}
|
||||
line += item;
|
||||
};
|
||||
|
||||
// File Types
|
||||
let line = '| File types:';
|
||||
const maxShown = 10;
|
||||
let max = workspaceStats.fileTypes.length > maxShown ? maxShown : workspaceStats.fileTypes.length;
|
||||
for (let i = 0; i < max; i++) {
|
||||
const item = workspaceStats.fileTypes[i];
|
||||
appendAndWrap(item.name, item.count);
|
||||
}
|
||||
output.push(line);
|
||||
|
||||
// Conf Files
|
||||
if (workspaceStats.configFiles.length >= 0) {
|
||||
line = '| Conf files:';
|
||||
col = 0;
|
||||
workspaceStats.configFiles.forEach((item) => {
|
||||
appendAndWrap(item.name, item.count);
|
||||
});
|
||||
output.push(line);
|
||||
}
|
||||
|
||||
// if (workspaceStats.launchConfigFiles.length > 0) {
|
||||
// let line = '| Launch Configs:';
|
||||
// workspaceStats.launchConfigFiles.forEach(each => {
|
||||
// const item = each.count > 1 ? ` ${each.name}(${each.count})` : ` ${each.name}`;
|
||||
// line += item;
|
||||
// });
|
||||
// output.push(line);
|
||||
// }
|
||||
return output.join('\n');
|
||||
}
|
||||
|
||||
private expandGPUFeatures(): string {
|
||||
const gpuFeatures = app.getGPUFeatureStatus();
|
||||
const longestFeatureName = Math.max(...Object.keys(gpuFeatures).map(feature => feature.length));
|
||||
// Make columns aligned by adding spaces after feature name
|
||||
return Object.keys(gpuFeatures).map(feature => `${feature}: ${repeat(' ', longestFeatureName - feature.length)} ${gpuFeatures[feature]}`).join('\n ');
|
||||
}
|
||||
|
||||
private formatWorkspaceMetadata(info: IMainProcessInfo): Promise<string> {
|
||||
const output: string[] = [];
|
||||
const workspaceStatPromises: Promise<void>[] = [];
|
||||
|
||||
info.windows.forEach(window => {
|
||||
if (window.folderURIs.length === 0 || !!window.remoteAuthority) {
|
||||
return;
|
||||
}
|
||||
|
||||
output.push(`| Window (${window.title})`);
|
||||
|
||||
window.folderURIs.forEach(uriComponents => {
|
||||
const folderUri = URI.revive(uriComponents);
|
||||
if (folderUri.scheme === 'file') {
|
||||
const folder = folderUri.fsPath;
|
||||
workspaceStatPromises.push(collectWorkspaceStats(folder, ['node_modules', '.git']).then(stats => {
|
||||
let countMessage = `${stats.fileCount} files`;
|
||||
if (stats.maxFilesReached) {
|
||||
countMessage = `more than ${countMessage}`;
|
||||
}
|
||||
output.push(`| Folder (${basename(folder)}): ${countMessage}`);
|
||||
output.push(this.formatWorkspaceStats(stats));
|
||||
|
||||
}).catch(error => {
|
||||
output.push(`| Error: Unable to collect workspace stats for folder ${folder} (${error.toString()})`);
|
||||
}));
|
||||
} else {
|
||||
output.push(`| Folder (${folderUri.toString()}): Workspace stats not available.`);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return Promise.all(workspaceStatPromises)
|
||||
.then(_ => output.join('\n'))
|
||||
.catch(e => `Unable to collect workspace stats: ${e}`);
|
||||
}
|
||||
|
||||
private formatProcessList(info: IMainProcessInfo, rootProcess: ProcessItem): string {
|
||||
const mapPidToWindowTitle = new Map<number, string>();
|
||||
info.windows.forEach(window => mapPidToWindowTitle.set(window.pid, window.title));
|
||||
|
||||
const output: string[] = [];
|
||||
|
||||
output.push('CPU %\tMem MB\t PID\tProcess');
|
||||
|
||||
if (rootProcess) {
|
||||
this.formatProcessItem(info.mainPID, mapPidToWindowTitle, output, rootProcess, 0);
|
||||
}
|
||||
|
||||
return output.join('\n');
|
||||
}
|
||||
|
||||
private formatProcessItem(mainPid: number, mapPidToWindowTitle: Map<number, string>, output: string[], item: ProcessItem, indent: number): void {
|
||||
const isRoot = (indent === 0);
|
||||
|
||||
const MB = 1024 * 1024;
|
||||
|
||||
// Format name with indent
|
||||
let name: string;
|
||||
if (isRoot) {
|
||||
name = item.pid === mainPid ? `${product.applicationName} main` : 'remote agent';
|
||||
} else {
|
||||
name = `${repeat(' ', indent)} ${item.name}`;
|
||||
|
||||
if (item.name === 'window') {
|
||||
name = `${name} (${mapPidToWindowTitle.get(item.pid)})`;
|
||||
}
|
||||
}
|
||||
const memory = process.platform === 'win32' ? item.mem : (osLib.totalmem() * (item.mem / 100));
|
||||
output.push(`${pad(Number(item.load.toFixed(0)), 5, ' ')}\t${pad(Number((memory / MB).toFixed(0)), 6, ' ')}\t${pad(Number((item.pid).toFixed(0)), 6, ' ')}\t${name}`);
|
||||
|
||||
// Recurse into children if any
|
||||
if (Array.isArray(item.children)) {
|
||||
item.children.forEach(child => this.formatProcessItem(mainPid, mapPidToWindowTitle, output, child, indent + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// function collectLaunchConfigs(folder: string): Promise<WorkspaceStatItem[]> {
|
||||
// const launchConfigs = new Map<string, number>();
|
||||
|
||||
// const launchConfig = join(folder, '.vscode', 'launch.json');
|
||||
// return new Promise((resolve, reject) => {
|
||||
// exists(launchConfig, (doesExist) => {
|
||||
// if (doesExist) {
|
||||
// readFile(launchConfig, (err, contents) => {
|
||||
// if (err) {
|
||||
// return resolve([]);
|
||||
// }
|
||||
|
||||
// const errors: ParseError[] = [];
|
||||
// const json = parse(contents.toString(), errors);
|
||||
// if (errors.length) {
|
||||
// output.push(`Unable to parse ${launchConfig}`);
|
||||
// return resolve([]);
|
||||
// }
|
||||
|
||||
// if (json['configurations']) {
|
||||
// for (const each of json['configurations']) {
|
||||
// const type = each['type'];
|
||||
// if (type) {
|
||||
// if (launchConfigs.has(type)) {
|
||||
// launchConfigs.set(type, launchConfigs.get(type)! + 1);
|
||||
// } else {
|
||||
// launchConfigs.set(type, 1);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// return resolve(asSortedItems(launchConfigs));
|
||||
// });
|
||||
// } else {
|
||||
// return resolve([]);
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
58
src/vs/platform/diagnostics/node/diagnosticsIpc.ts
Normal file
58
src/vs/platform/diagnostics/node/diagnosticsIpc.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IServerChannel, IChannel } from 'vs/base/parts/ipc/common/ipc';
|
||||
import { IDiagnosticsService, IRemoteDiagnosticInfo, IRemoteDiagnosticError, SystemInfo, PerformanceInfo } from 'vs/platform/diagnostics/common/diagnosticsService';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IMainProcessInfo } from 'vs/platform/launch/common/launchService';
|
||||
import { IWorkspace } from 'vs/platform/workspace/common/workspace';
|
||||
|
||||
export class DiagnosticsChannel implements IServerChannel {
|
||||
|
||||
constructor(private service: IDiagnosticsService) { }
|
||||
|
||||
listen(context: any, event: string): Event<any> {
|
||||
throw new Error('Invalid listen');
|
||||
}
|
||||
|
||||
call(context: any, command: string, args?: any): Promise<any> {
|
||||
switch (command) {
|
||||
case 'getDiagnostics':
|
||||
return this.service.getDiagnostics(args[0], args[1]);
|
||||
case 'getSystemInfo':
|
||||
return this.service.getSystemInfo(args[0], args[1]);
|
||||
case 'getPerformanceInfo':
|
||||
return this.service.getPerformanceInfo(args[0], args[1]);
|
||||
case 'reportWorkspaceStats':
|
||||
return this.service.reportWorkspaceStats(args);
|
||||
}
|
||||
|
||||
throw new Error('Invalid call');
|
||||
}
|
||||
}
|
||||
|
||||
export class DiagnosticsService implements IDiagnosticsService {
|
||||
|
||||
_serviceBrand: ServiceIdentifier<any>;
|
||||
|
||||
constructor(private channel: IChannel) { }
|
||||
|
||||
public getDiagnostics(mainProcessInfo: IMainProcessInfo, remoteInfo: (IRemoteDiagnosticInfo | IRemoteDiagnosticError)[]): Promise<string> {
|
||||
return this.channel.call('getDiagnostics', [mainProcessInfo, remoteInfo]);
|
||||
}
|
||||
|
||||
public getSystemInfo(mainProcessInfo: IMainProcessInfo, remoteInfo: (IRemoteDiagnosticInfo | IRemoteDiagnosticError)[]): Promise<SystemInfo> {
|
||||
return this.channel.call('getSystemInfo', [mainProcessInfo, remoteInfo]);
|
||||
}
|
||||
|
||||
public getPerformanceInfo(mainProcessInfo: IMainProcessInfo, remoteInfo: (IRemoteDiagnosticInfo | IRemoteDiagnosticError)[]): Promise<PerformanceInfo> {
|
||||
return this.channel.call('getPerformanceInfo', [mainProcessInfo, remoteInfo]);
|
||||
}
|
||||
|
||||
public reportWorkspaceStats(workspace: IWorkspace): Promise<void> {
|
||||
return this.channel.call('reportWorkspaceStats', workspace);
|
||||
}
|
||||
}
|
||||
@@ -2,28 +2,33 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as os from 'os';
|
||||
import * as osLib from 'os';
|
||||
import { virtualMachineHint } from 'vs/base/node/id';
|
||||
import { IMachineInfo, WorkspaceStats, WorkspaceStatItem } from 'vs/platform/diagnostics/common/diagnosticsService';
|
||||
import { readdir, stat } from 'fs';
|
||||
import { join } from 'vs/base/common/path';
|
||||
import { IMachineInfo, WorkspaceStats, WorkspaceStatItem, IDiagnosticsService, PerformanceInfo, SystemInfo, IRemoteDiagnosticInfo, IRemoteDiagnosticError, isRemoteDiagnosticError } from 'vs/platform/diagnostics/common/diagnosticsService';
|
||||
import { readdir, stat, exists, readFile } from 'fs';
|
||||
import { join, basename } from 'vs/base/common/path';
|
||||
import { parse, ParseError } from 'vs/base/common/json';
|
||||
import { listProcesses } from 'vs/base/node/ps';
|
||||
import product from 'vs/platform/product/node/product';
|
||||
import pkg from 'vs/platform/product/node/package';
|
||||
import { repeat, pad } from 'vs/base/common/strings';
|
||||
import { isWindows } from 'vs/base/common/platform';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { ProcessItem } from 'vs/base/common/processes';
|
||||
import { IMainProcessInfo } from 'vs/platform/launch/common/launchService';
|
||||
import { IWorkspace } from 'vs/platform/workspace/common/workspace';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
|
||||
export function getMachineInfo(): IMachineInfo {
|
||||
const MB = 1024 * 1024;
|
||||
const GB = 1024 * MB;
|
||||
export interface VersionInfo {
|
||||
vscodeVersion: string;
|
||||
os: string;
|
||||
}
|
||||
|
||||
const machineInfo: IMachineInfo = {
|
||||
os: `${os.type()} ${os.arch()} ${os.release()}`,
|
||||
memory: `${(os.totalmem() / GB).toFixed(2)}GB (${(os.freemem() / GB).toFixed(2)}GB free)`,
|
||||
vmHint: `${Math.round((virtualMachineHint.value() * 100))}%`,
|
||||
};
|
||||
|
||||
const cpus = os.cpus();
|
||||
if (cpus && cpus.length > 0) {
|
||||
machineInfo.cpus = `${cpus[0].model} (${cpus.length} x ${cpus[0].speed})`;
|
||||
}
|
||||
|
||||
return machineInfo;
|
||||
export interface ProcessInfo {
|
||||
cpu: number;
|
||||
memory: number;
|
||||
pid: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export function collectWorkspaceStats(folder: string, filter: string[]): Promise<WorkspaceStats> {
|
||||
@@ -145,16 +150,14 @@ export function collectWorkspaceStats(folder: string, filter: string[]): Promise
|
||||
walk(folder, filter, token, async (files) => {
|
||||
files.forEach(acceptFile);
|
||||
|
||||
// TODO@rachel commented out due to severe performance issues
|
||||
// see https://github.com/Microsoft/vscode/issues/70563
|
||||
// const launchConfigs = await collectLaunchConfigs(folder);
|
||||
const launchConfigs = await collectLaunchConfigs(folder);
|
||||
|
||||
resolve({
|
||||
configFiles: asSortedItems(configFiles),
|
||||
fileTypes: asSortedItems(fileTypes),
|
||||
fileCount: token.count,
|
||||
maxFilesReached: token.maxReached,
|
||||
// launchConfigFiles: launchConfigs
|
||||
launchConfigFiles: launchConfigs
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -164,4 +167,375 @@ function asSortedItems(map: Map<string, number>): WorkspaceStatItem[] {
|
||||
const a: WorkspaceStatItem[] = [];
|
||||
map.forEach((value, index) => a.push({ name: index, count: value }));
|
||||
return a.sort((a, b) => b.count - a.count);
|
||||
}
|
||||
|
||||
export function getMachineInfo(): IMachineInfo {
|
||||
const MB = 1024 * 1024;
|
||||
const GB = 1024 * MB;
|
||||
|
||||
const machineInfo: IMachineInfo = {
|
||||
os: `${osLib.type()} ${osLib.arch()} ${osLib.release()}`,
|
||||
memory: `${(osLib.totalmem() / GB).toFixed(2)}GB (${(osLib.freemem() / GB).toFixed(2)}GB free)`,
|
||||
vmHint: `${Math.round((virtualMachineHint.value() * 100))}%`,
|
||||
};
|
||||
|
||||
const cpus = osLib.cpus();
|
||||
if (cpus && cpus.length > 0) {
|
||||
machineInfo.cpus = `${cpus[0].model} (${cpus.length} x ${cpus[0].speed})`;
|
||||
}
|
||||
|
||||
return machineInfo;
|
||||
}
|
||||
|
||||
export function collectLaunchConfigs(folder: string): Promise<WorkspaceStatItem[]> {
|
||||
let launchConfigs = new Map<string, number>();
|
||||
|
||||
let launchConfig = join(folder, '.vscode', 'launch.json');
|
||||
return new Promise((resolve, reject) => {
|
||||
exists(launchConfig, (doesExist) => {
|
||||
if (doesExist) {
|
||||
readFile(launchConfig, (err, contents) => {
|
||||
if (err) {
|
||||
return resolve([]);
|
||||
}
|
||||
|
||||
const errors: ParseError[] = [];
|
||||
const json = parse(contents.toString(), errors);
|
||||
if (errors.length) {
|
||||
console.log(`Unable to parse ${launchConfig}`);
|
||||
return resolve([]);
|
||||
}
|
||||
|
||||
if (json['configurations']) {
|
||||
for (const each of json['configurations']) {
|
||||
const type = each['type'];
|
||||
if (type) {
|
||||
if (launchConfigs.has(type)) {
|
||||
launchConfigs.set(type, launchConfigs.get(type)! + 1);
|
||||
} else {
|
||||
launchConfigs.set(type, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return resolve(asSortedItems(launchConfigs));
|
||||
});
|
||||
} else {
|
||||
return resolve([]);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export class DiagnosticsService implements IDiagnosticsService {
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
constructor(@ITelemetryService private readonly telemetryService: ITelemetryService) { }
|
||||
|
||||
private formatMachineInfo(info: IMachineInfo): string {
|
||||
const output: string[] = [];
|
||||
output.push(`OS Version: ${info.os}`);
|
||||
output.push(`CPUs: ${info.cpus}`);
|
||||
output.push(`Memory (System): ${info.memory}`);
|
||||
output.push(`VM: ${info.vmHint}`);
|
||||
|
||||
return output.join('\n');
|
||||
}
|
||||
|
||||
private formatEnvironment(info: IMainProcessInfo): string {
|
||||
const MB = 1024 * 1024;
|
||||
const GB = 1024 * MB;
|
||||
|
||||
const output: string[] = [];
|
||||
output.push(`Version: ${pkg.name} ${pkg.version} (${product.commit || 'Commit unknown'}, ${product.date || 'Date unknown'})`);
|
||||
output.push(`OS Version: ${osLib.type()} ${osLib.arch()} ${osLib.release()}`);
|
||||
const cpus = osLib.cpus();
|
||||
if (cpus && cpus.length > 0) {
|
||||
output.push(`CPUs: ${cpus[0].model} (${cpus.length} x ${cpus[0].speed})`);
|
||||
}
|
||||
output.push(`Memory (System): ${(osLib.totalmem() / GB).toFixed(2)}GB (${(osLib.freemem() / GB).toFixed(2)}GB free)`);
|
||||
if (!isWindows) {
|
||||
output.push(`Load (avg): ${osLib.loadavg().map(l => Math.round(l)).join(', ')}`); // only provided on Linux/macOS
|
||||
}
|
||||
output.push(`VM: ${Math.round((virtualMachineHint.value() * 100))}%`);
|
||||
output.push(`Screen Reader: ${info.screenReader ? 'yes' : 'no'}`);
|
||||
output.push(`Process Argv: ${info.mainArguments.join(' ')}`);
|
||||
output.push(`GPU Status: ${this.expandGPUFeatures(info.gpuFeatureStatus)}`);
|
||||
|
||||
return output.join('\n');
|
||||
}
|
||||
|
||||
public async getPerformanceInfo(info: IMainProcessInfo, remoteData: (IRemoteDiagnosticInfo | IRemoteDiagnosticError)[]): Promise<PerformanceInfo> {
|
||||
return Promise.all<ProcessItem, string>([listProcesses(info.mainPID), this.formatWorkspaceMetadata(info)]).then(async result => {
|
||||
let [rootProcess, workspaceInfo] = result;
|
||||
let processInfo = this.formatProcessList(info, rootProcess);
|
||||
|
||||
remoteData.forEach(diagnostics => {
|
||||
if (isRemoteDiagnosticError(diagnostics)) {
|
||||
processInfo += `\n${diagnostics.errorMessage}`;
|
||||
workspaceInfo += `\n${diagnostics.errorMessage}`;
|
||||
} else {
|
||||
processInfo += `\n\nRemote: ${diagnostics.hostName}`;
|
||||
if (diagnostics.processes) {
|
||||
processInfo += `\n${this.formatProcessList(info, diagnostics.processes)}`;
|
||||
}
|
||||
|
||||
if (diagnostics.workspaceMetadata) {
|
||||
workspaceInfo += `\n| Remote: ${diagnostics.hostName}`;
|
||||
for (const folder of Object.keys(diagnostics.workspaceMetadata)) {
|
||||
const metadata = diagnostics.workspaceMetadata[folder];
|
||||
|
||||
let countMessage = `${metadata.fileCount} files`;
|
||||
if (metadata.maxFilesReached) {
|
||||
countMessage = `more than ${countMessage}`;
|
||||
}
|
||||
|
||||
workspaceInfo += `| Folder (${folder}): ${countMessage}`;
|
||||
workspaceInfo += this.formatWorkspaceStats(metadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
processInfo,
|
||||
workspaceInfo
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
public async getSystemInfo(info: IMainProcessInfo, remoteData: (IRemoteDiagnosticInfo | IRemoteDiagnosticError)[]): Promise<SystemInfo> {
|
||||
const { memory, vmHint, os, cpus } = getMachineInfo();
|
||||
const systemInfo: SystemInfo = {
|
||||
os,
|
||||
memory,
|
||||
cpus,
|
||||
vmHint,
|
||||
processArgs: `${info.mainArguments.join(' ')}`,
|
||||
gpuStatus: info.gpuFeatureStatus,
|
||||
screenReader: `${info.screenReader ? 'yes' : 'no'}`,
|
||||
remoteData
|
||||
};
|
||||
|
||||
|
||||
if (!isWindows) {
|
||||
systemInfo.load = `${osLib.loadavg().map(l => Math.round(l)).join(', ')}`;
|
||||
}
|
||||
|
||||
return Promise.resolve(systemInfo);
|
||||
}
|
||||
|
||||
public async getDiagnostics(info: IMainProcessInfo, remoteDiagnostics: (IRemoteDiagnosticInfo | IRemoteDiagnosticError)[]): Promise<string> {
|
||||
const output: string[] = [];
|
||||
return listProcesses(info.mainPID).then(async rootProcess => {
|
||||
|
||||
// Environment Info
|
||||
output.push('');
|
||||
output.push(this.formatEnvironment(info));
|
||||
|
||||
// Process List
|
||||
output.push('');
|
||||
output.push(this.formatProcessList(info, rootProcess));
|
||||
|
||||
// Workspace Stats
|
||||
if (info.windows.some(window => window.folderURIs && window.folderURIs.length > 0 && !window.remoteAuthority)) {
|
||||
output.push('');
|
||||
output.push('Workspace Stats: ');
|
||||
output.push(await this.formatWorkspaceMetadata(info));
|
||||
}
|
||||
|
||||
remoteDiagnostics.forEach(diagnostics => {
|
||||
if (isRemoteDiagnosticError(diagnostics)) {
|
||||
output.push(`\n${diagnostics.errorMessage}`);
|
||||
} else {
|
||||
output.push('\n\n');
|
||||
output.push(`Remote: ${diagnostics.hostName}`);
|
||||
output.push(this.formatMachineInfo(diagnostics.machineInfo));
|
||||
|
||||
if (diagnostics.processes) {
|
||||
output.push(this.formatProcessList(info, diagnostics.processes));
|
||||
}
|
||||
|
||||
if (diagnostics.workspaceMetadata) {
|
||||
for (const folder of Object.keys(diagnostics.workspaceMetadata)) {
|
||||
const metadata = diagnostics.workspaceMetadata[folder];
|
||||
|
||||
let countMessage = `${metadata.fileCount} files`;
|
||||
if (metadata.maxFilesReached) {
|
||||
countMessage = `more than ${countMessage}`;
|
||||
}
|
||||
|
||||
output.push(`Folder (${folder}): ${countMessage}`);
|
||||
output.push(this.formatWorkspaceStats(metadata));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
output.push('');
|
||||
output.push('');
|
||||
|
||||
return output.join('\n');
|
||||
});
|
||||
}
|
||||
|
||||
private formatWorkspaceStats(workspaceStats: WorkspaceStats): string {
|
||||
const output: string[] = [];
|
||||
const lineLength = 60;
|
||||
let col = 0;
|
||||
|
||||
const appendAndWrap = (name: string, count: number) => {
|
||||
const item = ` ${name}(${count})`;
|
||||
|
||||
if (col + item.length > lineLength) {
|
||||
output.push(line);
|
||||
line = '| ';
|
||||
col = line.length;
|
||||
}
|
||||
else {
|
||||
col += item.length;
|
||||
}
|
||||
line += item;
|
||||
};
|
||||
|
||||
// File Types
|
||||
let line = '| File types:';
|
||||
const maxShown = 10;
|
||||
let max = workspaceStats.fileTypes.length > maxShown ? maxShown : workspaceStats.fileTypes.length;
|
||||
for (let i = 0; i < max; i++) {
|
||||
const item = workspaceStats.fileTypes[i];
|
||||
appendAndWrap(item.name, item.count);
|
||||
}
|
||||
output.push(line);
|
||||
|
||||
// Conf Files
|
||||
if (workspaceStats.configFiles.length >= 0) {
|
||||
line = '| Conf files:';
|
||||
col = 0;
|
||||
workspaceStats.configFiles.forEach((item) => {
|
||||
appendAndWrap(item.name, item.count);
|
||||
});
|
||||
output.push(line);
|
||||
}
|
||||
|
||||
if (workspaceStats.launchConfigFiles.length > 0) {
|
||||
let line = '| Launch Configs:';
|
||||
workspaceStats.launchConfigFiles.forEach(each => {
|
||||
const item = each.count > 1 ? ` ${each.name}(${each.count})` : ` ${each.name}`;
|
||||
line += item;
|
||||
});
|
||||
output.push(line);
|
||||
}
|
||||
return output.join('\n');
|
||||
}
|
||||
|
||||
private expandGPUFeatures(gpuFeatures: any): string {
|
||||
const longestFeatureName = Math.max(...Object.keys(gpuFeatures).map(feature => feature.length));
|
||||
// Make columns aligned by adding spaces after feature name
|
||||
return Object.keys(gpuFeatures).map(feature => `${feature}: ${repeat(' ', longestFeatureName - feature.length)} ${gpuFeatures[feature]}`).join('\n ');
|
||||
}
|
||||
|
||||
private formatWorkspaceMetadata(info: IMainProcessInfo): Promise<string> {
|
||||
const output: string[] = [];
|
||||
const workspaceStatPromises: Promise<void>[] = [];
|
||||
|
||||
info.windows.forEach(window => {
|
||||
if (window.folderURIs.length === 0 || !!window.remoteAuthority) {
|
||||
return;
|
||||
}
|
||||
|
||||
output.push(`| Window (${window.title})`);
|
||||
|
||||
window.folderURIs.forEach(uriComponents => {
|
||||
const folderUri = URI.revive(uriComponents);
|
||||
if (folderUri.scheme === 'file') {
|
||||
const folder = folderUri.fsPath;
|
||||
workspaceStatPromises.push(collectWorkspaceStats(folder, ['node_modules', '.git']).then(stats => {
|
||||
let countMessage = `${stats.fileCount} files`;
|
||||
if (stats.maxFilesReached) {
|
||||
countMessage = `more than ${countMessage}`;
|
||||
}
|
||||
output.push(`| Folder (${basename(folder)}): ${countMessage}`);
|
||||
output.push(this.formatWorkspaceStats(stats));
|
||||
|
||||
}).catch(error => {
|
||||
output.push(`| Error: Unable to collect workspace stats for folder ${folder} (${error.toString()})`);
|
||||
}));
|
||||
} else {
|
||||
output.push(`| Folder (${folderUri.toString()}): Workspace stats not available.`);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return Promise.all(workspaceStatPromises)
|
||||
.then(_ => output.join('\n'))
|
||||
.catch(e => `Unable to collect workspace stats: ${e}`);
|
||||
}
|
||||
|
||||
private formatProcessList(info: IMainProcessInfo, rootProcess: ProcessItem): string {
|
||||
const mapPidToWindowTitle = new Map<number, string>();
|
||||
info.windows.forEach(window => mapPidToWindowTitle.set(window.pid, window.title));
|
||||
|
||||
const output: string[] = [];
|
||||
|
||||
output.push('CPU %\tMem MB\t PID\tProcess');
|
||||
|
||||
if (rootProcess) {
|
||||
this.formatProcessItem(info.mainPID, mapPidToWindowTitle, output, rootProcess, 0);
|
||||
}
|
||||
|
||||
return output.join('\n');
|
||||
}
|
||||
|
||||
private formatProcessItem(mainPid: number, mapPidToWindowTitle: Map<number, string>, output: string[], item: ProcessItem, indent: number): void {
|
||||
const isRoot = (indent === 0);
|
||||
|
||||
const MB = 1024 * 1024;
|
||||
|
||||
// Format name with indent
|
||||
let name: string;
|
||||
if (isRoot) {
|
||||
name = item.pid === mainPid ? `${product.applicationName} main` : 'remote agent';
|
||||
} else {
|
||||
name = `${repeat(' ', indent)} ${item.name}`;
|
||||
|
||||
if (item.name === 'window') {
|
||||
name = `${name} (${mapPidToWindowTitle.get(item.pid)})`;
|
||||
}
|
||||
}
|
||||
const memory = process.platform === 'win32' ? item.mem : (osLib.totalmem() * (item.mem / 100));
|
||||
output.push(`${pad(Number(item.load.toFixed(0)), 5, ' ')}\t${pad(Number((memory / MB).toFixed(0)), 6, ' ')}\t${pad(Number((item.pid).toFixed(0)), 6, ' ')}\t${name}`);
|
||||
|
||||
// Recurse into children if any
|
||||
if (Array.isArray(item.children)) {
|
||||
item.children.forEach(child => this.formatProcessItem(mainPid, mapPidToWindowTitle, output, child, indent + 1));
|
||||
}
|
||||
}
|
||||
|
||||
public async reportWorkspaceStats(workspace: IWorkspace): Promise<void> {
|
||||
workspace.folders.forEach(folder => {
|
||||
const folderUri = URI.revive(folder.uri);
|
||||
if (folderUri.scheme === 'file') {
|
||||
const folder = folderUri.fsPath;
|
||||
collectWorkspaceStats(folder, ['node_modules', '.git']).then(stats => {
|
||||
/* __GDPR__
|
||||
"workspace.stats" : {
|
||||
"fileTypes" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
|
||||
"configTypes" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
|
||||
"launchConfigs" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
|
||||
}
|
||||
*/
|
||||
this.telemetryService.publicLog('workspace.stats', {
|
||||
fileTypes: stats.fileTypes,
|
||||
configTypes: stats.configFiles,
|
||||
launchConfigs: stats.launchConfigFiles
|
||||
});
|
||||
}).catch(_ => {
|
||||
// Report nothing if collecting metadata fails.
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -9,10 +9,9 @@ import { ILayoutService } from 'vs/platform/layout/browser/layoutService';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import { Dialog } from 'vs/base/browser/ui/dialog/dialog';
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { attachDialogStyler } from 'vs/platform/theme/common/styler';
|
||||
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
import { EventHelper } from 'vs/base/browser/dom';
|
||||
|
||||
@@ -70,7 +69,7 @@ export class DialogService implements IDialogService {
|
||||
async show(severity: Severity, message: string, buttons: string[], options?: IDialogOptions): Promise<number> {
|
||||
this.logService.trace('DialogService#show', message);
|
||||
|
||||
const dialogDisposables: IDisposable[] = [];
|
||||
const dialogDisposables = new DisposableStore();
|
||||
const dialog = new Dialog(
|
||||
this.layoutService.container,
|
||||
message,
|
||||
@@ -84,14 +83,12 @@ export class DialogService implements IDialogService {
|
||||
}
|
||||
});
|
||||
|
||||
dialogDisposables.push(dialog);
|
||||
dialogDisposables.push(attachDialogStyler(dialog, this.themeService));
|
||||
dialogDisposables.add(dialog);
|
||||
dialogDisposables.add(attachDialogStyler(dialog, this.themeService));
|
||||
|
||||
const choice = await dialog.show();
|
||||
dispose(dialogDisposables);
|
||||
dialogDisposables.dispose();
|
||||
|
||||
return choice;
|
||||
}
|
||||
}
|
||||
|
||||
registerSingleton(IDialogService, DialogService, true);
|
||||
|
||||
@@ -36,7 +36,7 @@ export interface IConfirmationResult {
|
||||
|
||||
/**
|
||||
* This will only be defined if the confirmation was created
|
||||
* with the checkox option defined.
|
||||
* with the checkbox option defined.
|
||||
*/
|
||||
checkboxChecked?: boolean;
|
||||
}
|
||||
@@ -201,6 +201,11 @@ export interface IFileDialogService {
|
||||
*/
|
||||
pickWorkspaceAndOpen(options: IPickAndOpenOptions): Promise<void>;
|
||||
|
||||
/**
|
||||
* Shows a save file file dialog and save the file at the chosen file URI.
|
||||
*/
|
||||
pickFileToSave(options: ISaveDialogOptions): Promise<URI | undefined>;
|
||||
|
||||
/**
|
||||
* Shows a save file dialog and returns the chosen file URI.
|
||||
*/
|
||||
|
||||
@@ -7,19 +7,20 @@ import { IDownloadService } from 'vs/platform/download/common/download';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { copy } from 'vs/base/node/pfs';
|
||||
import { IRequestService } from 'vs/platform/request/node/request';
|
||||
import { asText, download } from 'vs/base/node/request';
|
||||
import { IRequestService, asText } from 'vs/platform/request/common/request';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { join } from 'vs/base/common/path';
|
||||
import { tmpdir } from 'os';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
|
||||
export class DownloadService implements IDownloadService {
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
constructor(
|
||||
@IRequestService private readonly requestService: IRequestService
|
||||
@IRequestService private readonly requestService: IRequestService,
|
||||
@IFileService private readonly fileService: IFileService
|
||||
) { }
|
||||
|
||||
download(uri: URI, target: string = join(tmpdir(), generateUuid()), cancellationToken: CancellationToken = CancellationToken.None): Promise<string> {
|
||||
@@ -30,7 +31,7 @@ export class DownloadService implements IDownloadService {
|
||||
return this.requestService.request(options, cancellationToken)
|
||||
.then(context => {
|
||||
if (context.res.statusCode === 200) {
|
||||
return download(target, context).then(() => target);
|
||||
return this.fileService.writeFile(URI.file(target), context.stream).then(() => target);
|
||||
}
|
||||
return asText(context)
|
||||
.then(message => Promise.reject(new Error(`Expected 200, got back ${context.res.statusCode} instead.\n\n${message}`)));
|
||||
|
||||
@@ -10,7 +10,7 @@ import { IMainProcessService } from 'vs/platform/ipc/electron-browser/mainProces
|
||||
import { getTopLeftOffset, getClientArea } from 'vs/base/browser/dom';
|
||||
import * as electron from 'electron';
|
||||
import { IWindowService } from 'vs/platform/windows/common/windows';
|
||||
import { Terminal } from 'vscode-xterm';
|
||||
import { Terminal } from 'xterm';
|
||||
import { timeout } from 'vs/base/common/async';
|
||||
import { coalesce } from 'vs/base/common/arrays';
|
||||
|
||||
|
||||
@@ -210,5 +210,5 @@ export async function serve(
|
||||
const channel = new DriverChannel(driver);
|
||||
server.registerChannel('driver', channel);
|
||||
|
||||
return combinedDisposable([server, windowServer]);
|
||||
return combinedDisposable(server, windowServer);
|
||||
}
|
||||
|
||||
@@ -95,15 +95,17 @@ export interface IEditorOptions {
|
||||
readonly forceReload?: boolean;
|
||||
|
||||
/**
|
||||
* Will reveal the editor if it is already opened and visible in any of the opened editor groups. Note
|
||||
* that this option is just a hint that might be ignored if the user wants to open an editor explicitly
|
||||
* Will reveal the editor if it is already opened and visible in any of the opened editor groups.
|
||||
*
|
||||
* Note that this option is just a hint that might be ignored if the user wants to open an editor explicitly
|
||||
* to the side of another one or into a specific editor group.
|
||||
*/
|
||||
readonly revealIfVisible?: boolean;
|
||||
|
||||
/**
|
||||
* Will reveal the editor if it is already opened (even when not visible) in any of the opened editor groups. Note
|
||||
* that this option is just a hint that might be ignored if the user wants to open an editor explicitly
|
||||
* Will reveal the editor if it is already opened (even when not visible) in any of the opened editor groups.
|
||||
*
|
||||
* Note that this option is just a hint that might be ignored if the user wants to open an editor explicitly
|
||||
* to the side of another one or into a specific editor group.
|
||||
*/
|
||||
readonly revealIfOpened?: boolean;
|
||||
|
||||
@@ -13,6 +13,7 @@ export interface ParsedArgs {
|
||||
_urls?: string[];
|
||||
help?: boolean;
|
||||
version?: boolean;
|
||||
telemetry?: boolean;
|
||||
status?: boolean;
|
||||
wait?: boolean;
|
||||
waitMarkerFilePath?: string;
|
||||
@@ -27,7 +28,6 @@ export interface ParsedArgs {
|
||||
'prof-startup'?: string;
|
||||
'prof-startup-prefix'?: string;
|
||||
'prof-append-timers'?: string;
|
||||
'prof-modules'?: string;
|
||||
verbose?: boolean;
|
||||
trace?: boolean;
|
||||
'trace-category-filter'?: string;
|
||||
@@ -65,10 +65,11 @@ export interface ParsedArgs {
|
||||
'max-memory'?: string;
|
||||
'file-write'?: boolean;
|
||||
'file-chmod'?: boolean;
|
||||
'upload-logs'?: string;
|
||||
'driver'?: string;
|
||||
'driver-verbose'?: boolean;
|
||||
remote?: string;
|
||||
'disable-user-env-probe'?: boolean;
|
||||
'enable-remote-auto-shutdown'?: boolean;
|
||||
// {{SQL CARBON EDIT}}
|
||||
aad?: boolean;
|
||||
database?: string;
|
||||
@@ -77,6 +78,16 @@ export interface ParsedArgs {
|
||||
user?: string;
|
||||
command?: string;
|
||||
// {{SQL CARBON EDIT}}
|
||||
'disable-inspect'?: boolean;
|
||||
'force'?: boolean;
|
||||
'gitCredential'?: string;
|
||||
// node flags
|
||||
'js-flags'?: boolean;
|
||||
'disable-gpu'?: boolean;
|
||||
'nolazy'?: boolean;
|
||||
|
||||
// Web flags
|
||||
'web-user-data-dir'?: string;
|
||||
}
|
||||
|
||||
export const IEnvironmentService = createDecorator<IEnvironmentService>('environmentService');
|
||||
@@ -90,6 +101,8 @@ export interface IExtensionHostDebugParams extends IDebugParams {
|
||||
debugId?: string;
|
||||
}
|
||||
|
||||
export const BACKUPS = 'Backups';
|
||||
|
||||
export interface IEnvironmentService {
|
||||
_serviceBrand: any;
|
||||
|
||||
@@ -104,20 +117,22 @@ export interface IEnvironmentService {
|
||||
|
||||
appNameLong: string;
|
||||
appQuality?: string;
|
||||
appSettingsHome: string;
|
||||
appSettingsPath: string;
|
||||
appKeybindingsPath: string;
|
||||
appSettingsHome: URI;
|
||||
|
||||
machineSettingsHome: string;
|
||||
machineSettingsPath: string;
|
||||
// user roaming data
|
||||
userRoamingDataHome: URI;
|
||||
settingsResource: URI;
|
||||
keybindingsResource: URI;
|
||||
keyboardLayoutResource: URI;
|
||||
localeResource: URI;
|
||||
|
||||
settingsSearchBuildId?: number;
|
||||
settingsSearchUrl?: string;
|
||||
machineSettingsHome: URI;
|
||||
machineSettingsResource: URI;
|
||||
|
||||
globalStorageHome: string;
|
||||
workspaceStorageHome: string;
|
||||
|
||||
backupHome: string;
|
||||
backupHome: URI;
|
||||
backupWorkspacesPath: string;
|
||||
|
||||
untitledWorkspacesHome: URI;
|
||||
@@ -159,4 +174,8 @@ export interface IEnvironmentService {
|
||||
|
||||
driverHandle?: string;
|
||||
driverVerbose: boolean;
|
||||
|
||||
webviewEndpoint?: string;
|
||||
readonly webviewResourceRoot: string;
|
||||
readonly webviewCspSource: string;
|
||||
}
|
||||
|
||||
@@ -8,28 +8,28 @@ import * as os from 'os';
|
||||
import { localize } from 'vs/nls';
|
||||
import { ParsedArgs } from 'vs/platform/environment/common/environment';
|
||||
import { join } from 'vs/base/common/path';
|
||||
import { writeFileSync } from 'fs';
|
||||
import { writeFileSync } from 'vs/base/node/pfs';
|
||||
|
||||
/**
|
||||
* This code is also used by standalone cli's. Avoid adding any other dependencies.
|
||||
*/
|
||||
|
||||
class HelpCategories {
|
||||
o = localize('optionsUpperCase', "Options");
|
||||
e = localize('extensionsManagement', "Extensions Management");
|
||||
t = localize('troubleshooting', "Troubleshooting");
|
||||
}
|
||||
const helpCategories = {
|
||||
o: localize('optionsUpperCase', "Options"),
|
||||
e: localize('extensionsManagement', "Extensions Management"),
|
||||
t: localize('troubleshooting', "Troubleshooting")
|
||||
};
|
||||
|
||||
export interface Option {
|
||||
id: string;
|
||||
id: keyof ParsedArgs;
|
||||
type: 'boolean' | 'string';
|
||||
alias?: string;
|
||||
deprecates?: string; // old deprecated id
|
||||
args?: string | string[];
|
||||
description?: string;
|
||||
cat?: keyof HelpCategories;
|
||||
cat?: keyof typeof helpCategories;
|
||||
}
|
||||
|
||||
//_urls
|
||||
export const options: Option[] = [
|
||||
{ id: 'diff', type: 'boolean', cat: 'o', alias: 'd', args: ['file', 'file'], description: localize('diff', "Compare two files with each other.") },
|
||||
{ id: 'add', type: 'boolean', cat: 'o', alias: 'a', args: 'folder', description: localize('add', "Add folder(s) to the last active window.") },
|
||||
@@ -41,6 +41,7 @@ export const options: Option[] = [
|
||||
{ id: 'user-data-dir', type: 'string', cat: 'o', args: 'dir', description: localize('userDataDir', "Specifies the directory that user data is kept in. Can be used to open multiple distinct instances of Code.") },
|
||||
{ id: 'version', type: 'boolean', cat: 'o', alias: 'v', description: localize('version', "Print version.") },
|
||||
{ id: 'help', type: 'boolean', cat: 'o', alias: 'h', description: localize('help', "Print usage.") },
|
||||
{ id: 'telemetry', type: 'boolean', cat: 'o', description: localize('telemetry', "Shows all telemetry events which VS code collects.") },
|
||||
{ id: 'folder-uri', type: 'string', cat: 'o', args: 'uri', description: localize('folderUri', "Opens a window with given folder uri(s)") },
|
||||
{ id: 'file-uri', type: 'string', cat: 'o', args: 'uri', description: localize('fileUri', "Opens a window with given file uri(s)") },
|
||||
|
||||
@@ -54,7 +55,6 @@ export const options: Option[] = [
|
||||
{ id: 'verbose', type: 'boolean', cat: 't', description: localize('verbose', "Print verbose output (implies --wait).") },
|
||||
{ id: 'log', type: 'string', cat: 't', args: 'level', description: localize('log', "Log level to use. Default is 'info'. Allowed values are 'critical', 'error', 'warn', 'info', 'debug', 'trace', 'off'.") },
|
||||
{ id: 'status', type: 'boolean', alias: 's', cat: 't', description: localize('status', "Print process usage and diagnostics information.") },
|
||||
{ id: 'prof-modules', type: 'boolean', alias: 'p', cat: 't', description: localize('prof-modules', "Capture performance markers while loading JS modules and print them with 'F1 > Developer: Startup Performance") },
|
||||
{ id: 'prof-startup', type: 'boolean', cat: 't', description: localize('prof-startup', "Run CPU profiler during startup") },
|
||||
{ id: 'disable-extensions', type: 'boolean', deprecates: 'disableExtensions', cat: 't', description: localize('disableExtensions', "Disable all installed extensions.") },
|
||||
{ id: 'disable-extension', type: 'string', cat: 't', args: 'extension-id', description: localize('disableExtension', "Disable an extension.") },
|
||||
@@ -62,7 +62,6 @@ export const options: Option[] = [
|
||||
{ id: 'inspect-extensions', type: 'string', deprecates: 'debugPluginHost', args: 'port', cat: 't', description: localize('inspect-extensions', "Allow debugging and profiling of extensions. Check the developer tools for the connection URI.") },
|
||||
{ id: 'inspect-brk-extensions', type: 'string', deprecates: 'debugBrkPluginHost', args: 'port', cat: 't', description: localize('inspect-brk-extensions', "Allow debugging and profiling of extensions with the extension host being paused after start. Check the developer tools for the connection URI.") },
|
||||
{ id: 'disable-gpu', type: 'boolean', cat: 't', description: localize('disableGPU', "Disable GPU hardware acceleration.") },
|
||||
{ id: 'upload-logs', type: 'string', cat: 't', description: localize('uploadLogs', "Uploads logs from current session to a secure endpoint.") },
|
||||
{ id: 'max-memory', type: 'string', cat: 't', description: localize('maxMemory', "Max memory size for a window (in Mbytes).") },
|
||||
|
||||
{ id: 'remote', type: 'string' },
|
||||
@@ -86,15 +85,14 @@ export const options: Option[] = [
|
||||
{ id: 'skip-add-to-recently-opened', type: 'boolean' },
|
||||
{ id: 'unity-launch', type: 'boolean' },
|
||||
{ id: 'open-url', type: 'boolean' },
|
||||
{ id: 'nolazy', type: 'boolean' },
|
||||
{ id: 'issue', type: 'boolean' },
|
||||
{ id: 'file-write', type: 'boolean' },
|
||||
{ id: 'file-chmod', type: 'boolean' },
|
||||
{ id: 'driver-verbose', type: 'boolean' },
|
||||
{ id: 'force', type: 'boolean' },
|
||||
{ id: 'trace-category-filter', type: 'string' },
|
||||
{ id: 'trace-options', type: 'string' },
|
||||
{ id: 'prof-code-loading', type: 'boolean' },
|
||||
{ id: '_', type: 'string' },
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
{ id: 'command', type: 'string', alias: 'c', cat: 'o', args: 'command-name', description: localize('commandParameter', 'Name of command to run') },
|
||||
{ id: 'database', type: 'string', alias: 'D', cat: 'o', args: 'database', description: localize('databaseParameter', 'Database name') },
|
||||
@@ -103,7 +101,9 @@ export const options: Option[] = [
|
||||
{ id: 'aad', type: 'boolean', cat: 'o', description: localize('aadParameter', 'Use Azure Active Directory authentication for server connection') },
|
||||
{ id: 'integrated', type: 'boolean', alias: 'E', cat: 'o', description: localize('integratedAuthParameter', 'Use Integrated authentication for server connection') },
|
||||
// {{SQL CARBON EDIT}} - End
|
||||
{ id: '_', type: 'string' }
|
||||
|
||||
{ id: 'js-flags', type: 'string' }, // chrome js flags
|
||||
{ id: 'nolazy', type: 'boolean' }, // node inspect
|
||||
];
|
||||
|
||||
export function parseArgs(args: string[], isOptionSupported = (_: Option) => true): ParsedArgs {
|
||||
@@ -130,8 +130,8 @@ export function parseArgs(args: string[], isOptionSupported = (_: Option) => tru
|
||||
}
|
||||
}
|
||||
// remote aliases to avoid confusion
|
||||
const parsedArgs = minimist(args, { string, boolean, alias }) as ParsedArgs;
|
||||
for (let o of options) {
|
||||
const parsedArgs = minimist(args, { string, boolean, alias });
|
||||
for (const o of options) {
|
||||
if (o.alias) {
|
||||
delete parsedArgs[o.alias];
|
||||
}
|
||||
@@ -198,8 +198,6 @@ function wrapText(text: string, columns: number): string[] {
|
||||
export function buildHelpMessage(productName: string, executableName: string, version: string, isOptionSupported = (_: Option) => true, isPipeSupported = true): string {
|
||||
const columns = (process.stdout).isTTY && (process.stdout).columns || 80;
|
||||
|
||||
let categories = new HelpCategories();
|
||||
|
||||
let help = [`${productName} ${version}`];
|
||||
help.push('');
|
||||
help.push(`${localize('usage', "Usage")}: ${executableName} [${localize('options', "options")}][${localize('paths', 'paths')}...]`);
|
||||
@@ -212,10 +210,12 @@ export function buildHelpMessage(productName: string, executableName: string, ve
|
||||
}
|
||||
help.push('');
|
||||
}
|
||||
for (let key in categories) {
|
||||
for (let helpCategoryKey in helpCategories) {
|
||||
const key = <keyof typeof helpCategories>helpCategoryKey;
|
||||
|
||||
let categoryOptions = options.filter(o => !!o.description && o.cat === key && isOptionSupported(o));
|
||||
if (categoryOptions.length) {
|
||||
help.push(categories[key]);
|
||||
help.push(helpCategories[key]);
|
||||
help.push(...formatOptions(categoryOptions, columns));
|
||||
help.push('');
|
||||
}
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IEnvironmentService, ParsedArgs, IDebugParams, IExtensionHostDebugParams } from 'vs/platform/environment/common/environment';
|
||||
import { IEnvironmentService, ParsedArgs, IDebugParams, IExtensionHostDebugParams, BACKUPS } from 'vs/platform/environment/common/environment';
|
||||
import * as crypto from 'crypto';
|
||||
import * as paths from 'vs/base/node/paths';
|
||||
import * as os from 'os';
|
||||
import * as path from 'vs/base/common/path';
|
||||
import * as resources from 'vs/base/common/resources';
|
||||
import { memoize } from 'vs/base/common/decorators';
|
||||
import pkg from 'vs/platform/product/node/package';
|
||||
import product from 'vs/platform/product/node/product';
|
||||
@@ -21,7 +22,9 @@ import { URI } from 'vs/base/common/uri';
|
||||
const xdgRuntimeDir = process.env['XDG_RUNTIME_DIR'];
|
||||
|
||||
function getNixIPCHandle(userDataPath: string, type: string): string {
|
||||
if (xdgRuntimeDir) {
|
||||
const vscodePortable = process.env['VSCODE_PORTABLE'];
|
||||
|
||||
if (xdgRuntimeDir && !vscodePortable) {
|
||||
const scope = crypto.createHash('md5').update(userDataPath).digest('hex').substr(0, 8);
|
||||
return path.join(xdgRuntimeDir, `vscode-${scope}-${pkg.version}-${type}.sock`);
|
||||
}
|
||||
@@ -93,6 +96,7 @@ export class EnvironmentService implements IEnvironmentService {
|
||||
@memoize
|
||||
get userDataPath(): string {
|
||||
const vscodePortable = process.env['VSCODE_PORTABLE'];
|
||||
|
||||
if (vscodePortable) {
|
||||
return path.join(vscodePortable, 'user-data');
|
||||
}
|
||||
@@ -100,45 +104,51 @@ export class EnvironmentService implements IEnvironmentService {
|
||||
return parseUserDataDir(this._args, process);
|
||||
}
|
||||
|
||||
@memoize
|
||||
get webUserDataHome(): URI { return URI.file(parsePathArg(this._args['web-user-data-dir'], process) || this.userDataPath); }
|
||||
|
||||
get appNameLong(): string { return product.nameLong; }
|
||||
|
||||
get appQuality(): string | undefined { return product.quality; }
|
||||
|
||||
@memoize
|
||||
get appSettingsHome(): string { return path.join(this.userDataPath, 'User'); }
|
||||
get appSettingsHome(): URI { return URI.file(path.join(this.userDataPath, 'User')); }
|
||||
|
||||
@memoize
|
||||
get appSettingsPath(): string { return path.join(this.appSettingsHome, 'settings.json'); }
|
||||
get userRoamingDataHome(): URI { return this.appSettingsHome; }
|
||||
|
||||
@memoize
|
||||
get machineSettingsHome(): string { return path.join(this.userDataPath, 'Machine'); }
|
||||
get settingsResource(): URI { return resources.joinPath(this.userRoamingDataHome, 'settings.json'); }
|
||||
|
||||
@memoize
|
||||
get machineSettingsPath(): string { return path.join(this.machineSettingsHome, 'settings.json'); }
|
||||
get machineSettingsHome(): URI { return URI.file(path.join(this.userDataPath, 'Machine')); }
|
||||
|
||||
@memoize
|
||||
get globalStorageHome(): string { return path.join(this.appSettingsHome, 'globalStorage'); }
|
||||
get machineSettingsResource(): URI { return resources.joinPath(this.machineSettingsHome, 'settings.json'); }
|
||||
|
||||
@memoize
|
||||
get workspaceStorageHome(): string { return path.join(this.appSettingsHome, 'workspaceStorage'); }
|
||||
get globalStorageHome(): string { return path.join(this.appSettingsHome.fsPath, 'globalStorage'); }
|
||||
|
||||
@memoize
|
||||
get settingsSearchBuildId(): number | undefined { return product.settingsSearchBuildId; }
|
||||
get workspaceStorageHome(): string { return path.join(this.appSettingsHome.fsPath, 'workspaceStorage'); }
|
||||
|
||||
@memoize
|
||||
get settingsSearchUrl(): string | undefined { return product.settingsSearchUrl; }
|
||||
get keybindingsResource(): URI { return resources.joinPath(this.userRoamingDataHome, 'keybindings.json'); }
|
||||
|
||||
@memoize
|
||||
get appKeybindingsPath(): string { return path.join(this.appSettingsHome, 'keybindings.json'); }
|
||||
get keyboardLayoutResource(): URI { return resources.joinPath(this.userRoamingDataHome, 'keyboardLayout.json'); }
|
||||
|
||||
@memoize
|
||||
get localeResource(): URI { return resources.joinPath(this.userRoamingDataHome, 'locale.json'); }
|
||||
|
||||
@memoize
|
||||
get isExtensionDevelopment(): boolean { return !!this._args.extensionDevelopmentPath; }
|
||||
|
||||
@memoize
|
||||
get backupHome(): string { return path.join(this.userDataPath, 'Backups'); }
|
||||
get backupHome(): URI { return URI.file(path.join(this.userDataPath, BACKUPS)); }
|
||||
|
||||
@memoize
|
||||
get backupWorkspacesPath(): string { return path.join(this.backupHome, 'workspaces.json'); }
|
||||
get backupWorkspacesPath(): string { return path.join(this.backupHome.fsPath, 'workspaces.json'); }
|
||||
|
||||
@memoize
|
||||
get untitledWorkspacesHome(): URI { return URI.file(path.join(this.userDataPath, 'Workspaces')); }
|
||||
@@ -170,6 +180,7 @@ export class EnvironmentService implements IEnvironmentService {
|
||||
}
|
||||
|
||||
const vscodePortable = process.env['VSCODE_PORTABLE'];
|
||||
|
||||
if (vscodePortable) {
|
||||
return path.join(vscodePortable, 'extensions');
|
||||
}
|
||||
@@ -261,6 +272,9 @@ export class EnvironmentService implements IEnvironmentService {
|
||||
get driverHandle(): string | undefined { return this._args['driver']; }
|
||||
get driverVerbose(): boolean { return !!this._args['driver-verbose']; }
|
||||
|
||||
readonly webviewResourceRoot = 'vscode-resource:{{resource}}';
|
||||
readonly webviewCspSource = 'vscode-resource:';
|
||||
|
||||
constructor(private _args: ParsedArgs, private _execPath: string) {
|
||||
if (!process.env['VSCODE_LOGS']) {
|
||||
const key = toLocalISOString(new Date()).replace(/-|:|\.\d+Z$/g, '');
|
||||
@@ -285,10 +299,11 @@ export function parseSearchPort(args: ParsedArgs, isBuild: boolean): IDebugParam
|
||||
return parseDebugPort(args['inspect-search'], args['inspect-brk-search'], 5876, isBuild);
|
||||
}
|
||||
|
||||
export function parseDebugPort(debugArg: string | undefined, debugBrkArg: string | undefined, defaultBuildPort: number, isBuild: boolean, debugId?: string): IExtensionHostDebugParams {
|
||||
function parseDebugPort(debugArg: string | undefined, debugBrkArg: string | undefined, defaultBuildPort: number, isBuild: boolean, debugId?: string): IExtensionHostDebugParams {
|
||||
const portStr = debugBrkArg || debugArg;
|
||||
const port = Number(portStr) || (!isBuild ? defaultBuildPort : null);
|
||||
const brk = port ? Boolean(!!debugBrkArg) : false;
|
||||
|
||||
return { port, break: brk, debugId };
|
||||
}
|
||||
|
||||
@@ -303,9 +318,9 @@ function parsePathArg(arg: string | undefined, process: NodeJS.Process): string
|
||||
|
||||
if (path.normalize(arg) === resolved) {
|
||||
return resolved;
|
||||
} else {
|
||||
return path.resolve(process.env['VSCODE_CWD'] || process.cwd(), arg);
|
||||
}
|
||||
|
||||
return path.resolve(process.env['VSCODE_CWD'] || process.cwd(), arg);
|
||||
}
|
||||
|
||||
export function parseUserDataDir(args: ParsedArgs, process: NodeJS.Process): string {
|
||||
|
||||
@@ -3,21 +3,15 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { tmpdir } from 'os';
|
||||
import * as path from 'vs/base/common/path';
|
||||
import { getErrorMessage, isPromiseCanceledError, canceled } from 'vs/base/common/errors';
|
||||
import { StatisticType, IGalleryExtension, IExtensionGalleryService, IGalleryExtensionAsset, IQueryOptions, SortBy, SortOrder, IExtensionIdentifier, IReportedExtension, InstallOperation, ITranslation, IGalleryExtensionVersion, IGalleryExtensionAssets, isIExtensionIdentifier } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { getGalleryExtensionId, getGalleryExtensionTelemetryData, adoptToGalleryExtensionId } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
|
||||
import { assign, getOrDefault } from 'vs/base/common/objects';
|
||||
import { IRequestService } from 'vs/platform/request/node/request';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IPager } from 'vs/base/common/paging';
|
||||
import { IRequestOptions, IRequestContext, download, asJson, asText } from 'vs/base/node/request';
|
||||
import pkg from 'vs/platform/product/node/package';
|
||||
import product from 'vs/platform/product/node/product';
|
||||
import { isEngineValid } from 'vs/platform/extensions/node/extensionValidator';
|
||||
import { IRequestService, IRequestOptions, IRequestContext, asJson, asText } from 'vs/platform/request/common/request';
|
||||
import { isEngineValid } from 'vs/platform/extensions/common/extensionValidator';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { writeFileSync, readFile } from 'vs/base/node/pfs';
|
||||
import { generateUuid, isUUID } from 'vs/base/common/uuid';
|
||||
import { values } from 'vs/base/common/map';
|
||||
// {{SQL CARBON EDIT}}
|
||||
@@ -27,6 +21,11 @@ import { ExtensionsPolicy, ExtensionsPolicyKey } from 'vs/workbench/contrib/exte
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { IExtensionManifest } from 'vs/platform/extensions/common/extensions';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { joinPath } from 'vs/base/common/resources';
|
||||
import { VSBuffer } from 'vs/base/common/buffer';
|
||||
import { IProductService } from 'vs/platform/product/common/product';
|
||||
|
||||
interface IRawGalleryExtensionFile {
|
||||
assetType: string;
|
||||
@@ -212,13 +211,16 @@ function getStatistic(statistics: IRawGalleryExtensionStatistics[], name: string
|
||||
return result ? result.value : 0;
|
||||
}
|
||||
|
||||
function getCoreTranslationAssets(version: IRawGalleryExtensionVersion): { [languageId: string]: IGalleryExtensionAsset } {
|
||||
function getCoreTranslationAssets(version: IRawGalleryExtensionVersion): [string, IGalleryExtensionAsset][] {
|
||||
const coreTranslationAssetPrefix = 'Microsoft.VisualStudio.Code.Translation.';
|
||||
const result = version.files.filter(f => f.assetType.indexOf(coreTranslationAssetPrefix) === 0);
|
||||
return result.reduce((result, file) => {
|
||||
result[file.assetType.substring(coreTranslationAssetPrefix.length)] = getVersionAsset(version, file.assetType);
|
||||
return result.reduce<[string, IGalleryExtensionAsset][]>((result, file) => {
|
||||
const asset = getVersionAsset(version, file.assetType);
|
||||
if (asset) {
|
||||
result.push([file.assetType.substring(coreTranslationAssetPrefix.length), asset]);
|
||||
}
|
||||
return result;
|
||||
}, {});
|
||||
}, []);
|
||||
}
|
||||
|
||||
function getRepositoryAsset(version: IRawGalleryExtensionVersion): IGalleryExtensionAsset | null {
|
||||
@@ -372,8 +374,8 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
private extensionsGalleryUrl: string;
|
||||
private extensionsControlUrl: string;
|
||||
private extensionsGalleryUrl: string | undefined;
|
||||
private extensionsControlUrl: string | undefined;
|
||||
|
||||
private readonly commonHeadersPromise: Promise<{ [key: string]: string; }>;
|
||||
|
||||
@@ -383,12 +385,14 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
|
||||
@IEnvironmentService private readonly environmentService: IEnvironmentService,
|
||||
@ITelemetryService private readonly telemetryService: ITelemetryService,
|
||||
// {{SQL CARBON EDIT}}
|
||||
@IConfigurationService private configurationService: IConfigurationService
|
||||
@IConfigurationService private configurationService: IConfigurationService,
|
||||
@IFileService private readonly fileService: IFileService,
|
||||
@IProductService private readonly productService: IProductService,
|
||||
) {
|
||||
const config = product.extensionsGallery;
|
||||
const config = productService.extensionsGallery;
|
||||
this.extensionsGalleryUrl = config && config.serviceUrl;
|
||||
this.extensionsControlUrl = config && config.controlUrl;
|
||||
this.commonHeadersPromise = resolveMarketplaceHeaders(this.environmentService);
|
||||
this.commonHeadersPromise = resolveMarketplaceHeaders(productService.version, this.environmentService, this.fileService);
|
||||
}
|
||||
|
||||
private api(path = ''): string {
|
||||
@@ -433,7 +437,7 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
|
||||
const versionAsset = rawExtension.versions.filter(v => v.version === version)[0];
|
||||
if (versionAsset) {
|
||||
const extension = toExtension(rawExtension, versionAsset, 0, query);
|
||||
if (extension.properties.engine && isEngineValid(extension.properties.engine)) {
|
||||
if (extension.properties.engine && isEngineValid(extension.properties.engine, this.productService.version)) {
|
||||
return extension;
|
||||
}
|
||||
}
|
||||
@@ -697,9 +701,9 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
|
||||
});
|
||||
}
|
||||
|
||||
download(extension: IGalleryExtension, operation: InstallOperation): Promise<string> {
|
||||
download(extension: IGalleryExtension, location: URI, operation: InstallOperation): Promise<URI> {
|
||||
this.logService.trace('ExtensionGalleryService#download', extension.identifier.id);
|
||||
const zipPath = path.join(tmpdir(), generateUuid());
|
||||
const zip = joinPath(location, generateUuid());
|
||||
const data = getGalleryExtensionTelemetryData(extension);
|
||||
const startTime = new Date().getTime();
|
||||
/* __GDPR__
|
||||
@@ -721,9 +725,9 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
|
||||
} : extension.assets.download;
|
||||
|
||||
return this.getAsset(downloadAsset)
|
||||
.then(context => download(zipPath, context))
|
||||
.then(context => this.fileService.writeFile(zip, context.stream))
|
||||
.then(() => log(new Date().getTime() - startTime))
|
||||
.then(() => zipPath);
|
||||
.then(() => zip);
|
||||
}
|
||||
|
||||
getReadme(extension: IGalleryExtension, token: CancellationToken): Promise<string> {
|
||||
@@ -745,9 +749,9 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
|
||||
}
|
||||
|
||||
getCoreTranslation(extension: IGalleryExtension, languageId: string): Promise<ITranslation | null> {
|
||||
const asset = extension.assets.coreTranslations[languageId.toUpperCase()];
|
||||
const asset = extension.assets.coreTranslations.filter(t => t[0] === languageId.toUpperCase())[0];
|
||||
if (asset) {
|
||||
return this.getAsset(asset)
|
||||
return this.getAsset(asset[1])
|
||||
.then(asText)
|
||||
.then(JSON.parse);
|
||||
}
|
||||
@@ -779,7 +783,7 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
|
||||
return this.queryGallery(query, CancellationToken.None).then(({ galleryExtensions }) => {
|
||||
if (galleryExtensions.length) {
|
||||
if (compatible) {
|
||||
return Promise.all(galleryExtensions[0].versions.map(v => this.getEngine(v).then(engine => isEngineValid(engine) ? v : null)))
|
||||
return Promise.all(galleryExtensions[0].versions.map(v => this.getEngine(v).then(engine => isEngineValid(engine, this.productService.version) ? v : null)))
|
||||
.then(versions => versions
|
||||
.filter(v => !!v)
|
||||
.map(v => ({ version: v!.version, date: v!.lastUpdated })));
|
||||
@@ -816,21 +820,26 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
|
||||
}
|
||||
|
||||
const message = getErrorMessage(err);
|
||||
/* __GDPR__
|
||||
"galleryService:requestError" : {
|
||||
"url" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
|
||||
"cdn": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
|
||||
"message": { "classification": "CallstackOrException", "purpose": "FeatureInsight" }
|
||||
}
|
||||
*/
|
||||
this.telemetryService.publicLog('galleryService:requestError', { url, cdn: true, message });
|
||||
/* __GDPR__
|
||||
"galleryService:cdnFallback" : {
|
||||
"url" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
|
||||
"message": { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
|
||||
}
|
||||
*/
|
||||
this.telemetryService.publicLog('galleryService:cdnFallback', { url, message });
|
||||
type GalleryServiceRequestErrorClassification = {
|
||||
url: { classification: 'SystemMetaData', purpose: 'FeatureInsight' };
|
||||
cdn: { classification: 'SystemMetaData', purpose: 'FeatureInsight', isMeasurement: true };
|
||||
message: { classification: 'CallstackOrException', purpose: 'FeatureInsight' };
|
||||
};
|
||||
type GalleryServiceRequestErrorEvent = {
|
||||
url: string;
|
||||
cdn: boolean;
|
||||
message: string;
|
||||
};
|
||||
this.telemetryService.publicLog2<GalleryServiceRequestErrorEvent, GalleryServiceRequestErrorClassification>('galleryService:requestError', { url, cdn: true, message });
|
||||
type GalleryServiceCDNFallbackClassification = {
|
||||
url: { classification: 'SystemMetaData', purpose: 'FeatureInsight' };
|
||||
message: { classification: 'SystemMetaData', purpose: 'FeatureInsight' };
|
||||
};
|
||||
type GalleryServiceCDNFallbackEvent = {
|
||||
url: string;
|
||||
message: string;
|
||||
};
|
||||
this.telemetryService.publicLog2<GalleryServiceCDNFallbackEvent, GalleryServiceCDNFallbackClassification>('galleryService:cdnFallback', { url, message });
|
||||
|
||||
const fallbackOptions = assign({}, options, { url: fallbackUrl });
|
||||
return this.requestService.request(fallbackOptions, token).then(undefined, err => {
|
||||
@@ -839,14 +848,7 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
|
||||
}
|
||||
|
||||
const message = getErrorMessage(err);
|
||||
/* __GDPR__
|
||||
"galleryService:requestError" : {
|
||||
"url" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
|
||||
"cdn": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
|
||||
"message": { "classification": "CallstackOrException", "purpose": "FeatureInsight" }
|
||||
}
|
||||
*/
|
||||
this.telemetryService.publicLog('galleryService:requestError', { url: fallbackUrl, cdn: false, message });
|
||||
this.telemetryService.publicLog2<GalleryServiceRequestErrorEvent, GalleryServiceRequestErrorClassification>('galleryService:requestError', { url: fallbackUrl, cdn: false, message });
|
||||
return Promise.reject(err);
|
||||
});
|
||||
});
|
||||
@@ -867,7 +869,7 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
|
||||
if (!engine) {
|
||||
return null;
|
||||
}
|
||||
if (isEngineValid(engine)) {
|
||||
if (isEngineValid(engine, this.productService.version)) {
|
||||
return Promise.resolve(version);
|
||||
}
|
||||
}
|
||||
@@ -899,7 +901,7 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
|
||||
const version = versions[0];
|
||||
return this.getEngine(version)
|
||||
.then(engine => {
|
||||
if (!isEngineValid(engine)) {
|
||||
if (!isEngineValid(engine, this.productService.version)) {
|
||||
return this.getLastValidExtensionVersionRecursively(extension, versions.slice(1));
|
||||
}
|
||||
|
||||
@@ -940,24 +942,30 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
|
||||
}
|
||||
}
|
||||
|
||||
export function resolveMarketplaceHeaders(environmentService: IEnvironmentService): Promise<{ [key: string]: string; }> {
|
||||
const marketplaceMachineIdFile = path.join(environmentService.userDataPath, 'machineid');
|
||||
export async function resolveMarketplaceHeaders(version: string, environmentService: IEnvironmentService, fileService: IFileService): Promise<{ [key: string]: string; }> {
|
||||
const marketplaceMachineIdFile = joinPath(URI.file(environmentService.userDataPath), 'machineid');
|
||||
|
||||
return readFile(marketplaceMachineIdFile, 'utf8')
|
||||
.then<string | null>(contents => isUUID(contents) ? contents : null, () => null /* error reading ID file */)
|
||||
.then(uuid => {
|
||||
if (!uuid) {
|
||||
uuid = generateUuid();
|
||||
try {
|
||||
writeFileSync(marketplaceMachineIdFile, uuid);
|
||||
} catch (error) {
|
||||
//noop
|
||||
}
|
||||
}
|
||||
return {
|
||||
'X-Market-Client-Id': `VSCode ${pkg.version}`,
|
||||
'User-Agent': `VSCode ${pkg.version}`,
|
||||
'X-Market-User-Id': uuid
|
||||
};
|
||||
});
|
||||
}
|
||||
let uuid: string | null = null;
|
||||
|
||||
try {
|
||||
const contents = await fileService.readFile(marketplaceMachineIdFile);
|
||||
const value = contents.value.toString();
|
||||
uuid = isUUID(value) ? value : null;
|
||||
} catch (e) {
|
||||
uuid = null;
|
||||
}
|
||||
|
||||
if (!uuid) {
|
||||
uuid = generateUuid();
|
||||
try {
|
||||
await fileService.writeFile(marketplaceMachineIdFile, VSBuffer.fromString(uuid));
|
||||
} catch (error) {
|
||||
//noop
|
||||
}
|
||||
}
|
||||
return {
|
||||
'X-Market-Client-Id': `VSCode ${version}`,
|
||||
'User-Agent': `VSCode ${version}`,
|
||||
'X-Market-User-Id': uuid
|
||||
};
|
||||
}
|
||||
@@ -39,7 +39,7 @@ export interface IGalleryExtensionAssets {
|
||||
// {{SQL CARBON EDIT}}
|
||||
downloadPage?: IGalleryExtensionAsset;
|
||||
icon: IGalleryExtensionAsset;
|
||||
coreTranslations: { [languageId: string]: IGalleryExtensionAsset };
|
||||
coreTranslations: [string, IGalleryExtensionAsset][];
|
||||
}
|
||||
|
||||
export function isIExtensionIdentifier(thing: any): thing is IExtensionIdentifier {
|
||||
@@ -155,7 +155,7 @@ export interface IExtensionGalleryService {
|
||||
isEnabled(): boolean;
|
||||
query(token: CancellationToken): Promise<IPager<IGalleryExtension>>;
|
||||
query(options: IQueryOptions, token: CancellationToken): Promise<IPager<IGalleryExtension>>;
|
||||
download(extension: IGalleryExtension, operation: InstallOperation): Promise<string>;
|
||||
download(extension: IGalleryExtension, location: URI, operation: InstallOperation): Promise<URI>;
|
||||
reportStatistic(publisher: string, name: string, version: string, type: StatisticType): Promise<void>;
|
||||
getReadme(extension: IGalleryExtension, token: CancellationToken): Promise<string>;
|
||||
getManifest(extension: IGalleryExtension, token: CancellationToken): Promise<IExtensionManifest | null>;
|
||||
@@ -200,8 +200,8 @@ export interface IExtensionManagementService {
|
||||
|
||||
zip(extension: ILocalExtension): Promise<URI>;
|
||||
unzip(zipLocation: URI, type: ExtensionType): Promise<IExtensionIdentifier>;
|
||||
install(vsix: URI): Promise<IExtensionIdentifier>;
|
||||
installFromGallery(extension: IGalleryExtension): Promise<void>;
|
||||
install(vsix: URI): Promise<ILocalExtension>;
|
||||
installFromGallery(extension: IGalleryExtension): Promise<ILocalExtension>;
|
||||
uninstall(extension: ILocalExtension, force?: boolean): Promise<void>;
|
||||
reinstallFromGallery(extension: ILocalExtension): Promise<void>;
|
||||
getInstalled(type?: ExtensionType): Promise<ILocalExtension[]>;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
import { ILocalExtension, IGalleryExtension, IExtensionIdentifier, IReportedExtension } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { compareIgnoreCase } from 'vs/base/common/strings';
|
||||
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
|
||||
|
||||
export function areSameExtensions(a: IExtensionIdentifier, b: IExtensionIdentifier): boolean {
|
||||
if (a.uuid && b.uuid) {
|
||||
@@ -16,6 +17,24 @@ export function areSameExtensions(a: IExtensionIdentifier, b: IExtensionIdentifi
|
||||
return compareIgnoreCase(a.id, b.id) === 0;
|
||||
}
|
||||
|
||||
export class ExtensionIdentifierWithVersion {
|
||||
constructor(
|
||||
readonly identifier: IExtensionIdentifier,
|
||||
readonly version: string
|
||||
) { }
|
||||
|
||||
key(): string {
|
||||
return `${this.identifier.id}-${this.version}`;
|
||||
}
|
||||
|
||||
equals(o: any): boolean {
|
||||
if (!(o instanceof ExtensionIdentifierWithVersion)) {
|
||||
return false;
|
||||
}
|
||||
return areSameExtensions(this.identifier, o.identifier) && this.version === o.version;
|
||||
}
|
||||
}
|
||||
|
||||
export function adoptToGalleryExtensionId(id: string): string {
|
||||
return id.toLocaleLowerCase();
|
||||
}
|
||||
@@ -89,7 +108,7 @@ export function getGalleryExtensionTelemetryData(extension: IGalleryExtension):
|
||||
};
|
||||
}
|
||||
|
||||
export const BetterMergeId = 'pprice.better-merge';
|
||||
export const BetterMergeId = new ExtensionIdentifier('pprice.better-merge');
|
||||
|
||||
export function getMaliciousExtensionsSet(report: IReportedExtension[]): Set<string> {
|
||||
const result = new Set<string>();
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IChannel, IServerChannel } from 'vs/base/parts/ipc/common/ipc';
|
||||
import { IExtensionManagementService, ILocalExtension, InstallExtensionEvent, DidInstallExtensionEvent, IGalleryExtension, DidUninstallExtensionEvent, IExtensionIdentifier, IGalleryMetadata, IReportedExtension } from '../common/extensionManagement';
|
||||
import { IExtensionManagementService, ILocalExtension, InstallExtensionEvent, DidInstallExtensionEvent, IGalleryExtension, DidUninstallExtensionEvent, IExtensionIdentifier, IGalleryMetadata, IReportedExtension } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
import { IURITransformer, DefaultURITransformer, transformAndReviveIncomingURIs } from 'vs/base/common/uriIpc';
|
||||
@@ -78,7 +78,9 @@ export class ExtensionManagementChannelClient implements IExtensionManagementSer
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
constructor(private channel: IChannel) { }
|
||||
constructor(
|
||||
private readonly channel: IChannel,
|
||||
) { }
|
||||
|
||||
get onInstallExtension(): Event<InstallExtensionEvent> { return this.channel.listen('onInstallExtension'); }
|
||||
get onDidInstallExtension(): Event<DidInstallExtensionEvent> { return Event.map(this.channel.listen<DidInstallExtensionEvent>('onDidInstallExtension'), i => ({ ...i, local: i.local ? transformIncomingExtension(i.local, null) : i.local })); }
|
||||
@@ -93,12 +95,12 @@ export class ExtensionManagementChannelClient implements IExtensionManagementSer
|
||||
return Promise.resolve(this.channel.call('unzip', [zipLocation, type]));
|
||||
}
|
||||
|
||||
install(vsix: URI): Promise<IExtensionIdentifier> {
|
||||
return Promise.resolve(this.channel.call('install', [vsix]));
|
||||
install(vsix: URI): Promise<ILocalExtension> {
|
||||
return Promise.resolve(this.channel.call<ILocalExtension>('install', [vsix])).then(local => transformIncomingExtension(local, null));
|
||||
}
|
||||
|
||||
installFromGallery(extension: IGalleryExtension): Promise<void> {
|
||||
return Promise.resolve(this.channel.call('installFromGallery', [extension]));
|
||||
installFromGallery(extension: IGalleryExtension): Promise<ILocalExtension> {
|
||||
return Promise.resolve(this.channel.call<ILocalExtension>('installFromGallery', [extension])).then(local => transformIncomingExtension(local, null));
|
||||
}
|
||||
|
||||
uninstall(extension: ILocalExtension, force = false): Promise<void> {
|
||||
|
||||
@@ -21,7 +21,7 @@ import {
|
||||
INSTALL_ERROR_MALICIOUS,
|
||||
INSTALL_ERROR_INCOMPATIBLE
|
||||
} from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { areSameExtensions, getGalleryExtensionId, groupByExtension, getMaliciousExtensionsSet, getGalleryExtensionTelemetryData, getLocalExtensionTelemetryData } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
|
||||
import { areSameExtensions, getGalleryExtensionId, groupByExtension, getMaliciousExtensionsSet, getGalleryExtensionTelemetryData, getLocalExtensionTelemetryData, ExtensionIdentifierWithVersion } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
|
||||
import { localizeManifest } from '../common/extensionNls';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { Limiter, createCancelablePromise, CancelablePromise, Queue } from 'vs/base/common/async';
|
||||
@@ -35,7 +35,7 @@ import { ExtensionsManifestCache } from 'vs/platform/extensionManagement/node/ex
|
||||
import { ExtensionsLifecycle } from 'vs/platform/extensionManagement/node/extensionLifecycle';
|
||||
import { toErrorMessage } from 'vs/base/common/errorMessage';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { isEngineValid } from 'vs/platform/extensions/node/extensionValidator';
|
||||
import { isEngineValid } from 'vs/platform/extensions/common/extensionValidator';
|
||||
import { tmpdir } from 'os';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { IDownloadService } from 'vs/platform/download/common/download';
|
||||
@@ -44,7 +44,7 @@ import { Schemas } from 'vs/base/common/network';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { getPathFromAmdModule } from 'vs/base/common/amd';
|
||||
import { getManifest } from 'vs/platform/extensionManagement/node/extensionManagementUtil';
|
||||
import { IExtensionManifest, ExtensionType, ExtensionIdentifierWithVersion } from 'vs/platform/extensions/common/extensions';
|
||||
import { IExtensionManifest, ExtensionType } from 'vs/platform/extensions/common/extensions';
|
||||
|
||||
// {{SQL CARBON EDIT}
|
||||
import product from 'vs/platform/product/node/product';
|
||||
@@ -112,21 +112,21 @@ export class ExtensionManagementService extends Disposable implements IExtension
|
||||
private uninstalledFileLimiter: Queue<any>;
|
||||
private reportedExtensions: Promise<IReportedExtension[]> | undefined;
|
||||
private lastReportTimestamp = 0;
|
||||
private readonly installingExtensions: Map<string, CancelablePromise<void>> = new Map<string, CancelablePromise<void>>();
|
||||
private readonly installingExtensions: Map<string, CancelablePromise<ILocalExtension>> = new Map<string, CancelablePromise<ILocalExtension>>();
|
||||
private readonly uninstallingExtensions: Map<string, CancelablePromise<void>> = new Map<string, CancelablePromise<void>>();
|
||||
private readonly manifestCache: ExtensionsManifestCache;
|
||||
private readonly extensionLifecycle: ExtensionsLifecycle;
|
||||
|
||||
private readonly _onInstallExtension = new Emitter<InstallExtensionEvent>();
|
||||
private readonly _onInstallExtension = this._register(new Emitter<InstallExtensionEvent>());
|
||||
readonly onInstallExtension: Event<InstallExtensionEvent> = this._onInstallExtension.event;
|
||||
|
||||
private readonly _onDidInstallExtension = new Emitter<DidInstallExtensionEvent>();
|
||||
private readonly _onDidInstallExtension = this._register(new Emitter<DidInstallExtensionEvent>());
|
||||
readonly onDidInstallExtension: Event<DidInstallExtensionEvent> = this._onDidInstallExtension.event;
|
||||
|
||||
private readonly _onUninstallExtension = new Emitter<IExtensionIdentifier>();
|
||||
private readonly _onUninstallExtension = this._register(new Emitter<IExtensionIdentifier>());
|
||||
readonly onUninstallExtension: Event<IExtensionIdentifier> = this._onUninstallExtension.event;
|
||||
|
||||
private _onDidUninstallExtension = new Emitter<DidUninstallExtensionEvent>();
|
||||
private _onDidUninstallExtension = this._register(new Emitter<DidUninstallExtensionEvent>());
|
||||
onDidUninstallExtension: Event<DidUninstallExtensionEvent> = this._onDidUninstallExtension.event;
|
||||
|
||||
constructor(
|
||||
@@ -161,7 +161,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
|
||||
|
||||
unzip(zipLocation: URI, type: ExtensionType): Promise<IExtensionIdentifier> {
|
||||
this.logService.trace('ExtensionManagementService#unzip', zipLocation.toString());
|
||||
return this.install(zipLocation, type);
|
||||
return this.install(zipLocation, type).then(local => local.identifier);
|
||||
}
|
||||
|
||||
private collectFiles(extension: ILocalExtension): Promise<IFile[]> {
|
||||
@@ -190,7 +190,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
|
||||
|
||||
}
|
||||
|
||||
install(vsix: URI, type: ExtensionType = ExtensionType.User): Promise<IExtensionIdentifier> {
|
||||
install(vsix: URI, type: ExtensionType = ExtensionType.User): Promise<ILocalExtension> {
|
||||
// {{SQL CARBON EDIT}}
|
||||
let startTime = new Date().getTime();
|
||||
|
||||
@@ -232,20 +232,20 @@ export class ExtensionManagementService extends Disposable implements IExtension
|
||||
local => {
|
||||
this.reportTelemetry(this.getTelemetryEvent(InstallOperation.Install), getLocalExtensionTelemetryData(local), new Date().getTime() - startTime, void 0);
|
||||
this._onDidInstallExtension.fire({ identifier, zipPath, local, operation: InstallOperation.Install });
|
||||
return identifier;
|
||||
return local;
|
||||
},
|
||||
error => { this._onDidInstallExtension.fire({ identifier, zipPath, error, operation: InstallOperation.Install }); return Promise.reject(error); }
|
||||
);
|
||||
// return this.getMetadata(getGalleryExtensionId(manifest.publisher, manifest.name))
|
||||
// .then(
|
||||
// metadata => this.installFromZipPath(identifierWithVersion, zipPath, metadata, type, operation, token),
|
||||
// () => this.installFromZipPath(identifierWithVersion, zipPath, null, type, operation, token))
|
||||
// .then(
|
||||
// () => { this.logService.info('Successfully installed the extension:', identifier.id); return identifier; },
|
||||
// e => {
|
||||
// this.logService.error('Failed to install the extension:', identifier.id, e.message);
|
||||
// return Promise.reject(e);
|
||||
// });
|
||||
// () => this.installFromZipPath(identifierWithVersion, zipPath, null, type, operation, token))
|
||||
// .then(
|
||||
// local => { this.logService.info('Successfully installed the extension:', identifier.id); return local; },
|
||||
// e => {
|
||||
// this.logService.error('Failed to install the extension:', identifier.id, e.message);
|
||||
// return Promise.reject(e);
|
||||
// });
|
||||
// {{SQL CARBON EDIT}} - End
|
||||
});
|
||||
});
|
||||
@@ -284,12 +284,12 @@ export class ExtensionManagementService extends Disposable implements IExtension
|
||||
));
|
||||
}
|
||||
|
||||
async installFromGallery(extension: IGalleryExtension): Promise<void> {
|
||||
async installFromGallery(extension: IGalleryExtension): Promise<ILocalExtension> {
|
||||
if (!this.galleryService.isEnabled()) {
|
||||
return Promise.reject(new Error(nls.localize('MarketPlaceDisabled', "Marketplace is not enabled")));
|
||||
}
|
||||
const startTime = new Date().getTime();
|
||||
|
||||
this.logService.info('Installing extension:', extension.identifier.id);
|
||||
this._onInstallExtension.fire({ identifier: extension.identifier, gallery: extension });
|
||||
|
||||
const onDidInstallExtensionSuccess = (extension: IGalleryExtension, operation: InstallOperation, local: ILocalExtension) => {
|
||||
this.logService.info(`Extensions installed successfully:`, extension.identifier.id);
|
||||
this._onDidInstallExtension.fire({ identifier: extension.identifier, gallery: extension, local, operation });
|
||||
@@ -317,8 +317,11 @@ export class ExtensionManagementService extends Disposable implements IExtension
|
||||
let cancellablePromise = this.installingExtensions.get(key);
|
||||
if (!cancellablePromise) {
|
||||
|
||||
this.logService.info('Installing extension:', extension.identifier.id);
|
||||
this._onInstallExtension.fire({ identifier: extension.identifier, gallery: extension });
|
||||
|
||||
let operation: InstallOperation = InstallOperation.Install;
|
||||
let cancellationToken: CancellationToken, successCallback: (a?: any) => void, errorCallback: (e?: any) => any | null;
|
||||
let cancellationToken: CancellationToken, successCallback: (local: ILocalExtension) => void, errorCallback: (e?: any) => any | null;
|
||||
cancellablePromise = createCancelablePromise(token => { cancellationToken = token; return new Promise((c, e) => { successCallback = c; errorCallback = e; }); });
|
||||
this.installingExtensions.set(key, cancellablePromise);
|
||||
try {
|
||||
@@ -340,7 +343,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
|
||||
}
|
||||
this.installingExtensions.delete(key);
|
||||
onDidInstallExtensionSuccess(extension, operation, local);
|
||||
successCallback(null);
|
||||
successCallback(local);
|
||||
},
|
||||
error => {
|
||||
this.installingExtensions.delete(key);
|
||||
@@ -367,7 +370,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
|
||||
const compatibleExtension = await this.galleryService.getCompatibleExtension(extension);
|
||||
|
||||
if (!compatibleExtension) {
|
||||
return Promise.reject(new ExtensionManagementError(nls.localize('notFoundCompatibleDependency', "Unable to install because, the extension '{0}' compatible with current version '{1}' of VS Code is not found.", extension.identifier.id, pkg.version), INSTALL_ERROR_INCOMPATIBLE));
|
||||
return Promise.reject(new ExtensionManagementError(nls.localize('notFoundCompatibleDependency', "Unable to install '{0}' extension because it is not compatible with the current version of VS Code (version {1}).", extension.identifier.id, pkg.version), INSTALL_ERROR_INCOMPATIBLE));
|
||||
}
|
||||
|
||||
return compatibleExtension;
|
||||
@@ -408,9 +411,10 @@ export class ExtensionManagementService extends Disposable implements IExtension
|
||||
};
|
||||
|
||||
this.logService.trace('Started downloading extension:', extension.identifier.id);
|
||||
return this.galleryService.download(extension, operation)
|
||||
return this.galleryService.download(extension, URI.file(tmpdir()), operation)
|
||||
.then(
|
||||
zipPath => {
|
||||
zip => {
|
||||
const zipPath = zip.fsPath;
|
||||
this.logService.info('Downloaded extension:', extension.identifier.id, zipPath);
|
||||
return getManifest(zipPath)
|
||||
.then(
|
||||
@@ -470,7 +474,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
|
||||
}
|
||||
this.logService.info('Installation completed.', identifier.id);
|
||||
if (metadata) {
|
||||
local.metadata = metadata;
|
||||
this.setMetadata(local, metadata);
|
||||
return this.saveMetadataForLocalExtension(local);
|
||||
}
|
||||
return local;
|
||||
@@ -500,12 +504,12 @@ export class ExtensionManagementService extends Disposable implements IExtension
|
||||
e => Promise.reject(new ExtensionManagementError(this.joinErrors(e).message, INSTALL_ERROR_DELETING)));
|
||||
}
|
||||
|
||||
private rename(identfier: IExtensionIdentifier, extractPath: string, renamePath: string, retryUntil: number): Promise<void> {
|
||||
private rename(identifier: IExtensionIdentifier, extractPath: string, renamePath: string, retryUntil: number): Promise<void> {
|
||||
return pfs.rename(extractPath, renamePath)
|
||||
.then(undefined, error => {
|
||||
if (isWindows && error && error.code === 'EPERM' && Date.now() < retryUntil) {
|
||||
this.logService.info(`Failed renaming ${extractPath} to ${renamePath} with 'EPERM' error. Trying again...`, identfier.id);
|
||||
return this.rename(identfier, extractPath, renamePath, retryUntil);
|
||||
this.logService.info(`Failed renaming ${extractPath} to ${renamePath} with 'EPERM' error. Trying again...`, identifier.id);
|
||||
return this.rename(identifier, extractPath, renamePath, retryUntil);
|
||||
}
|
||||
return Promise.reject(new ExtensionManagementError(error.message || nls.localize('renameError', "Unknown error while renaming {0} to {1}", extractPath, renamePath), error.code || INSTALL_ERROR_RENAMING));
|
||||
});
|
||||
@@ -743,7 +747,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
|
||||
this.logService.trace('Started scanning system extensions');
|
||||
const systemExtensionsPromise = this.scanExtensions(this.systemExtensionsPath, ExtensionType.System)
|
||||
.then(result => {
|
||||
this.logService.info('Scanned system extensions:', result.length);
|
||||
this.logService.trace('Scanned system extensions:', result.length);
|
||||
return result;
|
||||
});
|
||||
if (this.environmentService.isBuilt) {
|
||||
@@ -756,7 +760,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
|
||||
if (devSystemExtensionsList.length) {
|
||||
return this.scanExtensions(this.devSystemExtensionsPath, ExtensionType.System)
|
||||
.then(result => {
|
||||
this.logService.info('Scanned dev system extensions:', result.length);
|
||||
this.logService.trace('Scanned dev system extensions:', result.length);
|
||||
return result.filter(r => devSystemExtensionsList.some(id => areSameExtensions(r.identifier, { id })));
|
||||
});
|
||||
} else {
|
||||
@@ -776,7 +780,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
|
||||
const byExtension: ILocalExtension[][] = groupByExtension(extensions, e => e.identifier);
|
||||
extensions = byExtension.map(p => p.sort((a, b) => semver.rcompare(a.manifest.version, b.manifest.version))[0]);
|
||||
}
|
||||
this.logService.info('Scanned user extensions:', extensions.length);
|
||||
this.logService.trace('Scanned user extensions:', extensions.length);
|
||||
return extensions;
|
||||
});
|
||||
}
|
||||
@@ -800,25 +804,44 @@ export class ExtensionManagementService extends Disposable implements IExtension
|
||||
const readmeUrl = readme ? URI.file(path.join(extensionPath, readme)) : null;
|
||||
const changelog = children.filter(child => /^changelog(\.txt|\.md|)$/i.test(child))[0];
|
||||
const changelogUrl = changelog ? URI.file(path.join(extensionPath, changelog)) : null;
|
||||
const identifier = { id: getGalleryExtensionId(manifest.publisher, manifest.name), uuid: metadata ? metadata.id : null };
|
||||
return <ILocalExtension>{ type, identifier, manifest, metadata, location: URI.file(extensionPath), readmeUrl, changelogUrl };
|
||||
const identifier = { id: getGalleryExtensionId(manifest.publisher, manifest.name) };
|
||||
const local = <ILocalExtension>{ type, identifier, manifest, metadata, location: URI.file(extensionPath), readmeUrl, changelogUrl };
|
||||
if (metadata) {
|
||||
this.setMetadata(local, metadata);
|
||||
}
|
||||
return local;
|
||||
}))
|
||||
.then(undefined, () => null);
|
||||
}
|
||||
|
||||
removeDeprecatedExtensions(): Promise<any> {
|
||||
return this.removeUninstalledExtensions()
|
||||
.then(() => this.removeOutdatedExtensions());
|
||||
private setMetadata(local: ILocalExtension, metadata: IGalleryMetadata): void {
|
||||
local.metadata = metadata;
|
||||
local.identifier.uuid = metadata.id;
|
||||
}
|
||||
|
||||
private removeUninstalledExtensions(): Promise<void> {
|
||||
return this.getUninstalledExtensions()
|
||||
.then(uninstalled => this.scanExtensions(this.extensionsPath, ExtensionType.User) // All user extensions
|
||||
.then(extensions => {
|
||||
const toRemove: ILocalExtension[] = extensions.filter(e => uninstalled[new ExtensionIdentifierWithVersion(e.identifier, e.manifest.version).key()]);
|
||||
return Promise.all(toRemove.map(e => this.extensionLifecycle.postUninstall(e).then(() => this.removeUninstalledExtension(e))));
|
||||
})
|
||||
).then(() => undefined);
|
||||
async removeDeprecatedExtensions(): Promise<void> {
|
||||
await this.removeUninstalledExtensions();
|
||||
await this.removeOutdatedExtensions();
|
||||
}
|
||||
|
||||
private async removeUninstalledExtensions(): Promise<void> {
|
||||
const uninstalled = await this.getUninstalledExtensions();
|
||||
const extensions = await this.scanExtensions(this.extensionsPath, ExtensionType.User); // All user extensions
|
||||
const installed: Set<string> = new Set<string>();
|
||||
for (const e of extensions) {
|
||||
if (!uninstalled[new ExtensionIdentifierWithVersion(e.identifier, e.manifest.version).key()]) {
|
||||
installed.add(e.identifier.id.toLowerCase());
|
||||
}
|
||||
}
|
||||
const byExtension: ILocalExtension[][] = groupByExtension(extensions, e => e.identifier);
|
||||
await Promise.all(byExtension.map(async e => {
|
||||
const latest = e.sort((a, b) => semver.rcompare(a.manifest.version, b.manifest.version))[0];
|
||||
if (!installed.has(latest.identifier.id.toLowerCase())) {
|
||||
await this.extensionLifecycle.postUninstall(latest);
|
||||
}
|
||||
}));
|
||||
const toRemove: ILocalExtension[] = extensions.filter(e => uninstalled[new ExtensionIdentifierWithVersion(e.identifier, e.manifest.version).key()]);
|
||||
await Promise.all(toRemove.map(e => this.removeUninstalledExtension(e)));
|
||||
}
|
||||
|
||||
private removeOutdatedExtensions(): Promise<void> {
|
||||
@@ -845,8 +868,8 @@ export class ExtensionManagementService extends Disposable implements IExtension
|
||||
return pfs.rimraf(extension.location.fsPath).then(() => this.logService.info('Deleted from disk', extension.identifier.id, extension.location.fsPath));
|
||||
}
|
||||
|
||||
private isUninstalled(identfier: ExtensionIdentifierWithVersion): Promise<boolean> {
|
||||
return this.filterUninstalled(identfier).then(uninstalled => uninstalled.length === 1);
|
||||
private isUninstalled(identifier: ExtensionIdentifierWithVersion): Promise<boolean> {
|
||||
return this.filterUninstalled(identifier).then(uninstalled => uninstalled.length === 1);
|
||||
}
|
||||
|
||||
private filterUninstalled(...identifiers: ExtensionIdentifierWithVersion[]): Promise<string[]> {
|
||||
|
||||
@@ -16,11 +16,11 @@ export class ExtensionsManifestCache extends Disposable {
|
||||
|
||||
constructor(
|
||||
private readonly environmentService: IEnvironmentService,
|
||||
extensionsManagementServuce: IExtensionManagementService
|
||||
extensionsManagementService: IExtensionManagementService
|
||||
) {
|
||||
super();
|
||||
this._register(extensionsManagementServuce.onDidInstallExtension(e => this.onDidInstallExtension(e)));
|
||||
this._register(extensionsManagementServuce.onDidUninstallExtension(e => this.onDidUnInstallExtension(e)));
|
||||
this._register(extensionsManagementService.onDidInstallExtension(e => this.onDidInstallExtension(e)));
|
||||
this._register(extensionsManagementService.onDidUninstallExtension(e => this.onDidUnInstallExtension(e)));
|
||||
}
|
||||
|
||||
private onDidInstallExtension(e: DidInstallExtensionEvent): void {
|
||||
|
||||
@@ -11,15 +11,32 @@ import { getRandomTestPath } from 'vs/base/test/node/testUtils';
|
||||
import { join } from 'vs/base/common/path';
|
||||
import { mkdirp, RimRafMode, rimraf } from 'vs/base/node/pfs';
|
||||
// {{SQL CARBON EDIT}}
|
||||
import { resolveMarketplaceHeaders, ExtensionGalleryService } from 'vs/platform/extensionManagement/node/extensionGalleryService';
|
||||
import { resolveMarketplaceHeaders, ExtensionGalleryService } from 'vs/platform/extensionManagement/common/extensionGalleryService';
|
||||
import { isUUID } from 'vs/base/common/uuid';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { FileService } from 'vs/platform/files/common/fileService';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { DiskFileSystemProvider } from 'vs/platform/files/node/diskFileSystemProvider';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import pkg from 'vs/platform/product/node/package';
|
||||
|
||||
suite('Extension Gallery Service', () => {
|
||||
const parentDir = getRandomTestPath(os.tmpdir(), 'vsctests', 'extensiongalleryservice');
|
||||
const marketplaceHome = join(parentDir, 'Marketplace');
|
||||
let fileService: IFileService;
|
||||
let disposables: DisposableStore;
|
||||
|
||||
setup(done => {
|
||||
|
||||
disposables = new DisposableStore();
|
||||
fileService = new FileService(new NullLogService());
|
||||
disposables.add(fileService);
|
||||
|
||||
const diskFileSystemProvider = new DiskFileSystemProvider(new NullLogService());
|
||||
disposables.add(diskFileSystemProvider);
|
||||
fileService.registerProvider(Schemas.file, diskFileSystemProvider);
|
||||
|
||||
// Delete any existing backups completely and then re-create it.
|
||||
rimraf(marketplaceHome, RimRafMode.MOVE).then(() => {
|
||||
mkdirp(marketplaceHome).then(() => {
|
||||
@@ -29,6 +46,7 @@ suite('Extension Gallery Service', () => {
|
||||
});
|
||||
|
||||
teardown(done => {
|
||||
disposables.clear();
|
||||
rimraf(marketplaceHome, RimRafMode.MOVE).then(done, done);
|
||||
});
|
||||
|
||||
@@ -36,10 +54,10 @@ suite('Extension Gallery Service', () => {
|
||||
const args = ['--user-data-dir', marketplaceHome];
|
||||
const environmentService = new EnvironmentService(parseArgs(args), process.execPath);
|
||||
|
||||
return resolveMarketplaceHeaders(environmentService).then(headers => {
|
||||
return resolveMarketplaceHeaders(pkg.version, environmentService, fileService).then(headers => {
|
||||
assert.ok(isUUID(headers['X-Market-User-Id']));
|
||||
|
||||
return resolveMarketplaceHeaders(environmentService).then(headers2 => {
|
||||
return resolveMarketplaceHeaders(pkg.version, environmentService, fileService).then(headers2 => {
|
||||
assert.equal(headers['X-Market-User-Id'], headers2['X-Market-User-Id']);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as nls from 'vs/nls';
|
||||
import pkg from 'vs/platform/product/node/package';
|
||||
|
||||
export interface IParsedVersion {
|
||||
hasCaret: boolean;
|
||||
@@ -226,7 +225,7 @@ export function isValidExtensionVersion(version: string, extensionDesc: IReduced
|
||||
}
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
export function isEngineValid(engine: string, version: string = pkg.version): boolean {
|
||||
export function isEngineValid(engine: string, version: string): boolean {
|
||||
// TODO@joao: discuss with alex '*' doesn't seem to be a valid engine version
|
||||
return engine === '*' || isVersionValid(version, engine);
|
||||
}
|
||||
@@ -3,7 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { areSameExtensions } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import { ILocalization } from 'vs/platform/localizations/common/localizations';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
@@ -109,24 +108,6 @@ export interface IExtensionContributions {
|
||||
|
||||
export type ExtensionKind = 'ui' | 'workspace';
|
||||
|
||||
export class ExtensionIdentifierWithVersion {
|
||||
constructor(
|
||||
readonly identifier: IExtensionIdentifier,
|
||||
readonly version: string
|
||||
) { }
|
||||
|
||||
key(): string {
|
||||
return `${this.identifier.id}-${this.version}`;
|
||||
}
|
||||
|
||||
equals(o: any): boolean {
|
||||
if (!(o instanceof ExtensionIdentifierWithVersion)) {
|
||||
return false;
|
||||
}
|
||||
return areSameExtensions(this.identifier, o.identifier) && this.version === o.version;
|
||||
}
|
||||
}
|
||||
|
||||
export function isIExtensionIdentifier(thing: any): thing is IExtensionIdentifier {
|
||||
return thing
|
||||
&& typeof thing === 'object'
|
||||
@@ -144,8 +125,8 @@ export interface IExtensionManifest {
|
||||
readonly displayName?: string;
|
||||
readonly publisher: string;
|
||||
readonly version: string;
|
||||
// {{SQL CARBON EDIT}}
|
||||
engines: { vscode: string; azdata?: string };
|
||||
readonly engines: { vscode: string; azdata?: string }; // {{SQL CARBON EDIT}} add field
|
||||
readonly forceReload?: boolean; // {{ SQL CARBON EDIT }} add field
|
||||
readonly description?: string;
|
||||
readonly main?: string;
|
||||
readonly icon?: string;
|
||||
@@ -160,6 +141,7 @@ export interface IExtensionManifest {
|
||||
readonly bugs?: { url: string; };
|
||||
readonly enableProposedApi?: boolean;
|
||||
readonly api?: string;
|
||||
readonly scripts?: { [key: string]: string; };
|
||||
}
|
||||
|
||||
export const enum ExtensionType {
|
||||
@@ -242,4 +224,4 @@ export interface IExtensionDescription extends IExtensionManifest {
|
||||
|
||||
export function isLanguagePackExtension(manifest: IExtensionManifest): boolean {
|
||||
return manifest.contributes && manifest.contributes.localizations ? manifest.contributes.localizations.length > 0 : false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as assert from 'assert';
|
||||
import { INormalizedVersion, IParsedVersion, IReducedExtensionDescription, isValidExtensionVersion, isValidVersion, isValidVersionStr, normalizeVersion, parseVersion } from 'vs/platform/extensions/node/extensionValidator';
|
||||
import { INormalizedVersion, IParsedVersion, IReducedExtensionDescription, isValidExtensionVersion, isValidVersion, isValidVersionStr, normalizeVersion, parseVersion } from 'vs/platform/extensions/common/extensionValidator';
|
||||
|
||||
suite('Extension Version Validator', () => {
|
||||
|
||||
|
||||
1080
src/vs/platform/files/common/fileService.ts
Normal file
1080
src/vs/platform/files/common/fileService.ts
Normal file
File diff suppressed because it is too large
Load Diff
@@ -6,7 +6,6 @@
|
||||
import { sep } from 'vs/base/common/path';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import * as glob from 'vs/base/common/glob';
|
||||
import { isLinux } from 'vs/base/common/platform';
|
||||
import { createDecorator, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { startsWithIgnoreCase } from 'vs/base/common/strings';
|
||||
@@ -105,7 +104,7 @@ export interface IFileService {
|
||||
/**
|
||||
* Updates the content replacing its previous value.
|
||||
*/
|
||||
writeFile(resource: URI, bufferOrReadable: VSBuffer | VSBufferReadable, options?: IWriteFileOptions): Promise<IFileStatWithMetadata>;
|
||||
writeFile(resource: URI, bufferOrReadableOrStream: VSBuffer | VSBufferReadable | VSBufferReadableStream, options?: IWriteFileOptions): Promise<IFileStatWithMetadata>;
|
||||
|
||||
/**
|
||||
* Moves the file/folder to a new path identified by the resource.
|
||||
@@ -127,7 +126,7 @@ export interface IFileService {
|
||||
*
|
||||
* The optional parameter content can be used as value to fill into the new file.
|
||||
*/
|
||||
createFile(resource: URI, bufferOrReadable?: VSBuffer | VSBufferReadable, options?: ICreateFileOptions): Promise<IFileStatWithMetadata>;
|
||||
createFile(resource: URI, bufferOrReadableOrStream?: VSBuffer | VSBufferReadable | VSBufferReadableStream, options?: ICreateFileOptions): Promise<IFileStatWithMetadata>;
|
||||
|
||||
/**
|
||||
* Creates a new folder with the given path. The returned promise
|
||||
@@ -208,7 +207,7 @@ export interface IFileSystemProvider {
|
||||
readonly capabilities: FileSystemProviderCapabilities;
|
||||
readonly onDidChangeCapabilities: Event<void>;
|
||||
|
||||
readonly onDidErrorOccur?: Event<Error>; // TODO@ben remove once file watchers are solid
|
||||
readonly onDidErrorOccur?: Event<string>; // TODO@ben remove once file watchers are solid
|
||||
|
||||
readonly onDidChangeFile: Event<IFileChange[]>;
|
||||
watch(resource: URI, opts: IWatchOptions): IDisposable;
|
||||
@@ -429,10 +428,10 @@ export class FileChangesEvent {
|
||||
|
||||
// For deleted also return true when deleted folder is parent of target path
|
||||
if (change.type === FileChangeType.DELETED) {
|
||||
return isEqualOrParent(resource, change.resource, !isLinux /* ignorecase */);
|
||||
return isEqualOrParent(resource, change.resource);
|
||||
}
|
||||
|
||||
return isEqual(resource, change.resource, !isLinux /* ignorecase */);
|
||||
return isEqual(resource, change.resource);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -517,7 +516,7 @@ interface IBaseStat {
|
||||
resource: URI;
|
||||
|
||||
/**
|
||||
* The name which is the last segement
|
||||
* The name which is the last segment
|
||||
* of the {{path}}.
|
||||
*/
|
||||
name: string;
|
||||
@@ -531,7 +530,7 @@ interface IBaseStat {
|
||||
size?: number;
|
||||
|
||||
/**
|
||||
* The last modifictaion date represented
|
||||
* The last modification date represented
|
||||
* as millis from unix epoch.
|
||||
*
|
||||
* The value may or may not be resolved as
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { shell } from 'electron';
|
||||
import { DiskFileSystemProvider as NodeDiskFileSystemProvider } from 'vs/platform/files/node/diskFileSystemProvider';
|
||||
import { FileDeleteOptions, FileSystemProviderCapabilities } from 'vs/platform/files/common/files';
|
||||
import { isWindows } from 'vs/base/common/platform';
|
||||
import { localize } from 'vs/nls';
|
||||
import { basename } from 'vs/base/common/path';
|
||||
|
||||
export class DiskFileSystemProvider extends NodeDiskFileSystemProvider {
|
||||
|
||||
get capabilities(): FileSystemProviderCapabilities {
|
||||
if (!this._capabilities) {
|
||||
this._capabilities = super.capabilities | FileSystemProviderCapabilities.Trash;
|
||||
}
|
||||
|
||||
return this._capabilities;
|
||||
}
|
||||
|
||||
protected async doDelete(filePath: string, opts: FileDeleteOptions): Promise<void> {
|
||||
if (!opts.useTrash) {
|
||||
return super.doDelete(filePath, opts);
|
||||
}
|
||||
|
||||
const result = shell.moveItemToTrash(filePath);
|
||||
if (!result) {
|
||||
throw new Error(isWindows ? localize('binFailed', "Failed to move '{0}' to the recycle bin", basename(filePath)) : localize('trashFailed', "Failed to move '{0}' to the trash", basename(filePath)));
|
||||
}
|
||||
}
|
||||
}
|
||||
556
src/vs/platform/files/node/diskFileSystemProvider.ts
Normal file
556
src/vs/platform/files/node/diskFileSystemProvider.ts
Normal file
@@ -0,0 +1,556 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { mkdir, open, close, read, write, fdatasync, Dirent, Stats } from 'fs';
|
||||
import { promisify } from 'util';
|
||||
import { IDisposable, Disposable, toDisposable, dispose, combinedDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IFileSystemProvider, FileSystemProviderCapabilities, IFileChange, IWatchOptions, IStat, FileType, FileDeleteOptions, FileOverwriteOptions, FileWriteOptions, FileOpenOptions, FileSystemProviderErrorCode, createFileSystemProviderError, FileSystemProviderError } from 'vs/platform/files/common/files';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { isLinux, isWindows } from 'vs/base/common/platform';
|
||||
import { statLink, unlink, move, copy, readFile, truncate, rimraf, RimRafMode, exists, readdirWithFileTypes } from 'vs/base/node/pfs';
|
||||
import { normalize, basename, dirname } from 'vs/base/common/path';
|
||||
import { joinPath } from 'vs/base/common/resources';
|
||||
import { isEqual } from 'vs/base/common/extpath';
|
||||
import { retry, ThrottledDelayer } from 'vs/base/common/async';
|
||||
import { ILogService, LogLevel } from 'vs/platform/log/common/log';
|
||||
import { localize } from 'vs/nls';
|
||||
import { IDiskFileChange, toFileChanges, ILogMessage } from 'vs/platform/files/node/watcher/watcher';
|
||||
import { FileWatcher as UnixWatcherService } from 'vs/platform/files/node/watcher/unix/watcherService';
|
||||
import { FileWatcher as WindowsWatcherService } from 'vs/platform/files/node/watcher/win32/watcherService';
|
||||
import { FileWatcher as NsfwWatcherService } from 'vs/platform/files/node/watcher/nsfw/watcherService';
|
||||
import { FileWatcher as NodeJSWatcherService } from 'vs/platform/files/node/watcher/nodejs/watcherService';
|
||||
|
||||
export interface IWatcherOptions {
|
||||
pollingInterval?: number;
|
||||
usePolling: boolean;
|
||||
}
|
||||
|
||||
export class DiskFileSystemProvider extends Disposable implements IFileSystemProvider {
|
||||
|
||||
constructor(private logService: ILogService, private watcherOptions?: IWatcherOptions) {
|
||||
super();
|
||||
}
|
||||
|
||||
//#region File Capabilities
|
||||
|
||||
onDidChangeCapabilities: Event<void> = Event.None;
|
||||
|
||||
protected _capabilities: FileSystemProviderCapabilities;
|
||||
get capabilities(): FileSystemProviderCapabilities {
|
||||
if (!this._capabilities) {
|
||||
this._capabilities =
|
||||
FileSystemProviderCapabilities.FileReadWrite |
|
||||
FileSystemProviderCapabilities.FileOpenReadWriteClose |
|
||||
FileSystemProviderCapabilities.FileFolderCopy;
|
||||
|
||||
if (isLinux) {
|
||||
this._capabilities |= FileSystemProviderCapabilities.PathCaseSensitive;
|
||||
}
|
||||
}
|
||||
|
||||
return this._capabilities;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region File Metadata Resolving
|
||||
|
||||
async stat(resource: URI): Promise<IStat> {
|
||||
try {
|
||||
const { stat, isSymbolicLink } = await statLink(this.toFilePath(resource)); // cannot use fs.stat() here to support links properly
|
||||
|
||||
return {
|
||||
type: this.toType(stat, isSymbolicLink),
|
||||
ctime: stat.ctime.getTime(),
|
||||
mtime: stat.mtime.getTime(),
|
||||
size: stat.size
|
||||
};
|
||||
} catch (error) {
|
||||
throw this.toFileSystemProviderError(error);
|
||||
}
|
||||
}
|
||||
|
||||
async readdir(resource: URI): Promise<[string, FileType][]> {
|
||||
try {
|
||||
const children = await readdirWithFileTypes(this.toFilePath(resource));
|
||||
|
||||
const result: [string, FileType][] = [];
|
||||
await Promise.all(children.map(async child => {
|
||||
try {
|
||||
let type: FileType;
|
||||
if (child.isSymbolicLink()) {
|
||||
type = (await this.stat(joinPath(resource, child.name))).type; // always resolve target the link points to if any
|
||||
} else {
|
||||
type = this.toType(child);
|
||||
}
|
||||
|
||||
result.push([child.name, type]);
|
||||
} catch (error) {
|
||||
this.logService.trace(error); // ignore errors for individual entries that can arise from permission denied
|
||||
}
|
||||
}));
|
||||
|
||||
return result;
|
||||
} catch (error) {
|
||||
throw this.toFileSystemProviderError(error);
|
||||
}
|
||||
}
|
||||
|
||||
private toType(entry: Stats | Dirent, isSymbolicLink = entry.isSymbolicLink()): FileType {
|
||||
if (isSymbolicLink) {
|
||||
return FileType.SymbolicLink | (entry.isDirectory() ? FileType.Directory : FileType.File);
|
||||
}
|
||||
|
||||
return entry.isFile() ? FileType.File : entry.isDirectory() ? FileType.Directory : FileType.Unknown;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region File Reading/Writing
|
||||
|
||||
async readFile(resource: URI): Promise<Uint8Array> {
|
||||
try {
|
||||
const filePath = this.toFilePath(resource);
|
||||
|
||||
return await readFile(filePath);
|
||||
} catch (error) {
|
||||
throw this.toFileSystemProviderError(error);
|
||||
}
|
||||
}
|
||||
|
||||
async writeFile(resource: URI, content: Uint8Array, opts: FileWriteOptions): Promise<void> {
|
||||
let handle: number | undefined = undefined;
|
||||
try {
|
||||
const filePath = this.toFilePath(resource);
|
||||
|
||||
// Validate target
|
||||
const fileExists = await exists(filePath);
|
||||
if (fileExists && !opts.overwrite) {
|
||||
throw createFileSystemProviderError(new Error(localize('fileExists', "File already exists")), FileSystemProviderErrorCode.FileExists);
|
||||
} else if (!fileExists && !opts.create) {
|
||||
throw createFileSystemProviderError(new Error(localize('fileNotExists', "File does not exist")), FileSystemProviderErrorCode.FileNotFound);
|
||||
}
|
||||
|
||||
// Open
|
||||
handle = await this.open(resource, { create: true });
|
||||
|
||||
// Write content at once
|
||||
await this.write(handle, 0, content, 0, content.byteLength);
|
||||
} catch (error) {
|
||||
throw this.toFileSystemProviderError(error);
|
||||
} finally {
|
||||
if (typeof handle === 'number') {
|
||||
await this.close(handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private writeHandles: Set<number> = new Set();
|
||||
private canFlush: boolean = true;
|
||||
|
||||
async open(resource: URI, opts: FileOpenOptions): Promise<number> {
|
||||
try {
|
||||
const filePath = this.toFilePath(resource);
|
||||
|
||||
let flags: string | undefined = undefined;
|
||||
if (opts.create) {
|
||||
if (isWindows && await exists(filePath)) {
|
||||
try {
|
||||
// On Windows and if the file exists, we use a different strategy of saving the file
|
||||
// by first truncating the file and then writing with r+ flag. This helps to save hidden files on Windows
|
||||
// (see https://github.com/Microsoft/vscode/issues/931) and prevent removing alternate data streams
|
||||
// (see https://github.com/Microsoft/vscode/issues/6363)
|
||||
await truncate(filePath, 0);
|
||||
|
||||
// After a successful truncate() the flag can be set to 'r+' which will not truncate.
|
||||
flags = 'r+';
|
||||
} catch (error) {
|
||||
this.logService.trace(error);
|
||||
}
|
||||
}
|
||||
|
||||
// we take opts.create as a hint that the file is opened for writing
|
||||
// as such we use 'w' to truncate an existing or create the
|
||||
// file otherwise. we do not allow reading.
|
||||
if (!flags) {
|
||||
flags = 'w';
|
||||
}
|
||||
} else {
|
||||
// otherwise we assume the file is opened for reading
|
||||
// as such we use 'r' to neither truncate, nor create
|
||||
// the file.
|
||||
flags = 'r';
|
||||
}
|
||||
|
||||
const handle = await promisify(open)(filePath, flags);
|
||||
|
||||
// remember that this handle was used for writing
|
||||
if (opts.create) {
|
||||
this.writeHandles.add(handle);
|
||||
}
|
||||
|
||||
return handle;
|
||||
} catch (error) {
|
||||
throw this.toFileSystemProviderError(error);
|
||||
}
|
||||
}
|
||||
|
||||
async close(fd: number): Promise<void> {
|
||||
try {
|
||||
// if a handle is closed that was used for writing, ensure
|
||||
// to flush the contents to disk if possible.
|
||||
if (this.writeHandles.delete(fd) && this.canFlush) {
|
||||
try {
|
||||
await promisify(fdatasync)(fd);
|
||||
} catch (error) {
|
||||
// In some exotic setups it is well possible that node fails to sync
|
||||
// In that case we disable flushing and log the error to our logger
|
||||
this.canFlush = false;
|
||||
this.logService.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
return await promisify(close)(fd);
|
||||
} catch (error) {
|
||||
throw this.toFileSystemProviderError(error);
|
||||
}
|
||||
}
|
||||
|
||||
async read(fd: number, pos: number, data: Uint8Array, offset: number, length: number): Promise<number> {
|
||||
try {
|
||||
const result = await promisify(read)(fd, data, offset, length, pos);
|
||||
if (typeof result === 'number') {
|
||||
return result; // node.d.ts fail
|
||||
}
|
||||
|
||||
return result.bytesRead;
|
||||
} catch (error) {
|
||||
throw this.toFileSystemProviderError(error);
|
||||
}
|
||||
}
|
||||
|
||||
async write(fd: number, pos: number, data: Uint8Array, offset: number, length: number): Promise<number> {
|
||||
// we know at this point that the file to write to is truncated and thus empty
|
||||
// if the write now fails, the file remains empty. as such we really try hard
|
||||
// to ensure the write succeeds by retrying up to three times.
|
||||
return retry(() => this.doWrite(fd, pos, data, offset, length), 100 /* ms delay */, 3 /* retries */);
|
||||
}
|
||||
|
||||
private async doWrite(fd: number, pos: number, data: Uint8Array, offset: number, length: number): Promise<number> {
|
||||
try {
|
||||
const result = await promisify(write)(fd, data, offset, length, pos);
|
||||
if (typeof result === 'number') {
|
||||
return result; // node.d.ts fail
|
||||
}
|
||||
|
||||
return result.bytesWritten;
|
||||
} catch (error) {
|
||||
throw this.toFileSystemProviderError(error);
|
||||
}
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Move/Copy/Delete/Create Folder
|
||||
|
||||
async mkdir(resource: URI): Promise<void> {
|
||||
try {
|
||||
await promisify(mkdir)(this.toFilePath(resource));
|
||||
} catch (error) {
|
||||
throw this.toFileSystemProviderError(error);
|
||||
}
|
||||
}
|
||||
|
||||
async delete(resource: URI, opts: FileDeleteOptions): Promise<void> {
|
||||
try {
|
||||
const filePath = this.toFilePath(resource);
|
||||
|
||||
await this.doDelete(filePath, opts);
|
||||
} catch (error) {
|
||||
throw this.toFileSystemProviderError(error);
|
||||
}
|
||||
}
|
||||
|
||||
protected async doDelete(filePath: string, opts: FileDeleteOptions): Promise<void> {
|
||||
if (opts.recursive) {
|
||||
await rimraf(filePath, RimRafMode.MOVE);
|
||||
} else {
|
||||
await unlink(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
async rename(from: URI, to: URI, opts: FileOverwriteOptions): Promise<void> {
|
||||
const fromFilePath = this.toFilePath(from);
|
||||
const toFilePath = this.toFilePath(to);
|
||||
|
||||
if (fromFilePath === toFilePath) {
|
||||
return; // simulate node.js behaviour here and do a no-op if paths match
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
// Ensure target does not exist
|
||||
await this.validateTargetDeleted(from, to, 'move', opts && opts.overwrite);
|
||||
|
||||
// Move
|
||||
await move(fromFilePath, toFilePath);
|
||||
} catch (error) {
|
||||
|
||||
// rewrite some typical errors that can happen especially around symlinks
|
||||
// to something the user can better understand
|
||||
if (error.code === 'EINVAL' || error.code === 'EBUSY' || error.code === 'ENAMETOOLONG') {
|
||||
error = new Error(localize('moveError', "Unable to move '{0}' into '{1}' ({2}).", basename(fromFilePath), basename(dirname(toFilePath)), error.toString()));
|
||||
}
|
||||
|
||||
throw this.toFileSystemProviderError(error);
|
||||
}
|
||||
}
|
||||
|
||||
async copy(from: URI, to: URI, opts: FileOverwriteOptions): Promise<void> {
|
||||
const fromFilePath = this.toFilePath(from);
|
||||
const toFilePath = this.toFilePath(to);
|
||||
|
||||
if (fromFilePath === toFilePath) {
|
||||
return; // simulate node.js behaviour here and do a no-op if paths match
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
// Ensure target does not exist
|
||||
await this.validateTargetDeleted(from, to, 'copy', opts && opts.overwrite);
|
||||
|
||||
// Copy
|
||||
await copy(fromFilePath, toFilePath);
|
||||
} catch (error) {
|
||||
|
||||
// rewrite some typical errors that can happen especially around symlinks
|
||||
// to something the user can better understand
|
||||
if (error.code === 'EINVAL' || error.code === 'EBUSY' || error.code === 'ENAMETOOLONG') {
|
||||
error = new Error(localize('copyError', "Unable to copy '{0}' into '{1}' ({2}).", basename(fromFilePath), basename(dirname(toFilePath)), error.toString()));
|
||||
}
|
||||
|
||||
throw this.toFileSystemProviderError(error);
|
||||
}
|
||||
}
|
||||
|
||||
private async validateTargetDeleted(from: URI, to: URI, mode: 'move' | 'copy', overwrite?: boolean): Promise<void> {
|
||||
const isPathCaseSensitive = !!(this.capabilities & FileSystemProviderCapabilities.PathCaseSensitive);
|
||||
|
||||
const fromFilePath = this.toFilePath(from);
|
||||
const toFilePath = this.toFilePath(to);
|
||||
|
||||
let isSameResourceWithDifferentPathCase = false;
|
||||
if (!isPathCaseSensitive) {
|
||||
isSameResourceWithDifferentPathCase = isEqual(fromFilePath, toFilePath, true /* ignore case */);
|
||||
}
|
||||
|
||||
if (isSameResourceWithDifferentPathCase && mode === 'copy') {
|
||||
throw createFileSystemProviderError(new Error('File cannot be copied to same path with different path case'), FileSystemProviderErrorCode.FileExists);
|
||||
}
|
||||
|
||||
// handle existing target (unless this is a case change)
|
||||
if (!isSameResourceWithDifferentPathCase && await exists(toFilePath)) {
|
||||
if (!overwrite) {
|
||||
throw createFileSystemProviderError(new Error('File at target already exists'), FileSystemProviderErrorCode.FileExists);
|
||||
}
|
||||
|
||||
// Delete target
|
||||
await this.delete(to, { recursive: true, useTrash: false });
|
||||
}
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region File Watching
|
||||
|
||||
private _onDidWatchErrorOccur: Emitter<string> = this._register(new Emitter<string>());
|
||||
readonly onDidErrorOccur: Event<string> = this._onDidWatchErrorOccur.event;
|
||||
|
||||
private _onDidChangeFile: Emitter<IFileChange[]> = this._register(new Emitter<IFileChange[]>());
|
||||
get onDidChangeFile(): Event<IFileChange[]> { return this._onDidChangeFile.event; }
|
||||
|
||||
private recursiveWatcher: WindowsWatcherService | UnixWatcherService | NsfwWatcherService | undefined;
|
||||
private recursiveFoldersToWatch: { path: string, excludes: string[] }[] = [];
|
||||
private recursiveWatchRequestDelayer: ThrottledDelayer<void> = this._register(new ThrottledDelayer<void>(0));
|
||||
|
||||
private recursiveWatcherLogLevelListener: IDisposable | undefined;
|
||||
|
||||
watch(resource: URI, opts: IWatchOptions): IDisposable {
|
||||
if (opts.recursive) {
|
||||
return this.watchRecursive(resource, opts.excludes);
|
||||
}
|
||||
|
||||
return this.watchNonRecursive(resource); // TODO@ben ideally the same watcher can be used in both cases
|
||||
}
|
||||
|
||||
private watchRecursive(resource: URI, excludes: string[]): IDisposable {
|
||||
|
||||
// Add to list of folders to watch recursively
|
||||
const folderToWatch = { path: this.toFilePath(resource), excludes };
|
||||
this.recursiveFoldersToWatch.push(folderToWatch);
|
||||
|
||||
// Trigger update
|
||||
this.refreshRecursiveWatchers();
|
||||
|
||||
return toDisposable(() => {
|
||||
|
||||
// Remove from list of folders to watch recursively
|
||||
this.recursiveFoldersToWatch.splice(this.recursiveFoldersToWatch.indexOf(folderToWatch), 1);
|
||||
|
||||
// Trigger update
|
||||
this.refreshRecursiveWatchers();
|
||||
});
|
||||
}
|
||||
|
||||
private refreshRecursiveWatchers(): void {
|
||||
|
||||
// Buffer requests for recursive watching to decide on right watcher
|
||||
// that supports potentially watching more than one folder at once
|
||||
this.recursiveWatchRequestDelayer.trigger(() => {
|
||||
this.doRefreshRecursiveWatchers();
|
||||
|
||||
return Promise.resolve();
|
||||
});
|
||||
}
|
||||
|
||||
private doRefreshRecursiveWatchers(): void {
|
||||
|
||||
// Reuse existing
|
||||
if (this.recursiveWatcher instanceof NsfwWatcherService) {
|
||||
this.recursiveWatcher.setFolders(this.recursiveFoldersToWatch);
|
||||
}
|
||||
|
||||
// Create new
|
||||
else {
|
||||
|
||||
// Dispose old
|
||||
dispose(this.recursiveWatcher);
|
||||
this.recursiveWatcher = undefined;
|
||||
|
||||
// Create new if we actually have folders to watch
|
||||
if (this.recursiveFoldersToWatch.length > 0) {
|
||||
let watcherImpl: {
|
||||
new(
|
||||
folders: { path: string, excludes: string[] }[],
|
||||
onChange: (changes: IDiskFileChange[]) => void,
|
||||
onLogMessage: (msg: ILogMessage) => void,
|
||||
verboseLogging: boolean,
|
||||
watcherOptions?: IWatcherOptions
|
||||
): WindowsWatcherService | UnixWatcherService | NsfwWatcherService
|
||||
};
|
||||
let watcherOptions = undefined;
|
||||
|
||||
if (this.watcherOptions && this.watcherOptions.usePolling) {
|
||||
// requires a polling watcher
|
||||
watcherImpl = UnixWatcherService;
|
||||
watcherOptions = this.watcherOptions;
|
||||
} else {
|
||||
// Single Folder Watcher
|
||||
if (this.recursiveFoldersToWatch.length === 1) {
|
||||
if (isWindows) {
|
||||
watcherImpl = WindowsWatcherService;
|
||||
} else {
|
||||
watcherImpl = UnixWatcherService;
|
||||
}
|
||||
}
|
||||
|
||||
// Multi Folder Watcher
|
||||
else {
|
||||
watcherImpl = NsfwWatcherService;
|
||||
}
|
||||
}
|
||||
|
||||
// Create and start watching
|
||||
this.recursiveWatcher = new watcherImpl(
|
||||
this.recursiveFoldersToWatch,
|
||||
event => this._onDidChangeFile.fire(toFileChanges(event)),
|
||||
msg => {
|
||||
if (msg.type === 'error') {
|
||||
this._onDidWatchErrorOccur.fire(msg.message);
|
||||
}
|
||||
this.logService[msg.type](msg.message);
|
||||
},
|
||||
this.logService.getLevel() === LogLevel.Trace,
|
||||
watcherOptions
|
||||
);
|
||||
|
||||
if (!this.recursiveWatcherLogLevelListener) {
|
||||
this.recursiveWatcherLogLevelListener = this.logService.onDidChangeLogLevel(_ => {
|
||||
if (this.recursiveWatcher) {
|
||||
this.recursiveWatcher.setVerboseLogging(this.logService.getLevel() === LogLevel.Trace);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private watchNonRecursive(resource: URI): IDisposable {
|
||||
const watcherService = new NodeJSWatcherService(
|
||||
this.toFilePath(resource),
|
||||
changes => this._onDidChangeFile.fire(toFileChanges(changes)),
|
||||
msg => {
|
||||
if (msg.type === 'error') {
|
||||
this._onDidWatchErrorOccur.fire(msg.message);
|
||||
}
|
||||
this.logService[msg.type](msg.message);
|
||||
},
|
||||
this.logService.getLevel() === LogLevel.Trace
|
||||
);
|
||||
const logLevelListener = this.logService.onDidChangeLogLevel(_ => {
|
||||
watcherService.setVerboseLogging(this.logService.getLevel() === LogLevel.Trace);
|
||||
});
|
||||
|
||||
return combinedDisposable(watcherService, logLevelListener);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Helpers
|
||||
|
||||
protected toFilePath(resource: URI): string {
|
||||
return normalize(resource.fsPath);
|
||||
}
|
||||
|
||||
private toFileSystemProviderError(error: NodeJS.ErrnoException): FileSystemProviderError {
|
||||
if (error instanceof FileSystemProviderError) {
|
||||
return error; // avoid double conversion
|
||||
}
|
||||
|
||||
let code: FileSystemProviderErrorCode;
|
||||
switch (error.code) {
|
||||
case 'ENOENT':
|
||||
code = FileSystemProviderErrorCode.FileNotFound;
|
||||
break;
|
||||
case 'EISDIR':
|
||||
code = FileSystemProviderErrorCode.FileIsADirectory;
|
||||
break;
|
||||
case 'EEXIST':
|
||||
code = FileSystemProviderErrorCode.FileExists;
|
||||
break;
|
||||
case 'EPERM':
|
||||
case 'EACCES':
|
||||
code = FileSystemProviderErrorCode.NoPermissions;
|
||||
break;
|
||||
default:
|
||||
code = FileSystemProviderErrorCode.Unknown;
|
||||
}
|
||||
|
||||
return createFileSystemProviderError(error, code);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
dispose(): void {
|
||||
super.dispose();
|
||||
|
||||
dispose(this.recursiveWatcher);
|
||||
this.recursiveWatcher = undefined;
|
||||
|
||||
dispose(this.recursiveWatcherLogLevelListener);
|
||||
this.recursiveWatcherLogLevelListener = undefined;
|
||||
}
|
||||
}
|
||||
128
src/vs/platform/files/node/watcher/nodejs/watcherService.ts
Normal file
128
src/vs/platform/files/node/watcher/nodejs/watcherService.ts
Normal file
@@ -0,0 +1,128 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IDiskFileChange, normalizeFileChanges, ILogMessage } from 'vs/platform/files/node/watcher/watcher';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { statLink } from 'vs/base/node/pfs';
|
||||
import { realpath } from 'vs/base/node/extpath';
|
||||
import { watchFolder, watchFile, CHANGE_BUFFER_DELAY } from 'vs/base/node/watcher';
|
||||
import { FileChangeType } from 'vs/platform/files/common/files';
|
||||
import { ThrottledDelayer } from 'vs/base/common/async';
|
||||
import { join, basename } from 'vs/base/common/path';
|
||||
|
||||
export class FileWatcher extends Disposable {
|
||||
private isDisposed: boolean;
|
||||
|
||||
private fileChangesDelayer: ThrottledDelayer<void> = this._register(new ThrottledDelayer<void>(CHANGE_BUFFER_DELAY * 2 /* sync on delay from underlying library */));
|
||||
private fileChangesBuffer: IDiskFileChange[] = [];
|
||||
|
||||
constructor(
|
||||
private path: string,
|
||||
private onFileChanges: (changes: IDiskFileChange[]) => void,
|
||||
private onLogMessage: (msg: ILogMessage) => void,
|
||||
private verboseLogging: boolean
|
||||
) {
|
||||
super();
|
||||
|
||||
this.startWatching();
|
||||
}
|
||||
|
||||
setVerboseLogging(verboseLogging: boolean): void {
|
||||
this.verboseLogging = verboseLogging;
|
||||
}
|
||||
|
||||
private async startWatching(): Promise<void> {
|
||||
try {
|
||||
const { stat, isSymbolicLink } = await statLink(this.path);
|
||||
|
||||
if (this.isDisposed) {
|
||||
return;
|
||||
}
|
||||
|
||||
let pathToWatch = this.path;
|
||||
if (isSymbolicLink) {
|
||||
try {
|
||||
pathToWatch = await realpath(pathToWatch);
|
||||
} catch (error) {
|
||||
this.onError(error);
|
||||
}
|
||||
}
|
||||
|
||||
// Watch Folder
|
||||
if (stat.isDirectory()) {
|
||||
this._register(watchFolder(pathToWatch, (eventType, path) => {
|
||||
this.onFileChange({
|
||||
type: eventType === 'changed' ? FileChangeType.UPDATED : eventType === 'added' ? FileChangeType.ADDED : FileChangeType.DELETED,
|
||||
path: join(this.path, basename(path)) // ensure path is identical with what was passed in
|
||||
});
|
||||
}, error => this.onError(error)));
|
||||
}
|
||||
|
||||
// Watch File
|
||||
else {
|
||||
this._register(watchFile(pathToWatch, eventType => {
|
||||
this.onFileChange({
|
||||
type: eventType === 'changed' ? FileChangeType.UPDATED : FileChangeType.DELETED,
|
||||
path: this.path // ensure path is identical with what was passed in
|
||||
});
|
||||
}, error => this.onError(error)));
|
||||
}
|
||||
} catch (error) {
|
||||
this.onError(error);
|
||||
}
|
||||
}
|
||||
|
||||
private onFileChange(event: IDiskFileChange): void {
|
||||
|
||||
// Add to buffer
|
||||
this.fileChangesBuffer.push(event);
|
||||
|
||||
// Logging
|
||||
if (this.verboseLogging) {
|
||||
this.onVerbose(`${event.type === FileChangeType.ADDED ? '[ADDED]' : event.type === FileChangeType.DELETED ? '[DELETED]' : '[CHANGED]'} ${event.path}`);
|
||||
}
|
||||
|
||||
// Handle emit through delayer to accommodate for bulk changes and thus reduce spam
|
||||
this.fileChangesDelayer.trigger(() => {
|
||||
const fileChanges = this.fileChangesBuffer;
|
||||
this.fileChangesBuffer = [];
|
||||
|
||||
// Event normalization
|
||||
const normalizedFileChanges = normalizeFileChanges(fileChanges);
|
||||
|
||||
// Logging
|
||||
if (this.verboseLogging) {
|
||||
normalizedFileChanges.forEach(event => {
|
||||
this.onVerbose(`>> normalized ${event.type === FileChangeType.ADDED ? '[ADDED]' : event.type === FileChangeType.DELETED ? '[DELETED]' : '[CHANGED]'} ${event.path}`);
|
||||
});
|
||||
}
|
||||
|
||||
// Fire
|
||||
if (normalizedFileChanges.length > 0) {
|
||||
this.onFileChanges(normalizedFileChanges);
|
||||
}
|
||||
|
||||
return Promise.resolve();
|
||||
});
|
||||
}
|
||||
|
||||
private onError(error: string): void {
|
||||
if (!this.isDisposed) {
|
||||
this.onLogMessage({ type: 'error', message: `[File Watcher (node.js)] ${error}` });
|
||||
}
|
||||
}
|
||||
|
||||
private onVerbose(message: string): void {
|
||||
if (!this.isDisposed) {
|
||||
this.onLogMessage({ type: 'trace', message: `[File Watcher (node.js)] ${message}` });
|
||||
}
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this.isDisposed = true;
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
257
src/vs/platform/files/node/watcher/nsfw/nsfwWatcherService.ts
Normal file
257
src/vs/platform/files/node/watcher/nsfw/nsfwWatcherService.ts
Normal file
@@ -0,0 +1,257 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as glob from 'vs/base/common/glob';
|
||||
import * as extpath from 'vs/base/common/extpath';
|
||||
import * as path from 'vs/base/common/path';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import { IDiskFileChange, normalizeFileChanges, ILogMessage } from 'vs/platform/files/node/watcher/watcher';
|
||||
import * as nsfw from 'nsfw';
|
||||
import { IWatcherService, IWatcherRequest, IWatcherOptions } from 'vs/platform/files/node/watcher/nsfw/watcher';
|
||||
import { ThrottledDelayer } from 'vs/base/common/async';
|
||||
import { FileChangeType } from 'vs/platform/files/common/files';
|
||||
import { normalizeNFC } from 'vs/base/common/normalization';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { realcaseSync, realpathSync } from 'vs/base/node/extpath';
|
||||
|
||||
const nsfwActionToRawChangeType: { [key: number]: number } = [];
|
||||
nsfwActionToRawChangeType[nsfw.actions.CREATED] = FileChangeType.ADDED;
|
||||
nsfwActionToRawChangeType[nsfw.actions.MODIFIED] = FileChangeType.UPDATED;
|
||||
nsfwActionToRawChangeType[nsfw.actions.DELETED] = FileChangeType.DELETED;
|
||||
|
||||
interface IWatcherObjet {
|
||||
start(): any;
|
||||
stop(): any;
|
||||
}
|
||||
|
||||
interface IPathWatcher {
|
||||
ready: Promise<IWatcherObjet>;
|
||||
watcher?: IWatcherObjet;
|
||||
ignored: glob.ParsedPattern[];
|
||||
}
|
||||
|
||||
export class NsfwWatcherService implements IWatcherService {
|
||||
private static readonly FS_EVENT_DELAY = 50; // aggregate and only emit events when changes have stopped for this duration (in ms)
|
||||
|
||||
private _pathWatchers: { [watchPath: string]: IPathWatcher } = {};
|
||||
private _verboseLogging: boolean;
|
||||
private enospcErrorLogged: boolean;
|
||||
|
||||
private _onWatchEvent = new Emitter<IDiskFileChange[]>();
|
||||
readonly onWatchEvent = this._onWatchEvent.event;
|
||||
|
||||
private _onLogMessage = new Emitter<ILogMessage>();
|
||||
readonly onLogMessage: Event<ILogMessage> = this._onLogMessage.event;
|
||||
|
||||
watch(options: IWatcherOptions): Event<IDiskFileChange[]> {
|
||||
return this.onWatchEvent;
|
||||
}
|
||||
|
||||
private _watch(request: IWatcherRequest): void {
|
||||
let undeliveredFileEvents: IDiskFileChange[] = [];
|
||||
const fileEventDelayer = new ThrottledDelayer<void>(NsfwWatcherService.FS_EVENT_DELAY);
|
||||
|
||||
let readyPromiseResolve: (watcher: IWatcherObjet) => void;
|
||||
this._pathWatchers[request.path] = {
|
||||
ready: new Promise<IWatcherObjet>(resolve => readyPromiseResolve = resolve),
|
||||
ignored: Array.isArray(request.excludes) ? request.excludes.map(ignored => glob.parse(ignored)) : []
|
||||
};
|
||||
|
||||
process.on('uncaughtException', (e: Error | string) => {
|
||||
|
||||
// Specially handle ENOSPC errors that can happen when
|
||||
// the watcher consumes so many file descriptors that
|
||||
// we are running into a limit. We only want to warn
|
||||
// once in this case to avoid log spam.
|
||||
// See https://github.com/Microsoft/vscode/issues/7950
|
||||
if (e === 'Inotify limit reached' && !this.enospcErrorLogged) {
|
||||
this.enospcErrorLogged = true;
|
||||
this.error('Inotify limit reached (ENOSPC)');
|
||||
}
|
||||
});
|
||||
|
||||
// NSFW does not report file changes in the path provided on macOS if
|
||||
// - the path uses wrong casing
|
||||
// - the path is a symbolic link
|
||||
// We have to detect this case and massage the events to correct this.
|
||||
let realBasePathDiffers = false;
|
||||
let realBasePathLength = request.path.length;
|
||||
if (platform.isMacintosh) {
|
||||
try {
|
||||
|
||||
// First check for symbolic link
|
||||
let realBasePath = realpathSync(request.path);
|
||||
|
||||
// Second check for casing difference
|
||||
if (request.path === realBasePath) {
|
||||
realBasePath = (realcaseSync(request.path) || request.path);
|
||||
}
|
||||
|
||||
if (request.path !== realBasePath) {
|
||||
realBasePathLength = realBasePath.length;
|
||||
realBasePathDiffers = true;
|
||||
|
||||
this.warn(`Watcher basePath does not match version on disk and will be corrected (original: ${request.path}, real: ${realBasePath})`);
|
||||
}
|
||||
} catch (error) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
nsfw(request.path, events => {
|
||||
for (const e of events) {
|
||||
// Logging
|
||||
if (this._verboseLogging) {
|
||||
const logPath = e.action === nsfw.actions.RENAMED ? path.join(e.directory, e.oldFile || '') + ' -> ' + e.newFile : path.join(e.directory, e.file || '');
|
||||
this.log(`${e.action === nsfw.actions.CREATED ? '[CREATED]' : e.action === nsfw.actions.DELETED ? '[DELETED]' : e.action === nsfw.actions.MODIFIED ? '[CHANGED]' : '[RENAMED]'} ${logPath}`);
|
||||
}
|
||||
|
||||
// Convert nsfw event to IRawFileChange and add to queue
|
||||
let absolutePath: string;
|
||||
if (e.action === nsfw.actions.RENAMED) {
|
||||
// Rename fires when a file's name changes within a single directory
|
||||
absolutePath = path.join(e.directory, e.oldFile || '');
|
||||
if (!this._isPathIgnored(absolutePath, this._pathWatchers[request.path].ignored)) {
|
||||
undeliveredFileEvents.push({ type: FileChangeType.DELETED, path: absolutePath });
|
||||
} else if (this._verboseLogging) {
|
||||
this.log(` >> ignored ${absolutePath}`);
|
||||
}
|
||||
absolutePath = path.join(e.newDirectory || e.directory, e.newFile || '');
|
||||
if (!this._isPathIgnored(absolutePath, this._pathWatchers[request.path].ignored)) {
|
||||
undeliveredFileEvents.push({ type: FileChangeType.ADDED, path: absolutePath });
|
||||
} else if (this._verboseLogging) {
|
||||
this.log(` >> ignored ${absolutePath}`);
|
||||
}
|
||||
} else {
|
||||
absolutePath = path.join(e.directory, e.file || '');
|
||||
if (!this._isPathIgnored(absolutePath, this._pathWatchers[request.path].ignored)) {
|
||||
undeliveredFileEvents.push({
|
||||
type: nsfwActionToRawChangeType[e.action],
|
||||
path: absolutePath
|
||||
});
|
||||
} else if (this._verboseLogging) {
|
||||
this.log(` >> ignored ${absolutePath}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Delay and send buffer
|
||||
fileEventDelayer.trigger(() => {
|
||||
const events = undeliveredFileEvents;
|
||||
undeliveredFileEvents = [];
|
||||
|
||||
if (platform.isMacintosh) {
|
||||
events.forEach(e => {
|
||||
|
||||
// Mac uses NFD unicode form on disk, but we want NFC
|
||||
e.path = normalizeNFC(e.path);
|
||||
|
||||
// Convert paths back to original form in case it differs
|
||||
if (realBasePathDiffers) {
|
||||
e.path = request.path + e.path.substr(realBasePathLength);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Broadcast to clients normalized
|
||||
const res = normalizeFileChanges(events);
|
||||
this._onWatchEvent.fire(res);
|
||||
|
||||
// Logging
|
||||
if (this._verboseLogging) {
|
||||
res.forEach(r => {
|
||||
this.log(` >> normalized ${r.type === FileChangeType.ADDED ? '[ADDED]' : r.type === FileChangeType.DELETED ? '[DELETED]' : '[CHANGED]'} ${r.path}`);
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.resolve(undefined);
|
||||
});
|
||||
}).then(watcher => {
|
||||
this._pathWatchers[request.path].watcher = watcher;
|
||||
const startPromise = watcher.start();
|
||||
startPromise.then(() => readyPromiseResolve(watcher));
|
||||
return startPromise;
|
||||
});
|
||||
}
|
||||
|
||||
public setRoots(roots: IWatcherRequest[]): Promise<void> {
|
||||
const promises: Promise<void>[] = [];
|
||||
const normalizedRoots = this._normalizeRoots(roots);
|
||||
|
||||
// Gather roots that are not currently being watched
|
||||
const rootsToStartWatching = normalizedRoots.filter(r => {
|
||||
return !(r.path in this._pathWatchers);
|
||||
});
|
||||
|
||||
// Gather current roots that don't exist in the new roots array
|
||||
const rootsToStopWatching = Object.keys(this._pathWatchers).filter(r => {
|
||||
return normalizedRoots.every(normalizedRoot => normalizedRoot.path !== r);
|
||||
});
|
||||
|
||||
// Logging
|
||||
if (this._verboseLogging) {
|
||||
this.log(`Start watching: [${rootsToStartWatching.map(r => r.path).join(',')}]\nStop watching: [${rootsToStopWatching.join(',')}]`);
|
||||
}
|
||||
|
||||
// Stop watching some roots
|
||||
rootsToStopWatching.forEach(root => {
|
||||
this._pathWatchers[root].ready.then(watcher => watcher.stop());
|
||||
delete this._pathWatchers[root];
|
||||
});
|
||||
|
||||
// Start watching some roots
|
||||
rootsToStartWatching.forEach(root => this._watch(root));
|
||||
|
||||
// Refresh ignored arrays in case they changed
|
||||
roots.forEach(root => {
|
||||
if (root.path in this._pathWatchers) {
|
||||
this._pathWatchers[root.path].ignored = Array.isArray(root.excludes) ? root.excludes.map(ignored => glob.parse(ignored)) : [];
|
||||
}
|
||||
});
|
||||
|
||||
return Promise.all(promises).then(() => undefined);
|
||||
}
|
||||
|
||||
public setVerboseLogging(enabled: boolean): Promise<void> {
|
||||
this._verboseLogging = enabled;
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
public stop(): Promise<void> {
|
||||
for (let path in this._pathWatchers) {
|
||||
let watcher = this._pathWatchers[path];
|
||||
watcher.ready.then(watcher => watcher.stop());
|
||||
delete this._pathWatchers[path];
|
||||
}
|
||||
this._pathWatchers = Object.create(null);
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes a set of root paths by removing any root paths that are
|
||||
* sub-paths of other roots.
|
||||
*/
|
||||
protected _normalizeRoots(roots: IWatcherRequest[]): IWatcherRequest[] {
|
||||
return roots.filter(r => roots.every(other => {
|
||||
return !(r.path.length > other.path.length && extpath.isEqualOrParent(r.path, other.path));
|
||||
}));
|
||||
}
|
||||
|
||||
private _isPathIgnored(absolutePath: string, ignored: glob.ParsedPattern[]): boolean {
|
||||
return ignored && ignored.some(i => i(absolutePath));
|
||||
}
|
||||
|
||||
private log(message: string) {
|
||||
this._onLogMessage.fire({ type: 'trace', message: `[File Watcher (nswf)] ` + message });
|
||||
}
|
||||
|
||||
private warn(message: string) {
|
||||
this._onLogMessage.fire({ type: 'warn', message: `[File Watcher (nswf)] ` + message });
|
||||
}
|
||||
|
||||
private error(message: string) {
|
||||
this._onLogMessage.fire({ type: 'error', message: `[File Watcher (nswf)] ` + message });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 * as platform from 'vs/base/common/platform';
|
||||
|
||||
import { NsfwWatcherService } from 'vs/platform/files/node/watcher/nsfw/nsfwWatcherService';
|
||||
import { IWatcherRequest } from 'vs/platform/files/node/watcher/nsfw/watcher';
|
||||
|
||||
class TestNsfwWatcherService extends NsfwWatcherService {
|
||||
public normalizeRoots(roots: string[]): string[] {
|
||||
// Work with strings as paths to simplify testing
|
||||
const requests: IWatcherRequest[] = roots.map(r => {
|
||||
return { path: r, excludes: [] };
|
||||
});
|
||||
return this._normalizeRoots(requests).map(r => r.path);
|
||||
}
|
||||
}
|
||||
|
||||
suite('NSFW Watcher Service', () => {
|
||||
suite('_normalizeRoots', () => {
|
||||
test('should not impacts roots that don\'t overlap', () => {
|
||||
const service = new TestNsfwWatcherService();
|
||||
if (platform.isWindows) {
|
||||
assert.deepEqual(service.normalizeRoots(['C:\\a']), ['C:\\a']);
|
||||
assert.deepEqual(service.normalizeRoots(['C:\\a', 'C:\\b']), ['C:\\a', 'C:\\b']);
|
||||
assert.deepEqual(service.normalizeRoots(['C:\\a', 'C:\\b', 'C:\\c\\d\\e']), ['C:\\a', 'C:\\b', 'C:\\c\\d\\e']);
|
||||
} else {
|
||||
assert.deepEqual(service.normalizeRoots(['/a']), ['/a']);
|
||||
assert.deepEqual(service.normalizeRoots(['/a', '/b']), ['/a', '/b']);
|
||||
assert.deepEqual(service.normalizeRoots(['/a', '/b', '/c/d/e']), ['/a', '/b', '/c/d/e']);
|
||||
}
|
||||
});
|
||||
|
||||
test('should remove sub-folders of other roots', () => {
|
||||
const service = new TestNsfwWatcherService();
|
||||
if (platform.isWindows) {
|
||||
assert.deepEqual(service.normalizeRoots(['C:\\a', 'C:\\a\\b']), ['C:\\a']);
|
||||
assert.deepEqual(service.normalizeRoots(['C:\\a', 'C:\\b', 'C:\\a\\b']), ['C:\\a', 'C:\\b']);
|
||||
assert.deepEqual(service.normalizeRoots(['C:\\b\\a', 'C:\\a', 'C:\\b', 'C:\\a\\b']), ['C:\\a', 'C:\\b']);
|
||||
assert.deepEqual(service.normalizeRoots(['C:\\a', 'C:\\a\\b', 'C:\\a\\c\\d']), ['C:\\a']);
|
||||
} else {
|
||||
assert.deepEqual(service.normalizeRoots(['/a', '/a/b']), ['/a']);
|
||||
assert.deepEqual(service.normalizeRoots(['/a', '/b', '/a/b']), ['/a', '/b']);
|
||||
assert.deepEqual(service.normalizeRoots(['/b/a', '/a', '/b', '/a/b']), ['/a', '/b']);
|
||||
assert.deepEqual(service.normalizeRoots(['/a', '/a/b', '/a/c/d']), ['/a']);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
23
src/vs/platform/files/node/watcher/nsfw/watcher.ts
Normal file
23
src/vs/platform/files/node/watcher/nsfw/watcher.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { IDiskFileChange, ILogMessage } from 'vs/platform/files/node/watcher/watcher';
|
||||
|
||||
export interface IWatcherRequest {
|
||||
path: string;
|
||||
excludes: string[];
|
||||
}
|
||||
|
||||
export interface IWatcherOptions {
|
||||
}
|
||||
|
||||
export interface IWatcherService {
|
||||
watch(options: IWatcherOptions): Event<IDiskFileChange[]>;
|
||||
setRoots(roots: IWatcherRequest[]): Promise<void>;
|
||||
setVerboseLogging(enabled: boolean): Promise<void>;
|
||||
onLogMessage: Event<ILogMessage>;
|
||||
stop(): Promise<void>;
|
||||
}
|
||||
13
src/vs/platform/files/node/watcher/nsfw/watcherApp.ts
Normal file
13
src/vs/platform/files/node/watcher/nsfw/watcherApp.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Server } from 'vs/base/parts/ipc/node/ipc.cp';
|
||||
import { WatcherChannel } from 'vs/platform/files/node/watcher/nsfw/watcherIpc';
|
||||
import { NsfwWatcherService } from 'vs/platform/files/node/watcher/nsfw/nsfwWatcherService';
|
||||
|
||||
const server = new Server('watcher');
|
||||
const service = new NsfwWatcherService();
|
||||
const channel = new WatcherChannel(service);
|
||||
server.registerChannel('watcher', channel);
|
||||
58
src/vs/platform/files/node/watcher/nsfw/watcherIpc.ts
Normal file
58
src/vs/platform/files/node/watcher/nsfw/watcherIpc.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IChannel, IServerChannel } from 'vs/base/parts/ipc/common/ipc';
|
||||
import { IWatcherRequest, IWatcherService, IWatcherOptions } from './watcher';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { IDiskFileChange, ILogMessage } from 'vs/platform/files/node/watcher/watcher';
|
||||
|
||||
export class WatcherChannel implements IServerChannel {
|
||||
|
||||
constructor(private service: IWatcherService) { }
|
||||
|
||||
listen(_: unknown, event: string, arg?: any): Event<any> {
|
||||
switch (event) {
|
||||
case 'watch': return this.service.watch(arg);
|
||||
case 'onLogMessage': return this.service.onLogMessage;
|
||||
}
|
||||
|
||||
throw new Error(`Event not found: ${event}`);
|
||||
}
|
||||
|
||||
call(_: unknown, command: string, arg?: any): Promise<any> {
|
||||
switch (command) {
|
||||
case 'setRoots': return this.service.setRoots(arg);
|
||||
case 'setVerboseLogging': return this.service.setVerboseLogging(arg);
|
||||
case 'stop': return this.service.stop();
|
||||
}
|
||||
|
||||
throw new Error(`Call not found: ${command}`);
|
||||
}
|
||||
}
|
||||
|
||||
export class WatcherChannelClient implements IWatcherService {
|
||||
|
||||
constructor(private channel: IChannel) { }
|
||||
|
||||
watch(options: IWatcherOptions): Event<IDiskFileChange[]> {
|
||||
return this.channel.listen('watch', options);
|
||||
}
|
||||
|
||||
setVerboseLogging(enable: boolean): Promise<void> {
|
||||
return this.channel.call('setVerboseLogging', enable);
|
||||
}
|
||||
|
||||
setRoots(roots: IWatcherRequest[]): Promise<void> {
|
||||
return this.channel.call('setRoots', roots);
|
||||
}
|
||||
|
||||
get onLogMessage(): Event<ILogMessage> {
|
||||
return this.channel.listen('onLogMessage');
|
||||
}
|
||||
|
||||
stop(): Promise<void> {
|
||||
return this.channel.call('stop');
|
||||
}
|
||||
}
|
||||
100
src/vs/platform/files/node/watcher/nsfw/watcherService.ts
Normal file
100
src/vs/platform/files/node/watcher/nsfw/watcherService.ts
Normal file
@@ -0,0 +1,100 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { getNextTickChannel } from 'vs/base/parts/ipc/common/ipc';
|
||||
import { Client } from 'vs/base/parts/ipc/node/ipc.cp';
|
||||
import { IDiskFileChange, ILogMessage } from 'vs/platform/files/node/watcher/watcher';
|
||||
import { WatcherChannelClient } from 'vs/platform/files/node/watcher/nsfw/watcherIpc';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IWatcherRequest } from 'vs/platform/files/node/watcher/nsfw/watcher';
|
||||
import { getPathFromAmdModule } from 'vs/base/common/amd';
|
||||
|
||||
export class FileWatcher extends Disposable {
|
||||
private static readonly MAX_RESTARTS = 5;
|
||||
|
||||
private service: WatcherChannelClient;
|
||||
private isDisposed: boolean;
|
||||
private restartCounter: number;
|
||||
|
||||
constructor(
|
||||
private folders: IWatcherRequest[],
|
||||
private onFileChanges: (changes: IDiskFileChange[]) => void,
|
||||
private onLogMessage: (msg: ILogMessage) => void,
|
||||
private verboseLogging: boolean,
|
||||
) {
|
||||
super();
|
||||
|
||||
this.isDisposed = false;
|
||||
this.restartCounter = 0;
|
||||
|
||||
this.startWatching();
|
||||
}
|
||||
|
||||
private startWatching(): void {
|
||||
const client = this._register(new Client(
|
||||
getPathFromAmdModule(require, 'bootstrap-fork'),
|
||||
{
|
||||
serverName: 'File Watcher (nsfw)',
|
||||
args: ['--type=watcherService'],
|
||||
env: {
|
||||
AMD_ENTRYPOINT: 'vs/platform/files/node/watcher/nsfw/watcherApp',
|
||||
PIPE_LOGGING: 'true',
|
||||
VERBOSE_LOGGING: 'true' // transmit console logs from server to client
|
||||
}
|
||||
}
|
||||
));
|
||||
|
||||
this._register(client.onDidProcessExit(() => {
|
||||
// our watcher app should never be completed because it keeps on watching. being in here indicates
|
||||
// that the watcher process died and we want to restart it here. we only do it a max number of times
|
||||
if (!this.isDisposed) {
|
||||
if (this.restartCounter <= FileWatcher.MAX_RESTARTS) {
|
||||
this.error('terminated unexpectedly and is restarted again...');
|
||||
this.restartCounter++;
|
||||
this.startWatching();
|
||||
} else {
|
||||
this.error('failed to start after retrying for some time, giving up. Please report this as a bug report!');
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
// Initialize watcher
|
||||
const channel = getNextTickChannel(client.getChannel('watcher'));
|
||||
this.service = new WatcherChannelClient(channel);
|
||||
|
||||
this.service.setVerboseLogging(this.verboseLogging);
|
||||
|
||||
const options = {};
|
||||
this._register(this.service.watch(options)(e => !this.isDisposed && this.onFileChanges(e)));
|
||||
|
||||
this._register(this.service.onLogMessage(m => this.onLogMessage(m)));
|
||||
|
||||
// Start watching
|
||||
this.setFolders(this.folders);
|
||||
}
|
||||
|
||||
setVerboseLogging(verboseLogging: boolean): void {
|
||||
this.verboseLogging = verboseLogging;
|
||||
if (!this.isDisposed) {
|
||||
this.service.setVerboseLogging(verboseLogging);
|
||||
}
|
||||
}
|
||||
|
||||
error(message: string) {
|
||||
this.onLogMessage({ type: 'error', message: `[File Watcher (nsfw)] ${message}` });
|
||||
}
|
||||
|
||||
setFolders(folders: IWatcherRequest[]): void {
|
||||
this.folders = folders;
|
||||
|
||||
this.service.setRoots(folders);
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this.isDisposed = true;
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,376 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as chokidar from 'vscode-chokidar';
|
||||
import * as fs from 'fs';
|
||||
import * as gracefulFs from 'graceful-fs';
|
||||
gracefulFs.gracefulify(fs);
|
||||
import * as extpath from 'vs/base/common/extpath';
|
||||
import * as glob from 'vs/base/common/glob';
|
||||
import { FileChangeType } from 'vs/platform/files/common/files';
|
||||
import { ThrottledDelayer } from 'vs/base/common/async';
|
||||
import { normalizeNFC } from 'vs/base/common/normalization';
|
||||
import { realcaseSync } from 'vs/base/node/extpath';
|
||||
import { isMacintosh, isLinux } from 'vs/base/common/platform';
|
||||
import { IDiskFileChange, normalizeFileChanges, ILogMessage } from 'vs/platform/files/node/watcher/watcher';
|
||||
import { IWatcherRequest, IWatcherService, IWatcherOptions } from 'vs/platform/files/node/watcher/unix/watcher';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
|
||||
interface IWatcher {
|
||||
requests: ExtendedWatcherRequest[];
|
||||
stop(): any;
|
||||
}
|
||||
|
||||
interface ExtendedWatcherRequest extends IWatcherRequest {
|
||||
parsedPattern?: glob.ParsedPattern;
|
||||
}
|
||||
|
||||
export class ChokidarWatcherService implements IWatcherService {
|
||||
|
||||
private static readonly FS_EVENT_DELAY = 50; // aggregate and only emit events when changes have stopped for this duration (in ms)
|
||||
private static readonly EVENT_SPAM_WARNING_THRESHOLD = 60 * 1000; // warn after certain time span of event spam
|
||||
|
||||
private _watchers: { [watchPath: string]: IWatcher };
|
||||
private _watcherCount: number;
|
||||
|
||||
private _pollingInterval?: number;
|
||||
private _usePolling?: boolean;
|
||||
private _verboseLogging: boolean;
|
||||
|
||||
private spamCheckStartTime: number;
|
||||
private spamWarningLogged: boolean;
|
||||
private enospcErrorLogged: boolean;
|
||||
|
||||
private _onWatchEvent = new Emitter<IDiskFileChange[]>();
|
||||
readonly onWatchEvent = this._onWatchEvent.event;
|
||||
|
||||
private _onLogMessage = new Emitter<ILogMessage>();
|
||||
readonly onLogMessage: Event<ILogMessage> = this._onLogMessage.event;
|
||||
|
||||
public watch(options: IWatcherOptions): Event<IDiskFileChange[]> {
|
||||
this._pollingInterval = options.pollingInterval;
|
||||
this._usePolling = options.usePolling;
|
||||
this._watchers = Object.create(null);
|
||||
this._watcherCount = 0;
|
||||
return this.onWatchEvent;
|
||||
}
|
||||
|
||||
public setVerboseLogging(enabled: boolean): Promise<void> {
|
||||
this._verboseLogging = enabled;
|
||||
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
public setRoots(requests: IWatcherRequest[]): Promise<void> {
|
||||
const watchers = Object.create(null);
|
||||
const newRequests: string[] = [];
|
||||
|
||||
const requestsByBasePath = normalizeRoots(requests);
|
||||
|
||||
// evaluate new & remaining watchers
|
||||
for (let basePath in requestsByBasePath) {
|
||||
let watcher = this._watchers[basePath];
|
||||
if (watcher && isEqualRequests(watcher.requests, requestsByBasePath[basePath])) {
|
||||
watchers[basePath] = watcher;
|
||||
delete this._watchers[basePath];
|
||||
} else {
|
||||
newRequests.push(basePath);
|
||||
}
|
||||
}
|
||||
// stop all old watchers
|
||||
for (let path in this._watchers) {
|
||||
this._watchers[path].stop();
|
||||
}
|
||||
// start all new watchers
|
||||
for (let basePath of newRequests) {
|
||||
let requests = requestsByBasePath[basePath];
|
||||
watchers[basePath] = this._watch(basePath, requests);
|
||||
}
|
||||
|
||||
this._watchers = watchers;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
// for test purposes
|
||||
public get wacherCount() {
|
||||
return this._watcherCount;
|
||||
}
|
||||
|
||||
private _watch(basePath: string, requests: IWatcherRequest[]): IWatcher {
|
||||
if (this._verboseLogging) {
|
||||
this.log(`Start watching: ${basePath}]`);
|
||||
}
|
||||
|
||||
const pollingInterval = this._pollingInterval || 5000;
|
||||
const usePolling = this._usePolling;
|
||||
if (usePolling && this._verboseLogging) {
|
||||
this.log(`Use polling instead of fs.watch: Polling interval ${pollingInterval} ms`);
|
||||
}
|
||||
|
||||
const watcherOpts: chokidar.WatchOptions = {
|
||||
ignoreInitial: true,
|
||||
ignorePermissionErrors: true,
|
||||
followSymlinks: true, // this is the default of chokidar and supports file events through symlinks
|
||||
interval: pollingInterval, // while not used in normal cases, if any error causes chokidar to fallback to polling, increase its intervals
|
||||
binaryInterval: pollingInterval,
|
||||
usePolling: usePolling,
|
||||
disableGlobbing: true // fix https://github.com/Microsoft/vscode/issues/4586
|
||||
};
|
||||
|
||||
const excludes: string[] = [];
|
||||
// if there's only one request, use the built-in ignore-filterering
|
||||
const isSingleFolder = requests.length === 1;
|
||||
if (isSingleFolder) {
|
||||
excludes.push(...requests[0].excludes);
|
||||
}
|
||||
|
||||
if ((isMacintosh || isLinux) && (basePath.length === 0 || basePath === '/')) {
|
||||
excludes.push('/dev/**');
|
||||
if (isLinux) {
|
||||
excludes.push('/proc/**', '/sys/**');
|
||||
}
|
||||
}
|
||||
watcherOpts.ignored = excludes;
|
||||
|
||||
// Chokidar fails when the basePath does not match case-identical to the path on disk
|
||||
// so we have to find the real casing of the path and do some path massaging to fix this
|
||||
// see https://github.com/paulmillr/chokidar/issues/418
|
||||
const realBasePath = isMacintosh ? (realcaseSync(basePath) || basePath) : basePath;
|
||||
const realBasePathLength = realBasePath.length;
|
||||
const realBasePathDiffers = (basePath !== realBasePath);
|
||||
|
||||
if (realBasePathDiffers) {
|
||||
this.warn(`Watcher basePath does not match version on disk and was corrected (original: ${basePath}, real: ${realBasePath})`);
|
||||
}
|
||||
|
||||
let chokidarWatcher: chokidar.FSWatcher | null = chokidar.watch(realBasePath, watcherOpts);
|
||||
this._watcherCount++;
|
||||
|
||||
// Detect if for some reason the native watcher library fails to load
|
||||
if (isMacintosh && chokidarWatcher.options && !chokidarWatcher.options.useFsEvents) {
|
||||
this.warn('Watcher is not using native fsevents library and is falling back to unefficient polling.');
|
||||
}
|
||||
|
||||
let undeliveredFileEvents: IDiskFileChange[] = [];
|
||||
let fileEventDelayer: ThrottledDelayer<undefined> | null = new ThrottledDelayer(ChokidarWatcherService.FS_EVENT_DELAY);
|
||||
|
||||
const watcher: IWatcher = {
|
||||
requests,
|
||||
stop: () => {
|
||||
try {
|
||||
if (this._verboseLogging) {
|
||||
this.log(`Stop watching: ${basePath}]`);
|
||||
}
|
||||
if (chokidarWatcher) {
|
||||
chokidarWatcher.close();
|
||||
this._watcherCount--;
|
||||
chokidarWatcher = null;
|
||||
}
|
||||
if (fileEventDelayer) {
|
||||
fileEventDelayer.cancel();
|
||||
fileEventDelayer = null;
|
||||
}
|
||||
} catch (error) {
|
||||
this.warn('Error while stopping watcher: ' + error.toString());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
chokidarWatcher.on('all', (type: string, path: string) => {
|
||||
if (isMacintosh) {
|
||||
// Mac: uses NFD unicode form on disk, but we want NFC
|
||||
// See also https://github.com/nodejs/node/issues/2165
|
||||
path = normalizeNFC(path);
|
||||
}
|
||||
|
||||
if (path.indexOf(realBasePath) < 0) {
|
||||
return; // we really only care about absolute paths here in our basepath context here
|
||||
}
|
||||
|
||||
// Make sure to convert the path back to its original basePath form if the realpath is different
|
||||
if (realBasePathDiffers) {
|
||||
path = basePath + path.substr(realBasePathLength);
|
||||
}
|
||||
|
||||
let eventType: FileChangeType;
|
||||
switch (type) {
|
||||
case 'change':
|
||||
eventType = FileChangeType.UPDATED;
|
||||
break;
|
||||
case 'add':
|
||||
case 'addDir':
|
||||
eventType = FileChangeType.ADDED;
|
||||
break;
|
||||
case 'unlink':
|
||||
case 'unlinkDir':
|
||||
eventType = FileChangeType.DELETED;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
// if there's more than one request we need to do
|
||||
// extra filtering due to potentially overlapping roots
|
||||
if (!isSingleFolder) {
|
||||
if (isIgnored(path, watcher.requests)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let event = { type: eventType, path };
|
||||
|
||||
// Logging
|
||||
if (this._verboseLogging) {
|
||||
this.log(`${eventType === FileChangeType.ADDED ? '[ADDED]' : eventType === FileChangeType.DELETED ? '[DELETED]' : '[CHANGED]'} ${path}`);
|
||||
}
|
||||
|
||||
// Check for spam
|
||||
const now = Date.now();
|
||||
if (undeliveredFileEvents.length === 0) {
|
||||
this.spamWarningLogged = false;
|
||||
this.spamCheckStartTime = now;
|
||||
} else if (!this.spamWarningLogged && this.spamCheckStartTime + ChokidarWatcherService.EVENT_SPAM_WARNING_THRESHOLD < now) {
|
||||
this.spamWarningLogged = true;
|
||||
this.warn(`Watcher is busy catching up with ${undeliveredFileEvents.length} file changes in 60 seconds. Latest changed path is "${event.path}"`);
|
||||
}
|
||||
|
||||
// Add to buffer
|
||||
undeliveredFileEvents.push(event);
|
||||
|
||||
if (fileEventDelayer) {
|
||||
// Delay and send buffer
|
||||
fileEventDelayer.trigger(() => {
|
||||
const events = undeliveredFileEvents;
|
||||
undeliveredFileEvents = [];
|
||||
|
||||
// Broadcast to clients normalized
|
||||
const res = normalizeFileChanges(events);
|
||||
this._onWatchEvent.fire(res);
|
||||
|
||||
// Logging
|
||||
if (this._verboseLogging) {
|
||||
res.forEach(r => {
|
||||
this.log(` >> normalized ${r.type === FileChangeType.ADDED ? '[ADDED]' : r.type === FileChangeType.DELETED ? '[DELETED]' : '[CHANGED]'} ${r.path}`);
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.resolve(undefined);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
chokidarWatcher.on('error', (error: NodeJS.ErrnoException) => {
|
||||
if (error) {
|
||||
|
||||
// Specially handle ENOSPC errors that can happen when
|
||||
// the watcher consumes so many file descriptors that
|
||||
// we are running into a limit. We only want to warn
|
||||
// once in this case to avoid log spam.
|
||||
// See https://github.com/Microsoft/vscode/issues/7950
|
||||
if (error.code === 'ENOSPC') {
|
||||
if (!this.enospcErrorLogged) {
|
||||
this.enospcErrorLogged = true;
|
||||
this.stop();
|
||||
this.error('Inotify limit reached (ENOSPC)');
|
||||
}
|
||||
} else {
|
||||
this.warn(error.toString());
|
||||
}
|
||||
}
|
||||
});
|
||||
return watcher;
|
||||
}
|
||||
|
||||
public stop(): Promise<void> {
|
||||
for (let path in this._watchers) {
|
||||
let watcher = this._watchers[path];
|
||||
watcher.stop();
|
||||
}
|
||||
this._watchers = Object.create(null);
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
private log(message: string) {
|
||||
this._onLogMessage.fire({ type: 'trace', message: `[File Watcher (chokidar)] ` + message });
|
||||
}
|
||||
|
||||
private warn(message: string) {
|
||||
this._onLogMessage.fire({ type: 'warn', message: `[File Watcher (chokidar)] ` + message });
|
||||
}
|
||||
|
||||
private error(message: string) {
|
||||
this._onLogMessage.fire({ type: 'error', message: `[File Watcher (chokidar)] ` + message });
|
||||
}
|
||||
}
|
||||
|
||||
function isIgnored(path: string, requests: ExtendedWatcherRequest[]): boolean {
|
||||
for (let request of requests) {
|
||||
if (request.path === path) {
|
||||
return false;
|
||||
}
|
||||
if (extpath.isEqualOrParent(path, request.path)) {
|
||||
if (!request.parsedPattern) {
|
||||
if (request.excludes && request.excludes.length > 0) {
|
||||
let pattern = `{${request.excludes.join(',')}}`;
|
||||
request.parsedPattern = glob.parse(pattern);
|
||||
} else {
|
||||
request.parsedPattern = () => false;
|
||||
}
|
||||
}
|
||||
const relPath = path.substr(request.path.length + 1);
|
||||
if (!request.parsedPattern(relPath)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes a set of root paths by grouping by the most parent root path.
|
||||
* equests with Sub paths are skipped if they have the same ignored set as the parent.
|
||||
*/
|
||||
export function normalizeRoots(requests: IWatcherRequest[]): { [basePath: string]: IWatcherRequest[] } {
|
||||
requests = requests.sort((r1, r2) => r1.path.localeCompare(r2.path));
|
||||
let prevRequest: IWatcherRequest | null = null;
|
||||
let result: { [basePath: string]: IWatcherRequest[] } = Object.create(null);
|
||||
for (let request of requests) {
|
||||
let basePath = request.path;
|
||||
let ignored = (request.excludes || []).sort();
|
||||
if (prevRequest && (extpath.isEqualOrParent(basePath, prevRequest.path))) {
|
||||
if (!isEqualIgnore(ignored, prevRequest.excludes)) {
|
||||
result[prevRequest.path].push({ path: basePath, excludes: ignored });
|
||||
}
|
||||
} else {
|
||||
prevRequest = { path: basePath, excludes: ignored };
|
||||
result[basePath] = [prevRequest];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function isEqualRequests(r1: IWatcherRequest[], r2: IWatcherRequest[]) {
|
||||
if (r1.length !== r2.length) {
|
||||
return false;
|
||||
}
|
||||
for (let k = 0; k < r1.length; k++) {
|
||||
if (r1[k].path !== r2[k].path || !isEqualIgnore(r1[k].excludes, r2[k].excludes)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function isEqualIgnore(i1: string[], i2: string[]) {
|
||||
if (i1.length !== i2.length) {
|
||||
return false;
|
||||
}
|
||||
for (let k = 0; k < i1.length; k++) {
|
||||
if (i1[k] !== i2[k]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,322 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 * as os from 'os';
|
||||
import * as path from 'vs/base/common/path';
|
||||
import * as pfs from 'vs/base/node/pfs';
|
||||
import { normalizeRoots, ChokidarWatcherService } from '../chokidarWatcherService';
|
||||
import { IWatcherRequest } from '../watcher';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import { Delayer } from 'vs/base/common/async';
|
||||
import { IDiskFileChange } from 'vs/platform/files/node/watcher/watcher';
|
||||
import { FileChangeType } from 'vs/platform/files/common/files';
|
||||
|
||||
function newRequest(basePath: string, ignored: string[] = []): IWatcherRequest {
|
||||
return { path: basePath, excludes: ignored };
|
||||
}
|
||||
|
||||
function assertNormalizedRootPath(inputPaths: string[], expectedPaths: string[]) {
|
||||
const requests = inputPaths.map(path => newRequest(path));
|
||||
const actual = normalizeRoots(requests);
|
||||
assert.deepEqual(Object.keys(actual).sort(), expectedPaths);
|
||||
}
|
||||
|
||||
function assertNormalizedRequests(inputRequests: IWatcherRequest[], expectedRequests: { [path: string]: IWatcherRequest[] }) {
|
||||
const actual = normalizeRoots(inputRequests);
|
||||
const actualPath = Object.keys(actual).sort();
|
||||
const expectedPaths = Object.keys(expectedRequests).sort();
|
||||
assert.deepEqual(actualPath, expectedPaths);
|
||||
for (let path of actualPath) {
|
||||
let a = expectedRequests[path].sort((r1, r2) => r1.path.localeCompare(r2.path));
|
||||
let e = expectedRequests[path].sort((r1, r2) => r1.path.localeCompare(r2.path));
|
||||
assert.deepEqual(a, e);
|
||||
}
|
||||
}
|
||||
|
||||
function sort(changes: IDiskFileChange[]) {
|
||||
return changes.sort((c1, c2) => {
|
||||
return c1.path.localeCompare(c2.path);
|
||||
});
|
||||
}
|
||||
|
||||
function wait(time: number) {
|
||||
return new Delayer<void>(time).trigger(() => { });
|
||||
}
|
||||
|
||||
async function assertFileEvents(actuals: IDiskFileChange[], expected: IDiskFileChange[]) {
|
||||
let repeats = 40;
|
||||
while ((actuals.length < expected.length) && repeats-- > 0) {
|
||||
await wait(50);
|
||||
}
|
||||
assert.deepEqual(sort(actuals), sort(expected));
|
||||
actuals.length = 0;
|
||||
}
|
||||
|
||||
suite('Chokidar normalizeRoots', () => {
|
||||
test('should not impacts roots that don\'t overlap', () => {
|
||||
if (platform.isWindows) {
|
||||
assertNormalizedRootPath(['C:\\a'], ['C:\\a']);
|
||||
assertNormalizedRootPath(['C:\\a', 'C:\\b'], ['C:\\a', 'C:\\b']);
|
||||
assertNormalizedRootPath(['C:\\a', 'C:\\b', 'C:\\c\\d\\e'], ['C:\\a', 'C:\\b', 'C:\\c\\d\\e']);
|
||||
} else {
|
||||
assertNormalizedRootPath(['/a'], ['/a']);
|
||||
assertNormalizedRootPath(['/a', '/b'], ['/a', '/b']);
|
||||
assertNormalizedRootPath(['/a', '/b', '/c/d/e'], ['/a', '/b', '/c/d/e']);
|
||||
}
|
||||
});
|
||||
|
||||
test('should remove sub-folders of other roots', () => {
|
||||
if (platform.isWindows) {
|
||||
assertNormalizedRootPath(['C:\\a', 'C:\\a\\b'], ['C:\\a']);
|
||||
assertNormalizedRootPath(['C:\\a', 'C:\\b', 'C:\\a\\b'], ['C:\\a', 'C:\\b']);
|
||||
assertNormalizedRootPath(['C:\\b\\a', 'C:\\a', 'C:\\b', 'C:\\a\\b'], ['C:\\a', 'C:\\b']);
|
||||
assertNormalizedRootPath(['C:\\a', 'C:\\a\\b', 'C:\\a\\c\\d'], ['C:\\a']);
|
||||
} else {
|
||||
assertNormalizedRootPath(['/a', '/a/b'], ['/a']);
|
||||
assertNormalizedRootPath(['/a', '/b', '/a/b'], ['/a', '/b']);
|
||||
assertNormalizedRootPath(['/b/a', '/a', '/b', '/a/b'], ['/a', '/b']);
|
||||
assertNormalizedRootPath(['/a', '/a/b', '/a/c/d'], ['/a']);
|
||||
assertNormalizedRootPath(['/a/c/d/e', '/a/b/d', '/a/c/d', '/a/c/e/f', '/a/b'], ['/a/b', '/a/c/d', '/a/c/e/f']);
|
||||
}
|
||||
});
|
||||
|
||||
test('should remove duplicates', () => {
|
||||
if (platform.isWindows) {
|
||||
assertNormalizedRootPath(['C:\\a', 'C:\\a\\', 'C:\\a'], ['C:\\a']);
|
||||
} else {
|
||||
assertNormalizedRootPath(['/a', '/a/', '/a'], ['/a']);
|
||||
assertNormalizedRootPath(['/a', '/b', '/a/b'], ['/a', '/b']);
|
||||
assertNormalizedRootPath(['/b/a', '/a', '/b', '/a/b'], ['/a', '/b']);
|
||||
assertNormalizedRootPath(['/a', '/a/b', '/a/c/d'], ['/a']);
|
||||
}
|
||||
});
|
||||
|
||||
test('nested requests', () => {
|
||||
let p1, p2, p3;
|
||||
if (platform.isWindows) {
|
||||
p1 = 'C:\\a';
|
||||
p2 = 'C:\\a\\b';
|
||||
p3 = 'C:\\a\\b\\c';
|
||||
} else {
|
||||
p1 = '/a';
|
||||
p2 = '/a/b';
|
||||
p3 = '/a/b/c';
|
||||
}
|
||||
const r1 = newRequest(p1, ['**/*.ts']);
|
||||
const r2 = newRequest(p2, ['**/*.js']);
|
||||
const r3 = newRequest(p3, ['**/*.ts']);
|
||||
assertNormalizedRequests([r1, r2], { [p1]: [r1, r2] });
|
||||
assertNormalizedRequests([r2, r1], { [p1]: [r1, r2] });
|
||||
assertNormalizedRequests([r1, r2, r3], { [p1]: [r1, r2, r3] });
|
||||
assertNormalizedRequests([r1, r3], { [p1]: [r1] });
|
||||
assertNormalizedRequests([r2, r3], { [p2]: [r2, r3] });
|
||||
});
|
||||
});
|
||||
|
||||
suite.skip('Chokidar watching', () => {
|
||||
const tmpdir = os.tmpdir();
|
||||
const testDir = path.join(tmpdir, 'chokidartest-' + Date.now());
|
||||
const aFolder = path.join(testDir, 'a');
|
||||
const bFolder = path.join(testDir, 'b');
|
||||
const b2Folder = path.join(bFolder, 'b2');
|
||||
|
||||
const service = new ChokidarWatcherService();
|
||||
const result: IDiskFileChange[] = [];
|
||||
let error: string | null = null;
|
||||
|
||||
suiteSetup(async () => {
|
||||
await pfs.mkdirp(testDir);
|
||||
await pfs.mkdirp(aFolder);
|
||||
await pfs.mkdirp(bFolder);
|
||||
await pfs.mkdirp(b2Folder);
|
||||
|
||||
const opts = { verboseLogging: false, pollingInterval: 200 };
|
||||
service.watch(opts)(e => {
|
||||
if (Array.isArray(e)) {
|
||||
result.push(...e);
|
||||
}
|
||||
});
|
||||
service.onLogMessage(msg => {
|
||||
if (msg.type === 'error') {
|
||||
console.log('set error', msg.message);
|
||||
error = msg.message;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
suiteTeardown(async () => {
|
||||
await pfs.rimraf(testDir, pfs.RimRafMode.MOVE);
|
||||
await service.stop();
|
||||
});
|
||||
|
||||
setup(() => {
|
||||
result.length = 0;
|
||||
assert.equal(error, null);
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
assert.equal(error, null);
|
||||
});
|
||||
|
||||
test('simple file operations, single root, no ignore', async () => {
|
||||
let request: IWatcherRequest = { path: testDir, excludes: [] };
|
||||
service.setRoots([request]);
|
||||
await wait(300);
|
||||
|
||||
assert.equal(service.wacherCount, 1);
|
||||
|
||||
// create a file
|
||||
let testFilePath = path.join(testDir, 'file.txt');
|
||||
await pfs.writeFile(testFilePath, '');
|
||||
await assertFileEvents(result, [{ path: testFilePath, type: FileChangeType.ADDED }]);
|
||||
|
||||
// modify a file
|
||||
await pfs.writeFile(testFilePath, 'Hello');
|
||||
await assertFileEvents(result, [{ path: testFilePath, type: FileChangeType.UPDATED }]);
|
||||
|
||||
// create a folder
|
||||
let testFolderPath = path.join(testDir, 'newFolder');
|
||||
await pfs.mkdirp(testFolderPath);
|
||||
// copy a file
|
||||
let copiedFilePath = path.join(testFolderPath, 'file2.txt');
|
||||
await pfs.copy(testFilePath, copiedFilePath);
|
||||
await assertFileEvents(result, [{ path: copiedFilePath, type: FileChangeType.ADDED }, { path: testFolderPath, type: FileChangeType.ADDED }]);
|
||||
|
||||
// delete a file
|
||||
await pfs.rimraf(copiedFilePath, pfs.RimRafMode.MOVE);
|
||||
let renamedFilePath = path.join(testFolderPath, 'file3.txt');
|
||||
// move a file
|
||||
await pfs.rename(testFilePath, renamedFilePath);
|
||||
await assertFileEvents(result, [{ path: copiedFilePath, type: FileChangeType.DELETED }, { path: testFilePath, type: FileChangeType.DELETED }, { path: renamedFilePath, type: FileChangeType.ADDED }]);
|
||||
|
||||
// delete a folder
|
||||
await pfs.rimraf(testFolderPath, pfs.RimRafMode.MOVE);
|
||||
await assertFileEvents(result, [{ path: testFolderPath, type: FileChangeType.DELETED }, { path: renamedFilePath, type: FileChangeType.DELETED }]);
|
||||
});
|
||||
|
||||
test('simple file operations, ignore', async () => {
|
||||
let request: IWatcherRequest = { path: testDir, excludes: ['**/b/**', '**/*.js', '.git/**'] };
|
||||
service.setRoots([request]);
|
||||
await wait(300);
|
||||
|
||||
assert.equal(service.wacherCount, 1);
|
||||
|
||||
// create various ignored files
|
||||
let file1 = path.join(bFolder, 'file1.txt'); // hidden
|
||||
await pfs.writeFile(file1, 'Hello');
|
||||
let file2 = path.join(b2Folder, 'file2.txt'); // hidden
|
||||
await pfs.writeFile(file2, 'Hello');
|
||||
let folder1 = path.join(bFolder, 'folder1'); // hidden
|
||||
await pfs.mkdirp(folder1);
|
||||
let folder2 = path.join(aFolder, 'b'); // hidden
|
||||
await pfs.mkdirp(folder2);
|
||||
let folder3 = path.join(testDir, '.git'); // hidden
|
||||
await pfs.mkdirp(folder3);
|
||||
let folder4 = path.join(testDir, '.git1');
|
||||
await pfs.mkdirp(folder4);
|
||||
let folder5 = path.join(aFolder, '.git');
|
||||
await pfs.mkdirp(folder5);
|
||||
let file3 = path.join(aFolder, 'file3.js'); // hidden
|
||||
await pfs.writeFile(file3, 'var x;');
|
||||
let file4 = path.join(aFolder, 'file4.txt');
|
||||
await pfs.writeFile(file4, 'Hello');
|
||||
await assertFileEvents(result, [{ path: file4, type: FileChangeType.ADDED }, { path: folder4, type: FileChangeType.ADDED }, { path: folder5, type: FileChangeType.ADDED }]);
|
||||
|
||||
// move some files
|
||||
let movedFile1 = path.join(folder2, 'file1.txt'); // from ignored to ignored
|
||||
await pfs.rename(file1, movedFile1);
|
||||
let movedFile2 = path.join(aFolder, 'file2.txt'); // from ignored to visible
|
||||
await pfs.rename(file2, movedFile2);
|
||||
let movedFile3 = path.join(aFolder, 'file3.txt'); // from ignored file ext to visible
|
||||
await pfs.rename(file3, movedFile3);
|
||||
await assertFileEvents(result, [{ path: movedFile2, type: FileChangeType.ADDED }, { path: movedFile3, type: FileChangeType.ADDED }]);
|
||||
|
||||
// delete all files
|
||||
await pfs.rimraf(movedFile1); // hidden
|
||||
await pfs.rimraf(movedFile2, pfs.RimRafMode.MOVE);
|
||||
await pfs.rimraf(movedFile3, pfs.RimRafMode.MOVE);
|
||||
await pfs.rimraf(folder1); // hidden
|
||||
await pfs.rimraf(folder2); // hidden
|
||||
await pfs.rimraf(folder3); // hidden
|
||||
await pfs.rimraf(folder4, pfs.RimRafMode.MOVE);
|
||||
await pfs.rimraf(folder5, pfs.RimRafMode.MOVE);
|
||||
await pfs.rimraf(file4, pfs.RimRafMode.MOVE);
|
||||
await assertFileEvents(result, [{ path: movedFile2, type: FileChangeType.DELETED }, { path: movedFile3, type: FileChangeType.DELETED }, { path: file4, type: FileChangeType.DELETED }, { path: folder4, type: FileChangeType.DELETED }, { path: folder5, type: FileChangeType.DELETED }]);
|
||||
});
|
||||
|
||||
test('simple file operations, multiple roots', async () => {
|
||||
let request1: IWatcherRequest = { path: aFolder, excludes: ['**/*.js'] };
|
||||
let request2: IWatcherRequest = { path: b2Folder, excludes: ['**/*.ts'] };
|
||||
service.setRoots([request1, request2]);
|
||||
await wait(300);
|
||||
|
||||
assert.equal(service.wacherCount, 2);
|
||||
|
||||
// create some files
|
||||
let folderPath1 = path.join(aFolder, 'folder1');
|
||||
await pfs.mkdirp(folderPath1);
|
||||
let filePath1 = path.join(folderPath1, 'file1.json');
|
||||
await pfs.writeFile(filePath1, '');
|
||||
let filePath2 = path.join(folderPath1, 'file2.js'); // filtered
|
||||
await pfs.writeFile(filePath2, '');
|
||||
let folderPath2 = path.join(b2Folder, 'folder2');
|
||||
await pfs.mkdirp(folderPath2);
|
||||
let filePath3 = path.join(folderPath2, 'file3.ts'); // filtered
|
||||
await pfs.writeFile(filePath3, '');
|
||||
let filePath4 = path.join(testDir, 'file4.json'); // outside roots
|
||||
await pfs.writeFile(filePath4, '');
|
||||
|
||||
await assertFileEvents(result, [{ path: folderPath1, type: FileChangeType.ADDED }, { path: filePath1, type: FileChangeType.ADDED }, { path: folderPath2, type: FileChangeType.ADDED }]);
|
||||
|
||||
// change roots
|
||||
let request3: IWatcherRequest = { path: aFolder, excludes: ['**/*.json'] };
|
||||
service.setRoots([request3]);
|
||||
await wait(300);
|
||||
|
||||
assert.equal(service.wacherCount, 1);
|
||||
|
||||
// delete all
|
||||
await pfs.rimraf(folderPath1, pfs.RimRafMode.MOVE);
|
||||
await pfs.rimraf(folderPath2, pfs.RimRafMode.MOVE);
|
||||
await pfs.rimraf(filePath4, pfs.RimRafMode.MOVE);
|
||||
|
||||
await assertFileEvents(result, [{ path: folderPath1, type: FileChangeType.DELETED }, { path: filePath2, type: FileChangeType.DELETED }]);
|
||||
});
|
||||
|
||||
test('simple file operations, nested roots', async () => {
|
||||
let request1: IWatcherRequest = { path: testDir, excludes: ['**/b2/**'] };
|
||||
let request2: IWatcherRequest = { path: bFolder, excludes: ['**/b3/**'] };
|
||||
service.setRoots([request1, request2]);
|
||||
await wait(300);
|
||||
|
||||
assert.equal(service.wacherCount, 1);
|
||||
|
||||
// create files
|
||||
let filePath1 = path.join(bFolder, 'file1.xml'); // visible by both
|
||||
await pfs.writeFile(filePath1, '');
|
||||
let filePath2 = path.join(b2Folder, 'file2.xml'); // filtered by root1, but visible by root2
|
||||
await pfs.writeFile(filePath2, '');
|
||||
let folderPath1 = path.join(b2Folder, 'b3'); // filtered
|
||||
await pfs.mkdirp(folderPath1);
|
||||
let filePath3 = path.join(folderPath1, 'file3.xml'); // filtered
|
||||
await pfs.writeFile(filePath3, '');
|
||||
|
||||
await assertFileEvents(result, [{ path: filePath1, type: FileChangeType.ADDED }, { path: filePath2, type: FileChangeType.ADDED }]);
|
||||
|
||||
let renamedFilePath2 = path.join(folderPath1, 'file2.xml');
|
||||
// move a file
|
||||
await pfs.rename(filePath2, renamedFilePath2);
|
||||
await assertFileEvents(result, [{ path: filePath2, type: FileChangeType.DELETED }]);
|
||||
|
||||
// delete all
|
||||
await pfs.rimraf(folderPath1, pfs.RimRafMode.MOVE);
|
||||
await pfs.rimraf(filePath1, pfs.RimRafMode.MOVE);
|
||||
|
||||
await assertFileEvents(result, [{ path: filePath1, type: FileChangeType.DELETED }]);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
25
src/vs/platform/files/node/watcher/unix/watcher.ts
Normal file
25
src/vs/platform/files/node/watcher/unix/watcher.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { IDiskFileChange, ILogMessage } from 'vs/platform/files/node/watcher/watcher';
|
||||
|
||||
export interface IWatcherRequest {
|
||||
path: string;
|
||||
excludes: string[];
|
||||
}
|
||||
|
||||
export interface IWatcherOptions {
|
||||
pollingInterval?: number;
|
||||
usePolling?: boolean;
|
||||
}
|
||||
|
||||
export interface IWatcherService {
|
||||
watch(options: IWatcherOptions): Event<IDiskFileChange[]>;
|
||||
setRoots(roots: IWatcherRequest[]): Promise<void>;
|
||||
setVerboseLogging(enabled: boolean): Promise<void>;
|
||||
onLogMessage: Event<ILogMessage>;
|
||||
stop(): Promise<void>;
|
||||
}
|
||||
13
src/vs/platform/files/node/watcher/unix/watcherApp.ts
Normal file
13
src/vs/platform/files/node/watcher/unix/watcherApp.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Server } from 'vs/base/parts/ipc/node/ipc.cp';
|
||||
import { WatcherChannel } from 'vs/platform/files/node/watcher/unix/watcherIpc';
|
||||
import { ChokidarWatcherService } from 'vs/platform/files/node/watcher/unix/chokidarWatcherService';
|
||||
|
||||
const server = new Server('watcher');
|
||||
const service = new ChokidarWatcherService();
|
||||
const channel = new WatcherChannel(service);
|
||||
server.registerChannel('watcher', channel);
|
||||
58
src/vs/platform/files/node/watcher/unix/watcherIpc.ts
Normal file
58
src/vs/platform/files/node/watcher/unix/watcherIpc.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IChannel, IServerChannel } from 'vs/base/parts/ipc/common/ipc';
|
||||
import { IWatcherRequest, IWatcherService, IWatcherOptions } from './watcher';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { IDiskFileChange, ILogMessage } from 'vs/platform/files/node/watcher/watcher';
|
||||
|
||||
export class WatcherChannel implements IServerChannel {
|
||||
|
||||
constructor(private service: IWatcherService) { }
|
||||
|
||||
listen(_: unknown, event: string, arg?: any): Event<any> {
|
||||
switch (event) {
|
||||
case 'watch': return this.service.watch(arg);
|
||||
case 'onLogMessage': return this.service.onLogMessage;
|
||||
}
|
||||
|
||||
throw new Error(`Event not found: ${event}`);
|
||||
}
|
||||
|
||||
call(_: unknown, command: string, arg?: any): Promise<any> {
|
||||
switch (command) {
|
||||
case 'setRoots': return this.service.setRoots(arg);
|
||||
case 'setVerboseLogging': return this.service.setVerboseLogging(arg);
|
||||
case 'stop': return this.service.stop();
|
||||
}
|
||||
|
||||
throw new Error(`Call not found: ${command}`);
|
||||
}
|
||||
}
|
||||
|
||||
export class WatcherChannelClient implements IWatcherService {
|
||||
|
||||
constructor(private channel: IChannel) { }
|
||||
|
||||
watch(options: IWatcherOptions): Event<IDiskFileChange[]> {
|
||||
return this.channel.listen('watch', options);
|
||||
}
|
||||
|
||||
setVerboseLogging(enable: boolean): Promise<void> {
|
||||
return this.channel.call('setVerboseLogging', enable);
|
||||
}
|
||||
|
||||
get onLogMessage(): Event<ILogMessage> {
|
||||
return this.channel.listen('onLogMessage');
|
||||
}
|
||||
|
||||
setRoots(roots: IWatcherRequest[]): Promise<void> {
|
||||
return this.channel.call('setRoots', roots);
|
||||
}
|
||||
|
||||
stop(): Promise<void> {
|
||||
return this.channel.call('stop');
|
||||
}
|
||||
}
|
||||
98
src/vs/platform/files/node/watcher/unix/watcherService.ts
Normal file
98
src/vs/platform/files/node/watcher/unix/watcherService.ts
Normal file
@@ -0,0 +1,98 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { getNextTickChannel } from 'vs/base/parts/ipc/common/ipc';
|
||||
import { Client } from 'vs/base/parts/ipc/node/ipc.cp';
|
||||
import { IDiskFileChange, ILogMessage } from 'vs/platform/files/node/watcher/watcher';
|
||||
import { WatcherChannelClient } from 'vs/platform/files/node/watcher/unix/watcherIpc';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IWatcherRequest, IWatcherOptions } from 'vs/platform/files/node/watcher/unix/watcher';
|
||||
import { getPathFromAmdModule } from 'vs/base/common/amd';
|
||||
|
||||
export class FileWatcher extends Disposable {
|
||||
private static readonly MAX_RESTARTS = 5;
|
||||
|
||||
private isDisposed: boolean;
|
||||
private restartCounter: number;
|
||||
private service: WatcherChannelClient;
|
||||
|
||||
constructor(
|
||||
private folders: IWatcherRequest[],
|
||||
private onFileChanges: (changes: IDiskFileChange[]) => void,
|
||||
private onLogMessage: (msg: ILogMessage) => void,
|
||||
private verboseLogging: boolean,
|
||||
private watcherOptions: IWatcherOptions = {}
|
||||
) {
|
||||
super();
|
||||
|
||||
this.isDisposed = false;
|
||||
this.restartCounter = 0;
|
||||
|
||||
this.startWatching();
|
||||
}
|
||||
|
||||
private startWatching(): void {
|
||||
const client = this._register(new Client(
|
||||
getPathFromAmdModule(require, 'bootstrap-fork'),
|
||||
{
|
||||
serverName: 'File Watcher (chokidar)',
|
||||
args: ['--type=watcherService'],
|
||||
env: {
|
||||
AMD_ENTRYPOINT: 'vs/platform/files/node/watcher/unix/watcherApp',
|
||||
PIPE_LOGGING: 'true',
|
||||
VERBOSE_LOGGING: 'true' // transmit console logs from server to client
|
||||
}
|
||||
}
|
||||
));
|
||||
|
||||
this._register(client.onDidProcessExit(() => {
|
||||
// our watcher app should never be completed because it keeps on watching. being in here indicates
|
||||
// that the watcher process died and we want to restart it here. we only do it a max number of times
|
||||
if (!this.isDisposed) {
|
||||
if (this.restartCounter <= FileWatcher.MAX_RESTARTS) {
|
||||
this.error('terminated unexpectedly and is restarted again...');
|
||||
this.restartCounter++;
|
||||
this.startWatching();
|
||||
} else {
|
||||
this.error('failed to start after retrying for some time, giving up. Please report this as a bug report!');
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
// Initialize watcher
|
||||
const channel = getNextTickChannel(client.getChannel('watcher'));
|
||||
this.service = new WatcherChannelClient(channel);
|
||||
|
||||
this.service.setVerboseLogging(this.verboseLogging);
|
||||
|
||||
this._register(this.service.watch(this.watcherOptions)(e => !this.isDisposed && this.onFileChanges(e)));
|
||||
|
||||
this._register(this.service.onLogMessage(m => this.onLogMessage(m)));
|
||||
|
||||
// Start watching
|
||||
this.service.setRoots(this.folders);
|
||||
}
|
||||
|
||||
error(message: string) {
|
||||
this.onLogMessage({ type: 'error', message: `[File Watcher (chokidar)] ${message}` });
|
||||
}
|
||||
|
||||
setVerboseLogging(verboseLogging: boolean): void {
|
||||
this.verboseLogging = verboseLogging;
|
||||
this.service.setVerboseLogging(verboseLogging);
|
||||
}
|
||||
|
||||
setFolders(folders: IWatcherRequest[]): void {
|
||||
this.folders = folders;
|
||||
|
||||
this.service.setRoots(folders);
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this.isDisposed = true;
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
109
src/vs/platform/files/node/watcher/watcher.ts
Normal file
109
src/vs/platform/files/node/watcher/watcher.ts
Normal file
@@ -0,0 +1,109 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { URI as uri } from 'vs/base/common/uri';
|
||||
import { FileChangeType, isParent, IFileChange } from 'vs/platform/files/common/files';
|
||||
import { isLinux } from 'vs/base/common/platform';
|
||||
|
||||
export interface IDiskFileChange {
|
||||
type: FileChangeType;
|
||||
path: string;
|
||||
}
|
||||
|
||||
export interface ILogMessage {
|
||||
type: 'trace' | 'warn' | 'error';
|
||||
message: string;
|
||||
}
|
||||
|
||||
export function toFileChanges(changes: IDiskFileChange[]): IFileChange[] {
|
||||
return changes.map(change => ({
|
||||
type: change.type,
|
||||
resource: uri.file(change.path)
|
||||
}));
|
||||
}
|
||||
|
||||
export function normalizeFileChanges(changes: IDiskFileChange[]): IDiskFileChange[] {
|
||||
|
||||
// Build deltas
|
||||
const normalizer = new EventNormalizer();
|
||||
for (const event of changes) {
|
||||
normalizer.processEvent(event);
|
||||
}
|
||||
|
||||
return normalizer.normalize();
|
||||
}
|
||||
|
||||
class EventNormalizer {
|
||||
private normalized: IDiskFileChange[] = [];
|
||||
private mapPathToChange: Map<string, IDiskFileChange> = new Map();
|
||||
|
||||
processEvent(event: IDiskFileChange): void {
|
||||
const existingEvent = this.mapPathToChange.get(event.path);
|
||||
|
||||
// Event path already exists
|
||||
if (existingEvent) {
|
||||
const currentChangeType = existingEvent.type;
|
||||
const newChangeType = event.type;
|
||||
|
||||
// ignore CREATE followed by DELETE in one go
|
||||
if (currentChangeType === FileChangeType.ADDED && newChangeType === FileChangeType.DELETED) {
|
||||
this.mapPathToChange.delete(event.path);
|
||||
this.normalized.splice(this.normalized.indexOf(existingEvent), 1);
|
||||
}
|
||||
|
||||
// flatten DELETE followed by CREATE into CHANGE
|
||||
else if (currentChangeType === FileChangeType.DELETED && newChangeType === FileChangeType.ADDED) {
|
||||
existingEvent.type = FileChangeType.UPDATED;
|
||||
}
|
||||
|
||||
// Do nothing. Keep the created event
|
||||
else if (currentChangeType === FileChangeType.ADDED && newChangeType === FileChangeType.UPDATED) { }
|
||||
|
||||
// Otherwise apply change type
|
||||
else {
|
||||
existingEvent.type = newChangeType;
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise store new
|
||||
else {
|
||||
this.normalized.push(event);
|
||||
this.mapPathToChange.set(event.path, event);
|
||||
}
|
||||
}
|
||||
|
||||
normalize(): IDiskFileChange[] {
|
||||
const addedChangeEvents: IDiskFileChange[] = [];
|
||||
const deletedPaths: string[] = [];
|
||||
|
||||
// This algorithm will remove all DELETE events up to the root folder
|
||||
// that got deleted if any. This ensures that we are not producing
|
||||
// DELETE events for each file inside a folder that gets deleted.
|
||||
//
|
||||
// 1.) split ADD/CHANGE and DELETED events
|
||||
// 2.) sort short deleted paths to the top
|
||||
// 3.) for each DELETE, check if there is a deleted parent and ignore the event in that case
|
||||
return this.normalized.filter(e => {
|
||||
if (e.type !== FileChangeType.DELETED) {
|
||||
addedChangeEvents.push(e);
|
||||
|
||||
return false; // remove ADD / CHANGE
|
||||
}
|
||||
|
||||
return true; // keep DELETE
|
||||
}).sort((e1, e2) => {
|
||||
return e1.path.length - e2.path.length; // shortest path first
|
||||
}).filter(e => {
|
||||
if (deletedPaths.some(d => isParent(e.path, d, !isLinux /* ignorecase */))) {
|
||||
return false; // DELETE is ignored if parent is deleted already
|
||||
}
|
||||
|
||||
// otherwise mark as deleted
|
||||
deletedPaths.push(e.path);
|
||||
|
||||
return true;
|
||||
}).concat(addedChangeEvents);
|
||||
}
|
||||
}
|
||||
BIN
src/vs/platform/files/node/watcher/win32/CodeHelper.exe
Normal file
BIN
src/vs/platform/files/node/watcher/win32/CodeHelper.exe
Normal file
Binary file not shown.
8
src/vs/platform/files/node/watcher/win32/CodeHelper.md
Normal file
8
src/vs/platform/files/node/watcher/win32/CodeHelper.md
Normal file
@@ -0,0 +1,8 @@
|
||||
# Native File Watching for Windows using C# FileSystemWatcher
|
||||
|
||||
- Repository: https://github.com/Microsoft/vscode-filewatcher-windows
|
||||
|
||||
# Build
|
||||
|
||||
- Build in "Release" config
|
||||
- Copy CodeHelper.exe over into this folder
|
||||
140
src/vs/platform/files/node/watcher/win32/csharpWatcherService.ts
Normal file
140
src/vs/platform/files/node/watcher/win32/csharpWatcherService.ts
Normal file
@@ -0,0 +1,140 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as cp from 'child_process';
|
||||
import { FileChangeType } from 'vs/platform/files/common/files';
|
||||
import * as decoder from 'vs/base/node/decoder';
|
||||
import * as glob from 'vs/base/common/glob';
|
||||
import { IDiskFileChange, ILogMessage } from 'vs/platform/files/node/watcher/watcher';
|
||||
import { getPathFromAmdModule } from 'vs/base/common/amd';
|
||||
|
||||
export class OutOfProcessWin32FolderWatcher {
|
||||
|
||||
private static readonly MAX_RESTARTS = 5;
|
||||
|
||||
private static changeTypeMap: FileChangeType[] = [FileChangeType.UPDATED, FileChangeType.ADDED, FileChangeType.DELETED];
|
||||
|
||||
private ignored: glob.ParsedPattern[];
|
||||
|
||||
private handle: cp.ChildProcess;
|
||||
private restartCounter: number;
|
||||
|
||||
constructor(
|
||||
private watchedFolder: string,
|
||||
ignored: string[],
|
||||
private eventCallback: (events: IDiskFileChange[]) => void,
|
||||
private logCallback: (message: ILogMessage) => void,
|
||||
private verboseLogging: boolean
|
||||
) {
|
||||
this.restartCounter = 0;
|
||||
|
||||
if (Array.isArray(ignored)) {
|
||||
this.ignored = ignored.map(i => glob.parse(i));
|
||||
} else {
|
||||
this.ignored = [];
|
||||
}
|
||||
|
||||
// Logging
|
||||
if (this.verboseLogging) {
|
||||
this.log(`Start watching: ${watchedFolder}`);
|
||||
}
|
||||
|
||||
this.startWatcher();
|
||||
}
|
||||
|
||||
private startWatcher(): void {
|
||||
const args = [this.watchedFolder];
|
||||
if (this.verboseLogging) {
|
||||
args.push('-verbose');
|
||||
}
|
||||
|
||||
this.handle = cp.spawn(getPathFromAmdModule(require, 'vs/platform/files/node/watcher/win32/CodeHelper.exe'), args);
|
||||
|
||||
const stdoutLineDecoder = new decoder.LineDecoder();
|
||||
|
||||
// Events over stdout
|
||||
this.handle.stdout.on('data', (data: Buffer) => {
|
||||
|
||||
// Collect raw events from output
|
||||
const rawEvents: IDiskFileChange[] = [];
|
||||
stdoutLineDecoder.write(data).forEach((line) => {
|
||||
const eventParts = line.split('|');
|
||||
if (eventParts.length === 2) {
|
||||
const changeType = Number(eventParts[0]);
|
||||
const absolutePath = eventParts[1];
|
||||
|
||||
// File Change Event (0 Changed, 1 Created, 2 Deleted)
|
||||
if (changeType >= 0 && changeType < 3) {
|
||||
|
||||
// Support ignores
|
||||
if (this.ignored && this.ignored.some(ignore => ignore(absolutePath))) {
|
||||
if (this.verboseLogging) {
|
||||
this.log(absolutePath);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise record as event
|
||||
rawEvents.push({
|
||||
type: OutOfProcessWin32FolderWatcher.changeTypeMap[changeType],
|
||||
path: absolutePath
|
||||
});
|
||||
}
|
||||
|
||||
// 3 Logging
|
||||
else {
|
||||
this.log(eventParts[1]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Trigger processing of events through the delayer to batch them up properly
|
||||
if (rawEvents.length > 0) {
|
||||
this.eventCallback(rawEvents);
|
||||
}
|
||||
});
|
||||
|
||||
// Errors
|
||||
this.handle.on('error', (error: Error) => this.onError(error));
|
||||
this.handle.stderr.on('data', (data: Buffer) => this.onError(data));
|
||||
|
||||
// Exit
|
||||
this.handle.on('exit', (code: number, signal: string) => this.onExit(code, signal));
|
||||
}
|
||||
|
||||
private onError(error: Error | Buffer): void {
|
||||
this.error('process error: ' + error.toString());
|
||||
}
|
||||
|
||||
private onExit(code: number, signal: string): void {
|
||||
if (this.handle) { // exit while not yet being disposed is unexpected!
|
||||
this.error(`terminated unexpectedly (code: ${code}, signal: ${signal})`);
|
||||
|
||||
if (this.restartCounter <= OutOfProcessWin32FolderWatcher.MAX_RESTARTS) {
|
||||
this.error('is restarted again...');
|
||||
this.restartCounter++;
|
||||
this.startWatcher(); // restart
|
||||
} else {
|
||||
this.error('Watcher failed to start after retrying for some time, giving up. Please report this as a bug report!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private error(message: string) {
|
||||
this.logCallback({ type: 'error', message: `[File Watcher (C#)] ${message}` });
|
||||
}
|
||||
|
||||
private log(message: string) {
|
||||
this.logCallback({ type: 'trace', message: `[File Watcher (C#)] ${message}` });
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
if (this.handle) {
|
||||
this.handle.kill();
|
||||
this.handle = null!; // StrictNullOverride: nulling out ok in dispose
|
||||
}
|
||||
}
|
||||
}
|
||||
75
src/vs/platform/files/node/watcher/win32/watcherService.ts
Normal file
75
src/vs/platform/files/node/watcher/win32/watcherService.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IDiskFileChange, ILogMessage } from 'vs/platform/files/node/watcher/watcher';
|
||||
import { OutOfProcessWin32FolderWatcher } from 'vs/platform/files/node/watcher/win32/csharpWatcherService';
|
||||
import { posix } from 'vs/base/common/path';
|
||||
import { rtrim, endsWith } from 'vs/base/common/strings';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
|
||||
export class FileWatcher implements IDisposable {
|
||||
|
||||
private folder: { path: string, excludes: string[] };
|
||||
private service: OutOfProcessWin32FolderWatcher | undefined = undefined;
|
||||
|
||||
constructor(
|
||||
folders: { path: string, excludes: string[] }[],
|
||||
private onFileChanges: (changes: IDiskFileChange[]) => void,
|
||||
private onLogMessage: (msg: ILogMessage) => void,
|
||||
private verboseLogging: boolean
|
||||
) {
|
||||
this.folder = folders[0];
|
||||
|
||||
if (this.folder.path.indexOf('\\\\') === 0 && endsWith(this.folder.path, posix.sep)) {
|
||||
// for some weird reason, node adds a trailing slash to UNC paths
|
||||
// we never ever want trailing slashes as our base path unless
|
||||
// someone opens root ("/").
|
||||
// See also https://github.com/nodejs/io.js/issues/1765
|
||||
this.folder.path = rtrim(this.folder.path, posix.sep);
|
||||
}
|
||||
|
||||
this.service = this.startWatching();
|
||||
}
|
||||
|
||||
private get isDisposed(): boolean {
|
||||
return !this.service;
|
||||
}
|
||||
|
||||
private startWatching(): OutOfProcessWin32FolderWatcher {
|
||||
return new OutOfProcessWin32FolderWatcher(
|
||||
this.folder.path,
|
||||
this.folder.excludes,
|
||||
events => this.onFileEvents(events),
|
||||
message => this.onLogMessage(message),
|
||||
this.verboseLogging
|
||||
);
|
||||
}
|
||||
|
||||
setVerboseLogging(verboseLogging: boolean): void {
|
||||
this.verboseLogging = verboseLogging;
|
||||
if (this.service) {
|
||||
this.service.dispose();
|
||||
this.service = this.startWatching();
|
||||
}
|
||||
}
|
||||
|
||||
private onFileEvents(events: IDiskFileChange[]): void {
|
||||
if (this.isDisposed) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Emit through event emitter
|
||||
if (events.length > 0) {
|
||||
this.onFileChanges(events);
|
||||
}
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
if (this.service) {
|
||||
this.service.dispose();
|
||||
this.service = undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
112
src/vs/platform/files/test/browser/fileService.test.ts
Normal file
112
src/vs/platform/files/test/browser/fileService.test.ts
Normal file
@@ -0,0 +1,112 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 { FileService } from 'vs/platform/files/common/fileService';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IFileSystemProviderRegistrationEvent, FileSystemProviderCapabilities } from 'vs/platform/files/common/files';
|
||||
import { IDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { timeout } from 'vs/base/common/async';
|
||||
import { NullFileSystemProvider } from 'vs/platform/files/test/common/nullFileSystemProvider';
|
||||
|
||||
suite('File Service', () => {
|
||||
|
||||
test('provider registration', async () => {
|
||||
const service = new FileService(new NullLogService());
|
||||
const resource = URI.parse('test://foo/bar');
|
||||
|
||||
assert.equal(service.canHandleResource(resource), false);
|
||||
|
||||
const registrations: IFileSystemProviderRegistrationEvent[] = [];
|
||||
service.onDidChangeFileSystemProviderRegistrations(e => {
|
||||
registrations.push(e);
|
||||
});
|
||||
|
||||
let registrationDisposable: IDisposable | undefined = undefined;
|
||||
let callCount = 0;
|
||||
service.onWillActivateFileSystemProvider(e => {
|
||||
callCount++;
|
||||
|
||||
if (e.scheme === 'test' && callCount === 1) {
|
||||
e.join(new Promise(resolve => {
|
||||
registrationDisposable = service.registerProvider('test', new NullFileSystemProvider());
|
||||
|
||||
resolve();
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
||||
await service.activateProvider('test');
|
||||
|
||||
assert.equal(service.canHandleResource(resource), true);
|
||||
|
||||
assert.equal(registrations.length, 1);
|
||||
assert.equal(registrations[0].scheme, 'test');
|
||||
assert.equal(registrations[0].added, true);
|
||||
assert.ok(registrationDisposable);
|
||||
|
||||
await service.activateProvider('test');
|
||||
assert.equal(callCount, 2); // activation is called again
|
||||
|
||||
assert.equal(service.hasCapability(resource, FileSystemProviderCapabilities.Readonly), true);
|
||||
assert.equal(service.hasCapability(resource, FileSystemProviderCapabilities.FileOpenReadWriteClose), false);
|
||||
|
||||
registrationDisposable!.dispose();
|
||||
|
||||
assert.equal(service.canHandleResource(resource), false);
|
||||
|
||||
assert.equal(registrations.length, 2);
|
||||
assert.equal(registrations[1].scheme, 'test');
|
||||
assert.equal(registrations[1].added, false);
|
||||
});
|
||||
|
||||
test('watch', async () => {
|
||||
const service = new FileService(new NullLogService());
|
||||
|
||||
let disposeCounter = 0;
|
||||
service.registerProvider('test', new NullFileSystemProvider(() => {
|
||||
return toDisposable(() => {
|
||||
disposeCounter++;
|
||||
});
|
||||
}));
|
||||
await service.activateProvider('test');
|
||||
|
||||
const resource1 = URI.parse('test://foo/bar1');
|
||||
const watcher1Disposable = service.watch(resource1);
|
||||
|
||||
await timeout(0); // service.watch() is async
|
||||
assert.equal(disposeCounter, 0);
|
||||
watcher1Disposable.dispose();
|
||||
assert.equal(disposeCounter, 1);
|
||||
|
||||
disposeCounter = 0;
|
||||
const resource2 = URI.parse('test://foo/bar2');
|
||||
const watcher2Disposable1 = service.watch(resource2);
|
||||
const watcher2Disposable2 = service.watch(resource2);
|
||||
const watcher2Disposable3 = service.watch(resource2);
|
||||
|
||||
await timeout(0); // service.watch() is async
|
||||
assert.equal(disposeCounter, 0);
|
||||
watcher2Disposable1.dispose();
|
||||
assert.equal(disposeCounter, 0);
|
||||
watcher2Disposable2.dispose();
|
||||
assert.equal(disposeCounter, 0);
|
||||
watcher2Disposable3.dispose();
|
||||
assert.equal(disposeCounter, 1);
|
||||
|
||||
disposeCounter = 0;
|
||||
const resource3 = URI.parse('test://foo/bar3');
|
||||
const watcher3Disposable1 = service.watch(resource3);
|
||||
const watcher3Disposable2 = service.watch(resource3, { recursive: true, excludes: [] });
|
||||
|
||||
await timeout(0); // service.watch() is async
|
||||
assert.equal(disposeCounter, 0);
|
||||
watcher3Disposable1.dispose();
|
||||
assert.equal(disposeCounter, 1);
|
||||
watcher3Disposable2.dispose();
|
||||
assert.equal(disposeCounter, 2);
|
||||
});
|
||||
});
|
||||
33
src/vs/platform/files/test/common/nullFileSystemProvider.ts
Normal file
33
src/vs/platform/files/test/common/nullFileSystemProvider.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { FileSystemProviderCapabilities, IFileSystemProvider, IWatchOptions, IStat, FileType, FileDeleteOptions, FileOverwriteOptions, FileWriteOptions, FileOpenOptions, IFileChange } from 'vs/platform/files/common/files';
|
||||
import { IDisposable, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
|
||||
export class NullFileSystemProvider implements IFileSystemProvider {
|
||||
|
||||
capabilities: FileSystemProviderCapabilities = FileSystemProviderCapabilities.Readonly;
|
||||
|
||||
onDidChangeCapabilities: Event<void> = Event.None;
|
||||
onDidChangeFile: Event<IFileChange[]> = Event.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!); }
|
||||
delete(resource: URI, opts: FileDeleteOptions): Promise<void> { return Promise.resolve(undefined!); }
|
||||
rename(from: URI, to: URI, opts: FileOverwriteOptions): Promise<void> { return Promise.resolve(undefined!); }
|
||||
copy?(from: URI, to: URI, opts: FileOverwriteOptions): Promise<void> { return Promise.resolve(undefined!); }
|
||||
readFile?(resource: URI): Promise<Uint8Array> { return Promise.resolve(undefined!); }
|
||||
writeFile?(resource: URI, content: Uint8Array, opts: FileWriteOptions): Promise<void> { return Promise.resolve(undefined!); }
|
||||
open?(resource: URI, opts: FileOpenOptions): Promise<number> { return Promise.resolve(undefined!); }
|
||||
close?(fd: number): Promise<void> { return Promise.resolve(undefined!); }
|
||||
read?(fd: number, pos: number, data: Uint8Array, offset: number, length: number): Promise<number> { return Promise.resolve(undefined!); }
|
||||
write?(fd: number, pos: number, data: Uint8Array, offset: number, length: number): Promise<number> { return Promise.resolve(undefined!); }
|
||||
}
|
||||
1918
src/vs/platform/files/test/node/diskFileService.test.ts
Normal file
1918
src/vs/platform/files/test/node/diskFileService.test.ts
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
/// <reference path="employee.ts" />
|
||||
var Workforce;
|
||||
(function (Workforce_1) {
|
||||
var Company = (function () {
|
||||
function Company() {
|
||||
}
|
||||
return Company;
|
||||
})();
|
||||
(function (property, Workforce, IEmployee) {
|
||||
if (property === undefined) { property = employees; }
|
||||
if (IEmployee === undefined) { IEmployee = []; }
|
||||
property;
|
||||
calculateMonthlyExpenses();
|
||||
{
|
||||
var result = 0;
|
||||
for (var i = 0; i < employees.length; i++) {
|
||||
result += employees[i].calculatePay();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
});
|
||||
})(Workforce || (Workforce = {}));
|
||||
@@ -0,0 +1,117 @@
|
||||
'use strict';
|
||||
var Conway;
|
||||
(function (Conway) {
|
||||
var Cell = (function () {
|
||||
function Cell() {
|
||||
}
|
||||
return Cell;
|
||||
})();
|
||||
(function (property, number, property, number, property, boolean) {
|
||||
if (property === undefined) { property = row; }
|
||||
if (property === undefined) { property = col; }
|
||||
if (property === undefined) { property = live; }
|
||||
});
|
||||
var GameOfLife = (function () {
|
||||
function GameOfLife() {
|
||||
}
|
||||
return GameOfLife;
|
||||
})();
|
||||
(function () {
|
||||
property;
|
||||
gridSize = 50;
|
||||
property;
|
||||
canvasSize = 600;
|
||||
property;
|
||||
lineColor = '#cdcdcd';
|
||||
property;
|
||||
liveColor = '#666';
|
||||
property;
|
||||
deadColor = '#eee';
|
||||
property;
|
||||
initialLifeProbability = 0.5;
|
||||
property;
|
||||
animationRate = 60;
|
||||
property;
|
||||
cellSize = 0;
|
||||
property;
|
||||
context: ICanvasRenderingContext2D;
|
||||
property;
|
||||
world = createWorld();
|
||||
circleOfLife();
|
||||
function createWorld() {
|
||||
return travelWorld(function (cell) {
|
||||
cell.live = Math.random() < initialLifeProbability;
|
||||
return cell;
|
||||
});
|
||||
}
|
||||
function circleOfLife() {
|
||||
world = travelWorld(function (cell) {
|
||||
cell = world[cell.row][cell.col];
|
||||
draw(cell);
|
||||
return resolveNextGeneration(cell);
|
||||
});
|
||||
setTimeout(function () { circleOfLife(); }, animationRate);
|
||||
}
|
||||
function resolveNextGeneration(cell) {
|
||||
var count = countNeighbors(cell);
|
||||
var newCell = new Cell(cell.row, cell.col, cell.live);
|
||||
if (count < 2 || count > 3)
|
||||
newCell.live = false;
|
||||
else if (count == 3)
|
||||
newCell.live = true;
|
||||
return newCell;
|
||||
}
|
||||
function countNeighbors(cell) {
|
||||
var neighbors = 0;
|
||||
for (var row = -1; row <= 1; row++) {
|
||||
for (var col = -1; col <= 1; col++) {
|
||||
if (row == 0 && col == 0)
|
||||
continue;
|
||||
if (isAlive(cell.row + row, cell.col + col)) {
|
||||
neighbors++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return neighbors;
|
||||
}
|
||||
function isAlive(row, col) {
|
||||
// todo - need to guard with worl[row] exists?
|
||||
if (row < 0 || col < 0 || row >= gridSize || col >= gridSize)
|
||||
return false;
|
||||
return world[row][col].live;
|
||||
}
|
||||
function travelWorld(callback) {
|
||||
var result = [];
|
||||
for (var row = 0; row < gridSize; row++) {
|
||||
var rowData = [];
|
||||
for (var col = 0; col < gridSize; col++) {
|
||||
rowData.push(callback(new Cell(row, col, false)));
|
||||
}
|
||||
result.push(rowData);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function draw(cell) {
|
||||
if (context == null)
|
||||
context = createDrawingContext();
|
||||
if (cellSize == 0)
|
||||
cellSize = canvasSize / gridSize;
|
||||
context.strokeStyle = lineColor;
|
||||
context.strokeRect(cell.row * cellSize, cell.col * cellSize, cellSize, cellSize);
|
||||
context.fillStyle = cell.live ? liveColor : deadColor;
|
||||
context.fillRect(cell.row * cellSize, cell.col * cellSize, cellSize, cellSize);
|
||||
}
|
||||
function createDrawingContext() {
|
||||
var canvas = document.getElementById('conway-canvas');
|
||||
if (canvas == null) {
|
||||
canvas = document.createElement('canvas');
|
||||
canvas.id = "conway-canvas";
|
||||
canvas.width = canvasSize;
|
||||
canvas.height = canvasSize;
|
||||
document.body.appendChild(canvas);
|
||||
}
|
||||
return canvas.getContext('2d');
|
||||
}
|
||||
});
|
||||
})(Conway || (Conway = {}));
|
||||
var game = new Conway.GameOfLife();
|
||||
@@ -0,0 +1,38 @@
|
||||
'use strict';
|
||||
var Workforce;
|
||||
(function (Workforce) {
|
||||
var Employee = (function () {
|
||||
function Employee() {
|
||||
}
|
||||
return Employee;
|
||||
})();
|
||||
(property);
|
||||
name: string, property;
|
||||
basepay: number;
|
||||
implements;
|
||||
IEmployee;
|
||||
{
|
||||
name;
|
||||
basepay;
|
||||
}
|
||||
var SalesEmployee = (function () {
|
||||
function SalesEmployee() {
|
||||
}
|
||||
return SalesEmployee;
|
||||
})();
|
||||
();
|
||||
Employee(name, basepay);
|
||||
{
|
||||
function calculatePay() {
|
||||
var multiplier = (document.getElementById("mult")), as = any, value;
|
||||
return _super.calculatePay.call(this) * multiplier + bonus;
|
||||
}
|
||||
}
|
||||
var employee = new Employee('Bob', 1000);
|
||||
var salesEmployee = new SalesEmployee('Jim', 800, 400);
|
||||
salesEmployee.calclatePay(); // error: No member 'calclatePay' on SalesEmployee
|
||||
})(Workforce || (Workforce = {}));
|
||||
extern;
|
||||
var $;
|
||||
var s = Workforce.salesEmployee.calculatePay();
|
||||
$('#results').text(s);
|
||||
@@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
var M;
|
||||
(function (M) {
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
(function (x, property, number) {
|
||||
if (property === undefined) { property = w; }
|
||||
var local = 1;
|
||||
// unresolved symbol because x is local
|
||||
//self.x++;
|
||||
self.w--; // ok because w is a property
|
||||
property;
|
||||
f = function (y) {
|
||||
return y + x + local + w + self.w;
|
||||
};
|
||||
function sum(z) {
|
||||
return z + f(z) + w + self.w;
|
||||
}
|
||||
});
|
||||
})(M || (M = {}));
|
||||
var c = new M.C(12, 5);
|
||||
121
src/vs/platform/files/test/node/fixtures/resolver/index.html
Normal file
121
src/vs/platform/files/test/node/fixtures/resolver/index.html
Normal file
@@ -0,0 +1,121 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head id='headID'>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<title>Strada </title>
|
||||
<link href="site.css" rel="stylesheet" type="text/css" />
|
||||
<script src="jquery-1.4.1.js"></script>
|
||||
<script src="../compiler/dtree.js" type="text/javascript"></script>
|
||||
<script src="../compiler/typescript.js" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
// Compile strada source into resulting javascript
|
||||
function compile(prog, libText) {
|
||||
var outfile = {
|
||||
source: "",
|
||||
Write: function (s) { this.source += s; },
|
||||
WriteLine: function (s) { this.source += s + "\r"; },
|
||||
}
|
||||
|
||||
var parseErrors = []
|
||||
|
||||
var compiler=new Tools.TypeScriptCompiler(outfile,true);
|
||||
compiler.setErrorCallback(function(start,len, message) { parseErrors.push({start:start, len:len, message:message}); });
|
||||
compiler.addUnit(libText,"lib.ts");
|
||||
compiler.addUnit(prog,"input.ts");
|
||||
compiler.typeCheck();
|
||||
compiler.emit();
|
||||
|
||||
if(parseErrors.length > 0 ) {
|
||||
//throw new Error(parseErrors);
|
||||
}
|
||||
|
||||
while(outfile.source[0] == '/' && outfile.source[1] == '/' && outfile.source[2] == ' ') {
|
||||
outfile.source = outfile.source.slice(outfile.source.indexOf('\r')+1);
|
||||
}
|
||||
var errorPrefix = "";
|
||||
for(var i = 0;i<parseErrors.length;i++) {
|
||||
errorPrefix += "// Error: (" + parseErrors[i].start + "," + parseErrors[i].len + ") " + parseErrors[i].message + "\r";
|
||||
}
|
||||
|
||||
return errorPrefix + outfile.source;
|
||||
}
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
|
||||
var libText = "";
|
||||
$.get("../compiler/lib.ts", function(newLibText) {
|
||||
libText = newLibText;
|
||||
});
|
||||
|
||||
|
||||
// execute the javascript in the compiledOutput pane
|
||||
function execute() {
|
||||
$('#compilation').text("Running...");
|
||||
var txt = $('#compiledOutput').val();
|
||||
var res;
|
||||
try {
|
||||
var ret = eval(txt);
|
||||
res = "Ran successfully!";
|
||||
} catch(e) {
|
||||
res = "Exception thrown: " + e;
|
||||
}
|
||||
$('#compilation').text(String(res));
|
||||
}
|
||||
|
||||
// recompile the stradaSrc and populate the compiledOutput pane
|
||||
function srcUpdated() {
|
||||
var newText = $('#stradaSrc').val();
|
||||
var compiledSource;
|
||||
try {
|
||||
compiledSource = compile(newText, libText);
|
||||
} catch (e) {
|
||||
compiledSource = "//Parse error"
|
||||
for(var i in e)
|
||||
compiledSource += "\r// " + e[i];
|
||||
}
|
||||
$('#compiledOutput').val(compiledSource);
|
||||
}
|
||||
|
||||
// Populate the stradaSrc pane with one of the built in samples
|
||||
function exampleSelectionChanged() {
|
||||
var examples = document.getElementById('examples');
|
||||
var selectedExample = examples.options[examples.selectedIndex].value;
|
||||
if (selectedExample != "") {
|
||||
$.get('examples/' + selectedExample, function (srcText) {
|
||||
$('#stradaSrc').val(srcText);
|
||||
setTimeout(srcUpdated,100);
|
||||
}, function (err) {
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>TypeScript</h1>
|
||||
<br />
|
||||
<select id="examples" onchange='exampleSelectionChanged()'>
|
||||
<option value="">Select...</option>
|
||||
<option value="small.ts">Small</option>
|
||||
<option value="employee.ts">Employees</option>
|
||||
<option value="conway.ts">Conway Game of Life</option>
|
||||
<option value="typescript.ts">TypeScript Compiler</option>
|
||||
</select>
|
||||
|
||||
<div>
|
||||
<textarea id='stradaSrc' rows='40' cols='80' onchange='srcUpdated()' onkeyup='srcUpdated()' spellcheck="false">
|
||||
//Type your TypeScript here...
|
||||
</textarea>
|
||||
<textarea id='compiledOutput' rows='40' cols='80' spellcheck="false">
|
||||
//Compiled code will show up here...
|
||||
</textarea>
|
||||
<br />
|
||||
<button onclick='execute()'/>Run</button>
|
||||
<div id='compilation'>Press 'run' to execute code...</div>
|
||||
<div id='results'>...write your results into #results...</div>
|
||||
</div>
|
||||
<div id='bod' style='display:none'></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
/// <reference path="employee.ts" />
|
||||
var Workforce;
|
||||
(function (Workforce_1) {
|
||||
var Company = (function () {
|
||||
function Company() {
|
||||
}
|
||||
return Company;
|
||||
})();
|
||||
(function (property, Workforce, IEmployee) {
|
||||
if (property === undefined) { property = employees; }
|
||||
if (IEmployee === undefined) { IEmployee = []; }
|
||||
property;
|
||||
calculateMonthlyExpenses();
|
||||
{
|
||||
var result = 0;
|
||||
for (var i = 0; i < employees.length; i++) {
|
||||
result += employees[i].calculatePay();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
});
|
||||
})(Workforce || (Workforce = {}));
|
||||
@@ -0,0 +1,117 @@
|
||||
'use strict';
|
||||
var Conway;
|
||||
(function (Conway) {
|
||||
var Cell = (function () {
|
||||
function Cell() {
|
||||
}
|
||||
return Cell;
|
||||
})();
|
||||
(function (property, number, property, number, property, boolean) {
|
||||
if (property === undefined) { property = row; }
|
||||
if (property === undefined) { property = col; }
|
||||
if (property === undefined) { property = live; }
|
||||
});
|
||||
var GameOfLife = (function () {
|
||||
function GameOfLife() {
|
||||
}
|
||||
return GameOfLife;
|
||||
})();
|
||||
(function () {
|
||||
property;
|
||||
gridSize = 50;
|
||||
property;
|
||||
canvasSize = 600;
|
||||
property;
|
||||
lineColor = '#cdcdcd';
|
||||
property;
|
||||
liveColor = '#666';
|
||||
property;
|
||||
deadColor = '#eee';
|
||||
property;
|
||||
initialLifeProbability = 0.5;
|
||||
property;
|
||||
animationRate = 60;
|
||||
property;
|
||||
cellSize = 0;
|
||||
property;
|
||||
context: ICanvasRenderingContext2D;
|
||||
property;
|
||||
world = createWorld();
|
||||
circleOfLife();
|
||||
function createWorld() {
|
||||
return travelWorld(function (cell) {
|
||||
cell.live = Math.random() < initialLifeProbability;
|
||||
return cell;
|
||||
});
|
||||
}
|
||||
function circleOfLife() {
|
||||
world = travelWorld(function (cell) {
|
||||
cell = world[cell.row][cell.col];
|
||||
draw(cell);
|
||||
return resolveNextGeneration(cell);
|
||||
});
|
||||
setTimeout(function () { circleOfLife(); }, animationRate);
|
||||
}
|
||||
function resolveNextGeneration(cell) {
|
||||
var count = countNeighbors(cell);
|
||||
var newCell = new Cell(cell.row, cell.col, cell.live);
|
||||
if (count < 2 || count > 3)
|
||||
newCell.live = false;
|
||||
else if (count == 3)
|
||||
newCell.live = true;
|
||||
return newCell;
|
||||
}
|
||||
function countNeighbors(cell) {
|
||||
var neighbors = 0;
|
||||
for (var row = -1; row <= 1; row++) {
|
||||
for (var col = -1; col <= 1; col++) {
|
||||
if (row == 0 && col == 0)
|
||||
continue;
|
||||
if (isAlive(cell.row + row, cell.col + col)) {
|
||||
neighbors++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return neighbors;
|
||||
}
|
||||
function isAlive(row, col) {
|
||||
// todo - need to guard with worl[row] exists?
|
||||
if (row < 0 || col < 0 || row >= gridSize || col >= gridSize)
|
||||
return false;
|
||||
return world[row][col].live;
|
||||
}
|
||||
function travelWorld(callback) {
|
||||
var result = [];
|
||||
for (var row = 0; row < gridSize; row++) {
|
||||
var rowData = [];
|
||||
for (var col = 0; col < gridSize; col++) {
|
||||
rowData.push(callback(new Cell(row, col, false)));
|
||||
}
|
||||
result.push(rowData);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function draw(cell) {
|
||||
if (context == null)
|
||||
context = createDrawingContext();
|
||||
if (cellSize == 0)
|
||||
cellSize = canvasSize / gridSize;
|
||||
context.strokeStyle = lineColor;
|
||||
context.strokeRect(cell.row * cellSize, cell.col * cellSize, cellSize, cellSize);
|
||||
context.fillStyle = cell.live ? liveColor : deadColor;
|
||||
context.fillRect(cell.row * cellSize, cell.col * cellSize, cellSize, cellSize);
|
||||
}
|
||||
function createDrawingContext() {
|
||||
var canvas = document.getElementById('conway-canvas');
|
||||
if (canvas == null) {
|
||||
canvas = document.createElement('canvas');
|
||||
canvas.id = "conway-canvas";
|
||||
canvas.width = canvasSize;
|
||||
canvas.height = canvasSize;
|
||||
document.body.appendChild(canvas);
|
||||
}
|
||||
return canvas.getContext('2d');
|
||||
}
|
||||
});
|
||||
})(Conway || (Conway = {}));
|
||||
var game = new Conway.GameOfLife();
|
||||
@@ -0,0 +1,38 @@
|
||||
'use strict';
|
||||
var Workforce;
|
||||
(function (Workforce) {
|
||||
var Employee = (function () {
|
||||
function Employee() {
|
||||
}
|
||||
return Employee;
|
||||
})();
|
||||
(property);
|
||||
name: string, property;
|
||||
basepay: number;
|
||||
implements;
|
||||
IEmployee;
|
||||
{
|
||||
name;
|
||||
basepay;
|
||||
}
|
||||
var SalesEmployee = (function () {
|
||||
function SalesEmployee() {
|
||||
}
|
||||
return SalesEmployee;
|
||||
})();
|
||||
();
|
||||
Employee(name, basepay);
|
||||
{
|
||||
function calculatePay() {
|
||||
var multiplier = (document.getElementById("mult")), as = any, value;
|
||||
return _super.calculatePay.call(this) * multiplier + bonus;
|
||||
}
|
||||
}
|
||||
var employee = new Employee('Bob', 1000);
|
||||
var salesEmployee = new SalesEmployee('Jim', 800, 400);
|
||||
salesEmployee.calclatePay(); // error: No member 'calclatePay' on SalesEmployee
|
||||
})(Workforce || (Workforce = {}));
|
||||
extern;
|
||||
var $;
|
||||
var s = Workforce.salesEmployee.calculatePay();
|
||||
$('#results').text(s);
|
||||
@@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
var M;
|
||||
(function (M) {
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
(function (x, property, number) {
|
||||
if (property === undefined) { property = w; }
|
||||
var local = 1;
|
||||
// unresolved symbol because x is local
|
||||
//self.x++;
|
||||
self.w--; // ok because w is a property
|
||||
property;
|
||||
f = function (y) {
|
||||
return y + x + local + w + self.w;
|
||||
};
|
||||
function sum(z) {
|
||||
return z + f(z) + w + self.w;
|
||||
}
|
||||
});
|
||||
})(M || (M = {}));
|
||||
var c = new M.C(12, 5);
|
||||
40
src/vs/platform/files/test/node/fixtures/resolver/site.css
Normal file
40
src/vs/platform/files/test/node/fixtures/resolver/site.css
Normal file
@@ -0,0 +1,40 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
/*----------------------------------------------------------
|
||||
The base color for this template is #5c87b2. If you'd like
|
||||
to use a different color start by replacing all instances of
|
||||
#5c87b2 with your new color.
|
||||
----------------------------------------------------------*/
|
||||
body
|
||||
{
|
||||
background-color: #5c87b2;
|
||||
font-size: .75em;
|
||||
font-family: Segoe UI, Verdana, Helvetica, Sans-Serif;
|
||||
margin: 8px;
|
||||
padding: 0;
|
||||
color: #696969;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6
|
||||
{
|
||||
color: #000;
|
||||
font-size: 40px;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
textarea
|
||||
{
|
||||
font-family: Consolas
|
||||
}
|
||||
|
||||
#results
|
||||
{
|
||||
margin-top: 2em;
|
||||
margin-left: 2em;
|
||||
color: black;
|
||||
font-size: medium;
|
||||
}
|
||||
|
||||
BIN
src/vs/platform/files/test/node/fixtures/service/binary.txt
Normal file
BIN
src/vs/platform/files/test/node/fixtures/service/binary.txt
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 274 B |
@@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
/// <reference path="employee.ts" />
|
||||
var Workforce;
|
||||
(function (Workforce_1) {
|
||||
var Company = (function () {
|
||||
function Company() {
|
||||
}
|
||||
return Company;
|
||||
})();
|
||||
(function (property, Workforce, IEmployee) {
|
||||
if (property === undefined) { property = employees; }
|
||||
if (IEmployee === undefined) { IEmployee = []; }
|
||||
property;
|
||||
calculateMonthlyExpenses();
|
||||
{
|
||||
var result = 0;
|
||||
for (var i = 0; i < employees.length; i++) {
|
||||
result += employees[i].calculatePay();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
});
|
||||
})(Workforce || (Workforce = {}));
|
||||
117
src/vs/platform/files/test/node/fixtures/service/deep/conway.js
Normal file
117
src/vs/platform/files/test/node/fixtures/service/deep/conway.js
Normal file
@@ -0,0 +1,117 @@
|
||||
'use strict';
|
||||
var Conway;
|
||||
(function (Conway) {
|
||||
var Cell = (function () {
|
||||
function Cell() {
|
||||
}
|
||||
return Cell;
|
||||
})();
|
||||
(function (property, number, property, number, property, boolean) {
|
||||
if (property === undefined) { property = row; }
|
||||
if (property === undefined) { property = col; }
|
||||
if (property === undefined) { property = live; }
|
||||
});
|
||||
var GameOfLife = (function () {
|
||||
function GameOfLife() {
|
||||
}
|
||||
return GameOfLife;
|
||||
})();
|
||||
(function () {
|
||||
property;
|
||||
gridSize = 50;
|
||||
property;
|
||||
canvasSize = 600;
|
||||
property;
|
||||
lineColor = '#cdcdcd';
|
||||
property;
|
||||
liveColor = '#666';
|
||||
property;
|
||||
deadColor = '#eee';
|
||||
property;
|
||||
initialLifeProbability = 0.5;
|
||||
property;
|
||||
animationRate = 60;
|
||||
property;
|
||||
cellSize = 0;
|
||||
property;
|
||||
context: ICanvasRenderingContext2D;
|
||||
property;
|
||||
world = createWorld();
|
||||
circleOfLife();
|
||||
function createWorld() {
|
||||
return travelWorld(function (cell) {
|
||||
cell.live = Math.random() < initialLifeProbability;
|
||||
return cell;
|
||||
});
|
||||
}
|
||||
function circleOfLife() {
|
||||
world = travelWorld(function (cell) {
|
||||
cell = world[cell.row][cell.col];
|
||||
draw(cell);
|
||||
return resolveNextGeneration(cell);
|
||||
});
|
||||
setTimeout(function () { circleOfLife(); }, animationRate);
|
||||
}
|
||||
function resolveNextGeneration(cell) {
|
||||
var count = countNeighbors(cell);
|
||||
var newCell = new Cell(cell.row, cell.col, cell.live);
|
||||
if (count < 2 || count > 3)
|
||||
newCell.live = false;
|
||||
else if (count == 3)
|
||||
newCell.live = true;
|
||||
return newCell;
|
||||
}
|
||||
function countNeighbors(cell) {
|
||||
var neighbors = 0;
|
||||
for (var row = -1; row <= 1; row++) {
|
||||
for (var col = -1; col <= 1; col++) {
|
||||
if (row == 0 && col == 0)
|
||||
continue;
|
||||
if (isAlive(cell.row + row, cell.col + col)) {
|
||||
neighbors++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return neighbors;
|
||||
}
|
||||
function isAlive(row, col) {
|
||||
// todo - need to guard with worl[row] exists?
|
||||
if (row < 0 || col < 0 || row >= gridSize || col >= gridSize)
|
||||
return false;
|
||||
return world[row][col].live;
|
||||
}
|
||||
function travelWorld(callback) {
|
||||
var result = [];
|
||||
for (var row = 0; row < gridSize; row++) {
|
||||
var rowData = [];
|
||||
for (var col = 0; col < gridSize; col++) {
|
||||
rowData.push(callback(new Cell(row, col, false)));
|
||||
}
|
||||
result.push(rowData);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function draw(cell) {
|
||||
if (context == null)
|
||||
context = createDrawingContext();
|
||||
if (cellSize == 0)
|
||||
cellSize = canvasSize / gridSize;
|
||||
context.strokeStyle = lineColor;
|
||||
context.strokeRect(cell.row * cellSize, cell.col * cellSize, cellSize, cellSize);
|
||||
context.fillStyle = cell.live ? liveColor : deadColor;
|
||||
context.fillRect(cell.row * cellSize, cell.col * cellSize, cellSize, cellSize);
|
||||
}
|
||||
function createDrawingContext() {
|
||||
var canvas = document.getElementById('conway-canvas');
|
||||
if (canvas == null) {
|
||||
canvas = document.createElement('canvas');
|
||||
canvas.id = "conway-canvas";
|
||||
canvas.width = canvasSize;
|
||||
canvas.height = canvasSize;
|
||||
document.body.appendChild(canvas);
|
||||
}
|
||||
return canvas.getContext('2d');
|
||||
}
|
||||
});
|
||||
})(Conway || (Conway = {}));
|
||||
var game = new Conway.GameOfLife();
|
||||
@@ -0,0 +1,38 @@
|
||||
'use strict';
|
||||
var Workforce;
|
||||
(function (Workforce) {
|
||||
var Employee = (function () {
|
||||
function Employee() {
|
||||
}
|
||||
return Employee;
|
||||
})();
|
||||
(property);
|
||||
name: string, property;
|
||||
basepay: number;
|
||||
implements;
|
||||
IEmployee;
|
||||
{
|
||||
name;
|
||||
basepay;
|
||||
}
|
||||
var SalesEmployee = (function () {
|
||||
function SalesEmployee() {
|
||||
}
|
||||
return SalesEmployee;
|
||||
})();
|
||||
();
|
||||
Employee(name, basepay);
|
||||
{
|
||||
function calculatePay() {
|
||||
var multiplier = (document.getElementById("mult")), as = any, value;
|
||||
return _super.calculatePay.call(this) * multiplier + bonus;
|
||||
}
|
||||
}
|
||||
var employee = new Employee('Bob', 1000);
|
||||
var salesEmployee = new SalesEmployee('Jim', 800, 400);
|
||||
salesEmployee.calclatePay(); // error: No member 'calclatePay' on SalesEmployee
|
||||
})(Workforce || (Workforce = {}));
|
||||
extern;
|
||||
var $;
|
||||
var s = Workforce.salesEmployee.calculatePay();
|
||||
$('#results').text(s);
|
||||
@@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
var M;
|
||||
(function (M) {
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
(function (x, property, number) {
|
||||
if (property === undefined) { property = w; }
|
||||
var local = 1;
|
||||
// unresolved symbol because x is local
|
||||
//self.x++;
|
||||
self.w--; // ok because w is a property
|
||||
property;
|
||||
f = function (y) {
|
||||
return y + x + local + w + self.w;
|
||||
};
|
||||
function sum(z) {
|
||||
return z + f(z) + w + self.w;
|
||||
}
|
||||
});
|
||||
})(M || (M = {}));
|
||||
var c = new M.C(12, 5);
|
||||
121
src/vs/platform/files/test/node/fixtures/service/index.html
Normal file
121
src/vs/platform/files/test/node/fixtures/service/index.html
Normal file
@@ -0,0 +1,121 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head id='headID'>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<title>Strada </title>
|
||||
<link href="site.css" rel="stylesheet" type="text/css" />
|
||||
<script src="jquery-1.4.1.js"></script>
|
||||
<script src="../compiler/dtree.js" type="text/javascript"></script>
|
||||
<script src="../compiler/typescript.js" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
// Compile strada source into resulting javascript
|
||||
function compile(prog, libText) {
|
||||
var outfile = {
|
||||
source: "",
|
||||
Write: function (s) { this.source += s; },
|
||||
WriteLine: function (s) { this.source += s + "\r"; },
|
||||
}
|
||||
|
||||
var parseErrors = []
|
||||
|
||||
var compiler=new Tools.TypeScriptCompiler(outfile,true);
|
||||
compiler.setErrorCallback(function(start,len, message) { parseErrors.push({start:start, len:len, message:message}); });
|
||||
compiler.addUnit(libText,"lib.ts");
|
||||
compiler.addUnit(prog,"input.ts");
|
||||
compiler.typeCheck();
|
||||
compiler.emit();
|
||||
|
||||
if(parseErrors.length > 0 ) {
|
||||
//throw new Error(parseErrors);
|
||||
}
|
||||
|
||||
while(outfile.source[0] == '/' && outfile.source[1] == '/' && outfile.source[2] == ' ') {
|
||||
outfile.source = outfile.source.slice(outfile.source.indexOf('\r')+1);
|
||||
}
|
||||
var errorPrefix = "";
|
||||
for(var i = 0;i<parseErrors.length;i++) {
|
||||
errorPrefix += "// Error: (" + parseErrors[i].start + "," + parseErrors[i].len + ") " + parseErrors[i].message + "\r";
|
||||
}
|
||||
|
||||
return errorPrefix + outfile.source;
|
||||
}
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
|
||||
var libText = "";
|
||||
$.get("../compiler/lib.ts", function(newLibText) {
|
||||
libText = newLibText;
|
||||
});
|
||||
|
||||
|
||||
// execute the javascript in the compiledOutput pane
|
||||
function execute() {
|
||||
$('#compilation').text("Running...");
|
||||
var txt = $('#compiledOutput').val();
|
||||
var res;
|
||||
try {
|
||||
var ret = eval(txt);
|
||||
res = "Ran successfully!";
|
||||
} catch(e) {
|
||||
res = "Exception thrown: " + e;
|
||||
}
|
||||
$('#compilation').text(String(res));
|
||||
}
|
||||
|
||||
// recompile the stradaSrc and populate the compiledOutput pane
|
||||
function srcUpdated() {
|
||||
var newText = $('#stradaSrc').val();
|
||||
var compiledSource;
|
||||
try {
|
||||
compiledSource = compile(newText, libText);
|
||||
} catch (e) {
|
||||
compiledSource = "//Parse error"
|
||||
for(var i in e)
|
||||
compiledSource += "\r// " + e[i];
|
||||
}
|
||||
$('#compiledOutput').val(compiledSource);
|
||||
}
|
||||
|
||||
// Populate the stradaSrc pane with one of the built in samples
|
||||
function exampleSelectionChanged() {
|
||||
var examples = document.getElementById('examples');
|
||||
var selectedExample = examples.options[examples.selectedIndex].value;
|
||||
if (selectedExample != "") {
|
||||
$.get('examples/' + selectedExample, function (srcText) {
|
||||
$('#stradaSrc').val(srcText);
|
||||
setTimeout(srcUpdated,100);
|
||||
}, function (err) {
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>TypeScript</h1>
|
||||
<br />
|
||||
<select id="examples" onchange='exampleSelectionChanged()'>
|
||||
<option value="">Select...</option>
|
||||
<option value="small.ts">Small</option>
|
||||
<option value="employee.ts">Employees</option>
|
||||
<option value="conway.ts">Conway Game of Life</option>
|
||||
<option value="typescript.ts">TypeScript Compiler</option>
|
||||
</select>
|
||||
|
||||
<div>
|
||||
<textarea id='stradaSrc' rows='40' cols='80' onchange='srcUpdated()' onkeyup='srcUpdated()' spellcheck="false">
|
||||
//Type your TypeScript here...
|
||||
</textarea>
|
||||
<textarea id='compiledOutput' rows='40' cols='80' spellcheck="false">
|
||||
//Compiled code will show up here...
|
||||
</textarea>
|
||||
<br />
|
||||
<button onclick='execute()'/>Run</button>
|
||||
<div id='compilation'>Press 'run' to execute code...</div>
|
||||
<div id='results'>...write your results into #results...</div>
|
||||
</div>
|
||||
<div id='bod' style='display:none'></div>
|
||||
</body>
|
||||
</html>
|
||||
283
src/vs/platform/files/test/node/fixtures/service/lorem.txt
Normal file
283
src/vs/platform/files/test/node/fixtures/service/lorem.txt
Normal file
@@ -0,0 +1,283 @@
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur vulputate, ipsum quis interdum fermentum, lorem sem fermentum eros, vitae auctor neque lacus in nisi. Suspendisse potenti. Maecenas et scelerisque elit, in tincidunt quam. Sed eu tincidunt quam. Nullam justo ex, imperdiet a imperdiet et, fermentum sit amet eros. Aenean quis tempus sem. Pellentesque accumsan magna mi, ut mollis velit sagittis id. Etiam quis ipsum orci. Fusce purus ante, accumsan a lobortis at, venenatis eu nisl. Praesent ornare sed ante placerat accumsan. Suspendisse tempus dignissim fermentum. Nunc a leo ac lacus sodales iaculis eu vitae mi. In feugiat ante at massa finibus cursus. Suspendisse posuere fringilla ornare. Mauris elementum ac quam id convallis. Vestibulum non elit quis urna volutpat aliquam a eu lacus.
|
||||
|
||||
Aliquam vestibulum imperdiet neque, suscipit aliquam elit ultrices bibendum. Suspendisse ultrices pulvinar cursus. Morbi risus nisi, cursus consequat rutrum vitae, molestie sed dui. Fusce posuere, augue quis dignissim aliquam, nisi ipsum porttitor ante, quis fringilla nisl turpis ac nisi. Nulla varius enim eget lorem vehicula gravida. Donec finibus malesuada leo nec semper. Proin ac enim eros. Vivamus non tincidunt nisi, vel tristique lorem.
|
||||
|
||||
Nunc consequat ex id eros dignissim, id rutrum risus laoreet. Sed euismod non erat eu ultricies. Etiam vehicula gravida lacus ut porta. Vestibulum eu eros quis nunc aliquet luctus. Cras quis semper ligula. Nullam gravida vehicula quam sed porta. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. In porta cursus vulputate. Quisque porta a nisi eget cursus. Aliquam risus leo, luctus ac magna in, efficitur cursus magna. In condimentum non mi id semper. Donec interdum ante eget commodo maximus.
|
||||
|
||||
Vivamus sit amet vestibulum lectus. Fusce tincidunt mi sapien, dictum sollicitudin diam vulputate in. Integer fringilla consequat mollis. Cras aliquet consequat felis eget feugiat. Nunc tempor cursus arcu, vitae ornare nunc varius et. Vestibulum et tortor vel ante viverra porttitor. Nam at tortor ullamcorper, facilisis augue quis, tristique erat. Aenean ut euismod nibh. Quisque eu tincidunt est, nec euismod eros.
|
||||
|
||||
Proin vehicula nibh non viverra egestas. Phasellus sem dolor, ultricies ac sagittis tristique, lacinia a purus. Vestibulum in ante eros. Pellentesque lacus nulla, tristique vitae interdum vel, malesuada ac diam. Aenean bibendum posuere turpis in accumsan. Ut est nulla, ullamcorper quis turpis at, viverra sagittis mauris. Sed in interdum purus. Praesent scelerisque nibh eget sem euismod, ut imperdiet mi venenatis. Vivamus pulvinar orci sed dapibus auctor. Nulla facilisi. Vestibulum tincidunt erat nec porttitor egestas. Mauris quis risus ante. Nulla facilisi.
|
||||
|
||||
Aliquam ullamcorper ornare lobortis. Phasellus quis sem et ipsum mollis malesuada sed in ex. Ut aliquam ex eget metus finibus maximus. Proin suscipit mauris eu nibh lacinia, quis feugiat dui dapibus. Nam sed libero est. Aenean vulputate orci sit amet diam faucibus, eu sagittis sapien volutpat. Nam imperdiet felis turpis, at pretium odio pulvinar in. Sed vestibulum id eros nec ultricies. Sed quis aliquam tortor, vitae ullamcorper tellus. Donec egestas laoreet eros, id suscipit est rutrum nec. Sed auctor nulla eget metus aliquam, ut condimentum enim elementum.
|
||||
|
||||
Aliquam suscipit non turpis sit amet bibendum. Fusce velit ligula, euismod et maximus at, luctus sed neque. Quisque pretium, nisl at ullamcorper finibus, lectus leo mattis sapien, vel euismod mauris diam ullamcorper ex. Nulla ut risus finibus, lacinia ligula at, auctor erat. Mauris consectetur sagittis ligula vel dapibus. Nullam libero libero, lobortis aliquam libero vel, venenatis ultricies leo. Duis porttitor, nibh congue fermentum posuere, erat libero pulvinar tortor, a pellentesque nunc ipsum vel sem. Nullam volutpat, eros sit amet facilisis consectetur, ipsum est vehicula massa, non vestibulum neque elit in mauris. Nunc hendrerit ipsum non enim bibendum, vitae rhoncus mi egestas. Etiam ullamcorper massa vel nisl sagittis, nec bibendum arcu malesuada. Aenean aliquet turpis justo, a consectetur arcu mollis convallis. Etiam tellus ipsum, ultricies vitae lorem et, ornare facilisis orci. Praesent fringilla justo urna, vel mollis neque pulvinar vestibulum.
|
||||
|
||||
Donec non iaculis erat. Aliquam et mi sed nunc pulvinar ultricies in ut ipsum. Interdum et malesuada fames ac ante ipsum primis in faucibus. Praesent feugiat lacus ac dignissim semper. Phasellus vitae quam nisi. Morbi vel diam ultricies risus lobortis ornare. Fusce maximus et ligula quis iaculis. Sed congue ex eget felis convallis, sit amet hendrerit elit tempor. Donec vehicula blandit ante eget commodo. Vestibulum eleifend diam at feugiat euismod. Etiam magna tellus, dignissim eget fermentum vel, vestibulum vitae mauris. Nam accumsan et erat id sagittis. Donec lacinia, odio ut ornare ultricies, dolor velit accumsan tortor, non finibus erat tellus quis ligula. Nunc quis metus in leo volutpat ornare vulputate eu nisl.
|
||||
|
||||
Donec quis viverra ex. Nullam id feugiat mauris, eu fringilla nulla. Vestibulum id maximus elit. Cras elementum elit sed felis lobortis, eget sagittis nisi hendrerit. Vivamus vitae elit neque. Donec vulputate lacus ut libero ultrices accumsan. Vivamus accumsan nulla orci, in dignissim est laoreet sagittis. Proin at commodo velit. Curabitur in velit felis. Aliquam erat volutpat. Sed consequat, nulla et cursus sodales, nisi lacus mattis risus, quis eleifend erat ex nec turpis. Sed suscipit ultrices lorem in hendrerit.
|
||||
|
||||
Morbi vitae lacus nec libero ornare tempus eu et diam. Suspendisse magna ipsum, fermentum vel odio quis, molestie aliquam urna. Fusce mollis turpis a eros accumsan porttitor. Pellentesque rhoncus dolor sit amet magna rutrum, et dapibus justo tempor. Sed purus nisi, maximus vitae fringilla eu, molestie nec urna. Fusce malesuada finibus pretium. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec sed aliquet eros. Pellentesque luctus diam ante, eget euismod nisl aliquet eu. Sed accumsan elit purus, tempor varius ligula tempus nec. Curabitur ornare leo suscipit suscipit fermentum. Morbi eget nulla est. Maecenas faucibus interdum tristique.
|
||||
|
||||
Etiam ut elit eros. Nulla pharetra suscipit molestie. Nulla facilisis bibendum nisl non molestie. Curabitur turpis lectus, facilisis vel diam non, vulputate ultrices mauris. Aenean placerat aliquam convallis. Suspendisse sed scelerisque tellus. Vivamus lacinia neque eget risus cursus suscipit. Proin consequat dolor vel neque tempor, eu aliquam sem scelerisque. Duis non eros a purus malesuada pharetra non et nulla. Suspendisse potenti. Mauris libero eros, finibus vel nulla id, sagittis dapibus ante. Proin iaculis sed nunc et cursus.
|
||||
|
||||
Quisque accumsan lorem sit amet lorem aliquet euismod. Curabitur fermentum rutrum posuere. Etiam ultricies, sem id pellentesque suscipit, urna magna lacinia eros, quis efficitur risus nisl at lacus. Nulla quis lacus tortor. Mauris placerat ex in dolor tincidunt, vel aliquet nisi pretium. Cras iaculis risus vitae pellentesque aliquet. Quisque a enim imperdiet, ullamcorper arcu vitae, rutrum risus. Nullam consectetur libero at felis fringilla, nec congue nibh dignissim. Nam et lobortis felis, eu pellentesque ligula. Aenean facilisis, ligula non imperdiet maximus, massa orci gravida sapien, at sagittis lacus nisl in lacus. Nulla quis mauris luctus, scelerisque felis consequat, tempus risus. Fusce auctor nisl non nulla luctus molestie. Maecenas sapien nisl, auctor non dolor et, iaculis scelerisque lorem. Suspendisse egestas enim aliquet, accumsan mauris nec, posuere quam. Nulla iaculis dui dui, sit amet vestibulum erat ultricies ac.
|
||||
|
||||
Cras eget dolor erat. Proin at nisl ut leo consectetur ultricies vel ut arcu. Nulla in felis malesuada, ullamcorper tortor et, convallis massa. Nunc urna justo, ornare in nibh vitae, hendrerit condimentum libero. Etiam vitae libero in purus venenatis fringilla. Nullam velit nulla, consequat ut turpis non, egestas hendrerit nibh. Duis tortor turpis, interdum non ante ac, cursus accumsan lectus. Cras pharetra bibendum augue quis dictum. Sed euismod vestibulum justo. Proin porta lobortis purus. Duis venenatis diam tortor, sit amet condimentum eros rhoncus a. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nunc at magna nec diam lobortis efficitur sit amet ut lacus. Nulla quis orci tortor. Pellentesque tempus velit a odio finibus porta.
|
||||
|
||||
Proin feugiat mauris a tellus scelerisque convallis. Maecenas libero magna, blandit nec ultrices id, congue vel mi. Aliquam lacinia, quam vel condimentum convallis, tortor turpis aliquam odio, sed blandit libero lacus et eros. In eleifend iaculis magna ac finibus. Praesent auctor facilisis tellus in congue. Sed molestie lobortis dictum. Nam quis dignissim augue, vel euismod lorem. Curabitur posuere dapibus luctus. Donec ultricies dictum lectus, quis blandit arcu commodo ac. Aenean tincidunt ligula in nunc imperdiet dignissim. Curabitur egestas sollicitudin sapien ut semper. Aenean nec dignissim lacus.
|
||||
|
||||
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Donec aliquam dictum vehicula. Donec tortor est, volutpat non nisi nec, varius gravida ex. Nunc vel tristique nunc, vitae mattis nisi. Nunc nec luctus ex, vitae tincidunt lectus. In hac habitasse platea dictumst. Curabitur lobortis ex eget tincidunt tempor. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut a vehicula mi.
|
||||
|
||||
Fusce eu libero finibus, interdum nulla a, placerat neque. Cras bibendum tempor libero nec feugiat. Cras ut sodales eros. Proin viverra, massa sit amet viverra egestas, neque nisl porta ex, sit amet hendrerit libero ligula vel urna. Mauris suscipit lacus id justo rhoncus suscipit. Etiam vel libero tellus. Maecenas non diam molestie, condimentum tellus a, bibendum enim. Mauris aliquet imperdiet tellus, eget sagittis dolor. Sed blandit in neque et luctus. Cras elementum sagittis nunc, vel mollis lorem euismod et. Donec posuere at lacus eget suscipit.
|
||||
|
||||
Nulla nunc mi, pretium non massa vel, tempor semper magna. Nunc a leo pulvinar, tincidunt nunc at, dignissim mi. Aliquam erat volutpat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut viverra nulla a nisl finibus, at hendrerit ligula ullamcorper. Donec a lorem semper, tempor magna et, lobortis libero. Mauris id sapien leo. Donec dignissim, quam vitae porttitor dignissim, quam justo mattis dui, vel consequat odio elit quis orci. Etiam nec pretium neque, sit amet pretium orci. Duis ac tortor venenatis, feugiat purus non, feugiat nunc. Proin scelerisque nisl in turpis aliquam vulputate.
|
||||
|
||||
Praesent sed est semper, fringilla lorem vitae, tincidunt nibh. Cras eros metus, auctor at mauris sit amet, sodales semper orci. Nunc a ornare ex. Curabitur bibendum arcu congue urna vulputate egestas. Vestibulum finibus id risus et accumsan. Aenean ut volutpat tellus. Aenean tincidunt malesuada urna sit amet vestibulum. Mauris vel tellus dictum, varius lacus quis, dictum arcu.
|
||||
|
||||
Aenean quis metus eu erat feugiat cursus vel at ligula. Proin dapibus sodales urna, id euismod lectus tempus id. Pellentesque ex ligula, convallis et erat vel, vulputate condimentum nisl. Pellentesque pharetra nulla quis massa eleifend hendrerit. Praesent sed massa ipsum. Maecenas vehicula dolor massa, id sodales urna faucibus et. Mauris ac quam non massa tincidunt feugiat et at lacus. Fusce libero massa, vulputate vel scelerisque non, mollis in leo. Ut sit amet ultricies odio. Suspendisse in sapien viverra, facilisis purus ut, pretium libero.
|
||||
|
||||
Vivamus tristique pharetra molestie. Nam a volutpat purus. Praesent consequat gravida nisi, ac blandit nisi suscipit ut. Quisque posuere, ligula a ultrices laoreet, ligula nunc vulputate libero, ut rutrum erat odio tincidunt justo. Sed vitae leo at leo fringilla bibendum. Vestibulum ut augue nec dolor auctor accumsan. Praesent laoreet id eros pulvinar commodo. Suspendisse potenti. Ut pharetra, mauris vitae blandit fringilla, odio ante tincidunt lorem, sit amet tempor metus diam ut turpis.
|
||||
|
||||
Praesent quis egestas arcu. Nullam at porta arcu. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Morbi vulputate ligula malesuada ligula luctus, vulputate tempus erat bibendum. Nunc ullamcorper non lectus at euismod. Etiam nibh felis, tincidunt a metus vel, pellentesque rhoncus neque. Etiam at diam in erat luctus interdum. Nunc vel ipsum pulvinar, sollicitudin lacus ac, tempus urna. Etiam vel lacinia sapien. Pellentesque sagittis velit vel mi efficitur iaculis. Integer euismod sit amet urna in sagittis. Cras eleifend ut nibh in facilisis. Donec et lacus vitae nunc placerat sodales. Nulla sed hendrerit ligula, at dapibus sapien.
|
||||
|
||||
Praesent at iaculis ex. Curabitur est purus, cursus a faucibus quis, dictum id velit. Donec dignissim fringilla viverra. Nunc mauris felis, laoreet sit amet sagittis at, vestibulum in libero. Maecenas quis orci turpis. Quisque ut nibh vitae magna mollis consequat id at mauris. Aliquam eu odio eget nulla bibendum sodales. Quisque vel orci eleifend nisi pretium lacinia. Suspendisse eget risus eget mi volutpat molestie eget quis lacus. Duis nisi libero, tincidunt nec nulla id, faucibus cursus felis.
|
||||
|
||||
Donec tempor eget risus pellentesque molestie. Phasellus porta neque vel arcu egestas, nec blandit velit fringilla. Nullam porta faucibus justo vitae laoreet. Pellentesque viverra id nunc eu varius. Nulla pulvinar lobortis iaculis. Etiam vestibulum odio nec velit tristique, a tristique nisi mattis. In sed fringilla orci, vitae efficitur odio. Quisque dui odio, ornare eget velit at, lacinia consequat libero. Quisque lectus nulla, aliquet eu leo in, porta rutrum diam. Donec nec mattis neque. Nam rutrum, odio ac eleifend bibendum, dolor arcu rutrum neque, eget porta elit tellus a lacus. Sed massa metus, sollicitudin et sapien eu, finibus tempus orci. Proin et sapien sit amet erat molestie interdum. In quis rutrum velit, faucibus ultrices tellus.
|
||||
|
||||
Sed sagittis sed justo eget tincidunt. Maecenas ut leo sagittis, feugiat magna et, viverra velit. Maecenas ex arcu, feugiat at consequat vitae, auctor eu massa. Integer egestas, enim vitae maximus convallis, est lectus pretium mauris, ac posuere lectus nisl quis quam. Aliquam tempus laoreet mi, vitae dapibus dolor varius dapibus. Suspendisse potenti. Donec sit amet purus nec libero dapibus tristique. Pellentesque viverra bibendum ligula. Donec sed felis et ex lobortis laoreet. Phasellus a fringilla libero, vitae malesuada nulla. Pellentesque blandit mattis lacus, et blandit tortor laoreet consequat. Suspendisse libero nunc, viverra sed fermentum in, accumsan egestas arcu. Proin in placerat elit. Sed interdum imperdiet malesuada. Suspendisse aliquet quis mauris eget sollicitudin.
|
||||
|
||||
Vivamus accumsan tellus non erat volutpat, quis dictum dolor feugiat. Praesent rutrum nunc ac est mollis cursus. Fusce semper volutpat dui ut egestas. Curabitur sit amet posuere massa. Cras tincidunt nulla et mi mollis imperdiet. Suspendisse scelerisque ex id sodales vulputate. In nunc augue, pharetra in placerat eu, mattis id tellus. Vivamus cursus efficitur vehicula. Nulla aliquet vehicula aliquet.
|
||||
|
||||
Sed cursus tellus sed porta pulvinar. Sed vitae nisi neque. Nullam aliquet, lorem et efficitur scelerisque, arcu diam aliquam felis, sed pulvinar lorem odio et turpis. Praesent convallis pulvinar turpis eu iaculis. Aliquam nec gravida mi. Curabitur eu nibh tempor, blandit justo in, ultrices felis. Fusce placerat metus non mi sagittis rutrum. Morbi sed dui fringilla, sagittis mauris eget, imperdiet nunc. Phasellus hendrerit sem elit, id hendrerit libero auctor sit amet. Integer sodales elit sit amet consequat cursus.
|
||||
|
||||
Nam semper est eget nunc mollis, in pellentesque lectus fringilla. In finibus vel diam id semper. Nunc mattis quis erat eu consectetur. In hac habitasse platea dictumst. Nullam et ipsum vestibulum ex pulvinar ultricies sit amet id velit. Aenean suscipit mi tortor, a lobortis magna viverra non. Nulla condimentum aliquet ante et ullamcorper. Pellentesque porttitor arcu a posuere tempus. Aenean lacus quam, imperdiet eu justo vitae, pretium efficitur ex. Duis id purus id magna rhoncus ultrices id eu risus. Nunc dignissim et libero id dictum.
|
||||
|
||||
Quisque a tincidunt neque. Phasellus commodo mi sit amet tempor fringilla. Ut rhoncus, neque non porttitor elementum, libero nulla egestas augue, sed fringilla sapien felis ac velit. Phasellus viverra rhoncus mollis. Nam ullamcorper leo vel erat laoreet luctus. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vivamus semper a metus a cursus. Nulla sed orci egestas, efficitur purus ac, malesuada tellus. Aenean rutrum velit at tellus fermentum mollis. Aliquam eleifend euismod metus.
|
||||
|
||||
In hac habitasse platea dictumst. Vestibulum volutpat neque vitae porttitor laoreet. Nam at tellus consequat, sodales quam in, pulvinar arcu. Maecenas varius convallis diam, ac lobortis tellus pellentesque quis. Maecenas eget augue massa. Nullam volutpat nibh ac justo rhoncus, ut iaculis tellus rutrum. Fusce efficitur efficitur libero quis condimentum. Curabitur congue neque non tincidunt tristique. Fusce eget tempor ex, at pellentesque odio. Praesent luctus dictum vestibulum. Etiam non orci nunc. Vivamus vitae laoreet purus, a lobortis velit. Curabitur tincidunt purus ac lectus elementum pellentesque. Quisque sed tincidunt est.
|
||||
|
||||
Sed vel ultrices massa, vitae ultricies justo. Cras finibus mauris nec lacus tempus dignissim. Cras faucibus maximus velit, eget faucibus orci luctus vehicula. Nulla massa nunc, porta ac consequat eget, rhoncus non tellus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Fusce sed maximus metus, vel imperdiet ipsum. Ut scelerisque lectus at blandit porttitor. Ut vulputate nunc pharetra, aliquet sapien ac, sollicitudin sapien. Aenean eget ante lorem. Nam accumsan venenatis tellus id dignissim.
|
||||
|
||||
Curabitur fringilla, magna non maximus dapibus, nulla sapien vestibulum lectus, sit amet semper dolor neque vitae nisl. Nunc ultrices vehicula augue sed iaculis. Maecenas nec diam mollis, suscipit orci et, vestibulum ante. Pellentesque eu nisl tortor. Nunc eleifend, lacus quis volutpat volutpat, nisi mi molestie sem, quis mollis ipsum libero a tellus. Ut viverra dolor mattis convallis interdum. Sed tempus nisl at nunc scelerisque aliquet. Quisque tempor tempor lorem id feugiat. Nullam blandit lectus velit, vitae porta lacus tincidunt a. Vivamus sit amet arcu ultrices, tincidunt mi quis, viverra quam. Aenean fringilla libero elementum lorem semper, quis pulvinar eros gravida. Nullam sodales blandit mauris, sed fermentum velit fermentum sit amet. Donec malesuada mauris in augue sodales vulputate. Vestibulum gravida turpis id elit rhoncus dignissim. Integer non congue lorem, eu viverra orci.
|
||||
|
||||
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Donec at dolor magna. Aliquam consectetur erat augue, id iaculis velit pharetra ac. Integer rutrum venenatis dignissim. Integer non sodales elit. Curabitur ut magna ut nibh feugiat aliquam ac ut risus. Morbi nibh quam, aliquam id placerat nec, vestibulum eget velit. Suspendisse at dignissim quam. Vivamus aliquet sem sed nisl volutpat, ut cursus orci ultrices. Aliquam ultrices lacinia enim, vitae aliquet neque.
|
||||
|
||||
Quisque scelerisque finibus diam in mattis. Cras cursus auctor velit. Aliquam sem leo, fermentum et maximus et, molestie a libero. Aenean justo elit, rutrum a ornare id, egestas eget enim. Aenean auctor tristique erat. Curabitur condimentum libero lacus, nec consequat orci vestibulum sed. Fusce elit ligula, blandit vitae sapien vitae, dictum ultrices risus. Nam laoreet suscipit sapien, at interdum velit faucibus sit amet. Duis quis metus egestas lectus elementum posuere non nec libero. Aliquam a dolor bibendum, facilisis nunc a, maximus diam. Vestibulum suscipit tristique magna, non dignissim turpis sodales sed. Nunc ornare, velit ac facilisis fringilla, dolor mi consectetur lorem, vitae finibus erat justo suscipit urna. Maecenas sit amet eros erat. Nunc non arcu ornare, suscipit lorem eget, sodales mauris. Aliquam tincidunt, quam nec mollis lacinia, nisi orci fermentum libero, consequat eleifend lectus quam et sapien. Vestibulum a quam urna.
|
||||
|
||||
Cras arcu leo, euismod ac ullamcorper at, faucibus sed massa. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Vivamus porttitor velit in enim interdum, non commodo metus ornare. Morbi vel lorem quis nisl luctus tristique quis vitae nisl. Suspendisse condimentum tortor enim, nec eleifend ipsum euismod et. Sed gravida quam ut tristique lacinia. Mauris eu interdum ipsum, ac ultrices odio. Nullam auctor tellus a risus porttitor vehicula. Nulla blandit euismod dictum. In pharetra, enim iaculis pulvinar interdum, dui nunc placerat nunc, sit amet pretium lectus nulla vitae quam. Phasellus quis enim sollicitudin, varius nulla id, ornare purus. Donec quam lacus, vestibulum quis nunc ac, mollis dictum nisi. Cras ut mollis elit. Maecenas ultrices ligula at risus faucibus scelerisque. Etiam vitae porttitor purus. Curabitur blandit lectus urna, ut hendrerit tortor feugiat ut.
|
||||
|
||||
Phasellus fringilla, sapien pellentesque commodo pharetra, ante libero aliquam tellus, ut consectetur augue libero a sapien. Maecenas blandit luctus nisl eget aliquet. Maecenas vitae porta dolor, faucibus laoreet sapien. Suspendisse lobortis, ipsum sed vehicula aliquam, elit purus scelerisque dui, rutrum consectetur diam odio et lorem. In nec lacinia metus. Donec viverra libero est, vel bibendum erat condimentum quis. Donec feugiat purus leo. In laoreet vitae felis a porttitor. Mauris ullamcorper, lacus id condimentum suscipit, neque magna pellentesque arcu, eget cursus neque tellus id metus. Curabitur volutpat ac orci vel ultricies.
|
||||
|
||||
Sed ut finibus erat. Sed diam purus, varius non tincidunt quis, ultrices sit amet ipsum. Donec et egestas nulla. Suspendisse placerat nisi at dui laoreet iaculis. Aliquam aliquet leo at augue faucibus molestie. Nullam lacus augue, hendrerit sed nisi eu, faucibus porta est. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nam ut leo aliquet sem fermentum rutrum quis ac justo. Integer placerat aliquam nisl ut sagittis. Proin erat orci, lobortis et sem eget, eleifend fringilla augue. Mauris varius laoreet arcu, sed tincidunt felis. Pellentesque venenatis lorem odio, id pulvinar velit molestie feugiat. Donec mattis lacus sed eleifend pulvinar.
|
||||
|
||||
Sed condimentum ex in tincidunt hendrerit. Etiam eget risus lacinia, euismod nibh eu, pellentesque quam. Proin elit eros, convallis id mauris ac, bibendum ultrices lectus. Morbi venenatis, purus id fermentum consequat, nunc libero tincidunt ligula, non dictum ligula orci nec quam. Nulla nec ultrices lorem. Aenean maximus augue vel dictum pharetra. Etiam turpis urna, pellentesque quis malesuada eu, molestie faucibus felis.
|
||||
|
||||
Vestibulum pharetra augue ut quam blandit congue in nec risus. Proin eu nibh eu dui eleifend porta vitae id lectus. Proin lacus nibh, lobortis sed ligula vitae, interdum lobortis erat. Suspendisse potenti. In sollicitudin quis sapien ut aliquet. Mauris ac nulla arcu. Fusce tristique justo quis lectus mollis, eu volutpat lectus finibus. Vivamus venenatis facilisis ex ut vestibulum.
|
||||
|
||||
Etiam varius lobortis purus, in hendrerit elit tristique at. In tempus, augue vestibulum fermentum gravida, ligula tellus vulputate arcu, eu molestie ex sapien at purus. Vestibulum nec egestas metus. Duis pulvinar quam nec consequat interdum. Aenean non dapibus lacus. Aliquam sit amet aliquet nulla. Sed venenatis volutpat purus nec convallis. Phasellus aliquet semper sodales. Cras risus sapien, condimentum auctor urna a, pulvinar ornare nisl. Sed tincidunt felis elit, ut elementum est bibendum ac. Morbi interdum justo vel dui faucibus condimentum.
|
||||
|
||||
Sed convallis eu sem at tincidunt. Nullam at auctor est, et ullamcorper ipsum. Pellentesque eget ante ante. Interdum et malesuada fames ac ante ipsum primis in faucibus. Integer euismod, sapien sed dapibus ornare, nibh enim maximus lacus, lacinia placerat urna quam quis felis. Morbi accumsan id nisl ut condimentum. Donec bibendum nisi est, sed volutpat lorem rhoncus in. Vestibulum ac lacinia nunc, eget volutpat magna. Integer aliquam pharetra ipsum, id placerat nunc volutpat quis. Etiam urna diam, rhoncus sit amet varius vel, euismod vel sem. Nullam vel molestie urna. Vivamus ornare erat at venenatis euismod. Suspendisse potenti. Fusce diam justo, tincidunt vel sem at, commodo faucibus nisl. Duis gravida efficitur diam, vel sagittis erat pulvinar ut.
|
||||
|
||||
Quisque vel pharetra felis. Duis efficitur tortor dolor, vitae porttitor erat fermentum sed. Sed eu mi purus. Etiam dignissim tortor eu tempus molestie. Aenean pretium erat enim, in hendrerit ante hendrerit at. Sed ut risus vel nunc venenatis ultricies quis in lacus. Pellentesque vitae purus euismod, placerat risus non, ullamcorper augue. Quisque varius quam ligula, nec aliquet ex faucibus vitae. Quisque rhoncus sit amet leo tincidunt mattis. Cras id mauris eget purus pretium gravida sit amet eu augue. Aliquam dapibus odio augue, id lacinia velit pulvinar eu.
|
||||
|
||||
Mauris fringilla, tellus nec pharetra iaculis, neque nisi ultrices massa, et tincidunt sem dui sed mi. Curabitur erat lorem, venenatis quis tempus lacinia, tempus sit amet nunc. Aliquam at neque ac metus commodo dictum quis vitae justo. Phasellus eget lacus tempus, blandit lorem vel, rutrum est. Aenean pharetra sem ut augue lobortis dignissim. Sed rhoncus at nulla id ultrices. Cras id condimentum felis. In suscipit luctus vulputate. Donec tincidunt lacus nec enim tincidunt sollicitudin ut quis enim. Nam at libero urna. Praesent sit amet massa vitae massa ullamcorper vehicula.
|
||||
|
||||
Nullam bibendum augue ut turpis condimentum bibendum. Proin sit amet urna hendrerit, sodales tortor a, lobortis lectus. Integer sagittis velit turpis, et tincidunt nisi commodo eget. Duis tincidunt elit finibus accumsan cursus. Aenean dignissim scelerisque felis vel lacinia. Nunc lacinia maximus luctus. In hac habitasse platea dictumst. Vestibulum eget urna et enim tempor tempor. Nam feugiat, felis vel vestibulum tempus, orci justo viverra diam, id dapibus lorem justo in ligula.
|
||||
|
||||
Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In ac pellentesque sem. Vestibulum lacinia magna dui, eu lacinia augue placerat et. Maecenas pulvinar congue est. Pellentesque commodo dui non pulvinar scelerisque. Etiam interdum est posuere sem bibendum, ac commodo magna dictum. Cras ipsum turpis, rhoncus nec posuere vitae, laoreet a arcu. Integer ac massa sit amet enim placerat lacinia sed ultrices arcu. Suspendisse sem nibh, luctus sit amet volutpat in, pellentesque eu metus. Ut gravida neque eget mi accumsan tempus. Nam sit amet aliquet nibh.
|
||||
|
||||
Pellentesque a purus cursus nulla hendrerit congue quis et odio. Aenean hendrerit, leo ullamcorper sagittis hendrerit, erat dui molestie quam, sed condimentum lacus risus sed tellus. Morbi a dapibus lectus, ut feugiat ex. Phasellus pretium quam et sapien mollis, vel iaculis dui dignissim. Sed ullamcorper est turpis, a viverra lorem consectetur in. Aenean aliquet nibh non cursus rutrum. Suspendisse at tristique urna, id lobortis urna. In hac habitasse platea dictumst. Phasellus libero velit, rutrum sed tellus nec, dapibus tincidunt ligula. Quisque vel dui venenatis, consequat nisl ut, lacinia ipsum. Phasellus vitae magna pellentesque, lobortis est id, faucibus quam. Nam eleifend faucibus dui vel pellentesque.
|
||||
|
||||
Etiam ut est non lacus tincidunt interdum. Maecenas sed massa urna. Quisque ut nibh tortor. Pellentesque felis ipsum, tempor finibus ipsum et, euismod pretium metus. Donec sit amet est ipsum. Quisque rhoncus justo non finibus elementum. Nulla nec lectus ac tortor placerat fringilla. Phasellus ac ultrices nunc, eu efficitur nisl. Nulla rhoncus nunc vitae ante dictum tincidunt. Nunc ultrices, massa sit amet malesuada dignissim, lectus lacus consequat sapien, non eleifend metus sem in eros. Phasellus mauris ante, dictum sit amet suscipit ac, rhoncus eget nisi. Phasellus at orci mollis, imperdiet neque eget, faucibus nulla. In at purus massa. Pellentesque quis rutrum lectus.
|
||||
|
||||
Integer eu faucibus turpis, sit amet mollis massa. Vestibulum id nulla commodo, rutrum ipsum sed, semper ante. Phasellus condimentum orci nec nibh convallis, ac maximus orci ullamcorper. Maecenas vitae sollicitudin mi. Integer et finibus lectus, et condimentum ligula. Donec elementum tristique quam vitae dapibus. Morbi euismod ipsum in tristique ullamcorper.
|
||||
|
||||
Duis fermentum non enim eu auctor. Quisque lacinia nibh vehicula nibh posuere, eu volutpat turpis facilisis. Ut ac faucibus nulla. Sed eleifend quis ex et pellentesque. Vestibulum sollicitudin in libero id fringilla. Phasellus dignissim purus consequat, condimentum dui sit amet, condimentum ante. Pellentesque ac consectetur massa, quis sagittis est. Nulla maximus tristique risus accumsan convallis. Curabitur imperdiet ac lacus a ultrices. Nulla facilisi. Sed quis quam quis lectus placerat lobortis vel sed turpis. In mollis dui id neque iaculis, ut aliquet tellus malesuada. Proin at luctus odio, vel blandit sapien. Praesent dignissim tortor vehicula libero fringilla, nec ultrices erat suscipit. Maecenas scelerisque purus in dapibus fermentum.
|
||||
|
||||
Curabitur magna odio, mattis in tortor ut, porttitor congue est. Vestibulum mollis lacinia elementum. Fusce maximus erat vitae nunc rutrum lobortis. Integer ligula eros, auctor vel elit non, posuere luctus lacus. Maecenas quis auctor massa. Ut ipsum lacus, efficitur posuere euismod et, hendrerit efficitur est. Phasellus fringilla, quam id tincidunt pretium, nunc dui sollicitudin orci, eu dignissim nisi metus ut magna. Integer lobortis interdum dolor, non bibendum purus posuere et. Donec non lectus aliquet, pretium dolor eu, cursus massa. Sed ut dui sapien. In sed vestibulum massa. Pellentesque blandit, dui non sodales vehicula, orci metus mollis nunc, non pharetra ex tellus ac est. Mauris sagittis metus et fermentum pretium. Nulla facilisi. Quisque quis ante ut nulla placerat mattis ut quis nisi.
|
||||
|
||||
Sed quis nulla ligula. Quisque dignissim ligula urna, sed aliquam purus semper at. Suspendisse potenti. Nunc massa lectus, pharetra vehicula arcu bibendum, imperdiet sodales ipsum. Nam ac sapien diam. Mauris iaculis fringilla mattis. Pellentesque tempus eros sit amet justo volutpat mollis. Phasellus ac turpis ipsum. Morbi vel ante elit. Aenean posuere quam consequat velit varius suscipit. Donec tempor quam ut nibh cursus efficitur.
|
||||
|
||||
Morbi molestie dolor nec sem egestas suscipit. Etiam placerat pharetra lectus, et ullamcorper risus tristique in. Sed faucibus ullamcorper lectus eget fringilla. Maecenas malesuada hendrerit congue. Sed eget neque a erat placerat tincidunt. Aliquam vitae dignissim turpis. Fusce at placerat magna, a laoreet lectus. Maecenas a purus nec diam gravida fringilla. Nam malesuada euismod ante non vehicula. In faucibus bibendum leo, faucibus posuere nisl pretium quis. Fusce finibus bibendum finibus. Vestibulum eu justo maximus, hendrerit diam nec, dignissim sapien. Aenean dolor lacus, malesuada quis vestibulum ac, venenatis ac ipsum. Cras a est id nunc finibus facilisis. Cras lacinia neque et interdum vehicula. Suspendisse vulputate tellus elit, eget tempor dui finibus vel.
|
||||
|
||||
Cras sed pretium odio. Proin hendrerit elementum felis in tincidunt. Nam sed turpis vel justo molestie accumsan condimentum eu nunc. Praesent lobortis euismod rhoncus. Nulla vitae euismod nibh, quis mattis mi. Fusce ultrices placerat porttitor. Duis sem ipsum, pellentesque sit amet odio a, molestie vulputate mauris.
|
||||
|
||||
Duis blandit mollis ligula, sit amet mattis ligula finibus sit amet. Nunc a leo molestie, placerat diam et, vestibulum leo. Suspendisse facilisis neque purus, nec pellentesque ligula fermentum nec. Aenean malesuada mauris lorem, eu blandit arcu pulvinar quis. Duis laoreet urna lacus, non maximus arcu rutrum ultricies. Nulla augue dolor, suscipit eu mollis eu, aliquam condimentum diam. Ut semper orci luctus, pharetra turpis at, euismod mi. Nulla leo diam, finibus sit amet purus sed, maximus dictum lorem. Integer eu mi id turpis laoreet rhoncus.
|
||||
|
||||
Integer a mauris tincidunt, finibus orci ut, pretium mauris. Nulla molestie nunc mi, id finibus lorem elementum sed. Proin quis laoreet ante. Integer nulla augue, commodo id molestie quis, rutrum ut turpis. Suspendisse et tortor turpis. Sed ut pharetra massa. Pellentesque elementum blandit sem, ut elementum tellus egestas a. Fusce eu purus nibh.
|
||||
|
||||
Cras dignissim ligula scelerisque magna faucibus ullamcorper. Proin at condimentum risus, auctor malesuada quam. Nullam interdum interdum egestas. Nulla aliquam nisi vitae felis mollis dictum. Suspendisse dapibus consectetur tortor. Ut ut nisi non sem bibendum tincidunt. Vivamus suscipit leo quis gravida dignissim.
|
||||
|
||||
Aliquam interdum, leo id vehicula mollis, eros eros rhoncus diam, non mollis ligula mi eu mauris. Sed ultrices vel velit sollicitudin tincidunt. Nunc auctor metus at ligula gravida elementum. Praesent interdum eu elit et mollis. Duis egestas quam sit amet velit dignissim consequat. Aliquam ac turpis nec nunc convallis sagittis. Fusce blandit, erat ac fringilla consectetur, dolor eros sodales leo, vel aliquet risus nisl et diam. Aliquam luctus felis vitae est eleifend euismod facilisis et lacus. Sed leo tellus, auctor eu arcu in, volutpat sagittis nisl. Pellentesque nisl ligula, placerat vel ullamcorper at, vulputate ac odio. Morbi ac faucibus orci, et tempus nulla. Proin rhoncus rutrum dolor, in venenatis mauris. Suspendisse a fermentum augue, non semper mi. Nunc eget pretium neque. Phasellus augue erat, feugiat ac aliquam congue, rutrum non sapien. Pellentesque ac diam gravida, consectetur felis at, ornare neque.
|
||||
|
||||
Nullam interdum mattis sapien quis porttitor. Interdum et malesuada fames ac ante ipsum primis in faucibus. Phasellus aliquet rutrum ipsum id euismod. Maecenas consectetur massa et mi porta viverra. Nunc quam nibh, dignissim vitae maximus et, ullamcorper nec lorem. Nunc vitae justo dapibus, luctus lacus vitae, pretium elit. Maecenas et efficitur leo. Curabitur mauris lectus, placerat quis vehicula vitae, auctor ut urna. Quisque rhoncus pharetra luctus. In hac habitasse platea dictumst. Integer sit amet metus nec eros malesuada aliquam. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Morbi hendrerit mi ac leo aliquam, sit amet ultricies libero commodo. Mauris dapibus purus metus, sit amet viverra nibh imperdiet et. Nullam porta nulla tellus, quis vehicula diam imperdiet non. Vivamus enim massa, bibendum in fermentum in, ultrices at ex.
|
||||
|
||||
Suspendisse fermentum id nibh eget accumsan. Duis dapibus bibendum erat ut sollicitudin. Aliquam nec felis risus. Pellentesque rhoncus ligula id sem maximus mollis sed nec massa. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus ipsum ipsum, sodales sed enim id, convallis faucibus eros. Donec ultricies dictum tincidunt. Cras vitae nibh arcu. Pellentesque cursus, sapien nec consequat fermentum, ipsum ante suscipit dui, imperdiet hendrerit est nisl eu massa. Quisque vitae sem ligula. Aenean iaculis metus ut mauris interdum laoreet. Vivamus sed gravida dolor.
|
||||
|
||||
Morbi nulla metus, porttitor sed eros sit amet, efficitur efficitur est. In vel nisl urna. Ut aliquet tellus at congue convallis. Phasellus imperdiet lobortis sollicitudin. Integer sodales, sem eu ultricies pharetra, erat erat porttitor odio, eget dapibus libero ipsum eget velit. Phasellus gravida nulla nisl, eu pharetra mi auctor vel. Sed blandit pharetra velit, ut egestas libero placerat non. Aliquam a interdum quam. Proin at tortor nec dui sollicitudin tempus sed vestibulum elit. Nunc non sollicitudin velit.
|
||||
|
||||
Aenean consequat diam velit, sed rutrum tortor faucibus dictum. Quisque at semper augue. Duis ut est eget mi ornare bibendum id et ligula. Phasellus consequat tortor non leo pulvinar posuere. Proin vestibulum eleifend felis, in hendrerit tortor sollicitudin eu. Phasellus hendrerit, lacus vel laoreet interdum, dui tortor consequat justo, commodo ultricies arcu felis vitae enim. Vivamus eu sapien at leo suscipit rutrum eu at justo. Aenean et dolor a libero ullamcorper posuere. Integer laoreet placerat nisi in vulputate. Mauris laoreet eget risus sed cursus. Donec scelerisque neque a libero eleifend hendrerit. Nulla varius condimentum nunc sit amet fermentum. Aliquam lorem ex, varius nec mollis ut, ultrices in neque. Morbi sit amet porta leo. Integer iaculis fermentum lacus in vestibulum.
|
||||
|
||||
Ut gravida, tellus ut maximus ultrices, erat est venenatis nisl, vitae pretium massa ex ac magna. Sed non purus eget ligula aliquet volutpat non quis arcu. Nam aliquam tincidunt risus, sit amet fringilla sapien vulputate ut. Mauris luctus suscipit pellentesque. Nunc porttitor dapibus ex quis tempus. Ut ullamcorper metus a eros vulputate, vitae viverra lectus convallis. Mauris semper imperdiet augue quis tincidunt. Integer porta pretium magna, sed cursus sem scelerisque sollicitudin. Nam efficitur, nibh pretium eleifend vestibulum, purus diam posuere sem, in egestas mauris augue sit amet urna.
|
||||
|
||||
Vestibulum tincidunt euismod massa in congue. Duis interdum metus non laoreet fringilla. Donec at ligula congue, tincidunt nunc non, scelerisque nunc. Donec bibendum magna non est scelerisque feugiat at nec neque. Ut orci tortor, tempus eget massa non, dignissim faucibus dolor. Nam odio risus, accumsan pretium neque eget, accumsan dignissim dui. In ut neque auctor, scelerisque tellus sed, ullamcorper nisi. Suspendisse varius cursus quam at hendrerit. Vivamus elit libero, sagittis vitae sem ac, vulputate iaculis ligula.
|
||||
|
||||
Sed lobortis laoreet purus sit amet rutrum. Pellentesque feugiat non leo vel lacinia. Quisque feugiat nisl a orci bibendum vestibulum. In et sollicitudin urna. Morbi a arcu ac metus faucibus tempus. Nam eu imperdiet sapien, suscipit mattis tortor. Aenean blandit ipsum nisi, a eleifend ligula euismod at. Integer tincidunt pharetra felis, mollis placerat mauris hendrerit at. Curabitur convallis, est sit amet luctus volutpat, massa lacus cursus augue, sed eleifend magna quam et risus. Aliquam lobortis tincidunt metus vitae porttitor. Suspendisse potenti. Aenean ullamcorper, neque id commodo luctus, nulla nunc lobortis quam, id dapibus neque dui nec mauris. Etiam quis lorem quis elit commodo ornare. Ut pharetra purus ultricies enim ultrices efficitur. Proin vehicula tincidunt molestie. Mauris et placerat sem.
|
||||
|
||||
Aliquam erat volutpat. Suspendisse velit turpis, posuere ac lacus eu, lacinia laoreet velit. Sed interdum felis neque, id blandit sem malesuada sit amet. Ut sagittis justo erat, efficitur semper orci tempor sed. Donec enim massa, posuere varius lectus egestas, pellentesque posuere mi. Cras tincidunt ut libero sed mattis. Suspendisse quis magna et tellus posuere interdum vel at purus. Pellentesque fringilla tristique neque, id aliquet tellus ultricies non. Duis ut tellus vel odio lobortis vulputate.
|
||||
|
||||
Integer at magna ac erat convallis vestibulum. Sed lobortis porttitor mauris. Fusce varius lorem et volutpat pulvinar. Aenean ac vulputate lectus, vitae consequat velit. Suspendisse ex dui, varius ut risus ut, dictum scelerisque sem. Vivamus urna orci, volutpat ut convallis ac, venenatis vitae urna. In hac habitasse platea dictumst. Etiam eu purus arcu. Aenean vulputate leo urna, vel tristique dui sagittis euismod. Suspendisse non tellus efficitur ante rhoncus volutpat at et sapien.
|
||||
|
||||
Sed dapibus accumsan porttitor. Phasellus facilisis lectus finibus ligula dignissim, id pulvinar lectus feugiat. Nullam egestas commodo nisi posuere aliquet. Morbi sit amet tortor sagittis, rutrum dui nec, dapibus sapien. Sed posuere tortor tortor, interdum auctor magna varius vitae. Vestibulum id sagittis augue. Curabitur fermentum arcu sem, eu condimentum quam rutrum non. Phasellus rutrum nibh quis lectus rhoncus pretium. Curabitur dictum interdum elit. Vestibulum maximus sodales imperdiet. Mauris auctor nec purus sed venenatis. In in urna purus.
|
||||
|
||||
Duis placerat molestie suscipit. Morbi a elit id purus efficitur consequat. Nunc ac commodo turpis. Etiam sit amet lacus a ipsum tempus venenatis sed vel nibh. Duis elementum aliquam mi sed tristique. Morbi ligula tortor, semper ac est vel, lobortis maximus erat. Curabitur ipsum felis, laoreet vel condimentum eget, ullamcorper sit amet mauris. Nulla facilisi. Nam at purus sed mi egestas placerat vitae vel magna. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Suspendisse at dignissim diam. Phasellus consectetur eget neque vel viverra. Donec sollicitudin mattis dolor vel malesuada. Vivamus vehicula leo neque, vitae fermentum leo posuere et. Praesent dui est, finibus sit amet tristique quis, pharetra vel nibh.
|
||||
|
||||
Duis nulla leo, accumsan eu odio eget, sagittis semper orci. Quisque ullamcorper ligula quam, commodo porttitor mauris ullamcorper eu. Cras varius sagittis felis in aliquam. Duis sodales risus ac justo vehicula, nec mattis diam lacinia. Cras eget lectus ipsum. Ut commodo, enim vitae malesuada hendrerit, ex dolor egestas lectus, sit amet hendrerit metus diam nec est. Vestibulum tortor metus, lobortis sit amet ante eget, tempor molestie lacus. In molestie et urna et semper. Mauris mollis, sem non hendrerit condimentum, sapien nisi cursus est, non suscipit quam justo non metus. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam enim est, porta ac feugiat vitae, rutrum in lorem. Duis vehicula tortor ut posuere maximus.
|
||||
|
||||
Nullam vestibulum non tellus sed commodo. Quisque mattis elit sit amet sapien sollicitudin, ut condimentum nisl congue. Aenean sagittis massa vel elit faucibus fermentum. Donec tincidunt nisi nec nisl sodales pellentesque. Mauris congue congue ligula ut suscipit. Vivamus velit tortor, tempor et gravida eget, fermentum sit amet ante. Nullam fringilla, lorem at ultrices cursus, urna neque ornare dolor, eu lacinia orci enim sed nibh. Ut a ullamcorper lectus, id mattis purus. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aenean maximus sollicitudin posuere. Nunc at augue lacus. Aenean efficitur leo sit amet lacinia efficitur.
|
||||
|
||||
Quisque venenatis quam mi, in pharetra odio vulputate eu. In vel nisl pulvinar, pulvinar ligula ut, sodales risus. Sed efficitur lectus at vestibulum tincidunt. Vestibulum eu ullamcorper elit. Fusce vestibulum magna enim, et tempor lacus posuere vitae. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Integer leo elit, luctus nec mattis sit amet, sollicitudin in turpis.
|
||||
|
||||
Proin convallis venenatis leo, vitae tristique erat iaculis nec. Nulla facilisi. Duis porttitor, sapien et bibendum vulputate, sem libero sodales lacus, non malesuada felis erat ut libero. Nam non felis semper, finibus est a, mattis mauris. Praesent nec eros quam. Nulla hendrerit, augue consectetur eleifend ultricies, purus mi condimentum nulla, eget dapibus est nunc sed libero. Nullam elementum dui erat, vitae luctus libero sollicitudin et. Nulla odio magna, placerat in augue eu, dapibus imperdiet odio. Suspendisse imperdiet metus sit amet rhoncus dapibus. Cras at enim et urna vehicula cursus eu a mauris. Integer magna ante, eleifend ac placerat vitae, porta at nisi. Cras eget malesuada orci. Curabitur nunc est, vulputate id viverra et, dignissim sed odio. Curabitur non mattis sem. Sed bibendum, turpis vitae vehicula faucibus, nunc quam ultricies lectus, vitae viverra felis turpis at libero.
|
||||
|
||||
Nullam ut egestas ligula. Proin hendrerit justo a lectus commodo venenatis. Nulla facilisi. Ut cursus lorem quis est bibendum condimentum. Aenean in tristique odio. Fusce tempor hendrerit ipsum. Curabitur mollis felis justo, quis dapibus erat auctor vel. Sed augue lectus, finibus ut urna quis, ullamcorper vestibulum dui. Etiam molestie aliquam tempor. Integer mattis sollicitudin erat, et tristique elit varius vel. Mauris a ex justo.
|
||||
|
||||
Nam eros est, imperdiet non volutpat rutrum, pellentesque accumsan ligula. Duis sit amet turpis metus. Aenean in rhoncus metus, ac fringilla ex. Suspendisse condimentum egestas purus, ut pharetra odio vulputate vel. Duis tincidunt massa a placerat ultrices. Mauris ultricies nibh sit amet condimentum malesuada. Duis tincidunt id ipsum sed congue.
|
||||
|
||||
Praesent eu ex augue. Nullam in porta ligula. In tincidunt accumsan arcu, in pellentesque magna tristique in. Mauris eleifend libero ac nisl viverra faucibus. Nam sollicitudin dolor in commodo hendrerit. Cras at orci metus. Ut quis laoreet orci. Vivamus ultrices leo pellentesque tempor aliquet. Maecenas ut eros vitae purus placerat vestibulum. Etiam vitae gravida dolor, quis rhoncus diam. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.
|
||||
|
||||
Suspendisse fringilla lacinia sagittis. Integer tincidunt consectetur tristique. Morbi non orci convallis, congue sapien quis, vulputate nunc. Donec a libero vel magna elementum facilisis non quis mi. Mauris posuere tellus non ipsum ultrices elementum. Vivamus massa velit, facilisis quis placerat aliquet, aliquet nec leo. Praesent a maximus sem. Sed neque elit, feugiat vel quam non, molestie sagittis nunc. Etiam luctus nunc ac mauris scelerisque, nec rhoncus lacus convallis. Nunc pharetra, nunc ac pulvinar aliquam, ex ipsum euismod augue, nec porttitor lacus turpis vitae neque. Fusce bibendum odio id tortor faucibus pellentesque. Sed ac porta nibh, eu gravida erat.
|
||||
|
||||
Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aliquam quis ullamcorper felis. Nulla mattis sagittis ante ac tincidunt. Integer ac felis efficitur, viverra libero et, facilisis ligula. Suspendisse a metus a massa rhoncus posuere. Phasellus suscipit ligula ut lacus facilisis, ac pellentesque ex tempor. Quisque consectetur massa mi, ac molestie libero dictum quis. Proin porttitor ligula quis erat tincidunt venenatis. Proin congue nunc sed elit gravida, nec consectetur lectus sodales. Etiam tincidunt convallis ipsum at vestibulum. Quisque maximus enim et mauris porttitor, et molestie magna tristique. Morbi vitae metus elit. Maecenas sed volutpat turpis. Aliquam vitae dolor vestibulum, elementum purus eget, dapibus nibh. Nullam egestas dui ac rutrum semper.
|
||||
|
||||
Etiam hendrerit est metus, et condimentum metus aliquam ac. Pellentesque id neque id ipsum rhoncus vulputate. Aliquam erat nisl, posuere sit amet ligula ac, fermentum blandit felis. Vivamus fermentum mi risus, non lacinia purus viverra id. Aenean ac sapien consequat, finibus mauris nec, porta sem. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed quis consectetur ex, dignissim bibendum nulla. Phasellus ac libero at quam vehicula euismod non eu leo. Phasellus a sapien augue.
|
||||
|
||||
Maecenas ligula dui, bibendum vitae mauris et, auctor laoreet felis. Duis non libero a mi semper mattis. Quisque consequat luctus massa, quis tristique eros auctor feugiat. Maecenas sodales euismod neque vitae facilisis. Nullam laoreet imperdiet velit at pellentesque. Etiam massa odio, facilisis a consequat vitae, placerat vel magna. Nunc sagittis eros nec urna fringilla, pulvinar vestibulum nibh scelerisque. Sed magna metus, cursus eu consequat et, pharetra a est. Suspendisse elementum neque a dui malesuada lacinia. Donec sed ipsum volutpat, cursus urna id, ullamcorper arcu. Maecenas laoreet nisl eget velit egestas sollicitudin. Etiam nisl turpis, mollis id dignissim vitae, tristique vehicula ante. Maecenas eget placerat est, at rutrum augue. Vivamus faucibus lacinia ullamcorper. Sed pulvinar urna sodales ante sodales, at gravida leo dictum.
|
||||
|
||||
Morbi maximus, quam a lobortis bibendum, enim felis varius elit, ac vehicula elit nisl ut lacus. Quisque ut arcu augue. Praesent id turpis quam. Sed sed arcu eros. Maecenas at cursus lorem, ac eleifend nisi. Fusce mattis felis at commodo pharetra. Praesent ac commodo ipsum. Quisque finibus et eros vitae tincidunt. In hac habitasse platea dictumst. Praesent purus ipsum, luctus lobortis ornare quis, auctor eget justo. Nam vel enim sollicitudin, faucibus tortor eu, sagittis eros. Ut nec consectetur erat. Donec ultricies malesuada ligula, a hendrerit sapien volutpat in. Maecenas sed enim vitae sapien pulvinar faucibus.
|
||||
|
||||
Proin semper nunc nibh, non consequat neque ullamcorper vel. Maecenas lobortis sagittis blandit. Aenean et arcu ultricies turpis malesuada malesuada. Ut quam ex, laoreet ut blandit cursus, feugiat vitae dolor. Etiam ex lacus, scelerisque vel erat vel, efficitur tincidunt magna. Morbi tristique lacinia dolor, in egestas magna ultrices vitae. Integer ultrices leo ac tempus venenatis. Praesent ac porta tortor. Vivamus ornare blandit tristique. Nulla rutrum finibus pellentesque. In non dui elementum, fermentum ipsum vel, varius magna. Pellentesque euismod tortor risus, ac pellentesque nisl faucibus eget.
|
||||
|
||||
Vivamus eu enim purus. Cras ultrices rutrum egestas. Sed mollis erat nibh, at posuere nisl luctus nec. Nunc vulputate, sapien id auctor molestie, nisi diam tristique ante, non convallis tellus nibh at orci. Morbi a posuere purus, in ullamcorper ligula. Etiam elementum sit amet dui imperdiet iaculis. Proin vitae tincidunt ipsum, sit amet placerat lectus. Curabitur commodo sapien quam, et accumsan lectus fringilla non. Nullam eget accumsan enim, ac pharetra mauris. Sed quis tristique velit, vitae commodo nisi. Duis turpis dui, maximus ut risus at, finibus consequat nunc. Maecenas sed est accumsan, aliquet diam in, facilisis risus. Curabitur vehicula rutrum auctor. Nam iaculis risus pulvinar maximus viverra. Nulla vel augue et ex sagittis blandit.
|
||||
|
||||
Ut sem nulla, porta ac ante ac, posuere laoreet eros. Donec sodales posuere justo a auctor. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Cras mollis at orci hendrerit porta. Nullam sodales tortor tortor, non lacinia diam finibus id. Duis libero orci, suscipit ac odio et, dictum consequat ipsum. Pellentesque eu ligula sagittis, volutpat eros at, lacinia lorem. Cras euismod tellus in iaculis tempor. Quisque accumsan, magna a congue venenatis, ante ipsum aliquam lectus, at egestas enim nunc at justo. Quisque sem purus, viverra ut tristique ut, maximus id enim. Etiam quis placerat sem. In sollicitudin, lacus eu rutrum mollis, nulla eros luctus elit, vel dapibus urna purus nec urna. Phasellus egestas massa quam, ac molestie erat hendrerit a. Praesent ultrices neque ut turpis molestie auctor. Etiam molestie placerat purus, et euismod erat aliquam in. Morbi id suscipit justo.
|
||||
|
||||
Proin est ante, consequat at varius a, mattis quis felis. Sed accumsan nibh sit amet ipsum elementum posuere. Vestibulum bibendum id diam sit amet gravida. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Morbi nec dolor vel ipsum dignissim hendrerit vel non ipsum. Praesent facilisis orci quis elit auctor lobortis. Phasellus cursus risus lectus, vel lobortis libero dapibus in. Quisque tristique tempus leo a pulvinar. Pellentesque a magna tincidunt, pellentesque massa nec, laoreet orci. Morbi congue ornare dolor quis commodo. Phasellus massa nisi, tincidunt at eros dictum, hendrerit lobortis urna. Maecenas porta, magna id mattis molestie, nibh tellus lobortis sem, eget tincidunt ipsum quam eu turpis.
|
||||
|
||||
Ut gravida orci risus, vel rutrum mauris vehicula id. Etiam bibendum, neque a placerat condimentum, ex orci imperdiet lectus, quis dapibus arcu lacus eget lectus. Sed consequat non mi sit amet venenatis. Fusce vestibulum erat libero, eget hendrerit risus vulputate sollicitudin. Integer sed eleifend felis. Donec commodo, sem eu mattis placerat, urna odio aliquam tellus, et laoreet justo tellus eget erat. Fusce sed suscipit tortor. Nam hendrerit nibh ac nunc auctor lacinia. Pellentesque placerat condimentum ipsum, eget semper tortor hendrerit vel. Nullam non urna eu lacus pellentesque congue ut id eros.
|
||||
|
||||
Nunc finibus leo in rhoncus tristique. Sed eu ipsum nec nisl egestas faucibus eget a felis. Pellentesque vitae nisi in nulla accumsan fermentum. Sed venenatis feugiat eleifend. Fusce porttitor varius placerat. Aliquam aliquet lacus sit amet mattis mollis. Sed vel nulla quis dolor suscipit vehicula ac viverra lorem. Duis viverra ipsum eget nulla ullamcorper fermentum. Mauris tincidunt arcu quis quam fringilla ornare. Donec et iaculis tortor. Nam ultricies libero vel ipsum aliquet efficitur. Morbi eget dolor aliquam, tempus sapien eget, viverra ante. Donec varius mollis ex, sed efficitur purus euismod interdum. Quisque vel sapien non neque tincidunt semper. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
|
||||
|
||||
Suspendisse sit amet purus leo. Fusce lectus lorem, aliquam ac nulla eget, imperdiet ornare eros. Nullam sem augue, varius in nisi non, sollicitudin pellentesque ante. Etiam eu odio condimentum, tempor libero et, egestas arcu. Cras pellentesque eleifend aliquet. Pellentesque non blandit ligula. Ut congue viverra rhoncus. Phasellus mattis mi ac eros placerat, eu feugiat tellus ultrices. Aenean mollis laoreet libero eu imperdiet. Cras sed pulvinar mi, ac vehicula ligula. Vestibulum sit amet ex massa. In a egestas eros.
|
||||
|
||||
Mauris pretium ipsum risus, venenatis cursus ante imperdiet id. Praesent eu turpis nec risus feugiat maximus ullamcorper ac lectus. Integer placerat at mi vel dapibus. Vestibulum fermentum turpis sit amet turpis viverra, id aliquet diam suscipit. Nam nec ex sed ante ullamcorper pharetra quis sit amet risus. Sed ac faucibus velit, id feugiat nibh. Nullam eget ipsum ex. Vivamus tincidunt non nunc non faucibus. Quisque bibendum viverra facilisis. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur at nisi hendrerit quam suscipit egestas. Curabitur laoreet maximus ultricies. Duis ut tellus ac augue molestie dictum.
|
||||
|
||||
Suspendisse rhoncus iaculis erat, ut ullamcorper est tristique eget. Donec auctor nec risus at gravida. Vivamus volutpat vulputate tellus, vel ultricies eros suscipit eget. Ut pulvinar id mi eu tempus. Morbi malesuada augue in dui varius, nec blandit neque vehicula. Donec ornare nec nisl in mollis. Morbi enim nisi, rhoncus nec est id, dapibus tempus urna. Ut id elit a felis vestibulum consectetur. Duis lectus quam, pharetra sit amet diam sed, posuere vestibulum erat. Fusce vitae maximus massa. Nullam id metus tempus, iaculis risus eu, lobortis urna. Quisque in congue urna. Pellentesque placerat neque in augue dapibus, non varius ex malesuada. Curabitur ut eleifend libero. Fusce vitae ligula luctus, fermentum enim vitae, ultrices erat.
|
||||
|
||||
Sed viverra augue turpis, scelerisque egestas sapien mattis eu. Duis laoreet magna at ex pharetra dapibus. Praesent eget odio vel quam venenatis dictum. Nulla in sollicitudin dolor. Mauris lobortis nec eros vel rhoncus. Vestibulum porta viverra venenatis. Curabitur vel scelerisque quam, a egestas velit. Praesent volutpat tincidunt magna at laoreet.
|
||||
|
||||
Cras nec lorem odio. Pellentesque quis dui urna. Praesent at tellus ac lectus scelerisque placerat nec eu risus. Vestibulum sit amet mattis ligula. Vivamus sed nisi at leo elementum accumsan at sit amet arcu. Aenean mattis tellus nec leo gravida, eget hendrerit nisl faucibus. Mauris pellentesque luctus condimentum. Maecenas pretium sapien nunc, eget commodo dolor maximus id. Mauris vestibulum accumsan massa a dictum. Phasellus interdum quam ligula, ut maximus diam blandit aliquam. Nunc vitae ex eu erat condimentum consectetur. Maecenas interdum condimentum volutpat.
|
||||
|
||||
Donec et enim a libero rutrum laoreet. Praesent a condimentum sem, at tincidunt quam. In vel molestie risus. Sed urna dui, molestie vitae mollis laoreet, tempor quis lectus. Praesent vitae auctor est, et aliquet nunc. Curabitur vulputate blandit nulla, at gravida metus. Maecenas gravida dui eu iaculis tristique. Pellentesque posuere turpis nec auctor eleifend. Suspendisse bibendum diam eu tellus lobortis, et laoreet quam congue. In hac habitasse platea dictumst. Morbi dictum neque velit, eget rutrum eros ultrices sit amet.
|
||||
|
||||
Phasellus fermentum risus pharetra consectetur bibendum. Donec magna tortor, lacinia vitae nibh quis, aliquet pretium lorem. Donec turpis nisi, pretium eu enim volutpat, mattis malesuada augue. Nullam vel tellus iaculis, sollicitudin elit eget, tincidunt lacus. Fusce elementum elementum felis et iaculis. Suspendisse porta eros nec neque malesuada, in malesuada ante sollicitudin. Vivamus bibendum viverra molestie.
|
||||
|
||||
Integer feugiat, erat nec convallis aliquam, velit felis congue erat, molestie eleifend tellus erat in tellus. Nunc et justo purus. Donec egestas fermentum dui non feugiat. Quisque in sapien sagittis, gravida quam id, iaculis lectus. Cras sagittis rhoncus bibendum. Fusce quis metus in velit scelerisque tincidunt at non ipsum. Vivamus efficitur ante eu odio vulputate, vitae ultricies risus vehicula. Proin eget odio eu sem tincidunt feugiat vel id lorem.
|
||||
|
||||
Vestibulum sit amet nulla dignissim, euismod mi in, fermentum tortor. Donec ut aliquet libero, lacinia accumsan velit. Donec et nulla quam. Nullam laoreet odio nec nunc imperdiet, a congue eros venenatis. Quisque nec tellus sit amet neque interdum posuere. Duis quis mi gravida, tincidunt diam convallis, ultricies augue. Mauris consequat risus non porttitor congue. Ut in ligula consequat, viverra nunc a, eleifend enim. Duis ligula urna, imperdiet nec facilisis et, ornare eu ex. Proin lobortis lectus a lobortis porttitor. Nulla leo metus, egestas eu libero sed, pretium faucibus felis. Vestibulum non sem tortor. Nam cursus est leo. Vivamus luctus enim odio, non interdum sem dapibus a. Aenean accumsan consequat lectus in imperdiet.
|
||||
|
||||
Donec vehicula laoreet ipsum in posuere. Quisque vel quam imperdiet, sollicitudin nisi quis, suscipit velit. Morbi id sodales mauris. Curabitur tellus arcu, feugiat sed dui sit amet, sodales sagittis libero. Aenean vel suscipit metus, non placerat leo. Vestibulum quis nulla elit. Proin scelerisque non ante ut commodo. Interdum et malesuada fames ac ante ipsum primis in faucibus.
|
||||
|
||||
Sed non urna dolor. Suspendisse convallis mi porta pulvinar ultrices. Suspendisse quam ipsum, hendrerit non scelerisque molestie, interdum dictum nunc. Morbi condimentum condimentum turpis eu luctus. Pellentesque sagittis sollicitudin odio, sed ultricies felis ornare sit amet. Sed ultrices ex leo, a tincidunt nisl gravida sed. Nullam ornare accumsan porta. Praesent consectetur id est nec sollicitudin.
|
||||
|
||||
In hac habitasse platea dictumst. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed sed ultrices nibh. Duis accumsan suscipit eros, a dictum odio tempus sit amet. Aenean imperdiet erat ac lacus finibus, scelerisque cursus massa imperdiet. Mauris molestie risus ut lacinia posuere. Nulla et sodales purus. Maecenas orci erat, placerat in tristique quis, placerat in mi.
|
||||
|
||||
Donec sollicitudin pellentesque odio in feugiat. Morbi eu dolor ut mauris congue sollicitudin. Aliquam erat volutpat. Nulla id varius dui. Curabitur finibus urna ante, consectetur interdum nisi volutpat a. Quisque quis mi tristique, consequat tellus eget, rutrum sapien. Vivamus vitae tellus vulputate, rutrum ex eu, vulputate sem. Suspendisse viverra lorem tellus, vel interdum orci gravida quis. Ut laoreet arcu at mi ullamcorper finibus. Duis porta sagittis vestibulum. Sed commodo nisl vitae urna sollicitudin, nec lacinia est sodales. Curabitur imperdiet sodales dui sed iaculis. Sed ac tellus maximus, eleifend quam sit amet, feugiat elit. Aenean viverra, dui at mattis varius, est odio vestibulum sapien, sit amet mollis libero massa nec velit. Etiam quis sodales justo.
|
||||
|
||||
Ut ultricies, sem eget sodales feugiat, nunc arcu congue elit, ac tempor justo massa nec purus. Maecenas enim nunc, pharetra eget dictum sit amet, tempus pellentesque velit. Suspendisse venenatis ligula in nulla mattis, et imperdiet ex tincidunt. Etiam vulputate, tellus et ultrices suscipit, enim velit laoreet massa, vitae congue odio enim ac urna. Morbi quam lorem, iaculis ac varius sagittis, euismod quis dolor. In ut dui eu purus feugiat consectetur. Vestibulum cursus velit quis lacus pellentesque iaculis. Cras in risus sed mauris porta rutrum. Nulla facilisi. Nullam eu bibendum est, non pellentesque lectus. Sed imperdiet feugiat lorem, quis convallis ante auctor in. Maecenas justo magna, scelerisque sit amet tellus eget, varius elementum risus. Duis placerat et quam sed varius.
|
||||
|
||||
Duis nec nibh vitae nibh dignissim mollis quis sed felis. Curabitur vitae quam placerat, venenatis purus ut, euismod nisl. Curabitur porttitor nibh eu pulvinar ullamcorper. Suspendisse posuere nec ipsum ac dapibus. Cras convallis consectetur urna. Phasellus a nibh in dolor lacinia posuere id eget augue. In eu pharetra lorem, vitae cursus lacus. Aliquam tincidunt nibh lectus. Aenean facilisis ultricies posuere. Sed ut placerat orci. Curabitur scelerisque gravida blandit. Maecenas placerat ligula eget suscipit fringilla. Mauris a tortor justo. Aliquam hendrerit semper mollis. Phasellus et tincidunt libero. Etiam vel quam libero.
|
||||
|
||||
Quisque aliquet tempor ex. Ut ante sem, vehicula at enim vel, gravida porta elit. Etiam vitae lacus a neque lobortis consectetur. Mauris sed interdum odio. Mauris elementum ex blandit tempor cursus. Integer in enim in leo viverra elementum. Fusce consectetur metus et sem rutrum, mattis euismod diam semper. Nunc sed ipsum vel urna consequat vehicula. Donec cursus pretium lorem, vestibulum pretium felis commodo sit amet. Nam blandit felis enim, eget gravida ex faucibus a. In nec neque massa. Etiam laoreet posuere ipsum. Praesent volutpat nunc dolor, ac vulputate magna facilisis non. Aenean congue turpis vel lectus sollicitudin tristique. Sed nec consequat purus, non vehicula quam. Etiam ultricies, est ac dictum tincidunt, turpis turpis pretium massa, a vulputate libero justo at nibh.
|
||||
|
||||
Aliquam erat volutpat. Cras ultrices augue ac sollicitudin lobortis. Curabitur et aliquet purus. Duis feugiat semper facilisis. Phasellus lobortis cursus velit, a sollicitudin tortor. Nam feugiat sapien non dapibus condimentum. Morbi at mi bibendum, commodo quam at, laoreet enim. Integer eu ultrices enim. Sed vestibulum eu urna ut dictum. Curabitur at mattis leo, sed cursus massa. Aliquam porttitor, felis quis fermentum porttitor, justo velit feugiat nulla, eget condimentum sem dui ut sapien.
|
||||
|
||||
In fringilla elit eu orci aliquam consequat. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut eget fringilla tellus. Curabitur fermentum, mi et condimentum suscipit, elit neque bibendum dui, et hendrerit nunc metus id ipsum. Morbi placerat mi in hendrerit congue. Ut feugiat mauris eget scelerisque viverra. Vivamus sit amet erat dictum, sagittis lectus nec, pulvinar lorem. Sed non enim ac dui sollicitudin aliquet. Quisque ut lacus dolor. Fusce hendrerit malesuada euismod. Nulla faucibus vel mauris eu mollis. Mauris est diam, fringilla ac arcu feugiat, efficitur volutpat turpis. Aliquam venenatis cursus massa sed porttitor. Ut ac finibus enim, in tincidunt sapien.
|
||||
|
||||
Nunc faucibus semper turpis a lacinia. Phasellus gravida, libero vel pulvinar ornare, ex sem tincidunt lectus, sit amet convallis augue risus at tortor. Quisque sit amet ipsum id nulla posuere vestibulum. Pellentesque scelerisque mauris vel leo viverra sodales. Nulla viverra aliquam ex, ut rutrum enim fermentum venenatis. Aenean eget dapibus ex, eget faucibus metus. Vestibulum volutpat leo in diam semper, eget porta magna suscipit. Sed sit amet nulla blandit, aliquam dolor ac, gravida velit. Sed vel velit viverra, maximus est id, convallis justo.
|
||||
|
||||
Curabitur nulla ante, vulputate at libero vel, ullamcorper rutrum nibh. Pellentesque porttitor eu mauris id mattis. Duis vulputate augue elit, eget interdum justo pretium vel. Maecenas eu vulputate arcu, eget posuere purus. Suspendisse viverra a velit dictum eleifend. Suspendisse vitae dapibus diam. Donec vehicula justo in ante interdum, eu luctus diam placerat. Vivamus convallis ipsum eu orci suscipit, sed fermentum enim euismod. Maecenas faucibus elit vitae ex ornare tristique. Donec vestibulum nec elit sit amet porttitor. Aenean tempor lectus eget tortor hendrerit luctus. Nullam interdum vitae lectus vel feugiat. Cras in risus non magna consectetur lobortis. Sed faucibus enim quis gravida convallis.
|
||||
|
||||
Phasellus eget massa sit amet libero ultrices suscipit. Vivamus at risus sapien. Nam mollis nunc eget velit dictum maximus. Sed pellentesque, nunc ac fringilla lacinia, quam enim mattis ex, sed euismod tortor metus eu neque. Ut mattis nisl ut lectus rhoncus, sodales bibendum eros porta. Nulla porttitor enim nec diam sagittis, eget porta velit efficitur. Vestibulum ultricies eros neque. Phasellus rutrum suscipit enim, in interdum ante gravida vitae. Sed in sagittis diam, non commodo velit.
|
||||
|
||||
Morbi hendrerit odio orci, nec tincidunt odio rhoncus nec. Mauris neque velit, vehicula a lorem at, suscipit tristique dui. Sed finibus, nisl in mattis convallis, turpis neque sodales lacus, eu porta enim magna non diam. Nam commodo sodales risus consectetur malesuada. In eget elementum justo. Phasellus sit amet massa imperdiet, dapibus nunc sit amet, suscipit orci. Fusce condimentum laoreet feugiat. Ut ut viverra ante. Praesent bibendum interdum commodo. Nulla mollis nisi a est ornare volutpat. Sed at ligula eu nisi dapibus tempus. Proin cursus vestibulum justo, nec efficitur justo dignissim vel. Nunc quis maximus eros.
|
||||
|
||||
Cras viverra, diam a tristique mattis, libero felis vulputate tellus, a ornare felis leo a dui. Nulla ante nulla, finibus ut tellus ut, blandit pharetra nibh. Proin eleifend fermentum ex, eget auctor libero vulputate in. Nullam ultricies, mauris placerat pretium placerat, leo urna lobortis leo, vel placerat arcu libero sed mauris. Aliquam mauris ligula, ornare at urna at, eleifend gravida ligula. Vestibulum consectetur ut nulla non scelerisque. Donec ornare, sem nec elementum aliquam, urna nulla bibendum metus, eu euismod dui ligula ac est. Fusce laoreet erat eu ex lobortis, quis bibendum ligula interdum. Sed vel mi erat. Vivamus id lacus ac enim mattis tempor. Nunc ultricies pellentesque enim sed euismod. Fusce tincidunt convallis elit quis aliquam. Mauris nulla ipsum, sollicitudin quis diam ac, feugiat volutpat tellus. In nibh nibh, vulputate quis tincidunt quis, pulvinar eget magna. Pellentesque quis finibus dolor. Suspendisse viverra vitae lectus non eleifend.
|
||||
|
||||
Nunc ut orci et sapien maximus semper. Nulla dignissim sem urna, ac varius lectus ultricies id. Quisque aliquet pulvinar pretium. In ultricies molestie tellus vehicula porta. Nam enim lorem, aliquam eget ex et, hendrerit volutpat quam. Maecenas diam lacus, pellentesque eget tempus ac, pharetra eu elit. Donec vel eros a sem facilisis vulputate. Nullam ac nisi vulputate, laoreet nisl ac, eleifend sem. Nullam mi massa, rhoncus sed pharetra interdum, tincidunt eget nunc. Aliquam viverra mattis posuere. Mauris et dui sed nisl sollicitudin fermentum quis ut arcu. Nam placerat eget orci at tincidunt. Curabitur vel turpis metus. Phasellus nibh nulla, fermentum scelerisque sem vel, gravida tincidunt velit. Pellentesque vel quam tempor, finibus massa pellentesque, condimentum dui.
|
||||
|
||||
Donec at mattis neque. Etiam velit diam, consequat auctor mauris id, hendrerit faucibus metus. Maecenas ullamcorper eros a est sodales, ac consectetur odio scelerisque. Donec leo metus, imperdiet at pellentesque vel, feugiat id erat. Suspendisse at magna enim. Vestibulum placerat sodales lorem id sollicitudin. Aenean at euismod ligula, eget mollis diam. Phasellus pulvinar, orci nec pretium condimentum, est erat facilisis purus, quis feugiat augue elit aliquam nulla. Aenean vitae tortor id risus congue tincidunt. Sed dolor enim, mattis a ullamcorper id, volutpat ac leo.
|
||||
|
||||
Proin vehicula feugiat augue, id feugiat quam sodales quis. Donec et ultricies massa, a lacinia nulla. Duis aliquam augue ornare euismod viverra. Ut lectus risus, rutrum sit amet efficitur a, luctus nec nisl. Cras volutpat ullamcorper congue. Sed vitae odio metus. Phasellus aliquet euismod varius.
|
||||
|
||||
Nullam sem ex, malesuada ut magna ut, pretium mollis arcu. Nam porttitor eros cursus mi lacinia faucibus. Suspendisse aliquet eleifend iaculis. Maecenas sit amet viverra tortor. Nunc a mollis risus. Etiam tempus dolor in tortor malesuada mattis. Ut tincidunt venenatis est sit amet dignissim. Vestibulum massa enim, tristique sed scelerisque eu, fringilla ac velit. Donec efficitur quis urna sit amet malesuada. Vestibulum consequat ac ligula in dapibus. Maecenas massa massa, molestie non posuere nec, elementum ut magna. In nisi erat, mollis non venenatis eu, faucibus in justo. Morbi gravida non ex non egestas. Pellentesque finibus laoreet diam, eu commodo augue congue vitae.
|
||||
|
||||
Aenean sem mi, ullamcorper dapibus lobortis vitae, interdum tincidunt tortor. Vivamus eget vulputate libero. Ut bibendum posuere lectus, vel tincidunt tortor aliquet at. Phasellus malesuada orci et bibendum accumsan. Aliquam quis libero vel leo mollis porta. Sed sagittis leo ac lacus dictum, ac malesuada elit finibus. Suspendisse pharetra luctus commodo. Vivamus ultricies a odio non interdum. Vivamus scelerisque tincidunt turpis quis tempor. Pellentesque tortor ligula, varius non nunc eu, blandit sollicitudin neque. Nunc imperdiet, diam et tristique luctus, ipsum ex condimentum nunc, sit amet aliquam justo velit sed libero. Duis vel suscipit ligula. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed tincidunt neque vel massa ultricies, id dictum leo consequat. Curabitur lobortis ultricies tellus, eget mattis nisl aliquam sit amet.
|
||||
|
||||
Proin at suscipit justo. Vivamus ut vestibulum nisl. Pellentesque enim odio, pharetra non magna sed, efficitur auctor magna. Praesent tincidunt ante quis ante hendrerit viverra. Pellentesque vel ipsum id magna vulputate efficitur. Sed nec neque accumsan, pulvinar sapien quis, euismod mauris. Donec condimentum laoreet sapien quis gravida. Quisque sed mattis purus. Vestibulum placerat vel neque maximus scelerisque.
|
||||
|
||||
Vestibulum mattis quam quis efficitur elementum. Duis dictum dolor ac scelerisque commodo. Fusce sollicitudin nisi sit amet dictum placerat. Suspendisse euismod pharetra eleifend. In eros nisl, porttitor sed mauris at, consectetur aliquet mauris. Donec euismod viverra neque sed fermentum. Phasellus libero magna, accumsan ut ultricies vitae, dignissim eget metus. Donec tellus turpis, interdum eget maximus nec, hendrerit eget massa. Curabitur auctor ligula in iaculis auctor. In ultrices quam suscipit cursus finibus. Aenean id mi at dolor interdum iaculis vitae ut lorem. Nullam sed nibh fringilla, lacinia odio nec, placerat erat. In dui libero, viverra ac viverra ac, pellentesque sit amet turpis.
|
||||
|
||||
Nulla in enim ex. Sed feugiat est et consectetur venenatis. Cras varius facilisis dui vel convallis. Vestibulum et elit eget tellus feugiat pellentesque. In ut ante eu purus aliquet posuere. Nulla nec ornare sem, sed luctus lorem. Nam varius iaculis odio, eget faucibus nisl ullamcorper in. Sed eget cursus felis, nec efficitur nisi.
|
||||
|
||||
Vivamus commodo et sem quis pulvinar. Pellentesque libero ante, venenatis vitae ligula sit amet, ornare sollicitudin nulla. Mauris eget tellus hendrerit, pulvinar metus quis, tempor nisi. Proin magna ex, laoreet sed tortor quis, varius fermentum enim. Integer eu dolor dictum, vulputate tortor et, aliquet ligula. Vestibulum vitae justo id mauris luctus sollicitudin. Suspendisse eget auctor neque, sodales egestas lorem. Vestibulum lacinia egestas metus vitae euismod. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Vivamus ex tellus, volutpat nec pulvinar sit amet, condimentum vitae dui. Curabitur vel felis sodales, lacinia nunc iaculis, ullamcorper augue. Pellentesque consequat dolor quis eros efficitur malesuada. Nulla ut malesuada lectus.
|
||||
|
||||
Morbi et tristique ante. Aliquam erat volutpat. Vivamus vitae dui nec turpis pellentesque fermentum. Quisque eget velit massa. Pellentesque tristique aliquam nisl, eu sollicitudin justo venenatis sed. Duis eleifend sem eros, ut aliquam libero porttitor id. Sed non nunc consequat, rhoncus diam eu, commodo erat. Praesent fermentum in lectus id blandit. Donec quis ipsum at justo volutpat finibus. Nulla blandit justo nulla, at mollis lacus consequat eget. Aenean sollicitudin quis eros ut ullamcorper.
|
||||
|
||||
Pellentesque venenatis nulla ut mi aliquet feugiat. Cras semper vel magna nec pharetra. Integer mattis felis et sapien commodo imperdiet. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Duis quis luctus felis. Vestibulum justo nibh, aliquam non lectus vitae, molestie placerat justo. Donec lorem nibh, gravida sit amet hendrerit ac, maximus id ipsum. Nunc ac libero sodales risus eleifend sagittis. Phasellus est massa, lobortis elementum ex sed, scelerisque consectetur neque. Nunc faucibus neque id lorem malesuada, eget convallis ex mattis.
|
||||
|
||||
Sed turpis tortor, fermentum non turpis id, posuere varius nibh. Donec iaculis lorem dui. Etiam eros ante, sodales eget venenatis at, consectetur eget risus. Curabitur non aliquam ante, a pretium justo. Maecenas tempor nisl tortor, vitae dictum nisi ultrices eu. Duis eget dui ultrices, porttitor lacus sed, lobortis purus. Quisque mattis elit nec neque sagittis, sed commodo leo blandit. Mauris sodales interdum eleifend. Vestibulum condimentum consectetur augue, id luctus diam convallis et.
|
||||
|
||||
Nunc suscipit risus in justo accumsan, a placerat magna tincidunt. Proin a nisl ipsum. Sed libero dui, tristique in augue quis, auctor tristique risus. Sed porttitor ex augue, eu porta augue molestie a. Duis rhoncus purus libero, eu tempus turpis condimentum at. Sed mollis nisi id lectus placerat tincidunt. Maecenas non scelerisque elit, quis rutrum orci. Donec in tellus pharetra urna ornare lobortis. Phasellus id risus at nisi varius rutrum eu ut turpis.
|
||||
|
||||
Duis dictum justo quis nisl porta, eget tincidunt magna suscipit. Sed velit massa, ullamcorper eu sodales ac, pretium a massa. Duis et rutrum tortor. Nulla accumsan hendrerit sapien, cursus volutpat eros egestas eget. Donec sollicitudin at ante quis sollicitudin. Aenean blandit feugiat diam, id feugiat eros faucibus eget. Donec viverra dolor vel justo scelerisque dignissim. Nulla semper sem nunc, rhoncus semper tellus ultricies sed. Duis in ornare diam. Donec vehicula feugiat varius. Maecenas ut suscipit est. Vivamus sem sem, finibus at dolor sit amet, euismod dapibus ligula. Vestibulum fringilla odio dapibus, congue massa eget, congue sem. Donec feugiat magna eget tortor lacinia scelerisque non et ipsum.
|
||||
|
||||
Suspendisse potenti. Nunc convallis sollicitudin ex eget venenatis. Sed iaculis nibh ex, vel ornare ligula congue dignissim. Quisque sollicitudin dolor ac dui vestibulum, sit amet molestie nisi aliquet. Donec at risus felis. Aenean sollicitudin metus a feugiat porta. Aenean a tortor ut dolor cursus sagittis. Vivamus consectetur porttitor nunc in facilisis. Proin sit amet mi vel lectus consectetur ultrices.
|
||||
|
||||
Sed cursus lectus vitae nunc tristique, nec commodo turpis dapibus. Pellentesque luctus ex id facilisis ornare. Morbi quis placerat dolor. Donec in lectus in arcu mattis porttitor ac sit amet metus. Cras congue mauris non risus sodales, vitae feugiat ipsum bibendum. Nulla venenatis urna sed libero elementum, a cursus lorem commodo. Mauris faucibus lobortis eros nec commodo.
|
||||
|
||||
Nullam suscipit ligula ullamcorper lorem commodo blandit. Nulla porta nibh quis pulvinar placerat. Vivamus eu arcu justo. Vestibulum imperdiet est ut fermentum porttitor. Pellentesque consectetur libero in sapien efficitur scelerisque. Curabitur ac erat sit amet odio aliquet dignissim. Pellentesque mi sem, rhoncus et luctus at, porttitor rutrum lectus. Vestibulum sollicitudin sollicitudin suscipit. Aenean efficitur dolor non ultrices imperdiet. Donec vel sem ex.
|
||||
|
||||
Sed convallis mauris aliquam rutrum cursus. Ut tempor porttitor sodales. Etiam eu risus ac augue gravida egestas et eu dolor. Proin id magna ex. Suspendisse quis lectus quis lorem ultricies tempus. Donec porttitor velit vitae tincidunt faucibus. Aliquam vitae semper nisi. Morbi ultrices, leo non pretium dapibus, dui libero pellentesque ex, vel placerat enim ante vitae dui. Nunc varius, sem sit amet sagittis lobortis, lectus odio scelerisque mauris, ut vestibulum orci magna quis neque. Sed id congue justo. Interdum et malesuada fames ac ante ipsum primis in faucibus. Mauris congue nisi est, malesuada mollis elit tincidunt sed. Curabitur sed ex sit amet felis tristique elementum vitae vel nibh.
|
||||
|
||||
Etiam mollis pretium lobortis. Mauris augue lacus, efficitur at lacus sed, mollis tincidunt lectus. Aliquam erat volutpat. Donec at euismod elit, et mattis felis. Sed id lobortis urna. Morbi imperdiet vestibulum leo, sed maximus leo blandit eu. Aliquam semper lorem neque, nec euismod turpis mattis mollis. Quisque lobortis urna ultrices odio pretium, ac venenatis orci faucibus. Suspendisse bibendum odio ligula, sed lobortis massa pharetra nec. Donec turpis justo, iaculis at dictum ac, finibus eu libero. Maecenas quis porttitor mi, sit amet aliquet neque.
|
||||
|
||||
Vivamus auctor vulputate ante, at egestas lorem. Donec eu risus in nulla mollis ultricies at et urna. Duis accumsan porta egestas. Ut vel euismod augue. Fusce convallis nulla ante, nec fringilla velit aliquet at. Nam malesuada dapibus ligula, a aliquam nibh scelerisque ac. Praesent malesuada neque et pellentesque interdum. Curabitur volutpat at turpis vitae tristique. Vivamus porttitor semper congue. Quisque suscipit lacus mi, rhoncus ultrices tortor auctor quis. Maecenas neque neque, molestie ac facilisis eget, luctus ac lorem. In ut odio ut lacus suscipit pulvinar vitae sed elit. Nulla imperdiet, sem quis euismod sagittis, dui erat luctus dolor, faucibus faucibus erat sem eget nunc. Nam accumsan placerat malesuada. Maecenas convallis finibus pulvinar.
|
||||
|
||||
Cras at placerat tortor. Morbi facilisis auctor felis sit amet molestie. Donec sodales sed lorem vitae suscipit. Etiam fermentum pharetra ipsum, nec luctus orci gravida eu. Pellentesque gravida, est non condimentum tempus, mauris ligula molestie est, in congue dolor nisl vel sapien. Duis congue tempor augue, id rutrum eros porta dapibus. Etiam rutrum eget est eget vestibulum. Aenean mollis arcu vel consequat varius. Praesent at condimentum felis. Duis nec interdum nisl. Donec commodo lorem sed sapien scelerisque malesuada non eu urna. In blandit non ipsum at porta. Nam lobortis leo vitae dui auctor, non feugiat quam bibendum. Donec auctor lectus sagittis laoreet maximus. Maecenas rhoncus laoreet porttitor. Vestibulum porttitor augue ut lectus hendrerit, eget posuere mi gravida.
|
||||
|
||||
Sed mattis ex in erat pulvinar, eu imperdiet magna dapibus. Etiam nisi nibh, tempus non tellus sit amet, mattis tempor odio. Quisque nec lorem feugiat, lobortis odio et, commodo nunc. Maecenas semper purus nisi, nec vehicula nibh eleifend vitae. Nulla fermentum a lectus at maximus. Phasellus finibus metus non euismod ultrices. Etiam a pulvinar ante. Quisque convallis nec metus sit amet facilisis. Praesent laoreet massa et sollicitudin laoreet. Vestibulum in mauris aliquet, convallis mi ut, elementum purus. Nulla purus nulla, sodales at hendrerit quis, tempus sed lectus.
|
||||
|
||||
Nam ut laoreet neque, ut maximus nibh. Maecenas quis justo pellentesque, sollicitudin elit at, venenatis velit. Aenean nunc velit, vehicula scelerisque odio at, consectetur laoreet purus. Duis dui purus, malesuada quis ipsum sit amet, tempor interdum libero. Curabitur porta scelerisque sapien, vitae cursus diam condimentum eu. Phasellus sed orci quam. Nullam vitae dui quis purus tincidunt vestibulum. Curabitur quis nulla porta, cursus arcu non, auctor enim. Etiam sollicitudin ex id sem vehicula mollis. Morbi viverra laoreet tincidunt. Praesent ut semper dui. Nam sit amet pretium neque. Mauris vitae luctus diam, in lacinia purus. Maecenas ut placerat justo, ut porta felis. Integer eu mauris ante.
|
||||
|
||||
Aenean porttitor tellus diam, tempor consequat metus efficitur id. Suspendisse ut felis at erat tempor dictum at nec sapien. Sed vestibulum interdum felis, ac mattis mauris porta in. Nunc et condimentum massa. Sed cursus dictum justo et luctus. Integer convallis enim nisl, a rutrum lectus ultricies in. Donec dapibus lacus at nulla dapibus, id sollicitudin velit hendrerit. Fusce a magna at orci mollis rutrum ac a dolor. Aliquam erat volutpat. Morbi varius porta nunc, sit amet sodales ex hendrerit commodo. Donec tincidunt tortor sapien, vitae egestas sapien vehicula eget.
|
||||
|
||||
Suspendisse potenti. Donec pulvinar felis nec leo malesuada interdum. Integer posuere placerat maximus. Donec nibh ipsum, tincidunt vitae luctus vitae, bibendum at leo. Sed cursus nisl ut ex faucibus aliquet sed nec eros. Curabitur molestie posuere felis. Integer faucibus velit eget consequat iaculis. Mauris sed vulputate odio. Phasellus maximus, elit a pharetra egestas, lorem magna semper tellus, vestibulum semper diam felis at sapien. Suspendisse facilisis, nisl sit amet euismod vehicula, libero nulla vehicula dolor, quis fermentum nibh elit sit amet diam.
|
||||
|
||||
Morbi lorem enim, euismod eu varius ut, scelerisque quis odio. Nam tempus vitae eros id molestie. Nunc pretium in nulla eget accumsan. Quisque mattis est ut semper aliquet. Maecenas eget diam elementum, fermentum ipsum a, euismod sapien. Duis quam ligula, cursus et velit nec, ullamcorper tincidunt magna. Donec vulputate nisl est, et ullamcorper urna tempor sit amet.
|
||||
|
||||
Proin lacinia dui non turpis congue pretium. Morbi posuere metus vel purus imperdiet interdum. Morbi venenatis vel eros non ultricies. Nulla vel semper elit. Ut quis purus tincidunt, auctor justo ut, faucibus turpis. Proin quis mattis erat, at faucibus ligula. Mauris in mauris enim. Donec facilisis enim at est feugiat hendrerit. Nam vel nisi lorem. Fusce ultricies convallis diam, in feugiat tortor luctus quis. Donec tempor, leo vitae volutpat aliquam, magna elit feugiat leo, quis placerat sapien felis eget arcu. Donec ornare fermentum eleifend. Integer a est orci.
|
||||
|
||||
Proin rhoncus egestas leo. Nulla ultricies porta elit quis ornare. Nunc fermentum interdum vehicula. In in ligula lorem. Donec nec arcu sit amet orci lobortis iaculis. Mauris at mollis erat, sit amet mollis tortor. Mauris laoreet justo ullamcorper porttitor auctor. Aenean sit amet aliquam lectus, id fermentum eros. Praesent urna sem, vehicula ac fermentum id, dapibus ut purus. Vestibulum vitae tempus nunc. Donec at nunc ornare metus volutpat porta at eget magna. Donec varius aliquet metus, eu lobortis risus aliquam sed. Ut dapibus fermentum velit, ac tincidunt libero faucibus at.
|
||||
|
||||
In in purus auctor, feugiat massa quis, facilisis nisi. Donec dolor purus, gravida eget dolor ac, porttitor imperdiet urna. Donec faucibus placerat erat, a sagittis ante finibus ac. Sed venenatis dignissim elit, in iaculis felis posuere faucibus. Praesent sed viverra dolor. Mauris sed nulla consectetur nunc laoreet molestie in ut metus. Proin ac ex sit amet magna vulputate hendrerit ac condimentum urna. Proin ligula metus, gravida et sollicitudin facilisis, iaculis ut odio. Cras tincidunt urna et augue varius, ut facilisis urna consequat. Aenean vehicula finibus quam. Ut iaculis eu diam ac mollis. Nam mi lorem, tristique eget varius at, sodales at urna.
|
||||
|
||||
Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Proin vitae dictum erat, et auctor ipsum. Nullam nunc nunc, sollicitudin quis magna a, vestibulum fermentum mauris. Praesent at erat dolor. Proin laoreet tristique nulla vel efficitur. Nam sed ultrices nibh, id rutrum nunc. Curabitur eleifend a erat sit amet sollicitudin. Nullam metus quam, laoreet vitae dapibus id, placerat sed leo. Aliquam erat volutpat. Donec turpis nisl, cursus eu ex sit amet, lacinia pellentesque nisl. Sed id ipsum massa. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec interdum scelerisque lorem eu mattis.
|
||||
|
||||
Vivamus ac tristique massa, nec facilisis nisl. Nam ipsum neque, tincidunt vel urna in, cursus imperdiet enim. Nam pellentesque egestas tempus. Morbi facilisis imperdiet libero vitae fringilla. Nam lacinia ligula at sapien facilisis malesuada. Nullam accumsan pulvinar sem, et cursus libero porta sit amet. Curabitur vulputate erat elit, ut pulvinar erat maximus vel.
|
||||
|
||||
Cras aliquet metus ut purus sagittis, vel venenatis ante consectetur. Pellentesque nulla lacus, viverra viverra mattis non, placerat vitae nibh. Donec enim turpis, accumsan sit amet tincidunt eu, imperdiet non metus. Morbi ipsum eros, tincidunt vel est ac, tristique porttitor nibh. Praesent ut ullamcorper mauris. Sed laoreet sit amet diam congue venenatis. Integer porta purus nec orci sagittis posuere.
|
||||
|
||||
Donec vehicula mauris eget lacus mollis venenatis et sed nibh. Nam sodales ligula ipsum, scelerisque lacinia ligula sagittis in. Nam sit amet ipsum at erat malesuada congue. Aenean ut sollicitudin sapien. Etiam at tempor odio. Mauris vitae purus ut magna suscipit consequat. Vivamus quis sapien neque. Nulla vulputate sem sit amet massa pellentesque, eleifend tristique ligula egestas. Suspendisse tincidunt gravida mi, in pulvinar lectus egestas non. Aenean imperdiet ex sit amet nunc sollicitudin porta. Integer justo odio, ultricies at interdum in, rhoncus vitae sem. Sed porttitor arcu quis purus aliquet hendrerit. Praesent tempor tortor at dolor dictum pulvinar. Nulla aliquet nunc non ligula scelerisque accumsan. Donec nulla justo, congue vitae massa in, faucibus hendrerit magna. Donec non egestas purus.
|
||||
|
||||
Vivamus iaculis, lacus efficitur faucibus porta, dui nulla facilisis ligula, ut sodales odio nunc id sapien. Cras viverra auctor ipsum, dapibus mattis neque dictum sed. Sed convallis fermentum molestie. Nulla facilisi turpis duis.
|
||||
@@ -0,0 +1 @@
|
||||
Small File
|
||||
@@ -0,0 +1 @@
|
||||
Small File with Ümlaut
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
This is some UTF 8 with BOM file.
|
||||
227
src/vs/platform/files/test/node/normalizer.test.ts
Normal file
227
src/vs/platform/files/test/node/normalizer.test.ts
Normal file
@@ -0,0 +1,227 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 * as platform from 'vs/base/common/platform';
|
||||
import { FileChangeType, FileChangesEvent } from 'vs/platform/files/common/files';
|
||||
import { URI as uri } from 'vs/base/common/uri';
|
||||
import { IDiskFileChange, normalizeFileChanges, toFileChanges } from 'vs/platform/files/node/watcher/watcher';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
|
||||
function toFileChangesEvent(changes: IDiskFileChange[]): FileChangesEvent {
|
||||
return new FileChangesEvent(toFileChanges(changes));
|
||||
}
|
||||
|
||||
class TestFileWatcher {
|
||||
private readonly _onFileChanges: Emitter<FileChangesEvent>;
|
||||
|
||||
constructor() {
|
||||
this._onFileChanges = new Emitter<FileChangesEvent>();
|
||||
}
|
||||
|
||||
get onFileChanges(): Event<FileChangesEvent> {
|
||||
return this._onFileChanges.event;
|
||||
}
|
||||
|
||||
report(changes: IDiskFileChange[]): void {
|
||||
this.onRawFileEvents(changes);
|
||||
}
|
||||
|
||||
private onRawFileEvents(events: IDiskFileChange[]): void {
|
||||
|
||||
// Normalize
|
||||
let normalizedEvents = normalizeFileChanges(events);
|
||||
|
||||
// Emit through event emitter
|
||||
if (normalizedEvents.length > 0) {
|
||||
this._onFileChanges.fire(toFileChangesEvent(normalizedEvents));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum Path {
|
||||
UNIX,
|
||||
WINDOWS,
|
||||
UNC
|
||||
}
|
||||
|
||||
suite('Normalizer', () => {
|
||||
|
||||
test('simple add/update/delete', function (done: () => void) {
|
||||
const watch = new TestFileWatcher();
|
||||
|
||||
const added = uri.file('/users/data/src/added.txt');
|
||||
const updated = uri.file('/users/data/src/updated.txt');
|
||||
const deleted = uri.file('/users/data/src/deleted.txt');
|
||||
|
||||
const raw: IDiskFileChange[] = [
|
||||
{ path: added.fsPath, type: FileChangeType.ADDED },
|
||||
{ path: updated.fsPath, type: FileChangeType.UPDATED },
|
||||
{ path: deleted.fsPath, type: FileChangeType.DELETED },
|
||||
];
|
||||
|
||||
watch.onFileChanges(e => {
|
||||
assert.ok(e);
|
||||
assert.equal(e.changes.length, 3);
|
||||
assert.ok(e.contains(added, FileChangeType.ADDED));
|
||||
assert.ok(e.contains(updated, FileChangeType.UPDATED));
|
||||
assert.ok(e.contains(deleted, FileChangeType.DELETED));
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
watch.report(raw);
|
||||
});
|
||||
|
||||
let pathSpecs = platform.isWindows ? [Path.WINDOWS, Path.UNC] : [Path.UNIX];
|
||||
pathSpecs.forEach((p) => {
|
||||
test('delete only reported for top level folder (' + p + ')', function (done: () => void) {
|
||||
const watch = new TestFileWatcher();
|
||||
|
||||
const deletedFolderA = uri.file(p === Path.UNIX ? '/users/data/src/todelete1' : p === Path.WINDOWS ? 'C:\\users\\data\\src\\todelete1' : '\\\\localhost\\users\\data\\src\\todelete1');
|
||||
const deletedFolderB = uri.file(p === Path.UNIX ? '/users/data/src/todelete2' : p === Path.WINDOWS ? 'C:\\users\\data\\src\\todelete2' : '\\\\localhost\\users\\data\\src\\todelete2');
|
||||
const deletedFolderBF1 = uri.file(p === Path.UNIX ? '/users/data/src/todelete2/file.txt' : p === Path.WINDOWS ? 'C:\\users\\data\\src\\todelete2\\file.txt' : '\\\\localhost\\users\\data\\src\\todelete2\\file.txt');
|
||||
const deletedFolderBF2 = uri.file(p === Path.UNIX ? '/users/data/src/todelete2/more/test.txt' : p === Path.WINDOWS ? 'C:\\users\\data\\src\\todelete2\\more\\test.txt' : '\\\\localhost\\users\\data\\src\\todelete2\\more\\test.txt');
|
||||
const deletedFolderBF3 = uri.file(p === Path.UNIX ? '/users/data/src/todelete2/super/bar/foo.txt' : p === Path.WINDOWS ? 'C:\\users\\data\\src\\todelete2\\super\\bar\\foo.txt' : '\\\\localhost\\users\\data\\src\\todelete2\\super\\bar\\foo.txt');
|
||||
const deletedFileA = uri.file(p === Path.UNIX ? '/users/data/src/deleteme.txt' : p === Path.WINDOWS ? 'C:\\users\\data\\src\\deleteme.txt' : '\\\\localhost\\users\\data\\src\\deleteme.txt');
|
||||
|
||||
const addedFile = uri.file(p === Path.UNIX ? '/users/data/src/added.txt' : p === Path.WINDOWS ? 'C:\\users\\data\\src\\added.txt' : '\\\\localhost\\users\\data\\src\\added.txt');
|
||||
const updatedFile = uri.file(p === Path.UNIX ? '/users/data/src/updated.txt' : p === Path.WINDOWS ? 'C:\\users\\data\\src\\updated.txt' : '\\\\localhost\\users\\data\\src\\updated.txt');
|
||||
|
||||
const raw: IDiskFileChange[] = [
|
||||
{ path: deletedFolderA.fsPath, type: FileChangeType.DELETED },
|
||||
{ path: deletedFolderB.fsPath, type: FileChangeType.DELETED },
|
||||
{ path: deletedFolderBF1.fsPath, type: FileChangeType.DELETED },
|
||||
{ path: deletedFolderBF2.fsPath, type: FileChangeType.DELETED },
|
||||
{ path: deletedFolderBF3.fsPath, type: FileChangeType.DELETED },
|
||||
{ path: deletedFileA.fsPath, type: FileChangeType.DELETED },
|
||||
{ path: addedFile.fsPath, type: FileChangeType.ADDED },
|
||||
{ path: updatedFile.fsPath, type: FileChangeType.UPDATED }
|
||||
];
|
||||
|
||||
watch.onFileChanges(e => {
|
||||
assert.ok(e);
|
||||
assert.equal(e.changes.length, 5);
|
||||
|
||||
assert.ok(e.contains(deletedFolderA, FileChangeType.DELETED));
|
||||
assert.ok(e.contains(deletedFolderB, FileChangeType.DELETED));
|
||||
assert.ok(e.contains(deletedFileA, FileChangeType.DELETED));
|
||||
assert.ok(e.contains(addedFile, FileChangeType.ADDED));
|
||||
assert.ok(e.contains(updatedFile, FileChangeType.UPDATED));
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
watch.report(raw);
|
||||
});
|
||||
});
|
||||
|
||||
test('event normalization: ignore CREATE followed by DELETE', function (done: () => void) {
|
||||
const watch = new TestFileWatcher();
|
||||
|
||||
const created = uri.file('/users/data/src/related');
|
||||
const deleted = uri.file('/users/data/src/related');
|
||||
const unrelated = uri.file('/users/data/src/unrelated');
|
||||
|
||||
const raw: IDiskFileChange[] = [
|
||||
{ path: created.fsPath, type: FileChangeType.ADDED },
|
||||
{ path: deleted.fsPath, type: FileChangeType.DELETED },
|
||||
{ path: unrelated.fsPath, type: FileChangeType.UPDATED },
|
||||
];
|
||||
|
||||
watch.onFileChanges(e => {
|
||||
assert.ok(e);
|
||||
assert.equal(e.changes.length, 1);
|
||||
|
||||
assert.ok(e.contains(unrelated, FileChangeType.UPDATED));
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
watch.report(raw);
|
||||
});
|
||||
|
||||
test('event normalization: flatten DELETE followed by CREATE into CHANGE', function (done: () => void) {
|
||||
const watch = new TestFileWatcher();
|
||||
|
||||
const deleted = uri.file('/users/data/src/related');
|
||||
const created = uri.file('/users/data/src/related');
|
||||
const unrelated = uri.file('/users/data/src/unrelated');
|
||||
|
||||
const raw: IDiskFileChange[] = [
|
||||
{ path: deleted.fsPath, type: FileChangeType.DELETED },
|
||||
{ path: created.fsPath, type: FileChangeType.ADDED },
|
||||
{ path: unrelated.fsPath, type: FileChangeType.UPDATED },
|
||||
];
|
||||
|
||||
watch.onFileChanges(e => {
|
||||
assert.ok(e);
|
||||
assert.equal(e.changes.length, 2);
|
||||
|
||||
assert.ok(e.contains(deleted, FileChangeType.UPDATED));
|
||||
assert.ok(e.contains(unrelated, FileChangeType.UPDATED));
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
watch.report(raw);
|
||||
});
|
||||
|
||||
test('event normalization: ignore UPDATE when CREATE received', function (done: () => void) {
|
||||
const watch = new TestFileWatcher();
|
||||
|
||||
const created = uri.file('/users/data/src/related');
|
||||
const updated = uri.file('/users/data/src/related');
|
||||
const unrelated = uri.file('/users/data/src/unrelated');
|
||||
|
||||
const raw: IDiskFileChange[] = [
|
||||
{ path: created.fsPath, type: FileChangeType.ADDED },
|
||||
{ path: updated.fsPath, type: FileChangeType.UPDATED },
|
||||
{ path: unrelated.fsPath, type: FileChangeType.UPDATED },
|
||||
];
|
||||
|
||||
watch.onFileChanges(e => {
|
||||
assert.ok(e);
|
||||
assert.equal(e.changes.length, 2);
|
||||
|
||||
assert.ok(e.contains(created, FileChangeType.ADDED));
|
||||
assert.ok(!e.contains(created, FileChangeType.UPDATED));
|
||||
assert.ok(e.contains(unrelated, FileChangeType.UPDATED));
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
watch.report(raw);
|
||||
});
|
||||
|
||||
test('event normalization: apply DELETE', function (done: () => void) {
|
||||
const watch = new TestFileWatcher();
|
||||
|
||||
const updated = uri.file('/users/data/src/related');
|
||||
const updated2 = uri.file('/users/data/src/related');
|
||||
const deleted = uri.file('/users/data/src/related');
|
||||
const unrelated = uri.file('/users/data/src/unrelated');
|
||||
|
||||
const raw: IDiskFileChange[] = [
|
||||
{ path: updated.fsPath, type: FileChangeType.UPDATED },
|
||||
{ path: updated2.fsPath, type: FileChangeType.UPDATED },
|
||||
{ path: unrelated.fsPath, type: FileChangeType.UPDATED },
|
||||
{ path: updated.fsPath, type: FileChangeType.DELETED }
|
||||
];
|
||||
|
||||
watch.onFileChanges(e => {
|
||||
assert.ok(e);
|
||||
assert.equal(e.changes.length, 2);
|
||||
|
||||
assert.ok(e.contains(deleted, FileChangeType.DELETED));
|
||||
assert.ok(!e.contains(updated, FileChangeType.UPDATED));
|
||||
assert.ok(e.contains(unrelated, FileChangeType.UPDATED));
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
watch.report(raw);
|
||||
});
|
||||
});
|
||||
@@ -34,15 +34,15 @@ export interface IRecentFile {
|
||||
}
|
||||
|
||||
export function isRecentWorkspace(curr: IRecent): curr is IRecentWorkspace {
|
||||
return !!curr['workspace'];
|
||||
return curr.hasOwnProperty('workspace');
|
||||
}
|
||||
|
||||
export function isRecentFolder(curr: IRecent): curr is IRecentFolder {
|
||||
return !!curr['folderUri'];
|
||||
return curr.hasOwnProperty('folderUri');
|
||||
}
|
||||
|
||||
export function isRecentFile(curr: IRecent): curr is IRecentFile {
|
||||
return !!curr['fileUri'];
|
||||
return curr.hasOwnProperty('fileUri');
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { UriComponents, URI } from 'vs/base/common/uri';
|
||||
import { IRecentlyOpened, isRecentFolder } from 'vs/platform/history/common/history';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
|
||||
interface ISerializedRecentlyOpened {
|
||||
workspaces3: Array<ISerializedWorkspace | string>; // workspace or URI.toString() // added in 1.32
|
||||
@@ -21,59 +22,74 @@ interface ILegacySerializedRecentlyOpened {
|
||||
interface ISerializedWorkspace { id: string; configURIPath: string; }
|
||||
interface ILegacySerializedWorkspace { id: string; configPath: string; }
|
||||
|
||||
function isLegacySerializedWorkspace(curr: any): curr is ILegacySerializedWorkspace {
|
||||
return typeof curr === 'object' && typeof curr['id'] === 'string' && typeof curr['configPath'] === 'string';
|
||||
}
|
||||
|
||||
function isUriComponents(curr: any): curr is UriComponents {
|
||||
return curr && typeof curr['path'] === 'string' && typeof curr['scheme'] === 'string';
|
||||
}
|
||||
|
||||
export type RecentlyOpenedStorageData = object;
|
||||
|
||||
export function restoreRecentlyOpened(data: RecentlyOpenedStorageData | undefined): IRecentlyOpened {
|
||||
export function restoreRecentlyOpened(data: RecentlyOpenedStorageData | undefined, logService: ILogService): IRecentlyOpened {
|
||||
const result: IRecentlyOpened = { workspaces: [], files: [] };
|
||||
if (data) {
|
||||
const restoreGracefully = function <T>(entries: T[], func: (entry: T, index: number) => void) {
|
||||
for (let i = 0; i < entries.length; i++) {
|
||||
try {
|
||||
func(entries[i], i);
|
||||
} catch (e) {
|
||||
logService.warn(`Error restoring recent entry ${JSON.stringify(entries[i])}: ${e.toString()}. Skip entry.`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const storedRecents = data as ISerializedRecentlyOpened & ILegacySerializedRecentlyOpened;
|
||||
if (Array.isArray(storedRecents.workspaces3)) {
|
||||
for (let i = 0; i < storedRecents.workspaces3.length; i++) {
|
||||
const workspace = storedRecents.workspaces3[i];
|
||||
restoreGracefully(storedRecents.workspaces3, (workspace, i) => {
|
||||
const label: string | undefined = (Array.isArray(storedRecents.workspaceLabels) && storedRecents.workspaceLabels[i]) || undefined;
|
||||
if (typeof workspace === 'object' && typeof workspace.id === 'string' && typeof workspace.configURIPath === 'string') {
|
||||
result.workspaces.push({ label, workspace: { id: workspace.id, configPath: URI.parse(workspace.configURIPath) } });
|
||||
} else if (typeof workspace === 'string') {
|
||||
result.workspaces.push({ label, folderUri: URI.parse(workspace) });
|
||||
}
|
||||
}
|
||||
});
|
||||
} else if (Array.isArray(storedRecents.workspaces2)) {
|
||||
for (const workspace of storedRecents.workspaces2) {
|
||||
restoreGracefully(storedRecents.workspaces2, workspace => {
|
||||
if (typeof workspace === 'object' && typeof workspace.id === 'string' && typeof workspace.configPath === 'string') {
|
||||
result.workspaces.push({ workspace: { id: workspace.id, configPath: URI.file(workspace.configPath) } });
|
||||
} else if (typeof workspace === 'string') {
|
||||
result.workspaces.push({ folderUri: URI.parse(workspace) });
|
||||
}
|
||||
}
|
||||
});
|
||||
} else if (Array.isArray(storedRecents.workspaces)) {
|
||||
// TODO@martin legacy support can be removed at some point (6 month?)
|
||||
// format of 1.25 and before
|
||||
for (const workspace of storedRecents.workspaces) {
|
||||
restoreGracefully(storedRecents.workspaces, workspace => {
|
||||
if (typeof workspace === 'string') {
|
||||
result.workspaces.push({ folderUri: URI.file(workspace) });
|
||||
} else if (typeof workspace === 'object' && typeof workspace['id'] === 'string' && typeof workspace['configPath'] === 'string') {
|
||||
result.workspaces.push({ workspace: { id: workspace['id'], configPath: URI.file(workspace['configPath']) } });
|
||||
} else if (workspace && typeof workspace['path'] === 'string' && typeof workspace['scheme'] === 'string') {
|
||||
} else if (isLegacySerializedWorkspace(workspace)) {
|
||||
result.workspaces.push({ workspace: { id: workspace.id, configPath: URI.file(workspace.configPath) } });
|
||||
} else if (isUriComponents(window)) {
|
||||
// added by 1.26-insiders
|
||||
result.workspaces.push({ folderUri: URI.revive(<UriComponents>workspace) });
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (Array.isArray(storedRecents.files2)) {
|
||||
for (let i = 0; i < storedRecents.files2.length; i++) {
|
||||
const file = storedRecents.files2[i];
|
||||
restoreGracefully(storedRecents.files2, (file, i) => {
|
||||
const label: string | undefined = (Array.isArray(storedRecents.fileLabels) && storedRecents.fileLabels[i]) || undefined;
|
||||
if (typeof file === 'string') {
|
||||
result.files.push({ label, fileUri: URI.parse(file) });
|
||||
}
|
||||
}
|
||||
});
|
||||
} else if (Array.isArray(storedRecents.files)) {
|
||||
for (const file of storedRecents.files) {
|
||||
restoreGracefully(storedRecents.files, file => {
|
||||
if (typeof file === 'string') {
|
||||
result.files.push({ fileUri: URI.file(file) });
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,14 +20,17 @@ import { URI } from 'vs/base/common/uri';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { getSimpleWorkspaceLabel } from 'vs/platform/label/common/label';
|
||||
import { toStoreData, restoreRecentlyOpened, RecentlyOpenedStorageData } from 'vs/platform/history/electron-main/historyStorage';
|
||||
import { toStoreData, restoreRecentlyOpened, RecentlyOpenedStorageData } from 'vs/platform/history/common/historyStorage';
|
||||
import { exists } from 'vs/base/node/pfs';
|
||||
import { ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ILifecycleService, LifecycleMainPhase } from 'vs/platform/lifecycle/electron-main/lifecycleMain';
|
||||
|
||||
export class HistoryMainService implements IHistoryMainService {
|
||||
|
||||
private static readonly MAX_TOTAL_RECENT_ENTRIES = 100;
|
||||
private static readonly MAX_MACOS_DOCK_RECENT_FOLDERS = 10;
|
||||
private static readonly MAX_MACOS_DOCK_RECENT_FILES = 5;
|
||||
|
||||
private static readonly MAX_MACOS_DOCK_RECENT_WORKSPACES = 7; // prefer more workspaces...
|
||||
private static readonly MAX_MACOS_DOCK_RECENT_ENTRIES_TOTAL = 10; // ...compared to files
|
||||
|
||||
// Exclude some very common files from the dock/taskbar
|
||||
private static readonly COMMON_FILES_FILTER = [
|
||||
@@ -37,10 +40,10 @@ export class HistoryMainService implements IHistoryMainService {
|
||||
|
||||
private static readonly recentlyOpenedStorageKey = 'openedPathsList';
|
||||
|
||||
_serviceBrand: any;
|
||||
_serviceBrand: ServiceIdentifier<IHistoryMainService>;
|
||||
|
||||
private _onRecentlyOpenedChange = new Emitter<void>();
|
||||
onRecentlyOpenedChange: CommonEvent<void> = this._onRecentlyOpenedChange.event;
|
||||
readonly onRecentlyOpenedChange: CommonEvent<void> = this._onRecentlyOpenedChange.event;
|
||||
|
||||
private macOSRecentDocumentsUpdater: ThrottledDelayer<void>;
|
||||
|
||||
@@ -48,9 +51,21 @@ export class HistoryMainService implements IHistoryMainService {
|
||||
@IStateService private readonly stateService: IStateService,
|
||||
@ILogService private readonly logService: ILogService,
|
||||
@IWorkspacesMainService private readonly workspacesMainService: IWorkspacesMainService,
|
||||
@IEnvironmentService private readonly environmentService: IEnvironmentService
|
||||
@IEnvironmentService private readonly environmentService: IEnvironmentService,
|
||||
@ILifecycleService lifecycleService: ILifecycleService
|
||||
) {
|
||||
this.macOSRecentDocumentsUpdater = new ThrottledDelayer<void>(800);
|
||||
|
||||
lifecycleService.when(LifecycleMainPhase.AfterWindowOpen).then(() => this.handleWindowsJumpList());
|
||||
}
|
||||
|
||||
private handleWindowsJumpList(): void {
|
||||
if (!isWindows) {
|
||||
return; // only on windows
|
||||
}
|
||||
|
||||
this.updateWindowsJumpList();
|
||||
this.onRecentlyOpenedChange(() => this.updateWindowsJumpList());
|
||||
}
|
||||
|
||||
addRecentlyOpened(newlyAdded: IRecent[]): void {
|
||||
@@ -139,37 +154,58 @@ export class HistoryMainService implements IHistoryMainService {
|
||||
return;
|
||||
}
|
||||
|
||||
// macOS recent documents in the dock are behaving strangely. the entries seem to get
|
||||
// out of sync quickly over time. the attempted fix is to always set the list fresh
|
||||
// from our MRU history data. So we clear the documents first and then set the documents
|
||||
// again.
|
||||
// We clear all documents first to ensure an up-to-date view on the set. Since entries
|
||||
// can get deleted on disk, this ensures that the list is always valid
|
||||
app.clearRecentDocuments();
|
||||
|
||||
const mru = this.getRecentlyOpened();
|
||||
|
||||
// Fill in workspaces
|
||||
for (let i = 0, entries = 0; i < mru.workspaces.length && entries < HistoryMainService.MAX_MACOS_DOCK_RECENT_FOLDERS; i++) {
|
||||
// Collect max-N recent workspaces that are known to exist
|
||||
const workspaceEntries: string[] = [];
|
||||
let entries = 0;
|
||||
for (let i = 0; i < mru.workspaces.length && entries < HistoryMainService.MAX_MACOS_DOCK_RECENT_WORKSPACES; i++) {
|
||||
const loc = location(mru.workspaces[i]);
|
||||
if (loc.scheme === Schemas.file) {
|
||||
const workspacePath = originalFSPath(loc);
|
||||
if (await exists(workspacePath)) {
|
||||
app.addRecentDocument(workspacePath);
|
||||
workspaceEntries.push(workspacePath);
|
||||
entries++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fill in files
|
||||
for (let i = 0, entries = 0; i < mru.files.length && entries < HistoryMainService.MAX_MACOS_DOCK_RECENT_FILES; i++) {
|
||||
// Collect max-N recent files that are known to exist
|
||||
const fileEntries: string[] = [];
|
||||
for (let i = 0; i < mru.files.length && entries < HistoryMainService.MAX_MACOS_DOCK_RECENT_ENTRIES_TOTAL; i++) {
|
||||
const loc = location(mru.files[i]);
|
||||
if (loc.scheme === Schemas.file && HistoryMainService.COMMON_FILES_FILTER.indexOf(basename(loc)) === -1) {
|
||||
if (loc.scheme === Schemas.file) {
|
||||
const filePath = originalFSPath(loc);
|
||||
if (
|
||||
HistoryMainService.COMMON_FILES_FILTER.indexOf(basename(loc)) !== -1 || // skip some well known file entries
|
||||
workspaceEntries.indexOf(filePath) !== -1 // prefer a workspace entry over a file entry (e.g. for .code-workspace)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (await exists(filePath)) {
|
||||
app.addRecentDocument(filePath);
|
||||
fileEntries.push(filePath);
|
||||
entries++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The apple guidelines (https://developer.apple.com/design/human-interface-guidelines/macos/menus/menu-anatomy/)
|
||||
// explain that most recent entries should appear close to the interaction by the user (e.g. close to the
|
||||
// mouse click). Most native macOS applications that add recent documents to the dock, show the most recent document
|
||||
// to the bottom (because the dock menu is not appearing from top to bottom, but from the bottom to the top). As such
|
||||
// we fill in the entries in reverse order so that the most recent shows up at the bottom of the menu.
|
||||
//
|
||||
// On top of that, the maximum number of documents can be configured by the user (defaults to 10). To ensure that
|
||||
// we are not failing to show the most recent entries, we start by adding files first (in reverse order of recency)
|
||||
// and then add folders (in reverse order of recency). Given that strategy, we can ensure that the most recent
|
||||
// N folders are always appearing, even if the limit is low (https://github.com/microsoft/vscode/issues/74788)
|
||||
fileEntries.reverse().forEach(fileEntry => app.addRecentDocument(fileEntry));
|
||||
workspaceEntries.reverse().forEach(workspaceEntry => app.addRecentDocument(workspaceEntry));
|
||||
}
|
||||
|
||||
clearRecentlyOpened(): void {
|
||||
@@ -234,7 +270,7 @@ export class HistoryMainService implements IHistoryMainService {
|
||||
private getRecentlyOpenedFromStorage(): IRecentlyOpened {
|
||||
const storedRecents = this.stateService.getItem<RecentlyOpenedStorageData>(HistoryMainService.recentlyOpenedStorageKey);
|
||||
|
||||
return restoreRecentlyOpened(storedRecents);
|
||||
return restoreRecentlyOpened(storedRecents, this.logService);
|
||||
}
|
||||
|
||||
private saveRecentlyOpened(recent: IRecentlyOpened): void {
|
||||
|
||||
@@ -9,7 +9,8 @@ import * as path from 'vs/base/common/path';
|
||||
import { IWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IRecentlyOpened, isRecentFolder, IRecentFolder, IRecentWorkspace } from 'vs/platform/history/common/history';
|
||||
import { toStoreData, restoreRecentlyOpened } from 'vs/platform/history/electron-main/historyStorage';
|
||||
import { toStoreData, restoreRecentlyOpened } from 'vs/platform/history/common/historyStorage';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
|
||||
function toWorkspace(uri: URI): IWorkspaceIdentifier {
|
||||
return {
|
||||
@@ -51,7 +52,7 @@ function assertEqualRecentlyOpened(actual: IRecentlyOpened, expected: IRecentlyO
|
||||
|
||||
function assertRestoring(state: IRecentlyOpened, message?: string) {
|
||||
const stored = toStoreData(state);
|
||||
const restored = restoreRecentlyOpened(stored);
|
||||
const restored = restoreRecentlyOpened(stored, new NullLogService());
|
||||
assertEqualRecentlyOpened(state, restored, message);
|
||||
}
|
||||
|
||||
@@ -118,7 +119,7 @@ suite('History Storage', () => {
|
||||
]
|
||||
}`;
|
||||
|
||||
let actual = restoreRecentlyOpened(JSON.parse(v1_25_win));
|
||||
let actual = restoreRecentlyOpened(JSON.parse(v1_25_win), new NullLogService());
|
||||
let expected: IRecentlyOpened = {
|
||||
files: [{ fileUri: URI.file('C:\\workspaces\\test.code-workspace') }, { fileUri: URI.file('C:\\workspaces\\testing\\test-ext\\.gitignore') }],
|
||||
workspaces: [
|
||||
@@ -146,7 +147,7 @@ suite('History Storage', () => {
|
||||
]
|
||||
}`;
|
||||
|
||||
let actual = restoreRecentlyOpened(JSON.parse(v1_31_win));
|
||||
let actual = restoreRecentlyOpened(JSON.parse(v1_31_win), new NullLogService());
|
||||
let expected: IRecentlyOpened = {
|
||||
files: [{ fileUri: URI.parse('file:///c%3A/workspaces/vscode/.yarnrc') }],
|
||||
workspaces: [
|
||||
@@ -173,7 +174,7 @@ suite('History Storage', () => {
|
||||
]
|
||||
}`;
|
||||
|
||||
let windowsState = restoreRecentlyOpened(JSON.parse(v1_32));
|
||||
let windowsState = restoreRecentlyOpened(JSON.parse(v1_32), new NullLogService());
|
||||
let expected: IRecentlyOpened = {
|
||||
files: [{ fileUri: URI.parse('file:///home/user/.config/code-oss-dev/storage.json') }],
|
||||
workspaces: [
|
||||
@@ -206,7 +207,7 @@ suite('History Storage', () => {
|
||||
]
|
||||
}`;
|
||||
|
||||
let windowsState = restoreRecentlyOpened(JSON.parse(v1_33));
|
||||
let windowsState = restoreRecentlyOpened(JSON.parse(v1_33), new NullLogService());
|
||||
let expected: IRecentlyOpened = {
|
||||
files: [{ label: 'def', fileUri: URI.parse('file:///home/user/.config/code-oss-dev/storage.json') }],
|
||||
workspaces: [
|
||||
|
||||
@@ -6,18 +6,12 @@
|
||||
import { SyncDescriptor } from './descriptors';
|
||||
import { ServiceIdentifier, IConstructorSignature0 } from './instantiation';
|
||||
|
||||
|
||||
export interface IServiceContribution<T> {
|
||||
id: ServiceIdentifier<T>;
|
||||
descriptor: SyncDescriptor<T>;
|
||||
}
|
||||
|
||||
const _registry: IServiceContribution<any>[] = [];
|
||||
const _registry: [ServiceIdentifier<any>, SyncDescriptor<any>][] = [];
|
||||
|
||||
export function registerSingleton<T>(id: ServiceIdentifier<T>, ctor: IConstructorSignature0<T>, supportsDelayedInstantiation?: boolean): void {
|
||||
_registry.push({ id, descriptor: new SyncDescriptor<T>(ctor, [], supportsDelayedInstantiation) });
|
||||
_registry.push([id, new SyncDescriptor<T>(ctor, [], supportsDelayedInstantiation)]);
|
||||
}
|
||||
|
||||
export function getServices(): IServiceContribution<any>[] {
|
||||
export function getSingletonServiceDescriptors(): [ServiceIdentifier<any>, SyncDescriptor<any>][] {
|
||||
return _registry;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,8 @@ export interface IConstructorSignature8<A1, A2, A3, A4, A5, A6, A7, A8, T> {
|
||||
}
|
||||
|
||||
export interface ServicesAccessor {
|
||||
get<T>(id: ServiceIdentifier<T>, isOptional?: typeof optional): T;
|
||||
get<T>(id: ServiceIdentifier<T>): T;
|
||||
get<T>(id: ServiceIdentifier<T>, isOptional: typeof optional): T | undefined;
|
||||
}
|
||||
|
||||
export const IInstantiationService = createDecorator<IInstantiationService>('instantiationService');
|
||||
@@ -114,11 +115,11 @@ export interface ServiceIdentifier<T> {
|
||||
}
|
||||
|
||||
function storeServiceDependency(id: Function, target: Function, index: number, optional: boolean): void {
|
||||
if (target[_util.DI_TARGET] === target) {
|
||||
target[_util.DI_DEPENDENCIES].push({ id, index, optional });
|
||||
if ((target as any)[_util.DI_TARGET] === target) {
|
||||
(target as any)[_util.DI_DEPENDENCIES].push({ id, index, optional });
|
||||
} else {
|
||||
target[_util.DI_DEPENDENCIES] = [{ id, index, optional }];
|
||||
target[_util.DI_TARGET] = target;
|
||||
(target as any)[_util.DI_DEPENDENCIES] = [{ id, index, optional }];
|
||||
(target as any)[_util.DI_TARGET] = target;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user