2017-11-20 21 views
1

私はtypescriptのためにモナコのエディタを使用しています。現在のモデルでASTを取得する方法はありますか?エディタが変更に反応するようにツリーを変更することは可能ですか?私はtypescriptのための簡単なリファクタリングツールをしたいですか?モナコの編集者がASTにアクセス

答えて

0

モナコは、そのASTを公開していませんが、あなたの代わりにjscodeshiftを使用することができます。

const editor = monaco.editor.create(
    document.querySelector("#editor"), {value: 'var foo;'})// editor content: var foo; 
const newValue = jscodeshift(editor.getValue()) 
    .findVariableDeclarators('foo') 
    .renameTo('bar') 
    .toSource(); 
editor.setValue(newValue); // editor content: var bar; 
関連する問題