Skip to content
This repository was archived by the owner on Sep 24, 2021. It is now read-only.

Commit 4a437d9

Browse files
committed
initial commit
0 parents  commit 4a437d9

18 files changed

+5494
-0
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules
2+
.browser_modules
3+
lib
4+
*.log
5+
*-app/*
6+
!*-app/package.json

.vscode/launch.json

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
// Use IntelliSense to learn about possible Node.js debug attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "node",
9+
"request": "attach",
10+
"name": "Attach",
11+
"port": 9229,
12+
"protocol": "inspector"
13+
},
14+
{
15+
"type": "node",
16+
"request": "launch",
17+
"name": "Start Browser Backend",
18+
"program": "${workspaceRoot}/browser-app/src-gen/backend/main.js",
19+
"args": [
20+
"--loglevel=debug",
21+
"--port=3000",
22+
"--no-cluster"
23+
],
24+
"env": {
25+
"NODE_ENV": "development"
26+
},
27+
"sourceMaps": true,
28+
"outFiles": [
29+
"${workspaceRoot}/node_modules/@theia/*/lib/**/*.js",
30+
"${workspaceRoot}/browser-app/lib/**/*.js",
31+
"${workspaceRoot}/browser-app/src-gen/**/*.js"
32+
],
33+
"smartStep": true,
34+
"internalConsoleOptions": "openOnSessionStart",
35+
"outputCapture": "std"
36+
},
37+
{
38+
"type": "node",
39+
"request": "launch",
40+
"name": "Start Electron Backend",
41+
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
42+
"windows": {
43+
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
44+
},
45+
"program": "${workspaceRoot}/electron-app/src-gen/frontend/electron-main.js",
46+
"protocol": "inspector",
47+
"args": [
48+
"--loglevel=debug",
49+
"--hostname=localhost",
50+
"--no-cluster"
51+
],
52+
"env": {
53+
"NODE_ENV": "development"
54+
},
55+
"sourceMaps": true,
56+
"outFiles": [
57+
"${workspaceRoot}/electron-app/src-gen/frontend/electron-main.js",
58+
"${workspaceRoot}/electron-app/src-gen/backend/main.js",
59+
"${workspaceRoot}/electron-app/lib/**/*.js",
60+
"${workspaceRoot}/node_modules/@theia/*/lib/**/*.js"
61+
],
62+
"smartStep": true,
63+
"internalConsoleOptions": "openOnSessionStart",
64+
"outputCapture": "std"
65+
}
66+
]
67+
}

