@@ -660,104 +660,108 @@ export class ObjectScriptDebugSession extends LoggingDebugSession {
660
660
response : DebugProtocol . StackTraceResponse ,
661
661
args : DebugProtocol . StackTraceArguments
662
662
) : Promise < void > {
663
- const stack = await this . _connection . sendStackGetCommand ( ) ;
664
-
665
- /** Is set to true if we're at the CSP or unit test ending watchpoint.
666
- * We need to do this so VS Code doesn't try to open the source of
667
- * a stack frame before the debug session terminates. */
668
- let noStack = false ;
669
- const stackFrames = await Promise . all (
670
- stack . stack . map ( async ( stackFrame : xdebug . StackFrame , index ) : Promise < StackFrame > => {
671
- if ( noStack ) return ; // Stack frames won't be sent
672
- const [ , namespace , docName ] = decodeURI ( stackFrame . fileUri ) . match ( / ^ d b g p : \/ \/ \| ( [ ^ | ] + ) \| ( .* ) $ / ) ;
673
- const fileUri = DocumentContentProvider . getUri (
674
- docName ,
675
- this . _workspace ,
676
- namespace ,
677
- undefined ,
678
- this . _workspaceFolderUri
679
- ) ;
680
- const source = new Source ( docName , fileUri . toString ( ) ) ;
681
- let line = stackFrame . line + 1 ;
682
- const place = `${ stackFrame . method } +${ stackFrame . methodOffset } ` ;
683
- const stackFrameId = this . _stackFrameIdCounter ++ ;
684
- if ( index == 0 && this . _break ) {
685
- const csp = this . _isCsp && [ "%SYS.cspServer.mac" , "%SYS.cspServer.int" ] . includes ( source . name ) ;
686
- const unitTest = this . _isUnitTest && source . name . startsWith ( "%Api.Atelier.v" ) ;
687
- if ( csp || unitTest ) {
688
- // Check if we're at our special watchpoint
689
- const { result } = await this . _connection . sendEvalCommand (
690
- csp ? this . _cspWatchpointCondition : this . _unitTestWatchpointCondition
691
- ) ;
692
- if ( result . type == "int" && result . value == "1" ) {
693
- // Stop the debugging session
694
- const xdebugResponse = await this . _connection . sendDetachCommand ( ) ;
695
- this . _checkStatus ( xdebugResponse ) ;
696
- noStack = true ;
697
- return ;
663
+ try {
664
+ const stack = await this . _connection . sendStackGetCommand ( ) ;
665
+
666
+ /** Is set to true if we're at the CSP or unit test ending watchpoint.
667
+ * We need to do this so VS Code doesn't try to open the source of
668
+ * a stack frame before the debug session terminates. */
669
+ let noStack = false ;
670
+ const stackFrames = await Promise . all (
671
+ stack . stack . map ( async ( stackFrame : xdebug . StackFrame , index ) : Promise < StackFrame > => {
672
+ if ( noStack ) return ; // Stack frames won't be sent
673
+ const [ , namespace , docName ] = decodeURI ( stackFrame . fileUri ) . match ( / ^ d b g p : \/ \/ \| ( [ ^ | ] + ) \| ( .* ) $ / ) ;
674
+ const fileUri = DocumentContentProvider . getUri (
675
+ docName ,
676
+ this . _workspace ,
677
+ namespace ,
678
+ undefined ,
679
+ this . _workspaceFolderUri
680
+ ) ;
681
+ const source = new Source ( docName , fileUri . toString ( ) ) ;
682
+ let line = stackFrame . line + 1 ;
683
+ const place = `${ stackFrame . method } +${ stackFrame . methodOffset } ` ;
684
+ const stackFrameId = this . _stackFrameIdCounter ++ ;
685
+ if ( index == 0 && this . _break ) {
686
+ const csp = this . _isCsp && [ "%SYS.cspServer.mac" , "%SYS.cspServer.int" ] . includes ( source . name ) ;
687
+ const unitTest = this . _isUnitTest && source . name . startsWith ( "%Api.Atelier.v" ) ;
688
+ if ( csp || unitTest ) {
689
+ // Check if we're at our special watchpoint
690
+ const { result } = await this . _connection . sendEvalCommand (
691
+ csp ? this . _cspWatchpointCondition : this . _unitTestWatchpointCondition
692
+ ) ;
693
+ if ( result . type == "int" && result . value == "1" ) {
694
+ // Stop the debugging session
695
+ const xdebugResponse = await this . _connection . sendDetachCommand ( ) ;
696
+ this . _checkStatus ( xdebugResponse ) ;
697
+ noStack = true ;
698
+ return ;
699
+ }
698
700
}
699
701
}
700
- }
701
- const fileText = await this . _getFileText ( fileUri ) ;
702
- const hasCmdLoc = typeof stackFrame . cmdBeginLine == "number" ;
703
- if ( ! fileText . length ) {
704
- // Can't get the source for the document
705
- this . _stackFrames . set ( stackFrameId , stackFrame ) ;
702
+ const fileText = await this . _getFileText ( fileUri ) ;
703
+ const hasCmdLoc = typeof stackFrame . cmdBeginLine == "number" ;
704
+ if ( ! fileText . length ) {
705
+ // Can't get the source for the document
706
+ this . _stackFrames . set ( stackFrameId , stackFrame ) ;
707
+ return {
708
+ id : stackFrameId ,
709
+ name : place ,
710
+ // Don't provide a source path so VS Code doesn't attempt
711
+ // to open this file or provide an option to "create" it
712
+ source : {
713
+ name : docName ,
714
+ presentationHint : "deemphasize" ,
715
+ } ,
716
+ line,
717
+ column : 0 ,
718
+ } ;
719
+ }
720
+ let noSource = false ;
721
+ try {
722
+ if ( source . name . endsWith ( ".cls" ) && stackFrame . method !== "" ) {
723
+ // Compute DocumentSymbols for this class
724
+ const symbols : vscode . DocumentSymbol [ ] = (
725
+ await vscode . commands . executeCommand < vscode . DocumentSymbol [ ] > (
726
+ "vscode.executeDocumentSymbolProvider" ,
727
+ fileUri
728
+ )
729
+ ) [ 0 ] . children ;
730
+ const newLine = methodOffsetToLine ( symbols , fileText , stackFrame . method , stackFrame . methodOffset ) ;
731
+ if ( newLine != undefined ) line = newLine ;
732
+ }
733
+ this . _stackFrames . set ( stackFrameId , stackFrame ) ;
734
+ } catch {
735
+ noSource = true ;
736
+ }
737
+ const lineDiff = line - stackFrame . line ;
706
738
return {
707
739
id : stackFrameId ,
708
740
name : place ,
709
- // Don't provide a source path so VS Code doesn't attempt
710
- // to open this file or provide an option to "create" it
711
- source : {
712
- name : docName ,
713
- presentationHint : "deemphasize" ,
714
- } ,
741
+ source : noSource ? null : source ,
715
742
line,
716
- column : 0 ,
743
+ column : hasCmdLoc ? stackFrame . cmdBeginPos + 1 : 0 ,
744
+ endLine : hasCmdLoc ? stackFrame . cmdEndLine + lineDiff : undefined ,
745
+ endColumn : hasCmdLoc
746
+ ? ( stackFrame . cmdEndPos == 0
747
+ ? // A command that ends at position zero means "rest of this line"
748
+ fileText . split ( / \r ? \n / ) [ stackFrame . cmdEndLine + lineDiff - 1 ] . length
749
+ : stackFrame . cmdEndPos ) + 1
750
+ : undefined ,
717
751
} ;
718
- }
719
- let noSource = false ;
720
- try {
721
- if ( source . name . endsWith ( ".cls" ) && stackFrame . method !== "" ) {
722
- // Compute DocumentSymbols for this class
723
- const symbols : vscode . DocumentSymbol [ ] = (
724
- await vscode . commands . executeCommand < vscode . DocumentSymbol [ ] > (
725
- "vscode.executeDocumentSymbolProvider" ,
726
- fileUri
727
- )
728
- ) [ 0 ] . children ;
729
- const newLine = methodOffsetToLine ( symbols , fileText , stackFrame . method , stackFrame . methodOffset ) ;
730
- if ( newLine != undefined ) line = newLine ;
731
- }
732
- this . _stackFrames . set ( stackFrameId , stackFrame ) ;
733
- } catch {
734
- noSource = true ;
735
- }
736
- const lineDiff = line - stackFrame . line ;
737
- return {
738
- id : stackFrameId ,
739
- name : place ,
740
- source : noSource ? null : source ,
741
- line,
742
- column : hasCmdLoc ? stackFrame . cmdBeginPos + 1 : 0 ,
743
- endLine : hasCmdLoc ? stackFrame . cmdEndLine + lineDiff : undefined ,
744
- endColumn : hasCmdLoc
745
- ? ( stackFrame . cmdEndPos == 0
746
- ? // A command that ends at position zero means "rest of this line"
747
- fileText . split ( / \r ? \n / ) [ stackFrame . cmdEndLine + lineDiff - 1 ] . length
748
- : stackFrame . cmdEndPos ) + 1
749
- : undefined ,
750
- } ;
751
- } )
752
- ) ;
752
+ } )
753
+ ) ;
753
754
754
- this . _break = false ;
755
- if ( ! noStack ) {
756
- response . body = {
757
- stackFrames,
758
- } ;
755
+ this . _break = false ;
756
+ if ( ! noStack ) {
757
+ response . body = {
758
+ stackFrames,
759
+ } ;
760
+ }
761
+ this . sendResponse ( response ) ;
762
+ } catch ( error ) {
763
+ this . sendErrorResponse ( response , error ) ;
759
764
}
760
- this . sendResponse ( response ) ;
761
765
}
762
766
763
767
protected async scopesRequest (
0 commit comments