Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #7269: complete support vscode.workspace.fs API #7908

Merged
merged 1 commit into from
Aug 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .theia/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
},
"typescript.tsdk": "node_modules/typescript/lib",
"clang-format.language.typescript.enable": false
}
}
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@
- [output] `OutputWidget#setInput` has been removed. The _Output_ view automatically shows the channel when calling `OutputChannel#show`. Moved the `OutputCommands` namespace from the `output-contribution` to its dedicated `output-commands` module to overcome a DI cycle. [#8243](https://github.com/eclipse-theia/theia/pull/8243)
- [example app] updated yarn.lock so that the latest version of `vscode-ripgrep` is used (`v1.8.0`). This way we can benefit from the recently added support for it using proxy settings when fetching the platform-specific `ripgrep` executable, after npm package install. This should make it a lot easier to build our example application in corporate settings, behind a firewall. [#8280](https://github.com/eclipse-theia/theia/pull/8280)
- Note to downstream IDE designers: this change will not have an effect beyond this repo's example application. If it's desirable for your product to have the latest `vscode-ripgrep`, you should do similarly in your own `yarn.lock`.

<a name="1_4_0_deprecate_file_sytem"></a>
- [[filesystem]](#1_4_0_deprecate_file_sytem) `FileSystem` and `FileSystemWatcher` services are deprecated [#7908](https://github.com/eclipse-theia/theia/pull/7908)
- On the backend there is no anymore `FileSystem` implementation. One has to use Node.js APIs instead.
- On the frontend `FileService` should be used instead. It was ported from VS Code for compatibility with VS Code extensions.
- On the frontend `EnvVariableServer` should be used instead to access the current user home and available drives.
<a name="1_4_0_usestorage_as_fs_provider"></a>
- [[userstorage]](#1_4_0_usestorage_as_fs_provider) `UserStorageService` was replaced by the user data fs provider [#7908](https://github.com/eclipse-theia/theia/pull/7908)

## v1.4.0

Expand Down
2 changes: 1 addition & 1 deletion configs/base.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
"node_modules",
"*.d.ts"
]
}
}
4 changes: 1 addition & 3 deletions configs/errors.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"rules": {
"@typescript-eslint/class-name-casing": "error",
"@typescript-eslint/consistent-type-definitions": "error",
"@typescript-eslint/indent": "off",
"@typescript-eslint/no-explicit-any": "error",
Expand Down Expand Up @@ -35,7 +34,6 @@
"guard-for-in": "error",
"id-blacklist": "off",
"id-match": "off",
"import/no-deprecated": "error",
"import/no-extraneous-dependencies": "off",
"max-len": [
"error",
Expand Down Expand Up @@ -131,4 +129,4 @@
}
]
}
}
}
8 changes: 6 additions & 2 deletions configs/warnings.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"plugins": [
"deprecation"
],
"rules": {
"@typescript-eslint/await-thenable": "warn",
"no-return-await": "warn"
"no-return-await": "warn",
"deprecation/deprecation": "warn"
}
}
}
3 changes: 1 addition & 2 deletions examples/api-tests/src/find-replace.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ describe('Find and Replace', function () {

const { assert } = chai;

const Uri = require('@theia/core/lib/common/uri');
const { animationFrame } = require('@theia/core/lib/browser/browser');
const { DisposableCollection } = require('@theia/core/lib/common/disposable');
const { CommonCommands } = require('@theia/core/lib/browser/common-frontend-contribution');
Expand All @@ -40,7 +39,7 @@ describe('Find and Replace', function () {
const navigatorContribution = container.get(FileNavigatorContribution);
const shell = container.get(ApplicationShell);

const rootUri = new Uri.default(workspaceService.tryGetRoots()[0].uri);
const rootUri = workspaceService.tryGetRoots()[0].resource;
const fileUri = rootUri.resolve('webpack.config.js');

const toTearDown = new DisposableCollection();
Expand Down
3 changes: 1 addition & 2 deletions examples/api-tests/src/keybindings.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ describe('Keybindings', function () {
const { Deferred } = require('@theia/core/lib/common/promise-util');
const { Key } = require('@theia/core/lib/browser/keys');
const { EditorManager } = require('@theia/editor/lib/browser/editor-manager');
const Uri = require('@theia/core/lib/common/uri');
const { WorkspaceService } = require('@theia/workspace/lib/browser/workspace-service');

/** @type {import('inversify').Container} */
Expand Down Expand Up @@ -74,7 +73,7 @@ describe('Keybindings', function () {
when: 'false'
}));

const editor = await editorManager.open(new Uri.default(workspaceService.tryGetRoots()[0].uri).resolve('package.json'), {
const editor = await editorManager.open(workspaceService.tryGetRoots()[0].resource.resolve('package.json'), {
mode: 'activate',
selection: {
start: {
Expand Down
21 changes: 10 additions & 11 deletions examples/api-tests/src/launch-preferences.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ describe('Launch Preferences', function () {
const { assert } = chai;

const { PreferenceService, PreferenceScope } = require('@theia/core/lib/browser/preferences/preference-service');
const Uri = require('@theia/core/lib/common/uri');
const { WorkspaceService } = require('@theia/workspace/lib/browser/workspace-service');
const { FileSystem } = require('@theia/filesystem/lib/common/filesystem');
const { FileService } = require('@theia/filesystem/lib/browser/file-service');
const { FileResourceResolver } = require('@theia/filesystem/lib/browser/file-resource');
const { MonacoTextModelService } = require('@theia/monaco/lib/browser/monaco-text-model-service');
const { MonacoWorkspace } = require('@theia/monaco/lib/browser/monaco-workspace');

const container = window.theia.container;
/** @type {import('@theia/core/lib/browser/preferences/preference-service').PreferenceService} */
const preferences = container.get(PreferenceService);
const workspaceService = container.get(WorkspaceService);
/** @type {import('@theia/filesystem/lib/common/filesystem').FileSystem} */
const fileSystem = container.get(FileSystem);
const fileService = container.get(FileService);
const textModelService = container.get(MonacoTextModelService);
const workspace = container.get(MonacoWorkspace);
const fileResourceResolver = container.get(FileResourceResolver);

const defaultLaunch = {
'configurations': [],
Expand Down Expand Up @@ -388,7 +388,7 @@ describe('Launch Preferences', function () {

}

const rootUri = new Uri.default(workspaceService.tryGetRoots()[0].uri);
const rootUri = workspaceService.tryGetRoots()[0].resource;

function deleteWorkspacePreferences() {
const promises = [];
Expand Down Expand Up @@ -418,22 +418,21 @@ describe('Launch Preferences', function () {
}
return Promise.all([
...promises,
fileSystem.delete(rootUri.resolve('.theia').toString(), { moveToTrash: false }).catch(() => { }),
fileSystem.delete(rootUri.resolve('.vscode').toString(), { moveToTrash: false }).catch(() => { })
fileService.delete(rootUri.resolve('.theia'), { fromUserGesture: false, recursive: true }).catch(() => { }),
fileService.delete(rootUri.resolve('.vscode'), { fromUserGesture: false, recursive: true }).catch(() => { })
]);
}

const client = /** @type {import('@theia/filesystem/lib/common/filesystem').FileSystemClient} */ (fileSystem.getClient());
const originalShouldOverwrite = client.shouldOverwrite;
const originalShouldOverwrite = fileResourceResolver['shouldOverwrite'];

before(async () => {
// fail tests if out of async happens
client.shouldOverwrite = async () => (assert.fail('should be in sync'), false);
fileResourceResolver['shouldOverwrite'] = async () => (assert.fail('should be in sync'), false);
await deleteWorkspacePreferences();
});

after(() => {
client.shouldOverwrite = originalShouldOverwrite;
fileResourceResolver['shouldOverwrite'] = originalShouldOverwrite;
});

/**
Expand Down
11 changes: 5 additions & 6 deletions examples/api-tests/src/monaco-api.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ describe('Monaco API', async function () {
const { assert } = chai;

const { EditorManager } = require('@theia/editor/lib/browser/editor-manager');
const Uri = require('@theia/core/lib/common/uri');
const { WorkspaceService } = require('@theia/workspace/lib/browser/workspace-service');
const { MonacoEditor } = require('@theia/monaco/lib/browser/monaco-editor');
const { MonacoResolvedKeybinding } = require('@theia/monaco/lib/browser/monaco-resolved-keybinding');
Expand All @@ -39,7 +38,7 @@ describe('Monaco API', async function () {

before(async () => {
const root = workspaceService.tryGetRoots()[0];
const editor = await editorManager.open(new Uri.default(root.uri).resolve('package.json'), {
const editor = await editorManager.open(root.resource.resolve('package.json'), {
mode: 'reveal'
});
monacoEditor = /** @type {MonacoEditor} */ (MonacoEditor.get(editor));
Expand Down Expand Up @@ -67,11 +66,11 @@ describe('Monaco API', async function () {

const platform = window.navigator.platform;
let expected;
if (platform.includes("Mac")){
if (platform.includes('Mac')) {
// Mac os
expected = {
label: '⌃⇧⌥⌘K',
ariaLabel: "⌃⇧⌥⌘K",
ariaLabel: '⌃⇧⌥⌘K',
electronAccelerator: 'Ctrl+Shift+Alt+Cmd+K',
userSettingsLabel: 'ctrl+shift+alt+cmd+K',
WYSIWYG: true,
Expand All @@ -87,7 +86,7 @@ describe('Monaco API', async function () {
dispatchParts: [
'ctrl+shift+alt+meta+K'
]
}
};
} else {
expected = {
label: 'Ctrl+Shift+Alt+K',
Expand All @@ -107,7 +106,7 @@ describe('Monaco API', async function () {
dispatchParts: [
'ctrl+shift+alt+K'
]
}
};
}

assert.deepStrictEqual({
Expand Down
91 changes: 91 additions & 0 deletions examples/api-tests/src/navigator.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/********************************************************************************
* Copyright (C) 2020 TypeFox and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

// @ts-check
describe('Navigator', function () {

const { assert } = chai;

const { FileService } = require('@theia/filesystem/lib/browser/file-service');
const { DirNode, FileNode } = require('@theia/filesystem/lib/browser/file-tree/file-tree');
const { WorkspaceService } = require('@theia/workspace/lib/browser/workspace-service');
const { FileNavigatorContribution } = require('@theia/navigator/lib/browser/navigator-contribution');

/** @type {import('inversify').Container} */
const container = window['theia'].container;
const fileService = container.get(FileService);
const workspaceService = container.get(WorkspaceService);
const navigatorContribution = container.get(FileNavigatorContribution);

const rootUri = workspaceService.tryGetRoots()[0].resource;
const fileUri = rootUri.resolve('.test/nested/source/text.txt');
const targetUri = rootUri.resolve('.test/target');

beforeEach(async () => {
await fileService.create(fileUri, 'foo', { fromUserGesture: false, overwrite: true });
await fileService.createFolder(targetUri);
});

afterEach(async () => {
await fileService.delete(targetUri.parent, { fromUserGesture: false, useTrash: false, recursive: true });
});

/** @type {Array<['copy' | 'move', boolean]>} */
const operations = [
['copy', false],
['move', false]
];
/** @type {Array<['file' | 'dir', boolean]>} */
const fileTypes = [
['file', false],
['dir', false],
];
for (const [operation, onlyOperation] of operations) {
for (const [fileType, onlyFileType] of fileTypes) {
const ExpectedNodeType = fileType === 'file' ? FileNode : DirNode;
(onlyOperation || onlyFileType ? it.only : it)(operation + ' ' + fileType, async function () {
const navigator = await navigatorContribution.openView({ reveal: true });
await navigator.model.refresh();

const sourceUri = fileType === 'file' ? fileUri : fileUri.parent;
const sourceNode = await navigator.model.revealFile(sourceUri);
if (!ExpectedNodeType.is(sourceNode)) {
return assert.isTrue(ExpectedNodeType.is(sourceNode));
}

const targetNode = await navigator.model.revealFile(targetUri);
if (!DirNode.is(targetNode)) {
return assert.isTrue(DirNode.is(targetNode));
}

let actualUri;
if (operation === 'copy') {
actualUri = await navigator.model.copy(sourceUri, targetNode);
} else {
actualUri = await navigator.model.move(sourceNode, targetNode);
}
if (!actualUri) {
return assert.isDefined(actualUri);
}

await navigator.model.refresh(targetNode);
const actualNode = await navigator.model.revealFile(actualUri);
assert.isTrue(ExpectedNodeType.is(actualNode));
});
}
}

});
Loading