Skip to content

Commit

Permalink
Merge branch 'main' into notebook_comment_lifecycle
Browse files Browse the repository at this point in the history
  • Loading branch information
rehmsen authored Jun 17, 2024
2 parents 825680c + b8d1155 commit 87aad98
Show file tree
Hide file tree
Showing 271 changed files with 6,001 additions and 3,167 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/devcontainers/typescript-node:18-bookworm
FROM mcr.microsoft.com/devcontainers/typescript-node:20-bookworm

ADD install-vscode.sh /root/
RUN /root/install-vscode.sh
Expand Down
4 changes: 2 additions & 2 deletions .github/classifier.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"debug": {"assign": ["roblourens"]},
"debug-disassembly": {"assign": []},
"dialogs": {"assign": ["sbatten"]},
"diff-editor": {"assign": ["alexdima"]},
"diff-editor": {"assign": ["hediet"]},
"dropdown": {"assign": ["lramos15"]},
"editor-api": {"assign": ["alexdima"]},
"editor-autoclosing": {"assign": ["alexdima"]},
Expand Down Expand Up @@ -116,7 +116,7 @@
"json": {"assign": ["aeschli"]},
"json-sorting": {"assign": ["aiday-mar"]},
"keybindings": {"assign": ["ulugbekna"]},
"keybindings-editor": {"assign": ["sandy081"]},
"keybindings-editor": {"assign": ["ulugbekna"]},
"keyboard-layout": {"assign": ["ulugbekna"]},
"L10N": {"assign": ["TylerLeonhardt", "csigs"]},
"l10n-platform": {"assign": ["TylerLeonhardt"]},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { IstanbulCoverageContext } from 'istanbul-to-vscode';
import * as vscode from 'vscode';
import { SourceLocationMapper, SourceMapStore } from './testOutputScanner';
import { SearchStrategy, SourceLocationMapper, SourceMapStore } from './testOutputScanner';
import { IScriptCoverage, OffsetToPosition, RangeCoverageTracker } from './v8CoverageWrangling';

