mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
npm.fetchOnlinePackageInfo is not respected in latest build. Fixes #103540
This commit is contained in:
parent
de7bb5b5fe
commit
4899592904
|
@ -33,7 +33,7 @@ export class BowerJSONContribution implements IJSONContribution {
|
|||
return [{ language: 'json', scheme: '*', pattern: '**/bower.json' }, { language: 'json', scheme: '*', pattern: '**/.bower.json' }];
|
||||
}
|
||||
|
||||
private onlineEnabled() {
|
||||
private isEnabled() {
|
||||
return !!workspace.getConfiguration('npm').get('fetchOnlinePackageInfo');
|
||||
}
|
||||
|
||||
|
@ -54,8 +54,11 @@ export class BowerJSONContribution implements IJSONContribution {
|
|||
}
|
||||
|
||||
public collectPropertySuggestions(_resource: string, location: Location, currentWord: string, addValue: boolean, isLast: boolean, collector: ISuggestionsCollector): Thenable<any> | null {
|
||||
if (!this.isEnabled()) {
|
||||
return null;
|
||||
}
|
||||
if ((location.matches(['dependencies']) || location.matches(['devDependencies']))) {
|
||||
if (currentWord.length > 0 && this.onlineEnabled()) {
|
||||
if (currentWord.length > 0) {
|
||||
const queryUrl = 'https://registry.bower.io/packages/search/' + encodeURIComponent(currentWord);
|
||||
|
||||
return this.xhr({
|
||||
|
@ -122,7 +125,10 @@ export class BowerJSONContribution implements IJSONContribution {
|
|||
return null;
|
||||
}
|
||||
|
||||
public collectValueSuggestions(_resource: string, location: Location, collector: ISuggestionsCollector): Thenable<any> {
|
||||
public collectValueSuggestions(_resource: string, location: Location, collector: ISuggestionsCollector): Promise<any> | null {
|
||||
if (!this.isEnabled()) {
|
||||
return null;
|
||||
}
|
||||
if ((location.matches(['dependencies', '*']) || location.matches(['devDependencies', '*']))) {
|
||||
// not implemented. Could be do done calling the bower command. Waiting for web API: https://github.com/bower/registry/issues/26
|
||||
const proposal = new CompletionItem(localize('json.bower.latest.version', 'latest'));
|
||||
|
@ -132,7 +138,7 @@ export class BowerJSONContribution implements IJSONContribution {
|
|||
proposal.documentation = 'The latest version of the package';
|
||||
collector.add(proposal);
|
||||
}
|
||||
return Promise.resolve(null);
|
||||
return null;
|
||||
}
|
||||
|
||||
public resolveSuggestion(item: CompletionItem): Thenable<CompletionItem | null> | null {
|
||||
|
@ -149,10 +155,6 @@ export class BowerJSONContribution implements IJSONContribution {
|
|||
}
|
||||
|
||||
private getInfo(pack: string): Thenable<string | undefined> {
|
||||
if (!this.onlineEnabled()) {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
const queryUrl = 'https://registry.bower.io/packages/' + encodeURIComponent(pack);
|
||||
|
||||
return this.xhr({
|
||||
|
@ -181,6 +183,9 @@ export class BowerJSONContribution implements IJSONContribution {
|
|||
}
|
||||
|
||||
public getInfoContribution(_resource: string, location: Location): Thenable<MarkdownString[] | null> | null {
|
||||
if (!this.isEnabled()) {
|
||||
return null;
|
||||
}
|
||||
if ((location.matches(['dependencies', '*']) || location.matches(['devDependencies', '*']))) {
|
||||
const pack = location.path[location.path.length - 1];
|
||||
if (typeof pack === 'string') {
|
||||
|
|
|
@ -25,7 +25,7 @@ export interface IJSONContribution {
|
|||
getDocumentSelector(): DocumentSelector;
|
||||
getInfoContribution(fileName: string, location: Location): Thenable<MarkedString[] | null> | null;
|
||||
collectPropertySuggestions(fileName: string, location: Location, currentWord: string, addValue: boolean, isLast: boolean, result: ISuggestionsCollector): Thenable<any> | null;
|
||||
collectValueSuggestions(fileName: string, location: Location, result: ISuggestionsCollector): Thenable<any>;
|
||||
collectValueSuggestions(fileName: string, location: Location, result: ISuggestionsCollector): Thenable<any> | null;
|
||||
collectDefaultSuggestions(fileName: string, result: ISuggestionsCollector): Thenable<any>;
|
||||
resolveSuggestion?(item: CompletionItem): Thenable<CompletionItem | null> | null;
|
||||
}
|
||||
|
|
|
@ -51,6 +51,10 @@ export class PackageJSONContribution implements IJSONContribution {
|
|||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
private isEnabled() {
|
||||
return this.canRunNPM || this.onlineEnabled();
|
||||
}
|
||||
|
||||
private onlineEnabled() {
|
||||
return !!workspace.getConfiguration('npm').get('fetchOnlinePackageInfo');
|
||||
}
|
||||
|
@ -63,7 +67,7 @@ export class PackageJSONContribution implements IJSONContribution {
|
|||
isLast: boolean,
|
||||
collector: ISuggestionsCollector
|
||||
): Thenable<any> | null {
|
||||
if (!this.onlineEnabled()) {
|
||||
if (!this.isEnabled()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -180,7 +184,7 @@ export class PackageJSONContribution implements IJSONContribution {
|
|||
}
|
||||
|
||||
public async collectValueSuggestions(_fileName: string, location: Location, result: ISuggestionsCollector): Promise<any> {
|
||||
if (!this.onlineEnabled()) {
|
||||
if (!this.isEnabled()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -250,7 +254,7 @@ export class PackageJSONContribution implements IJSONContribution {
|
|||
if (this.canRunNPM) {
|
||||
info = await this.npmView(pack);
|
||||
}
|
||||
if (!info) {
|
||||
if (!info && this.onlineEnabled()) {
|
||||
info = await this.npmjsView(pack);
|
||||
}
|
||||
return info;
|
||||
|
@ -303,6 +307,9 @@ export class PackageJSONContribution implements IJSONContribution {
|
|||
}
|
||||
|
||||
public getInfoContribution(_fileName: string, location: Location): Thenable<MarkedString[] | null> | null {
|
||||
if (!this.isEnabled()) {
|
||||
return null;
|
||||
}
|
||||
if ((location.matches(['dependencies', '*']) || location.matches(['devDependencies', '*']) || location.matches(['optionalDependencies', '*']) || location.matches(['peerDependencies', '*']))) {
|
||||
const pack = location.path[location.path.length - 1];
|
||||
if (typeof pack === 'string') {
|
||||
|
|
Loading…
Reference in a new issue