-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
43 changed files
with
1,119 additions
and
1,670 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
--require reflect-metadata/Reflect | ||
--reporter spec | ||
--watch-extensions js | ||
--exit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/******************************************************************************** | ||
* Copyright (C) 2019 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 | ||
********************************************************************************/ | ||
|
||
import * as path from 'path'; | ||
import * as webpack from 'webpack'; | ||
// tslint:disable:no-implicit-dependencies | ||
import { RawSourceMap } from 'source-map'; | ||
import { ApplicationPackage } from '@theia/application-package/lib/application-package'; | ||
|
||
const modulePackages: { dir: string, name?: string }[] = []; | ||
for (const extensionPackage of new ApplicationPackage({ projectPath: process.cwd() }).extensionPackages) { | ||
modulePackages.push({ | ||
name: extensionPackage.name, | ||
dir: path.dirname(extensionPackage.raw.installed!.packagePath) | ||
}); | ||
} | ||
|
||
function exposeModule(modulePackage: { dir: string, name?: string }, resourcePath: string, source: string): string { | ||
if (!modulePackage.name) { | ||
return source; | ||
} | ||
const { dir, name } = path.parse(resourcePath); | ||
let moduleName = path.join(modulePackage.name, dir.substring(modulePackage.dir.length)); | ||
if (name !== 'index') { | ||
moduleName = path.join(moduleName, name); | ||
} | ||
if (path.sep !== '/') { | ||
moduleName = moduleName.split(path.sep).join('/'); | ||
} | ||
return source + `\nif (!global) global = {};\n(global['theia'] = global['theia'] || {})['${moduleName}'] = this;\n`; | ||
} | ||
|
||
export = function (this: webpack.loader.LoaderContext, source: string, sourceMap?: RawSourceMap): string | undefined { | ||
if (this.cacheable) { | ||
this.cacheable(); | ||
} | ||
|
||
let modulePackage = modulePackages.find(({ dir }) => this.resourcePath.startsWith(dir)); | ||
if (modulePackage) { | ||
this.callback(undefined, exposeModule(modulePackage, this.resourcePath, source), sourceMap); | ||
return; | ||
} | ||
const index = this.resourcePath.lastIndexOf('/node_modules'); | ||
if (index !== -1) { | ||
const nodeModulesPath = this.resourcePath.substring(0, index + '/node_modules'.length); | ||
let dir = this.resourcePath; | ||
while ((dir = path.dirname(dir)) !== nodeModulesPath) { | ||
try { | ||
const { name } = require(path.join(dir, 'package.json')); | ||
modulePackage = { name, dir }; | ||
modulePackages.push(modulePackage); | ||
this.callback(undefined, exposeModule(modulePackage, this.resourcePath, source), sourceMap); | ||
return; | ||
} catch { | ||
/** no-op */ | ||
} | ||
} | ||
} | ||
this.callback(undefined, source, sourceMap); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "@theia/api-tests", | ||
"version": "0.14.0", | ||
"description": "Theia API tests", | ||
"dependencies": { | ||
"@theia/core": "^0.14.0" | ||
}, | ||
"license": "EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/eclipse-theia/theia.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/eclipse-theia/theia/issues" | ||
}, | ||
"homepage": "https://github.com/eclipse-theia/theia", | ||
"files": [ | ||
"src" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/******************************************************************************** | ||
* 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('Editors', 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'); | ||
|
||
/** @type {import('inversify').Container} */ | ||
const container = window['theia'].container; | ||
const editorManager = container.get(EditorManager); | ||
const workspaceService = container.get(WorkspaceService); | ||
|
||
before(() => editorManager.closeAll()); | ||
|
||
it('open', async () => { | ||
const root = (await workspaceService.roots)[0]; | ||
assert.equal(editorManager.all.length, 0); | ||
await editorManager.open(new Uri.default(root.uri).resolve('package.json'), { | ||
mode: 'reveal' | ||
}); | ||
assert.equal(editorManager.all.length, 1); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/******************************************************************************** | ||
* 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('Menus', function () { | ||
|
||
const { MenuBarWidget } = require('@theia/core/lib/browser/menu/browser-menu-plugin'); | ||
const { ApplicationShell } = require('@theia/core/lib/browser/shell/application-shell'); | ||
const { CallHierarchyContribution } = require('@theia/callhierarchy/lib/browser/callhierarchy-contribution'); | ||
const { FileNavigatorContribution } = require('@theia/navigator/lib/browser/navigator-contribution'); | ||
const { ScmContribution } = require('@theia/scm/lib/browser/scm-contribution'); | ||
const { GitHistoryContribution } = require('@theia/git/lib/browser/history/git-history-contribution'); | ||
const { OutlineViewContribution } = require('@theia/outline-view/lib/browser/outline-view-contribution'); | ||
const { OutputContribution } = require('@theia/output/lib/browser/output-contribution'); | ||
const { PluginFrontendViewContribution } = require('@theia/plugin-ext/lib/main/browser/plugin-frontend-view-contribution'); | ||
const { ProblemContribution } = require('@theia/markers/lib/browser/problem/problem-contribution'); | ||
const { SearchInWorkspaceFrontendContribution } = require('@theia/search-in-workspace/lib/browser/search-in-workspace-frontend-contribution'); | ||
|
||
/** @type {import('inversify').Container} */ | ||
const container = window['theia'].container; | ||
const shell = container.get(ApplicationShell); | ||
const menuBar = /** @type {MenuBarWidget} */ (shell.topPanel.widgets.find(w => w instanceof MenuBarWidget)); | ||
|
||
for (const contribution of [ | ||
container.get(CallHierarchyContribution), | ||
container.get(FileNavigatorContribution), | ||
container.get(ScmContribution), | ||
container.get(GitHistoryContribution), | ||
container.get(OutlineViewContribution), | ||
container.get(OutputContribution), | ||
container.get(PluginFrontendViewContribution), | ||
container.get(ProblemContribution), | ||
container.get(SearchInWorkspaceFrontendContribution) | ||
]) { | ||
it(`should toggle '${contribution.viewLabel}' view`, async () => { | ||
await contribution.closeView(); | ||
await menuBar.triggerMenuItem('View', contribution.viewLabel); | ||
await shell.waitForActivation(contribution.viewId); | ||
}); | ||
} | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.