DefaultScriptMapping.js [plain text]
WebInspector.DefaultScriptMapping = function(workspace)
{
this._projectDelegate = new WebInspector.DebuggerProjectDelegate();
this._workspace = workspace;
this._workspace.addProject(this._projectDelegate);
WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.GlobalObjectCleared, this._debuggerReset, this);
this._debuggerReset();
}
WebInspector.DefaultScriptMapping.prototype = {
rawLocationToUILocation: function(rawLocation)
{
var debuggerModelLocation = (rawLocation);
var script = WebInspector.debuggerModel.scriptForId(debuggerModelLocation.scriptId);
var uiSourceCode = this._uiSourceCodeForScriptId[script.scriptId];
var lineNumber = debuggerModelLocation.lineNumber;
var columnNumber = debuggerModelLocation.columnNumber || 0;
return new WebInspector.UILocation(uiSourceCode, lineNumber, columnNumber);
},
uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber)
{
var scriptId = this._scriptIdForUISourceCode.get(uiSourceCode);
var script = WebInspector.debuggerModel.scriptForId(scriptId);
return WebInspector.debuggerModel.createRawLocation(script, lineNumber, columnNumber);
},
isIdentity: function()
{
return true;
},
addScript: function(script)
{
var path = this._projectDelegate.addScript(script);
var uiSourceCode = this._workspace.uiSourceCode(this._projectDelegate.id(), path);
this._uiSourceCodeForScriptId[script.scriptId] = uiSourceCode;
this._scriptIdForUISourceCode.put(uiSourceCode, script.scriptId);
uiSourceCode.setSourceMapping(this);
script.pushSourceMapping(this);
script.addEventListener(WebInspector.Script.Events.ScriptEdited, this._scriptEdited.bind(this, script.scriptId));
return uiSourceCode;
},
_scriptEdited: function(scriptId, event)
{
var content = (event.data);
this._uiSourceCodeForScriptId[scriptId].addRevision(content);
},
_debuggerReset: function()
{
this._uiSourceCodeForScriptId = {};
this._scriptIdForUISourceCode = new Map();
this._projectDelegate.reset();
}
}
WebInspector.DebuggerProjectDelegate = function()
{
WebInspector.ContentProviderBasedProjectDelegate.call(this, WebInspector.projectTypes.Debugger);
}
WebInspector.DebuggerProjectDelegate.prototype = {
id: function()
{
return "debugger:";
},
displayName: function()
{
return "debugger";
},
addScript: function(script)
{
var contentProvider = script.isInlineScript() ? new WebInspector.ConcatenatedScriptsContentProvider([script]) : script;
var splittedURL = WebInspector.ParsedURL.splitURL(script.sourceURL);
var name = splittedURL[splittedURL.length - 1];
name = "[VM] " + name + " (" + script.scriptId + ")";
return this.addContentProvider([name], script.sourceURL, contentProvider, false, script.isContentScript);
},
__proto__: WebInspector.ContentProviderBasedProjectDelegate.prototype
}