Skip to content

Commit

Permalink
VSCodeDebugProtocolPlugin: fixed issue where entries in the call stac…
Browse files Browse the repository at this point in the history
…k that didn't have a source location (such as internal runtime functions) resulted in null reference errors (closes #47)
  • Loading branch information
joshtynjala committed Nov 28, 2017
1 parent 182bf6f commit fb8f381
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,12 @@ package actionScripts.plugins.vscodeDebug

private function parseSource(response:Object):Source
{
if(!response)
{
//the stack trace sometimes includes functions internal to the
//runtime that don't have a source. That's perfectly fine!
return null;
}
var vo:Source = new Source();
vo.name = response.name as String;
vo.path = response.path as String;
Expand All @@ -570,6 +576,12 @@ package actionScripts.plugins.vscodeDebug

private function gotoStackFrame(stackFrame:StackFrame):void
{
if(!stackFrame.source)
{
//nothing to open! sometimes the stack trace includes functions
//internal to the runtime that cannot be viewed as source.
return;
}
var filePath:String = stackFrame.source.path;
var line:int = stackFrame.line - 1;
var character:int = stackFrame.column;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import mx.collections.IHierarchicalData;
import mx.events.AdvancedDataGridEvent;
import mx.events.ListEvent;
import actionScripts.locator.IDEModel;
import actionScripts.plugins.vscodeDebug.events.LoadVariablesEvent;
import actionScripts.plugins.vscodeDebug.events.StackFrameEvent;
Expand Down Expand Up @@ -76,10 +76,24 @@
return "";
}
private function lineLabelFunction(item:StackFrame, column:DataGridColumn = null):String
{
if(item.source)
{
return item.line.toString();
}
return "";
}
private function nameDataTipFunction(item:StackFrame):String
{
return item.name + " (" + item.line + "," + item.column + ")\n" +
item.source.path;
var result:String = item.name;
if(item.source)
{
result += " (" + item.line + "," + item.column + ")";
result += "\n" + item.source.path;
}
return result;
}
private function variablesTree_itemOpenHandler(event:AdvancedDataGridEvent):void
Expand All @@ -96,7 +110,6 @@
var stackFrame:StackFrame = StackFrame(event.itemRenderer.data);
this.dispatchEvent(new StackFrameEvent(StackFrameEvent.GOTO_STACK_FRAME, stackFrame));
}
]]></mx:Script>

<mx:Style>
Expand Down Expand Up @@ -196,7 +209,7 @@
<mx:columns>
<mx:DataGridColumn headerText="Stack Frame" dataField="name"
dataTipField="source" dataTipFunction="{nameDataTipFunction}" showDataTips="true"/>
<mx:DataGridColumn headerText="Line" dataField="line" width="50"/>
<mx:DataGridColumn headerText="Line" labelFunction="{lineLabelFunction}" width="50"/>
</mx:columns>
</mx:DataGrid>
</mx:VBox>

0 comments on commit fb8f381

Please sign in to comment.