Improve cell language detection and add support for language magics (#4081)

* Move to using notebook language by default, with override in cell
* Update cell language on kernel change
* Tweak language logic so that it prefers code mirror mode, then falls back since this was failing some notebooks
* Add new package.json contribution to define language magics. These result in cell language changing. Language is cleared out on removing the language magic
* Added support for executing Python, R and Java in the SQL Kernel to prove this out. It converts to the sp_execute_external_script format

TODO in future PR:

* Need to hook up completion item support for magics (issue #4078)
* Should add indicator at the bottom of a cell when an alternate language has been detected (issue #4079)
* On executing Python, R or Java, should add some output showing the generated code (issue #4080)
This commit is contained in:
Kevin Cunnane
2019-02-19 17:05:56 -08:00
committed by GitHub
parent 0205d0afb5
commit 1f501f4553
16 changed files with 400 additions and 131 deletions

View File

@@ -17,6 +17,7 @@ export class NotebookModelStub implements INotebookModel {
constructor(private _languageInfo?: nb.ILanguageInfo) {
}
public trustedMode: boolean;
language: string;
public get languageInfo(): nb.ILanguageInfo {
return this._languageInfo;

View File

@@ -27,7 +27,7 @@ describe('Cell Model', function (): void {
it('Should update values', async function (): Promise<void> {
let cell = factory.createCell(undefined, undefined);
cell.language = 'sql';
cell.setOverrideLanguage('sql');
should(cell.language).equal('sql');
cell.source = 'abcd';
should(cell.source).equal('abcd');

View File

@@ -96,6 +96,7 @@ describe('notebook model', function(): void {
connectionService: queryConnectionService.object,
providerId: 'SQL',
standardKernels: [{ name: 'SQL', connectionProviderIds: ['MSSQL'], notebookProvider: 'sql' }],
cellMagicMapper: undefined,
defaultKernel: undefined,
layoutChanged: undefined,
capabilitiesService: capabilitiesService.object