-
Notifications
You must be signed in to change notification settings - Fork 4
Developer's Note
Developer's Note
from Kanon_memo_by_masuhara
URL: https://github.com/prg-titech/Kanon
read README.md
npm start -> open localhost:8000
__$__.ASTTransforms : {
<visitor_generator># : () -> { enter: (node,path)->(), leave: (node,path)->() }
}
ContextUpdateが呼び出すDraw (viewとsnapshotを探して描画)
MoveContextOnCursorPosition カーソル位置を固定して文脈を前後させる
instrumented code が呼出びす RegisterCallRelationship (caller/calleeを記録)
ContextUpdate: 文脈が変化したときに呼び出されるとグラフ表示を更新する
(snapshotを取るときに見た目も決定しているので注意)
graph というのは、snapshot traverse.js に定義がある
[[file:~/current/students/t4/oka/Kanon/src/js/editor.js::$.langTools%20=%20ace.require('ace/ext/language_tools');][editor.js]] を編集
#+BEGIN_SRC js $.editor.commands.addCommand({ name: 'UpContext', bindKey: {win: 'Ctrl-Shift-u', mac: 'Command-Shift-u'}, exec: function() { alert("UpContext!"); } }); #+END_SRC みたいに追加
#+BEGIN_SRC $.Context.SnapshotContext Object { cpID: "18", loopLabel: "FunctionDeclaration2", contextSensitiveID: "main-ForStatement1-1-call2-FunctionDeclaration1-call1-FunctionDeclaration2" } #+END_SRC こんな感じの情報を使えばよい
クラス定義は [[file:~/current/students/t4/oka/Kanon/src/js/call-tree/callTree.js::$.CallTree%20=%20{};][callTree.js]] にある
例えば "main-ForStatement1-1-call2-FunctionDeclaration1" に戻る
$.Context.LabelPos の中から対応する文/式の種類(Call, Loop, New)とかの辞書からLabelを参照する
call2 の場所だったら、 $.Context.LabelPos.Call.call2 に start, end がある (line は1始まり)
editorの row (これは0始まり)
[[https://ace.c9.io/#nav=api&api=editor][ACE Editor のAPI]] を見て $.editor.moveCursorTo(6,21); とかする。 jumpToConstruction の定義を参考にせよ
さらに $.Update.ContextUpdate() を呼ぶ (カーソル位置を探して、snapshopを見つけて再描画)