11// Copyright (c) Jupyter Development Team.
22// Distributed under the terms of the Modified BSD License.
33
4+ import type { KernelMessage } from '@jupyterlab/services' ;
5+
46import { parseScript } from 'meriyah' ;
57import { generate } from 'astring' ;
68
@@ -61,19 +63,14 @@ export interface ICompletionResult {
6163/**
6264 * Result of code completeness check.
6365 */
64- export interface IIsCompleteResult {
65- status : 'complete' | 'incomplete' | 'invalid' | 'unknown' ;
66- indent ?: string ;
67- }
66+ export type IIsCompleteResult =
67+ | KernelMessage . IIsCompleteReplyIncomplete
68+ | KernelMessage . IIsCompleteReplyOther ;
6869
6970/**
7071 * Result of code inspection.
7172 */
72- export interface IInspectResult {
73- found : boolean ;
74- data : IMimeBundle ;
75- metadata : Record < string , any > ;
76- }
73+ export type IInspectResult = KernelMessage . IInspectReply ;
7774
7875/**
7976 * Registry for tracking code declarations across cells.
@@ -904,13 +901,14 @@ export class JavaScriptExecutor {
904901 inspect (
905902 code : string ,
906903 cursorPos : number ,
907- detailLevel : number = 0
904+ detailLevel : KernelMessage . IInspectRequestMsg [ 'content' ] [ 'detail_level' ] = 0
908905 ) : IInspectResult {
909906 // Extract the word/expression at cursor position
910907 const expression = this . _extractExpressionAtCursor ( code , cursorPos ) ;
911908
912909 if ( ! expression ) {
913910 return {
911+ status : 'ok' ,
914912 found : false ,
915913 data : { } ,
916914 metadata : { }
@@ -933,6 +931,7 @@ export class JavaScriptExecutor {
933931 ) ;
934932
935933 return {
934+ status : 'ok' ,
936935 found : true ,
937936 data : inspectionData ,
938937 metadata : { }
@@ -965,6 +964,7 @@ export class JavaScriptExecutor {
965964 const doc = this . getBuiltinDocumentation ( expression ) ;
966965 if ( doc ) {
967966 return {
967+ status : 'ok' ,
968968 found : true ,
969969 data : {
970970 'text/plain' : `${ expression } : ${ doc } ` ,
@@ -978,6 +978,7 @@ export class JavaScriptExecutor {
978978 const suggestions = this . _findSimilarNames ( expression ) ;
979979 if ( suggestions . length > 0 ) {
980980 return {
981+ status : 'ok' ,
981982 found : true ,
982983 data : {
983984 'text/plain' : `'${ expression } ' not found. Did you mean: ${ suggestions . join ( ', ' ) } ?` ,
@@ -988,6 +989,7 @@ export class JavaScriptExecutor {
988989 }
989990
990991 return {
992+ status : 'ok' ,
991993 found : false ,
992994 data : { } ,
993995 metadata : { }
@@ -1870,14 +1872,14 @@ export class JavaScriptExecutor {
18701872
18711873 for ( const part of parts ) {
18721874 if ( value === null || value === undefined ) {
1873- return { found : false , data : { } , metadata : { } } ;
1875+ return { status : 'ok' , found : false , data : { } , metadata : { } } ;
18741876 }
18751877 const hasProp =
18761878 part in value || Object . prototype . hasOwnProperty . call ( value , part ) ;
18771879 if ( hasProp ) {
18781880 value = value [ part ] ;
18791881 } else {
1880- return { found : false , data : { } , metadata : { } } ;
1882+ return { status : 'ok' , found : false , data : { } , metadata : { } } ;
18811883 }
18821884 }
18831885
@@ -1898,12 +1900,13 @@ export class JavaScriptExecutor {
18981900 }
18991901
19001902 return {
1903+ status : 'ok' ,
19011904 found : true ,
19021905 data : inspectionData ,
19031906 metadata : { }
19041907 } ;
19051908 } catch {
1906- return { found : false , data : { } , metadata : { } } ;
1909+ return { status : 'ok' , found : false , data : { } , metadata : { } } ;
19071910 }
19081911 }
19091912
0 commit comments