debt - use network.Scheme.file in more places

This commit is contained in:
Benjamin Pasero 2020-09-25 08:53:37 +02:00
parent 5484453ae2
commit 528b473dba
15 changed files with 29 additions and 22 deletions

View file

@ -36,6 +36,7 @@ import { IStorageMainService } from 'vs/platform/storage/node/storageMainService
import { IFileService } from 'vs/platform/files/common/files';
import { ColorScheme } from 'vs/platform/theme/common/theme';
import { getPathFromAmdModule } from 'vs/base/common/amd';
import { Schemas } from 'vs/base/common/network';
export interface IWindowCreationOptions {
state: IWindowState;
@ -1291,7 +1292,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
private createTouchBarGroupSegments(items: ISerializableCommandAction[] = []): ITouchBarSegment[] {
const segments: ITouchBarSegment[] = items.map(item => {
let icon: NativeImage | undefined;
if (item.icon && !ThemeIcon.isThemeIcon(item.icon) && item.icon?.dark?.scheme === 'file') {
if (item.icon && !ThemeIcon.isThemeIcon(item.icon) && item.icon?.dark?.scheme === Schemas.file) {
icon = nativeImage.createFromPath(URI.revive(item.icon.dark).fsPath);
if (icon.isEmpty()) {
icon = undefined;

View file

@ -17,6 +17,7 @@ import { IMainProcessInfo } from 'vs/platform/launch/node/launch';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { Iterable } from 'vs/base/common/iterator';
import { Schemas } from 'vs/base/common/network';
export const ID = 'diagnosticsService';
export const IDiagnosticsService = createDecorator<IDiagnosticsService>(ID);
@ -450,7 +451,7 @@ export class DiagnosticsService implements IDiagnosticsService {
window.folderURIs.forEach(uriComponents => {
const folderUri = URI.revive(uriComponents);
if (folderUri.scheme === 'file') {
if (folderUri.scheme === Schemas.file) {
const folder = folderUri.fsPath;
workspaceStatPromises.push(collectWorkspaceStats(folder, ['node_modules', '.git']).then(stats => {
let countMessage = `${stats.fileCount} files`;
@ -518,7 +519,7 @@ export class DiagnosticsService implements IDiagnosticsService {
public async reportWorkspaceStats(workspace: IWorkspaceInformation): Promise<void> {
for (const { uri } of workspace.folders) {
const folderUri = URI.revive(uri);
if (folderUri.scheme !== 'file') {
if (folderUri.scheme !== Schemas.file) {
continue;
}

View file

@ -8,6 +8,7 @@ import { IDebuggerContribution, IDebugSession, IConfigPresentation } from 'vs/wo
import { URI as uri } from 'vs/base/common/uri';
import { isAbsolute } from 'vs/base/common/path';
import { deepClone } from 'vs/base/common/objects';
import { Schemas } from 'vs/base/common/network';
const _formatPIIRegexp = /{([^}]+)}/g;
@ -145,7 +146,7 @@ function uriToString(source: PathContainer): string | undefined {
if (typeof source.path === 'object') {
const u = uri.revive(source.path);
if (u) {
if (u.scheme === 'file') {
if (u.scheme === Schemas.file) {
return u.fsPath;
} else {
return u.toString();

View file

@ -424,7 +424,7 @@ export class RuntimeExtensionsEditor extends EditorPane {
data.msgContainer.appendChild(el);
}
if (element.description.extensionLocation.scheme !== 'file') {
if (element.description.extensionLocation.scheme !== Schemas.file) {
const el = $('span', undefined, ...renderCodicons(`$(remote) ${element.description.extensionLocation.authority}`));
data.msgContainer.appendChild(el);

View file

@ -30,6 +30,7 @@ import { memoize } from 'vs/base/common/decorators';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { compareFileNames, compareFileExtensions, comparePaths } from 'vs/base/common/comparers';
import { IFileService, IFileStatWithMetadata } from 'vs/platform/files/common/files';
import { Schemas } from 'vs/base/common/network';
export class Match {
@ -1106,9 +1107,9 @@ export class SearchModel extends Disposable {
const stats = completed && completed.stats as ITextSearchStats;
const fileSchemeOnly = this._searchQuery.folderQueries.every(fq => fq.folder.scheme === 'file');
const otherSchemeOnly = this._searchQuery.folderQueries.every(fq => fq.folder.scheme !== 'file');
const scheme = fileSchemeOnly ? 'file' :
const fileSchemeOnly = this._searchQuery.folderQueries.every(fq => fq.folder.scheme === Schemas.file);
const otherSchemeOnly = this._searchQuery.folderQueries.every(fq => fq.folder.scheme !== Schemas.file);
const scheme = fileSchemeOnly ? Schemas.file :
otherSchemeOnly ? 'other' :
'mixed';

View file

@ -1075,7 +1075,7 @@ export class TerminalTaskSystem implements ITaskSystem {
if (options.cwd) {
let cwd = options.cwd;
if (!path.isAbsolute(cwd)) {
if (workspaceFolder && (workspaceFolder.uri.scheme === 'file')) {
if (workspaceFolder && (workspaceFolder.uri.scheme === Schemas.file)) {
cwd = path.join(workspaceFolder.uri.fsPath, cwd);
}
}

View file

@ -191,7 +191,7 @@ export class TerminalLinkManager extends DisposableStore {
// Check if it's a file:/// link, hand off to local link handler so to open an editor and
// respect line/col attachment
const uri = URI.parse(link);
if (uri.scheme === 'file') {
if (uri.scheme === Schemas.file) {
this._handleLocalLink(uri.fsPath);
return;
}

View file

@ -10,6 +10,7 @@ import { TerminalLink, OPEN_FILE_LABEL } from 'vs/workbench/contrib/terminal/bro
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { URI } from 'vs/base/common/uri';
import { TerminalBaseLinkProvider } from 'vs/workbench/contrib/terminal/browser/links/terminalBaseLinkProvider';
import { Schemas } from 'vs/base/common/network';
export class TerminalProtocolLinkProvider extends TerminalBaseLinkProvider {
private _linkComputerTarget: ILinkComputerTarget | undefined;
@ -51,7 +52,7 @@ export class TerminalProtocolLinkProvider extends TerminalBaseLinkProvider {
const uri = link.url
? (typeof link.url === 'string' ? URI.parse(link.url) : link.url)
: undefined;
const label = (uri?.scheme === 'file') ? OPEN_FILE_LABEL : undefined;
const label = (uri?.scheme === Schemas.file) ? OPEN_FILE_LABEL : undefined;
return this._instantiationService.createInstance(TerminalLink, this._xterm, range, link.url?.toString() || '', this._xterm.buffer.active.viewportY, this._activateCallback, this._tooltipCallback, true, label);
});
}

View file

@ -692,7 +692,7 @@ export function registerTerminalActions() {
}
const uri = editor.getModel().uri;
if (uri.scheme !== 'file') {
if (uri.scheme !== Schemas.file) {
notificationService.warn(localize('workbench.action.terminal.runActiveFile.noFile', 'Only files on disk can be run in the terminal'));
return;
}

View file

@ -17,6 +17,7 @@ import { ThemeRule, findMatchingThemeRule } from 'vs/workbench/services/textMate
import { Color } from 'vs/base/common/color';
import { IFileService } from 'vs/platform/files/common/files';
import { basename } from 'vs/base/common/resources';
import { Schemas } from 'vs/base/common/network';
interface IToken {
c: string;
@ -244,7 +245,7 @@ CommandsRegistry.registerCommand('_workbench.captureSyntaxTokens', function (acc
if (!resource) {
const editorService = accessor.get(IEditorService);
const file = editorService.activeEditor ? toResource(editorService.activeEditor, { filterByScheme: 'file' }) : null;
const file = editorService.activeEditor ? toResource(editorService.activeEditor, { filterByScheme: Schemas.file }) : null;
if (file) {
process(file).then(result => {
console.log(result);

View file

@ -352,7 +352,7 @@ export class TimelinePane extends ViewPane {
if ((uri?.toString(true) === this.uri?.toString(true) && uri !== undefined) ||
// Fallback to match on fsPath if we are dealing with files or git schemes
(uri?.fsPath === this.uri?.fsPath && (uri?.scheme === 'file' || uri?.scheme === 'git') && (this.uri?.scheme === 'file' || this.uri?.scheme === 'git'))) {
(uri?.fsPath === this.uri?.fsPath && (uri?.scheme === Schemas.file || uri?.scheme === 'git') && (this.uri?.scheme === Schemas.file || this.uri?.scheme === 'git'))) {
// If the uri hasn't changed, make sure we have valid caches
for (const source of this.timelineService.getSources()) {

View file

@ -3,6 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Schemas } from 'vs/base/common/network';
import { IPath, win32, posix } from 'vs/base/common/path';
import { OperatingSystem, OS } from 'vs/base/common/platform';
import { URI } from 'vs/base/common/uri';
@ -132,9 +133,8 @@ export abstract class AbstractPathService implements IPathService {
}
}
// return new _URI('file', authority, path, '', '');
return URI.from({
scheme: 'file',
scheme: Schemas.file,
authority,
path: _path,
query: '',

View file

@ -282,9 +282,9 @@ export class SearchService extends Disposable implements ISearchService {
}
private sendTelemetry(query: ISearchQuery, endToEndTime: number, complete?: ISearchComplete, err?: SearchError): void {
const fileSchemeOnly = query.folderQueries.every(fq => fq.folder.scheme === 'file');
const otherSchemeOnly = query.folderQueries.every(fq => fq.folder.scheme !== 'file');
const scheme = fileSchemeOnly ? 'file' :
const fileSchemeOnly = query.folderQueries.every(fq => fq.folder.scheme === Schemas.file);
const otherSchemeOnly = query.folderQueries.every(fq => fq.folder.scheme !== Schemas.file);
const scheme = fileSchemeOnly ? Schemas.file :
otherSchemeOnly ? 'other' :
'mixed';

View file

@ -13,6 +13,7 @@ import { URI } from 'vs/base/common/uri';
import { IExtendedExtensionSearchOptions, IFileMatch, IFolderQuery, IPatternInfo, ISearchCompleteStats, ITextQuery, ITextSearchContext, ITextSearchMatch, ITextSearchResult, QueryGlobTester, resolvePatternsForProvider } from 'vs/workbench/services/search/common/search';
import { TextSearchProvider, TextSearchResult, TextSearchMatch, TextSearchComplete, Range, TextSearchOptions, TextSearchQuery } from 'vs/workbench/services/search/common/searchExtTypes';
import { nextTick } from 'vs/base/common/process';
import { Schemas } from 'vs/base/common/network';
export interface IFileUtils {
readdir: (resource: URI) => Promise<string[]>;
@ -117,7 +118,7 @@ export class TextSearchManager {
return;
}
const hasSibling = folderQuery.folder.scheme === 'file' ?
const hasSibling = folderQuery.folder.scheme === Schemas.file ?
glob.hasSiblingPromiseFn(() => {
return this.fileUtils.readdir(resources.dirname(result.uri));
}) :

View file

@ -852,10 +852,10 @@ export class TestFileService implements IFileService {
}
activateProvider(_scheme: string): Promise<void> { throw new Error('not implemented'); }
canHandleResource(resource: URI): boolean { return resource.scheme === 'file' || this.providers.has(resource.scheme); }
canHandleResource(resource: URI): boolean { return resource.scheme === Schemas.file || this.providers.has(resource.scheme); }
listCapabilities() {
return [
{ scheme: 'file', capabilities: FileSystemProviderCapabilities.FileOpenReadWriteClose },
{ scheme: Schemas.file, capabilities: FileSystemProviderCapabilities.FileOpenReadWriteClose },
...Iterable.map(this.providers, ([scheme, p]) => { return { scheme, capabilities: p.capabilities }; })
];
}