Merge from vscode 6e530127a1bb8ffbd1bfb77dc680c321dc0d71f5 (#6844)

This commit is contained in:
Anthony Dresser
2019-08-20 21:07:47 -07:00
committed by GitHub
parent 1f00249646
commit ecb80f14f0
221 changed files with 3140 additions and 1552 deletions

View File

@@ -169,7 +169,7 @@ class SelectionToReplAction extends EditorAction {
});
}
public run(accessor: ServicesAccessor, editor: ICodeEditor): Promise<void> {
public async run(accessor: ServicesAccessor, editor: ICodeEditor): Promise<void> {
const debugService = accessor.get(IDebugService);
const panelService = accessor.get(IPanelService);
const viewModel = debugService.getViewModel();
@@ -179,9 +179,8 @@ class SelectionToReplAction extends EditorAction {
}
const text = editor.getModel().getValueInRange(editor.getSelection());
return session.addReplExpression(viewModel.focusedStackFrame!, text)
.then(() => panelService.openPanel(REPL_ID, true))
.then(_ => undefined);
await session.addReplExpression(viewModel.focusedStackFrame!, text);
await panelService.openPanel(REPL_ID, true);
}
}

View File

@@ -404,7 +404,7 @@ export class DebugService implements IDebugService {
.then(() => false);
}
return launch && launch.openConfigFile(false, true, undefined, this.initCancellationToken ? this.initCancellationToken.token : undefined).then(() => false);
return !!launch && launch.openConfigFile(false, true, undefined, this.initCancellationToken ? this.initCancellationToken.token : undefined).then(() => false);
});
}
@@ -542,6 +542,10 @@ export class DebugService implements IDebugService {
if (this.layoutService.isVisible(Parts.SIDEBAR_PART) && this.configurationService.getValue<IDebugConfiguration>('debug').openExplorerOnEnd) {
this.viewletService.openViewlet(EXPLORER_VIEWLET_ID);
}
// Data breakpoints that can not be persisted should be cleared when a session ends
const dataBreakpoints = this.model.getDataBreakpoints().filter(dbp => !dbp.canPersist);
dataBreakpoints.forEach(dbp => this.model.removeDataBreakpoints(dbp.getId()));
}
}));

View File