README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Hello World Extension Example
2+
The example of how to build the Theia-based applications with the go-extension.
3+
4+
## Getting started
5+
6+
Install [nvm](https://github.com/creationix/nvm#install-script).
7+
8+
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.5/install.sh | bash
9+
10+
Install npm and node.
11+
12+
nvm install 8
13+
nvm use 8
14+
15+
Install yarn.
16+
17+
npm install -g yarn
18+
19+
## Running the browser example
20+
21+
yarn rebuild:browser
22+
cd browser-app
23+
yarn start
24+
25+
Open http://localhost:3000 in the browser.
26+
27+
## Running the Electron example
28+
29+
yarn rebuild:electron
30+
cd electron-app
31+
yarn start
32+
33+
## Developing with the browser example
34+
35+
Start watching of the hello world extension.
36+
37+
cd go-extension
38+
yarn watch
39+
40+
Start watching of the browser example.
41+
42+
yarn rebuild:browser
43+
cd browser-app
44+
yarn watch
45+
46+
Launch `Start Browser Backend` configuration from VS code.
47+
48+
Open http://localhost:3000 in the browser.
49+
50+
## Developing with the Electron example
51+
52+
Start watching of the hello world extension.
53+
54+
cd go-extension
55+
yarn watch
56+
57+
Start watching of the electron example.
58+
59+
yarn rebuild:electron
60+
cd electron-app
61+
yarn watch
62+
63+
Launch `Start Electron Backend` configuration from VS code.
64+
65+
## Publishing go-extension
66+
67+
Create a npm user and login to the npm registry, [more on npm publishing](https://docs.npmjs.com/getting-started/publishing-npm-packages).
68+
69+
npm login
70+
71+
Publish packages with lerna to update versions properly across local packages, [more on publishing with lerna](https://github.com/lerna/lerna#publish).
72+
73+
npx lerna publish

browser-app/package.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"private": true,
3+
"name": "browser-app",
4+
"version": "0.0.0",
5+
"dependencies": {
6+
"@theia/core": "latest",
7+
"@theia/filesystem": "latest",
8+
"@theia/workspace": "latest",
9+
"@theia/preferences": "latest",
10+
"@theia/navigator": "latest",
11+
"@theia/process": "latest",
12+
"@theia/terminal": "latest",
13+
"@theia/editor": "latest",
14+
"@theia/languages": "latest",
15+
"@theia/markers": "latest",
16+
"@theia/monaco": "latest",
17+
"@theia/typescript": "latest",
18+
"go-extension": "0.0.0"
19+
},
20+
"devDependencies": {
21+
"@theia/cli": "latest"
22+
},
23+
"scripts": {
24+
"prepare": "theia build",
25+
"start": "theia start",
26+
"watch": "theia build --watch"
27+
},
28+
"theia": {
29+
"target": "browser"
30+
}
31+
}

electron-app/package.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"private": true,
3+
"name": "electron-app",
4+
"version": "0.0.0",
5+
"dependencies": {
6+
"@theia/core": "latest",
7+
"@theia/filesystem": "latest",
8+
"@theia/workspace": "latest",
9+
"@theia/preferences": "latest",
10+
"@theia/navigator": "latest",
11+
"@theia/process": "latest",
12+
"@theia/terminal": "latest",
13+
"@theia/editor": "latest",
14+
"@theia/languages": "latest",
15+
"@theia/markers": "latest",
16+
"@theia/monaco": "latest",
17+
"@theia/typescript": "latest",
18+
"go-extension": "0.0.0"
19+
},
20+
"devDependencies": {
21+
"@theia/cli": "latest"
22+
},
23+
"scripts": {
24+
"prepare": "theia build",
25+
"start": "theia start",
26+
"watch": "theia build --watch"
27+
},
28+
"theia": {
29+
"target": "electron"
30+
}
31+
}

go-extension/package.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "go-extension",
3+
"keywords": [
4+
"theia-extension"
5+
],
6+
"version": "0.0.0",
7+
"files": [
8+
"lib",
9+
"src"
10+
],
11+
"dependencies": {
12+
"@theia/core": "latest"
13+
},
14+
"devDependencies": {
15+
"rimraf": "latest",
16+
"typescript": "latest"
17+
},
18+
"scripts": {
19+
"prepare": "yarn run clean && yarn run build",
20+
"clean": "rimraf lib",
21+
"build": "tsc",
22+
"watch": "tsc -w"
23+
},
24+
"theiaExtensions": [
25+
{
26+
"frontend": "lib/browser/go-frontend-module",
27+
"backend": "lib/node/go-backend-module"
28+
}
29+
]
30+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright (C) 2017 TypeFox and others.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6+
*/
7+
8+
import { injectable, inject } from "inversify";
9+
import { BaseLanguageClientContribution, Workspace, Languages, LanguageClientFactory } from '@theia/languages/lib/browser';
10+
import { GO_LANGUAGE_ID, GO_LANGUAGE_NAME } from '../common';
11+
12+
@injectable()
13+
export class GoClientContribution extends BaseLanguageClientContribution {
14+
15+
readonly id = GO_LANGUAGE_ID;
16+
readonly name = GO_LANGUAGE_NAME;
17+
18+
constructor(
19+
@inject(Workspace) protected readonly workspace: Workspace,
20+
@inject(Languages) protected readonly languages: Languages,
21+
@inject(LanguageClientFactory) protected readonly languageClientFactory: LanguageClientFactory
22+
) {
23+
super(workspace, languages, languageClientFactory);
24+
}
25+
26+
protected get globPatterns() {
27+
return [
28+
'**/*.go'
29+
];
30+
}
31+
}
32+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { CommandContribution, CommandRegistry, Command } from "@theia/core";
2+
3+
4+
export const CONVERTING_SHOW_REFERENCE_COMMAND = <Command> {
5+
id: 'converting.editor.action.showReferences'
6+
}
7+
8+
export class GoCommandContribution implements CommandContribution {
9+
10+
registerCommands(commands: CommandRegistry): void {
11+
throw new Error("Method not implemented.");
12+
}
13+
14+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { GoMenuContribution } from './go-menu-contribution';
2+
/*
3+
* Copyright (C) 2017 TypeFox and others.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
7+
*/
8+
9+
import { ContainerModule } from "inversify";
10+
import { LanguageClientContribution } from "@theia/languages/lib/browser";
11+
import { GoClientContribution } from "./go-client-contribution";
12+
import { MenuContribution } from '@theia/core';
13+
14+
export default new ContainerModule(bind => {
15+
bind(GoClientContribution).toSelf().inSingletonScope();
16+
bind(LanguageClientContribution).toDynamicValue(ctx => ctx.container.get(GoClientContribution));
17+
bind(GoMenuContribution).toSelf().inSingletonScope();
18+
bind(MenuContribution).toDynamicValue(ctx => ctx.container.get(GoMenuContribution));
19+
});
20+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { MenuContribution, MenuModelRegistry } from "@theia/core";
2+
import { EDITOR_CONTEXT_MENU } from "@theia/editor/lib/browser";
3+
import { injectable } from "inversify";
4+
5+
@injectable()
6+
export class GoMenuContribution implements MenuContribution {
7+
registerMenus(menus: MenuModelRegistry): void {
8+
menus.registerMenuAction(EDITOR_CONTEXT_MENU.concat("2_go"), {
9+
commandId: "go.install.package",
10+
label: "Go: Install Current Package"
11+
})
12+
menus.registerMenuAction(EDITOR_CONTEXT_MENU.concat("2_go"), {
13+
commandId : "go.lint.package",
14+
label: "Go: Lint Current Package"
15+
})
16+
menus.registerMenuAction(EDITOR_CONTEXT_MENU.concat("2_go"), {
17+
commandId : "go.lint.workspace",
18+
label : "Go: Lint Workspace"
19+
})
20+
menus.registerMenuAction(EDITOR_CONTEXT_MENU.concat("2_go"), {
21+
commandId : "go.vet.package",
22+
label : "Go: Vet Current Package"
23+
})
24+
menus.registerMenuAction(EDITOR_CONTEXT_MENU.concat("2_go"), {
25+
commandId : "go.vet.workspace",
26+
label : "Go: Vet Workspace"
27+
})
28+
}
29+
}

0 commit comments

Comments
 (0)