Revert "Remove typings and replace missing methods with vscodes (#8217)" (#8240)

This reverts commit 22a427f934.
This commit is contained in:
Elliot Boschwitz
2019-11-06 11:33:55 -08:00
committed by GitHub
parent 3b1eaca58e
commit e801a04bcf
184 changed files with 43388 additions and 634 deletions

View File

@@ -42,7 +42,6 @@ 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;
@@ -213,7 +212,7 @@ export class NotebookService extends Disposable implements INotebookService {
let sqlNotebookProvider = this._providerToStandardKernels.get(notebookConstants.SQL);
if (sqlNotebookProvider) {
let sqlConnectionTypes = this._queryManagementService.getRegisteredProviders();
let provider = find(sqlNotebookProvider, p => p.name === notebookConstants.SQL);
let provider = sqlNotebookProvider.find(p => p.name === notebookConstants.SQL);
if (provider) {
this._providerToStandardKernels.set(notebookConstants.SQL, [{
name: notebookConstants.SQL,
@@ -354,7 +353,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 = firstIndex(managers, m => m.providerId === providerId);
let index = managers.findIndex(m => m.providerId === providerId);
if (index && index >= 0) {
return managers[index];
}
@@ -405,7 +404,7 @@ export class NotebookService extends Disposable implements INotebookService {
return undefined;
}
let uriString = notebookUri.toString();
let editor = find(this.listNotebookEditors(), n => n.id === uriString);
let editor = this.listNotebookEditors().find(n => n.id === uriString);
return editor;
}
@@ -513,7 +512,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.some(x => x === key)) {
if (!knownProviders.includes(key)) {
this._providers.delete(key);
delete cache[key];
}
@@ -533,7 +532,7 @@ export class NotebookService extends Disposable implements INotebookService {
private removeContributedProvidersFromCache(identifier: IExtensionIdentifier, extensionService: IExtensionService) {
const notebookProvider = 'notebookProvider';
extensionService.getExtensions().then(i => {
let extension = find(i, c => c.identifier.value.toLowerCase() === identifier.id.toLowerCase());
let extension = i.find(c => c.identifier.value.toLowerCase() === identifier.id.toLowerCase());
if (extension && extension.contributes
&& extension.contributes[notebookProvider]
&& extension.contributes[notebookProvider].providerId) {
@@ -585,9 +584,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 && firstIndex(this._trustedCacheQueue, uri => uri.toString() === notebookUriString) < 0) {
if (changeType === NotebookChangeType.Saved && this._trustedCacheQueue.findIndex(uri => uri.toString() === notebookUriString) < 0) {
// Only save if it's trusted
let notebook = find(this.listNotebookEditors(), n => n.id === notebookUriString);
let notebook = this.listNotebookEditors().find(n => n.id === notebookUriString);
if (notebook && notebook.model.trustedMode) {
this._trustedCacheQueue.push(notebookUri);
this._updateTrustCacheScheduler.schedule();

View File

@@ -25,8 +25,6 @@ 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;
@@ -73,7 +71,7 @@ export class SqlSessionManager implements nb.SessionManager {
startNew(options: nb.ISessionOptions): Thenable<nb.ISession> {
let sqlSession = new SqlSession(options, this._instantiationService);
let index = firstIndex(SqlSessionManager._sessions, session => session.path === options.path);
let index = SqlSessionManager._sessions.findIndex(session => session.path === options.path);
if (index > -1) {
SqlSessionManager._sessions.splice(index);
}
@@ -82,7 +80,7 @@ export class SqlSessionManager implements nb.SessionManager {
}
shutdown(id: string): Thenable<void> {
let index = firstIndex(SqlSessionManager._sessions, session => session.id === id);
let index = SqlSessionManager._sessions.findIndex(session => session.id === id);
if (index > -1) {
let sessionManager = SqlSessionManager._sessions[index];
SqlSessionManager._sessions.splice(index);
@@ -308,7 +306,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 (startsWith(firstLine, '%%')) {
if (firstLine.startsWith('%%')) {
// 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