mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-25 22:30:29 -04:00
Refresh master with initial release/0.24 snapshot (#332)
* Initial port of release/0.24 source code * Fix additional headers * Fix a typo in launch.json
This commit is contained in:
@@ -13,7 +13,21 @@ import { IModeService } from 'vs/editor/common/services/modeService';
|
||||
import { ITextModelService, ITextModelContentProvider } from 'vs/editor/common/services/resolverService';
|
||||
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
|
||||
import { DEBUG_SCHEME, IDebugService, IProcess } from 'vs/workbench/parts/debug/common/debug';
|
||||
import { Source } from 'vs/workbench/parts/debug/common/debugSource';
|
||||
|
||||
/**
|
||||
* Debug URI format
|
||||
*
|
||||
* a debug URI represents a Source object and the debug session where the Source comes from.
|
||||
*
|
||||
* debug:arbitrary_path?session=123e4567-e89b-12d3-a456-426655440000&ref=1016
|
||||
* \___/ \____________/ \__________________________________________/ \______/
|
||||
* | | | |
|
||||
* scheme source.path session id source.referencequery
|
||||
*
|
||||
* the arbitrary_path and the session id are encoded with 'encodeURIComponent'
|
||||
*
|
||||
*/
|
||||
export class DebugContentProvider implements IWorkbenchContribution, ITextModelContentProvider {
|
||||
|
||||
constructor(
|
||||
@@ -32,15 +46,12 @@ export class DebugContentProvider implements IWorkbenchContribution, ITextModelC
|
||||
public provideTextContent(resource: uri): TPromise<IModel> {
|
||||
|
||||
let process: IProcess;
|
||||
let sourceRef: number;
|
||||
|
||||
if (resource.query) {
|
||||
const keyvalues = resource.query.split('&');
|
||||
for (let keyvalue of keyvalues) {
|
||||
const pair = keyvalue.split('=');
|
||||
if (pair.length === 2 && pair[0] === 'session') {
|
||||
process = this.debugService.findProcessByUUID(decodeURIComponent(pair[1]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
const data = Source.getEncodedDebugData(resource);
|
||||
process = this.debugService.getModel().getProcesses().filter(p => p.getId() === data.processId).pop();
|
||||
sourceRef = data.sourceReference;
|
||||
}
|
||||
|
||||
if (!process) {
|
||||
@@ -55,18 +66,26 @@ export class DebugContentProvider implements IWorkbenchContribution, ITextModelC
|
||||
let rawSource: DebugProtocol.Source;
|
||||
if (source) {
|
||||
rawSource = source.raw;
|
||||
if (!sourceRef) {
|
||||
sourceRef = source.reference;
|
||||
}
|
||||
} else {
|
||||
// Remove debug: scheme
|
||||
rawSource = { path: resource.with({ scheme: '', query: '' }).toString(true) };
|
||||
// create a Source
|
||||
rawSource = {
|
||||
path: resource.with({ scheme: '', query: '' }).toString(true), // Remove debug: scheme
|
||||
sourceReference: sourceRef
|
||||
};
|
||||
}
|
||||
|
||||
return process.session.source({ sourceReference: source ? source.reference : undefined, source: rawSource }).then(response => {
|
||||
const mime = response.body.mimeType || guessMimeTypes(resource.toString())[0];
|
||||
return process.session.source({ sourceReference: sourceRef, source: rawSource }).then(response => {
|
||||
|
||||
const mime = response.body.mimeType || guessMimeTypes(resource.path)[0];
|
||||
const modePromise = this.modeService.getOrCreateMode(mime);
|
||||
const model = this.modelService.createModel(response.body.content, modePromise, resource);
|
||||
|
||||
return model;
|
||||
}, (err: DebugProtocol.ErrorResponse) => {
|
||||
|
||||
this.debugService.sourceIsNotAvailable(resource);
|
||||
const modePromise = this.modeService.getOrCreateMode(MIME_TEXT);
|
||||
const model = this.modelService.createModel(err.message, modePromise, resource);
|
||||
|
||||
Reference in New Issue
Block a user