Skip to content

Commit ebf640b

Browse files
author
automatic-merge
committed
Merge remote branch 'origin/master' into edge
2 parents 3c3fc89 + 7ce368c commit ebf640b

File tree

10 files changed

+783
-302
lines changed

10 files changed

+783
-302
lines changed

.vscode/extensions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"dbaeumer.vscode-eslint",
88
"esbenp.prettier-vscode",
99
"gruntfuggly.triggertaskonsave",
10-
"davidanson.vscode-markdownlint"
10+
"davidanson.vscode-markdownlint",
11+
"adacore.ada"
1112
]
1213
}

.vscode/tasks.json

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@
4646
}
4747
},
4848
{
49-
// This task starts a background npm process that monitors changes to
50-
// TS files and recompiles them as needed. It is configured to be run
51-
// before the (vscode)-based launch configurations to make sure the TS
52-
// files are compiled and re-compiled upon changes.
5349
"type": "npm",
5450
"script": "watch",
5551
"path": "integration/vscode/ada",
@@ -68,6 +64,24 @@
6864
"problemMatcher": ["$ada"],
6965
"group": "build",
7066
"label": "ada: Check current file"
67+
},
68+
{
69+
"type": "npm",
70+
"script": "watch",
71+
"path": "integration/vscode/ada",
72+
"group": "build",
73+
"problemMatcher": [
74+
{
75+
"base": "$tsc-watch",
76+
"fileLocation": [
77+
"relative",
78+
"${workspaceFolder}/integration/vscode/ada"
79+
]
80+
}
81+
],
82+
"label": "npm: watch - integration/vscode/ada",
83+
"detail": "node ./node_modules/typescript/bin/tsc -watch",
84+
"isBackground": true
7185
}
7286
]
7387
}

doc/HACKING.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,40 @@ and run
7575

