-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
* Add functions to register ports * Addd debugport handler * check if ort already exist * fix lint * fix error
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
'use strict'; | ||
|
||
import { inject, injectable } from 'inversify'; | ||
import { DebugSessionCustomEvent } from 'vscode'; | ||
import { swallowExceptions } from '../../common/utils/decorators'; | ||
import { DebuggerEvents } from './constants'; | ||
import { DebuggerTypeName } from '../../constants'; | ||
import { DebugPortAttributesProvider } from '../debugPort/portAttributesProvider'; | ||
import { IDebugSessionEventHandlers } from './types'; | ||
|
||
/** | ||
* This class is responsible for register ports using by debugpy in the portProvider. | ||
* @export | ||
* @class ChildProcessAttachEventHandler | ||
* @implements {IDebugSessionEventHandlers} | ||
*/ | ||
@injectable() | ||
export class DebugpySocketsHandler implements IDebugSessionEventHandlers { | ||
constructor( | ||
@inject(DebugPortAttributesProvider) private readonly debugPortAttributesProvider: DebugPortAttributesProvider, | ||
) {} | ||
|
||
@swallowExceptions('Handle child process launch') | ||
public async handleCustomEvent(event: DebugSessionCustomEvent): Promise<void> { | ||
if (!event || event.session.configuration.type !== DebuggerTypeName) { | ||
return; | ||
} | ||
|
||
if (event.event == DebuggerEvents.DebugpySockets) { | ||
Check warning on line 32 in src/extension/debugger/hooks/debugpySocketsHandler.ts GitHub Actions / Lint
Check warning on line 32 in src/extension/debugger/hooks/debugpySocketsHandler.ts GitHub Actions / Tests (ubuntu-latest, 3.7)
Check warning on line 32 in src/extension/debugger/hooks/debugpySocketsHandler.ts GitHub Actions / Tests (ubuntu-latest, 3.8)
Check warning on line 32 in src/extension/debugger/hooks/debugpySocketsHandler.ts GitHub Actions / Tests (ubuntu-latest, 3.9)
Check warning on line 32 in src/extension/debugger/hooks/debugpySocketsHandler.ts GitHub Actions / Tests (ubuntu-latest, 3.10)
Check warning on line 32 in src/extension/debugger/hooks/debugpySocketsHandler.ts GitHub Actions / Tests (ubuntu-latest, 3.11)
Check warning on line 32 in src/extension/debugger/hooks/debugpySocketsHandler.ts GitHub Actions / Tests (windows-latest, 3.9)
Check warning on line 32 in src/extension/debugger/hooks/debugpySocketsHandler.ts GitHub Actions / Tests (windows-latest, 3.7)
Check warning on line 32 in src/extension/debugger/hooks/debugpySocketsHandler.ts GitHub Actions / Tests (windows-latest, 3.8)
Check warning on line 32 in src/extension/debugger/hooks/debugpySocketsHandler.ts GitHub Actions / Tests (windows-latest, 3.11)
|
||
let portSocket = event.body.sockets.find((socket: { [x: string]: any }) => { | ||
return socket['internal'] == false; | ||
Check warning on line 34 in src/extension/debugger/hooks/debugpySocketsHandler.ts GitHub Actions / Lint
Check warning on line 34 in src/extension/debugger/hooks/debugpySocketsHandler.ts GitHub Actions / Tests (ubuntu-latest, 3.7)
Check warning on line 34 in src/extension/debugger/hooks/debugpySocketsHandler.ts GitHub Actions / Tests (ubuntu-latest, 3.8)
Check warning on line 34 in src/extension/debugger/hooks/debugpySocketsHandler.ts GitHub Actions / Tests (ubuntu-latest, 3.9)
Check warning on line 34 in src/extension/debugger/hooks/debugpySocketsHandler.ts GitHub Actions / Tests (ubuntu-latest, 3.10)
Check warning on line 34 in src/extension/debugger/hooks/debugpySocketsHandler.ts GitHub Actions / Tests (ubuntu-latest, 3.11)
Check warning on line 34 in src/extension/debugger/hooks/debugpySocketsHandler.ts GitHub Actions / Tests (windows-latest, 3.9)
Check warning on line 34 in src/extension/debugger/hooks/debugpySocketsHandler.ts GitHub Actions / Tests (windows-latest, 3.7)
Check warning on line 34 in src/extension/debugger/hooks/debugpySocketsHandler.ts GitHub Actions / Tests (windows-latest, 3.8)
Check warning on line 34 in src/extension/debugger/hooks/debugpySocketsHandler.ts GitHub Actions / Tests (windows-latest, 3.11)
|
||
}); | ||
if (portSocket != undefined) { | ||
Check warning on line 36 in src/extension/debugger/hooks/debugpySocketsHandler.ts GitHub Actions / Lint
Check warning on line 36 in src/extension/debugger/hooks/debugpySocketsHandler.ts GitHub Actions / Tests (ubuntu-latest, 3.7)
Check warning on line 36 in src/extension/debugger/hooks/debugpySocketsHandler.ts GitHub Actions / Tests (ubuntu-latest, 3.8)
Check warning on line 36 in src/extension/debugger/hooks/debugpySocketsHandler.ts GitHub Actions / Tests (ubuntu-latest, 3.9)
Check warning on line 36 in src/extension/debugger/hooks/debugpySocketsHandler.ts GitHub Actions / Tests (ubuntu-latest, 3.10)
Check warning on line 36 in src/extension/debugger/hooks/debugpySocketsHandler.ts GitHub Actions / Tests (ubuntu-latest, 3.11)
Check warning on line 36 in src/extension/debugger/hooks/debugpySocketsHandler.ts GitHub Actions / Tests (windows-latest, 3.9)
Check warning on line 36 in src/extension/debugger/hooks/debugpySocketsHandler.ts GitHub Actions / Tests (windows-latest, 3.7)
Check warning on line 36 in src/extension/debugger/hooks/debugpySocketsHandler.ts GitHub Actions / Tests (windows-latest, 3.8)
Check warning on line 36 in src/extension/debugger/hooks/debugpySocketsHandler.ts GitHub Actions / Tests (windows-latest, 3.11)
|
||
this.debugPortAttributesProvider.setPortAttribute(portSocket.port); | ||
} | ||
} else { | ||
return; | ||
} | ||
} | ||
} |