@@ -14,41 +14,20 @@ interface ProcessInfoItem extends vscode.QuickPickItem {
1414}
1515
1616export class AttachDebuggerProvider implements vscode . DebugConfigurationProvider {
17- private isNullOrEmpty ( s ?: string ) : boolean {
17+ protected isNullOrEmpty ( s ?: string ) : boolean {
1818 return ! s || s . trim ( ) . length === 0 ;
1919 }
2020
21- private getSourceRoots ( ) : string [ ] {
21+ protected getSourceRoots ( ) : string [ ] {
2222 var list = vscode . workspace . workspaceFolders ! . map ( f => { return f . uri . fsPath ; } ) ;
2323 var config = < Array < string > > vscode . workspace . getConfiguration ( "emmylua" ) . get ( "source.roots" ) || [ ] ;
2424 return list . concat ( config . map ( item => { return normalize ( item ) ; } ) ) ;
2525 }
2626
27- provideDebugConfigurations ( folder : WorkspaceFolder | undefined , token ?: CancellationToken ) : ProviderResult < DebugConfiguration [ ] > {
28- var config : DebugConfiguration = {
29- name : "Attach" ,
30- type : "emmylua_attach" ,
31- request : "attach" ,
32- pid : 0
33- } ;
34- return [ config ] ;
35- }
36-
3727 resolveDebugConfiguration ( folder : WorkspaceFolder | undefined , debugConfiguration : AttachDebugConfiguration , token ?: CancellationToken ) : ProviderResult < DebugConfiguration > {
3828 debugConfiguration . extensionPath = savedContext . extensionPath ;
3929 debugConfiguration . sourcePaths = this . getSourceRoots ( ) ;
40- if ( debugConfiguration . type === "emmylua_launch" ) {
41- if ( this . isNullOrEmpty ( debugConfiguration . workingDir ) ) {
42- var list = vscode . workspace . workspaceFolders ! . map ( f => { return f . uri . fsPath ; } ) ;
43- if ( list . length > 0 ) {
44- debugConfiguration . workingDir = list [ 0 ] ;
45- }
46- }
47- if ( ! debugConfiguration . arguments ) {
48- debugConfiguration . arguments = [ ] ;
49- }
50- return debugConfiguration ;
51- }
30+ debugConfiguration . request = "attach" ;
5231 if ( debugConfiguration . pid > 0 ) {
5332 return debugConfiguration ;
5433 }
@@ -85,4 +64,26 @@ export class AttachDebuggerProvider implements vscode.DebugConfigurationProvider
8564 dispose ( ) {
8665
8766 }
67+ }
68+
69+ export class AttachLaunchDebuggerProvider extends AttachDebuggerProvider {
70+ resolveDebugConfiguration ( folder : WorkspaceFolder | undefined , debugConfiguration : AttachDebugConfiguration , token ?: CancellationToken ) : ProviderResult < DebugConfiguration > {
71+ debugConfiguration . extensionPath = savedContext . extensionPath ;
72+ debugConfiguration . sourcePaths = this . getSourceRoots ( ) ;
73+ debugConfiguration . type = "emmylua_launch" ;
74+ debugConfiguration . request = "launch" ;
75+ if ( this . isNullOrEmpty ( debugConfiguration . workingDir ) ) {
76+ var list = vscode . workspace . workspaceFolders ! . map ( f => { return f . uri . fsPath ; } ) ;
77+ if ( list . length > 0 ) {
78+ debugConfiguration . workingDir = list [ 0 ] ;
79+ }
80+ }
81+ if ( this . isNullOrEmpty ( debugConfiguration . program ) ) {
82+ debugConfiguration . program = "lua" ;
83+ }
84+ if ( ! debugConfiguration . arguments ) {
85+ debugConfiguration . arguments = [ ] ;
86+ }
87+ return debugConfiguration ;
88+ }
8889}
0 commit comments