7676
On Mac OX X use [atos](https://www.unix.com/man-page/osx/1/atos/) instead.
7777

78+
## Getting symbolic backtrace for TypeScript
79+
80+
The Ada & SPARK extension for Visual Studio Code is published as minified
81+
JavaScript code. For that reason backtraces reported are not easily readable
82+
by humans. To alleviate that, the published .vsix includes a source map file
83+
at `out/src/extension.js.map`.
84+
85+
To resolve a backtrace to the original TypeScript source locations:
86+
87+
1. Unzip the .vsix
88+
89+
2. Copy the backtrace into a plain text file *while preserving the error message
90+
on the first line*, for example:
91+
92+
```
93+
2024-01-11 10:11:54.191 [Ada Extension] ERROR Error while starting Ada extension...
94+
at Gu (/home/XXXXXXX/.vscode/extensions/adacore.ada-24.0.3/out/src/extension.js:75:5911)
95+
at oS (/home/XXXXXXX/.vscode/extensions/adacore.ada-24.0.3/out/src/extension.js:75:6057)
96+
at w$ (/home/XXXXXXX/.vscode/extensions/adacore.ada-24.0.3/out/src/extension.js:85:2292)
97+
at b$ (/home/XXXXXXX/.vscode/extensions/adacore.ada-24.0.3/out/src/extension.js:85:2154)
98+
...
99+
```
100+
101+
3. Run the following command to obtain source locations:
102+
103+
```
104+
$ npx stacktracify out/src/extension.js.map -f trace.txt
105+
2024-01-11 10:11:54.191 [Ada Extension] ERROR Error while starting Ada extension...
106+
at [unknown] (../../src/helpers.ts:150:56)
107+
at getEvaluatedCustomEnv (../../src/helpers.ts:186:22)
108+
at assertSupportedEnvironments (../../src/extension.ts:128:4)
109+
at activateExtension (../../src/extension.ts:118:14)
110+
```
111+
78112
### Writing tests
79113

80114
To write a functional test for Ada Language Server:

integration/vscode/ada/.vscodeignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# This file contains patterns to exclude from the packaging into a .vsix
12
.vscode-test/
23
advanced/
34
node_modules/
@@ -10,5 +11,6 @@ test/
1011
debug.code-workspace
1112
run_grammar_tests.sh
1213
tsconfig.json
13-
**/*.map
1414
**/*.ts
15+
**/*.ts.map
16+
xfail.yaml

integration/vscode/ada/package.json

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,7 @@
482482
"configuration": {
483483
"type": "object",
484484
"required": [
485-
"kind",
486-
"projectFile"
485+
"kind"
487486
],
488487
"properties": {
489488
"kind": {
@@ -494,7 +493,16 @@
494493
"checkFile",
495494
"cleanProject",
496495
"buildMain",
496+
"runMain",
497497
"buildAndRunMain"
498+
],
499+
"enumDescriptions": [
500+
"Build a GPR project",
501+
"Run semantic checks on an Ada file",
502+
"Clean a GPR project",
503+
"Build a main program specified in a GPR project",
504+
"Run a main program specified in a GPR project",
505+
"Run a build task and a run task in sequence for a given main program"
498506
]
499507
},
500508
"projectFile": {
@@ -554,19 +562,14 @@
554562
"properties": {
555563
"kind": {
556564
"enum": [
557-
"buildAndRunMain"
565+
"runMain"
558566
]
559567
},
560568
"projectFile": true,
561-
"args": true,
562569
"main": {
563570
"type": "string",
564571
"description": "Path to main source file"
565572
},
566-
"executable": {
567-
"type": "string",
568-
"description": "Path to main executable file (if it cannot be computed automatically)"
569-
},
570573
"mainArgs": {
571574
"type": "array",
572575
"items": {
@@ -576,6 +579,29 @@
576579
}
577580
},
578581
"additionalProperties": false
582+
},
583+
{
584+
"required": [
585+
"buildTask",
586+
"runTask"
587+
],
588+
"$comment": "Each oneOf is evaluated regardless of the parent schema. That's why valid properties of the parent must be repeated here in order to be allowed.",
589+
"properties": {
590+
"kind": {
591+
"enum": [
592+
"buildAndRunMain"
593+
]
594+
},
595+
"buildTask": {
596+
"type": "string",
597+
"description": "Name of the task that builds the main executable"
598+
},
599+
"runTask": {
600+
"type": "string",
601+
"description": "Name of the task that runs the main executable"
602+
}
603+
},
604+
"additionalProperties": false
579605
}
580606
]
581607
}
@@ -849,14 +875,15 @@
849875
},
850876
"scripts": {
851877
"check-licenses": "npx license-checker-rseidelsohn --summary --onlyAllow \"0BSD;Apache-2.0;BSD-2-Clause;BSD-3-Clause;BlueOak-1.0.0;CC0-1.0;GPL-3.0;GPL-3.0-or-later;ISC;MIT;Python-2.0;Zlib\"",
852-
"vscode:prepublish": "npm run esbuild-base -- --minify",
878+
"vscode:prepublish": "npm run esbuild-base -- --minify --sourcemap",
853879
"esbuild-base": "esbuild ./src/extension.ts --bundle --outfile=out/src/extension.js --external:vscode --format=cjs --platform=node",
854880
"compile": "node ./node_modules/typescript/bin/tsc",
855881
"watch": "node ./node_modules/typescript/bin/tsc -watch",
856882
"pretest": "npm run compile",
857883
"lint": "eslint \"./src/**/*.{js,ts,tsx}\" --quiet --fix",
858884
"cilint": "eslint \"./src/**/*.{js,ts,tsx}\"",
859-
"test": "node ./out/test/runTest.js"
885+
"test": "node ./out/test/runTest.js",
886+
"resolve-backtrace": "npx stacktracify"
860887
},
861888
"dependencies": {
862889
"@types/command-exists": "1.2.0",

integration/vscode/ada/src/commands.ts

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ import { ExtensionState } from './ExtensionState';
88
import { getOrAskForProgram } from './debugConfigProvider';
99
import { adaExtState, mainOutputChannel } from './extension';
1010
import { getProjectFileRelPath } from './helpers';
11-
import { CustomTaskDefinition, getEnclosingSymbol } from './taskProviders';
11+
import {
12+
CustomTaskDefinition,
13+
getConventionalTaskLabel,
14+
getEnclosingSymbol,
15+
isFromWorkspace,
16+
} from './taskProviders';
1217

1318
export function registerCommands(context: vscode.ExtensionContext, clients: ExtensionState) {
1419
context.subscriptions.push(vscode.commands.registerCommand('ada.otherFile', otherFileHandler));
@@ -39,10 +44,12 @@ export function registerCommands(context: vscode.ExtensionContext, clients: Exte
3944

4045
// This is a hidden command that gets called in the default debug
4146
// configuration snippet that gets offered in the launch.json file.
47+
// It is expected to return the relative path of the main program chosen for
48+
// debugging.
4249
context.subscriptions.push(
4350
vscode.commands.registerCommand('ada.getOrAskForProgram', async () => {
4451
const p = await getOrAskForProgram();
45-
return p;
52+
return p?.execRelPath();
4653
})
4754
);
4855

@@ -157,27 +164,6 @@ function getTaskLabel(task: vscode.Task): string {
157164
return isFromWorkspace(task) ? `(From Workspace) ${task.name}` : getConventionalTaskLabel(task);
158165
}
159166

160-
/**
161-
*
162-
* @param task - a task
163-
* @returns the label typically generated for that task by vscode. For tasks not
164-
* defined explicitely in the workspace, this is `ada: <task name>`. For tasks
165-
* defined in the workspace simply return the name which should already include
166-
* the convention.
167-
*/
168-
function getConventionalTaskLabel(task: vscode.Task): string {
169-
return isFromWorkspace(task) ? task.name : `${task.source}: ${task.name}`;
170-
}
171-
172-
/**
173-
*
174-
* @param task - a task
175-
* @returns `true` if the task is defined explicitely in the workspace's tasks.json
176-
*/
177-
function isFromWorkspace(task: vscode.Task) {
178-
return task.source == 'Workspace';
179-
}
180-
181167
interface TaskQuickPickItem extends vscode.QuickPickItem {
182168
task: vscode.Task;
183169
}

0 commit comments

Comments
 (0)