blob: 53df20cc78dee27a274bdea421aca30d7288addb [file] [log] [blame]
<!--
* Copyright 2020 The Chromium Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
-->
<script language="javascript">
class ExtensionPluginBase {
constructor(impl) {
this._impl = impl;
}
dispose() {
}
/*async */ removeRawModule(rawModuleId) {
if (this._impl.removeRawModule) {
return this._impl.removeRawModule(rawModule);
}
return Promise.resolve();
}
/** Notify the plugin about a new script
* @param {string} rawModuleId
* @param {string} symbols - URL of a file providing the debug symbols for this module
* @param {!{url: string}} rawModule
* @return {!Promise<!Array<string>>} - An array of absolute or relative URLs for the source files for the raw module
*/
/*async */ addRawModule(rawModuleId, symbols, rawModule) {
if (this._impl.addRawModule) {
return this._impl.addRawModule(rawModuleId, symbols, rawModule);
}
return Promise.resolve([]);
}
/** Find locations in raw modules from a location in a source file
* @param {!SourceLocation} sourceLocation
* @return {!Promise<!Array<!*>>}
*/
/*async */ sourceLocationToRawLocation(sourceLocation) {
if (this._impl.sourceLocationToRawLocation) {
return this._impl.sourceLocationToRawLocation(sourceLocation);
}
return Promise.resolve([]);
}
/** Find locations in source files from a location in a raw module
* @param {!RawLocation} rawLocation
* @return {!Promise<!Array<!*>>}
*/
/*async */ rawLocationToSourceLocation(rawLocation) {
if (this._impl.rawLocationToSourceLocation) {
return this._impl.rawLocationToSourceLocation(rawLocation);
}
return Promise.resolve([]);
}
/** Return detailed information about a scope
* @param {string} type
* @return {!Promise<!ScopeInfo>}
*/
/*async*/ getScopeInfo(type) {
if (this._impl.getScopeInfo) {
return this._impl.getScopeInfo(type);
}
return Promise.reject(new Error('getScopeInfo() not implemented'));
}
/** List all variables in lexical scope at a given location in a raw module
* @param {!RawLocation} rawLocation
* @return {!Promise<!Array<!*>>}
*/
/*async*/ listVariablesInScope(rawLocation) {
if (this._impl.listVariablesInScope) {
return this._impl.listVariablesInScope(rawLocation);
}
return Promise.resolve([]);
}
/** List all variables in lexical scope at a given location in a raw module
* @param {!RawLocation} rawLocation
* @return {!Promise<!{frames: Array<!*>}>}
*/
/*async*/ getFunctionInfo(rawLocation) {
if (this._impl.getFunctionInfo) {
return this._impl.getFunctionInfo(rawLocation);
}
return Promise.resolve({frames: []});
}
/**
* @param {string} rawModuleId
* @param {string} sourceFileURL
* @return {!Promise<!Array<number>|undefined>}
*/
async getMappedLines(rawModuleId, sourceFileURL) {
if (this._impl.getMappedLines) {
return this._impl.getMappedLines(rawModuleId, sourceFileURL);
}
return Promise.resolve(undefined);
}
evaluate(expression, context, stopId){
if (this._impl.evaluate) {
return this._impl.evaluate(expression, context, stopId);
}
return Promise.resolve(null);
}
getProperties(objectId) {
if (this._impl.getProperties) {
return this._impl.getProperties(objectId);
}
return Promise.resolve([]);
}
releaseObject(objectId) {
if (this._impl.releaseObject) {
return this._impl.releaseObject(objectId);
}
return Promise.resolve();
}
getInlinedCalleesRanges(location) {
if (this._impl.getInlinedCalleesRanges) {
return this._impl.getInlinedCalleesRanges(location);
}
return Promise.resolve([]);
}
getInlinedFunctionRanges(location) {
if (this._impl.getInlinedFunctionRanges) {
return this._impl.getInlinedCalleesRanges(location);
}
return Promise.resolve([]);
}
}
/**
* @param {*} pluginImpl
* @param {string} name
* @param {!{language: string, symbol_types: !Array<string>}} supportedScriptTypes
*/
function RegisterExtension(pluginImpl, name, supportedScriptTypes) {
chrome.devtools.languageServices.registerLanguageExtensionPlugin(
new ExtensionPluginBase(pluginImpl), name, supportedScriptTypes);
}
</script>