// ĠCopyright Ġ 2 0 0 0 - 2 0 1 8 Ġ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 . dv cs . ui Ċ Ċ import Ġcom . intellij . dv cs . repo . Repository Ċ import Ġcom . intellij . dv cs . repo . V cs Repository Manager Ċ import Ġcom . intellij . openapi . project . Project Ċ import Ġcom . intellij . openapi . util . NotNull Lazy Key Ċ import Ġcom . intellij . openapi . vcs . changes . ui . Base Changes Grouping Policy Ċ import Ġcom . intellij . openapi . vcs . changes . ui . Changes Browser Node Ċ import Ġcom . intellij . openapi . vcs . changes . ui . Changes Grouping Policy Factory Ċ import Ġcom . intellij . openapi . vcs . changes . ui . Static FilePath Ċ import Ġcom . intellij . openapi . vcs . changes . ui . Tree Model Builder .* Ċ import Ġjavax . swing . tree . Default Tree Model Ċ Ċ class ĠRepository Changes Grouping Policy ( val Ġproject : ĠProject , Ġval Ġmodel : ĠDefault Tree Model ) Ġ: ĠBase Changes Grouping Policy () Ġ{ ĊĠ Ġprivate Ġval Ġrepository Manager Ġ= ĠV cs Repository Manager . getInstance ( project ) ĊĊĠ Ġoverride Ġfun ĠgetParent Node For ( node Path : ĠStatic FilePath , Ġsubtree Root : ĠChanges Browser Node < *> ): ĠChanges Browser Node < *> ? Ġ{ ĊĠĠĠ Ġval Ġfile Ġ= Ġresolve Virtual File ( node Path ) ĊĠĠĠ Ġval Ġnext Policy Parent Ġ= Ġnext Policy ?. getParent Node For ( node Path , Ġsubtree Root ) ĊĊĠĠĠ Ġfile ?. let Ġ{ Ġrepository Manager . getRepository For File ( it , Ġtrue ) Ġ} ?. let Ġ{ Ġrepository Ġ-> ĊĠĠĠĠĠ Ġval Ġgrand Parent Ġ= Ġnext Policy Parent Ġ?: Ġsubtree Root ĊĠĠĠĠĠ Ġval Ġcaching Root Ġ= Ġget Caching Root ( grand Parent , Ġsubtree Root ) ĊĊĠĠĠĠĠ ĠRE POSITORY _ CACHE . getValue ( caching Root )[ repository ]?. let Ġ{ Ġreturn Ġit Ġ} ĊĊĠĠĠĠĠ ĠRepository Changes Browser Node ( repository ). let Ġ{ ĊĠĠĠĠĠĠĠ Ġit . mark As Helper Node () ĊĊĠĠĠĠĠĠĠ Ġmodel . insert Node Into ( it , Ġgrand Parent , Ġgrand Parent . child Count ) ĊĊĠĠĠĠĠĠĠ ĠRE POSITORY _ CACHE . getValue ( caching Root )[ repository ] Ġ= Ġit ĊĠĠĠĠĠĠĠ ĠIS _ C ACH ING _ ROOT . set ( it , Ġtrue ) ĊĠĠĠĠĠĠĠ ĠDIRECTORY _ CACHE . getValue ( it )[ static From ( repository . root ). key ] Ġ= Ġit ĊĠĠĠĠĠĠĠ Ġreturn Ġit ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġreturn Ġnext Policy Parent ĊĠ Ġ} ĊĊĠ Ġclass ĠFactory ( val Ġproject : ĠProject ) Ġ: ĠChanges Grouping Policy Factory () Ġ{ ĊĠĠĠ Ġoverride Ġfun Ġcreate Grouping Policy ( model : ĠDefault Tree Model ) Ġ= ĠRepository Changes Grouping Policy ( project , Ġmodel ) ĊĠ Ġ} ĊĊĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠ Ġval ĠRE POSITORY _ CACHE Ġ= ĠNot Null Lazy Key . create < Mutable Map < Repository , ĠChanges Browser Node <* >>, ĠChanges Browser Node < *> >( ĊĠĠĠĠĠ Ġ" Changes Tree . Repository Cache ") Ġ{ Ġ_ Ġ-> Ġmutable Map Of () Ġ} ĊĊĠ Ġ} Ċ }