/* Ċ Ġ* ĠCopyright Ġ 2 0 0 0 - 2 0 2 0 ĠJetBrains Ġs . r . o . Ġand Ġother Ġcontributors . ĠUse Ġof Ġthis Ġsource Ġcode Ġis Ġgoverned Ġby Ġthe ĠApache Ġ 2 . 0 Ġlicense Ġthat Ġcan Ġbe Ġfound Ġin Ġthe ĠLICENSE Ġfile . Ċ Ġ*/ Ċ Ċ package Ġcom . jetbrains . plugin verifier Ċ Ċ import Ġcom . jetbrains . plugin . structure . base . plugin . Plugin Problem Ċ import Ġcom . jetbrains . plugin . structure . classes . resolvers . Composite Resolver Ċ import Ġcom . jetbrains . plugin . structure . classes . resolvers . Resolver Ċ import Ġcom . jetbrains . plugin . structure . ide . Plugin Id And Version Ċ import Ġcom . jetbrains . plugin . structure . ide . util . Known Ide Packages Ċ import Ġcom . jetbrains . plugin . structure . intellij . classes . plugin . Ide Plugin Classes Locations Ċ import Ġcom . jetbrains . plugin . structure . intellij . plugin . Extension Point Ċ import Ġcom . jetbrains . plugin . structure . intellij . plugin . Ide Plugin Impl Ċ import Ġcom . jetbrains . plugin verifier . dependencies . Dependencies Graph Ċ import Ġcom . jetbrains . plugin verifier . d ym am ic . Dynamic Plugins Ċ import Ġcom . jetbrains . plugin verifier . filtering . External Build Classes Selector Ċ import Ġcom . jetbrains . plugin verifier . filtering . Main Classes Selector Ċ import Ġcom . jetbrains . plugin verifier . filtering . Problems Filter Ċ import Ġcom . jetbrains . plugin verifier . plugin . Plugin Details Ċ import Ġcom . jetbrains . plugin verifier . plugin . Plugin Details Cache Ċ import Ġcom . jetbrains . plugin verifier . results . problems . Compatibility Problem Ċ import Ġcom . jetbrains . plugin verifier . us ages . deprecated . Deprecated Method Over riding Processor Ċ import Ġcom . jetbrains . plugin verifier . us ages . experimental . Experimental Method Over riding Processor Ċ import Ġcom . jetbrains . plugin verifier . us ages . internal . Internal Method Over riding Processor Ċ import Ġcom . jetbrains . plugin verifier . us ages . non Extend able . Non Extend able Method Over riding Processor Ċ import Ġcom . jetbrains . plugin verifier . us ages . non Extend able . Non Extend able Type Inherited Processor Ċ import Ġcom . jetbrains . plugin verifier . ver ifiers . Byte code Verifier Ċ import Ġcom . jetbrains . plugin verifier . ver ifiers . Plugin Verification Context Ċ import Ġcom . jetbrains . plugin verifier . ver ifiers . Verification Context Ċ import Ġcom . jetbrains . plugin verifier . ver ifiers . filter . Class Filter Ċ import Ġcom . jetbrains . plugin verifier . ver ifiers . method . Method Over riding Verifier Ċ import Ġcom . jetbrains . plugin verifier . warnings .* Ċ Ċ /** Ċ Ġ* ĠPerforms Ġverification Ġspecified Ġby Ġ[ verification Descriptor ] Ġand Ġreturns Ġ[ Plugin Verification Result ]. Ċ Ġ*/ Ċ class ĠPlugin Verifier ( ĊĠ Ġval Ġverification Descriptor : ĠPlugin Verification Descriptor , ĊĠ Ġprivate Ġval Ġproblem Filters : ĠList < Problems Filter >, ĊĠ Ġprivate Ġval Ġplugin Details Cache : ĠPlugin Details Cache , ĊĠ Ġprivate Ġval Ġclass Filters : ĠList < Class Filter > Ċ ) Ġ{ ĊĊĠ Ġfun Ġload Plugin And Verify (): ĠPlugin Verification Result Ġ{ ĊĠĠĠ Ġplugin Details Cache . get Plugin Details Cache Entry ( verification Descriptor . checked Plugin ). use Ġ{ Ġcache Entry Ġ-> ĊĠĠĠĠĠ Ġreturn Ġwhen Ġ( cache Entry ) Ġ{ ĊĠĠĠĠĠĠĠ Ġis ĠPlugin Details Cache . Result . Invalid Plugin Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠ ĠPlugin Verification Result . Invalid Plugin ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverification Descriptor . checked Plugin , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverification Descriptor . to Target (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcache Entry . plugin Errors ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. filter Ġ{ Ġit . level Ġ== ĠPlugin Problem . Level . ERROR Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. map To ( hash Set Of ()) Ġ{ ĠPlugin Structure Error ( it ) Ġ} ĊĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġis ĠPlugin Details Cache . Result . File NotFound Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠ ĠPlugin Verification Result . NotFound ( verification Descriptor . checked Plugin , Ġverification Descriptor . to Target (), Ġcache Entry . reason ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġis ĠPlugin Details Cache . Result . Failed Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠ ĠPlugin Verification Result . Failed To Download ( verification Descriptor . checked Plugin , Ġverification Descriptor . to Target (), Ġcache Entry . reason ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġis ĠPlugin Details Cache . Result . Provided Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġverify ( cache Entry . plugin Details ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĊĠ Ġprivate Ġfun Ġverify ( plugin Details : ĠPlugin Details ): ĠPlugin Verification Result Ġ{ ĊĠĠĠ Ġverification Descriptor . class Resolver Provider . provide ( plugin Details ). use Ġ{ Ġ( plugin Resolver , Ġall Resolver , Ġdependencies Graph ) Ġ-> ĊĠĠĠĠĠ Ġval Ġexternal Classes Package Filter Ġ= Ġverification Descriptor . class Resolver Provider . provide External Classes Package Filter () ĊĊĠĠĠĠĠ Ġval Ġcontext Ġ= ĠPlugin Verification Context ( ĊĠĠĠĠĠĠĠ Ġplugin Details . ide Plugin , ĊĠĠĠĠĠĠĠ Ġverification Descriptor , ĊĠĠĠĠĠĠĠ Ġplugin Resolver , ĊĠĠĠĠĠĠĠ Ġall Resolver , ĊĠĠĠĠĠĠĠ Ġexternal Classes Package Filter , ĊĠĠĠĠĠĠĠ Ġdependencies Graph ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠ Ġplugin Details . plugin Warnings . forEach Ġ{ Ġcontext . register Plugin Structure Warning ( Plugin Structure Warning ( it )) Ġ} ĊĠĠĠĠĠ Ġcontext . check If Plugin Is Marked In compatible With This Ide () ĊĠĠĠĠĠ Ġcontext . find M ist aken ly Bund led Ide Classes ( plugin Resolver ) ĊĠĠĠĠĠ Ġcontext . find Dependencies Cycles ( dependencies Graph ) ĊĊĠĠĠĠĠ Ġval Ġclasses ToCheck Ġ= Ġselect Classes For Check ( plugin Details ) ĊĊĠĠĠĠĠ ĠByte code Verifier ( ĊĠĠĠĠĠĠĠ Ġclass Filters , ĊĠĠĠĠĠĠĠ ĠlistOf ( Non Extend able Type Inherited Processor ( context )), ĊĠĠĠĠĠĠĠ ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠ ĠMethod Over riding Verifier ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠExperimental Method Over riding Processor ( context ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠDeprecated Method Over riding Processor ( context ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠNon Extend able Method Over riding Processor ( context ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠInternal Method Over riding Processor ( context ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠ Ġ). verify ( classes ToCheck , Ġcontext ) Ġ{} ĊĊĠĠĠĠĠ Ġcontext . post Process Results () ĊĊĠĠĠĠĠ Ġval Ġ( report Problems , Ġignored Problems ) Ġ= Ġpartition Report And Ignored Problems ( context . compatibility Problems , Ġcontext ) ĊĊĠĠĠĠĠ Ġreturn Ġwith ( context ) Ġ{ ĊĠĠĠĠĠĠĠ ĠPlugin Verification Result . Verified ( ĊĠĠĠĠĠĠĠĠĠ Ġverification Descriptor . checked Plugin , ĊĠĠĠĠĠĠĠĠĠ Ġverification Descriptor . to Target (), ĊĠĠĠĠĠĠĠĠĠ Ġdependencies Graph , ĊĠĠĠĠĠĠĠĠĠ Ġreport Problems , ĊĠĠĠĠĠĠĠĠĠ Ġignored Problems , ĊĠĠĠĠĠĠĠĠĠ Ġcompatibility Warnings , ĊĠĠĠĠĠĠĠĠĠ Ġdeprecated Usage s , ĊĠĠĠĠĠĠĠĠĠ Ġexperimental Api Usage s , ĊĠĠĠĠĠĠĠĠĠ Ġinternal Api Usage s , ĊĠĠĠĠĠĠĠĠĠ Ġnon Extend able Api Usage s , ĊĠĠĠĠĠĠĠĠĠ Ġoverride Only Method Usage s , ĊĠĠĠĠĠĠĠĠĠ Ġplugin Structure Warnings , ĊĠĠĠĠĠĠĠĠĠ ĠDynamic Plugins . get Dynamic Plugin Status ( this ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġpartition Report And Ignored Problems ( ĊĠĠĠ Ġall Problems : ĠSet < Compatibility Problem >, ĊĠĠĠ Ġverification Context : ĠVerification Context ĊĠ Ġ): ĠPair < Set < Compatibility Problem >, ĠMap < Compatibility Problem , ĠString >> Ġ{ ĊĊĠĠĠ Ġval Ġreport Problems Ġ= Ġhash Set Of < Compatibility Problem >() ĊĠĠĠ Ġval Ġignored Problems Ġ= Ġhash Map Of < Compatibility Problem , ĠString >() ĊĊĠĠĠ Ġfor Ġ( problem Ġin Ġall Problems ) Ġ{ ĊĠĠĠĠĠ Ġval Ġignore Decision Ġ= Ġproblem Filters . as Sequence () ĊĠĠĠĠĠĠĠ Ġ. map Ġ{ Ġit . should Report Problem ( problem , Ġverification Context ) Ġ} ĊĠĠĠĠĠĠĠ Ġ. filter Is Instance < Problems Filter . Result . Ignore >() ĊĠĠĠĠĠĠĠ Ġ. first OrNull () ĊĊĠĠĠĠĠ Ġif Ġ( ignore Decision Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠ Ġignored Problems [ problem ] Ġ= Ġignore Decision . reason ĊĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠ Ġreport Problems Ġ+= Ġproblem ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġreturn Ġreport Problems Ġto Ġignored Problems ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun ĠPlugin Verification Context . check If Plugin Is Marked In compatible With This Ide () Ġ{ ĊĠĠĠ Ġif Ġ( verification Descriptor Ġis ĠPlugin Verification Descriptor . IDE ) Ġ{ ĊĠĠĠĠĠ Ġif Ġ( Plugin Id And Version ( verification Descriptor . checked Plugin . plugin Id , Ġverification Descriptor . checked Plugin . version ) Ġin Ġverification Descriptor . in compatible Plugins ) Ġ{ ĊĠĠĠĠĠĠĠ Ġregister Problem ( Plugin Is Marked In compatible Problem ( verification Descriptor . checked Plugin , Ġverification Descriptor . ide Version )) ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun ĠPlugin Verification Context . find Dependencies Cycles ( dependencies Graph : ĠDependencies Graph ) Ġ{ ĊĠĠĠ Ġval Ġcycles Ġ= Ġdependencies Graph . getAll Cycles () ĊĠĠĠ Ġfor Ġ( cycle Ġin Ġcycles ) Ġ{ ĊĠĠĠĠĠ Ġregister Compatibility Warning ( Dependencies Cycle Warning ( cycle )) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun ĠPlugin Verification Context . find M ist aken ly Bund led Ide Classes ( plugin Resolver : ĠResolver ) Ġ{ ĊĠĠĠ Ġval Ġide Packages Ġ= Ġplugin Resolver . all Packages . filter Ġ{ ĠKnown Ide Packages . is Known Package ( it ) Ġ} ĊĠĠĠ Ġif Ġ( ide Packages . isNotEmpty ()) Ġ{ ĊĠĠĠĠĠ Ġregister Compatibility Warning ( M ist aken ly Bund led Ide Packages Warning ( ide Packages )) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġselect Classes For Check ( plugin Details : ĠPlugin Details ): ĠSet < String > Ġ{ ĊĠĠĠ Ġval Ġclasses For Check Ġ= Ġhash Set Of < String >() ĊĠĠĠ Ġfor Ġ( classes Selector Ġin Ġclasses Selectors ) Ġ{ ĊĠĠĠĠĠ Ġclasses For Check Ġ+= Ġclasses Selector . get Classes For Check ( plugin Details . plugin Classes Locations ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġreturn Ġclasses For Check ĊĠ Ġ} Ċ Ċ } Ċ Ċ /** Ċ Ġ* ĠSelect ors Ġof Ġclasses Ġthat Ġconst itute Ġthe Ġplugin Ċ Ġ* Ġclass Ġloader Ġand Ġof Ġclasses Ġthat Ġshould Ġbe Ġverified . Ċ Ġ*/ Ċ private Ġval Ġclasses Selectors Ġ= ĠlistOf ( Main Classes Selector (), ĠExternal Build Classes Selector ()) Ċ Ċ fun ĠIde Plugin Classes Locations . create Plugin Resolver () Ġ= ĊĠ ĠComposite Resolver . create ( classes Selectors . flatMap Ġ{ Ġit . getClassLoader ( this ) Ġ})