package Ġcom . github . kor ni lo va 2 0 3 . matlab . resolve Ċ Ċ import Ġcom . github . kor ni lo va 2 0 3 . matlab . Mat lab Reference Ċ import Ġcom . github . kor ni lo va 2 0 3 . matlab . psi . Mat lab Declaration Ċ import Ġcom . intellij . openapi . util . text . StringUtil Ċ import Ġcom . intellij . test Framework . fixtures . Base Platform TestCase Ċ import Ġjunit . framework . TestCase Ċ import Ġjava . io . File Ċ Ċ private Ġconst Ġval ĠDECL _ MARKER Ġ= Ġ"< decl >" Ċ private Ġconst Ġval ĠREF _ MARKER Ġ= Ġ"< ref >" Ċ Ċ class ĠMult if ile Resolve Test Ġ: ĠBase Platform TestCase () Ġ{ ĊĊĠĠĠ Ġoverride Ġfun Ġget TestData Path (): ĠString Ġ= Ġ" testData / resolve / mult if ile /" ĊĊĠĠĠ Ġfun Ġtest Function () Ġ= Ġdo Test (" Function Declaration ") ĊĠĠĠ Ġfun Ġtest Class () Ġ= Ġdo Test (" Class Declaration ") ĊĠĠĠ Ġfun Ġtest Variable Un resolved () Ġ= Ġdo Test Un resolved (" a ") ĊĠĠĠ Ġfun Ġtest Global () Ġ= Ġdo Test Multi (" a ", Ġ 2 ) ĊĠĠĠ Ġfun Ġtest Global Un resolved () Ġ= Ġdo Test Un resolved (" a ") ĊĠĠĠ Ġfun Ġtest Property () Ġ= Ġdo Test (" Prop ") ĊĠĠĠ Ġfun Ġtest Method Dot Not ation () Ġ= Ġdo Test (" foo ") ĊĠĠĠ Ġfun Ġtest Constructor () Ġ= Ġdo Test (" Prop ") ĊĠĠĠ Ġfun Ġtest Find Class In Assign () Ġ= Ġdo Test (" Prop ") ĊĠĠĠ Ġfun Ġtest Find Class In Method () Ġ= Ġdo Test (" Prop ") ĠĠĠĠĊĠĠĠ Ġfun Ġtest Find Class In Prop () Ġ= Ġdo Test With Additional File (" Prop ") ĠĠĠĠĠĠ ĊĠĠĠ Ġfun Ġtest Nested Qualified () Ġ= Ġdo Test With Additional File (" Prop ") ĠĠĠĊĠĠĠ Ġfun Ġtest Method () Ġ= Ġdo Test (" foo ") ĊĊĠĠĠ Ġprivate Ġfun Ġdo Test ( name : ĠString , ĠshouldBe Resolved : ĠBoolean Ġ= Ġtrue ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġtest Name Ġ= ĠtestData Path Ġ+ Ġget Test Name ( false ) ĊĠĠĠĠĠĠĠ Ġval Ġref File Ġ= ĠFile ( test Name Ġ+ Ġ". m ") ĊĠĠĠĠĠĠĠ Ġval Ġdecl File Ġ= ĠFile ( test Name Ġ+ Ġ" Declaration . m ") ĊĠĠĠĠĠĠĠ Ġval Ġ( ref , Ġdecl ) Ġ= Ġget Expected Declaration ( ref File , Ġdecl File ) ĊĠĠĠĠĠĠĠ Ġval Ġresolved Decl Ġ= Ġref . resolve () ĊĠĠĠĠĠĠĠ Ġif Ġ( shouldBe Resolved ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertNotNull (" Declaration Ġnot Ġfound ", Ġresolved Decl ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( name , Ġresolved Decl ?. name Identifier ?. text ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( resolved Decl , Ġdecl ) ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( resolved Decl Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( resolved Decl . containing File , Ġref . element . containing File ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġdo Test Un resolved ( name : ĠString ) Ġ= Ġdo Test ( name , Ġfalse ) ĊĊĠĠĠ Ġprivate Ġfun Ġdo Test Multi ( name : ĠString , Ġcount : ĠInt ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġtest Name Ġ= ĠtestData Path Ġ+ Ġget Test Name ( false ) ĊĠĠĠĠĠĠĠ Ġval Ġref File Ġ= ĠFile ("$ test Name . m ") ĊĠĠĠĠĠĠĠ Ġval Ġdecl File Ġ= ĠFile ( test Name Ġ+ Ġ" Declaration . m ") ĊĠĠĠĠĠĠĠ Ġval Ġref Ġ= Ġget Expected Declaration ( ref File , Ġdecl File ). first ĊĠĠĠĠĠĠĠ Ġval Ġresolved Decl Ġ= Ġref . multi Resolve ( false ) ĊĠĠĠĠĠĠĠ ĠTestCase . assertEquals ( count , Ġresolved Decl . size ) ĊĠĠĠĠĠĠĠ Ġfor Ġ( decl Ġin Ġresolved Decl ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġelement Ġ= Ġdecl . element Ġas ĠMat lab Declaration ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( name , Ġelement . name Identifier ?. text ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠĠĠĠĊĠĠĠ Ġprivate Ġfun Ġdo Test With Additional File ( name : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ Ġmy Fixture . configure By File ( getTest Name ( false ) Ġ+ Ġ" Add . m ") ĊĠĠĠĠĠĠĠ Ġdo Test ( name ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġget Expected Declaration ( ref File Original : ĠFile , Ġdecl File Original : ĠFile ): ĠPair < Mat lab Reference , ĠMat lab Declaration ?> Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġref File Text Ġ= ĠString Util . convert Line Separ ators ( ref File Original . read Text ()) ĊĠĠĠĠĠĠĠ Ġval Ġdecl File Text Ġ= ĠString Util . convert Line Separ ators ( decl File Original . read Text ()) ĊĠĠĠĠĠĠĠ Ġval Ġref Offset Ġ= Ġref File Text . indexOf ( REF _ MARKER ) ĊĠĠĠĠĠĠĠ Ġval Ġdecl Offset Ġ= Ġdecl File Text . indexOf ( DECL _ MARKER ) ĊĠĠĠĠĠĠĠ Ġval Ġref Clear Text Ġ= Ġref File Text . cut Out ( ref Offset , ĠREF _ MARKER . length ) ĊĠĠĠĠĠĠĠ Ġval Ġdecl Clear Text Ġ= Ġif Ġ( decl Offset Ġ== Ġ- 1 ) Ġdecl File Text Ġelse Ġdecl File Text . cut Out ( decl Offset , ĠDECL _ MARKER . length ) ĊĊĠĠĠĠĠĠĠ Ġval Ġref File Ġ= Ġmy Fixture . configure By Text (" ref . m ", Ġref Clear Text ) ĊĠĠĠĠĠĠĠ Ġval Ġdecl File Ġ= Ġmy Fixture . configure By Text ( decl File Original . name , Ġdecl Clear Text ) ĊĊĠĠĠĠĠĠĠ Ġvar Ġdecl Element Ġ= Ġif Ġ( decl Offset Ġ== Ġ- 1 ) Ġnull Ġelse Ġdecl File . findElement At ( decl Offset ) ĊĠĠĠĠĠĠĠ Ġwhile Ġ( decl Element Ġ!= Ġnull Ġ&& Ġdecl Element Ġ! is ĠMat lab Declaration ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdecl Element Ġ= Ġdecl Element . parent ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġif Ġ( decl Element Ġ!= Ġnull ) Ġassert InstanceOf ( decl Element , ĠMat lab Declaration :: class . java ) ĊĠĠĠĠĠĠĠ Ġreturn Ġref File . find Reference At ( ref Offset ) Ġas ĠMat lab Reference Ġto Ġdecl Element Ġas ? ĠMat lab Declaration ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun ĠString . cut Out ( marker Offset : ĠInt , Ġmarker Length : ĠInt ): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġsubstring ( 0 , Ġmarker Offset ) Ġ+ Ġsubstring ( marker Offset Ġ+ Ġmarker Length ) ĊĠĠĠ Ġ} Ċ } Ċ