Selaa lähdekoodia

Makes scopes optional on codeLens.scopesByLanguage

main
Eric Amodio 6 vuotta sitten
vanhempi
commit
11dc8f37f7
3 muutettua tiedostoa jossa 11 lisäystä ja 16 poistoa
  1. +1
    -2
      package.json
  2. +9
    -13
      src/gitCodeLensProvider.ts
  3. +1
    -1
      src/ui/config.ts

+ 1
- 2
package.json Näytä tiedosto

@ -275,8 +275,7 @@
"items": {
"type": "object",
"required": [
"language",
"scopes"
"language"
],
"properties": {
"language": {

+ 9
- 13
src/gitCodeLensProvider.ts Näytä tiedosto

@ -90,18 +90,14 @@ export class GitCodeLensProvider implements CodeLensProvider {
let languageScope = cfg.scopesByLanguage && cfg.scopesByLanguage.find(ll => ll.language !== undefined && ll.language.toLowerCase() === document.languageId);
if (languageScope == null) {
languageScope = {
language: undefined,
scopes: cfg.scopes,
symbolScopes: cfg.symbolScopes
language: undefined
} as CodeLensLanguageScope;
}
else {
if (languageScope.scopes === undefined) {
languageScope.scopes = cfg.scopes;
}
if (languageScope.symbolScopes === undefined) {
languageScope.symbolScopes = cfg.symbolScopes;
}
if (languageScope.scopes == null) {
languageScope.scopes = cfg.scopes;
}
if (languageScope.symbolScopes == null) {
languageScope.symbolScopes = cfg.symbolScopes;
}
languageScope.symbolScopes = languageScope.symbolScopes != null
@ -148,7 +144,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
if (symbols !== undefined) {
Logger.log('GitCodeLensProvider.provideCodeLenses:', `${symbols.length} symbol(s) found`);
symbols.forEach(sym => this.provideCodeLens(lenses, document, sym, languageScope!, documentRangeFn, blame, gitUri, cfg, dirty, dirtyCommand));
symbols.forEach(sym => this.provideCodeLens(lenses, document, sym, languageScope as Required<CodeLensLanguageScope>, documentRangeFn, blame, gitUri, cfg, dirty, dirtyCommand));
}
if ((languageScope.scopes.includes(CodeLensScopes.Document) || languageScope.symbolScopes.includes('file')) && !languageScope.symbolScopes.includes('!file')) {
@ -196,7 +192,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
return lenses;
}
private validateSymbolAndGetBlameRange(symbol: SymbolInformation, languageScope: CodeLensLanguageScope, documentRangeFn: () => Range): Range | undefined {
private validateSymbolAndGetBlameRange(symbol: SymbolInformation, languageScope: Required<CodeLensLanguageScope>, documentRangeFn: () => Range): Range | undefined {
let valid = false;
let range: Range | undefined;
@ -255,7 +251,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
return valid ? range || symbol.location.range : undefined;
}
private provideCodeLens(lenses: CodeLens[], document: TextDocument, symbol: SymbolInformation, languageScope: CodeLensLanguageScope, documentRangeFn: () => Range, blame: GitBlame | undefined, gitUri: GitUri | undefined, cfg: ICodeLensConfig, dirty: boolean, dirtyCommand: Command | undefined): void {
private provideCodeLens(lenses: CodeLens[], document: TextDocument, symbol: SymbolInformation, languageScope: Required<CodeLensLanguageScope>, documentRangeFn: () => Range, blame: GitBlame | undefined, gitUri: GitUri | undefined, cfg: ICodeLensConfig, dirty: boolean, dirtyCommand: Command | undefined): void {
const blameRange = this.validateSymbolAndGetBlameRange(symbol, languageScope, documentRangeFn);
if (blameRange === undefined) return;

+ 1
- 1
src/ui/config.ts Näytä tiedosto

@ -16,7 +16,7 @@ export enum CodeLensCommand {
export interface CodeLensLanguageScope {
language: string | undefined;
scopes: CodeLensScopes[];
scopes?: CodeLensScopes[];
symbolScopes?: string[];
}

Ladataan…
Peruuta
Tallenna