No console linting (#9156)

* add no-console linting and change to just using overrides for sql files

* whitespace

* fix tests
This commit is contained in:
Anthony Dresser
2020-02-14 21:13:16 -06:00
committed by GitHub
parent 6b0332b2d1
commit 74b89a0a85
31 changed files with 107 additions and 105 deletions

View File

@@ -12,6 +12,7 @@ import { URI } from 'vs/base/common/uri';
import { IConfigurationService, ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
import { localize } from 'vs/nls';
import { ILogService } from 'vs/platform/log/common/log';
@extHostNamedCustomer(SqlMainContext.MainThreadExtensionManagement)
export class MainThreadExtensionManagement extends Disposable implements MainThreadExtensionManagementShape {
@@ -22,7 +23,8 @@ export class MainThreadExtensionManagement extends Disposable implements MainThr
extHostContext: IExtHostContext,
@IExtensionManagementService private _extensionService: IExtensionManagementService,
@IConfigurationService private _configurationService: IConfigurationService,
@INotificationService private _notificationService: INotificationService
@INotificationService private _notificationService: INotificationService,
@ILogService private readonly logService: ILogService
) {
super();
}
@@ -32,7 +34,7 @@ export class MainThreadExtensionManagement extends Disposable implements MainThr
}
public $showObsoleteExtensionApiUsageNotification(message: string): void {
console.warn(message);
this.logService.warn(message);
if (this._obsoleteExtensionApiUsageNotificationShown) {
return;

View File

@@ -91,7 +91,7 @@ export class MainThreadQueryEditor extends Disposable implements MainThreadQuery
let profile: IConnectionProfile = MainThreadQueryEditor.connectionProfileToIConnectionProfile(connection);
let connectionResult = await this._connectionManagementService.connect(profile, fileUri, options);
if (connectionResult && connectionResult.connected) {
console.log(`editor ${fileUri} connected`);
this._logService.info(`editor ${fileUri} connected`);
}
});
}

View File

