// Ġ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 . java . code Insight . daemon . problems Ċ Ċ import Ġcom . intellij . openapi . command . Write Command Action Ċ import Ġcom . intellij . openapi . command . undo . Undo Manager Ċ import Ġcom . intellij . openapi . editor . Editor Ċ import Ġcom . intellij . openapi . file Editor . File Editor Manager Ċ import Ġcom . intellij . openapi . file Editor . ex . File Editor Provider Manager Ċ import Ġcom . intellij . openapi . file Editor . impl . File Editor ManagerImpl Ċ import Ġcom . intellij . openapi . file Editor . impl . File Editor Provider ManagerImpl Ċ import Ġcom . intellij . openapi . file Editor . impl . text . Text Editor Impl Ċ import Ġcom . intellij . openapi . wm . Ide Focus Manager Ċ import Ġcom . intellij . psi . Java Psi Facade Ċ import Ġcom . intellij . psi . Psi Class Ċ import Ġcom . intellij . psi . Psi Java Code Reference Element Ċ import Ġcom . intellij . test Framework . fixtures . impl . Code Insight TestFixture Impl Ċ import Ġcom . intellij . test Framework . register Component Instance Ċ import Ġcom . intellij . ui . dock ing . Dock Manager Ċ import Ġcom . intellij . util . Array Util Rt Ċ import Ġjavax . swing . Swing Constants Ċ Ċ internal Ġclass ĠSplit Editor Problems Test Ġ: ĠProject Problems View Test () Ġ{ ĊĊĠ Ġprivate Ġvar Ġmy Manager : ĠFile Editor ManagerImpl ? Ġ= Ġnull ĊĊĠ Ġoverride Ġfun ĠsetUp () Ġ{ ĊĠĠĠ Ġsuper . setUp () ĊĠĠĠ Ġmy Manager Ġ= ĠFile Editor ManagerImpl ( project ). also Ġ{ Ġit . init Dock able Content Factory () Ġ} ĊĠĠĠ Ġproject . register Component Instance ( File Editor Manager :: class . java , Ġmy Manager !! , Ġtest Root Disposable ) ĊĠĠĠ Ġ( File Editor Provider Manager . getInstance () Ġas ĠFile Editor Provider ManagerImpl ). clear Selected Providers () ĊĠ Ġ} ĊĊĠ Ġfun Ġtest Class Rename In Two Detached Windows () Ġ{ ĊĠĠĠ Ġval Ġparent Class Ġ= Ġmy Fixture . addClass (""" ĊĠĠĠĠĠ Ġpackage Ġbar ; ĊĠĠĠĠĠĠĊĠĠĠĠĠ Ġpublic Ġclass ĠParent 1 Ġ{ ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ""" . trim Indent ()) ĊĠĠĠ Ġval Ġchild Class Ġ= Ġmy Fixture . addClass (""" ĊĠĠĠĠĠ Ġpackage Ġfoo ; ĊĠĠĠĠĠĠĊĠĠĠĠĠ Ġimport Ġbar . Parent 1 ; ĊĊĠĠĠĠĠ Ġpublic Ġfinal Ġclass ĠChild Ġextends ĠParent 1 Ġ{ ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ""" . trim Indent ()) ĊĊĠĠĠ Ġval Ġeditor Manager Ġ= Ġmy Manager !! ĊĠĠĠ Ġeditor Manager . open File In New Window ( child Class . containing File . virtual File ). first [ 0 ] ĊĠĠĠ Ġval Ġparent Editor Ġ= Ġ( editor Manager . open File In New Window ( parent Class . containing File . virtual File ). first [ 0 ] Ġas ĠText Editor Impl ). editor ĊĠĠĠ Ġre highlight ( parent Class , Ġparent Editor ) ĊĊĠĠĠ ĠWrite Command Action . run Write Command Action ( project ) Ġ{ ĊĠĠĠĠĠ Ġval Ġfactory Ġ= ĠJava Psi Facade . getInstance ( project ). element Factory ĊĠĠĠĠĠ Ġparent Class . name Identifier ?. replace ( factory . create Identifier (" Parent ")) ĊĠĠĠ Ġ} ĊĠĠĠ Ġre highlight ( parent Class , Ġparent Editor ) ĊĠĠĠ Ġassert Size ( 2 , Ġget Problems ( parent Editor )) ĊĊĠĠĠ ĠDock Manager . getInstance ( project ). containers . forEach Ġ{ Ġit . close All () Ġ} ĊĠ Ġ} ĊĊĠ Ġfun Ġtest Rename Class Change Usage And Undo All In Split Editor () Ġ{ ĊĠĠĠ Ġval Ġparent Class Ġ= Ġmy Fixture . addClass (""" ĊĠĠĠĠĠ Ġpackage Ġbar ; ĊĠĠĠĠĠĠĊĠĠĠĠĠ Ġpublic Ġclass ĠParent 1 Ġ{ ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ""" . trim Indent ()) ĊĠĠĠ Ġval Ġchild Class Ġ= Ġmy Fixture . addClass (""" ĊĠĠĠĠĠ Ġpackage Ġfoo ; ĊĠĠĠĠĠĠĊĠĠĠĠĠ Ġimport Ġbar . Parent 1 ; ĊĊĠĠĠĠĠ Ġpublic Ġfinal Ġclass ĠChild Ġextends ĠParent 1 Ġ{ ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ""" . trim Indent ()) ĊĊĠĠĠ Ġ// Ġopen Ġparent Ġclass Ġand Ġre highlight ĊĠĠĠ Ġval Ġeditor Manager Ġ= Ġmy Manager !! ĊĠĠĠ Ġval Ġparent Text Editor Ġ= Ġeditor Manager . open File ( parent Class . containing File . virtual File , Ġtrue )[ 0 ] Ġas ĠText Editor Impl ĊĠĠĠ Ġval Ġparent Editor Ġ= Ġparent Text Editor . editor ĊĠĠĠ Ġre highlight ( parent Class , Ġparent Editor ) ĊĠĠĠ Ġassert Empty ( get Problems ( parent Editor )) ĊĊĠĠĠ Ġ// Ġopen Ġchild Ġclass Ġin Ġhorizontal Ġsplit , Ġfocus Ġstays Ġin Ġparent Ġeditor ĊĠĠĠ Ġval Ġcurrent Window Ġ= Ġeditor Manager . current Window ĊĠĠĠ Ġeditor Manager . create Splitter ( Swing Constants . HORIZONTAL , Ġcurrent Window ) ĊĠĠĠ Ġval Ġnext Window Ġ= Ġeditor Manager . getNext Window ( current Window ) ĊĠĠĠ Ġval Ġchild Editor Ġ= Ġeditor Manager . open File With Providers ( child Class . containing File . virtual File , Ġfalse , Ġnext Window ). first [ 0 ] ĊĊĠĠĠ Ġ// Ġrename Ġparent , Ġcheck Ġfor Ġerrors ĊĠĠĠ ĠWrite Command Action . run Write Command Action ( project ) Ġ{ ĊĠĠĠĠĠ Ġval Ġfactory Ġ= ĠJava Psi Facade . getInstance ( project ). element Factory ĊĠĠĠĠĠ Ġparent Class . name Identifier ?. replace ( factory . create Identifier (" Parent ")) ĊĠĠĠ Ġ} ĊĠĠĠ Ġre highlight ( parent Class , Ġparent Editor ) ĊĠĠĠ Ġassert Size ( 2 , Ġget Problems ( parent Editor )) ĊĊĠĠĠ Ġ// Ġselect Ġchild Ġeditor , Ġremove Ġparent Ġfrom Ġchild Ġextends Ġlist , Ġcheck Ġthat Ġnumber Ġof Ġproblems Ġchanged ĊĠĠĠ ĠIde Focus Manager . getInstance ( project ). request Focus ( child Editor . component , Ġtrue ) ĊĠĠĠ ĠWrite Command Action . run Write Command Action ( project ) Ġ{ ĊĠĠĠĠĠ Ġval Ġfactory Ġ= ĠJava Psi Facade . getInstance ( project ). element Factory ĊĠĠĠĠĠ Ġchild Class . extends List ?. replace ( factory . create Reference List ( Psi Java Code Reference Element . EMPTY _ ARRAY )) ĊĠĠĠ Ġ} ĊĠĠĠ Ġre highlight ( child Class , Ġparent Editor ) ĊĠĠĠ Ġassert Size ( 1 , Ġget Problems ( parent Editor )) ĊĊĠĠĠ Ġ// Ġundo Ġchild Ġchange ĊĠĠĠ ĠWrite Command Action . run Write Command Action ( project ) Ġ{ ĊĠĠĠĠĠ ĠUndo Manager . getInstance ( project ). undo ( child Editor ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġre highlight ( child Class , Ġparent Editor ) ĊĠĠĠ Ġassert Size ( 2 , Ġget Problems ( parent Editor )) ĊĊĠĠĠ Ġ// Ġundo Ġparent Ġrename , Ġcheck Ġthat Ġproblems Ġare Ġgone ĊĠĠĠ ĠIde Focus Manager . getInstance ( project ). request Focus ( parent Editor . component , Ġtrue ) ĊĠĠĠ ĠWrite Command Action . run Write Command Action ( project ) Ġ{ ĊĠĠĠĠĠ ĠUndo Manager . getInstance ( project ). undo ( parent Text Editor ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġre highlight ( child Class , Ġparent Editor ) ĊĠĠĠ Ġassert Empty ( get Problems ( parent Editor )) ĊĠ Ġ} ĊĊĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠ Ġprivate Ġfun Ġre highlight ( psi Class : ĠPsi Class , Ġeditor : ĠEditor ) Ġ= ĊĠĠĠĠĠ ĠCode Insight TestFixture Impl . instantiate And Run ( psi Class . containing File , Ġeditor , ĠArray Util Rt . EMPTY _ INT _ ARRAY , Ġfalse ) ĊĠ Ġ} Ċ }