// Ġ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 . gradle . service . resolve Ċ Ċ import Ġcom . intellij . patterns . Psi Java Patterns . psi Element Ċ import Ġcom . intellij . psi .* Ċ import Ġcom . intellij . psi . scope . Psi Scope Processor Ċ import Ġgro ovy . lang . Closure Ċ import Ġorg . jetbrains . plugins . gradle . service . resolve . Gradle Common ClassNames .* Ċ import Ġorg . jetbrains . plugins . groovy . lang . psi . Gro ovy File Ċ import Ġorg . jetbrains . plugins . groovy . lang . psi . api . statements . blocks . Gr C losable Block Ċ import Ġorg . jetbrains . plugins . groovy . lang . psi . api . statements . expressions . Gr MethodCall Ċ import Ġorg . jetbrains . plugins . groovy . lang . psi . api . statements . expressions . path . Gr MethodCall Expression Ċ import Ġorg . jetbrains . plugins . groovy . lang . psi . impl . Gro ovy Psi Manager Ċ import Ġorg . jetbrains . plugins . groovy . lang . psi . impl . statements . expressions . Types Util . create Type Ċ import Ġorg . jetbrains . plugins . groovy . lang . psi . impl . synt hetic . Gr Light Method Builder Ċ import Ġorg . jetbrains . plugins . groovy . lang . psi . patterns . Gro ovy Closure Pattern Ċ import Ġorg . jetbrains . plugins . groovy . lang . psi . patterns . groovy Closure Ċ import Ġorg . jetbrains . plugins . groovy . lang . psi . patterns . psi Method Ċ import Ġorg . jetbrains . plugins . groovy . lang . psi . util . Gro ovy Common ClassNames . GRO OV Y _ LANG _ CLO S URE Ċ import Ġorg . jetbrains . plugins . groovy . lang . resolve . Resolve Util Ċ import Ġorg . jetbrains . plugins . groovy . lang . resolve . deleg ates To . DE LEG ATES _ TO _ KEY Ċ import Ġorg . jetbrains . plugins . groovy . lang . resolve . deleg ates To . Deleg ates To Info Ċ Ċ /** Ċ Ġ* Ġ@ author ĠV lad isl av . S or ok a Ċ Ġ* Ċ Ġ* Ġ@ since Ġ 1 1 / 2 4 / 2 0 1 6 Ċ Ġ*/ Ċ class ĠGradle Misc Contributor Ġ: ĠGradle Method Context Contributor Ġ{ ĊĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠ Ġval Ġuse JUnit Closure : ĠGro ovy Closure Pattern Ġ= Ġgro ovy Closure (). in Method ( psi Method ( GRAD LE _ API _ TASK S _ TEST ING _ TEST , Ġ" use JUnit ")) ĊĠĠĠ Ġval Ġtest Logging Closure : ĠGro ovy Closure Pattern Ġ= Ġgro ovy Closure (). in Method ( psi Method ( GRAD LE _ API _ TASK S _ TEST ING _ TEST , Ġ" test Logging ")) ĊĠĠĠ Ġval Ġdownload Closure : ĠGro ovy Closure Pattern Ġ= Ġgro ovy Closure (). in Method ( psi Method ( GRAD LE _ API _ PROJECT , Ġ" download ")) ĊĠĠĠ Ġval Ġdomain Collection WithType Closure : ĠGro ovy Closure Pattern Ġ= Ġgro ovy Closure (). in Method ( psi Method ( GRAD LE _ API _ DOMAIN _ OBJECT _ COLLECTION , Ġ" with Type ")) ĊĠĠĠ Ġval Ġmanifest Closure : ĠGro ovy Closure Pattern Ġ= Ġgro ovy Closure (). in Method ( psi Method ( GRAD LE _ JVM _ TASK S _ JAR , Ġ" manifest ")) ĊĠĠĠ Ġ// ĠĠĠ Ġval Ġpublications Closure Ġ= Ġgro ovy Closure (). in Method ( psi Method (" org . gradle . api . publish . Publishing Extension ", Ġ" publications ")) ĊĠĠĠ Ġconst Ġval Ġdownload Spec F qn : ĠString Ġ= Ġ" de . under couch . gradle . tasks . download . Download Spec " ĊĠĠĠ Ġconst Ġval Ġplugin Dependencies Spec F qn : ĠString Ġ= Ġ" org . gradle . plugin . use . Plugin Dependencies Spec " ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġget Deleg ates To Info ( closure : ĠGr C losable Block ): ĠDeleg ates To Info ? Ġ{ ĊĠĠĠ Ġif Ġ( use JUnit Closure . accept s ( closure )) Ġ{ ĊĠĠĠĠĠ Ġreturn ĠDeleg ates To Info ( create Type ( GRAD LE _ API _ J UNIT _ OPTIONS , Ġclosure ), ĠClosure . DE LEG ATE _ FIRST ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġif Ġ( test Logging Closure . accept s ( closure )) Ġ{ ĊĠĠĠĠĠ Ġreturn ĠDeleg ates To Info ( create Type ( GRAD LE _ API _ TEST _ LOG GING _ CONTAINER , Ġclosure ), ĠClosure . DE LEG ATE _ FIRST ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġif Ġ( download Closure . accept s ( closure )) Ġ{ ĊĠĠĠĠĠ Ġreturn ĠDeleg ates To Info ( create Type ( download Spec F qn , Ġclosure ), ĠClosure . DE LEG ATE _ FIRST ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġif Ġ( manifest Closure . accept s ( closure )) Ġ{ ĊĠĠĠĠĠ Ġreturn ĠDeleg ates To Info ( create Type ( GRAD LE _ API _ JAVA _ ARCH IV ES _ MAN IFEST , Ġclosure ), ĠClosure . DE LEG ATE _ FIRST ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġ// ĠĠĠ Ġif Ġ( publications Closure . accept s ( closure )) Ġ{ ĊĠĠĠ Ġ// ĠĠĠĠĠ Ġreturn ĠDeleg ates To Info ( Types Util . create Type (" org . gradle . api . publish . Publication Container ", Ġclosure ), ĠClosure . DE LEG ATE _ FIRST ) ĊĠĠĠ Ġ// ĠĠĠ Ġ} ĊĊĠĠĠ Ġval Ġparent Ġ= Ġclosure . parent ĊĠĠĠ Ġif Ġ( domain Collection WithType Closure . accept s ( closure )) Ġ{ ĊĠĠĠĠĠ Ġif Ġ( parent Ġis ĠGr MethodCall Expression ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġpsi Element Ġ= Ġparent . argument List . all Arguments . single OrNull ()?. reference ?. resolve () ĊĠĠĠĠĠĠĠ Ġif Ġ( psi Element Ġis ĠPsi Class ) Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġreturn ĠDeleg ates To Info ( create Type ( psi Element . qualified Name , Ġclosure ), ĠClosure . DE LEG ATE _ FIRST ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// Ġresolve Ġclosure Ġtype Ġto Ġdelegate Ġbased Ġon Ġreturn Ġmethod Ġtype , Ġe . g . ĊĠĠĠ Ġ// ĠFlat Directory Artifact Repository Ġflat Dir ( Closure Ġconfigure Closure ) ĊĠĠĠ Ġif Ġ( parent Ġis ĠGr MethodCall ) Ġ{ ĊĠĠĠĠĠ Ġval Ġpsi Type Ġ= Ġparent . inv oked Expression . type ĊĠĠĠĠĠ Ġif Ġ( psi Type Ġ!= Ġnull Ġ&& Ġpsi Type Ġ!= ĠPsi Type . VOID ) Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠDeleg ates To Info ( psi Type , ĠClosure . DE LEG ATE _ FIRST ) ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠĠĠ Ġreturn Ġnull ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġprocess ( method Call Info : ĠMutable List < String >, Ġprocessor : ĠPsi Scope Processor , Ġstate : ĠResolve State , Ġplace : ĠPsi Element ): ĠBoolean Ġ{ ĊĊĠĠĠ Ġval Ġclass Hint Ġ= Ġprocessor . get Hint ( com . intellij . psi . scope . Element Class Hint . KEY ) ĊĠĠĠ Ġval Ġshould Process Methods Ġ= ĠResolve Util . should Process Methods ( class Hint ) ĊĠĠĠ Ġval Ġgro ovy Psi Manager Ġ= ĠGro ovy Psi Manager . getInstance ( place . project ) ĊĠĠĠ Ġval Ġresolve Scope Ġ= Ġplace . resolve Scope ĊĊĠĠĠ Ġif Ġ( should Process Methods Ġ&& Ġplace . parent ?. parent Ġis ĠGro ovy File Ġ&& Ġplace . text Ġ== Ġ" plugins ") Ġ{ ĊĠĠĠĠĠ Ġval Ġplugins Dependencies Class Ġ= ĠJava Psi Facade . getInstance ( place . project ). find Class ( plugin Dependencies Spec F qn , Ġresolve Scope ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ?: Ġreturn Ġtrue ĊĠĠĠĠĠ Ġval Ġreturn Class Ġ= Ġgro ovy Psi Manager . create Type By FQ ClassName ( plugin Dependencies Spec F qn , Ġresolve Scope ) Ġ?: Ġreturn Ġtrue ĊĠĠĠĠĠ Ġval Ġmethod Builder Ġ= ĠGr Light Method Builder ( place . manager , Ġ" plugins "). apply Ġ{ ĊĠĠĠĠĠĠĠ Ġcontaining Class Ġ= Ġplugins Dependencies Class ĊĠĠĠĠĠĠĠ ĠreturnType Ġ= Ġreturn Class ĊĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġmethod Builder . add AndGet Parameter (" configuration ", ĠGRO OV Y _ LANG _ CLO S URE , Ġfalse ). put UserData ( DE LEG ATES _ TO _ KEY , Ġplugin Dependencies Spec F qn ) ĊĠĠĠĠĠ Ġplace . put UserData ( RESOL VED _ CODE , Ġtrue ) ĊĠĠĠĠĠ Ġif Ġ(! processor . execute ( method Builder , Ġstate )) Ġreturn Ġfalse ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġif Ġ( psi Element (). inside ( domain Collection WithType Closure ). accept s ( place )) Ġ{ ĊĊĠĠĠ Ġ} ĊĠĠĠ Ġreturn Ġtrue ĊĠ Ġ} Ċ } Ċ