Browse Source

Avoids casts

main
Eric Amodio 4 years ago
parent
commit
497c4ac2f0
5 changed files with 7 additions and 17 deletions
  1. +2
    -12
      src/annotations/blameAnnotationProvider.ts
  2. +1
    -1
      src/annotations/gutterChangesAnnotationProvider.ts
  3. +1
    -1
      src/commands/gitCommands.actions.ts
  4. +2
    -2
      src/git/gitService.ts
  5. +1
    -1
      src/git/parsers/statusParser.ts

+ 2
- 12
src/annotations/blameAnnotationProvider.ts View File

@ -1,15 +1,5 @@
'use strict'; 'use strict';
import {
CancellationToken,
Disposable,
Hover,
languages,
MarkdownString,
Position,
Range,
TextDocument,
TextEditor,
} from 'vscode';
import { CancellationToken, Disposable, Hover, languages, Position, Range, TextDocument, TextEditor } from 'vscode';
import { AnnotationProviderBase } from './annotationProvider'; import { AnnotationProviderBase } from './annotationProvider';
import { ComputedHeatmap, getHeatmapColors } from './annotations'; import { ComputedHeatmap, getHeatmapColors } from './annotations';
import { Container } from '../container'; import { Container } from '../container';
@ -165,7 +155,7 @@ export abstract class BlameAnnotationProviderBase extends AnnotationProviderBase
? Hovers.changesMessage(commit, await GitUri.fromUri(document.uri), position.line) ? Hovers.changesMessage(commit, await GitUri.fromUri(document.uri), position.line)
: undefined, : undefined,
]) ])
).filter(Boolean) as MarkdownString[];
).filter(<T>(m?: T): m is T => Boolean(m));
return new Hover( return new Hover(
messages, messages,

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

@ -138,7 +138,7 @@ export class GutterChangesAnnotationProvider extends AnnotationProviderBase {
] ]
: [Container.git.getDiffForFile(this.trackedDocument.uri, ref1, ref2)], : [Container.git.getDiffForFile(this.trackedDocument.uri, ref1, ref2)],
) )
).filter(Boolean) as GitDiff[];
).filter(<T>(d?: T): d is T => Boolean(d));
if (!diffs?.length) return false; if (!diffs?.length) return false;
let start = process.hrtime(); let start = process.hrtime();

+ 1
- 1
src/commands/gitCommands.actions.ts View File

@ -595,7 +595,7 @@ export namespace GitActions {
await Promise.all( await Promise.all(
files.map(file => Container.git.getWorkingUri(repoPath!, GitUri.fromFile(file, repoPath!, ref))), files.map(file => Container.git.getWorkingUri(repoPath!, GitUri.fromFile(file, repoPath!, ref))),
) )
).filter(Boolean) as Uri[];
).filter(<T>(u?: T): u is T => Boolean(u));
findOrOpenEditors(uris); findOrOpenEditors(uris);
} }

+ 2
- 2
src/git/gitService.ts View File

@ -542,7 +542,7 @@ export class GitService implements Disposable {
const data = await Git.check_ignore(repoPath, ...paths.keys()); const data = await Git.check_ignore(repoPath, ...paths.keys());
if (data == null) return uris; if (data == null) return uris;
const ignored = data.split('\0').filter(Boolean);
const ignored = data.split('\0').filter(<T>(i?: T): i is T => Boolean(i));
if (ignored.length === 0) return uris; if (ignored.length === 0) return uris;
for (const file of ignored) { for (const file of ignored) {
@ -1174,7 +1174,7 @@ export class GitService implements Disposable {
return data return data
.split('\n') .split('\n')
.map(b => b.substr(2).trim()) .map(b => b.substr(2).trim())
.filter(Boolean);
.filter(<T>(i?: T): i is T => Boolean(i));
} }
@log() @log()

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

@ -12,7 +12,7 @@ export class GitStatusParser {
static parse(data: string, repoPath: string, porcelainVersion: number): GitStatus | undefined { static parse(data: string, repoPath: string, porcelainVersion: number): GitStatus | undefined {
if (!data) return undefined; if (!data) return undefined;
const lines = data.split('\n').filter(Boolean);
const lines = data.split('\n').filter(<T>(i?: T): i is T => Boolean(i));
if (lines.length === 0) return undefined; if (lines.length === 0) return undefined;
if (porcelainVersion < 2) return this.parseV1(lines, repoPath); if (porcelainVersion < 2) return this.parseV1(lines, repoPath);

Loading…
Cancel
Save