export class CanonicalWorkspace implements IWorkspace {
constructor(
private readonly canonicalFolderUris: URI[],
private readonly canonicalConfiguration: URI | null | undefined
) { }
Frontier kind: Code frontier
unlabeled · c_729dae7ee7ed
6 tests · 25430 LOC · 136 files · introduces 0 tests · 148 LOC · 2 files
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.
Every exact file and test below is linked only from the concept that introduces it.
mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/instantiation/test/common/instantiationService.test|title=Instantiation Service @Param - fixed args|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/instantiation/test/common/instantiationService.test|title=Instantiation Service @Param - simple clase|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/lifecycle.test|title=Lifecycle Action bar has broken accessibility #100273|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/lifecycle.test|title=Lifecycle dispose disposable array|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/languageStatus/test/common/languageStatusDedupe.test|title=LanguageStatus - Dedicated Entry Deduplication creates new entry when none exists|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/languageStatus/test/common/languageStatusDedupe.test|title=LanguageStatus - Dedicated Entry Deduplication duplicate IDs with existing entry - fixed version reuses existing|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/languageStatus/test/common/languageStatusDedupe.test|title=LanguageStatus - Dedicated Entry Deduplication duplicate status IDs - buggy version leaks entry|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/languageStatus/test/common/languageStatusDedupe.test|title=LanguageStatus - Dedicated Entry Deduplication duplicate status IDs - fixed version reuses entry from current update|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/languageStatus/test/common/languageStatusDedupe.test|title=LanguageStatus - Dedicated Entry Deduplication mixed unique and duplicate IDs|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/languageStatus/test/common/languageStatusDedupe.test|title=LanguageStatus - Dedicated Entry Deduplication reuses existing entry from previous update|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/charCode.test|title=CharCode has good values|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/path.test|title=Paths (Node Implementation) path|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/uri.test|title=URI File paths containing apostrophes break URI parsing and cannot be opened #276075|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/uri.test|title=URI URI#file, win-speciale|occurrence=1Every collected test enters the hierarchy at exactly one concept.
No tests are introduced at this concept. Its intent tests are introduced by other concepts.
Every collected source range enters the hierarchy at exactly one concept.
2 files ranked by introduced lines: 148 introduced LOC across 36 ranges. Expand a file to inspect source; the > gutter marks introduced lines.
export class CanonicalWorkspace implements IWorkspace {
constructor(
private readonly canonicalFolderUris: URI[],
private readonly canonicalConfiguration: URI | null | undefined
) { }
constructor(
@IConfigurationService private readonly configurationService: IConfigurationService,
workspaceTrust.ts
@IRemoteAuthorityResolverService private readonly remoteAuthorityResolverService: IRemoteAuthorityResolverService,
@IStorageService private readonly storageService: IStorageService,
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService,
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
@IWorkspaceContextService private readonly workspaceService: IWorkspaceContextService,
@IWorkspaceTrustEnablementService private readonly workspaceTrustEnablementService: IWorkspaceTrustEnablementService,
@IFileService private readonly fileService: IFileService
) {
super();
this._canonicalUrisResolved = false;
this._canonicalWorkspace = this.workspaceService.getWorkspace();
({ promise: this._workspaceResolvedPromise, resolve: this._workspaceResolvedPromiseResolve } = promiseWithResolvers());
({ promise: this._workspaceTrustInitializedPromise, resolve: this._workspaceTrustInitializedPromiseResolve } = promiseWithResolvers());
this._storedTrustState = new WorkspaceTrustMemento(isWeb && this.isEmptyWorkspace() ? undefined : this.storageService);
this._trustTransitionManager = this._register(new WorkspaceTrustTransitionManager());
this._trustStateInfo = this.loadTrustInfo();
this._isTrusted = this.calculateWorkspaceTrust();
this.initializeWorkspaceTrust();
this.registerListeners();
}
//#region initialize
private initializeWorkspaceTrust(): void {
this.resolveCanonicalUris()
.then(async () => {
this._canonicalUrisResolved = true;
await this.updateWorkspaceTrust();
})
.finally(() => {
this._workspaceResolvedPromiseResolve();
if (!this.environmentService.remoteAuthority) {
this._workspaceTrustInitializedPromiseResolve();
}
});
// Remote - resolve remote authority
if (this.environmentService.remoteAuthority) {
this.remoteAuthorityResolverService.resolveAuthority(this.environmentService.remoteAuthority)
.then(async result => {
});
}
// Empty workspace - save initial state to memento
if (this.isEmptyWorkspace()) {
this._workspaceTrustInitializedPromise.then(() => {
if (this._storedTrustState.isEmptyWorkspaceTrusted === undefined) {
this._storedTrustState.isEmptyWorkspaceTrusted = this.isWorkspaceTrusted();
}
}
}
//#endregion
private registerListeners(): void {
this._register(this.workspaceService.onDidChangeWorkspaceFolders(async () => await this.updateWorkspaceTrust()));
workspaceTrust.ts
this._register(this.storageService.onDidChangeValue(StorageScope.APPLICATION_SHARED, this.storageKey, this._store)(async () => {
/* This will only execute if storage was changed by a user action in a separate window */
if (JSON.stringify(this._trustStateInfo) !== JSON.stringify(this.loadTrustInfo())) {
await this.updateWorkspaceTrust();
}
}
private async getCanonicalUri(uri: URI): Promise<URI> {
private async resolveCanonicalUris(): Promise<void> {
const filesToOpen: IPath[] = [];
if (this.environmentService.filesToOpenOrCreate) {
filesToOpen.push(...this.environmentService.filesToOpenOrCreate);
}
if (this.environmentService.filesToDiff) {
filesToOpen.push(...this.environmentService.filesToDiff);
}
if (this.environmentService.filesToMerge) {
filesToOpen.push(...this.environmentService.filesToMerge);
}
if (filesToOpen.length) {
const filesToOpenOrCreateUris = filesToOpen.filter(f => !!f.fileUri).map(f => f.fileUri!);
const canonicalFilesToOpen = await Promise.all(filesToOpenOrCreateUris.map(uri => this.getCanonicalUri(uri)));
this._canonicalStartupFiles.push(...canonicalFilesToOpen.filter(uri => this._canonicalStartupFiles.every(u => !this.uriIdentityService.extUri.isEqual(uri, u))));
}
// Workspace
const workspaceUris = this.workspaceService.getWorkspace().folders.map(f => f.uri);
const canonicalWorkspaceFolders = await Promise.all(workspaceUris.map(uri => this.getCanonicalUri(uri)));
let canonicalWorkspaceConfiguration = this.workspaceService.getWorkspace().configuration;
if (canonicalWorkspaceConfiguration && isSavedWorkspace(canonicalWorkspaceConfiguration, this.environmentService)) {
canonicalWorkspaceConfiguration = await this.getCanonicalUri(canonicalWorkspaceConfiguration);
}
this._canonicalWorkspace = new CanonicalWorkspace(this.workspaceService.getWorkspace(), canonicalWorkspaceFolders, canonicalWorkspaceConfiguration);
}
private loadTrustInfo(): IWorkspaceTrustInfo {
const infoAsString = this.storageService.get(this.storageKey, StorageScope.APPLICATION_SHARED);
workspaceTrust.ts
let result: IWorkspaceTrustInfo | undefined;
try {
if (infoAsString) {
result = JSON.parse(infoAsString);
}
if (!result) {
result = {
uriTrustInfo: []
};
}
if (!result.uriTrustInfo) {
result.uriTrustInfo = [];
}
result.uriTrustInfo = result.uriTrustInfo.map(info => { return { uri: URI.revive(info.uri), trusted: info.trusted }; });
result.uriTrustInfo = result.uriTrustInfo.filter(info => info.trusted);
return result;
}
private async saveTrustInfo(): Promise<void> {
private calculateWorkspaceTrust(): boolean {
if (!this.workspaceTrustEnablementService.isWorkspaceTrustEnabled()) {
return true;
}
// Canonical Uris not yet resolved
if (!this._canonicalUrisResolved) {
return false;
}
// Remote - resolver explicitly sets workspace trust to TRUE
if (this.environmentService.remoteAuthority && this._remoteAuthority?.options?.isTrusted) {
return this._remoteAuthority.options.isTrusted;
}
// Empty workspace - use memento, open ediors, or user setting
if (this.isEmptyWorkspace()) {
// Use memento if present
if (this._storedTrustState.isEmptyWorkspaceTrusted !== undefined) {
return this._storedTrustState.isEmptyWorkspaceTrusted;
}
// Startup files
if (this._canonicalStartupFiles.length) {
return this.getUrisTrust(this._canonicalStartupFiles);
}
return this.getUrisTrust(this.getWorkspaceUris());
private async updateWorkspaceTrust(trusted?: boolean): Promise<void> {
return;
}
if (trusted === undefined) {
await this.resolveCanonicalUris();
trusted = this.calculateWorkspaceTrust();
}
if (this.isWorkspaceTrusted() === trusted) { return; }
// Update workspace trust
// Fire workspace trust change event
this._onDidChangeTrust.fire(trusted);
private getUrisTrust(uris: URI[]): boolean {
private isEmptyWorkspace(): boolean {
return true;
}
const workspace = this.workspaceService.getWorkspace();
return false;
private isTrustedVirtualResource(uri: URI): boolean {
get workspaceTrustInitialized(): Promise<void> {
}
get acceptsOutOfWorkspaceFiles(): boolean {
isWorkspaceTrusted(): boolean {
}
isWorkspaceTrustForced(): boolean {
}
private readonly participants = new LinkedList<IWorkspaceTrustTransitionParticipant>();
addWorkspaceTrustTransitionParticipant(participant: IWorkspaceTrustTransitionParticipant): IDisposable {
override dispose(): void {
super.dispose();
}
}
constructor(storageService?: IStorageService) {
this._memento = new Memento('workspaceTrust', storageService);
this._mementoObject = this._memento.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE);
} else {
this._mementoObject = {};
}
get acceptsOutOfWorkspaceFiles(): boolean {
get isEmptyWorkspaceTrusted(): boolean | undefined {
}
set isEmptyWorkspaceTrusted(value: boolean | undefined) {
this._memento?.saveMemento();
}
}
return WorkbenchState.FOLDER;
}
return WorkbenchState.EMPTY;
}