Browse Source

Removes more system imports

main
Eric Amodio 2 years ago
parent
commit
496c35eaef
17 changed files with 45 additions and 40 deletions
  1. +3
    -1
      src/annotations/gutterBlameAnnotationProvider.ts
  2. +2
    -1
      src/annotations/gutterChangesAnnotationProvider.ts
  3. +2
    -1
      src/annotations/gutterHeatmapBlameAnnotationProvider.ts
  4. +9
    -7
      src/avatars.ts
  5. +2
    -2
      src/commands/closeUnchangedFiles.ts
  6. +2
    -2
      src/configuration.ts
  7. +1
    -1
      src/env/node/git/locator.ts
  8. +4
    -2
      src/git/fsProvider.ts
  9. +1
    -1
      src/git/parsers/statusParser.ts
  10. +1
    -1
      src/keyboard.ts
  11. +1
    -1
      src/logger.ts
  12. +0
    -10
      src/system.ts
  13. +1
    -0
      src/system/array.ts
  14. +1
    -0
      src/system/function.ts
  15. +1
    -0
      src/system/object.ts
  16. +5
    -4
      src/trackers/lineTracker.ts
  17. +9
    -6
      src/views/nodes/viewNode.ts

+ 3
- 1
src/annotations/gutterBlameAnnotationProvider.ts View File

@ -5,7 +5,9 @@ import { Container } from '../container';
import { CommitFormatOptions, CommitFormatter } from '../git/formatters';
import { GitBlame, GitCommit } from '../git/models';
import { Logger } from '../logger';
import { Arrays, Iterables, log, Stopwatch, Strings } from '../system';
import { Arrays, Iterables, Strings } from '../system';
import { log } from '../system/decorators/log';
import { Stopwatch } from '../system/stopwatch';
import { GitDocumentState } from '../trackers/gitDocumentTracker';
import { TrackedDocument } from '../trackers/trackedDocument';
import { AnnotationContext } from './annotationProvider';

+ 2
- 1
src/annotations/gutterChangesAnnotationProvider.ts View File

@ -17,7 +17,8 @@ import { Container } from '../container';
import { GitCommit, GitDiff } from '../git/models';
import { Hovers } from '../hovers/hovers';
import { Logger } from '../logger';
import { log, Stopwatch } from '../system';
import { log } from '../system/decorators/log';
import { Stopwatch } from '../system/stopwatch';
import { GitDocumentState, TrackedDocument } from '../trackers/gitDocumentTracker';
import { AnnotationContext, AnnotationProviderBase } from './annotationProvider';
import { Decorations } from './fileAnnotationController';

+ 2
- 1
src/annotations/gutterHeatmapBlameAnnotationProvider.ts View File

@ -3,7 +3,8 @@ import { FileAnnotationType } from '../configuration';
import { Container } from '../container';
import { GitCommit } from '../git/models';
import { Logger } from '../logger';
import { log, Stopwatch } from '../system';
import { log } from '../system/decorators/log';
import { Stopwatch } from '../system/stopwatch';
import { GitDocumentState } from '../trackers/gitDocumentTracker';
import { TrackedDocument } from '../trackers/trackedDocument';
import { AnnotationContext } from './annotationProvider';

+ 9
- 7
src/avatars.ts View File

