mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-23 17:23:02 -05:00
Remove typings and replace missing methods with vscodes (#8217)
* remove typings and replace missing methods with vscodes * fix strict-null-checks * fix tests
This commit is contained in:
@@ -42,6 +42,7 @@ import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { toErrorMessage } from 'vs/base/common/errorMessage';
|
||||
import { NotebookChangeType } from 'sql/workbench/parts/notebook/common/models/contracts';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { find, firstIndex } from 'vs/base/common/arrays';
|
||||
|
||||
export interface NotebookProviderProperties {
|
||||
provider: string;
|
||||
@@ -212,7 +213,7 @@ export class NotebookService extends Disposable implements INotebookService {
|
||||
let sqlNotebookProvider = this._providerToStandardKernels.get(notebookConstants.SQL);
|
||||
if (sqlNotebookProvider) {
|
||||
let sqlConnectionTypes = this._queryManagementService.getRegisteredProviders();
|
||||
let provider = sqlNotebookProvider.find(p => p.name === notebookConstants.SQL);
|
||||
let provider = find(sqlNotebookProvider, p => p.name === notebookConstants.SQL);
|
||||
if (provider) {
|
||||
this._providerToStandardKernels.set(notebookConstants.SQL, [{
|
||||
name: notebookConstants.SQL,
|
||||
@@ -353,7 +354,7 @@ export class NotebookService extends Disposable implements INotebookService {
|
||||
let managers: INotebookManager[] = this._managersMap.get(uriString);
|
||||
// If manager already exists for a given notebook, return it
|
||||
if (managers) {
|
||||
let index = managers.findIndex(m => m.providerId === providerId);
|
||||
let index = firstIndex(managers, m => m.providerId === providerId);
|
||||
if (index && index >= 0) {
|
||||
return managers[index];
|
||||
}
|
||||
@@ -404,7 +405,7 @@ export class NotebookService extends Disposable implements INotebookService {
|
||||
return undefined;
|
||||
}
|
||||
let uriString = notebookUri.toString();
|
||||
let editor = this.listNotebookEditors().find(n => n.id === uriString);
|
||||
let editor = find(this.listNotebookEditors(), n => n.id === uriString);
|
||||
return editor;
|
||||
}
|
||||
|
||||
@@ -512,7 +513,7 @@ export class NotebookService extends Disposable implements INotebookService {
|
||||
let knownProviders = Object.keys(notebookRegistry.providers);
|
||||
let cache = this.providersMemento.notebookProviderCache;
|
||||
for (let key in cache) {
|
||||
if (!knownProviders.includes(key)) {
|
||||
if (!knownProviders.some(x => x === key)) {
|
||||
this._providers.delete(key);
|
||||
delete cache[key];
|
||||
}
|
||||
@@ -532,7 +533,7 @@ export class NotebookService extends Disposable implements INotebookService {
|
||||
private removeContributedProvidersFromCache(identifier: IExtensionIdentifier, extensionService: IExtensionService) {
|
||||
const notebookProvider = 'notebookProvider';
|
||||
extensionService.getExtensions().then(i => {
|
||||
let extension = i.find(c => c.identifier.value.toLowerCase() === identifier.id.toLowerCase());
|
||||
let extension = find(i, c => c.identifier.value.toLowerCase() === identifier.id.toLowerCase());
|
||||
if (extension && extension.contributes
|
||||
&& extension.contributes[notebookProvider]
|
||||
&& extension.contributes[notebookProvider].providerId) {
|
||||
@@ -584,9 +585,9 @@ export class NotebookService extends Disposable implements INotebookService {
|
||||
// 3. Not already saving (e.g. isn't in the queue to be cached)
|
||||
// 4. Notebook is trusted. Don't need to save state of untrusted notebooks
|
||||
let notebookUriString = notebookUri.toString();
|
||||
if (changeType === NotebookChangeType.Saved && this._trustedCacheQueue.findIndex(uri => uri.toString() === notebookUriString) < 0) {
|
||||
if (changeType === NotebookChangeType.Saved && firstIndex(this._trustedCacheQueue, uri => uri.toString() === notebookUriString) < 0) {
|
||||
// Only save if it's trusted
|
||||
let notebook = this.listNotebookEditors().find(n => n.id === notebookUriString);
|
||||
let notebook = find(this.listNotebookEditors(), n => n.id === notebookUriString);
|
||||
if (notebook && notebook.model.trustedMode) {
|
||||
this._trustedCacheQueue.push(notebookUri);
|
||||
this._updateTrustCacheScheduler.schedule();
|
||||
|
||||
@@ -25,6 +25,8 @@ import { ILanguageMagic } from 'sql/workbench/services/notebook/browser/notebook
|
||||
import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { getUriPrefix, uriPrefixes } from 'sql/platform/connection/common/utils';
|
||||
import { firstIndex } from 'vs/base/common/arrays';
|
||||
import { startsWith } from 'vs/base/common/strings';
|
||||
|
||||
export const sqlKernelError: string = localize("sqlKernelError", "SQL kernel error");
|
||||
export const MAX_ROWS = 5000;
|
||||
@@ -71,7 +73,7 @@ export class SqlSessionManager implements nb.SessionManager {
|
||||
|
||||
startNew(options: nb.ISessionOptions): Thenable<nb.ISession> {
|
||||
let sqlSession = new SqlSession(options, this._instantiationService);
|
||||
let index = SqlSessionManager._sessions.findIndex(session => session.path === options.path);
|
||||
let index = firstIndex(SqlSessionManager._sessions, session => session.path === options.path);
|
||||
if (index > -1) {
|
||||
SqlSessionManager._sessions.splice(index);
|
||||
}
|
||||
@@ -80,7 +82,7 @@ export class SqlSessionManager implements nb.SessionManager {
|
||||
}
|
||||
|
||||
shutdown(id: string): Thenable<void> {
|
||||
let index = SqlSessionManager._sessions.findIndex(session => session.id === id);
|
||||
let index = firstIndex(SqlSessionManager._sessions, session => session.id === id);
|
||||
if (index > -1) {
|
||||
let sessionManager = SqlSessionManager._sessions[index];
|
||||
SqlSessionManager._sessions.splice(index);
|
||||
@@ -306,7 +308,7 @@ class SqlKernel extends Disposable implements nb.IKernel {
|
||||
let code = Array.isArray(content.code) ? content.code.join('') : content.code;
|
||||
let firstLineEnd = code.indexOf(this.textResourcePropertiesService.getEOL(URI.file(this._path)));
|
||||
let firstLine = code.substring(0, (firstLineEnd >= 0) ? firstLineEnd : 0).trimLeft();
|
||||
if (firstLine.startsWith('%%')) {
|
||||
if (startsWith(firstLine, '%%')) {
|
||||
// Strip out the line
|
||||
code = code.substring(firstLineEnd, code.length);
|
||||
// Try and match to an external script magic. If we add more magics later, should handle transforms better
|
||||
|
||||
Reference in New Issue
Block a user