// ĠCopyright Ġ 2 0 0 0 - 2 0 2 1 ĠJetBrains Ġs . r . o . Ġand Ġcontributors . ĠUse Ġof Ġthis Ġsource Ġcode Ġis Ġgoverned Ġby Ġthe ĠApache Ġ 2 . 0 Ġlicense Ġthat Ġcan Ġbe Ġfound Ġin Ġthe ĠLICENSE Ġfile . Ċ Ċ package Ġorg . jetbrains . kotlin . idea . de compiler . navigation Ċ Ċ import Ġcom . intellij . openapi . roots . Library Order Entry Ċ import Ġcom . intellij . openapi . roots . Module Root Manager Ċ import Ġcom . intellij . openapi . roots . Order Root Type Ċ import Ġcom . intellij . openapi . vfs . Virtual FileManager Ċ import Ġcom . intellij . psi . Psi Element Ċ import Ġorg . jetbrains . kotlin . idea . test . Kotlin Light Code Insight Fixture TestCase Ċ import Ġorg . jetbrains . kotlin . idea . test . Mock Library Facility Ċ Ċ abstract Ġclass ĠAbstract Navigate From Library Sources Test Ġ: ĠKotlin Light Code Insight Fixture TestCase () Ġ{ ĊĠĠĠ Ġprotected Ġfun Ġnavigation Element For Reference In Library Source ( filePath : ĠString , Ġreference Text : ĠString ): ĠPsi Element Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġlibrary Order Entry Ġ= ĠModule Root Manager . getInstance ( module ). order Entries ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. first Ġ{ Ġit Ġis ĠLibrary Order Entry Ġ&& Ġit . library Name Ġ== ĠMock Library Facility . MOCK _ LIBRARY _ NAME Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġlib Sources Root Ġ= Ġlibrary Order Entry . get Urls ( Order Root Type . SOURCES )[ 0 ] ĊĠĠĠĠĠĠĠ Ġval Ġlib Url Ġ= Ġ"$ lib Sources Root /$ filePath " ĊĠĠĠĠĠĠĠ Ġval Ġvirtual File Ġ= ĠVirtual FileManager . getInstance (). refresh And Find File By Url ( lib Url ) Ġ?: Ġerror (" Can 't Ġfind Ġlibrary : Ġ$ lib Url ") ĊĠĠĠĠĠĠĠ Ġval Ġpsi File Ġ= Ġpsi Manager . find File ( virtual File ) Ġ?: Ġerror (" Can 't Ġfind ĠP SI Ġfile Ġfor Ġ$ virtual File ") ĊĠĠĠĠĠĠĠ Ġval ĠindexOf Ġ= Ġpsi File . text . indexOf ( reference Text ) ĊĠĠĠĠĠĠĠ Ġval Ġreference Ġ= Ġpsi File . find Reference At ( indexOf ) Ġ?: Ġerror (" Can 't Ġfind Ġreference Ġat Ġindex Ġ$ indexOf ") ĊĠĠĠĠĠĠĠ Ġval Ġresolved Element Ġ= Ġreference . resolve () Ġ?: Ġerror (" Can 't Ġresolve Ġreference ") ĊĠĠĠĠĠĠĠ Ġreturn Ġresolved Element . navigation Element Ġ?: Ġerror (" Can 't Ġget Ġnavigation Ġelement ") ĊĠĠĠ Ġ} Ċ } Ċ