package Ġcom . github . bj ans en . intellij . pe bble . psi Ċ Ċ import Ġcom . github . bj ans en . intellij . pe bble . lang . P eb ble Language Ċ import Ġcom . github . bj ans en . intellij . pe bble . psi . P eb ble Parser Definition . Companion . rules Ċ import Ġcom . github . bj ans en . pe bble . parser . P eb ble Parser Ċ import Ġcom . intellij . lang . AST Node Ċ import Ġcom . intellij . openapi . project . Project Ċ import Ġcom . intellij . psi . Psi Element Ċ import Ġcom . intellij . psi . Psi File Ċ import Ġcom . intellij . psi . Psi File Factory Ċ import Ġcom . intellij . psi . util . Psi Tree Util Ċ import Ġorg . antlr . intellij . adapt or . lexer . Token I ElementType Ċ Ċ object ĠPsi Element Factory Ġ{ ĊĊĠĠĠ Ġfun Ġcreate Identifier ( name : ĠString , Ġproject : ĠProject ): ĠP eb ble Identifier Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfile Ġ= Ġcreate File (" {{$ name }} ", Ġproject ) ĊĠĠĠĠĠĠĠ Ġreturn ĠPsi Tree Util . find Child OfType ( file , ĠP eb ble Identifier :: class . java ) !! ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġcreate Comment ( text : ĠString , Ġproject : ĠProject ): ĠP eb ble Comment Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfile Ġ= Ġcreate File ( text , Ġproject ) ĊĠĠĠĠĠĠĠ Ġreturn Ġfile . firstChild Ġas ĠP eb ble Comment ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġcreate File ( content : ĠString , Ġproject : ĠProject ): ĠPsi File Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠPsi File Factory . getInstance ( project ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. create File FromText (" a . pe b ", ĠP eb ble Language . INSTANCE , Ġcontent ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun ĠcreateElement ( node : ĠAST Node ): ĠPsi Element Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġel Type Ġ= Ġnode . elementType ĊĊĠĠĠĠĠĠĠ Ġif Ġ( el Type Ġ== Ġrules [ P eb ble Parser . RULE _ pe bble Template ]) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĠP eb ble Template ( node ) ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġif Ġ( el Type Ġ== ĠP eb ble Parser Definition . for ElementType ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĠP eb ble For Tag ( node ) ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġif Ġ( el Type Ġ== ĠP eb ble Parser Definition . macro ElementType ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĠP eb ble Macro Tag ( node ) ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġif Ġ( el Type Ġ== ĠP eb ble Parser Definition . block ElementType ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĠP eb ble Block Tag ( node ) ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġif Ġ( P eb ble Parser Definition . is Tag Directive Like ( el Type )) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn Ġwhen Ġ( node . firstChild Node . find Child ByType ( rules [ P eb ble Parser . RULE _ tagName ]) ?. text ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" set " Ġ-> ĠP eb ble Set Tag ( node ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġelse Ġ-> ĠP eb ble Tag Directive ( node ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġif Ġ( el Type Ġ== Ġrules [ P eb ble Parser . RULE _ print Directive ]) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĠP eb ble Print Directive ( node ) ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġif Ġ( el Type Ġ== Ġrules [ P eb ble Parser . RULE _ identifier ]) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( node . tree Parent ?. elementType Ġ== Ġrules [ P eb ble Parser . RULE _ in _ expression ]) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĠP eb ble In Variable ( node ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĠP eb ble Identifier ( node ) ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġif Ġ( el Type Ġ== Ġrules [ P eb ble Parser . RULE _ argument _ list ]) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĠP eb ble ArgumentList ( node ) ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġif Ġ( el Type Ġis ĠToken I ElementType ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĠP eb ble Psi Element ( node ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġreturn ĠP eb ble Psi Element ( node ) Ġ// ĠTODO ĊĠĠĠ Ġ} Ċ } ĊĊ