-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
VSCode debug adapter protocol implementation #2447
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work !
Although here are the things that I picked up:
- I am able to put breakpoints in
launch.json
(?) - The only breakpoints that show up in the debug panel are the ones placed in the json file, placing breakpoints in
packages/filesystem/src/node/node-filesystem.ts
doesn't show up in the panel. - Couldn't find a way to debug using Electron for Theia (maybe just a missing dep in the
package.json
)
Regarding the following coding pattern:
function shouldBeAsync(...args): Promise<void> {
stuff();
return Promise.resolve();
}
The issue here is that if an error is thrown, it will be done synchronously, and you will not be able to catch it using shouldBeAsync().catch(e => ...)
.
If this is intended, it's fine I guess.
I might have missed some things, but I'm sure Anton will have sharper eyes :)
@inject(ActiveLineDecorator) protected readonly lineDecorator: ActiveLineDecorator, | ||
@inject(BreakpointDecorator) protected readonly breakpointDecorator: BreakpointDecorator, | ||
@inject(BreakpointStorage) protected readonly storage: BreakpointStorage, | ||
@inject(BreakpointsApplier) protected readonly breakpointApplier: BreakpointsApplier, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BreakpointDecorator
, BreakpointStorage
, so why BreakpointsApplier
?
Maybe it would be more consistent to call it BreakpointApplier
too? (-s)
(even the variable is called breakpointApplier
)
super.setMarkers(uri, BREAKPOINT_OWNER, newBreakpoints); | ||
}); | ||
|
||
return Promise.resolve(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async update(data: Ext...) { ... }
Then you don't need the return Promise.resolve()
.
existedBreakpoints.push(breakpoint); | ||
super.setMarkers(uri, BREAKPOINT_OWNER, existedBreakpoints); | ||
|
||
return Promise.resolve(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Convert function to async and you won't need the return.
const breakpoints = super.findMarkers({ uri, dataFilter: b => DebugUtils.makeBreakpointId(b) !== id }).map(m => m.data); | ||
|
||
super.setMarkers(uri, BREAKPOINT_OWNER, breakpoints); | ||
return Promise.resolve(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make async
* @returns true if breakpoint exists and false otherwise | ||
*/ | ||
exists(id: string): Promise<boolean> { | ||
return Promise.resolve(super.findMarkers().some(m => DebugUtils.makeBreakpointId(m.data) === id)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function async exists(id: string): Promise<boolean> {
return super.findMarkers().some(m => DebugUtils.makeBreakpointId(m.data) === id);
}
(added the function
keyword here for github to color the code)
Really nice work @tolusha I can confirm this works as expected when attaching to an existing node process and I think it's a really good base to build a debug experience matching vscode! I took the testing further by implementing the vscode example mock debug extension and have this working as a I'm happy to share this if anyone needs it, but I'm not sure how valuable it is to the Theia project. In order to create a https://github.com/thegecko/theia/commits/vscode-debug-launch Please let me know if you'd like to see this as a PR onto the |
https://github.com/thegecko/theia/commits/vscode-debug-launch |
@tolusha Great work! Is there a specific reason you made the debug view horizontal? I think chrome devtools and vs code do it really well by laying it out vertically, because with the collapsable sections you can have all the important sections in one view without wasting screen estate if you are not interested (because you can collapse). Also it would be more familiar to devs because of the two tools mentioned above are widely used. |
5b10181
to
73546f2
Compare
@marechal-p |
@svenefftinge |
IMO, if in doubt we should copy the layout used in vscode. People are used to it and debug adapters have been built with that layout in mind. |
Agreed. Could you clean up / squash the history a bit? Also the DCO check fails. |
c7034ac
to
d718177
Compare
d718177
to
3636325
Compare
@svenefftinge |
@tolusha the build fails. Looks like it is because you run https://travis-ci.org/theia-ide/theia/jobs/415824849#L4037 In other cases we have put a dummy file. |
Please add new packages to travis file for caching. I see there is a binary file, it is supposed to be checked in or downloaded each time? |
@akosyakov |
@tolusha: it makes sense, although the file is currently checked in:
|
packages/debug-nodejs/package.json
Outdated
}, | ||
"devDependencies": { | ||
"@theia/ext-scripts": "^0.3.13", | ||
"gulp": "^3.9.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, if there is nothing else used from gulp
, could you convert it to plain nodejs like in @theia/java
it's huge library to just download an archive in the end. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In @tolusha 's defence, I'm surprised Theia doesn't use a task runner like gulp already. IMO, the npm scripts and theia-cli
are alien and unwieldy. Perhaps a discussion for another time, however :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can bring the matter for next week's dev meeting?
I would be interested to hear about it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not about Theia, but about downstream projects, they will have to install gulp just to download binaries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using npm scripts as build tools is a common practice in JS world: https://www.keithcirkel.co.uk/how-to-use-npm-as-a-build-tool/
As well as abstracting common scripts via packages: https://blog.kentcdodds.com/automation-without-config-412ab5e47229
I don't really see a need to pull more dev dependencies and write additional js files for them.
@AlexTugarev @marechal-p |
5828aea
to
4eafe9d
Compare
@svenefftinge |
@@ -58,6 +59,7 @@ export class MonacoEditor implements TextEditor, IEditorReference { | |||
protected readonly onSelectionChangedEmitter = new Emitter<Range>(); | |||
protected readonly onFocusChangedEmitter = new Emitter<boolean>(); | |||
protected readonly onDocumentContentChangedEmitter = new Emitter<TextDocumentChangeEvent>(); | |||
protected readonly onMouseDownEmitter = new Emitter<EditorMouseEvent>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add it toDispose
in the constructor
const { lineNumber, column } = e.target.position; | ||
const event = { | ||
target: { | ||
...e.target, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why to copy other properties if they are not exposed? range
and mosueColumn
should not be copied but properly converted from 1-bazed to 0-based positions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks safe, there almost no changes in other packages.
Please take care of comments in monaco package and merge.
1d3c0f7
to
8c047bf
Compare
Signed-off-by: Anatoliy Bazko <abazko@redhat.com>
8c047bf
to
6a03487
Compare
@akosyakov |
@tolusha if you are worried about appveyor: don't... The current error log is something rather common for some reason. Maybe someone can restart the build, but travis linux + mac is green, so it should be good! |
@tolusha if travis is green it is enough, tests are flaky on windows all the time |
Theia support DAP since [this PR](eclipse-theia/theia#2447) cc @tolusha @slemeur @tsmaeder
Reference issues
#1573
eclipse-che/che#8383
Description
This PR brings VSCode debug adapter protocol to the Theia IDE
Implemented features:
Establish Debug Sessions
Threads
Suspend/Resume Actions
Stack Frame Variables
Step actions
Breakpoints
Line Breakpoint
Demo vidoes
Demo 1
Demo 2