@@ -16,6 +16,7 @@ import { SqlMainContext, ExtHostModelViewShape, MainThreadModelViewShape, ExtHos
import { IItemConfig, ModelComponentTypes, IComponentShape, IComponentEventArgs, ComponentEventType, ColumnSizingMode } from 'sql/workbench/api/common/sqlExtHostTypes';
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
import { firstIndex } from 'vs/base/common/arrays';
import { ILogService } from 'vs/platform/log/common/log';
class ModelBuilderImpl implements azdata.ModelBuilder {
private nextComponentId: number;
@@ -25,7 +26,8 @@ class ModelBuilderImpl implements azdata.ModelBuilder {
private readonly _proxy: MainThreadModelViewShape,
private readonly _handle: number,
private readonly _extHostModelViewTree: ExtHostModelViewTreeViewsShape,
private readonly _extension: IExtensionDescription
private readonly _extension: IExtensionDescription,
private readonly logService: ILogService
) {
this.nextComponentId = 0;
}
@@ -82,7 +84,7 @@ class ModelBuilderImpl implements azdata.ModelBuilder {
private cardDeprecationMessagePrinted = false;
card(): azdata.ComponentBuilder<azdata.CardComponent> {
if (!this.cardDeprecationMessagePrinted) {
console.warn(`Extension '${this._extension.identifier.value}' is using card component which has been replaced by radioCardGroup. the card component will be removed in a future release.`);
this.logService.warn(`Extension '${this._extension.identifier.value}' is using card component which has been replaced by radioCardGroup. the card component will be removed in a future release.`);
this.cardDeprecationMessagePrinted = true;
}
let id = this.getNextComponentId();
@@ -1699,9 +1701,10 @@ class ModelViewImpl implements azdata.ModelView {
private readonly _connection: azdata.connection.Connection,
private readonly _serverInfo: azdata.ServerInfo,
private readonly _extHostModelViewTree: ExtHostModelViewTreeViewsShape,
_extension: IExtensionDescription
_extension: IExtensionDescription,
logService: ILogService
) {
this._modelBuilder = new ModelBuilderImpl(this._proxy, this._handle, this._extHostModelViewTree, _extension);
this._modelBuilder = new ModelBuilderImpl(this._proxy, this._handle, this._extHostModelViewTree, _extension, logService);
}
public get onClosed(): vscode.Event<any> {
@@ -1755,7 +1758,8 @@ export class ExtHostModelView implements ExtHostModelViewShape {
private readonly _handlerToExtension = new Map<string, IExtensionDescription>();
constructor(
_mainContext: IMainContext,
private _extHostModelViewTree: ExtHostModelViewTreeViewsShape
private _extHostModelViewTree: ExtHostModelViewTreeViewsShape,
private readonly logService: ILogService
) {
this._proxy = _mainContext.getProxy(SqlMainContext.MainThreadModelView);
}
@@ -1774,7 +1778,7 @@ export class ExtHostModelView implements ExtHostModelViewShape {
$registerWidget(handle: number, id: string, connection: azdata.connection.Connection, serverInfo: azdata.ServerInfo): void {
let extension = this._handlerToExtension.get(id);
let view = new ModelViewImpl(this._proxy, handle, connection, serverInfo, this._extHostModelViewTree, extension);
let view = new ModelViewImpl(this._proxy, handle, connection, serverInfo, this._extHostModelViewTree, extension, this.logService);
this._modelViews.set(handle, view);
this._handlers.get(id)(view);
}

View File

@@ -14,6 +14,7 @@ import * as vsTreeExt from 'vs/workbench/api/common/extHostTreeViews';
import { Emitter } from 'vs/base/common/event';
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
import { assign } from 'vs/base/common/objects';
import { ILogService } from 'vs/platform/log/common/log';
export class ExtHostModelViewTreeViews implements ExtHostModelViewTreeViewsShape {
private _proxy: MainThreadModelViewShape;
@@ -21,7 +22,8 @@ export class ExtHostModelViewTreeViews implements ExtHostModelViewTreeViewsShape
private treeViews: Map<string, ExtHostTreeView<any>> = new Map<string, ExtHostTreeView<any>>();
constructor(
private _mainContext: IMainContext
private _mainContext: IMainContext,
private readonly logService: ILogService
) {
this._proxy = this._mainContext.getProxy(SqlMainContext.MainThreadModelView);
}
@@ -31,7 +33,7 @@ export class ExtHostModelViewTreeViews implements ExtHostModelViewTreeViewsShape
throw new Error('Options with treeDataProvider is mandatory');
}
const treeView = this.createExtHostTreeViewer(handle, componentId, options.treeDataProvider, extension);
const treeView = this.createExtHostTreeViewer(handle, componentId, options.treeDataProvider, extension, this.logService);
return {
dispose: () => {
this.treeViews.delete(componentId);
@@ -74,8 +76,8 @@ export class ExtHostModelViewTreeViews implements ExtHostModelViewTreeViewsShape
$setVisible(treeViewId: string, visible: boolean): void {
}
private createExtHostTreeViewer<T>(handle: number, id: string, dataProvider: azdata.TreeComponentDataProvider<T>, extension: IExtensionDescription): ExtHostTreeView<T> {
const treeView = new ExtHostTreeView<T>(handle, id, dataProvider, this._proxy, undefined, extension);
private createExtHostTreeViewer<T>(handle: number, id: string, dataProvider: azdata.TreeComponentDataProvider<T>, extension: IExtensionDescription, logService: ILogService): ExtHostTreeView<T> {
const treeView = new ExtHostTreeView<T>(handle, id, dataProvider, this._proxy, undefined, extension, logService);
this.treeViews.set(`${handle}-${id}`, treeView);
return treeView;
}
@@ -89,14 +91,15 @@ export class ExtHostTreeView<T> extends vsTreeExt.ExtHostTreeView<T> {
public readonly ChangeSelection: vscode.Event<vscode.TreeViewSelectionChangeEvent<T>> = this._onChangeSelection.event;
constructor(
private handle: number, private componentId: string, private componentDataProvider: azdata.TreeComponentDataProvider<T>,
private modelViewProxy: MainThreadModelViewShape, commands: CommandsConverter, extension: IExtensionDescription) {
super(componentId, { treeDataProvider: componentDataProvider }, undefined, commands, undefined, extension);
private modelViewProxy: MainThreadModelViewShape, commands: CommandsConverter, extension: IExtensionDescription,
private readonly _logService: ILogService) {
super(componentId, { treeDataProvider: componentDataProvider }, undefined, commands, _logService, extension);
}
onNodeCheckedChanged(parentHandle?: vsTreeExt.TreeItemHandle, checked?: boolean): void {
const parentElement = parentHandle ? this.getExtensionElement(parentHandle) : void 0;
if (parentHandle && !parentElement) {
console.error(`No tree item with id \'${parentHandle}\' found.`);
this._logService.error(`No tree item with id \'${parentHandle}\' found.`);
}
this._onNodeCheckedChanged.fire({ element: parentElement, checked: checked });

View File

@@ -10,6 +10,7 @@ import { ExtensionIdentifier, IExtensionDescription } from 'vs/platform/extensio
import * as azdata from 'azdata';
import { IAzdataExtensionApiFactory } from 'sql/workbench/api/common/sqlExtHost.api.impl';
import { INodeModuleFactory } from 'vs/workbench/api/common/extHostRequireInterceptor';
import { ILogService } from 'vs/platform/log/common/log';
export class AzdataNodeModuleFactory implements INodeModuleFactory {
public readonly nodeModuleName = 'azdata';
@@ -19,7 +20,8 @@ export class AzdataNodeModuleFactory implements INodeModuleFactory {
constructor(
private readonly _apiFactory: IAzdataExtensionApiFactory,
private readonly _extensionPaths: TernarySearchTree<IExtensionDescription>
private readonly _extensionPaths: TernarySearchTree<IExtensionDescription>,
private readonly _logService: ILogService
) {
}
@@ -40,7 +42,7 @@ export class AzdataNodeModuleFactory implements INodeModuleFactory {
if (!this._defaultApiImpl) {
let extensionPathsPretty = '';
this._extensionPaths.forEach((value, index) => extensionPathsPretty += `\t${index} -> ${value.identifier.value}\n`);
console.warn(`Could not identify extension for 'azdata' require call from ${parent.fsPath}. These are the extension path mappings: \n${extensionPathsPretty}`);
this._logService.warn(`Could not identify extension for 'azdata' require call from ${parent.fsPath}. These are the extension path mappings: \n${extensionPathsPretty}`);
this._defaultApiImpl = this._apiFactory(nullExtensionDescription);
}
return this._defaultApiImpl;

View File

@@ -70,6 +70,7 @@ export function createAdsApiFactory(accessor: ServicesAccessor): IAdsExtensionAp
const uriTransformer = accessor.get(IURITransformerService);
const rpcProtocol = accessor.get(IExtHostRpcService);
const extHostLogService = accessor.get(ILogService);
const logService = accessor.get(ILogService);
// Addressable instances
const extHostAccountManagement = rpcProtocol.set(SqlExtHostContext.ExtHostAccountManagement, new ExtHostAccountManagement(rpcProtocol));
@@ -82,8 +83,8 @@ export function createAdsApiFactory(accessor: ServicesAccessor): IAdsExtensionAp
const extHostTasks = rpcProtocol.set(SqlExtHostContext.ExtHostTasks, new ExtHostTasks(rpcProtocol, extHostLogService));
const extHostBackgroundTaskManagement = rpcProtocol.set(SqlExtHostContext.ExtHostBackgroundTaskManagement, new ExtHostBackgroundTaskManagement(rpcProtocol));
const extHostWebviewWidgets = rpcProtocol.set(SqlExtHostContext.ExtHostDashboardWebviews, new ExtHostDashboardWebviews(rpcProtocol));
const extHostModelViewTree = rpcProtocol.set(SqlExtHostContext.ExtHostModelViewTreeViews, new ExtHostModelViewTreeViews(rpcProtocol));
const extHostModelView = rpcProtocol.set(SqlExtHostContext.ExtHostModelView, new ExtHostModelView(rpcProtocol, extHostModelViewTree));
const extHostModelViewTree = rpcProtocol.set(SqlExtHostContext.ExtHostModelViewTreeViews, new ExtHostModelViewTreeViews(rpcProtocol, logService));
const extHostModelView = rpcProtocol.set(SqlExtHostContext.ExtHostModelView, new ExtHostModelView(rpcProtocol, extHostModelViewTree, logService));
const extHostDashboard = rpcProtocol.set(SqlExtHostContext.ExtHostDashboard, new ExtHostDashboard(rpcProtocol));
const extHostModelViewDialog = rpcProtocol.set(SqlExtHostContext.ExtHostModelViewDialog, new ExtHostModelViewDialog(rpcProtocol, extHostModelView, extHostBackgroundTaskManagement));
const extHostQueryEditor = rpcProtocol.set(SqlExtHostContext.ExtHostQueryEditor, new ExtHostQueryEditor(rpcProtocol));
@@ -91,7 +92,6 @@ export function createAdsApiFactory(accessor: ServicesAccessor): IAdsExtensionAp
const extHostNotebookDocumentsAndEditors = rpcProtocol.set(SqlExtHostContext.ExtHostNotebookDocumentsAndEditors, new ExtHostNotebookDocumentsAndEditors(rpcProtocol));
const extHostExtensionManagement = rpcProtocol.set(SqlExtHostContext.ExtHostExtensionManagement, new ExtHostExtensionManagement(rpcProtocol));
return {
azdata: function (extension: IExtensionDescription): typeof azdata {
// namespace: connection
@@ -113,7 +113,7 @@ export function createAdsApiFactory(accessor: ServicesAccessor): IAdsExtensionAp
},
// "sqlops" back-compat APIs
getActiveConnections(): Thenable<azdata.connection.Connection[]> {
console.warn('the method azdata.connection.getActiveConnections has been deprecated, replace it with azdata.connection.getConnections');
logService.warn('the method azdata.connection.getActiveConnections has been deprecated, replace it with azdata.connection.getConnections');
return extHostConnectionManagement.$getActiveConnections();
},
getCredentials(connectionId: string): Thenable<{ [name: string]: string }> {