debugUtils.ts ×21

Frontier kind: Code frontier

unlabeled · c_37380178b219

12 tests · 11902 LOC · 51 files · introduces 0 tests · 86 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
21 ranges86 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1671 ranges11902 lines · 51 files · Browse complete extent
All tests (intent)
12 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 86 introduced LOC across 21 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/contrib/debug/common/debugUtils.ts 86 introduced LOC · 21 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- debugUtils.ts
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import { equalsIgnoreCase } from '../../../../base/common/strings.js';
7 > import { IDebuggerContribution, IDebugSession, IConfig, IConfigPresentation, State } from './debug.js';
8 > import { URI as uri } from '../../../../base/common/uri.js';
9 > import { isAbsolute } from '../../../../base/common/path.js';
10 > import { deepClone } from '../../../../base/common/objects.js';
11 > import { Schemas } from '../../../../base/common/network.js';
12 > import { IEditorService } from '../../../services/editor/common/editorService.js';
13 > import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';
14 > import { ITextModel } from '../../../../editor/common/model.js';
15 > import { Position } from '../../../../editor/common/core/position.js';
16 > import { IRange, Range } from '../../../../editor/common/core/range.js';
17 > import { CancellationToken } from '../../../../base/common/cancellation.js';
18 > import { coalesce } from '../../../../base/common/arrays.js';
19 > import { ILanguageFeaturesService } from '../../../../editor/common/services/languageFeatures.js';
20 > import { OperatingSystem, OS } from '../../../../base/common/platform.js';
21 >
22 > const _formatPIIRegexp = /{([^}]+)}/g;
23 >
24 > export function formatPII(value: string, excludePII: boolean, args: { [key: string]: string } | undefined): string {
25 return value.replace(_formatPIIRegexp, function (match, group) {
26 if (excludePII && group.length > 0 && group[0] !== '_') {
33 });
34 }
36 > /**
37 > * Filters exceptions (keys marked with "!") from the given object. Used to
38 > * ensure exception data is not sent on web remotes, see #97628.
39 > */
40 > export function filterExceptionsFromTelemetry<T extends { [key: string]: unknown }>(data: T): Partial<T> {
41 const output: Partial<T> = {};
42 for (const key of Object.keys(data) as (keyof T & string)[]) {
48 return output;
49 }
51 >
52 > export function isSessionAttach(session: IDebugSession): boolean {
53 return session.configuration.request === 'attach' && !getExtensionHostDebugSession(session) && (!session.parentSession || isSessionAttach(session.parentSession));
54 }
56 > /**
57 > * Returns the session or any parent which is an extension host debug session.
58 > * Returns undefined if there's none.
59 > */
60 > export function getExtensionHostDebugSession(session: IDebugSession): IDebugSession | void {
61 let type = session.configuration.type;
62 if (!type) {
74 return session.parentSession ? getExtensionHostDebugSession(session.parentSession) : undefined;
75 }
77 > // only a debugger contributions with a label, program, or runtime attribute is considered a "defining" or "main" debugger contribution
78 > export function isDebuggerMainContribution(dbg: IDebuggerContribution) {
79 return dbg.type && (dbg.label || dbg.program || dbg.runtime);
80 }
82 > /**
83 > * Note- uses 1-indexed numbers
84 > */
85 > export function getExactExpressionStartAndEnd(lineContent: string, looseStart: number, looseEnd: number): { start: number; end: number } {
86 let matchingExpression: string | undefined = undefined;
87 let startOffset = 0;
134 { start: 0, end: 0 };
135 }
137 export async function getEvaluatableExpressionAtPosition(languageFeaturesService: ILanguageFeaturesService, model: ITextModel, position: Position, token?: CancellationToken): Promise<{ range: IRange; matchingExpression: string } | null> {
138 if (languageFeaturesService.evaluatableExpressionProvider.has(model)) {
172 return null;
173 }
175 > // RFC 2396, Appendix A: https://www.ietf.org/rfc/rfc2396.txt
176 > const _schemePattern = /^[a-zA-Z][a-zA-Z0-9\+\-\.]+:/;
177 >
178 > export function isUriString(s: string | undefined): boolean {
179 // heuristics: a valid uri starts with a scheme and
180 // the scheme has at least 2 characters so that it doesn't look like a drive letter.
181 return !!(s && s.match(_schemePattern));
182 }
184 function stringToUri(source: PathContainer): string | undefined {
185 if (typeof source.path === 'string') {
201 return source.path;
202 }
204 function uriToString(source: PathContainer): string | undefined {
205 if (typeof source.path === 'object') {
215 return source.path;
216 }
218 > // path hooks helpers
219 >
220 > interface PathContainer {
221 > path?: string;
222 > sourceReference?: number;
223 > }
224 >
225 > export function convertToDAPaths(message: DebugProtocol.ProtocolMessage, toUri: boolean): DebugProtocol.ProtocolMessage {
226
227 const fixPath = toUri ? stringToUri : uriToString;
237 return msg;
238 }
240 > export function convertToVSCPaths(message: DebugProtocol.ProtocolMessage, toUri: boolean): DebugProtocol.ProtocolMessage {
241
242 const fixPath = toUri ? stringToUri : uriToString;
252 return msg;
253 }
255 function convertPaths(msg: DebugProtocol.ProtocolMessage, fixSourcePath: (toDA: boolean, source: PathContainer | undefined) => void): void {
256
332 }
333 }
334 > export function getVisibleAndSorted<T extends { presentation?: IConfigPresentation }>(array: T[]): T[] { debugUtils.ts
335 return array.filter(config => !config.presentation?.hidden).sort((first, second) => {
336 if (!first.presentation) {
359 });
360 }
362 function compareOrders(first: number | undefined, second: number | undefined): number {
363 if (typeof first !== 'number') {
374 return first - second;
375 }
377 export async function saveAllBeforeDebugStart(configurationService: IConfigurationService, editorService: IEditorService): Promise<void> {
378 const saveBeforeStartConfig: string = configurationService.getValue('debug.saveBeforeStart', { overrideIdentifier: editorService.activeTextEditorLanguageId });
389 await configurationService.reloadConfiguration();
390 }
392 > export const sourcesEqual = (a: DebugProtocol.Source | undefined, b: DebugProtocol.Source | undefined): boolean =>
393 !a || !b ? a === b : a.name === b.name && a.path === b.path && a.sourceReference === b.sourceReference;
395 > /**
396 > * Resolves the best child session to focus when a parent session is selected.
397 > * Always prefer child sessions over parent wrapper sessions to ensure console responsiveness.
398 > * Fixes issue #152407: Using debug console picker when not paused leaves console unresponsive.
399 > */
400 > export function resolveChildSession(session: IDebugSession, allSessions: readonly IDebugSession[]): IDebugSession {
401 // Always focus child session instead of parent wrapper session #152407
402 const childSessions = allSessions.filter(s => s.parentSession === session);
414 return session;
415 }
417 > type IPlatformSpecificConfig = NonNullable<IConfig['windows']>;
418 >
419 function getPlatformSpecificConfig(config: IConfig, os: OperatingSystem): IPlatformSpecificConfig | undefined {
420 switch (os) {
427 }
428 }
430 > export function getEffectiveConfigForPlatform(config: IConfig, os: OperatingSystem = OS): IConfig {
431 const platformConfig = getPlatformSpecificConfig(config, os);
432 if (!platformConfig) {
440 };
441 }
443 > export function getEffectivePresentationForConfig(config: IConfig, os: OperatingSystem = OS): IConfigPresentation | undefined {
444 return getEffectiveConfigForPlatform(config, os).presentation;
445 }