package Ġorg . jetbrains . plugins . notebooks . editor Ċ Ċ import Ġcom . intellij . openapi . action System . DataContext Ċ import Ġcom . intellij . openapi . action System . Platform Data Keys Ċ import Ġcom . intellij . openapi . editor . Editor Ċ import Ġcom . intellij . openapi . editor . impl . Editor Component Impl Ċ import Ġcom . intellij . util . cast S af ely To Ċ import Ġjava . awt . Component Ċ import Ġjavax . swing . Swing Utilities Ċ Ċ /** Ċ Ġ* ĠGet Ġthe Ġposition Ġof Ġa Ġcurrent Ġ[ Notebook Cell Lines . Interval ]. ĠIt Ġis Ġcalculated Ġaccording Ġto Ġthe Ġfocused Ġcomponent Ġand Ġthe Ġcaret Ġposition . Ċ Ġ*/ Ċ val ĠData Context . notebook Cell Lines Interval : ĠNotebook Cell Lines . Interval ? ĊĠ Ġget () Ġ= ĊĠĠĠ ĠgetData ( NOTE BOOK _ CELL _ LINES _ INTERVAL _ DATA _ KEY ) ĊĠĠĠ Ġ?: Ġget Offset In Editor With Components ( this ) Ġ{ Ġit . notebook Cell Lines Provider Ġ!= Ġnull Ġ} ĊĠĠĠĠĠ Ġ? . let Ġ{ Ġ( editor , Ġoffset ) Ġ-> ĊĠĠĠĠĠĠĠ ĠNotebook Cell Lines . get ( editor ). intervals Iterator ( editor . document . get LineNumber ( offset )). take If Ġ{ Ġit . hasNext () Ġ} ?. next () ĊĠĠĠĠĠ Ġ} Ċ Ċ inline Ġfun Ġget Offset In Editor With Components ( ĊĠ Ġdata Context : ĠData Context , ĊĠ Ġcross inline Ġeditor Filter : Ġ( Editor ) Ġ-> ĠBoolean , Ċ ): ĠPair < Editor , ĠInt >? Ġ= ĊĠ Ġdata Context ĊĠĠĠ Ġ. getData ( Platform Data Keys . CONTEXT _ COMPONENT ) ĊĠĠĠ Ġ? . cast S af ely To < Editor Component Impl >() ĊĠĠĠ Ġ? . editor ĊĠĠĠ Ġ? . take If ( editor Filter ) ĊĠĠĠ Ġ? . let Ġ{ Ġnotebook Editor Ġ-> ĊĠĠĠĠĠ Ġnotebook Editor Ġto Ġnotebook Editor . caret Model . offset . coerce At Most ( notebook Editor . document . text Length Ġ- Ġ 1 ). coerce At Least ( 0 ) ĊĠĠĠ Ġ} ĊĠ Ġ?: Ġget Offset In Editor By Component Hierarchy ( data Context . getData ( Platform Data Keys . CONTEXT _ COMPONENT ), Ġeditor Filter ) ĊĠ Ġ?: Ġget Offset In Editor By Component Hierarchy ( data Context . getData ( Platform Data Keys . EDITOR )?. content Component , Ġeditor Filter ) Ċ Ċ /** ĠPrivate ĠAPI . Ġ*/ Ċ @ Published Api Ċ internal Ġinline Ġfun Ġget Offset In Editor By Component Hierarchy ( ĊĠ Ġcomponent : ĠComponent ?, ĊĠ Ġcross inline Ġeditor Filter : Ġ( Editor ) Ġ-> ĠBoolean , Ċ ): ĠPair < Editor , ĠInt >? Ġ= ĊĠ Ġgenerate Sequence ( component , ĠComponent :: getParent ) ĊĠĠĠ Ġ. zip With Next () ĊĠĠĠ Ġ. map NotNull Ġ{ Ġ( child , Ġparent ) Ġ-> ĊĠĠĠĠĠ Ġif Ġ( parent Ġis ĠEditor Component Impl Ġ&& Ġeditor Filter ( parent . editor )) Ġchild Ġto Ġparent . editor ĊĠĠĠĠĠ Ġelse Ġnull ĊĠĠĠ Ġ} ĊĠĠĠ Ġ. first OrNull () ĊĠĠĠ Ġ? . let Ġ{ Ġ( child , Ġeditor ) Ġ-> ĊĠĠĠĠĠ Ġval Ġpoint Ġ= ĠSw ing Utilities . convert Point ( child , Ġ 0 , Ġ 0 , Ġeditor . content Component ) ĊĠĠĠĠĠ Ġeditor Ġto Ġeditor . logical Position To Offset ( editor . xy To Logical Position ( point )) ĊĠĠĠ Ġ}