export const istanbulCoverageContext = new IstanbulCoverageContext();
Expand All @@ -18,7 +18,7 @@ export const istanbulCoverageContext = new IstanbulCoverageContext();
export class PerTestCoverageTracker {
private readonly scripts = new Map</* script ID */ string, Script>();

constructor(private readonly maps: SourceMapStore) {}
constructor(private readonly maps: SourceMapStore) { }

public add(coverage: IScriptCoverage, test?: vscode.TestItem) {
const script = this.scripts.get(coverage.scriptId);
Expand Down Expand Up @@ -71,11 +71,7 @@ class Script {
public async report(run: vscode.TestRun) {
const mapper = await this.maps.getSourceLocationMapper(this.uri.toString());
const originalUri = (await this.maps.getSourceFile(this.uri.toString())) || this.uri;

run.addCoverage(this.overall.report(originalUri, this.converter, mapper));
for (const [test, projection] of this.perItem) {
run.addCoverage(projection.report(originalUri, this.converter, mapper, test));
}
run.addCoverage(this.overall.report(originalUri, this.converter, mapper, this.perItem));
}
}

Expand All @@ -88,20 +84,11 @@ class ScriptCoverageTracker {
}
}

/**
* Generates the script's coverage for the test run.
*
* If a source location mapper is given, it assumes the `uri` is the mapped
* URI, and that any unmapped locations/outside the URI should be ignored.
*/
public report(
public *toDetails(
uri: vscode.Uri,
convert: OffsetToPosition,
mapper: SourceLocationMapper | undefined,
item?: vscode.TestItem
): V8CoverageFile {
const file = new V8CoverageFile(uri, item);

) {
for (const range of this.coverage) {
if (range.start === range.end) {
continue;
Expand All @@ -113,8 +100,8 @@ class ScriptCoverageTracker {
const endCov = convert.toLineColumn(range.end);
let end = new vscode.Position(endCov.line, endCov.column);
if (mapper) {
const startMap = mapper(start.line, start.character);
const endMap = startMap && mapper(end.line, end.character);
const startMap = mapper(start.line, start.character, SearchStrategy.FirstAfter);
const endMap = startMap && mapper(end.line, end.character, SearchStrategy.FirstBefore);
if (!endMap || uri.toString().toLowerCase() !== endMap.uri.toString().toLowerCase()) {
continue;
}
Expand All @@ -123,28 +110,48 @@ class ScriptCoverageTracker {
}

for (let i = start.line; i <= end.line; i++) {
file.add(
new vscode.StatementCoverage(
range.covered,
new vscode.Range(
new vscode.Position(i, i === start.line ? start.character : 0),
new vscode.Position(i, i === end.line ? end.character : Number.MAX_SAFE_INTEGER)
)
yield new vscode.StatementCoverage(
range.covered,
new vscode.Range(
new vscode.Position(i, i === start.line ? start.character : 0),
new vscode.Position(i, i === end.line ? end.character : Number.MAX_SAFE_INTEGER)
)
);
}
}
}

/**
* Generates the script's coverage for the test run.
*
* If a source location mapper is given, it assumes the `uri` is the mapped
* URI, and that any unmapped locations/outside the URI should be ignored.
*/
public report(
uri: vscode.Uri,
convert: OffsetToPosition,
mapper: SourceLocationMapper | undefined,
items: Map<vscode.TestItem, ScriptCoverageTracker>,
): V8CoverageFile {
const file = new V8CoverageFile(uri, items, convert, mapper);
for (const detail of this.toDetails(uri, convert, mapper)) {
file.add(detail);
}

return file;
}
}

export class V8CoverageFile extends vscode.FileCoverage {
export class V8CoverageFile extends vscode.FileCoverage2 {
public details: vscode.StatementCoverage[] = [];

constructor(uri: vscode.Uri, item?: vscode.TestItem) {
super(uri, { covered: 0, total: 0 });
(this as vscode.FileCoverage2).testItem = item;
constructor(
uri: vscode.Uri,
private readonly perTest: Map<vscode.TestItem, ScriptCoverageTracker>,
private readonly convert: OffsetToPosition,
private readonly mapper: SourceLocationMapper | undefined,
) {
super(uri, { covered: 0, total: 0 }, undefined, undefined, [...perTest.keys()]);
}

public add(detail: vscode.StatementCoverage) {
Expand All @@ -154,4 +161,9 @@ export class V8CoverageFile extends vscode.FileCoverage {
this.statementCoverage.covered++;
}
}

public testDetails(test: vscode.TestItem): vscode.FileCoverageDetail[] {
const t = this.perTest.get(test);
return t ? [...t.toDetails(this.uri, this.convert, this.mapper)] : [];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ export async function activate(context: vscode.ExtensionContext) {
true
);

coverage.loadDetailedCoverage = async (_run, coverage) => {
(coverage as vscode.TestRunProfile2).loadDetailedCoverage = async (_run, coverage, _token, test) => {
if (coverage instanceof V8CoverageFile) {
return coverage.details;
return test ? coverage.testDetails(test) : coverage.details;
}

return [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,44 +424,94 @@ const tryMakeMarkdown = (message: string) => {
const inlineSourcemapRe = /^\/\/# sourceMappingURL=data:application\/json;base64,(.+)/m;
const sourceMapBiases = [GREATEST_LOWER_BOUND, LEAST_UPPER_BOUND] as const;

export type SourceLocationMapper = (line: number, col: number) => vscode.Location | undefined;
export const enum SearchStrategy {
FirstBefore = -1,
FirstAfter = 1,
}

export type SourceLocationMapper = (line: number, col: number, strategy: SearchStrategy) => vscode.Location | undefined;

export class SourceMapStore {
private readonly cache = new Map</* file uri */ string, Promise<TraceMap | undefined>>();

async getSourceLocationMapper(fileUri: string) {
async getSourceLocationMapper(fileUri: string): Promise<SourceLocationMapper> {
const sourceMap = await this.loadSourceMap(fileUri);
return (line: number, col: number) => {
return (line, col, strategy) => {
if (!sourceMap) {
return undefined;
}

let smLine = line + 1;
// 1. Look for the ideal position on this line if it exists
const idealPosition = originalPositionFor(sourceMap, { column: col, line: line + 1, bias: SearchStrategy.FirstAfter ? GREATEST_LOWER_BOUND : LEAST_UPPER_BOUND });
if (idealPosition.line !== null && idealPosition.column !== null && idealPosition.source !== null) {
return new vscode.Location(
this.completeSourceMapUrl(sourceMap, idealPosition.source),
new vscode.Position(idealPosition.line - 1, idealPosition.column)
);
}

// if the range is after the end of mappings, adjust it to the last mapped line
// Otherwise get the first/last valid mapping on another line.
const decoded = decodedMappings(sourceMap);
if (decoded.length <= line) {
smLine = decoded.length; // base 1, no -1 needed
col = Number.MAX_SAFE_INTEGER;
const enum MapField {
COLUMN = 0,
SOURCES_INDEX = 1,
SOURCE_LINE = 2,
SOURCE_COLUMN = 3,
}

for (const bias of sourceMapBiases) {
const position = originalPositionFor(sourceMap, { column: col, line: smLine, bias });
if (position.line !== null && position.column !== null && position.source !== null) {
return new vscode.Location(
this.completeSourceMapUrl(sourceMap, position.source),
new vscode.Position(position.line - 1, position.column)
);
do {
line += strategy;
const segments = decoded[line];
if (!segments?.length) {
continue;
}
}

const index = strategy === SearchStrategy.FirstBefore
? findLastIndex(segments, s => s.length !== 1)
: segments.findIndex(s => s.length !== 1);
const segment = segments[index];

if (!segment || segment.length === 1) {
continue;
}

return new vscode.Location(
this.completeSourceMapUrl(sourceMap, sourceMap.sources[segment[MapField.SOURCES_INDEX]]!),
new vscode.Position(segment[MapField.SOURCE_LINE] - 1, segment[MapField.SOURCE_COLUMN])
);
} while (strategy === SearchStrategy.FirstBefore ? line > 0 : line < decoded.length);

return undefined;
};
}

/** Gets an original location from a base 0 line and column */
async getSourceLocation(fileUri: string, line: number, col = 0) {
return this.getSourceLocationMapper(fileUri).then(m => m(line, col));
const sourceMap = await this.loadSourceMap(fileUri);
if (!sourceMap) {
return undefined;
}

let smLine = line + 1;

// if the range is after the end of mappings, adjust it to the last mapped line
const decoded = decodedMappings(sourceMap);
if (decoded.length <= line) {
smLine = decoded.length; // base 1, no -1 needed
col = Number.MAX_SAFE_INTEGER;
}

for (const bias of sourceMapBiases) {
const position = originalPositionFor(sourceMap, { column: col, line: smLine, bias });
if (position.line !== null && position.column !== null && position.source !== null) {
return new vscode.Location(
this.completeSourceMapUrl(sourceMap, position.source),
new vscode.Position(position.line - 1, position.column)
);
}
}

return undefined;
}

async getSourceFile(compiledUri: string) {
Expand Down Expand Up @@ -602,3 +652,13 @@ async function deriveSourceLocation(store: SourceMapStore, parts: RegExpMatchArr
const [, fileUri, line, col] = parts;
return store.getSourceLocation(fileUri, Number(line) - 1, Number(col));
}

function findLastIndex<T>(arr: T[], predicate: (value: T) => boolean) {
for (let i = arr.length - 1; i >= 0; i--) {
if (predicate(arr[i])) {
return i;
}
}

return -1;
}
2 changes: 1 addition & 1 deletion .vscode/notebooks/api.github-issues
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{
"kind": 2,
"language": "github-issues",
"value": "$REPO=repo:microsoft/vscode\n$MILESTONE=milestone:\"May 2024\""
"value": "$REPO=repo:microsoft/vscode\n$MILESTONE=milestone:\"June 2024\""
},
{
"kind": 1,
Expand Down
2 changes: 1 addition & 1 deletion .vscode/notebooks/my-endgame.github-issues
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{
"kind": 2,
"language": "github-issues",
"value": "$REPOS=repo:microsoft/lsprotocol repo:microsoft/monaco-editor repo:microsoft/vscode repo:microsoft/vscode-anycode repo:microsoft/vscode-autopep8 repo:microsoft/vscode-black-formatter repo:microsoft/vscode-copilot repo:microsoft/vscode-copilot-release repo:microsoft/vscode-dev repo:microsoft/vscode-dev-chrome-launcher repo:microsoft/vscode-emmet-helper repo:microsoft/vscode-extension-telemetry repo:microsoft/vscode-flake8 repo:microsoft/vscode-github-issue-notebooks repo:microsoft/vscode-hexeditor repo:microsoft/vscode-internalbacklog repo:microsoft/vscode-isort repo:microsoft/vscode-js-debug repo:microsoft/vscode-jupyter repo:microsoft/vscode-jupyter-internal repo:microsoft/vscode-l10n repo:microsoft/vscode-livepreview repo:microsoft/vscode-markdown-languageservice repo:microsoft/vscode-markdown-tm-grammar repo:microsoft/vscode-mypy repo:microsoft/vscode-pull-request-github repo:microsoft/vscode-pylint repo:microsoft/vscode-python repo:microsoft/vscode-python-debugger repo:microsoft/vscode-python-tools-extension-template repo:microsoft/vscode-references-view repo:microsoft/vscode-remote-release repo:microsoft/vscode-remote-repositories-github repo:microsoft/vscode-remote-tunnels repo:microsoft/vscode-remotehub repo:microsoft/vscode-settings-sync-server repo:microsoft/vscode-unpkg repo:microsoft/vscode-vsce\n\n$MILESTONE=milestone:\"May 2024\"\n\n$MINE=assignee:@me"
"value": "$REPOS=repo:microsoft/lsprotocol repo:microsoft/monaco-editor repo:microsoft/vscode repo:microsoft/vscode-anycode repo:microsoft/vscode-autopep8 repo:microsoft/vscode-black-formatter repo:microsoft/vscode-copilot repo:microsoft/vscode-copilot-release repo:microsoft/vscode-dev repo:microsoft/vscode-dev-chrome-launcher repo:microsoft/vscode-emmet-helper repo:microsoft/vscode-extension-telemetry repo:microsoft/vscode-flake8 repo:microsoft/vscode-github-issue-notebooks repo:microsoft/vscode-hexeditor repo:microsoft/vscode-internalbacklog repo:microsoft/vscode-isort repo:microsoft/vscode-js-debug repo:microsoft/vscode-jupyter repo:microsoft/vscode-jupyter-internal repo:microsoft/vscode-l10n repo:microsoft/vscode-livepreview repo:microsoft/vscode-markdown-languageservice repo:microsoft/vscode-markdown-tm-grammar repo:microsoft/vscode-mypy repo:microsoft/vscode-pull-request-github repo:microsoft/vscode-pylint repo:microsoft/vscode-python repo:microsoft/vscode-python-debugger repo:microsoft/vscode-python-tools-extension-template repo:microsoft/vscode-references-view repo:microsoft/vscode-remote-release repo:microsoft/vscode-remote-repositories-github repo:microsoft/vscode-remote-tunnels repo:microsoft/vscode-remotehub repo:microsoft/vscode-settings-sync-server repo:microsoft/vscode-unpkg repo:microsoft/vscode-vsce\n\n$MILESTONE=milestone:\"June 2024\"\n\n$MINE=assignee:@me"
},
{
"kind": 1,
Expand Down
2 changes: 1 addition & 1 deletion .vscode/notebooks/my-work.github-issues
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{
"kind": 2,
"language": "github-issues",
"value": "// list of repos we work in\n$REPOS=repo:microsoft/lsprotocol repo:microsoft/monaco-editor repo:microsoft/vscode repo:microsoft/vscode-anycode repo:microsoft/vscode-autopep8 repo:microsoft/vscode-black-formatter repo:microsoft/vscode-copilot repo:microsoft/vscode-copilot-release repo:microsoft/vscode-dev repo:microsoft/vscode-dev-chrome-launcher repo:microsoft/vscode-emmet-helper repo:microsoft/vscode-extension-telemetry repo:microsoft/vscode-flake8 repo:microsoft/vscode-github-issue-notebooks repo:microsoft/vscode-hexeditor repo:microsoft/vscode-internalbacklog repo:microsoft/vscode-isort repo:microsoft/vscode-js-debug repo:microsoft/vscode-jupyter repo:microsoft/vscode-jupyter-internal repo:microsoft/vscode-l10n repo:microsoft/vscode-livepreview repo:microsoft/vscode-markdown-languageservice repo:microsoft/vscode-markdown-tm-grammar repo:microsoft/vscode-mypy repo:microsoft/vscode-pull-request-github repo:microsoft/vscode-pylint repo:microsoft/vscode-python repo:microsoft/vscode-python-debugger repo:microsoft/vscode-python-tools-extension-template repo:microsoft/vscode-references-view repo:microsoft/vscode-remote-release repo:microsoft/vscode-remote-repositories-github repo:microsoft/vscode-remote-tunnels repo:microsoft/vscode-remotehub repo:microsoft/vscode-settings-sync-server repo:microsoft/vscode-unpkg repo:microsoft/vscode-vsce\n\n// current milestone name\n$MILESTONE=milestone:\"May 2024\"\n"
"value": "// list of repos we work in\n$REPOS=repo:microsoft/lsprotocol repo:microsoft/monaco-editor repo:microsoft/vscode repo:microsoft/vscode-anycode repo:microsoft/vscode-autopep8 repo:microsoft/vscode-black-formatter repo:microsoft/vscode-copilot repo:microsoft/vscode-copilot-release repo:microsoft/vscode-dev repo:microsoft/vscode-dev-chrome-launcher repo:microsoft/vscode-emmet-helper repo:microsoft/vscode-extension-telemetry repo:microsoft/vscode-flake8 repo:microsoft/vscode-github-issue-notebooks repo:microsoft/vscode-hexeditor repo:microsoft/vscode-internalbacklog repo:microsoft/vscode-isort repo:microsoft/vscode-js-debug repo:microsoft/vscode-jupyter repo:microsoft/vscode-jupyter-internal repo:microsoft/vscode-l10n repo:microsoft/vscode-livepreview repo:microsoft/vscode-markdown-languageservice repo:microsoft/vscode-markdown-tm-grammar repo:microsoft/vscode-mypy repo:microsoft/vscode-pull-request-github repo:microsoft/vscode-pylint repo:microsoft/vscode-python repo:microsoft/vscode-python-debugger repo:microsoft/vscode-python-tools-extension-template repo:microsoft/vscode-references-view repo:microsoft/vscode-remote-release repo:microsoft/vscode-remote-repositories-github repo:microsoft/vscode-remote-tunnels repo:microsoft/vscode-remotehub repo:microsoft/vscode-settings-sync-server repo:microsoft/vscode-unpkg repo:microsoft/vscode-vsce\n\n// current milestone name\n$MILESTONE=milestone:\"June 2024\"\n"
},
{
"kind": 1,
Expand Down
6 changes: 3 additions & 3 deletions build/azure-pipelines/product-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ extends:
- job: CLIMacOSX64
pool:
name: Azure Pipelines
image: macOS-11
image: macOS-13
os: macOS
steps:
- template: build/azure-pipelines/darwin/cli-build-darwin.yml@self
Expand All @@ -284,7 +284,7 @@ extends:
- job: CLIMacOSARM64
pool:
name: Azure Pipelines
image: macOS-11
image: macOS-13
os: macOS
steps:
- template: build/azure-pipelines/darwin/cli-build-darwin.yml@self
Expand Down Expand Up @@ -597,7 +597,7 @@ extends:
- CompileCLI
pool:
name: Azure Pipelines
image: macOS-11
image: macOS-13
os: macOS
variables:
BUILDSECMON_OPT_IN: true
Expand Down
3 changes: 2 additions & 1 deletion build/gulpfile.reh.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ function getNodeChecksum(nodeVersion, platform, arch, glibcPrefix) {
let expectedName;
switch (platform) {
case 'win32':
expectedName = `win-${arch}/node.exe`;
expectedName = product.nodejsRepository !== 'https://nodejs.org' ?
`win-${arch}-node.exe` : `win-${arch}/node.exe`;
break;

case 'darwin':
Expand Down
4 changes: 1 addition & 3 deletions build/lib/stylelint/vscode-known-variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -818,8 +818,6 @@
"--vscode-hover-maxWidth",
"--vscode-hover-sourceWhiteSpace",
"--vscode-hover-whiteSpace",
"--vscode-inline-chat-quick-voice-height",
"--vscode-inline-chat-quick-voice-width",
"--vscode-editor-dictation-widget-height",
"--vscode-editor-dictation-widget-width",
"--vscode-interactive-session-foreground",
Expand Down Expand Up @@ -855,4 +853,4 @@
"--zoom-factor",
"--test-bar-width"
]
}
}
2 changes: 1 addition & 1 deletion build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "MIT",
"devDependencies": {
"@azure/cosmos": "^3",
"@azure/identity": "^3.4.1",
"@azure/identity": "^4.2.1",
"@azure/storage-blob": "^12.17.0",
"@electron/get": "^2.0.0",
"@types/ansi-colors": "^3.2.0",
Expand Down
Loading

0 comments on commit 87aad98

Please sign in to comment.