Skip to content

Commit 57607d0

Browse files
author
Akos Kitta
committed
Can start and debug extension from Code.
Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
1 parent 714fffc commit 57607d0

File tree

6 files changed

+677
-2228
lines changed

6 files changed

+677
-2228
lines changed

.vscode/launch.json

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,16 @@
33
"version": "0.2.0",
44
"configurations": [
55
{
6-
"name": "Launch Arduino Tools – VS Code Extension",
7-
"type": "extensionHost",
8-
"request": "launch",
9-
"runtimeExecutable": "${execPath}",
10-
"args": [
11-
"--extensionDevelopmentPath=${workspaceRoot}"
12-
],
13-
"stopOnEntry": false,
14-
"sourceMaps": true,
15-
"outFiles": [
16-
"${workspaceRoot}/lib/**/*.js"
17-
],
18-
"preLaunchTask": "npm"
6+
"name": "Launch Arduino Tools - VS Code Extension",
7+
"type": "extensionHost",
8+
"request": "launch",
9+
"args": [
10+
"--extensionDevelopmentPath=${workspaceFolder}"
11+
],
12+
"outFiles": [
13+
"${workspaceFolder}/dist/**/*.js"
14+
],
15+
"preLaunchTask": "${defaultBuildTask}"
1916
}
2017
]
2118
}

.vscode/tasks.json

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,40 @@
1+
// See https://go.microsoft.com/fwlink/?LinkId=733558
2+
// for the documentation about the tasks.json format
13
{
2-
"version": "2.0.0",
3-
"command": "npm",
4-
"args": [
5-
"run",
6-
"compile"
7-
],
8-
"isBackground": true,
9-
"problemMatcher": "$tsc-watch"
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
"type": "npm",
8+
"script": "watch",
9+
"problemMatcher": "$ts-webpack-watch",
10+
"isBackground": true,
11+
"presentation": {
12+
"reveal": "never",
13+
"group": "watchers"
14+
},
15+
"group": {
16+
"kind": "build",
17+
"isDefault": true
18+
}
19+
},
20+
{
21+
"type": "npm",
22+
"script": "watch-tests",
23+
"problemMatcher": "$tsc-watch",
24+
"isBackground": true,
25+
"presentation": {
26+
"reveal": "never",
27+
"group": "watchers"
28+
},
29+
"group": "build"
30+
},
31+
{
32+
"label": "tasks: watch-tests",
33+
"dependsOn": [
34+
"npm: watch",
35+
"npm: watch-tests"
36+
],
37+
"problemMatcher": []
38+
}
39+
]
1040
}

configs/webpack.config.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ const PermissionsOutputPlugin = require('webpack-permissions-plugin');
99
*/
1010
const config = {
1111
target: 'node',
12-
node: {
13-
__dirname: false,
14-
__filename: false
15-
},
16-
entry: './lib/extension.js',
12+
entry: './src/extension.ts',
1713
output: {
1814
path: path.resolve(__dirname, '..', 'dist'),
1915
filename: 'bundle.js',
@@ -26,8 +22,21 @@ const config = {
2622
vscode: 'commonjs vscode'
2723
},
2824
resolve: {
29-
extensions: ['.js']
25+
extensions: ['.ts', '.js']
3026
},
27+
module: {
28+
rules: [
29+
{
30+
test: /\.ts$/,
31+
exclude: /node_modules/,
32+
use: [
33+
{
34+
loader: 'ts-loader'
35+
}
36+
]
37+
}
38+
]
39+
},
3140
plugins: [
3241
new CopyPlugin({
3342
patterns: [

package.json

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"clean": "rimraf ./lib ./dist ./build-artifacts",
1616
"compile": "tsc -p ./",
1717
"lint": "eslint src --ext ts",
18-
"watch": "tsc -w -p ./",
18+
"watch": "webpack --config ./configs/webpack.config.js --watch",
1919
"webpack": "webpack --config ./configs/webpack.config.js",
2020
"package": "mkdirp build-artifacts && vsce package --out ./build-artifacts"
2121
},
@@ -35,11 +35,12 @@
3535
"eslint": "^7.9.0",
3636
"mkdirp": "^1.0.4",
3737
"rimraf": "^3.0.2",
38-
"typescript": "^3.8.3",
38+
"typescript": "^4.7.4",
39+
"ts-loader": "^9.3.1",
3940
"vsce": "^1.66.0",
4041
"vscode": "^1.1.33",
41-
"webpack": "^4.39.1",
42-
"webpack-cli": "^3.3.6",
42+
"webpack": "^5.73.0",
43+
"webpack-cli": "^4.10.0",
4344
"webpack-permissions-plugin": "^1.0.7"
4445
},
4546
"dependencies": {
@@ -74,6 +75,7 @@
7475
},
7576
"activationEvents": [
7677
"onLanguage:ino",
78+
"onCommand:arduino.ide2Path",
7779
"onCommand:arduino.debug.start",
7880
"onCommand:arduino.languageserver.start",
7981
"onCommand:arduino.languageserver.stop",
@@ -131,7 +133,21 @@
131133
"command": "arduino.debug.start",
132134
"title": "Start Debug",
133135
"category": "Arduino"
136+
},
137+
{
138+
"command": "arduino.ide2Path",
139+
"title": "Print IDE2 Path",
140+
"category": "Arduino"
141+
}
142+
],
143+
"configuration": {
144+
"title": "Arduino Tools",
145+
"properties": {
146+
"arduinoTools.ide2Path": {
147+
"type": "string",
148+
"description": "Absolute path to the Arduino IDE2 installation. This is required to use the Arduino CLI, language server, and other binaries from the IDE2"
149+
}
134150
}
135-
]
151+
}
136152
}
137153
}

src/extension.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,23 @@ let crashCount = 0;
6666
const languageServerStartMutex = new Mutex();
6767
export let languageServerIsRunning = false; // TODO: use later for `start`, `stop`, and `restart` language server.
6868

69+
let ide2Path: string | undefined;
70+
6971
export function activate(context: ExtensionContext) {
72+
ide2Path = vscode.workspace.getConfiguration('vscode-arduino-tools').get('arduinoTools.ide2Path');
73+
vscode.window.showInformationMessage('ide2Path: ' + ide2Path);
74+
vscode.workspace.onDidChangeConfiguration(event => {
75+
if (event.affectsConfiguration('arduinoTools.ide2Path')) {
76+
ide2Path = vscode.workspace.getConfiguration('vscode-arduino-tools').get('arduinoTools.ide2Path');
77+
vscode.window.showInformationMessage('ide2Path: ' + ide2Path);
78+
}
79+
});
80+
console.log('hello');
7081
context.subscriptions.push(
82+
vscode.commands.registerCommand('arduino.ide2Path', () => {
83+
ide2Path = vscode.workspace.getConfiguration('vscode-arduino-tools').get('arduinoTools.ide2Path');
84+
vscode.window.showInformationMessage('ide2Path: ' + ide2Path);
85+
}),
7186
vscode.commands.registerCommand('arduino.languageserver.start', async (config: LanguageServerConfig) => {
7287
const unlock = await languageServerStartMutex.acquire();
7388
try {

0 commit comments

Comments
 (0)