@@ -54,7 +54,9 @@ function EditorUASTSpitPane({
54
54
handleLangChange,
55
55
handleShowLocationsChange,
56
56
handleFilterChange,
57
- handleSearch
57
+ handleSearch,
58
+ mode,
59
+ handleModeChange
58
60
} ) {
59
61
return (
60
62
< SplitPane split = "vertical" defaultSize = { 500 } minSize = { 1 } maxSize = { - 15 } >
@@ -72,6 +74,8 @@ function EditorUASTSpitPane({
72
74
handleShowLocationsChange = { handleShowLocationsChange }
73
75
handleFilterChange = { handleFilterChange }
74
76
handleSearch = { handleSearch }
77
+ mode = { mode }
78
+ handleModeChange = { handleModeChange }
75
79
/>
76
80
</ SplitPane >
77
81
) ;
@@ -87,7 +91,9 @@ EditorUASTSpitPane.propTypes = {
87
91
handleLangChange : PropTypes . func . isRequired ,
88
92
handleShowLocationsChange : PropTypes . func . isRequired ,
89
93
handleFilterChange : PropTypes . func . isRequired ,
90
- handleSearch : PropTypes . func . isRequired
94
+ handleSearch : PropTypes . func . isRequired ,
95
+ mode : PropTypes . string . isRequired ,
96
+ handleModeChange : PropTypes . func . isRequired
91
97
} ;
92
98
93
99
const EditorWithUAST = withUASTEditor ( EditorUASTSpitPane ) ;
@@ -104,7 +110,8 @@ class CodeViewer extends Component {
104
110
uast : null ,
105
111
error : null ,
106
112
showLocations : false ,
107
- filter : ''
113
+ filter : '' ,
114
+ mode : api . defaultUastMode
108
115
} ;
109
116
110
117
this . handleLangChange = this . handleLangChange . bind ( this ) ;
@@ -113,6 +120,7 @@ class CodeViewer extends Component {
113
120
this . removeError = this . removeError . bind ( this ) ;
114
121
this . handleShowLocationsChange = this . handleShowLocationsChange . bind ( this ) ;
115
122
this . handleFilterChange = this . handleFilterChange . bind ( this ) ;
123
+ this . handleModeChange = this . handleModeChange . bind ( this ) ;
116
124
}
117
125
118
126
componentDidMount ( ) {
@@ -154,7 +162,12 @@ class CodeViewer extends Component {
154
162
this . setState ( { error : null , uast : null , uastLoading : true } ) ;
155
163
156
164
api
157
- . parseCode ( this . state . language , this . props . code , this . state . filter )
165
+ . parseCode (
166
+ this . state . language ,
167
+ this . props . code ,
168
+ this . state . mode ,
169
+ this . state . filter
170
+ )
158
171
. then ( res => {
159
172
this . setState ( { uast : res } ) ;
160
173
} )
@@ -176,6 +189,13 @@ class CodeViewer extends Component {
176
189
this . setState ( { filter : e . target . value } ) ;
177
190
}
178
191
192
+ handleModeChange ( mode ) {
193
+ this . setState ( { mode } ) ;
194
+ if ( this . state . showUast ) {
195
+ this . parseCode ( ) ;
196
+ }
197
+ }
198
+
179
199
render ( ) {
180
200
const { showModal, onHide, code, languages } = this . props ;
181
201
const {
@@ -186,7 +206,8 @@ class CodeViewer extends Component {
186
206
uast,
187
207
error,
188
208
showLocations,
189
- filter
209
+ filter,
210
+ mode
190
211
} = this . state ;
191
212
192
213
if ( loading ) {
@@ -230,6 +251,8 @@ class CodeViewer extends Component {
230
251
handleShowLocationsChange = { this . handleShowLocationsChange }
231
252
handleFilterChange = { this . handleFilterChange }
232
253
handleSearch = { this . parseCode }
254
+ mode = { mode }
255
+ handleModeChange = { this . handleModeChange }
233
256
/>
234
257
{ error ? (
235
258
< div className = "error" >
0 commit comments