// ĠCopyright Ġ 2 0 0 0 - 2 0 2 0 ĠJetBrains Ġs . r . o . ĠUse Ġof Ġthis Ġsource Ġcode Ġis Ġgoverned Ġby Ġthe ĠApache Ġ 2 . 0 Ġlicense Ġthat Ġcan Ġbe Ġfound Ġin Ġthe ĠLICENSE Ġfile . Ċ package Ġcom . intellij . space . vcs . review . details . diff Ċ Ċ import Ġcom . intellij . diff . Frame Diff Tool Ċ import Ġcom . intellij . diff . tools . fragment ed . Unified Diff Viewer Ċ import Ġcom . intellij . diff . tools . simple . Simple On es ide Diff Viewer Ċ import Ġcom . intellij . diff . tools . util . side . Tw os ide Text Diff Viewer Ċ import Ġcom . intellij . diff . util . Line Range Ċ import Ġcom . intellij . diff . util . Side Ċ import Ġcom . intellij . openapi . Disposable Ċ import Ġcom . intellij . openapi . action System . An Action Ċ import Ġcom . intellij . openapi . action System . An ActionEvent Ċ import Ġcom . intellij . openapi . editor . ex . Editor Ex Ċ import Ġcom . intellij . openapi . editor . impl . Editor Impl Ċ import Ġcom . intellij . openapi . project . D umb Aware Action Ċ import Ġcom . intellij . openapi . util . Dis poser Ċ import Ġcom . intellij . openapi . util . N ls Actions Ċ import Ġcom . intellij . openapi . util . component 1 Ċ import Ġcom . intellij . openapi . util . component 2 Ċ import Ġcom . intellij . openapi . wm . Ide Focus Manager Ċ import Ġcom . intellij . space . chat . ui . Space Chat Avatar Type Ċ import Ġcom . intellij . space . chat . ui . Space Chat New Message With Avatar Component Ċ import Ġcom . intellij . space . messages . Space Bundle Ċ import Ġcom . intellij . util . ui . J BU I Ċ import Ġcom . intellij . util . ui . coder e view . comment . wrap Component Using Rounded Panel Ċ import Ġcom . intellij . util . ui . coder e view . diff . Add Comment G utter Icon Renderer Ċ import Ġcom . intellij . util . ui . coder e view . diff . Diff Editor G utter Icon Renderer Factory Ċ import Ġcom . intellij . util . ui . coder e view . diff . Editor Component In lay s Manager Ċ import Ġcom . intellij . util . ui . coder e view . diff . Editor Ranges Controller Ċ import Ġcom . intellij . util . ui . coder e view . timeline . comment . Submit table TextField Model Base Ċ import Ġlibraries . coroutines . extra . launch Ċ import Ġruntime . Ui Ċ import Ġjavax . swing . J Component Ċ Ċ internal Ġfun Ġcreate Handler ( viewer : ĠFrame Diff Tool . Diff Viewer , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcomment Submit ter : ĠSpace Review Comment Submit ter ): ĠSpace Diff Comments Handler Ġ= Ġwhen Ġ( viewer ) Ġ{ ĊĠ Ġis ĠTw os ide Text Diff Viewer Ġ-> ĠTwo Side Diff Comments Handler ( viewer , Ġcomment Submit ter ) ĊĠ Ġis ĠUn ified Diff Viewer Ġ-> ĠUn ified Diff Comments Handler ( viewer , Ġcomment Submit ter ) ĊĠ Ġis ĠSimple On es ide Diff Viewer Ġ-> ĠSimple On es ide Diff Comments Handler ( viewer , Ġcomment Submit ter ) ĊĠ Ġelse Ġ-> Ġerror (" Unsupported ĠDiff Viewer ") Ċ } Ċ Ċ internal Ġabstract Ġclass ĠSpace Diff Comments Handler Ġ{ ĊĠ Ġabstract Ġfun Ġinsert Left ( line : ĠInt , Ġcomponent : ĠJ Component ): ĠDis posable ? ĊĊĠ Ġabstract Ġfun Ġinsert Right ( line : ĠInt , Ġcomponent : ĠJ Component ): ĠDis posable ? ĊĊĠ Ġprotected Ġfun Ġinsert ( manager : ĠEditor Component In lay s Manager , Ġline : ĠInt , Ġcomponent : ĠJ Component ): ĠDis posable ? Ġ{ ĊĠĠĠ Ġreturn Ġmanager . insert After ( line , Ġcomponent ) ĊĠ Ġ} Ċ } Ċ Ċ private Ġclass ĠSimple On es ide Diff Comments Handler ( viewer : ĠSimple On es ide Diff Viewer , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcomment Submit ter : ĠSpace Review Comment Submit ter ) Ġ: ĠSpace Diff Comments Handler () Ġ{ ĊĠ Ġprivate Ġval Ġmanager Ġ= ĠEditor Component In lay s Manager ( viewer . editor Ġas ĠEditor Impl ) ĊĊĠ Ġinit Ġ{ ĊĠĠĠ Ġval Ġfactory Ġ= ĠSpace Diff Editor G utter Icon Renderer Factory ( manager , Ġcomment Submit ter ) Ġ{ Ġviewer . side Ġto Ġit Ġ} ĊĠĠĠ ĠSpace Editor Ranges Controller ( factory , Ġviewer . editor ) ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġinsert Left ( line : ĠInt , Ġcomponent : ĠJ Component ): ĠDis posable ? Ġ= Ġinsert ( manager , Ġline , Ġcomponent ) ĊĊĠ Ġoverride Ġfun Ġinsert Right ( line : ĠInt , Ġcomponent : ĠJ Component ): ĠDis posable ? Ġ= Ġinsert Left ( line , Ġcomponent ) Ċ } Ċ Ċ private Ġclass ĠTwo Side Diff Comments Handler ( viewer : ĠTw os ide Text Diff Viewer , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcomment Submit ter : ĠSpace Review Comment Submit ter ) Ġ: ĠSpace Diff Comments Handler () Ġ{ ĊĠ Ġprivate Ġval Ġleft Manager Ġ= ĠEditor Component In lay s Manager ( viewer . editor 1 Ġas ĠEditor Impl ) ĊĠ Ġprivate Ġval Ġright Manager Ġ= ĠEditor Component In lay s Manager ( viewer . editor 2 Ġas ĠEditor Impl ) ĊĊĠ Ġinit Ġ{ ĊĠĠĠ Ġval Ġleft Factory Ġ= ĠSpace Diff Editor G utter Icon Renderer Factory ( left Manager , Ġcomment Submit ter ) Ġ{ Ġline Ġ-> ĠSide . LEFT Ġto Ġline Ġ} ĊĠĠĠ ĠSpace Editor Ranges Controller ( left Factory , Ġviewer . editor 1 ) ĊĠĠĠ Ġval Ġright Factory Ġ= ĠSpace Diff Editor G utter Icon Renderer Factory ( right Manager , Ġcomment Submit ter ) Ġ{ Ġline Ġ-> ĠSide . RIGHT Ġto Ġline Ġ} ĊĠĠĠ ĠSpace Editor Ranges Controller ( right Factory , Ġviewer . editor 2 ) ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġinsert Left ( line : ĠInt , Ġcomponent : ĠJ Component ): ĠDis posable ? Ġ= Ġinsert ( left Manager , Ġline , Ġcomponent ) ĊĊĠ Ġoverride Ġfun Ġinsert Right ( line : ĠInt , Ġcomponent : ĠJ Component ): ĠDis posable ? Ġ= Ġinsert ( right Manager , Ġline , Ġcomponent ) Ċ } Ċ Ċ private Ġclass ĠUn ified Diff Comments Handler ( private Ġval Ġviewer : ĠUn ified Diff Viewer , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcomment Submit ter : ĠSpace Review Comment Submit ter ) Ġ: ĠSpace Diff Comments Handler () Ġ{ ĊĠ Ġprivate Ġval Ġmanager Ġ= ĠEditor Component In lay s Manager ( viewer . editor Ġas ĠEditor Impl ) ĊĊĠ Ġinit Ġ{ ĊĠĠĠ Ġval Ġfactory Ġ= ĠSpace Diff Editor G utter Icon Renderer Factory ( manager , Ġcomment Submit ter ) Ġ{ Ġfile Line Ġ-> ĊĠĠĠĠĠ Ġval Ġ( indices , Ġside ) Ġ= Ġviewer . transfer Line From On es ide ( file Line ) ĊĠĠĠĠĠ Ġval Ġline Ġ= Ġside . select ( indices ). take If Ġ{ Ġit Ġ>= Ġ 0 Ġ} Ġ?: Ġreturn @ Space Diff Editor G utter Icon Renderer Factory Ġnull ĊĊĠĠĠĠĠ Ġside Ġto Ġline ĊĠĠĠ Ġ} ĊĠĠĠ ĠSpace Editor Ranges Controller ( factory , Ġviewer . editor ) ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġinsert Left ( line : ĠInt , Ġcomponent : ĠJ Component ): ĠDis posable ? Ġ{ ĊĠĠĠ Ġval Ġnew Line Ġ= Ġviewer . transfer Line To On es ide ( Side . LEFT , Ġline ) ĊĠĠĠ Ġreturn Ġinsert ( manager , Ġnew Line , Ġcomponent ) ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġinsert Right ( line : ĠInt , Ġcomponent : ĠJ Component ): ĠDis posable ? Ġ{ ĊĠĠĠ Ġval Ġnew Line Ġ= Ġviewer . transfer Line To On es ide ( Side . RIGHT , Ġline ) ĊĠĠĠ Ġreturn Ġinsert ( manager , Ġnew Line , Ġcomponent ) ĊĠ Ġ} Ċ } Ċ Ċ internal Ġclass ĠSpace Diff Editor G utter Icon Renderer Factory ( ĊĠ Ġprivate Ġval Ġin lay s Manager : ĠEditor Component In lay s Manager , ĊĠ Ġprivate Ġval Ġcomment Submit ter : ĠSpace Review Comment Submit ter , ĊĠ Ġprivate Ġval Ġline Location Calculator : Ġ( Int ) Ġ-> ĠPair < Side , ĠInt >? Ċ ) Ġ: ĠDiff Editor G utter Icon Renderer Factory Ġ{ ĊĊĠ Ġoverride Ġfun Ġcreate Comment Renderer ( line : ĠInt ): ĠAdd Comment G utter Icon Renderer Ġ= ĠCreate Comment G utter Renderer ( line ) ĊĊĠ Ġprivate Ġinner Ġclass ĠCreate Comment G utter Renderer ( override Ġval Ġline : ĠInt ) Ġ: ĠAdd Comment G utter Icon Renderer () Ġ{ ĊĠĠĠ Ġprivate Ġvar Ġin lay : ĠComponent With Disposable ? Ġ= Ġnull ĊĊĠĠĠ Ġoverride Ġfun Ġdispose In lay () Ġ{ ĊĠĠĠĠĠ Ġin lay ?. let Ġ{ ĠDis poser . dispose ( it . dis posable ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġget Click Action (): ĠAn Action Ġ{ ĊĠĠĠĠĠ Ġreturn ĠIn lay Action ({ ĠSpace Bundle . message (" action . comment . line . text ") Ġ}, Ġline ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġinner Ġclass ĠIn lay Action ( val Ġaction Name : Ġ() Ġ-> ĠString , Ġprivate Ġval Ġeditor Line : ĠInt ) Ġ: ĠD umb Aware Action ( action Name ) Ġ{ ĊĠĠĠĠĠ Ġoverride Ġfun ĠactionPerformed ( e : ĠAn ActionEvent ) Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( in lay ?. let Ġ{ Ġfocus Panel ( it . component ) Ġ} Ġ!= Ġnull ) Ġreturn ĊĊĠĠĠĠĠĠĠ Ġval Ġ( side , Ġline ) Ġ= Ġline Location Calculator ( editor Line ) Ġ?: Ġreturn ĊĊĠĠĠĠĠĠĠ Ġval Ġhide Callback Ġ= Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġin lay ?. let Ġ{ ĠDis poser . dispose ( it . dis posable ) Ġ} ĊĠĠĠĠĠĠĠĠĠ Ġin lay Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġval Ġcomponent Ġ= Ġcreate Component ( side , Ġline , Ġhide Callback , Ġaction Name ()) ĊĠĠĠĠĠĠĠ Ġval Ġdis posable Ġ= Ġin lay s Manager . insert After ( editor Line , Ġcomponent ) Ġ?: Ġreturn ĊĠĠĠĠĠĠĠ Ġfocus Panel ( component ) ĊĠĠĠĠĠĠĠ Ġin lay Ġ= ĠComponent With Disposable ( component , Ġdis posable ) ĊĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠ Ġfun Ġcreate Component ( side : ĠSide , Ġline : ĠInt , Ġhide Callback : Ġ() Ġ-> ĠUnit , Ġ@ N ls Actions . Action Text Ġaction Name : ĠString ): ĠJ Component Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġmodel Ġ= Ġobject Ġ: ĠSubmit table TextField Model Base ("") Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġoverride Ġfun Ġsubmit () Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlaunch ( comment Submit ter . lifetime , ĠUi ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġis Busy Ġ= Ġtrue ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcomment Submit ter . submit Comment ( side , Ġline , Ġdocument . text ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġhide Callback () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcatch Ġ( e : ĠException ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġerror Ġ= Ġe ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġis Busy Ġ= Ġfalse ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġcomponent Ġ= ĠSpace Chat New Message With Avatar Component ( comment Submit ter . lifetime , ĠSpace Chat Avatar Type . THREAD , Ġmodel , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġhide Callback ). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġborder Ġ= ĠJ BU I . B orders . empty ( 1 0 ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġreturn Ġwrap Component Using Rounded Panel ( component ). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġborder Ġ= ĠJ BU I . B orders . empty ( 2 , Ġ 0 ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} Ċ } Ċ Ċ internal Ġdata Ġclass ĠComponent With Disposable ( val Ġcomponent : ĠJ Component , Ġval Ġdis posable : ĠDis posable ) Ċ Ċ internal Ġclass ĠSpace Editor Ranges Controller ( ĊĠ Ġfactory : ĠSpace Diff Editor G utter Icon Renderer Factory , ĊĠ Ġeditor : ĠEditor Ex Ċ ) Ġ: ĠEditor Ranges Controller ( factory , Ġeditor ) Ġ{ ĊĠ Ġinit Ġ{ ĊĠĠĠ Ġ// Ġall Ġlines Ġare Ġcomment able Ġin ĠSpace Ġreview ĊĠĠĠ Ġmark Comment able Lines ( Line Range ( 0 , Ġeditor . document . line Count )) ĊĠ Ġ} Ċ } Ċ Ċ private Ġfun Ġfocus Panel ( panel : ĠJ Component ) Ġ{ ĊĠ Ġval Ġfocus Manager Ġ= ĠIde Focus Manager . find Instance By Component ( panel ) ĊĠ Ġval Ġto Focus Ġ= Ġfocus Manager . get Focus Target For ( panel ) Ġ?: Ġreturn ĊĠ Ġfocus Manager . do When Focus Set tles Down Ġ{ Ġfocus Manager . request Focus ( to Focus , Ġtrue ) Ġ} Ċ } ĊĊ