1- import React , { useState } from 'react' ;
1+ import React , { useRef , useState } from 'react' ;
22import ReactDOM from 'react-dom' ;
33import { IAppInstance , AppRenderer , SlotLocation } from '@alipay/alex' ;
44import '@alipay/alex/languages/sql' ;
@@ -13,6 +13,8 @@ import * as SQLPlugin from './sql.plugin';
1313import { IEditor } from '@opensumi/ide-editor' ;
1414import { Popover , Radio } from 'antd' ;
1515import 'antd/dist/antd.css' ;
16+ import odcTheme from '@alipay/alex/extensions/alex.odc-theme' ;
17+
1618setMonacoEnvironment ( ) ;
1719
1820const layoutConfig = {
@@ -48,22 +50,39 @@ async function editor() {
4850 console . log ( editor ?. monacoEditor . getValue ( ) ) ;
4951}
5052
53+
54+
5155const App = ( ) => {
5256 const [ fontValue , setFontValue ] = useState ( 16 ) ;
5357 const [ encoding , setEncoding ] = useState ( 'utf8' ) ;
5458
59+ let tableID = 1
60+
61+ const suggestTables = useRef ( [ {
62+ label : `sample_one_table_${ tableID } ` ,
63+ type : 'SAMPLE_TYPE_ONE' ,
64+ insertText : 'LD.sample_one_table1' ,
65+ kind : CompletionItemKind . Method ,
66+ sortText : 'a' ,
67+ } ] )
68+
69+ function changeTables ( ) {
70+ tableID ++ ;
71+ suggestTables . current = suggestTables . current . concat ( [ {
72+ label : `sample_one_table_${ tableID } ` ,
73+ type : 'SAMPLE_TYPE_ONE' ,
74+ insertText : 'LD.sample_one_table1' ,
75+ kind : CompletionItemKind . Method ,
76+ sortText : 'a' ,
77+ } ] )
78+ }
5579 const onChangeFont = ( e ) => {
5680 setFontValue ( e . target . value ) ;
57- console . log ( e . target . value )
5881 updatePrefeence ( 'editor.fontSize' , e . target . value ) ;
59- console . log ( SQLPlugin . api . commands ?. executeCommand ( 'alex.getDefaultPreference' , 'files.encoding' ) )
6082 } ;
6183 const onChangeEnoding = ( e ) => {
6284 setEncoding ( e . target . value ) ;
63- console . log ( e . target . value )
64-
6585 updatePrefeence ( 'files.encoding' , e . target . value ) ;
66-
6786 } ;
6887
6988 const content = ( ) => (
@@ -90,6 +109,7 @@ const App = () => {
90109 < Button onClick = { ( ) => addLine ( ) } > 添加行</ Button >
91110 < Button onClick = { ( ) => openFile ( ) } > 打开文件</ Button >
92111 < Button onClick = { ( ) => editor ( ) } > 获取当前内容</ Button >
112+ < Button onClick = { ( ) => changeTables ( ) } > change suggest Tables</ Button >
93113 < Popover content = { content } placement = "top" >
94114 < Button > 设置</ Button >
95115 </ Popover >
@@ -139,16 +159,8 @@ const App = () => {
139159 } ,
140160 ] ,
141161 onSuggestTables : ( keyword , options ) => {
142- console . log ( keyword , options ) ;
143- return Promise . resolve ( [
144- {
145- label : 'sample_one_table1' ,
146- type : 'SAMPLE_TYPE_ONE' ,
147- insertText : 'LD.sample_one_table1' ,
148- kind : CompletionItemKind . Method ,
149- sortText : 'a' ,
150- } ,
151- ] ) ;
162+ console . log ( 'suggest' , keyword , options , suggestTables . current ) ;
163+ return suggestTables . current ;
152164 } ,
153165 onSuggestFields : ( prefix , options ) => {
154166 return Promise . resolve ( [
@@ -177,6 +189,7 @@ const App = () => {
177189 } ,
178190 options : {
179191 language : supportLanguage . ODPSSQL ,
192+ disableAsyncItemCache : true ,
180193 } ,
181194 sorter : ( type ) => {
182195 switch ( type ) {
@@ -234,11 +247,11 @@ const App = () => {
234247 } ,
235248 } ) ,
236249 ] ,
237- extensionMetadata : [ ] ,
250+ extensionMetadata : [ odcTheme ] ,
238251 workspaceDir : `sql-service` ,
239252 layoutConfig,
240253 defaultPreferences : {
241- 'general.theme' : 'opensumi -light' ,
254+ 'general.theme' : 'odc -light' ,
242255 'application.confirmExit' : 'never' ,
243256 'editor.autoSave' : 'afterDelay' ,
244257 'editor.guides.bracketPairs' : false ,
0 commit comments