@ -3,16 +3,18 @@ import { GravatarDefaultStyle } from './config';
import { GlobalState } from './constants';
import { Container } from './container';
import { GitRevisionReference } from './git/models';
import { Functions, Iterables, Strings } from './system';
import { debounce } from './system/function';
import { filterMap } from './system/iterable';
import { base64, equalsIgnoreCase, md5 } from './system/string';
import { ContactPresenceStatus } from './vsls/vsls';
const _onDidFetchAvatar = new EventEmitter<{ email: string }>();
_onDidFetchAvatar.event(
Functions.debounce(() => {
debounce(() => {
const avatars =
avatarCache != null
? [
...Iterables.filterMap(avatarCache, ([key, avatar]) =>
...filterMap(avatarCache, ([key, avatar]) =>
avatar.uri != null
? [
key,
@ -89,7 +91,7 @@ export function getAvatarUri(
return avatar.uri ?? avatar.fallback!;
}
const hash = Strings.md5(email.trim().toLowerCase(), 'hex');
const hash = md5(email.trim().toLowerCase(), 'hex');
const key = `${hash}:${size}`;
const avatar = createOrUpdateAvatar(key, email, size, hash, defaultStyle);
@ -203,8 +205,8 @@ async function getAvatarUriFromRemoteProvider(
avatar.timestamp = Date.now();
avatar.retries = 0;
if (account.email != null && Strings.equalsIgnoreCase(email, account.email)) {
avatarCache.set(`${Strings.md5(account.email.trim().toLowerCase(), 'hex')}:${size}`, { ...avatar });
if (account.email != null && equalsIgnoreCase(email, account.email)) {
avatarCache.set(`${md5(account.email.trim().toLowerCase(), 'hex')}:${size}`, { ...avatar });
}
_onDidFetchAvatar.fire({ email: email });
@ -230,7 +232,7 @@ const presenceStatusColorMap = new Map([
export function getPresenceDataUri(status: ContactPresenceStatus) {
let dataUri = presenceCache.get(status);
if (dataUri == null) {
const contents = Strings.base64(`<?xml version="1.0" encoding="utf-8"?>
const contents = base64(`<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="4" height="16" viewBox="0 0 4 16">
<circle cx="2" cy="14" r="2" fill="${presenceStatusColorMap.get(status)!}"/>
</svg>`);

+ 2
- 2
src/commands/closeUnchangedFiles.ts View File

@ -4,7 +4,7 @@ import { BuiltInCommands } from '../constants';
import type { Container } from '../container';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { Functions } from '../system';
import { debounce } from '../system/function';
import { Command, command, Commands, getRepoPathOrPrompt } from './common';
export interface CloseUnchangedFilesCommandArgs {
@ -44,7 +44,7 @@ export class CloseUnchangedFilesCommand extends Command {
}
const disposable = window.onDidChangeActiveTextEditor(
Functions.debounce((e: TextEditor | undefined) => this._onEditorChangedFn?.(e), 50),
debounce((e: TextEditor | undefined) => this._onEditorChangedFn?.(e), 50),
);
let editor = window.activeTextEditor;

+ 2
- 2
src/configuration.ts View File

@ -10,7 +10,7 @@ import {
workspace,
} from 'vscode';
import { Config } from './config';
import { Objects } from './system';
import { areEqual } from './system/object';
const configPrefix = 'gitlens';
@ -286,7 +286,7 @@ export class Configuration {
return configuration.update(
section,
Objects.areEqual(value, inspect.defaultValue) ? undefined : value,
areEqual(value, inspect.defaultValue) ? undefined : value,
ConfigurationTarget.Global,
);
}

+ 1
- 1
src/env/node/git/locator.ts View File

@ -1,8 +1,8 @@
import { join as joinPaths } from 'path';
import { GlyphChars } from '../../../constants';
import { LogLevel } from '../../../logger';
import { Stopwatch } from '../../../system';
import { any } from '../../../system/promise';
import { Stopwatch } from '../../../system/stopwatch';
import { findExecutable, run } from './shell';
export class UnableToFindGitError extends Error {

+ 4
- 2
src/git/fsProvider.ts View File

@ -14,8 +14,10 @@ import { isLinux } from '@env/platform';
import { Schemes } from '../constants';
import { Container } from '../container';
import { GitUri } from '../git/gitUri';
import { debug, Iterables, TernarySearchTree } from '../system';
import { debug } from '../system/decorators/log';
import { map } from '../system/iterable';
import { normalizePath, relative } from '../system/path';
import { TernarySearchTree } from '../system/searchTree';
import { GitRevision, GitTreeEntry } from './models';
const emptyArray = new Uint8Array(0);
@ -65,7 +67,7 @@ export class GitFileSystemProvider implements FileSystemProvider, Disposable {
if (tree === undefined) throw FileSystemError.FileNotFound(uri);
const items = [
...Iterables.map<GitTreeEntry, [string, FileType]>(tree, t => [
...map<GitTreeEntry, [string, FileType]>(tree, t => [
path != null && path.length !== 0 ? normalizePath(relative(path, t.path)) : t.path,
typeToFileType(t.type),
]),

+ 1
- 1
src/git/parsers/statusParser.ts View File

@ -1,4 +1,4 @@
import { debug } from '../../system';
import { debug } from '../../system/decorators/log';
import { normalizePath } from '../../system/path';
import { GitStatus, GitStatusFile } from '../models';

+ 1
- 1
src/keyboard.ts View File

@ -1,7 +1,7 @@
import { commands, Disposable } from 'vscode';
import { ContextKeys, setContext } from './constants';
import { Logger } from './logger';
import { log } from './system';
import { log } from './system/decorators/log';
export declare interface KeyCommand {
onDidPressKey?(key: Keys): void | Promise<void>;

+ 1
- 1
src/logger.ts View File

@ -1,6 +1,6 @@
import { ExtensionContext, ExtensionMode, OutputChannel, Uri, window } from 'vscode';
import { OutputLevel } from './configuration';
import { getCorrelationContext, getNextCorrelationId } from './system';
import { getCorrelationContext, getNextCorrelationId } from './system/decorators/log';
const emptyStr = '';
const outputChannelName = 'GitLens';

+ 0
- 10
src/system.ts View File

@ -20,17 +20,7 @@ declare global {
}
export * as Arrays from './system/array';
export * as Dates from './system/date';
export * from './system/decorators/gate';
export * from './system/decorators/log';
export * from './system/decorators/memoize';
export * from './system/decorators/serialize';
export * from './system/decorators/timeout';
export * as Encoding from './system/encoding';
export * as Functions from './system/function';
export * as Iterables from './system/iterable';
export * as Objects from './system/object';
export * from './system/searchTree';
export * from './system/stopwatch';
export * as Strings from './system/string';
export * as Versions from './system/version';

+ 1
- 0
src/system/array.ts View File

@ -1,3 +1,4 @@
// eslint-disable-next-line no-restricted-imports
export { findLastIndex, intersectionWith as intersection } from 'lodash-es';
export function chunk<T>(source: T[], size: number): T[][] {

+ 1
- 0
src/system/function.ts View File

@ -1,3 +1,4 @@
// eslint-disable-next-line no-restricted-imports
import { debounce as _debounce, once as _once } from 'lodash-es';
import { Disposable } from 'vscode';

+ 1
- 0
src/system/object.ts View File

@ -1,3 +1,4 @@
// eslint-disable-next-line no-restricted-imports
export { isEqual as areEqual } from 'lodash-es';
export function flatten(o: any, prefix: string = '', stringify: boolean = false): Record<string, any> {

+ 5
- 4
src/trackers/lineTracker.ts View File

@ -1,7 +1,8 @@
import { Disposable, Event, EventEmitter, Selection, TextEditor, TextEditorSelectionChangeEvent, window } from 'vscode';
import { isTextEditor } from '../constants';
import { Logger } from '../logger';
import { debug, Functions } from '../system';
import { debug } from '../system/decorators/log';
import { debounce, Deferrable } from '../system/function';
export interface LinesChangeEvent {
readonly editor: TextEditor | undefined;
@ -134,7 +135,7 @@ export class LineTracker implements Disposable {
Logger.debug(cc, 'Starting line tracker...');
this._disposable = Disposable.from(
window.onDidChangeActiveTextEditor(Functions.debounce(this.onActiveTextEditorChanged, 0), this),
window.onDidChangeActiveTextEditor(debounce(this.onActiveTextEditorChanged, 0), this),
window.onDidChangeTextEditorSelection(this.onTextEditorSelectionChanged, this),
this.onStart?.() ?? { dispose: () => {} },
);
@ -200,7 +201,7 @@ export class LineTracker implements Disposable {
this.onLinesChanged({ editor: this._editor, selections: this.selections, reason: reason });
}
private _linesChangedDebounced: Functions.Deferrable<(e: LinesChangeEvent) => void> | undefined;
private _linesChangedDebounced: Deferrable<(e: LinesChangeEvent) => void> | undefined;
private onLinesChanged(e: LinesChangeEvent) {
if (e.selections == null) {
@ -218,7 +219,7 @@ export class LineTracker implements Disposable {
}
if (this._linesChangedDebounced == null) {
this._linesChangedDebounced = Functions.debounce(
this._linesChangedDebounced = debounce(
(e: LinesChangeEvent) => {
if (e.editor !== window.activeTextEditor) return;
// Make sure we are still on the same lines

+ 9
- 6
src/views/nodes/viewNode.ts View File

@ -21,7 +21,10 @@ import {
RepositoryChangeEvent,
} from '../../git/models';
import { Logger } from '../../logger';
import { debug, Functions, gate, log, logName, Strings } from '../../system';
import { gate } from '../../system/decorators/gate';
import { debug, log, logName } from '../../system/decorators/log';
import { is as isA } from '../../system/function';
import { pad } from '../../system/string';
import { TreeViewNodeCollapsibleStateChangeEvent, View } from '../viewBase';
export const enum ContextValues {
@ -177,7 +180,7 @@ export interface PageableViewNode {
export namespace PageableViewNode {
export function is(node: ViewNode): node is ViewNode & PageableViewNode {
return Functions.is<ViewNode & PageableViewNode>(node, 'loadMore');
return isA<ViewNode & PageableViewNode>(node, 'loadMore');
}
}
@ -394,9 +397,9 @@ export abstract class RepositoryFolderNode<
const lastFetched = (await this.repo.getLastFetched()) ?? 0;
const status = branch.getTrackingStatus();
item.description = `${status ? `${status}${Strings.pad(GlyphChars.Dot, 1, 1)}` : ''}${branch.name}${
item.description = `${status ? `${status}${pad(GlyphChars.Dot, 1, 1)}` : ''}${branch.name}${
lastFetched
? `${Strings.pad(GlyphChars.Dot, 1, 1)}Last fetched ${Repository.formatLastFetched(lastFetched)}`
? `${pad(GlyphChars.Dot, 1, 1)}Last fetched ${Repository.formatLastFetched(lastFetched)}`
: ''
}`;
@ -414,7 +417,7 @@ export abstract class RepositoryFolderNode<
item.tooltip = new MarkdownString(
`${this.repo.formattedName ?? this.uri.repoPath ?? ''}${
lastFetched
? `${Strings.pad(GlyphChars.Dash, 2, 2)}Last fetched ${Repository.formatLastFetched(
? `${pad(GlyphChars.Dash, 2, 2)}Last fetched ${Repository.formatLastFetched(
lastFetched,
false,
)}`
@ -559,7 +562,7 @@ interface AutoRefreshableView {
}
export function canAutoRefreshView(view: View): view is View & AutoRefreshableView {
return Functions.is<View & AutoRefreshableView>(view, 'onDidChangeAutoRefresh');
return isA<View & AutoRefreshableView>(view, 'onDidChangeAutoRefresh');
}
export function canClearNode(node: ViewNode): node is ViewNode & { clear(): void | Promise<void> } {

Loading…
Cancel
Save