@@ -54,7 +54,9 @@ function EditorUASTSpitPane({
5454 handleLangChange,
5555 handleShowLocationsChange,
5656 handleFilterChange,
57- handleSearch
57+ handleSearch,
58+ mode,
59+ handleModeChange
5860} ) {
5961 return (
6062 < SplitPane split = "vertical" defaultSize = { 500 } minSize = { 1 } maxSize = { - 15 } >
@@ -72,6 +74,8 @@ function EditorUASTSpitPane({
7274 handleShowLocationsChange = { handleShowLocationsChange }
7375 handleFilterChange = { handleFilterChange }
7476 handleSearch = { handleSearch }
77+ mode = { mode }
78+ handleModeChange = { handleModeChange }
7579 />
7680 </ SplitPane >
7781 ) ;
@@ -87,7 +91,9 @@ EditorUASTSpitPane.propTypes = {
8791 handleLangChange : PropTypes . func . isRequired ,
8892 handleShowLocationsChange : PropTypes . func . isRequired ,
8993 handleFilterChange : PropTypes . func . isRequired ,
90- handleSearch : PropTypes . func . isRequired
94+ handleSearch : PropTypes . func . isRequired ,
95+ mode : PropTypes . string . isRequired ,
96+ handleModeChange : PropTypes . func . isRequired
9197} ;
9298
9399const EditorWithUAST = withUASTEditor ( EditorUASTSpitPane ) ;
@@ -104,7 +110,8 @@ class CodeViewer extends Component {
104110 uast : null ,
105111 error : null ,
106112 showLocations : false ,
107- filter : ''
113+ filter : '' ,
114+ mode : api . defaultUastMode
108115 } ;
109116
110117 this . handleLangChange = this . handleLangChange . bind ( this ) ;
@@ -113,6 +120,7 @@ class CodeViewer extends Component {
113120 this . removeError = this . removeError . bind ( this ) ;
114121 this . handleShowLocationsChange = this . handleShowLocationsChange . bind ( this ) ;
115122 this . handleFilterChange = this . handleFilterChange . bind ( this ) ;
123+ this . handleModeChange = this . handleModeChange . bind ( this ) ;
116124 }
117125
118126 componentDidMount ( ) {
@@ -154,7 +162,12 @@ class CodeViewer extends Component {
154162 this . setState ( { error : null , uast : null , uastLoading : true } ) ;
155163
156164 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+ )
158171 . then ( res => {
159172 this . setState ( { uast : res } ) ;
160173 } )
@@ -176,6 +189,13 @@ class CodeViewer extends Component {
176189 this . setState ( { filter : e . target . value } ) ;
177190 }
178191
192+ handleModeChange ( mode ) {
193+ this . setState ( { mode } ) ;
194+ if ( this . state . showUast ) {
195+ this . parseCode ( ) ;
196+ }
197+ }
198+
179199 render ( ) {
180200 const { showModal, onHide, code, languages } = this . props ;
181201 const {
@@ -186,7 +206,8 @@ class CodeViewer extends Component {
186206 uast,
187207 error,
188208 showLocations,
189- filter
209+ filter,
210+ mode
190211 } = this . state ;
191212
192213 if ( loading ) {
@@ -230,6 +251,8 @@ class CodeViewer extends Component {
230251 handleShowLocationsChange = { this . handleShowLocationsChange }
231252 handleFilterChange = { this . handleFilterChange }
232253 handleSearch = { this . parseCode }
254+ mode = { mode }
255+ handleModeChange = { this . handleModeChange }
233256 />
234257 { error ? (
235258 < div className = "error" >
0 commit comments