@@ -31,6 +31,8 @@ import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { ReplModel } from 'vs/workbench/contrib/debug/common/replModel';
import { onUnexpectedError } from 'vs/base/common/errors';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { IOpenerService } from 'vs/platform/opener/common/opener';
import { variableSetEmitter } from 'vs/workbench/contrib/debug/browser/variablesView';
export class DebugSession implements IDebugSession {
@@ -66,7 +68,8 @@ export class DebugSession implements IDebugSession {
@IWorkspaceContextService private readonly workspaceContextService: IWorkspaceContextService,
@INotificationService private readonly notificationService: INotificationService,
@IProductService private readonly productService: IProductService,
@IWindowsService private readonly windowsService: IWindowsService
@IWindowsService private readonly windowsService: IWindowsService,
@IOpenerService private readonly openerService: IOpenerService
) {
this.id = generateUuid();
this.repl = new ReplModel(this);
@@ -167,7 +170,7 @@ export class DebugSession implements IDebugSession {
return dbgr.createDebugAdapter(this).then(debugAdapter => {
this.raw = new RawDebugSession(debugAdapter, dbgr, this.telemetryService, customTelemetryService, this.windowsService);
this.raw = new RawDebugSession(debugAdapter, dbgr, this.telemetryService, customTelemetryService, this.windowsService, this.openerService);
return this.raw.start().then(() => {
@@ -552,7 +555,8 @@ export class DebugSession implements IDebugSession {
insertText: item.text || item.label,
kind: completionKindFromString(item.type || 'property'),
filterText: (item.start && item.length) ? text.substr(item.start, item.length).concat(item.label) : undefined,
range: Range.fromPositions(position.delta(0, -(item.length || overwriteBefore)), position)
range: Range.fromPositions(position.delta(0, -(item.length || overwriteBefore)), position),
sortText: item.sortText
});
}
});
@@ -903,12 +907,13 @@ export class DebugSession implements IDebugSession {
this._onDidChangeREPLElements.fire();
}
addReplExpression(stackFrame: IStackFrame | undefined, name: string): Promise<void> {
async addReplExpression(stackFrame: IStackFrame | undefined, name: string): Promise<void> {
const viewModel = this.debugService.getViewModel();
return this.repl.addReplExpression(stackFrame, name)
.then(() => this._onDidChangeREPLElements.fire())
// Evaluate all watch expressions and fetch variables again since repl evaluation might have changed some.
.then(() => this.debugService.focusStackFrame(viewModel.focusedStackFrame, viewModel.focusedThread, viewModel.focusedSession));
await this.repl.addReplExpression(stackFrame, name);
this._onDidChangeREPLElements.fire();
// Evaluate all watch expressions and fetch variables again since repl evaluation might have changed some.
this.debugService.focusStackFrame(viewModel.focusedStackFrame, viewModel.focusedThread, viewModel.focusedSession);
variableSetEmitter.fire();
}
appendToRepl(data: string | IExpression, severity: severity, source?: IReplElementSource): void {

View File

@@ -3,7 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import strings = require('vs/base/common/strings');
import * as strings from 'vs/base/common/strings';
import { isAbsolute } from 'vs/base/common/path';
import { URI as uri } from 'vs/base/common/uri';
import { isMacintosh } from 'vs/base/common/platform';

View File

@@ -17,6 +17,7 @@ import { IWindowsService } from 'vs/platform/windows/common/windows';
import { URI } from 'vs/base/common/uri';
import { IProcessEnvironment } from 'vs/base/common/platform';
import { env as processEnv } from 'vs/base/common/process';
import { IOpenerService } from 'vs/platform/opener/common/opener';
/**
* This interface represents a single command line argument split into a "prefix" and a "path" half.
@@ -74,7 +75,8 @@ export class RawDebugSession {
dbgr: IDebugger,
private readonly telemetryService: ITelemetryService,
public readonly customTelemetryService: ITelemetryService | undefined,
private readonly windowsService: IWindowsService
private readonly windowsService: IWindowsService,
private readonly openerService: IOpenerService
) {
this.debugAdapter = debugAdapter;
@@ -652,7 +654,7 @@ export class RawDebugSession {
const label = error.urlLabel ? error.urlLabel : nls.localize('moreInfo', "More Info");
return createErrorWithActions(userMessage, {
actions: [new Action('debug.moreInfo', label, undefined, true, () => {
window.open(error.url);
this.openerService.open(URI.parse(error.url));
return Promise.resolve(null);
})]
});

View File

@@ -62,7 +62,7 @@ import { RunOnceScheduler } from 'vs/base/common/async';
import { FuzzyScore, createMatches } from 'vs/base/common/filters';
import { HighlightedLabel } from 'vs/base/browser/ui/highlightedlabel/highlightedLabel';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { VariablesRenderer, variableSetEmitter } from 'vs/workbench/contrib/debug/browser/variablesView';
import { VariablesRenderer } from 'vs/workbench/contrib/debug/browser/variablesView';
const $ = dom.$;
@@ -104,6 +104,7 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
private scopedInstantiationService!: IInstantiationService;
private replElementsChangeListener: IDisposable | undefined;
private styleElement: HTMLStyleElement | undefined;
private completionItemProvider: IDisposable | undefined;
constructor(
@IDebugService private readonly debugService: IDebugService,
@@ -131,7 +132,33 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
this._register(this.debugService.getViewModel().onDidFocusSession(session => {
if (session) {
sessionsToIgnore.delete(session);
if (this.completionItemProvider) {
this.completionItemProvider.dispose();
}
if (session.capabilities.supportsCompletionsRequest) {
this.completionItemProvider = CompletionProviderRegistry.register({ scheme: DEBUG_SCHEME, pattern: '**/replinput', hasAccessToAllModels: true }, {
triggerCharacters: session.capabilities.completionTriggerCharacters || ['.'],
provideCompletionItems: async (_: ITextModel, position: Position, _context: CompletionContext, token: CancellationToken): Promise<CompletionList> => {
// Disable history navigation because up and down are used to navigate through the suggest widget
this.historyNavigationEnablement.set(false);
const model = this.replInput.getModel();
if (model) {
const word = model.getWordAtPosition(position);
const overwriteBefore = word ? word.word.length : 0;
const text = model.getLineContent(position.lineNumber);
const focusedStackFrame = this.debugService.getViewModel().focusedStackFrame;
const frameId = focusedStackFrame ? focusedStackFrame.frameId : undefined;
const suggestions = await session.completions(frameId, text, position, overwriteBefore);
return { suggestions };
}
return Promise.resolve({ suggestions: [] });
}
});
}
}
this.selectSession();
}));
this._register(this.debugService.onWillNewSession(newSession => {
@@ -274,7 +301,6 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
revealLastElement(this.tree);
this.history.add(this.replInput.getValue());
this.replInput.setValue('');
variableSetEmitter.fire();
const shouldRelayout = this.replInputHeight > Repl.REPL_INPUT_INITIAL_HEIGHT;
this.replInputHeight = Repl.REPL_INPUT_INITIAL_HEIGHT;
if (shouldRelayout) {
@@ -418,6 +444,7 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
private createReplInput(container: HTMLElement): void {
this.replInputContainer = dom.append(container, $('.repl-input-wrapper'));
this.replInputContainer.title = nls.localize('debugConsole', "Debug Console");
const { scopedContextKeyService, historyNavigationEnablement } = createAndBindHistoryNavigationWidgetScopedContextKeyService(this.contextKeyService, { target: this.replInputContainer, historyNavigator: this });
this.historyNavigationEnablement = historyNavigationEnablement;
@@ -430,34 +457,6 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
options.readOnly = true;
this.replInput = this.scopedInstantiationService.createInstance(CodeEditorWidget, this.replInputContainer, options, getSimpleCodeEditorWidgetOptions());
CompletionProviderRegistry.register({ scheme: DEBUG_SCHEME, pattern: '**/replinput', hasAccessToAllModels: true }, {
triggerCharacters: ['.'],
provideCompletionItems: (model: ITextModel, position: Position, _context: CompletionContext, token: CancellationToken): Promise<CompletionList> => {
// Disable history navigation because up and down are used to navigate through the suggest widget
this.historyNavigationEnablement.set(false);
const focusedSession = this.debugService.getViewModel().focusedSession;
if (focusedSession && focusedSession.capabilities.supportsCompletionsRequest) {
const model = this.replInput.getModel();
if (model) {
const word = model.getWordAtPosition(position);
const overwriteBefore = word ? word.word.length : 0;
const text = model.getLineContent(position.lineNumber);
const focusedStackFrame = this.debugService.getViewModel().focusedStackFrame;
const frameId = focusedStackFrame ? focusedStackFrame.frameId : undefined;
return focusedSession.completions(frameId, text, position, overwriteBefore).then(suggestions => {
return { suggestions };
}, err => {
return { suggestions: [] };
});
}
}
return Promise.resolve({ suggestions: [] });
}
});
this._register(this.replInput.onDidScrollChange(e => {
if (!e.scrollHeightChanged) {
return;

View File

@@ -168,7 +168,7 @@ declare module DebugProtocol {
category?: string;
/** The output to report. */
output: string;
/** If an attribute 'variablesReference' exists and its value is > 0, the output contains objects which can be retrieved by passing 'variablesReference' to the 'variables' request. */
/** If an attribute 'variablesReference' exists and its value is > 0, the output contains objects which can be retrieved by passing 'variablesReference' to the 'variables' request. The value should be less than or equal to 2147483647 (2^31 - 1). */
variablesReference?: number;
/** An optional source location where the output was produced. */
source?: Source;
@@ -284,9 +284,9 @@ declare module DebugProtocol {
/** Response to 'runInTerminal' request. */
export interface RunInTerminalResponse extends Response {
body: {
/** The process ID. */
/** The process ID. The value should be less than or equal to 2147483647 (2^31 - 1). */
processId?: number;
/** The process ID of the terminal shell. */
/** The process ID of the terminal shell. The value should be less than or equal to 2147483647 (2^31 - 1). */
shellProcessId?: number;
};
}
@@ -757,7 +757,7 @@ declare module DebugProtocol {
}
/** Pause request; value of command field is 'pause'.
The request suspenses the debuggee.
The request suspends the debuggee.
The debug adapter first sends the response and then a 'stopped' event (with reason 'pause') after the thread has been paused successfully.
*/
export interface PauseRequest extends Request {
@@ -842,7 +842,7 @@ declare module DebugProtocol {
export interface VariablesArguments {
/** The Variable reference. */
variablesReference: number;
/** Optional filter to limit the child variables to either named or indexed. If ommited, both types are fetched. */
/** Optional filter to limit the child variables to either named or indexed. If omitted, both types are fetched. */
filter?: 'indexed' | 'named';
/** The index of the first variable to return; if omitted children start at 0. */
start?: number;
@@ -887,14 +887,14 @@ declare module DebugProtocol {
value: string;
/** The type of the new value. Typically shown in the UI when hovering over the value. */
type?: string;
/** If variablesReference is > 0, the new value is structured and its children can be retrieved by passing variablesReference to the VariablesRequest. */
/** If variablesReference is > 0, the new value is structured and its children can be retrieved by passing variablesReference to the VariablesRequest. The value should be less than or equal to 2147483647 (2^31 - 1). */
variablesReference?: number;
/** The number of named child variables.
The client can use this optional information to present the variables in a paged UI and fetch them in chunks.
The client can use this optional information to present the variables in a paged UI and fetch them in chunks. The value should be less than or equal to 2147483647 (2^31 - 1).
*/
namedVariables?: number;
/** The number of indexed child variables.
The client can use this optional information to present the variables in a paged UI and fetch them in chunks.
The client can use this optional information to present the variables in a paged UI and fetch them in chunks. The value should be less than or equal to 2147483647 (2^31 - 1).
*/
indexedVariables?: number;
};
@@ -1041,14 +1041,14 @@ declare module DebugProtocol {
type?: string;
/** Properties of a evaluate result that can be used to determine how to render the result in the UI. */
presentationHint?: VariablePresentationHint;
/** If variablesReference is > 0, the evaluate result is structured and its children can be retrieved by passing variablesReference to the VariablesRequest. */
/** If variablesReference is > 0, the evaluate result is structured and its children can be retrieved by passing variablesReference to the VariablesRequest. The value should be less than or equal to 2147483647 (2^31 - 1). */
variablesReference: number;
/** The number of named child variables.
The client can use this optional information to present the variables in a paged UI and fetch them in chunks.
The client can use this optional information to present the variables in a paged UI and fetch them in chunks. The value should be less than or equal to 2147483647 (2^31 - 1).
*/
namedVariables?: number;
/** The number of indexed child variables.
The client can use this optional information to present the variables in a paged UI and fetch them in chunks.
The client can use this optional information to present the variables in a paged UI and fetch them in chunks. The value should be less than or equal to 2147483647 (2^31 - 1).
*/
indexedVariables?: number;
/** Memory reference to a location appropriate for this result. For pointer type eval results, this is generally a reference to the memory address contained in the pointer. */
@@ -1086,14 +1086,14 @@ declare module DebugProtocol {
type?: string;
/** Properties of a value that can be used to determine how to render the result in the UI. */
presentationHint?: VariablePresentationHint;
/** If variablesReference is > 0, the value is structured and its children can be retrieved by passing variablesReference to the VariablesRequest. */
/** If variablesReference is > 0, the value is structured and its children can be retrieved by passing variablesReference to the VariablesRequest. The value should be less than or equal to 2147483647 (2^31 - 1). */
variablesReference?: number;
/** The number of named child variables.
The client can use this optional information to present the variables in a paged UI and fetch them in chunks.
The client can use this optional information to present the variables in a paged UI and fetch them in chunks. The value should be less than or equal to 2147483647 (2^31 - 1).
*/
namedVariables?: number;
/** The number of indexed child variables.
The client can use this optional information to present the variables in a paged UI and fetch them in chunks.
The client can use this optional information to present the variables in a paged UI and fetch them in chunks. The value should be less than or equal to 2147483647 (2^31 - 1).
*/
indexedVariables?: number;
};
@@ -1294,6 +1294,8 @@ declare module DebugProtocol {
supportsStepInTargetsRequest?: boolean;
/** The debug adapter supports the 'completions' request. */
supportsCompletionsRequest?: boolean;
/** The set of characters that should trigger completion in a REPL. If not specified, the UI should assume the '.' character. */
completionTriggerCharacters?: string[];
/** The debug adapter supports the 'modules' request. */
supportsModulesRequest?: boolean;
/** The set of additional module information exposed by the debug adapter. */
@@ -1433,7 +1435,7 @@ declare module DebugProtocol {
name?: string;
/** The path of the source to be shown in the UI. It is only used to locate and load the content of the source if no sourceReference is specified (or its value is 0). */
path?: string;
/** If sourceReference > 0 the contents of the source must be retrieved through the SourceRequest (even if a path is specified). A sourceReference is only valid for a session, so it must not be used to persist a source. */
/** If sourceReference > 0 the contents of the source must be retrieved through the SourceRequest (even if a path is specified). A sourceReference is only valid for a session, so it must not be used to persist a source. The value should be less than or equal to 2147483647 (2^31 - 1). */
sourceReference?: number;
/** An optional hint for how to present the source in the UI. A value of 'deemphasize' can be used to indicate that the source is not available or that it is skipped on stepping. */
presentationHint?: 'normal' | 'emphasize' | 'deemphasize';
@@ -1668,6 +1670,8 @@ declare module DebugProtocol {
label: string;
/** If text is not falsy then it is inserted instead of the label. */
text?: string;
/** A string that should be used when comparing this item with other items. When `falsy` the label is used. */
sortText?: string;
/** The item's type. Typically the client uses this information to render the item in the UI with an icon. */
type?: CompletionItemType;
/** This value determines the location (in the CompletionsRequest's 'text' attribute) where the completion text is added.
@@ -1729,7 +1733,7 @@ declare module DebugProtocol {
/** This enumeration defines all possible conditions when a thrown exception should result in a break.
never: never breaks,
always: always breaks,
unhandled: breaks when excpetion unhandled,
unhandled: breaks when exception unhandled,
userUnhandled: breaks if the exception is not handled by user code.
*/
export type ExceptionBreakMode = 'never' | 'always' | 'unhandled' | 'userUnhandled';
@@ -1766,7 +1770,7 @@ declare module DebugProtocol {
instructionBytes?: string;
/** Text representing the instruction and its operands, in an implementation-defined format. */
instruction: string;
/** Name of the symbol that correponds with the location of this instruction, if any. */
/** Name of the symbol that corresponds with the location of this instruction, if any. */
symbol?: string;
/** Source location that corresponds to this instruction, if any. Should always be set (if available) on the first instruction returned, but can be omitted afterwards if this instruction maps to the same source file as the previous instruction. */
location?: Source;

View File

@@ -13,9 +13,10 @@ import { Source } from 'vs/workbench/contrib/debug/common/debugSource';
import { DebugSession } from 'vs/workbench/contrib/debug/browser/debugSession';
import { ReplModel } from 'vs/workbench/contrib/debug/common/replModel';
import { IBreakpointUpdateData } from 'vs/workbench/contrib/debug/common/debug';
import { NullOpenerService } from 'vs/platform/opener/common/opener';
function createMockSession(model: DebugModel, name = 'mockSession', parentSession?: DebugSession | undefined): DebugSession {
return new DebugSession({ resolved: { name, type: 'node', request: 'launch' }, unresolved: undefined }, undefined!, model, parentSession, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!);
return new DebugSession({ resolved: { name, type: 'node', request: 'launch' }, unresolved: undefined }, undefined!, model, parentSession, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, NullOpenerService);
}
suite('Debug - Model', () => {
@@ -427,7 +428,7 @@ suite('Debug - Model', () => {
// Repl output
test('repl output', () => {
const session = new DebugSession({ resolved: { name: 'mockSession', type: 'node', request: 'launch' }, unresolved: undefined }, undefined!, model, undefined, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!);
const session = new DebugSession({ resolved: { name: 'mockSession', type: 'node', request: 'launch' }, unresolved: undefined }, undefined!, model, undefined, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, NullOpenerService);
const repl = new ReplModel(session);
repl.appendToRepl('first line\n', severity.Error);
repl.appendToRepl('second line ', severity.Error);