// Ġ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 Ġorg . jetbrains . plugins . groovy . lang . resolve . cache s Ċ Ċ import Ġcom . intellij . openapi . util . Key Ċ import Ġcom . intellij . psi . Psi Element Ċ import Ġcom . intellij . psi . Psi Named Element Ċ import Ġcom . intellij . psi . Resolve State Ċ import Ġcom . intellij . psi . scope . Element Class Hint Ċ import Ġcom . intellij . psi . scope . Psi Scope Processor Ċ import Ġcom . intellij . util . containers . Most ly Sing ular Multi Map Ċ import Ġorg . jetbrains . plugins . groovy . lang . resolve . Annotation Hint Ċ import Ġorg . jetbrains . plugins . groovy . lang . resolve . getName Ċ import Ġorg . jetbrains . plugins . groovy . lang . resolve . imports . imported Name Key Ċ import Ġorg . jetbrains . plugins . groovy . lang . resolve . sor ry Cannot K now Element Kind Ċ Ċ private Ġdata Ġclass ĠElement With State ( val Ġelement : ĠPsi Element , Ġval Ġstate : ĠResolve State ) Ċ Ċ class ĠFile Cache Builder Processor ( private Ġval Ġannotation Resolve : ĠBoolean ) Ġ: ĠPsi Scope Processor , ĠElement Class Hint , ĠAnnotation Hint Ġ{ ĊĊĠ Ġprivate Ġval Ġdeclarations Ġ= ĠMost ly Sing ular Multi Map < String , ĠElement With State >() ĊĊĠ Ġfun Ġbuild Cache (): ĠDeclaration Holder Ġ= ĠFile Declarations Cache ( declarations ) ĊĊĠ Ġoverride Ġfun Ġexecute ( element : ĠPsi Element , Ġstate : ĠResolve State ): ĠBoolean Ġ{ ĊĠĠĠ Ġval Ġnamed Element Ġ= Ġelement Ġas ? ĠPsi Named Element Ġ?: Ġreturn Ġtrue ĊĠĠĠ Ġval Ġname Ġ= Ġstate . get ( imported Name Key ) Ġ?: Ġnamed Element . name Ġ?: Ġreturn Ġtrue ĊĠĠĠ Ġdeclarations . add ( name , ĠElement With State ( element , Ġstate )) ĊĠĠĠ Ġreturn Ġtrue ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġ< T Ġ: ĠAny ?> Ġget Hint ( hint Key : ĠKey < T >): ĠT ? Ġ{ ĊĠĠĠ Ġ@ Suppress (" UN CHECK ED _ CAST ") ĊĠĠĠ Ġreturn Ġwhen Ġ( hint Key ) Ġ{ ĊĠĠĠĠĠ ĠAnnotation Hint . HINT _ KEY , ĊĠĠĠĠĠ ĠElement Class Hint . KEY Ġ-> Ġthis Ġas ĠT ĊĠĠĠĠĠ Ġelse Ġ-> Ġnull ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġis Annotation Resolve (): ĠBoolean Ġ= Ġannotation Resolve ĊĊĠ Ġoverride Ġfun Ġshould Process ( kind : ĠElement Class Hint . Declaration Kind ): ĠBoolean Ġ{ ĊĠĠĠ Ġreturn Ġ! annotation Resolve Ġ|| Ġkind Ġ=== ĠElement Class Hint . Declaration Kind . CLASS ĊĠ Ġ} Ċ } Ċ Ċ private Ġclass ĠFile Declarations Cache ( private Ġval Ġdeclarations : ĠMost ly Sing ular Multi Map < String , ĠElement With State >) Ġ: ĠDeclaration Holder Ġ{ ĊĊĠ Ġoverride Ġfun Ġprocess Declarations ( processor : ĠPsi Scope Processor , Ġstate : ĠResolve State , Ġplace : ĠPsi Element ): ĠBoolean Ġ{ ĊĠĠĠ Ġval ĠnewState Ġ= Ġstate . put ( sor ry Cannot K now Element Kind , Ġtrue ) ĊĠĠĠ Ġval Ġdeclaration Processor Ġ= Ġ{ Ġ( element , Ġcached State ): ĠElement With State Ġ-> ĊĠĠĠĠĠ Ġprocessor . execute ( element , ĠnewState . put All ( cached State )) ĊĠĠĠ Ġ} ĊĠĠĠ Ġval Ġname Ġ= Ġprocessor . getName ( state ) ĊĠĠĠ Ġreturn Ġif Ġ( name Ġ== Ġnull ) Ġ{ ĊĠĠĠĠĠ Ġdeclarations . process All Values ( declaration Processor ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġelse Ġ{ ĊĠĠĠĠĠ Ġdeclarations . process ForKey ( name , Ġdeclaration Processor ) ĊĠĠĠ Ġ} ĊĠ Ġ} Ċ } Ċ