jsonWorker.js 272 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293
  1. /*!-----------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Version: 0.31.1(337587859b1c171314b40503171188b6cea6a32a)
  4. * Released under the MIT license
  5. * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
  6. *-----------------------------------------------------------------------------*/
  7. define("vs/language/json/jsonWorker",[],()=>{
  8. var moduleExports = (() => {
  9. var __defProp = Object.defineProperty;
  10. var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
  11. var __export = (target, all) => {
  12. __markAsModule(target);
  13. for (var name in all)
  14. __defProp(target, name, { get: all[name], enumerable: true });
  15. };
  16. // src/json/jsonWorker.ts
  17. var jsonWorker_exports = {};
  18. __export(jsonWorker_exports, {
  19. JSONWorker: () => JSONWorker,
  20. create: () => create
  21. });
  22. // node_modules/jsonc-parser/lib/esm/impl/scanner.js
  23. "use strict";
  24. function createScanner(text, ignoreTrivia) {
  25. if (ignoreTrivia === void 0) {
  26. ignoreTrivia = false;
  27. }
  28. var len = text.length;
  29. var pos = 0, value = "", tokenOffset = 0, token = 16, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0;
  30. function scanHexDigits(count, exact) {
  31. var digits = 0;
  32. var value2 = 0;
  33. while (digits < count || !exact) {
  34. var ch = text.charCodeAt(pos);
  35. if (ch >= 48 && ch <= 57) {
  36. value2 = value2 * 16 + ch - 48;
  37. } else if (ch >= 65 && ch <= 70) {
  38. value2 = value2 * 16 + ch - 65 + 10;
  39. } else if (ch >= 97 && ch <= 102) {
  40. value2 = value2 * 16 + ch - 97 + 10;
  41. } else {
  42. break;
  43. }
  44. pos++;
  45. digits++;
  46. }
  47. if (digits < count) {
  48. value2 = -1;
  49. }
  50. return value2;
  51. }
  52. function setPosition(newPosition) {
  53. pos = newPosition;
  54. value = "";
  55. tokenOffset = 0;
  56. token = 16;
  57. scanError = 0;
  58. }
  59. function scanNumber() {
  60. var start = pos;
  61. if (text.charCodeAt(pos) === 48) {
  62. pos++;
  63. } else {
  64. pos++;
  65. while (pos < text.length && isDigit(text.charCodeAt(pos))) {
  66. pos++;
  67. }
  68. }
  69. if (pos < text.length && text.charCodeAt(pos) === 46) {
  70. pos++;
  71. if (pos < text.length && isDigit(text.charCodeAt(pos))) {
  72. pos++;
  73. while (pos < text.length && isDigit(text.charCodeAt(pos))) {
  74. pos++;
  75. }
  76. } else {
  77. scanError = 3;
  78. return text.substring(start, pos);
  79. }
  80. }
  81. var end = pos;
  82. if (pos < text.length && (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101)) {
  83. pos++;
  84. if (pos < text.length && text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45) {
  85. pos++;
  86. }
  87. if (pos < text.length && isDigit(text.charCodeAt(pos))) {
  88. pos++;
  89. while (pos < text.length && isDigit(text.charCodeAt(pos))) {
  90. pos++;
  91. }
  92. end = pos;
  93. } else {
  94. scanError = 3;
  95. }
  96. }
  97. return text.substring(start, end);
  98. }
  99. function scanString() {
  100. var result = "", start = pos;
  101. while (true) {
  102. if (pos >= len) {
  103. result += text.substring(start, pos);
  104. scanError = 2;
  105. break;
  106. }
  107. var ch = text.charCodeAt(pos);
  108. if (ch === 34) {
  109. result += text.substring(start, pos);
  110. pos++;
  111. break;
  112. }
  113. if (ch === 92) {
  114. result += text.substring(start, pos);
  115. pos++;
  116. if (pos >= len) {
  117. scanError = 2;
  118. break;
  119. }
  120. var ch2 = text.charCodeAt(pos++);
  121. switch (ch2) {
  122. case 34:
  123. result += '"';
  124. break;
  125. case 92:
  126. result += "\\";
  127. break;
  128. case 47:
  129. result += "/";
  130. break;
  131. case 98:
  132. result += "\b";
  133. break;
  134. case 102:
  135. result += "\f";
  136. break;
  137. case 110:
  138. result += "\n";
  139. break;
  140. case 114:
  141. result += "\r";
  142. break;
  143. case 116:
  144. result += " ";
  145. break;
  146. case 117:
  147. var ch3 = scanHexDigits(4, true);
  148. if (ch3 >= 0) {
  149. result += String.fromCharCode(ch3);
  150. } else {
  151. scanError = 4;
  152. }
  153. break;
  154. default:
  155. scanError = 5;
  156. }
  157. start = pos;
  158. continue;
  159. }
  160. if (ch >= 0 && ch <= 31) {
  161. if (isLineBreak(ch)) {
  162. result += text.substring(start, pos);
  163. scanError = 2;
  164. break;
  165. } else {
  166. scanError = 6;
  167. }
  168. }
  169. pos++;
  170. }
  171. return result;
  172. }
  173. function scanNext() {
  174. value = "";
  175. scanError = 0;
  176. tokenOffset = pos;
  177. lineStartOffset = lineNumber;
  178. prevTokenLineStartOffset = tokenLineStartOffset;
  179. if (pos >= len) {
  180. tokenOffset = len;
  181. return token = 17;
  182. }
  183. var code = text.charCodeAt(pos);
  184. if (isWhiteSpace(code)) {
  185. do {
  186. pos++;
  187. value += String.fromCharCode(code);
  188. code = text.charCodeAt(pos);
  189. } while (isWhiteSpace(code));
  190. return token = 15;
  191. }
  192. if (isLineBreak(code)) {
  193. pos++;
  194. value += String.fromCharCode(code);
  195. if (code === 13 && text.charCodeAt(pos) === 10) {
  196. pos++;
  197. value += "\n";
  198. }
  199. lineNumber++;
  200. tokenLineStartOffset = pos;
  201. return token = 14;
  202. }
  203. switch (code) {
  204. case 123:
  205. pos++;
  206. return token = 1;
  207. case 125:
  208. pos++;
  209. return token = 2;
  210. case 91:
  211. pos++;
  212. return token = 3;
  213. case 93:
  214. pos++;
  215. return token = 4;
  216. case 58:
  217. pos++;
  218. return token = 6;
  219. case 44:
  220. pos++;
  221. return token = 5;
  222. case 34:
  223. pos++;
  224. value = scanString();
  225. return token = 10;
  226. case 47:
  227. var start = pos - 1;
  228. if (text.charCodeAt(pos + 1) === 47) {
  229. pos += 2;
  230. while (pos < len) {
  231. if (isLineBreak(text.charCodeAt(pos))) {
  232. break;
  233. }
  234. pos++;
  235. }
  236. value = text.substring(start, pos);
  237. return token = 12;
  238. }
  239. if (text.charCodeAt(pos + 1) === 42) {
  240. pos += 2;
  241. var safeLength = len - 1;
  242. var commentClosed = false;
  243. while (pos < safeLength) {
  244. var ch = text.charCodeAt(pos);
  245. if (ch === 42 && text.charCodeAt(pos + 1) === 47) {
  246. pos += 2;
  247. commentClosed = true;
  248. break;
  249. }
  250. pos++;
  251. if (isLineBreak(ch)) {
  252. if (ch === 13 && text.charCodeAt(pos) === 10) {
  253. pos++;
  254. }
  255. lineNumber++;
  256. tokenLineStartOffset = pos;
  257. }
  258. }
  259. if (!commentClosed) {
  260. pos++;
  261. scanError = 1;
  262. }
  263. value = text.substring(start, pos);
  264. return token = 13;
  265. }
  266. value += String.fromCharCode(code);
  267. pos++;
  268. return token = 16;
  269. case 45:
  270. value += String.fromCharCode(code);
  271. pos++;
  272. if (pos === len || !isDigit(text.charCodeAt(pos))) {
  273. return token = 16;
  274. }
  275. case 48:
  276. case 49:
  277. case 50:
  278. case 51:
  279. case 52:
  280. case 53:
  281. case 54:
  282. case 55:
  283. case 56:
  284. case 57:
  285. value += scanNumber();
  286. return token = 11;
  287. default:
  288. while (pos < len && isUnknownContentCharacter(code)) {
  289. pos++;
  290. code = text.charCodeAt(pos);
  291. }
  292. if (tokenOffset !== pos) {
  293. value = text.substring(tokenOffset, pos);
  294. switch (value) {
  295. case "true":
  296. return token = 8;
  297. case "false":
  298. return token = 9;
  299. case "null":
  300. return token = 7;
  301. }
  302. return token = 16;
  303. }
  304. value += String.fromCharCode(code);
  305. pos++;
  306. return token = 16;
  307. }
  308. }
  309. function isUnknownContentCharacter(code) {
  310. if (isWhiteSpace(code) || isLineBreak(code)) {
  311. return false;
  312. }
  313. switch (code) {
  314. case 125:
  315. case 93:
  316. case 123:
  317. case 91:
  318. case 34:
  319. case 58:
  320. case 44:
  321. case 47:
  322. return false;
  323. }
  324. return true;
  325. }
  326. function scanNextNonTrivia() {
  327. var result;
  328. do {
  329. result = scanNext();
  330. } while (result >= 12 && result <= 15);
  331. return result;
  332. }
  333. return {
  334. setPosition,
  335. getPosition: function() {
  336. return pos;
  337. },
  338. scan: ignoreTrivia ? scanNextNonTrivia : scanNext,
  339. getToken: function() {
  340. return token;
  341. },
  342. getTokenValue: function() {
  343. return value;
  344. },
  345. getTokenOffset: function() {
  346. return tokenOffset;
  347. },
  348. getTokenLength: function() {
  349. return pos - tokenOffset;
  350. },
  351. getTokenStartLine: function() {
  352. return lineStartOffset;
  353. },
  354. getTokenStartCharacter: function() {
  355. return tokenOffset - prevTokenLineStartOffset;
  356. },
  357. getTokenError: function() {
  358. return scanError;
  359. }
  360. };
  361. }
  362. function isWhiteSpace(ch) {
  363. return ch === 32 || ch === 9 || ch === 11 || ch === 12 || ch === 160 || ch === 5760 || ch >= 8192 && ch <= 8203 || ch === 8239 || ch === 8287 || ch === 12288 || ch === 65279;
  364. }
  365. function isLineBreak(ch) {
  366. return ch === 10 || ch === 13 || ch === 8232 || ch === 8233;
  367. }
  368. function isDigit(ch) {
  369. return ch >= 48 && ch <= 57;
  370. }
  371. // node_modules/jsonc-parser/lib/esm/impl/format.js
  372. "use strict";
  373. function format(documentText, range, options) {
  374. var initialIndentLevel;
  375. var formatText;
  376. var formatTextStart;
  377. var rangeStart;
  378. var rangeEnd;
  379. if (range) {
  380. rangeStart = range.offset;
  381. rangeEnd = rangeStart + range.length;
  382. formatTextStart = rangeStart;
  383. while (formatTextStart > 0 && !isEOL(documentText, formatTextStart - 1)) {
  384. formatTextStart--;
  385. }
  386. var endOffset = rangeEnd;
  387. while (endOffset < documentText.length && !isEOL(documentText, endOffset)) {
  388. endOffset++;
  389. }
  390. formatText = documentText.substring(formatTextStart, endOffset);
  391. initialIndentLevel = computeIndentLevel(formatText, options);
  392. } else {
  393. formatText = documentText;
  394. initialIndentLevel = 0;
  395. formatTextStart = 0;
  396. rangeStart = 0;
  397. rangeEnd = documentText.length;
  398. }
  399. var eol = getEOL(options, documentText);
  400. var lineBreak = false;
  401. var indentLevel = 0;
  402. var indentValue;
  403. if (options.insertSpaces) {
  404. indentValue = repeat(" ", options.tabSize || 4);
  405. } else {
  406. indentValue = " ";
  407. }
  408. var scanner2 = createScanner(formatText, false);
  409. var hasError = false;
  410. function newLineAndIndent() {
  411. return eol + repeat(indentValue, initialIndentLevel + indentLevel);
  412. }
  413. function scanNext() {
  414. var token = scanner2.scan();
  415. lineBreak = false;
  416. while (token === 15 || token === 14) {
  417. lineBreak = lineBreak || token === 14;
  418. token = scanner2.scan();
  419. }
  420. hasError = token === 16 || scanner2.getTokenError() !== 0;
  421. return token;
  422. }
  423. var editOperations = [];
  424. function addEdit(text, startOffset, endOffset2) {
  425. if (!hasError && (!range || startOffset < rangeEnd && endOffset2 > rangeStart) && documentText.substring(startOffset, endOffset2) !== text) {
  426. editOperations.push({ offset: startOffset, length: endOffset2 - startOffset, content: text });
  427. }
  428. }
  429. var firstToken = scanNext();
  430. if (firstToken !== 17) {
  431. var firstTokenStart = scanner2.getTokenOffset() + formatTextStart;
  432. var initialIndent = repeat(indentValue, initialIndentLevel);
  433. addEdit(initialIndent, formatTextStart, firstTokenStart);
  434. }
  435. while (firstToken !== 17) {
  436. var firstTokenEnd = scanner2.getTokenOffset() + scanner2.getTokenLength() + formatTextStart;
  437. var secondToken = scanNext();
  438. var replaceContent = "";
  439. var needsLineBreak = false;
  440. while (!lineBreak && (secondToken === 12 || secondToken === 13)) {
  441. var commentTokenStart = scanner2.getTokenOffset() + formatTextStart;
  442. addEdit(" ", firstTokenEnd, commentTokenStart);
  443. firstTokenEnd = scanner2.getTokenOffset() + scanner2.getTokenLength() + formatTextStart;
  444. needsLineBreak = secondToken === 12;
  445. replaceContent = needsLineBreak ? newLineAndIndent() : "";
  446. secondToken = scanNext();
  447. }
  448. if (secondToken === 2) {
  449. if (firstToken !== 1) {
  450. indentLevel--;
  451. replaceContent = newLineAndIndent();
  452. }
  453. } else if (secondToken === 4) {
  454. if (firstToken !== 3) {
  455. indentLevel--;
  456. replaceContent = newLineAndIndent();
  457. }
  458. } else {
  459. switch (firstToken) {
  460. case 3:
  461. case 1:
  462. indentLevel++;
  463. replaceContent = newLineAndIndent();
  464. break;
  465. case 5:
  466. case 12:
  467. replaceContent = newLineAndIndent();
  468. break;
  469. case 13:
  470. if (lineBreak) {
  471. replaceContent = newLineAndIndent();
  472. } else if (!needsLineBreak) {
  473. replaceContent = " ";
  474. }
  475. break;
  476. case 6:
  477. if (!needsLineBreak) {
  478. replaceContent = " ";
  479. }
  480. break;
  481. case 10:
  482. if (secondToken === 6) {
  483. if (!needsLineBreak) {
  484. replaceContent = "";
  485. }
  486. break;
  487. }
  488. case 7:
  489. case 8:
  490. case 9:
  491. case 11:
  492. case 2:
  493. case 4:
  494. if (secondToken === 12 || secondToken === 13) {
  495. if (!needsLineBreak) {
  496. replaceContent = " ";
  497. }
  498. } else if (secondToken !== 5 && secondToken !== 17) {
  499. hasError = true;
  500. }
  501. break;
  502. case 16:
  503. hasError = true;
  504. break;
  505. }
  506. if (lineBreak && (secondToken === 12 || secondToken === 13)) {
  507. replaceContent = newLineAndIndent();
  508. }
  509. }
  510. if (secondToken === 17) {
  511. replaceContent = options.insertFinalNewline ? eol : "";
  512. }
  513. var secondTokenStart = scanner2.getTokenOffset() + formatTextStart;
  514. addEdit(replaceContent, firstTokenEnd, secondTokenStart);
  515. firstToken = secondToken;
  516. }
  517. return editOperations;
  518. }
  519. function repeat(s, count) {
  520. var result = "";
  521. for (var i = 0; i < count; i++) {
  522. result += s;
  523. }
  524. return result;
  525. }
  526. function computeIndentLevel(content, options) {
  527. var i = 0;
  528. var nChars = 0;
  529. var tabSize = options.tabSize || 4;
  530. while (i < content.length) {
  531. var ch = content.charAt(i);
  532. if (ch === " ") {
  533. nChars++;
  534. } else if (ch === " ") {
  535. nChars += tabSize;
  536. } else {
  537. break;
  538. }
  539. i++;
  540. }
  541. return Math.floor(nChars / tabSize);
  542. }
  543. function getEOL(options, text) {
  544. for (var i = 0; i < text.length; i++) {
  545. var ch = text.charAt(i);
  546. if (ch === "\r") {
  547. if (i + 1 < text.length && text.charAt(i + 1) === "\n") {
  548. return "\r\n";
  549. }
  550. return "\r";
  551. } else if (ch === "\n") {
  552. return "\n";
  553. }
  554. }
  555. return options && options.eol || "\n";
  556. }
  557. function isEOL(text, offset) {
  558. return "\r\n".indexOf(text.charAt(offset)) !== -1;
  559. }
  560. // node_modules/jsonc-parser/lib/esm/impl/parser.js
  561. "use strict";
  562. var ParseOptions;
  563. (function(ParseOptions2) {
  564. ParseOptions2.DEFAULT = {
  565. allowTrailingComma: false
  566. };
  567. })(ParseOptions || (ParseOptions = {}));
  568. function parse(text, errors, options) {
  569. if (errors === void 0) {
  570. errors = [];
  571. }
  572. if (options === void 0) {
  573. options = ParseOptions.DEFAULT;
  574. }
  575. var currentProperty = null;
  576. var currentParent = [];
  577. var previousParents = [];
  578. function onValue(value) {
  579. if (Array.isArray(currentParent)) {
  580. currentParent.push(value);
  581. } else if (currentProperty !== null) {
  582. currentParent[currentProperty] = value;
  583. }
  584. }
  585. var visitor = {
  586. onObjectBegin: function() {
  587. var object = {};
  588. onValue(object);
  589. previousParents.push(currentParent);
  590. currentParent = object;
  591. currentProperty = null;
  592. },
  593. onObjectProperty: function(name) {
  594. currentProperty = name;
  595. },
  596. onObjectEnd: function() {
  597. currentParent = previousParents.pop();
  598. },
  599. onArrayBegin: function() {
  600. var array = [];
  601. onValue(array);
  602. previousParents.push(currentParent);
  603. currentParent = array;
  604. currentProperty = null;
  605. },
  606. onArrayEnd: function() {
  607. currentParent = previousParents.pop();
  608. },
  609. onLiteralValue: onValue,
  610. onError: function(error, offset, length) {
  611. errors.push({ error, offset, length });
  612. }
  613. };
  614. visit(text, visitor, options);
  615. return currentParent[0];
  616. }
  617. function getNodePath(node) {
  618. if (!node.parent || !node.parent.children) {
  619. return [];
  620. }
  621. var path = getNodePath(node.parent);
  622. if (node.parent.type === "property") {
  623. var key = node.parent.children[0].value;
  624. path.push(key);
  625. } else if (node.parent.type === "array") {
  626. var index = node.parent.children.indexOf(node);
  627. if (index !== -1) {
  628. path.push(index);
  629. }
  630. }
  631. return path;
  632. }
  633. function getNodeValue(node) {
  634. switch (node.type) {
  635. case "array":
  636. return node.children.map(getNodeValue);
  637. case "object":
  638. var obj = Object.create(null);
  639. for (var _i = 0, _a = node.children; _i < _a.length; _i++) {
  640. var prop = _a[_i];
  641. var valueNode = prop.children[1];
  642. if (valueNode) {
  643. obj[prop.children[0].value] = getNodeValue(valueNode);
  644. }
  645. }
  646. return obj;
  647. case "null":
  648. case "string":
  649. case "number":
  650. case "boolean":
  651. return node.value;
  652. default:
  653. return void 0;
  654. }
  655. }
  656. function contains(node, offset, includeRightBound) {
  657. if (includeRightBound === void 0) {
  658. includeRightBound = false;
  659. }
  660. return offset >= node.offset && offset < node.offset + node.length || includeRightBound && offset === node.offset + node.length;
  661. }
  662. function findNodeAtOffset(node, offset, includeRightBound) {
  663. if (includeRightBound === void 0) {
  664. includeRightBound = false;
  665. }
  666. if (contains(node, offset, includeRightBound)) {
  667. var children = node.children;
  668. if (Array.isArray(children)) {
  669. for (var i = 0; i < children.length && children[i].offset <= offset; i++) {
  670. var item = findNodeAtOffset(children[i], offset, includeRightBound);
  671. if (item) {
  672. return item;
  673. }
  674. }
  675. }
  676. return node;
  677. }
  678. return void 0;
  679. }
  680. function visit(text, visitor, options) {
  681. if (options === void 0) {
  682. options = ParseOptions.DEFAULT;
  683. }
  684. var _scanner = createScanner(text, false);
  685. function toNoArgVisit(visitFunction) {
  686. return visitFunction ? function() {
  687. return visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter());
  688. } : function() {
  689. return true;
  690. };
  691. }
  692. function toOneArgVisit(visitFunction) {
  693. return visitFunction ? function(arg) {
  694. return visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter());
  695. } : function() {
  696. return true;
  697. };
  698. }
  699. var onObjectBegin = toNoArgVisit(visitor.onObjectBegin), onObjectProperty = toOneArgVisit(visitor.onObjectProperty), onObjectEnd = toNoArgVisit(visitor.onObjectEnd), onArrayBegin = toNoArgVisit(visitor.onArrayBegin), onArrayEnd = toNoArgVisit(visitor.onArrayEnd), onLiteralValue = toOneArgVisit(visitor.onLiteralValue), onSeparator = toOneArgVisit(visitor.onSeparator), onComment = toNoArgVisit(visitor.onComment), onError = toOneArgVisit(visitor.onError);
  700. var disallowComments = options && options.disallowComments;
  701. var allowTrailingComma = options && options.allowTrailingComma;
  702. function scanNext() {
  703. while (true) {
  704. var token = _scanner.scan();
  705. switch (_scanner.getTokenError()) {
  706. case 4:
  707. handleError(14);
  708. break;
  709. case 5:
  710. handleError(15);
  711. break;
  712. case 3:
  713. handleError(13);
  714. break;
  715. case 1:
  716. if (!disallowComments) {
  717. handleError(11);
  718. }
  719. break;
  720. case 2:
  721. handleError(12);
  722. break;
  723. case 6:
  724. handleError(16);
  725. break;
  726. }
  727. switch (token) {
  728. case 12:
  729. case 13:
  730. if (disallowComments) {
  731. handleError(10);
  732. } else {
  733. onComment();
  734. }
  735. break;
  736. case 16:
  737. handleError(1);
  738. break;
  739. case 15:
  740. case 14:
  741. break;
  742. default:
  743. return token;
  744. }
  745. }
  746. }
  747. function handleError(error, skipUntilAfter, skipUntil) {
  748. if (skipUntilAfter === void 0) {
  749. skipUntilAfter = [];
  750. }
  751. if (skipUntil === void 0) {
  752. skipUntil = [];
  753. }
  754. onError(error);
  755. if (skipUntilAfter.length + skipUntil.length > 0) {
  756. var token = _scanner.getToken();
  757. while (token !== 17) {
  758. if (skipUntilAfter.indexOf(token) !== -1) {
  759. scanNext();
  760. break;
  761. } else if (skipUntil.indexOf(token) !== -1) {
  762. break;
  763. }
  764. token = scanNext();
  765. }
  766. }
  767. }
  768. function parseString(isValue) {
  769. var value = _scanner.getTokenValue();
  770. if (isValue) {
  771. onLiteralValue(value);
  772. } else {
  773. onObjectProperty(value);
  774. }
  775. scanNext();
  776. return true;
  777. }
  778. function parseLiteral() {
  779. switch (_scanner.getToken()) {
  780. case 11:
  781. var tokenValue = _scanner.getTokenValue();
  782. var value = Number(tokenValue);
  783. if (isNaN(value)) {
  784. handleError(2);
  785. value = 0;
  786. }
  787. onLiteralValue(value);
  788. break;
  789. case 7:
  790. onLiteralValue(null);
  791. break;
  792. case 8:
  793. onLiteralValue(true);
  794. break;
  795. case 9:
  796. onLiteralValue(false);
  797. break;
  798. default:
  799. return false;
  800. }
  801. scanNext();
  802. return true;
  803. }
  804. function parseProperty() {
  805. if (_scanner.getToken() !== 10) {
  806. handleError(3, [], [2, 5]);
  807. return false;
  808. }
  809. parseString(false);
  810. if (_scanner.getToken() === 6) {
  811. onSeparator(":");
  812. scanNext();
  813. if (!parseValue()) {
  814. handleError(4, [], [2, 5]);
  815. }
  816. } else {
  817. handleError(5, [], [2, 5]);
  818. }
  819. return true;
  820. }
  821. function parseObject() {
  822. onObjectBegin();
  823. scanNext();
  824. var needsComma = false;
  825. while (_scanner.getToken() !== 2 && _scanner.getToken() !== 17) {
  826. if (_scanner.getToken() === 5) {
  827. if (!needsComma) {
  828. handleError(4, [], []);
  829. }
  830. onSeparator(",");
  831. scanNext();
  832. if (_scanner.getToken() === 2 && allowTrailingComma) {
  833. break;
  834. }
  835. } else if (needsComma) {
  836. handleError(6, [], []);
  837. }
  838. if (!parseProperty()) {
  839. handleError(4, [], [2, 5]);
  840. }
  841. needsComma = true;
  842. }
  843. onObjectEnd();
  844. if (_scanner.getToken() !== 2) {
  845. handleError(7, [2], []);
  846. } else {
  847. scanNext();
  848. }
  849. return true;
  850. }
  851. function parseArray() {
  852. onArrayBegin();
  853. scanNext();
  854. var needsComma = false;
  855. while (_scanner.getToken() !== 4 && _scanner.getToken() !== 17) {
  856. if (_scanner.getToken() === 5) {
  857. if (!needsComma) {
  858. handleError(4, [], []);
  859. }
  860. onSeparator(",");
  861. scanNext();
  862. if (_scanner.getToken() === 4 && allowTrailingComma) {
  863. break;
  864. }
  865. } else if (needsComma) {
  866. handleError(6, [], []);
  867. }
  868. if (!parseValue()) {
  869. handleError(4, [], [4, 5]);
  870. }
  871. needsComma = true;
  872. }
  873. onArrayEnd();
  874. if (_scanner.getToken() !== 4) {
  875. handleError(8, [4], []);
  876. } else {
  877. scanNext();
  878. }
  879. return true;
  880. }
  881. function parseValue() {
  882. switch (_scanner.getToken()) {
  883. case 3:
  884. return parseArray();
  885. case 1:
  886. return parseObject();
  887. case 10:
  888. return parseString(true);
  889. default:
  890. return parseLiteral();
  891. }
  892. }
  893. scanNext();
  894. if (_scanner.getToken() === 17) {
  895. if (options.allowEmptyContent) {
  896. return true;
  897. }
  898. handleError(4, [], []);
  899. return false;
  900. }
  901. if (!parseValue()) {
  902. handleError(4, [], []);
  903. return false;
  904. }
  905. if (_scanner.getToken() !== 17) {
  906. handleError(9, [], []);
  907. }
  908. return true;
  909. }
  910. // node_modules/jsonc-parser/lib/esm/impl/edit.js
  911. "use strict";
  912. // node_modules/jsonc-parser/lib/esm/main.js
  913. "use strict";
  914. var createScanner2 = createScanner;
  915. var parse2 = parse;
  916. var findNodeAtOffset2 = findNodeAtOffset;
  917. var getNodePath2 = getNodePath;
  918. var getNodeValue2 = getNodeValue;
  919. function format2(documentText, range, options) {
  920. return format(documentText, range, options);
  921. }
  922. // node_modules/vscode-json-languageservice/lib/esm/utils/objects.js
  923. function equals(one, other) {
  924. if (one === other) {
  925. return true;
  926. }
  927. if (one === null || one === void 0 || other === null || other === void 0) {
  928. return false;
  929. }
  930. if (typeof one !== typeof other) {
  931. return false;
  932. }
  933. if (typeof one !== "object") {
  934. return false;
  935. }
  936. if (Array.isArray(one) !== Array.isArray(other)) {
  937. return false;
  938. }
  939. var i, key;
  940. if (Array.isArray(one)) {
  941. if (one.length !== other.length) {
  942. return false;
  943. }
  944. for (i = 0; i < one.length; i++) {
  945. if (!equals(one[i], other[i])) {
  946. return false;
  947. }
  948. }
  949. } else {
  950. var oneKeys = [];
  951. for (key in one) {
  952. oneKeys.push(key);
  953. }
  954. oneKeys.sort();
  955. var otherKeys = [];
  956. for (key in other) {
  957. otherKeys.push(key);
  958. }
  959. otherKeys.sort();
  960. if (!equals(oneKeys, otherKeys)) {
  961. return false;
  962. }
  963. for (i = 0; i < oneKeys.length; i++) {
  964. if (!equals(one[oneKeys[i]], other[oneKeys[i]])) {
  965. return false;
  966. }
  967. }
  968. }
  969. return true;
  970. }
  971. function isNumber(val) {
  972. return typeof val === "number";
  973. }
  974. function isDefined(val) {
  975. return typeof val !== "undefined";
  976. }
  977. function isBoolean(val) {
  978. return typeof val === "boolean";
  979. }
  980. function isString(val) {
  981. return typeof val === "string";
  982. }
  983. // node_modules/vscode-json-languageservice/lib/esm/utils/strings.js
  984. function startsWith(haystack, needle) {
  985. if (haystack.length < needle.length) {
  986. return false;
  987. }
  988. for (var i = 0; i < needle.length; i++) {
  989. if (haystack[i] !== needle[i]) {
  990. return false;
  991. }
  992. }
  993. return true;
  994. }
  995. function endsWith(haystack, needle) {
  996. var diff = haystack.length - needle.length;
  997. if (diff > 0) {
  998. return haystack.lastIndexOf(needle) === diff;
  999. } else if (diff === 0) {
  1000. return haystack === needle;
  1001. } else {
  1002. return false;
  1003. }
  1004. }
  1005. function extendedRegExp(pattern) {
  1006. var flags = "";
  1007. if (startsWith(pattern, "(?i)")) {
  1008. pattern = pattern.substring(4);
  1009. flags = "i";
  1010. }
  1011. try {
  1012. return new RegExp(pattern, flags + "u");
  1013. } catch (e) {
  1014. try {
  1015. return new RegExp(pattern, flags);
  1016. } catch (e2) {
  1017. return void 0;
  1018. }
  1019. }
  1020. }
  1021. // node_modules/vscode-languageserver-types/lib/esm/main.js
  1022. "use strict";
  1023. var integer;
  1024. (function(integer2) {
  1025. integer2.MIN_VALUE = -2147483648;
  1026. integer2.MAX_VALUE = 2147483647;
  1027. })(integer || (integer = {}));
  1028. var uinteger;
  1029. (function(uinteger2) {
  1030. uinteger2.MIN_VALUE = 0;
  1031. uinteger2.MAX_VALUE = 2147483647;
  1032. })(uinteger || (uinteger = {}));
  1033. var Position;
  1034. (function(Position2) {
  1035. function create2(line, character) {
  1036. if (line === Number.MAX_VALUE) {
  1037. line = uinteger.MAX_VALUE;
  1038. }
  1039. if (character === Number.MAX_VALUE) {
  1040. character = uinteger.MAX_VALUE;
  1041. }
  1042. return { line, character };
  1043. }
  1044. Position2.create = create2;
  1045. function is(value) {
  1046. var candidate = value;
  1047. return Is.objectLiteral(candidate) && Is.uinteger(candidate.line) && Is.uinteger(candidate.character);
  1048. }
  1049. Position2.is = is;
  1050. })(Position || (Position = {}));
  1051. var Range;
  1052. (function(Range2) {
  1053. function create2(one, two, three, four) {
  1054. if (Is.uinteger(one) && Is.uinteger(two) && Is.uinteger(three) && Is.uinteger(four)) {
  1055. return { start: Position.create(one, two), end: Position.create(three, four) };
  1056. } else if (Position.is(one) && Position.is(two)) {
  1057. return { start: one, end: two };
  1058. } else {
  1059. throw new Error("Range#create called with invalid arguments[" + one + ", " + two + ", " + three + ", " + four + "]");
  1060. }
  1061. }
  1062. Range2.create = create2;
  1063. function is(value) {
  1064. var candidate = value;
  1065. return Is.objectLiteral(candidate) && Position.is(candidate.start) && Position.is(candidate.end);
  1066. }
  1067. Range2.is = is;
  1068. })(Range || (Range = {}));
  1069. var Location;
  1070. (function(Location2) {
  1071. function create2(uri, range) {
  1072. return { uri, range };
  1073. }
  1074. Location2.create = create2;
  1075. function is(value) {
  1076. var candidate = value;
  1077. return Is.defined(candidate) && Range.is(candidate.range) && (Is.string(candidate.uri) || Is.undefined(candidate.uri));
  1078. }
  1079. Location2.is = is;
  1080. })(Location || (Location = {}));
  1081. var LocationLink;
  1082. (function(LocationLink2) {
  1083. function create2(targetUri, targetRange, targetSelectionRange, originSelectionRange) {
  1084. return { targetUri, targetRange, targetSelectionRange, originSelectionRange };
  1085. }
  1086. LocationLink2.create = create2;
  1087. function is(value) {
  1088. var candidate = value;
  1089. return Is.defined(candidate) && Range.is(candidate.targetRange) && Is.string(candidate.targetUri) && (Range.is(candidate.targetSelectionRange) || Is.undefined(candidate.targetSelectionRange)) && (Range.is(candidate.originSelectionRange) || Is.undefined(candidate.originSelectionRange));
  1090. }
  1091. LocationLink2.is = is;
  1092. })(LocationLink || (LocationLink = {}));
  1093. var Color;
  1094. (function(Color2) {
  1095. function create2(red, green, blue, alpha) {
  1096. return {
  1097. red,
  1098. green,
  1099. blue,
  1100. alpha
  1101. };
  1102. }
  1103. Color2.create = create2;
  1104. function is(value) {
  1105. var candidate = value;
  1106. return Is.numberRange(candidate.red, 0, 1) && Is.numberRange(candidate.green, 0, 1) && Is.numberRange(candidate.blue, 0, 1) && Is.numberRange(candidate.alpha, 0, 1);
  1107. }
  1108. Color2.is = is;
  1109. })(Color || (Color = {}));
  1110. var ColorInformation;
  1111. (function(ColorInformation2) {
  1112. function create2(range, color) {
  1113. return {
  1114. range,
  1115. color
  1116. };
  1117. }
  1118. ColorInformation2.create = create2;
  1119. function is(value) {
  1120. var candidate = value;
  1121. return Range.is(candidate.range) && Color.is(candidate.color);
  1122. }
  1123. ColorInformation2.is = is;
  1124. })(ColorInformation || (ColorInformation = {}));
  1125. var ColorPresentation;
  1126. (function(ColorPresentation2) {
  1127. function create2(label, textEdit, additionalTextEdits) {
  1128. return {
  1129. label,
  1130. textEdit,
  1131. additionalTextEdits
  1132. };
  1133. }
  1134. ColorPresentation2.create = create2;
  1135. function is(value) {
  1136. var candidate = value;
  1137. return Is.string(candidate.label) && (Is.undefined(candidate.textEdit) || TextEdit.is(candidate)) && (Is.undefined(candidate.additionalTextEdits) || Is.typedArray(candidate.additionalTextEdits, TextEdit.is));
  1138. }
  1139. ColorPresentation2.is = is;
  1140. })(ColorPresentation || (ColorPresentation = {}));
  1141. var FoldingRangeKind;
  1142. (function(FoldingRangeKind2) {
  1143. FoldingRangeKind2["Comment"] = "comment";
  1144. FoldingRangeKind2["Imports"] = "imports";
  1145. FoldingRangeKind2["Region"] = "region";
  1146. })(FoldingRangeKind || (FoldingRangeKind = {}));
  1147. var FoldingRange;
  1148. (function(FoldingRange2) {
  1149. function create2(startLine, endLine, startCharacter, endCharacter, kind) {
  1150. var result = {
  1151. startLine,
  1152. endLine
  1153. };
  1154. if (Is.defined(startCharacter)) {
  1155. result.startCharacter = startCharacter;
  1156. }
  1157. if (Is.defined(endCharacter)) {
  1158. result.endCharacter = endCharacter;
  1159. }
  1160. if (Is.defined(kind)) {
  1161. result.kind = kind;
  1162. }
  1163. return result;
  1164. }
  1165. FoldingRange2.create = create2;
  1166. function is(value) {
  1167. var candidate = value;
  1168. return Is.uinteger(candidate.startLine) && Is.uinteger(candidate.startLine) && (Is.undefined(candidate.startCharacter) || Is.uinteger(candidate.startCharacter)) && (Is.undefined(candidate.endCharacter) || Is.uinteger(candidate.endCharacter)) && (Is.undefined(candidate.kind) || Is.string(candidate.kind));
  1169. }
  1170. FoldingRange2.is = is;
  1171. })(FoldingRange || (FoldingRange = {}));
  1172. var DiagnosticRelatedInformation;
  1173. (function(DiagnosticRelatedInformation2) {
  1174. function create2(location, message) {
  1175. return {
  1176. location,
  1177. message
  1178. };
  1179. }
  1180. DiagnosticRelatedInformation2.create = create2;
  1181. function is(value) {
  1182. var candidate = value;
  1183. return Is.defined(candidate) && Location.is(candidate.location) && Is.string(candidate.message);
  1184. }
  1185. DiagnosticRelatedInformation2.is = is;
  1186. })(DiagnosticRelatedInformation || (DiagnosticRelatedInformation = {}));
  1187. var DiagnosticSeverity;
  1188. (function(DiagnosticSeverity2) {
  1189. DiagnosticSeverity2.Error = 1;
  1190. DiagnosticSeverity2.Warning = 2;
  1191. DiagnosticSeverity2.Information = 3;
  1192. DiagnosticSeverity2.Hint = 4;
  1193. })(DiagnosticSeverity || (DiagnosticSeverity = {}));
  1194. var DiagnosticTag;
  1195. (function(DiagnosticTag2) {
  1196. DiagnosticTag2.Unnecessary = 1;
  1197. DiagnosticTag2.Deprecated = 2;
  1198. })(DiagnosticTag || (DiagnosticTag = {}));
  1199. var CodeDescription;
  1200. (function(CodeDescription2) {
  1201. function is(value) {
  1202. var candidate = value;
  1203. return candidate !== void 0 && candidate !== null && Is.string(candidate.href);
  1204. }
  1205. CodeDescription2.is = is;
  1206. })(CodeDescription || (CodeDescription = {}));
  1207. var Diagnostic;
  1208. (function(Diagnostic2) {
  1209. function create2(range, message, severity, code, source, relatedInformation) {
  1210. var result = { range, message };
  1211. if (Is.defined(severity)) {
  1212. result.severity = severity;
  1213. }
  1214. if (Is.defined(code)) {
  1215. result.code = code;
  1216. }
  1217. if (Is.defined(source)) {
  1218. result.source = source;
  1219. }
  1220. if (Is.defined(relatedInformation)) {
  1221. result.relatedInformation = relatedInformation;
  1222. }
  1223. return result;
  1224. }
  1225. Diagnostic2.create = create2;
  1226. function is(value) {
  1227. var _a;
  1228. var candidate = value;
  1229. return Is.defined(candidate) && Range.is(candidate.range) && Is.string(candidate.message) && (Is.number(candidate.severity) || Is.undefined(candidate.severity)) && (Is.integer(candidate.code) || Is.string(candidate.code) || Is.undefined(candidate.code)) && (Is.undefined(candidate.codeDescription) || Is.string((_a = candidate.codeDescription) === null || _a === void 0 ? void 0 : _a.href)) && (Is.string(candidate.source) || Is.undefined(candidate.source)) && (Is.undefined(candidate.relatedInformation) || Is.typedArray(candidate.relatedInformation, DiagnosticRelatedInformation.is));
  1230. }
  1231. Diagnostic2.is = is;
  1232. })(Diagnostic || (Diagnostic = {}));
  1233. var Command;
  1234. (function(Command2) {
  1235. function create2(title, command) {
  1236. var args = [];
  1237. for (var _i = 2; _i < arguments.length; _i++) {
  1238. args[_i - 2] = arguments[_i];
  1239. }
  1240. var result = { title, command };
  1241. if (Is.defined(args) && args.length > 0) {
  1242. result.arguments = args;
  1243. }
  1244. return result;
  1245. }
  1246. Command2.create = create2;
  1247. function is(value) {
  1248. var candidate = value;
  1249. return Is.defined(candidate) && Is.string(candidate.title) && Is.string(candidate.command);
  1250. }
  1251. Command2.is = is;
  1252. })(Command || (Command = {}));
  1253. var TextEdit;
  1254. (function(TextEdit2) {
  1255. function replace(range, newText) {
  1256. return { range, newText };
  1257. }
  1258. TextEdit2.replace = replace;
  1259. function insert(position, newText) {
  1260. return { range: { start: position, end: position }, newText };
  1261. }
  1262. TextEdit2.insert = insert;
  1263. function del(range) {
  1264. return { range, newText: "" };
  1265. }
  1266. TextEdit2.del = del;
  1267. function is(value) {
  1268. var candidate = value;
  1269. return Is.objectLiteral(candidate) && Is.string(candidate.newText) && Range.is(candidate.range);
  1270. }
  1271. TextEdit2.is = is;
  1272. })(TextEdit || (TextEdit = {}));
  1273. var ChangeAnnotation;
  1274. (function(ChangeAnnotation2) {
  1275. function create2(label, needsConfirmation, description) {
  1276. var result = { label };
  1277. if (needsConfirmation !== void 0) {
  1278. result.needsConfirmation = needsConfirmation;
  1279. }
  1280. if (description !== void 0) {
  1281. result.description = description;
  1282. }
  1283. return result;
  1284. }
  1285. ChangeAnnotation2.create = create2;
  1286. function is(value) {
  1287. var candidate = value;
  1288. return candidate !== void 0 && Is.objectLiteral(candidate) && Is.string(candidate.label) && (Is.boolean(candidate.needsConfirmation) || candidate.needsConfirmation === void 0) && (Is.string(candidate.description) || candidate.description === void 0);
  1289. }
  1290. ChangeAnnotation2.is = is;
  1291. })(ChangeAnnotation || (ChangeAnnotation = {}));
  1292. var ChangeAnnotationIdentifier;
  1293. (function(ChangeAnnotationIdentifier2) {
  1294. function is(value) {
  1295. var candidate = value;
  1296. return typeof candidate === "string";
  1297. }
  1298. ChangeAnnotationIdentifier2.is = is;
  1299. })(ChangeAnnotationIdentifier || (ChangeAnnotationIdentifier = {}));
  1300. var AnnotatedTextEdit;
  1301. (function(AnnotatedTextEdit2) {
  1302. function replace(range, newText, annotation) {
  1303. return { range, newText, annotationId: annotation };
  1304. }
  1305. AnnotatedTextEdit2.replace = replace;
  1306. function insert(position, newText, annotation) {
  1307. return { range: { start: position, end: position }, newText, annotationId: annotation };
  1308. }
  1309. AnnotatedTextEdit2.insert = insert;
  1310. function del(range, annotation) {
  1311. return { range, newText: "", annotationId: annotation };
  1312. }
  1313. AnnotatedTextEdit2.del = del;
  1314. function is(value) {
  1315. var candidate = value;
  1316. return TextEdit.is(candidate) && (ChangeAnnotation.is(candidate.annotationId) || ChangeAnnotationIdentifier.is(candidate.annotationId));
  1317. }
  1318. AnnotatedTextEdit2.is = is;
  1319. })(AnnotatedTextEdit || (AnnotatedTextEdit = {}));
  1320. var TextDocumentEdit;
  1321. (function(TextDocumentEdit2) {
  1322. function create2(textDocument, edits) {
  1323. return { textDocument, edits };
  1324. }
  1325. TextDocumentEdit2.create = create2;
  1326. function is(value) {
  1327. var candidate = value;
  1328. return Is.defined(candidate) && OptionalVersionedTextDocumentIdentifier.is(candidate.textDocument) && Array.isArray(candidate.edits);
  1329. }
  1330. TextDocumentEdit2.is = is;
  1331. })(TextDocumentEdit || (TextDocumentEdit = {}));
  1332. var CreateFile;
  1333. (function(CreateFile2) {
  1334. function create2(uri, options, annotation) {
  1335. var result = {
  1336. kind: "create",
  1337. uri
  1338. };
  1339. if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
  1340. result.options = options;
  1341. }
  1342. if (annotation !== void 0) {
  1343. result.annotationId = annotation;
  1344. }
  1345. return result;
  1346. }
  1347. CreateFile2.create = create2;
  1348. function is(value) {
  1349. var candidate = value;
  1350. return candidate && candidate.kind === "create" && Is.string(candidate.uri) && (candidate.options === void 0 || (candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))) && (candidate.annotationId === void 0 || ChangeAnnotationIdentifier.is(candidate.annotationId));
  1351. }
  1352. CreateFile2.is = is;
  1353. })(CreateFile || (CreateFile = {}));
  1354. var RenameFile;
  1355. (function(RenameFile2) {
  1356. function create2(oldUri, newUri, options, annotation) {
  1357. var result = {
  1358. kind: "rename",
  1359. oldUri,
  1360. newUri
  1361. };
  1362. if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
  1363. result.options = options;
  1364. }
  1365. if (annotation !== void 0) {
  1366. result.annotationId = annotation;
  1367. }
  1368. return result;
  1369. }
  1370. RenameFile2.create = create2;
  1371. function is(value) {
  1372. var candidate = value;
  1373. return candidate && candidate.kind === "rename" && Is.string(candidate.oldUri) && Is.string(candidate.newUri) && (candidate.options === void 0 || (candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))) && (candidate.annotationId === void 0 || ChangeAnnotationIdentifier.is(candidate.annotationId));
  1374. }
  1375. RenameFile2.is = is;
  1376. })(RenameFile || (RenameFile = {}));
  1377. var DeleteFile;
  1378. (function(DeleteFile2) {
  1379. function create2(uri, options, annotation) {
  1380. var result = {
  1381. kind: "delete",
  1382. uri
  1383. };
  1384. if (options !== void 0 && (options.recursive !== void 0 || options.ignoreIfNotExists !== void 0)) {
  1385. result.options = options;
  1386. }
  1387. if (annotation !== void 0) {
  1388. result.annotationId = annotation;
  1389. }
  1390. return result;
  1391. }
  1392. DeleteFile2.create = create2;
  1393. function is(value) {
  1394. var candidate = value;
  1395. return candidate && candidate.kind === "delete" && Is.string(candidate.uri) && (candidate.options === void 0 || (candidate.options.recursive === void 0 || Is.boolean(candidate.options.recursive)) && (candidate.options.ignoreIfNotExists === void 0 || Is.boolean(candidate.options.ignoreIfNotExists))) && (candidate.annotationId === void 0 || ChangeAnnotationIdentifier.is(candidate.annotationId));
  1396. }
  1397. DeleteFile2.is = is;
  1398. })(DeleteFile || (DeleteFile = {}));
  1399. var WorkspaceEdit;
  1400. (function(WorkspaceEdit2) {
  1401. function is(value) {
  1402. var candidate = value;
  1403. return candidate && (candidate.changes !== void 0 || candidate.documentChanges !== void 0) && (candidate.documentChanges === void 0 || candidate.documentChanges.every(function(change) {
  1404. if (Is.string(change.kind)) {
  1405. return CreateFile.is(change) || RenameFile.is(change) || DeleteFile.is(change);
  1406. } else {
  1407. return TextDocumentEdit.is(change);
  1408. }
  1409. }));
  1410. }
  1411. WorkspaceEdit2.is = is;
  1412. })(WorkspaceEdit || (WorkspaceEdit = {}));
  1413. var TextEditChangeImpl = function() {
  1414. function TextEditChangeImpl2(edits, changeAnnotations) {
  1415. this.edits = edits;
  1416. this.changeAnnotations = changeAnnotations;
  1417. }
  1418. TextEditChangeImpl2.prototype.insert = function(position, newText, annotation) {
  1419. var edit2;
  1420. var id;
  1421. if (annotation === void 0) {
  1422. edit2 = TextEdit.insert(position, newText);
  1423. } else if (ChangeAnnotationIdentifier.is(annotation)) {
  1424. id = annotation;
  1425. edit2 = AnnotatedTextEdit.insert(position, newText, annotation);
  1426. } else {
  1427. this.assertChangeAnnotations(this.changeAnnotations);
  1428. id = this.changeAnnotations.manage(annotation);
  1429. edit2 = AnnotatedTextEdit.insert(position, newText, id);
  1430. }
  1431. this.edits.push(edit2);
  1432. if (id !== void 0) {
  1433. return id;
  1434. }
  1435. };
  1436. TextEditChangeImpl2.prototype.replace = function(range, newText, annotation) {
  1437. var edit2;
  1438. var id;
  1439. if (annotation === void 0) {
  1440. edit2 = TextEdit.replace(range, newText);
  1441. } else if (ChangeAnnotationIdentifier.is(annotation)) {
  1442. id = annotation;
  1443. edit2 = AnnotatedTextEdit.replace(range, newText, annotation);
  1444. } else {
  1445. this.assertChangeAnnotations(this.changeAnnotations);
  1446. id = this.changeAnnotations.manage(annotation);
  1447. edit2 = AnnotatedTextEdit.replace(range, newText, id);
  1448. }
  1449. this.edits.push(edit2);
  1450. if (id !== void 0) {
  1451. return id;
  1452. }
  1453. };
  1454. TextEditChangeImpl2.prototype.delete = function(range, annotation) {
  1455. var edit2;
  1456. var id;
  1457. if (annotation === void 0) {
  1458. edit2 = TextEdit.del(range);
  1459. } else if (ChangeAnnotationIdentifier.is(annotation)) {
  1460. id = annotation;
  1461. edit2 = AnnotatedTextEdit.del(range, annotation);
  1462. } else {
  1463. this.assertChangeAnnotations(this.changeAnnotations);
  1464. id = this.changeAnnotations.manage(annotation);
  1465. edit2 = AnnotatedTextEdit.del(range, id);
  1466. }
  1467. this.edits.push(edit2);
  1468. if (id !== void 0) {
  1469. return id;
  1470. }
  1471. };
  1472. TextEditChangeImpl2.prototype.add = function(edit2) {
  1473. this.edits.push(edit2);
  1474. };
  1475. TextEditChangeImpl2.prototype.all = function() {
  1476. return this.edits;
  1477. };
  1478. TextEditChangeImpl2.prototype.clear = function() {
  1479. this.edits.splice(0, this.edits.length);
  1480. };
  1481. TextEditChangeImpl2.prototype.assertChangeAnnotations = function(value) {
  1482. if (value === void 0) {
  1483. throw new Error("Text edit change is not configured to manage change annotations.");
  1484. }
  1485. };
  1486. return TextEditChangeImpl2;
  1487. }();
  1488. var ChangeAnnotations = function() {
  1489. function ChangeAnnotations2(annotations) {
  1490. this._annotations = annotations === void 0 ? Object.create(null) : annotations;
  1491. this._counter = 0;
  1492. this._size = 0;
  1493. }
  1494. ChangeAnnotations2.prototype.all = function() {
  1495. return this._annotations;
  1496. };
  1497. Object.defineProperty(ChangeAnnotations2.prototype, "size", {
  1498. get: function() {
  1499. return this._size;
  1500. },
  1501. enumerable: false,
  1502. configurable: true
  1503. });
  1504. ChangeAnnotations2.prototype.manage = function(idOrAnnotation, annotation) {
  1505. var id;
  1506. if (ChangeAnnotationIdentifier.is(idOrAnnotation)) {
  1507. id = idOrAnnotation;
  1508. } else {
  1509. id = this.nextId();
  1510. annotation = idOrAnnotation;
  1511. }
  1512. if (this._annotations[id] !== void 0) {
  1513. throw new Error("Id " + id + " is already in use.");
  1514. }
  1515. if (annotation === void 0) {
  1516. throw new Error("No annotation provided for id " + id);
  1517. }
  1518. this._annotations[id] = annotation;
  1519. this._size++;
  1520. return id;
  1521. };
  1522. ChangeAnnotations2.prototype.nextId = function() {
  1523. this._counter++;
  1524. return this._counter.toString();
  1525. };
  1526. return ChangeAnnotations2;
  1527. }();
  1528. var WorkspaceChange = function() {
  1529. function WorkspaceChange2(workspaceEdit) {
  1530. var _this = this;
  1531. this._textEditChanges = Object.create(null);
  1532. if (workspaceEdit !== void 0) {
  1533. this._workspaceEdit = workspaceEdit;
  1534. if (workspaceEdit.documentChanges) {
  1535. this._changeAnnotations = new ChangeAnnotations(workspaceEdit.changeAnnotations);
  1536. workspaceEdit.changeAnnotations = this._changeAnnotations.all();
  1537. workspaceEdit.documentChanges.forEach(function(change) {
  1538. if (TextDocumentEdit.is(change)) {
  1539. var textEditChange = new TextEditChangeImpl(change.edits, _this._changeAnnotations);
  1540. _this._textEditChanges[change.textDocument.uri] = textEditChange;
  1541. }
  1542. });
  1543. } else if (workspaceEdit.changes) {
  1544. Object.keys(workspaceEdit.changes).forEach(function(key) {
  1545. var textEditChange = new TextEditChangeImpl(workspaceEdit.changes[key]);
  1546. _this._textEditChanges[key] = textEditChange;
  1547. });
  1548. }
  1549. } else {
  1550. this._workspaceEdit = {};
  1551. }
  1552. }
  1553. Object.defineProperty(WorkspaceChange2.prototype, "edit", {
  1554. get: function() {
  1555. this.initDocumentChanges();
  1556. if (this._changeAnnotations !== void 0) {
  1557. if (this._changeAnnotations.size === 0) {
  1558. this._workspaceEdit.changeAnnotations = void 0;
  1559. } else {
  1560. this._workspaceEdit.changeAnnotations = this._changeAnnotations.all();
  1561. }
  1562. }
  1563. return this._workspaceEdit;
  1564. },
  1565. enumerable: false,
  1566. configurable: true
  1567. });
  1568. WorkspaceChange2.prototype.getTextEditChange = function(key) {
  1569. if (OptionalVersionedTextDocumentIdentifier.is(key)) {
  1570. this.initDocumentChanges();
  1571. if (this._workspaceEdit.documentChanges === void 0) {
  1572. throw new Error("Workspace edit is not configured for document changes.");
  1573. }
  1574. var textDocument = { uri: key.uri, version: key.version };
  1575. var result = this._textEditChanges[textDocument.uri];
  1576. if (!result) {
  1577. var edits = [];
  1578. var textDocumentEdit = {
  1579. textDocument,
  1580. edits
  1581. };
  1582. this._workspaceEdit.documentChanges.push(textDocumentEdit);
  1583. result = new TextEditChangeImpl(edits, this._changeAnnotations);
  1584. this._textEditChanges[textDocument.uri] = result;
  1585. }
  1586. return result;
  1587. } else {
  1588. this.initChanges();
  1589. if (this._workspaceEdit.changes === void 0) {
  1590. throw new Error("Workspace edit is not configured for normal text edit changes.");
  1591. }
  1592. var result = this._textEditChanges[key];
  1593. if (!result) {
  1594. var edits = [];
  1595. this._workspaceEdit.changes[key] = edits;
  1596. result = new TextEditChangeImpl(edits);
  1597. this._textEditChanges[key] = result;
  1598. }
  1599. return result;
  1600. }
  1601. };
  1602. WorkspaceChange2.prototype.initDocumentChanges = function() {
  1603. if (this._workspaceEdit.documentChanges === void 0 && this._workspaceEdit.changes === void 0) {
  1604. this._changeAnnotations = new ChangeAnnotations();
  1605. this._workspaceEdit.documentChanges = [];
  1606. this._workspaceEdit.changeAnnotations = this._changeAnnotations.all();
  1607. }
  1608. };
  1609. WorkspaceChange2.prototype.initChanges = function() {
  1610. if (this._workspaceEdit.documentChanges === void 0 && this._workspaceEdit.changes === void 0) {
  1611. this._workspaceEdit.changes = Object.create(null);
  1612. }
  1613. };
  1614. WorkspaceChange2.prototype.createFile = function(uri, optionsOrAnnotation, options) {
  1615. this.initDocumentChanges();
  1616. if (this._workspaceEdit.documentChanges === void 0) {
  1617. throw new Error("Workspace edit is not configured for document changes.");
  1618. }
  1619. var annotation;
  1620. if (ChangeAnnotation.is(optionsOrAnnotation) || ChangeAnnotationIdentifier.is(optionsOrAnnotation)) {
  1621. annotation = optionsOrAnnotation;
  1622. } else {
  1623. options = optionsOrAnnotation;
  1624. }
  1625. var operation;
  1626. var id;
  1627. if (annotation === void 0) {
  1628. operation = CreateFile.create(uri, options);
  1629. } else {
  1630. id = ChangeAnnotationIdentifier.is(annotation) ? annotation : this._changeAnnotations.manage(annotation);
  1631. operation = CreateFile.create(uri, options, id);
  1632. }
  1633. this._workspaceEdit.documentChanges.push(operation);
  1634. if (id !== void 0) {
  1635. return id;
  1636. }
  1637. };
  1638. WorkspaceChange2.prototype.renameFile = function(oldUri, newUri, optionsOrAnnotation, options) {
  1639. this.initDocumentChanges();
  1640. if (this._workspaceEdit.documentChanges === void 0) {
  1641. throw new Error("Workspace edit is not configured for document changes.");
  1642. }
  1643. var annotation;
  1644. if (ChangeAnnotation.is(optionsOrAnnotation) || ChangeAnnotationIdentifier.is(optionsOrAnnotation)) {
  1645. annotation = optionsOrAnnotation;
  1646. } else {
  1647. options = optionsOrAnnotation;
  1648. }
  1649. var operation;
  1650. var id;
  1651. if (annotation === void 0) {
  1652. operation = RenameFile.create(oldUri, newUri, options);
  1653. } else {
  1654. id = ChangeAnnotationIdentifier.is(annotation) ? annotation : this._changeAnnotations.manage(annotation);
  1655. operation = RenameFile.create(oldUri, newUri, options, id);
  1656. }
  1657. this._workspaceEdit.documentChanges.push(operation);
  1658. if (id !== void 0) {
  1659. return id;
  1660. }
  1661. };
  1662. WorkspaceChange2.prototype.deleteFile = function(uri, optionsOrAnnotation, options) {
  1663. this.initDocumentChanges();
  1664. if (this._workspaceEdit.documentChanges === void 0) {
  1665. throw new Error("Workspace edit is not configured for document changes.");
  1666. }
  1667. var annotation;
  1668. if (ChangeAnnotation.is(optionsOrAnnotation) || ChangeAnnotationIdentifier.is(optionsOrAnnotation)) {
  1669. annotation = optionsOrAnnotation;
  1670. } else {
  1671. options = optionsOrAnnotation;
  1672. }
  1673. var operation;
  1674. var id;
  1675. if (annotation === void 0) {
  1676. operation = DeleteFile.create(uri, options);
  1677. } else {
  1678. id = ChangeAnnotationIdentifier.is(annotation) ? annotation : this._changeAnnotations.manage(annotation);
  1679. operation = DeleteFile.create(uri, options, id);
  1680. }
  1681. this._workspaceEdit.documentChanges.push(operation);
  1682. if (id !== void 0) {
  1683. return id;
  1684. }
  1685. };
  1686. return WorkspaceChange2;
  1687. }();
  1688. var TextDocumentIdentifier;
  1689. (function(TextDocumentIdentifier2) {
  1690. function create2(uri) {
  1691. return { uri };
  1692. }
  1693. TextDocumentIdentifier2.create = create2;
  1694. function is(value) {
  1695. var candidate = value;
  1696. return Is.defined(candidate) && Is.string(candidate.uri);
  1697. }
  1698. TextDocumentIdentifier2.is = is;
  1699. })(TextDocumentIdentifier || (TextDocumentIdentifier = {}));
  1700. var VersionedTextDocumentIdentifier;
  1701. (function(VersionedTextDocumentIdentifier2) {
  1702. function create2(uri, version) {
  1703. return { uri, version };
  1704. }
  1705. VersionedTextDocumentIdentifier2.create = create2;
  1706. function is(value) {
  1707. var candidate = value;
  1708. return Is.defined(candidate) && Is.string(candidate.uri) && Is.integer(candidate.version);
  1709. }
  1710. VersionedTextDocumentIdentifier2.is = is;
  1711. })(VersionedTextDocumentIdentifier || (VersionedTextDocumentIdentifier = {}));
  1712. var OptionalVersionedTextDocumentIdentifier;
  1713. (function(OptionalVersionedTextDocumentIdentifier2) {
  1714. function create2(uri, version) {
  1715. return { uri, version };
  1716. }
  1717. OptionalVersionedTextDocumentIdentifier2.create = create2;
  1718. function is(value) {
  1719. var candidate = value;
  1720. return Is.defined(candidate) && Is.string(candidate.uri) && (candidate.version === null || Is.integer(candidate.version));
  1721. }
  1722. OptionalVersionedTextDocumentIdentifier2.is = is;
  1723. })(OptionalVersionedTextDocumentIdentifier || (OptionalVersionedTextDocumentIdentifier = {}));
  1724. var TextDocumentItem;
  1725. (function(TextDocumentItem2) {
  1726. function create2(uri, languageId, version, text) {
  1727. return { uri, languageId, version, text };
  1728. }
  1729. TextDocumentItem2.create = create2;
  1730. function is(value) {
  1731. var candidate = value;
  1732. return Is.defined(candidate) && Is.string(candidate.uri) && Is.string(candidate.languageId) && Is.integer(candidate.version) && Is.string(candidate.text);
  1733. }
  1734. TextDocumentItem2.is = is;
  1735. })(TextDocumentItem || (TextDocumentItem = {}));
  1736. var MarkupKind;
  1737. (function(MarkupKind2) {
  1738. MarkupKind2.PlainText = "plaintext";
  1739. MarkupKind2.Markdown = "markdown";
  1740. })(MarkupKind || (MarkupKind = {}));
  1741. (function(MarkupKind2) {
  1742. function is(value) {
  1743. var candidate = value;
  1744. return candidate === MarkupKind2.PlainText || candidate === MarkupKind2.Markdown;
  1745. }
  1746. MarkupKind2.is = is;
  1747. })(MarkupKind || (MarkupKind = {}));
  1748. var MarkupContent;
  1749. (function(MarkupContent2) {
  1750. function is(value) {
  1751. var candidate = value;
  1752. return Is.objectLiteral(value) && MarkupKind.is(candidate.kind) && Is.string(candidate.value);
  1753. }
  1754. MarkupContent2.is = is;
  1755. })(MarkupContent || (MarkupContent = {}));
  1756. var CompletionItemKind;
  1757. (function(CompletionItemKind2) {
  1758. CompletionItemKind2.Text = 1;
  1759. CompletionItemKind2.Method = 2;
  1760. CompletionItemKind2.Function = 3;
  1761. CompletionItemKind2.Constructor = 4;
  1762. CompletionItemKind2.Field = 5;
  1763. CompletionItemKind2.Variable = 6;
  1764. CompletionItemKind2.Class = 7;
  1765. CompletionItemKind2.Interface = 8;
  1766. CompletionItemKind2.Module = 9;
  1767. CompletionItemKind2.Property = 10;
  1768. CompletionItemKind2.Unit = 11;
  1769. CompletionItemKind2.Value = 12;
  1770. CompletionItemKind2.Enum = 13;
  1771. CompletionItemKind2.Keyword = 14;
  1772. CompletionItemKind2.Snippet = 15;
  1773. CompletionItemKind2.Color = 16;
  1774. CompletionItemKind2.File = 17;
  1775. CompletionItemKind2.Reference = 18;
  1776. CompletionItemKind2.Folder = 19;
  1777. CompletionItemKind2.EnumMember = 20;
  1778. CompletionItemKind2.Constant = 21;
  1779. CompletionItemKind2.Struct = 22;
  1780. CompletionItemKind2.Event = 23;
  1781. CompletionItemKind2.Operator = 24;
  1782. CompletionItemKind2.TypeParameter = 25;
  1783. })(CompletionItemKind || (CompletionItemKind = {}));
  1784. var InsertTextFormat;
  1785. (function(InsertTextFormat2) {
  1786. InsertTextFormat2.PlainText = 1;
  1787. InsertTextFormat2.Snippet = 2;
  1788. })(InsertTextFormat || (InsertTextFormat = {}));
  1789. var CompletionItemTag;
  1790. (function(CompletionItemTag2) {
  1791. CompletionItemTag2.Deprecated = 1;
  1792. })(CompletionItemTag || (CompletionItemTag = {}));
  1793. var InsertReplaceEdit;
  1794. (function(InsertReplaceEdit2) {
  1795. function create2(newText, insert, replace) {
  1796. return { newText, insert, replace };
  1797. }
  1798. InsertReplaceEdit2.create = create2;
  1799. function is(value) {
  1800. var candidate = value;
  1801. return candidate && Is.string(candidate.newText) && Range.is(candidate.insert) && Range.is(candidate.replace);
  1802. }
  1803. InsertReplaceEdit2.is = is;
  1804. })(InsertReplaceEdit || (InsertReplaceEdit = {}));
  1805. var InsertTextMode;
  1806. (function(InsertTextMode2) {
  1807. InsertTextMode2.asIs = 1;
  1808. InsertTextMode2.adjustIndentation = 2;
  1809. })(InsertTextMode || (InsertTextMode = {}));
  1810. var CompletionItem;
  1811. (function(CompletionItem2) {
  1812. function create2(label) {
  1813. return { label };
  1814. }
  1815. CompletionItem2.create = create2;
  1816. })(CompletionItem || (CompletionItem = {}));
  1817. var CompletionList;
  1818. (function(CompletionList2) {
  1819. function create2(items, isIncomplete) {
  1820. return { items: items ? items : [], isIncomplete: !!isIncomplete };
  1821. }
  1822. CompletionList2.create = create2;
  1823. })(CompletionList || (CompletionList = {}));
  1824. var MarkedString;
  1825. (function(MarkedString2) {
  1826. function fromPlainText(plainText) {
  1827. return plainText.replace(/[\\`*_{}[\]()#+\-.!]/g, "\\$&");
  1828. }
  1829. MarkedString2.fromPlainText = fromPlainText;
  1830. function is(value) {
  1831. var candidate = value;
  1832. return Is.string(candidate) || Is.objectLiteral(candidate) && Is.string(candidate.language) && Is.string(candidate.value);
  1833. }
  1834. MarkedString2.is = is;
  1835. })(MarkedString || (MarkedString = {}));
  1836. var Hover;
  1837. (function(Hover2) {
  1838. function is(value) {
  1839. var candidate = value;
  1840. return !!candidate && Is.objectLiteral(candidate) && (MarkupContent.is(candidate.contents) || MarkedString.is(candidate.contents) || Is.typedArray(candidate.contents, MarkedString.is)) && (value.range === void 0 || Range.is(value.range));
  1841. }
  1842. Hover2.is = is;
  1843. })(Hover || (Hover = {}));
  1844. var ParameterInformation;
  1845. (function(ParameterInformation2) {
  1846. function create2(label, documentation) {
  1847. return documentation ? { label, documentation } : { label };
  1848. }
  1849. ParameterInformation2.create = create2;
  1850. })(ParameterInformation || (ParameterInformation = {}));
  1851. var SignatureInformation;
  1852. (function(SignatureInformation2) {
  1853. function create2(label, documentation) {
  1854. var parameters = [];
  1855. for (var _i = 2; _i < arguments.length; _i++) {
  1856. parameters[_i - 2] = arguments[_i];
  1857. }
  1858. var result = { label };
  1859. if (Is.defined(documentation)) {
  1860. result.documentation = documentation;
  1861. }
  1862. if (Is.defined(parameters)) {
  1863. result.parameters = parameters;
  1864. } else {
  1865. result.parameters = [];
  1866. }
  1867. return result;
  1868. }
  1869. SignatureInformation2.create = create2;
  1870. })(SignatureInformation || (SignatureInformation = {}));
  1871. var DocumentHighlightKind;
  1872. (function(DocumentHighlightKind2) {
  1873. DocumentHighlightKind2.Text = 1;
  1874. DocumentHighlightKind2.Read = 2;
  1875. DocumentHighlightKind2.Write = 3;
  1876. })(DocumentHighlightKind || (DocumentHighlightKind = {}));
  1877. var DocumentHighlight;
  1878. (function(DocumentHighlight2) {
  1879. function create2(range, kind) {
  1880. var result = { range };
  1881. if (Is.number(kind)) {
  1882. result.kind = kind;
  1883. }
  1884. return result;
  1885. }
  1886. DocumentHighlight2.create = create2;
  1887. })(DocumentHighlight || (DocumentHighlight = {}));
  1888. var SymbolKind;
  1889. (function(SymbolKind2) {
  1890. SymbolKind2.File = 1;
  1891. SymbolKind2.Module = 2;
  1892. SymbolKind2.Namespace = 3;
  1893. SymbolKind2.Package = 4;
  1894. SymbolKind2.Class = 5;
  1895. SymbolKind2.Method = 6;
  1896. SymbolKind2.Property = 7;
  1897. SymbolKind2.Field = 8;
  1898. SymbolKind2.Constructor = 9;
  1899. SymbolKind2.Enum = 10;
  1900. SymbolKind2.Interface = 11;
  1901. SymbolKind2.Function = 12;
  1902. SymbolKind2.Variable = 13;
  1903. SymbolKind2.Constant = 14;
  1904. SymbolKind2.String = 15;
  1905. SymbolKind2.Number = 16;
  1906. SymbolKind2.Boolean = 17;
  1907. SymbolKind2.Array = 18;
  1908. SymbolKind2.Object = 19;
  1909. SymbolKind2.Key = 20;
  1910. SymbolKind2.Null = 21;
  1911. SymbolKind2.EnumMember = 22;
  1912. SymbolKind2.Struct = 23;
  1913. SymbolKind2.Event = 24;
  1914. SymbolKind2.Operator = 25;
  1915. SymbolKind2.TypeParameter = 26;
  1916. })(SymbolKind || (SymbolKind = {}));
  1917. var SymbolTag;
  1918. (function(SymbolTag2) {
  1919. SymbolTag2.Deprecated = 1;
  1920. })(SymbolTag || (SymbolTag = {}));
  1921. var SymbolInformation;
  1922. (function(SymbolInformation2) {
  1923. function create2(name, kind, range, uri, containerName) {
  1924. var result = {
  1925. name,
  1926. kind,
  1927. location: { uri, range }
  1928. };
  1929. if (containerName) {
  1930. result.containerName = containerName;
  1931. }
  1932. return result;
  1933. }
  1934. SymbolInformation2.create = create2;
  1935. })(SymbolInformation || (SymbolInformation = {}));
  1936. var DocumentSymbol;
  1937. (function(DocumentSymbol2) {
  1938. function create2(name, detail, kind, range, selectionRange, children) {
  1939. var result = {
  1940. name,
  1941. detail,
  1942. kind,
  1943. range,
  1944. selectionRange
  1945. };
  1946. if (children !== void 0) {
  1947. result.children = children;
  1948. }
  1949. return result;
  1950. }
  1951. DocumentSymbol2.create = create2;
  1952. function is(value) {
  1953. var candidate = value;
  1954. return candidate && Is.string(candidate.name) && Is.number(candidate.kind) && Range.is(candidate.range) && Range.is(candidate.selectionRange) && (candidate.detail === void 0 || Is.string(candidate.detail)) && (candidate.deprecated === void 0 || Is.boolean(candidate.deprecated)) && (candidate.children === void 0 || Array.isArray(candidate.children)) && (candidate.tags === void 0 || Array.isArray(candidate.tags));
  1955. }
  1956. DocumentSymbol2.is = is;
  1957. })(DocumentSymbol || (DocumentSymbol = {}));
  1958. var CodeActionKind;
  1959. (function(CodeActionKind2) {
  1960. CodeActionKind2.Empty = "";
  1961. CodeActionKind2.QuickFix = "quickfix";
  1962. CodeActionKind2.Refactor = "refactor";
  1963. CodeActionKind2.RefactorExtract = "refactor.extract";
  1964. CodeActionKind2.RefactorInline = "refactor.inline";
  1965. CodeActionKind2.RefactorRewrite = "refactor.rewrite";
  1966. CodeActionKind2.Source = "source";
  1967. CodeActionKind2.SourceOrganizeImports = "source.organizeImports";
  1968. CodeActionKind2.SourceFixAll = "source.fixAll";
  1969. })(CodeActionKind || (CodeActionKind = {}));
  1970. var CodeActionContext;
  1971. (function(CodeActionContext2) {
  1972. function create2(diagnostics, only) {
  1973. var result = { diagnostics };
  1974. if (only !== void 0 && only !== null) {
  1975. result.only = only;
  1976. }
  1977. return result;
  1978. }
  1979. CodeActionContext2.create = create2;
  1980. function is(value) {
  1981. var candidate = value;
  1982. return Is.defined(candidate) && Is.typedArray(candidate.diagnostics, Diagnostic.is) && (candidate.only === void 0 || Is.typedArray(candidate.only, Is.string));
  1983. }
  1984. CodeActionContext2.is = is;
  1985. })(CodeActionContext || (CodeActionContext = {}));
  1986. var CodeAction;
  1987. (function(CodeAction2) {
  1988. function create2(title, kindOrCommandOrEdit, kind) {
  1989. var result = { title };
  1990. var checkKind = true;
  1991. if (typeof kindOrCommandOrEdit === "string") {
  1992. checkKind = false;
  1993. result.kind = kindOrCommandOrEdit;
  1994. } else if (Command.is(kindOrCommandOrEdit)) {
  1995. result.command = kindOrCommandOrEdit;
  1996. } else {
  1997. result.edit = kindOrCommandOrEdit;
  1998. }
  1999. if (checkKind && kind !== void 0) {
  2000. result.kind = kind;
  2001. }
  2002. return result;
  2003. }
  2004. CodeAction2.create = create2;
  2005. function is(value) {
  2006. var candidate = value;
  2007. return candidate && Is.string(candidate.title) && (candidate.diagnostics === void 0 || Is.typedArray(candidate.diagnostics, Diagnostic.is)) && (candidate.kind === void 0 || Is.string(candidate.kind)) && (candidate.edit !== void 0 || candidate.command !== void 0) && (candidate.command === void 0 || Command.is(candidate.command)) && (candidate.isPreferred === void 0 || Is.boolean(candidate.isPreferred)) && (candidate.edit === void 0 || WorkspaceEdit.is(candidate.edit));
  2008. }
  2009. CodeAction2.is = is;
  2010. })(CodeAction || (CodeAction = {}));
  2011. var CodeLens;
  2012. (function(CodeLens2) {
  2013. function create2(range, data) {
  2014. var result = { range };
  2015. if (Is.defined(data)) {
  2016. result.data = data;
  2017. }
  2018. return result;
  2019. }
  2020. CodeLens2.create = create2;
  2021. function is(value) {
  2022. var candidate = value;
  2023. return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.command) || Command.is(candidate.command));
  2024. }
  2025. CodeLens2.is = is;
  2026. })(CodeLens || (CodeLens = {}));
  2027. var FormattingOptions;
  2028. (function(FormattingOptions2) {
  2029. function create2(tabSize, insertSpaces) {
  2030. return { tabSize, insertSpaces };
  2031. }
  2032. FormattingOptions2.create = create2;
  2033. function is(value) {
  2034. var candidate = value;
  2035. return Is.defined(candidate) && Is.uinteger(candidate.tabSize) && Is.boolean(candidate.insertSpaces);
  2036. }
  2037. FormattingOptions2.is = is;
  2038. })(FormattingOptions || (FormattingOptions = {}));
  2039. var DocumentLink;
  2040. (function(DocumentLink2) {
  2041. function create2(range, target, data) {
  2042. return { range, target, data };
  2043. }
  2044. DocumentLink2.create = create2;
  2045. function is(value) {
  2046. var candidate = value;
  2047. return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.target) || Is.string(candidate.target));
  2048. }
  2049. DocumentLink2.is = is;
  2050. })(DocumentLink || (DocumentLink = {}));
  2051. var SelectionRange;
  2052. (function(SelectionRange2) {
  2053. function create2(range, parent) {
  2054. return { range, parent };
  2055. }
  2056. SelectionRange2.create = create2;
  2057. function is(value) {
  2058. var candidate = value;
  2059. return candidate !== void 0 && Range.is(candidate.range) && (candidate.parent === void 0 || SelectionRange2.is(candidate.parent));
  2060. }
  2061. SelectionRange2.is = is;
  2062. })(SelectionRange || (SelectionRange = {}));
  2063. var TextDocument;
  2064. (function(TextDocument3) {
  2065. function create2(uri, languageId, version, content) {
  2066. return new FullTextDocument(uri, languageId, version, content);
  2067. }
  2068. TextDocument3.create = create2;
  2069. function is(value) {
  2070. var candidate = value;
  2071. return Is.defined(candidate) && Is.string(candidate.uri) && (Is.undefined(candidate.languageId) || Is.string(candidate.languageId)) && Is.uinteger(candidate.lineCount) && Is.func(candidate.getText) && Is.func(candidate.positionAt) && Is.func(candidate.offsetAt) ? true : false;
  2072. }
  2073. TextDocument3.is = is;
  2074. function applyEdits(document, edits) {
  2075. var text = document.getText();
  2076. var sortedEdits = mergeSort2(edits, function(a2, b) {
  2077. var diff = a2.range.start.line - b.range.start.line;
  2078. if (diff === 0) {
  2079. return a2.range.start.character - b.range.start.character;
  2080. }
  2081. return diff;
  2082. });
  2083. var lastModifiedOffset = text.length;
  2084. for (var i = sortedEdits.length - 1; i >= 0; i--) {
  2085. var e = sortedEdits[i];
  2086. var startOffset = document.offsetAt(e.range.start);
  2087. var endOffset = document.offsetAt(e.range.end);
  2088. if (endOffset <= lastModifiedOffset) {
  2089. text = text.substring(0, startOffset) + e.newText + text.substring(endOffset, text.length);
  2090. } else {
  2091. throw new Error("Overlapping edit");
  2092. }
  2093. lastModifiedOffset = startOffset;
  2094. }
  2095. return text;
  2096. }
  2097. TextDocument3.applyEdits = applyEdits;
  2098. function mergeSort2(data, compare) {
  2099. if (data.length <= 1) {
  2100. return data;
  2101. }
  2102. var p = data.length / 2 | 0;
  2103. var left = data.slice(0, p);
  2104. var right = data.slice(p);
  2105. mergeSort2(left, compare);
  2106. mergeSort2(right, compare);
  2107. var leftIdx = 0;
  2108. var rightIdx = 0;
  2109. var i = 0;
  2110. while (leftIdx < left.length && rightIdx < right.length) {
  2111. var ret = compare(left[leftIdx], right[rightIdx]);
  2112. if (ret <= 0) {
  2113. data[i++] = left[leftIdx++];
  2114. } else {
  2115. data[i++] = right[rightIdx++];
  2116. }
  2117. }
  2118. while (leftIdx < left.length) {
  2119. data[i++] = left[leftIdx++];
  2120. }
  2121. while (rightIdx < right.length) {
  2122. data[i++] = right[rightIdx++];
  2123. }
  2124. return data;
  2125. }
  2126. })(TextDocument || (TextDocument = {}));
  2127. var FullTextDocument = function() {
  2128. function FullTextDocument3(uri, languageId, version, content) {
  2129. this._uri = uri;
  2130. this._languageId = languageId;
  2131. this._version = version;
  2132. this._content = content;
  2133. this._lineOffsets = void 0;
  2134. }
  2135. Object.defineProperty(FullTextDocument3.prototype, "uri", {
  2136. get: function() {
  2137. return this._uri;
  2138. },
  2139. enumerable: false,
  2140. configurable: true
  2141. });
  2142. Object.defineProperty(FullTextDocument3.prototype, "languageId", {
  2143. get: function() {
  2144. return this._languageId;
  2145. },
  2146. enumerable: false,
  2147. configurable: true
  2148. });
  2149. Object.defineProperty(FullTextDocument3.prototype, "version", {
  2150. get: function() {
  2151. return this._version;
  2152. },
  2153. enumerable: false,
  2154. configurable: true
  2155. });
  2156. FullTextDocument3.prototype.getText = function(range) {
  2157. if (range) {
  2158. var start = this.offsetAt(range.start);
  2159. var end = this.offsetAt(range.end);
  2160. return this._content.substring(start, end);
  2161. }
  2162. return this._content;
  2163. };
  2164. FullTextDocument3.prototype.update = function(event, version) {
  2165. this._content = event.text;
  2166. this._version = version;
  2167. this._lineOffsets = void 0;
  2168. };
  2169. FullTextDocument3.prototype.getLineOffsets = function() {
  2170. if (this._lineOffsets === void 0) {
  2171. var lineOffsets = [];
  2172. var text = this._content;
  2173. var isLineStart = true;
  2174. for (var i = 0; i < text.length; i++) {
  2175. if (isLineStart) {
  2176. lineOffsets.push(i);
  2177. isLineStart = false;
  2178. }
  2179. var ch = text.charAt(i);
  2180. isLineStart = ch === "\r" || ch === "\n";
  2181. if (ch === "\r" && i + 1 < text.length && text.charAt(i + 1) === "\n") {
  2182. i++;
  2183. }
  2184. }
  2185. if (isLineStart && text.length > 0) {
  2186. lineOffsets.push(text.length);
  2187. }
  2188. this._lineOffsets = lineOffsets;
  2189. }
  2190. return this._lineOffsets;
  2191. };
  2192. FullTextDocument3.prototype.positionAt = function(offset) {
  2193. offset = Math.max(Math.min(offset, this._content.length), 0);
  2194. var lineOffsets = this.getLineOffsets();
  2195. var low = 0, high = lineOffsets.length;
  2196. if (high === 0) {
  2197. return Position.create(0, offset);
  2198. }
  2199. while (low < high) {
  2200. var mid = Math.floor((low + high) / 2);
  2201. if (lineOffsets[mid] > offset) {
  2202. high = mid;
  2203. } else {
  2204. low = mid + 1;
  2205. }
  2206. }
  2207. var line = low - 1;
  2208. return Position.create(line, offset - lineOffsets[line]);
  2209. };
  2210. FullTextDocument3.prototype.offsetAt = function(position) {
  2211. var lineOffsets = this.getLineOffsets();
  2212. if (position.line >= lineOffsets.length) {
  2213. return this._content.length;
  2214. } else if (position.line < 0) {
  2215. return 0;
  2216. }
  2217. var lineOffset = lineOffsets[position.line];
  2218. var nextLineOffset = position.line + 1 < lineOffsets.length ? lineOffsets[position.line + 1] : this._content.length;
  2219. return Math.max(Math.min(lineOffset + position.character, nextLineOffset), lineOffset);
  2220. };
  2221. Object.defineProperty(FullTextDocument3.prototype, "lineCount", {
  2222. get: function() {
  2223. return this.getLineOffsets().length;
  2224. },
  2225. enumerable: false,
  2226. configurable: true
  2227. });
  2228. return FullTextDocument3;
  2229. }();
  2230. var Is;
  2231. (function(Is2) {
  2232. var toString = Object.prototype.toString;
  2233. function defined(value) {
  2234. return typeof value !== "undefined";
  2235. }
  2236. Is2.defined = defined;
  2237. function undefined2(value) {
  2238. return typeof value === "undefined";
  2239. }
  2240. Is2.undefined = undefined2;
  2241. function boolean(value) {
  2242. return value === true || value === false;
  2243. }
  2244. Is2.boolean = boolean;
  2245. function string(value) {
  2246. return toString.call(value) === "[object String]";
  2247. }
  2248. Is2.string = string;
  2249. function number(value) {
  2250. return toString.call(value) === "[object Number]";
  2251. }
  2252. Is2.number = number;
  2253. function numberRange(value, min, max) {
  2254. return toString.call(value) === "[object Number]" && min <= value && value <= max;
  2255. }
  2256. Is2.numberRange = numberRange;
  2257. function integer2(value) {
  2258. return toString.call(value) === "[object Number]" && -2147483648 <= value && value <= 2147483647;
  2259. }
  2260. Is2.integer = integer2;
  2261. function uinteger2(value) {
  2262. return toString.call(value) === "[object Number]" && 0 <= value && value <= 2147483647;
  2263. }
  2264. Is2.uinteger = uinteger2;
  2265. function func(value) {
  2266. return toString.call(value) === "[object Function]";
  2267. }
  2268. Is2.func = func;
  2269. function objectLiteral(value) {
  2270. return value !== null && typeof value === "object";
  2271. }
  2272. Is2.objectLiteral = objectLiteral;
  2273. function typedArray(value, check) {
  2274. return Array.isArray(value) && value.every(check);
  2275. }
  2276. Is2.typedArray = typedArray;
  2277. })(Is || (Is = {}));
  2278. // node_modules/vscode-languageserver-textdocument/lib/esm/main.js
  2279. "use strict";
  2280. var __spreadArray = function(to, from, pack) {
  2281. if (pack || arguments.length === 2)
  2282. for (var i = 0, l = from.length, ar; i < l; i++) {
  2283. if (ar || !(i in from)) {
  2284. if (!ar)
  2285. ar = Array.prototype.slice.call(from, 0, i);
  2286. ar[i] = from[i];
  2287. }
  2288. }
  2289. return to.concat(ar || Array.prototype.slice.call(from));
  2290. };
  2291. var FullTextDocument2 = function() {
  2292. function FullTextDocument3(uri, languageId, version, content) {
  2293. this._uri = uri;
  2294. this._languageId = languageId;
  2295. this._version = version;
  2296. this._content = content;
  2297. this._lineOffsets = void 0;
  2298. }
  2299. Object.defineProperty(FullTextDocument3.prototype, "uri", {
  2300. get: function() {
  2301. return this._uri;
  2302. },
  2303. enumerable: false,
  2304. configurable: true
  2305. });
  2306. Object.defineProperty(FullTextDocument3.prototype, "languageId", {
  2307. get: function() {
  2308. return this._languageId;
  2309. },
  2310. enumerable: false,
  2311. configurable: true
  2312. });
  2313. Object.defineProperty(FullTextDocument3.prototype, "version", {
  2314. get: function() {
  2315. return this._version;
  2316. },
  2317. enumerable: false,
  2318. configurable: true
  2319. });
  2320. FullTextDocument3.prototype.getText = function(range) {
  2321. if (range) {
  2322. var start = this.offsetAt(range.start);
  2323. var end = this.offsetAt(range.end);
  2324. return this._content.substring(start, end);
  2325. }
  2326. return this._content;
  2327. };
  2328. FullTextDocument3.prototype.update = function(changes, version) {
  2329. for (var _i = 0, changes_1 = changes; _i < changes_1.length; _i++) {
  2330. var change = changes_1[_i];
  2331. if (FullTextDocument3.isIncremental(change)) {
  2332. var range = getWellformedRange(change.range);
  2333. var startOffset = this.offsetAt(range.start);
  2334. var endOffset = this.offsetAt(range.end);
  2335. this._content = this._content.substring(0, startOffset) + change.text + this._content.substring(endOffset, this._content.length);
  2336. var startLine = Math.max(range.start.line, 0);
  2337. var endLine = Math.max(range.end.line, 0);
  2338. var lineOffsets = this._lineOffsets;
  2339. var addedLineOffsets = computeLineOffsets(change.text, false, startOffset);
  2340. if (endLine - startLine === addedLineOffsets.length) {
  2341. for (var i = 0, len = addedLineOffsets.length; i < len; i++) {
  2342. lineOffsets[i + startLine + 1] = addedLineOffsets[i];
  2343. }
  2344. } else {
  2345. if (addedLineOffsets.length < 1e4) {
  2346. lineOffsets.splice.apply(lineOffsets, __spreadArray([startLine + 1, endLine - startLine], addedLineOffsets, false));
  2347. } else {
  2348. this._lineOffsets = lineOffsets = lineOffsets.slice(0, startLine + 1).concat(addedLineOffsets, lineOffsets.slice(endLine + 1));
  2349. }
  2350. }
  2351. var diff = change.text.length - (endOffset - startOffset);
  2352. if (diff !== 0) {
  2353. for (var i = startLine + 1 + addedLineOffsets.length, len = lineOffsets.length; i < len; i++) {
  2354. lineOffsets[i] = lineOffsets[i] + diff;
  2355. }
  2356. }
  2357. } else if (FullTextDocument3.isFull(change)) {
  2358. this._content = change.text;
  2359. this._lineOffsets = void 0;
  2360. } else {
  2361. throw new Error("Unknown change event received");
  2362. }
  2363. }
  2364. this._version = version;
  2365. };
  2366. FullTextDocument3.prototype.getLineOffsets = function() {
  2367. if (this._lineOffsets === void 0) {
  2368. this._lineOffsets = computeLineOffsets(this._content, true);
  2369. }
  2370. return this._lineOffsets;
  2371. };
  2372. FullTextDocument3.prototype.positionAt = function(offset) {
  2373. offset = Math.max(Math.min(offset, this._content.length), 0);
  2374. var lineOffsets = this.getLineOffsets();
  2375. var low = 0, high = lineOffsets.length;
  2376. if (high === 0) {
  2377. return { line: 0, character: offset };
  2378. }
  2379. while (low < high) {
  2380. var mid = Math.floor((low + high) / 2);
  2381. if (lineOffsets[mid] > offset) {
  2382. high = mid;
  2383. } else {
  2384. low = mid + 1;
  2385. }
  2386. }
  2387. var line = low - 1;
  2388. return { line, character: offset - lineOffsets[line] };
  2389. };
  2390. FullTextDocument3.prototype.offsetAt = function(position) {
  2391. var lineOffsets = this.getLineOffsets();
  2392. if (position.line >= lineOffsets.length) {
  2393. return this._content.length;
  2394. } else if (position.line < 0) {
  2395. return 0;
  2396. }
  2397. var lineOffset = lineOffsets[position.line];
  2398. var nextLineOffset = position.line + 1 < lineOffsets.length ? lineOffsets[position.line + 1] : this._content.length;
  2399. return Math.max(Math.min(lineOffset + position.character, nextLineOffset), lineOffset);
  2400. };
  2401. Object.defineProperty(FullTextDocument3.prototype, "lineCount", {
  2402. get: function() {
  2403. return this.getLineOffsets().length;
  2404. },
  2405. enumerable: false,
  2406. configurable: true
  2407. });
  2408. FullTextDocument3.isIncremental = function(event) {
  2409. var candidate = event;
  2410. return candidate !== void 0 && candidate !== null && typeof candidate.text === "string" && candidate.range !== void 0 && (candidate.rangeLength === void 0 || typeof candidate.rangeLength === "number");
  2411. };
  2412. FullTextDocument3.isFull = function(event) {
  2413. var candidate = event;
  2414. return candidate !== void 0 && candidate !== null && typeof candidate.text === "string" && candidate.range === void 0 && candidate.rangeLength === void 0;
  2415. };
  2416. return FullTextDocument3;
  2417. }();
  2418. var TextDocument2;
  2419. (function(TextDocument3) {
  2420. function create2(uri, languageId, version, content) {
  2421. return new FullTextDocument2(uri, languageId, version, content);
  2422. }
  2423. TextDocument3.create = create2;
  2424. function update(document, changes, version) {
  2425. if (document instanceof FullTextDocument2) {
  2426. document.update(changes, version);
  2427. return document;
  2428. } else {
  2429. throw new Error("TextDocument.update: document must be created by TextDocument.create");
  2430. }
  2431. }
  2432. TextDocument3.update = update;
  2433. function applyEdits(document, edits) {
  2434. var text = document.getText();
  2435. var sortedEdits = mergeSort(edits.map(getWellformedEdit), function(a2, b) {
  2436. var diff = a2.range.start.line - b.range.start.line;
  2437. if (diff === 0) {
  2438. return a2.range.start.character - b.range.start.character;
  2439. }
  2440. return diff;
  2441. });
  2442. var lastModifiedOffset = 0;
  2443. var spans = [];
  2444. for (var _i = 0, sortedEdits_1 = sortedEdits; _i < sortedEdits_1.length; _i++) {
  2445. var e = sortedEdits_1[_i];
  2446. var startOffset = document.offsetAt(e.range.start);
  2447. if (startOffset < lastModifiedOffset) {
  2448. throw new Error("Overlapping edit");
  2449. } else if (startOffset > lastModifiedOffset) {
  2450. spans.push(text.substring(lastModifiedOffset, startOffset));
  2451. }
  2452. if (e.newText.length) {
  2453. spans.push(e.newText);
  2454. }
  2455. lastModifiedOffset = document.offsetAt(e.range.end);
  2456. }
  2457. spans.push(text.substr(lastModifiedOffset));
  2458. return spans.join("");
  2459. }
  2460. TextDocument3.applyEdits = applyEdits;
  2461. })(TextDocument2 || (TextDocument2 = {}));
  2462. function mergeSort(data, compare) {
  2463. if (data.length <= 1) {
  2464. return data;
  2465. }
  2466. var p = data.length / 2 | 0;
  2467. var left = data.slice(0, p);
  2468. var right = data.slice(p);
  2469. mergeSort(left, compare);
  2470. mergeSort(right, compare);
  2471. var leftIdx = 0;
  2472. var rightIdx = 0;
  2473. var i = 0;
  2474. while (leftIdx < left.length && rightIdx < right.length) {
  2475. var ret = compare(left[leftIdx], right[rightIdx]);
  2476. if (ret <= 0) {
  2477. data[i++] = left[leftIdx++];
  2478. } else {
  2479. data[i++] = right[rightIdx++];
  2480. }
  2481. }
  2482. while (leftIdx < left.length) {
  2483. data[i++] = left[leftIdx++];
  2484. }
  2485. while (rightIdx < right.length) {
  2486. data[i++] = right[rightIdx++];
  2487. }
  2488. return data;
  2489. }
  2490. function computeLineOffsets(text, isAtLineStart, textOffset) {
  2491. if (textOffset === void 0) {
  2492. textOffset = 0;
  2493. }
  2494. var result = isAtLineStart ? [textOffset] : [];
  2495. for (var i = 0; i < text.length; i++) {
  2496. var ch = text.charCodeAt(i);
  2497. if (ch === 13 || ch === 10) {
  2498. if (ch === 13 && i + 1 < text.length && text.charCodeAt(i + 1) === 10) {
  2499. i++;
  2500. }
  2501. result.push(textOffset + i + 1);
  2502. }
  2503. }
  2504. return result;
  2505. }
  2506. function getWellformedRange(range) {
  2507. var start = range.start;
  2508. var end = range.end;
  2509. if (start.line > end.line || start.line === end.line && start.character > end.character) {
  2510. return { start: end, end: start };
  2511. }
  2512. return range;
  2513. }
  2514. function getWellformedEdit(textEdit) {
  2515. var range = getWellformedRange(textEdit.range);
  2516. if (range !== textEdit.range) {
  2517. return { newText: textEdit.newText, range };
  2518. }
  2519. return textEdit;
  2520. }
  2521. // node_modules/vscode-json-languageservice/lib/esm/jsonLanguageTypes.js
  2522. var ErrorCode;
  2523. (function(ErrorCode2) {
  2524. ErrorCode2[ErrorCode2["Undefined"] = 0] = "Undefined";
  2525. ErrorCode2[ErrorCode2["EnumValueMismatch"] = 1] = "EnumValueMismatch";
  2526. ErrorCode2[ErrorCode2["Deprecated"] = 2] = "Deprecated";
  2527. ErrorCode2[ErrorCode2["UnexpectedEndOfComment"] = 257] = "UnexpectedEndOfComment";
  2528. ErrorCode2[ErrorCode2["UnexpectedEndOfString"] = 258] = "UnexpectedEndOfString";
  2529. ErrorCode2[ErrorCode2["UnexpectedEndOfNumber"] = 259] = "UnexpectedEndOfNumber";
  2530. ErrorCode2[ErrorCode2["InvalidUnicode"] = 260] = "InvalidUnicode";
  2531. ErrorCode2[ErrorCode2["InvalidEscapeCharacter"] = 261] = "InvalidEscapeCharacter";
  2532. ErrorCode2[ErrorCode2["InvalidCharacter"] = 262] = "InvalidCharacter";
  2533. ErrorCode2[ErrorCode2["PropertyExpected"] = 513] = "PropertyExpected";
  2534. ErrorCode2[ErrorCode2["CommaExpected"] = 514] = "CommaExpected";
  2535. ErrorCode2[ErrorCode2["ColonExpected"] = 515] = "ColonExpected";
  2536. ErrorCode2[ErrorCode2["ValueExpected"] = 516] = "ValueExpected";
  2537. ErrorCode2[ErrorCode2["CommaOrCloseBacketExpected"] = 517] = "CommaOrCloseBacketExpected";
  2538. ErrorCode2[ErrorCode2["CommaOrCloseBraceExpected"] = 518] = "CommaOrCloseBraceExpected";
  2539. ErrorCode2[ErrorCode2["TrailingComma"] = 519] = "TrailingComma";
  2540. ErrorCode2[ErrorCode2["DuplicateKey"] = 520] = "DuplicateKey";
  2541. ErrorCode2[ErrorCode2["CommentNotPermitted"] = 521] = "CommentNotPermitted";
  2542. ErrorCode2[ErrorCode2["SchemaResolveError"] = 768] = "SchemaResolveError";
  2543. })(ErrorCode || (ErrorCode = {}));
  2544. var ClientCapabilities;
  2545. (function(ClientCapabilities2) {
  2546. ClientCapabilities2.LATEST = {
  2547. textDocument: {
  2548. completion: {
  2549. completionItem: {
  2550. documentationFormat: [MarkupKind.Markdown, MarkupKind.PlainText],
  2551. commitCharactersSupport: true
  2552. }
  2553. }
  2554. }
  2555. };
  2556. })(ClientCapabilities || (ClientCapabilities = {}));
  2557. // build/fillers/vscode-nls.ts
  2558. function format3(message, args) {
  2559. let result;
  2560. if (args.length === 0) {
  2561. result = message;
  2562. } else {
  2563. result = message.replace(/\{(\d+)\}/g, (match, rest) => {
  2564. let index = rest[0];
  2565. return typeof args[index] !== "undefined" ? args[index] : match;
  2566. });
  2567. }
  2568. return result;
  2569. }
  2570. function localize(key, message, ...args) {
  2571. return format3(message, args);
  2572. }
  2573. function loadMessageBundle(file) {
  2574. return localize;
  2575. }
  2576. // node_modules/vscode-json-languageservice/lib/esm/parser/jsonParser.js
  2577. var __extends = function() {
  2578. var extendStatics = function(d, b) {
  2579. extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
  2580. d2.__proto__ = b2;
  2581. } || function(d2, b2) {
  2582. for (var p in b2)
  2583. if (Object.prototype.hasOwnProperty.call(b2, p))
  2584. d2[p] = b2[p];
  2585. };
  2586. return extendStatics(d, b);
  2587. };
  2588. return function(d, b) {
  2589. if (typeof b !== "function" && b !== null)
  2590. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  2591. extendStatics(d, b);
  2592. function __() {
  2593. this.constructor = d;
  2594. }
  2595. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2596. };
  2597. }();
  2598. var localize2 = loadMessageBundle();
  2599. var formats = {
  2600. "color-hex": { errorMessage: localize2("colorHexFormatWarning", "Invalid color format. Use #RGB, #RGBA, #RRGGBB or #RRGGBBAA."), pattern: /^#([0-9A-Fa-f]{3,4}|([0-9A-Fa-f]{2}){3,4})$/ },
  2601. "date-time": { errorMessage: localize2("dateTimeFormatWarning", "String is not a RFC3339 date-time."), pattern: /^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\.[0-9]+)?(Z|(\+|-)([01][0-9]|2[0-3]):([0-5][0-9]))$/i },
  2602. "date": { errorMessage: localize2("dateFormatWarning", "String is not a RFC3339 date."), pattern: /^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/i },
  2603. "time": { errorMessage: localize2("timeFormatWarning", "String is not a RFC3339 time."), pattern: /^([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\.[0-9]+)?(Z|(\+|-)([01][0-9]|2[0-3]):([0-5][0-9]))$/i },
  2604. "email": { errorMessage: localize2("emailFormatWarning", "String is not an e-mail address."), pattern: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ }
  2605. };
  2606. var ASTNodeImpl = function() {
  2607. function ASTNodeImpl2(parent, offset, length) {
  2608. if (length === void 0) {
  2609. length = 0;
  2610. }
  2611. this.offset = offset;
  2612. this.length = length;
  2613. this.parent = parent;
  2614. }
  2615. Object.defineProperty(ASTNodeImpl2.prototype, "children", {
  2616. get: function() {
  2617. return [];
  2618. },
  2619. enumerable: false,
  2620. configurable: true
  2621. });
  2622. ASTNodeImpl2.prototype.toString = function() {
  2623. return "type: " + this.type + " (" + this.offset + "/" + this.length + ")" + (this.parent ? " parent: {" + this.parent.toString() + "}" : "");
  2624. };
  2625. return ASTNodeImpl2;
  2626. }();
  2627. var NullASTNodeImpl = function(_super) {
  2628. __extends(NullASTNodeImpl2, _super);
  2629. function NullASTNodeImpl2(parent, offset) {
  2630. var _this = _super.call(this, parent, offset) || this;
  2631. _this.type = "null";
  2632. _this.value = null;
  2633. return _this;
  2634. }
  2635. return NullASTNodeImpl2;
  2636. }(ASTNodeImpl);
  2637. var BooleanASTNodeImpl = function(_super) {
  2638. __extends(BooleanASTNodeImpl2, _super);
  2639. function BooleanASTNodeImpl2(parent, boolValue, offset) {
  2640. var _this = _super.call(this, parent, offset) || this;
  2641. _this.type = "boolean";
  2642. _this.value = boolValue;
  2643. return _this;
  2644. }
  2645. return BooleanASTNodeImpl2;
  2646. }(ASTNodeImpl);
  2647. var ArrayASTNodeImpl = function(_super) {
  2648. __extends(ArrayASTNodeImpl2, _super);
  2649. function ArrayASTNodeImpl2(parent, offset) {
  2650. var _this = _super.call(this, parent, offset) || this;
  2651. _this.type = "array";
  2652. _this.items = [];
  2653. return _this;
  2654. }
  2655. Object.defineProperty(ArrayASTNodeImpl2.prototype, "children", {
  2656. get: function() {
  2657. return this.items;
  2658. },
  2659. enumerable: false,
  2660. configurable: true
  2661. });
  2662. return ArrayASTNodeImpl2;
  2663. }(ASTNodeImpl);
  2664. var NumberASTNodeImpl = function(_super) {
  2665. __extends(NumberASTNodeImpl2, _super);
  2666. function NumberASTNodeImpl2(parent, offset) {
  2667. var _this = _super.call(this, parent, offset) || this;
  2668. _this.type = "number";
  2669. _this.isInteger = true;
  2670. _this.value = Number.NaN;
  2671. return _this;
  2672. }
  2673. return NumberASTNodeImpl2;
  2674. }(ASTNodeImpl);
  2675. var StringASTNodeImpl = function(_super) {
  2676. __extends(StringASTNodeImpl2, _super);
  2677. function StringASTNodeImpl2(parent, offset, length) {
  2678. var _this = _super.call(this, parent, offset, length) || this;
  2679. _this.type = "string";
  2680. _this.value = "";
  2681. return _this;
  2682. }
  2683. return StringASTNodeImpl2;
  2684. }(ASTNodeImpl);
  2685. var PropertyASTNodeImpl = function(_super) {
  2686. __extends(PropertyASTNodeImpl2, _super);
  2687. function PropertyASTNodeImpl2(parent, offset, keyNode) {
  2688. var _this = _super.call(this, parent, offset) || this;
  2689. _this.type = "property";
  2690. _this.colonOffset = -1;
  2691. _this.keyNode = keyNode;
  2692. return _this;
  2693. }
  2694. Object.defineProperty(PropertyASTNodeImpl2.prototype, "children", {
  2695. get: function() {
  2696. return this.valueNode ? [this.keyNode, this.valueNode] : [this.keyNode];
  2697. },
  2698. enumerable: false,
  2699. configurable: true
  2700. });
  2701. return PropertyASTNodeImpl2;
  2702. }(ASTNodeImpl);
  2703. var ObjectASTNodeImpl = function(_super) {
  2704. __extends(ObjectASTNodeImpl2, _super);
  2705. function ObjectASTNodeImpl2(parent, offset) {
  2706. var _this = _super.call(this, parent, offset) || this;
  2707. _this.type = "object";
  2708. _this.properties = [];
  2709. return _this;
  2710. }
  2711. Object.defineProperty(ObjectASTNodeImpl2.prototype, "children", {
  2712. get: function() {
  2713. return this.properties;
  2714. },
  2715. enumerable: false,
  2716. configurable: true
  2717. });
  2718. return ObjectASTNodeImpl2;
  2719. }(ASTNodeImpl);
  2720. function asSchema(schema) {
  2721. if (isBoolean(schema)) {
  2722. return schema ? {} : { "not": {} };
  2723. }
  2724. return schema;
  2725. }
  2726. var EnumMatch;
  2727. (function(EnumMatch2) {
  2728. EnumMatch2[EnumMatch2["Key"] = 0] = "Key";
  2729. EnumMatch2[EnumMatch2["Enum"] = 1] = "Enum";
  2730. })(EnumMatch || (EnumMatch = {}));
  2731. var SchemaCollector = function() {
  2732. function SchemaCollector2(focusOffset, exclude) {
  2733. if (focusOffset === void 0) {
  2734. focusOffset = -1;
  2735. }
  2736. this.focusOffset = focusOffset;
  2737. this.exclude = exclude;
  2738. this.schemas = [];
  2739. }
  2740. SchemaCollector2.prototype.add = function(schema) {
  2741. this.schemas.push(schema);
  2742. };
  2743. SchemaCollector2.prototype.merge = function(other) {
  2744. Array.prototype.push.apply(this.schemas, other.schemas);
  2745. };
  2746. SchemaCollector2.prototype.include = function(node) {
  2747. return (this.focusOffset === -1 || contains2(node, this.focusOffset)) && node !== this.exclude;
  2748. };
  2749. SchemaCollector2.prototype.newSub = function() {
  2750. return new SchemaCollector2(-1, this.exclude);
  2751. };
  2752. return SchemaCollector2;
  2753. }();
  2754. var NoOpSchemaCollector = function() {
  2755. function NoOpSchemaCollector2() {
  2756. }
  2757. Object.defineProperty(NoOpSchemaCollector2.prototype, "schemas", {
  2758. get: function() {
  2759. return [];
  2760. },
  2761. enumerable: false,
  2762. configurable: true
  2763. });
  2764. NoOpSchemaCollector2.prototype.add = function(schema) {
  2765. };
  2766. NoOpSchemaCollector2.prototype.merge = function(other) {
  2767. };
  2768. NoOpSchemaCollector2.prototype.include = function(node) {
  2769. return true;
  2770. };
  2771. NoOpSchemaCollector2.prototype.newSub = function() {
  2772. return this;
  2773. };
  2774. NoOpSchemaCollector2.instance = new NoOpSchemaCollector2();
  2775. return NoOpSchemaCollector2;
  2776. }();
  2777. var ValidationResult = function() {
  2778. function ValidationResult2() {
  2779. this.problems = [];
  2780. this.propertiesMatches = 0;
  2781. this.propertiesValueMatches = 0;
  2782. this.primaryValueMatches = 0;
  2783. this.enumValueMatch = false;
  2784. this.enumValues = void 0;
  2785. }
  2786. ValidationResult2.prototype.hasProblems = function() {
  2787. return !!this.problems.length;
  2788. };
  2789. ValidationResult2.prototype.mergeAll = function(validationResults) {
  2790. for (var _i = 0, validationResults_1 = validationResults; _i < validationResults_1.length; _i++) {
  2791. var validationResult = validationResults_1[_i];
  2792. this.merge(validationResult);
  2793. }
  2794. };
  2795. ValidationResult2.prototype.merge = function(validationResult) {
  2796. this.problems = this.problems.concat(validationResult.problems);
  2797. };
  2798. ValidationResult2.prototype.mergeEnumValues = function(validationResult) {
  2799. if (!this.enumValueMatch && !validationResult.enumValueMatch && this.enumValues && validationResult.enumValues) {
  2800. this.enumValues = this.enumValues.concat(validationResult.enumValues);
  2801. for (var _i = 0, _a = this.problems; _i < _a.length; _i++) {
  2802. var error = _a[_i];
  2803. if (error.code === ErrorCode.EnumValueMismatch) {
  2804. error.message = localize2("enumWarning", "Value is not accepted. Valid values: {0}.", this.enumValues.map(function(v) {
  2805. return JSON.stringify(v);
  2806. }).join(", "));
  2807. }
  2808. }
  2809. }
  2810. };
  2811. ValidationResult2.prototype.mergePropertyMatch = function(propertyValidationResult) {
  2812. this.merge(propertyValidationResult);
  2813. this.propertiesMatches++;
  2814. if (propertyValidationResult.enumValueMatch || !propertyValidationResult.hasProblems() && propertyValidationResult.propertiesMatches) {
  2815. this.propertiesValueMatches++;
  2816. }
  2817. if (propertyValidationResult.enumValueMatch && propertyValidationResult.enumValues && propertyValidationResult.enumValues.length === 1) {
  2818. this.primaryValueMatches++;
  2819. }
  2820. };
  2821. ValidationResult2.prototype.compare = function(other) {
  2822. var hasProblems = this.hasProblems();
  2823. if (hasProblems !== other.hasProblems()) {
  2824. return hasProblems ? -1 : 1;
  2825. }
  2826. if (this.enumValueMatch !== other.enumValueMatch) {
  2827. return other.enumValueMatch ? -1 : 1;
  2828. }
  2829. if (this.primaryValueMatches !== other.primaryValueMatches) {
  2830. return this.primaryValueMatches - other.primaryValueMatches;
  2831. }
  2832. if (this.propertiesValueMatches !== other.propertiesValueMatches) {
  2833. return this.propertiesValueMatches - other.propertiesValueMatches;
  2834. }
  2835. return this.propertiesMatches - other.propertiesMatches;
  2836. };
  2837. return ValidationResult2;
  2838. }();
  2839. function newJSONDocument(root, diagnostics) {
  2840. if (diagnostics === void 0) {
  2841. diagnostics = [];
  2842. }
  2843. return new JSONDocument(root, diagnostics, []);
  2844. }
  2845. function getNodeValue3(node) {
  2846. return getNodeValue2(node);
  2847. }
  2848. function getNodePath3(node) {
  2849. return getNodePath2(node);
  2850. }
  2851. function contains2(node, offset, includeRightBound) {
  2852. if (includeRightBound === void 0) {
  2853. includeRightBound = false;
  2854. }
  2855. return offset >= node.offset && offset < node.offset + node.length || includeRightBound && offset === node.offset + node.length;
  2856. }
  2857. var JSONDocument = function() {
  2858. function JSONDocument2(root, syntaxErrors, comments) {
  2859. if (syntaxErrors === void 0) {
  2860. syntaxErrors = [];
  2861. }
  2862. if (comments === void 0) {
  2863. comments = [];
  2864. }
  2865. this.root = root;
  2866. this.syntaxErrors = syntaxErrors;
  2867. this.comments = comments;
  2868. }
  2869. JSONDocument2.prototype.getNodeFromOffset = function(offset, includeRightBound) {
  2870. if (includeRightBound === void 0) {
  2871. includeRightBound = false;
  2872. }
  2873. if (this.root) {
  2874. return findNodeAtOffset2(this.root, offset, includeRightBound);
  2875. }
  2876. return void 0;
  2877. };
  2878. JSONDocument2.prototype.visit = function(visitor) {
  2879. if (this.root) {
  2880. var doVisit_1 = function(node) {
  2881. var ctn = visitor(node);
  2882. var children = node.children;
  2883. if (Array.isArray(children)) {
  2884. for (var i = 0; i < children.length && ctn; i++) {
  2885. ctn = doVisit_1(children[i]);
  2886. }
  2887. }
  2888. return ctn;
  2889. };
  2890. doVisit_1(this.root);
  2891. }
  2892. };
  2893. JSONDocument2.prototype.validate = function(textDocument, schema, severity) {
  2894. if (severity === void 0) {
  2895. severity = DiagnosticSeverity.Warning;
  2896. }
  2897. if (this.root && schema) {
  2898. var validationResult = new ValidationResult();
  2899. validate(this.root, schema, validationResult, NoOpSchemaCollector.instance);
  2900. return validationResult.problems.map(function(p) {
  2901. var _a;
  2902. var range = Range.create(textDocument.positionAt(p.location.offset), textDocument.positionAt(p.location.offset + p.location.length));
  2903. return Diagnostic.create(range, p.message, (_a = p.severity) !== null && _a !== void 0 ? _a : severity, p.code);
  2904. });
  2905. }
  2906. return void 0;
  2907. };
  2908. JSONDocument2.prototype.getMatchingSchemas = function(schema, focusOffset, exclude) {
  2909. if (focusOffset === void 0) {
  2910. focusOffset = -1;
  2911. }
  2912. var matchingSchemas = new SchemaCollector(focusOffset, exclude);
  2913. if (this.root && schema) {
  2914. validate(this.root, schema, new ValidationResult(), matchingSchemas);
  2915. }
  2916. return matchingSchemas.schemas;
  2917. };
  2918. return JSONDocument2;
  2919. }();
  2920. function validate(n, schema, validationResult, matchingSchemas) {
  2921. if (!n || !matchingSchemas.include(n)) {
  2922. return;
  2923. }
  2924. var node = n;
  2925. switch (node.type) {
  2926. case "object":
  2927. _validateObjectNode(node, schema, validationResult, matchingSchemas);
  2928. break;
  2929. case "array":
  2930. _validateArrayNode(node, schema, validationResult, matchingSchemas);
  2931. break;
  2932. case "string":
  2933. _validateStringNode(node, schema, validationResult, matchingSchemas);
  2934. break;
  2935. case "number":
  2936. _validateNumberNode(node, schema, validationResult, matchingSchemas);
  2937. break;
  2938. case "property":
  2939. return validate(node.valueNode, schema, validationResult, matchingSchemas);
  2940. }
  2941. _validateNode();
  2942. matchingSchemas.add({ node, schema });
  2943. function _validateNode() {
  2944. function matchesType(type) {
  2945. return node.type === type || type === "integer" && node.type === "number" && node.isInteger;
  2946. }
  2947. if (Array.isArray(schema.type)) {
  2948. if (!schema.type.some(matchesType)) {
  2949. validationResult.problems.push({
  2950. location: { offset: node.offset, length: node.length },
  2951. message: schema.errorMessage || localize2("typeArrayMismatchWarning", "Incorrect type. Expected one of {0}.", schema.type.join(", "))
  2952. });
  2953. }
  2954. } else if (schema.type) {
  2955. if (!matchesType(schema.type)) {
  2956. validationResult.problems.push({
  2957. location: { offset: node.offset, length: node.length },
  2958. message: schema.errorMessage || localize2("typeMismatchWarning", 'Incorrect type. Expected "{0}".', schema.type)
  2959. });
  2960. }
  2961. }
  2962. if (Array.isArray(schema.allOf)) {
  2963. for (var _i = 0, _a = schema.allOf; _i < _a.length; _i++) {
  2964. var subSchemaRef = _a[_i];
  2965. validate(node, asSchema(subSchemaRef), validationResult, matchingSchemas);
  2966. }
  2967. }
  2968. var notSchema = asSchema(schema.not);
  2969. if (notSchema) {
  2970. var subValidationResult = new ValidationResult();
  2971. var subMatchingSchemas = matchingSchemas.newSub();
  2972. validate(node, notSchema, subValidationResult, subMatchingSchemas);
  2973. if (!subValidationResult.hasProblems()) {
  2974. validationResult.problems.push({
  2975. location: { offset: node.offset, length: node.length },
  2976. message: localize2("notSchemaWarning", "Matches a schema that is not allowed.")
  2977. });
  2978. }
  2979. for (var _b = 0, _c = subMatchingSchemas.schemas; _b < _c.length; _b++) {
  2980. var ms = _c[_b];
  2981. ms.inverted = !ms.inverted;
  2982. matchingSchemas.add(ms);
  2983. }
  2984. }
  2985. var testAlternatives = function(alternatives, maxOneMatch) {
  2986. var matches = [];
  2987. var bestMatch = void 0;
  2988. for (var _i2 = 0, alternatives_1 = alternatives; _i2 < alternatives_1.length; _i2++) {
  2989. var subSchemaRef2 = alternatives_1[_i2];
  2990. var subSchema = asSchema(subSchemaRef2);
  2991. var subValidationResult2 = new ValidationResult();
  2992. var subMatchingSchemas2 = matchingSchemas.newSub();
  2993. validate(node, subSchema, subValidationResult2, subMatchingSchemas2);
  2994. if (!subValidationResult2.hasProblems()) {
  2995. matches.push(subSchema);
  2996. }
  2997. if (!bestMatch) {
  2998. bestMatch = { schema: subSchema, validationResult: subValidationResult2, matchingSchemas: subMatchingSchemas2 };
  2999. } else {
  3000. if (!maxOneMatch && !subValidationResult2.hasProblems() && !bestMatch.validationResult.hasProblems()) {
  3001. bestMatch.matchingSchemas.merge(subMatchingSchemas2);
  3002. bestMatch.validationResult.propertiesMatches += subValidationResult2.propertiesMatches;
  3003. bestMatch.validationResult.propertiesValueMatches += subValidationResult2.propertiesValueMatches;
  3004. } else {
  3005. var compareResult = subValidationResult2.compare(bestMatch.validationResult);
  3006. if (compareResult > 0) {
  3007. bestMatch = { schema: subSchema, validationResult: subValidationResult2, matchingSchemas: subMatchingSchemas2 };
  3008. } else if (compareResult === 0) {
  3009. bestMatch.matchingSchemas.merge(subMatchingSchemas2);
  3010. bestMatch.validationResult.mergeEnumValues(subValidationResult2);
  3011. }
  3012. }
  3013. }
  3014. }
  3015. if (matches.length > 1 && maxOneMatch) {
  3016. validationResult.problems.push({
  3017. location: { offset: node.offset, length: 1 },
  3018. message: localize2("oneOfWarning", "Matches multiple schemas when only one must validate.")
  3019. });
  3020. }
  3021. if (bestMatch) {
  3022. validationResult.merge(bestMatch.validationResult);
  3023. validationResult.propertiesMatches += bestMatch.validationResult.propertiesMatches;
  3024. validationResult.propertiesValueMatches += bestMatch.validationResult.propertiesValueMatches;
  3025. matchingSchemas.merge(bestMatch.matchingSchemas);
  3026. }
  3027. return matches.length;
  3028. };
  3029. if (Array.isArray(schema.anyOf)) {
  3030. testAlternatives(schema.anyOf, false);
  3031. }
  3032. if (Array.isArray(schema.oneOf)) {
  3033. testAlternatives(schema.oneOf, true);
  3034. }
  3035. var testBranch = function(schema2) {
  3036. var subValidationResult2 = new ValidationResult();
  3037. var subMatchingSchemas2 = matchingSchemas.newSub();
  3038. validate(node, asSchema(schema2), subValidationResult2, subMatchingSchemas2);
  3039. validationResult.merge(subValidationResult2);
  3040. validationResult.propertiesMatches += subValidationResult2.propertiesMatches;
  3041. validationResult.propertiesValueMatches += subValidationResult2.propertiesValueMatches;
  3042. matchingSchemas.merge(subMatchingSchemas2);
  3043. };
  3044. var testCondition = function(ifSchema2, thenSchema, elseSchema) {
  3045. var subSchema = asSchema(ifSchema2);
  3046. var subValidationResult2 = new ValidationResult();
  3047. var subMatchingSchemas2 = matchingSchemas.newSub();
  3048. validate(node, subSchema, subValidationResult2, subMatchingSchemas2);
  3049. matchingSchemas.merge(subMatchingSchemas2);
  3050. if (!subValidationResult2.hasProblems()) {
  3051. if (thenSchema) {
  3052. testBranch(thenSchema);
  3053. }
  3054. } else if (elseSchema) {
  3055. testBranch(elseSchema);
  3056. }
  3057. };
  3058. var ifSchema = asSchema(schema.if);
  3059. if (ifSchema) {
  3060. testCondition(ifSchema, asSchema(schema.then), asSchema(schema.else));
  3061. }
  3062. if (Array.isArray(schema.enum)) {
  3063. var val = getNodeValue3(node);
  3064. var enumValueMatch = false;
  3065. for (var _d = 0, _e = schema.enum; _d < _e.length; _d++) {
  3066. var e = _e[_d];
  3067. if (equals(val, e)) {
  3068. enumValueMatch = true;
  3069. break;
  3070. }
  3071. }
  3072. validationResult.enumValues = schema.enum;
  3073. validationResult.enumValueMatch = enumValueMatch;
  3074. if (!enumValueMatch) {
  3075. validationResult.problems.push({
  3076. location: { offset: node.offset, length: node.length },
  3077. code: ErrorCode.EnumValueMismatch,
  3078. message: schema.errorMessage || localize2("enumWarning", "Value is not accepted. Valid values: {0}.", schema.enum.map(function(v) {
  3079. return JSON.stringify(v);
  3080. }).join(", "))
  3081. });
  3082. }
  3083. }
  3084. if (isDefined(schema.const)) {
  3085. var val = getNodeValue3(node);
  3086. if (!equals(val, schema.const)) {
  3087. validationResult.problems.push({
  3088. location: { offset: node.offset, length: node.length },
  3089. code: ErrorCode.EnumValueMismatch,
  3090. message: schema.errorMessage || localize2("constWarning", "Value must be {0}.", JSON.stringify(schema.const))
  3091. });
  3092. validationResult.enumValueMatch = false;
  3093. } else {
  3094. validationResult.enumValueMatch = true;
  3095. }
  3096. validationResult.enumValues = [schema.const];
  3097. }
  3098. if (schema.deprecationMessage && node.parent) {
  3099. validationResult.problems.push({
  3100. location: { offset: node.parent.offset, length: node.parent.length },
  3101. severity: DiagnosticSeverity.Warning,
  3102. message: schema.deprecationMessage,
  3103. code: ErrorCode.Deprecated
  3104. });
  3105. }
  3106. }
  3107. function _validateNumberNode(node2, schema2, validationResult2, matchingSchemas2) {
  3108. var val = node2.value;
  3109. function normalizeFloats(float) {
  3110. var _a;
  3111. var parts = /^(-?\d+)(?:\.(\d+))?(?:e([-+]\d+))?$/.exec(float.toString());
  3112. return parts && {
  3113. value: Number(parts[1] + (parts[2] || "")),
  3114. multiplier: (((_a = parts[2]) === null || _a === void 0 ? void 0 : _a.length) || 0) - (parseInt(parts[3]) || 0)
  3115. };
  3116. }
  3117. ;
  3118. if (isNumber(schema2.multipleOf)) {
  3119. var remainder = -1;
  3120. if (Number.isInteger(schema2.multipleOf)) {
  3121. remainder = val % schema2.multipleOf;
  3122. } else {
  3123. var normMultipleOf = normalizeFloats(schema2.multipleOf);
  3124. var normValue = normalizeFloats(val);
  3125. if (normMultipleOf && normValue) {
  3126. var multiplier = Math.pow(10, Math.abs(normValue.multiplier - normMultipleOf.multiplier));
  3127. if (normValue.multiplier < normMultipleOf.multiplier) {
  3128. normValue.value *= multiplier;
  3129. } else {
  3130. normMultipleOf.value *= multiplier;
  3131. }
  3132. remainder = normValue.value % normMultipleOf.value;
  3133. }
  3134. }
  3135. if (remainder !== 0) {
  3136. validationResult2.problems.push({
  3137. location: { offset: node2.offset, length: node2.length },
  3138. message: localize2("multipleOfWarning", "Value is not divisible by {0}.", schema2.multipleOf)
  3139. });
  3140. }
  3141. }
  3142. function getExclusiveLimit(limit, exclusive) {
  3143. if (isNumber(exclusive)) {
  3144. return exclusive;
  3145. }
  3146. if (isBoolean(exclusive) && exclusive) {
  3147. return limit;
  3148. }
  3149. return void 0;
  3150. }
  3151. function getLimit(limit, exclusive) {
  3152. if (!isBoolean(exclusive) || !exclusive) {
  3153. return limit;
  3154. }
  3155. return void 0;
  3156. }
  3157. var exclusiveMinimum = getExclusiveLimit(schema2.minimum, schema2.exclusiveMinimum);
  3158. if (isNumber(exclusiveMinimum) && val <= exclusiveMinimum) {
  3159. validationResult2.problems.push({
  3160. location: { offset: node2.offset, length: node2.length },
  3161. message: localize2("exclusiveMinimumWarning", "Value is below the exclusive minimum of {0}.", exclusiveMinimum)
  3162. });
  3163. }
  3164. var exclusiveMaximum = getExclusiveLimit(schema2.maximum, schema2.exclusiveMaximum);
  3165. if (isNumber(exclusiveMaximum) && val >= exclusiveMaximum) {
  3166. validationResult2.problems.push({
  3167. location: { offset: node2.offset, length: node2.length },
  3168. message: localize2("exclusiveMaximumWarning", "Value is above the exclusive maximum of {0}.", exclusiveMaximum)
  3169. });
  3170. }
  3171. var minimum = getLimit(schema2.minimum, schema2.exclusiveMinimum);
  3172. if (isNumber(minimum) && val < minimum) {
  3173. validationResult2.problems.push({
  3174. location: { offset: node2.offset, length: node2.length },
  3175. message: localize2("minimumWarning", "Value is below the minimum of {0}.", minimum)
  3176. });
  3177. }
  3178. var maximum = getLimit(schema2.maximum, schema2.exclusiveMaximum);
  3179. if (isNumber(maximum) && val > maximum) {
  3180. validationResult2.problems.push({
  3181. location: { offset: node2.offset, length: node2.length },
  3182. message: localize2("maximumWarning", "Value is above the maximum of {0}.", maximum)
  3183. });
  3184. }
  3185. }
  3186. function _validateStringNode(node2, schema2, validationResult2, matchingSchemas2) {
  3187. if (isNumber(schema2.minLength) && node2.value.length < schema2.minLength) {
  3188. validationResult2.problems.push({
  3189. location: { offset: node2.offset, length: node2.length },
  3190. message: localize2("minLengthWarning", "String is shorter than the minimum length of {0}.", schema2.minLength)
  3191. });
  3192. }
  3193. if (isNumber(schema2.maxLength) && node2.value.length > schema2.maxLength) {
  3194. validationResult2.problems.push({
  3195. location: { offset: node2.offset, length: node2.length },
  3196. message: localize2("maxLengthWarning", "String is longer than the maximum length of {0}.", schema2.maxLength)
  3197. });
  3198. }
  3199. if (isString(schema2.pattern)) {
  3200. var regex = extendedRegExp(schema2.pattern);
  3201. if (!(regex === null || regex === void 0 ? void 0 : regex.test(node2.value))) {
  3202. validationResult2.problems.push({
  3203. location: { offset: node2.offset, length: node2.length },
  3204. message: schema2.patternErrorMessage || schema2.errorMessage || localize2("patternWarning", 'String does not match the pattern of "{0}".', schema2.pattern)
  3205. });
  3206. }
  3207. }
  3208. if (schema2.format) {
  3209. switch (schema2.format) {
  3210. case "uri":
  3211. case "uri-reference":
  3212. {
  3213. var errorMessage = void 0;
  3214. if (!node2.value) {
  3215. errorMessage = localize2("uriEmpty", "URI expected.");
  3216. } else {
  3217. var match = /^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/.exec(node2.value);
  3218. if (!match) {
  3219. errorMessage = localize2("uriMissing", "URI is expected.");
  3220. } else if (!match[2] && schema2.format === "uri") {
  3221. errorMessage = localize2("uriSchemeMissing", "URI with a scheme is expected.");
  3222. }
  3223. }
  3224. if (errorMessage) {
  3225. validationResult2.problems.push({
  3226. location: { offset: node2.offset, length: node2.length },
  3227. message: schema2.patternErrorMessage || schema2.errorMessage || localize2("uriFormatWarning", "String is not a URI: {0}", errorMessage)
  3228. });
  3229. }
  3230. }
  3231. break;
  3232. case "color-hex":
  3233. case "date-time":
  3234. case "date":
  3235. case "time":
  3236. case "email":
  3237. var format4 = formats[schema2.format];
  3238. if (!node2.value || !format4.pattern.exec(node2.value)) {
  3239. validationResult2.problems.push({
  3240. location: { offset: node2.offset, length: node2.length },
  3241. message: schema2.patternErrorMessage || schema2.errorMessage || format4.errorMessage
  3242. });
  3243. }
  3244. default:
  3245. }
  3246. }
  3247. }
  3248. function _validateArrayNode(node2, schema2, validationResult2, matchingSchemas2) {
  3249. if (Array.isArray(schema2.items)) {
  3250. var subSchemas = schema2.items;
  3251. for (var index = 0; index < subSchemas.length; index++) {
  3252. var subSchemaRef = subSchemas[index];
  3253. var subSchema = asSchema(subSchemaRef);
  3254. var itemValidationResult = new ValidationResult();
  3255. var item = node2.items[index];
  3256. if (item) {
  3257. validate(item, subSchema, itemValidationResult, matchingSchemas2);
  3258. validationResult2.mergePropertyMatch(itemValidationResult);
  3259. } else if (node2.items.length >= subSchemas.length) {
  3260. validationResult2.propertiesValueMatches++;
  3261. }
  3262. }
  3263. if (node2.items.length > subSchemas.length) {
  3264. if (typeof schema2.additionalItems === "object") {
  3265. for (var i = subSchemas.length; i < node2.items.length; i++) {
  3266. var itemValidationResult = new ValidationResult();
  3267. validate(node2.items[i], schema2.additionalItems, itemValidationResult, matchingSchemas2);
  3268. validationResult2.mergePropertyMatch(itemValidationResult);
  3269. }
  3270. } else if (schema2.additionalItems === false) {
  3271. validationResult2.problems.push({
  3272. location: { offset: node2.offset, length: node2.length },
  3273. message: localize2("additionalItemsWarning", "Array has too many items according to schema. Expected {0} or fewer.", subSchemas.length)
  3274. });
  3275. }
  3276. }
  3277. } else {
  3278. var itemSchema = asSchema(schema2.items);
  3279. if (itemSchema) {
  3280. for (var _i = 0, _a = node2.items; _i < _a.length; _i++) {
  3281. var item = _a[_i];
  3282. var itemValidationResult = new ValidationResult();
  3283. validate(item, itemSchema, itemValidationResult, matchingSchemas2);
  3284. validationResult2.mergePropertyMatch(itemValidationResult);
  3285. }
  3286. }
  3287. }
  3288. var containsSchema = asSchema(schema2.contains);
  3289. if (containsSchema) {
  3290. var doesContain = node2.items.some(function(item2) {
  3291. var itemValidationResult2 = new ValidationResult();
  3292. validate(item2, containsSchema, itemValidationResult2, NoOpSchemaCollector.instance);
  3293. return !itemValidationResult2.hasProblems();
  3294. });
  3295. if (!doesContain) {
  3296. validationResult2.problems.push({
  3297. location: { offset: node2.offset, length: node2.length },
  3298. message: schema2.errorMessage || localize2("requiredItemMissingWarning", "Array does not contain required item.")
  3299. });
  3300. }
  3301. }
  3302. if (isNumber(schema2.minItems) && node2.items.length < schema2.minItems) {
  3303. validationResult2.problems.push({
  3304. location: { offset: node2.offset, length: node2.length },
  3305. message: localize2("minItemsWarning", "Array has too few items. Expected {0} or more.", schema2.minItems)
  3306. });
  3307. }
  3308. if (isNumber(schema2.maxItems) && node2.items.length > schema2.maxItems) {
  3309. validationResult2.problems.push({
  3310. location: { offset: node2.offset, length: node2.length },
  3311. message: localize2("maxItemsWarning", "Array has too many items. Expected {0} or fewer.", schema2.maxItems)
  3312. });
  3313. }
  3314. if (schema2.uniqueItems === true) {
  3315. var values_1 = getNodeValue3(node2);
  3316. var duplicates = values_1.some(function(value, index2) {
  3317. return index2 !== values_1.lastIndexOf(value);
  3318. });
  3319. if (duplicates) {
  3320. validationResult2.problems.push({
  3321. location: { offset: node2.offset, length: node2.length },
  3322. message: localize2("uniqueItemsWarning", "Array has duplicate items.")
  3323. });
  3324. }
  3325. }
  3326. }
  3327. function _validateObjectNode(node2, schema2, validationResult2, matchingSchemas2) {
  3328. var seenKeys = Object.create(null);
  3329. var unprocessedProperties = [];
  3330. for (var _i = 0, _a = node2.properties; _i < _a.length; _i++) {
  3331. var propertyNode = _a[_i];
  3332. var key = propertyNode.keyNode.value;
  3333. seenKeys[key] = propertyNode.valueNode;
  3334. unprocessedProperties.push(key);
  3335. }
  3336. if (Array.isArray(schema2.required)) {
  3337. for (var _b = 0, _c = schema2.required; _b < _c.length; _b++) {
  3338. var propertyName = _c[_b];
  3339. if (!seenKeys[propertyName]) {
  3340. var keyNode = node2.parent && node2.parent.type === "property" && node2.parent.keyNode;
  3341. var location = keyNode ? { offset: keyNode.offset, length: keyNode.length } : { offset: node2.offset, length: 1 };
  3342. validationResult2.problems.push({
  3343. location,
  3344. message: localize2("MissingRequiredPropWarning", 'Missing property "{0}".', propertyName)
  3345. });
  3346. }
  3347. }
  3348. }
  3349. var propertyProcessed = function(prop2) {
  3350. var index = unprocessedProperties.indexOf(prop2);
  3351. while (index >= 0) {
  3352. unprocessedProperties.splice(index, 1);
  3353. index = unprocessedProperties.indexOf(prop2);
  3354. }
  3355. };
  3356. if (schema2.properties) {
  3357. for (var _d = 0, _e = Object.keys(schema2.properties); _d < _e.length; _d++) {
  3358. var propertyName = _e[_d];
  3359. propertyProcessed(propertyName);
  3360. var propertySchema = schema2.properties[propertyName];
  3361. var child = seenKeys[propertyName];
  3362. if (child) {
  3363. if (isBoolean(propertySchema)) {
  3364. if (!propertySchema) {
  3365. var propertyNode = child.parent;
  3366. validationResult2.problems.push({
  3367. location: { offset: propertyNode.keyNode.offset, length: propertyNode.keyNode.length },
  3368. message: schema2.errorMessage || localize2("DisallowedExtraPropWarning", "Property {0} is not allowed.", propertyName)
  3369. });
  3370. } else {
  3371. validationResult2.propertiesMatches++;
  3372. validationResult2.propertiesValueMatches++;
  3373. }
  3374. } else {
  3375. var propertyValidationResult = new ValidationResult();
  3376. validate(child, propertySchema, propertyValidationResult, matchingSchemas2);
  3377. validationResult2.mergePropertyMatch(propertyValidationResult);
  3378. }
  3379. }
  3380. }
  3381. }
  3382. if (schema2.patternProperties) {
  3383. for (var _f = 0, _g = Object.keys(schema2.patternProperties); _f < _g.length; _f++) {
  3384. var propertyPattern = _g[_f];
  3385. var regex = extendedRegExp(propertyPattern);
  3386. for (var _h = 0, _j = unprocessedProperties.slice(0); _h < _j.length; _h++) {
  3387. var propertyName = _j[_h];
  3388. if (regex === null || regex === void 0 ? void 0 : regex.test(propertyName)) {
  3389. propertyProcessed(propertyName);
  3390. var child = seenKeys[propertyName];
  3391. if (child) {
  3392. var propertySchema = schema2.patternProperties[propertyPattern];
  3393. if (isBoolean(propertySchema)) {
  3394. if (!propertySchema) {
  3395. var propertyNode = child.parent;
  3396. validationResult2.problems.push({
  3397. location: { offset: propertyNode.keyNode.offset, length: propertyNode.keyNode.length },
  3398. message: schema2.errorMessage || localize2("DisallowedExtraPropWarning", "Property {0} is not allowed.", propertyName)
  3399. });
  3400. } else {
  3401. validationResult2.propertiesMatches++;
  3402. validationResult2.propertiesValueMatches++;
  3403. }
  3404. } else {
  3405. var propertyValidationResult = new ValidationResult();
  3406. validate(child, propertySchema, propertyValidationResult, matchingSchemas2);
  3407. validationResult2.mergePropertyMatch(propertyValidationResult);
  3408. }
  3409. }
  3410. }
  3411. }
  3412. }
  3413. }
  3414. if (typeof schema2.additionalProperties === "object") {
  3415. for (var _k = 0, unprocessedProperties_1 = unprocessedProperties; _k < unprocessedProperties_1.length; _k++) {
  3416. var propertyName = unprocessedProperties_1[_k];
  3417. var child = seenKeys[propertyName];
  3418. if (child) {
  3419. var propertyValidationResult = new ValidationResult();
  3420. validate(child, schema2.additionalProperties, propertyValidationResult, matchingSchemas2);
  3421. validationResult2.mergePropertyMatch(propertyValidationResult);
  3422. }
  3423. }
  3424. } else if (schema2.additionalProperties === false) {
  3425. if (unprocessedProperties.length > 0) {
  3426. for (var _l = 0, unprocessedProperties_2 = unprocessedProperties; _l < unprocessedProperties_2.length; _l++) {
  3427. var propertyName = unprocessedProperties_2[_l];
  3428. var child = seenKeys[propertyName];
  3429. if (child) {
  3430. var propertyNode = child.parent;
  3431. validationResult2.problems.push({
  3432. location: { offset: propertyNode.keyNode.offset, length: propertyNode.keyNode.length },
  3433. message: schema2.errorMessage || localize2("DisallowedExtraPropWarning", "Property {0} is not allowed.", propertyName)
  3434. });
  3435. }
  3436. }
  3437. }
  3438. }
  3439. if (isNumber(schema2.maxProperties)) {
  3440. if (node2.properties.length > schema2.maxProperties) {
  3441. validationResult2.problems.push({
  3442. location: { offset: node2.offset, length: node2.length },
  3443. message: localize2("MaxPropWarning", "Object has more properties than limit of {0}.", schema2.maxProperties)
  3444. });
  3445. }
  3446. }
  3447. if (isNumber(schema2.minProperties)) {
  3448. if (node2.properties.length < schema2.minProperties) {
  3449. validationResult2.problems.push({
  3450. location: { offset: node2.offset, length: node2.length },
  3451. message: localize2("MinPropWarning", "Object has fewer properties than the required number of {0}", schema2.minProperties)
  3452. });
  3453. }
  3454. }
  3455. if (schema2.dependencies) {
  3456. for (var _m = 0, _o = Object.keys(schema2.dependencies); _m < _o.length; _m++) {
  3457. var key = _o[_m];
  3458. var prop = seenKeys[key];
  3459. if (prop) {
  3460. var propertyDep = schema2.dependencies[key];
  3461. if (Array.isArray(propertyDep)) {
  3462. for (var _p = 0, propertyDep_1 = propertyDep; _p < propertyDep_1.length; _p++) {
  3463. var requiredProp = propertyDep_1[_p];
  3464. if (!seenKeys[requiredProp]) {
  3465. validationResult2.problems.push({
  3466. location: { offset: node2.offset, length: node2.length },
  3467. message: localize2("RequiredDependentPropWarning", "Object is missing property {0} required by property {1}.", requiredProp, key)
  3468. });
  3469. } else {
  3470. validationResult2.propertiesValueMatches++;
  3471. }
  3472. }
  3473. } else {
  3474. var propertySchema = asSchema(propertyDep);
  3475. if (propertySchema) {
  3476. var propertyValidationResult = new ValidationResult();
  3477. validate(node2, propertySchema, propertyValidationResult, matchingSchemas2);
  3478. validationResult2.mergePropertyMatch(propertyValidationResult);
  3479. }
  3480. }
  3481. }
  3482. }
  3483. }
  3484. var propertyNames = asSchema(schema2.propertyNames);
  3485. if (propertyNames) {
  3486. for (var _q = 0, _r = node2.properties; _q < _r.length; _q++) {
  3487. var f2 = _r[_q];
  3488. var key = f2.keyNode;
  3489. if (key) {
  3490. validate(key, propertyNames, validationResult2, NoOpSchemaCollector.instance);
  3491. }
  3492. }
  3493. }
  3494. }
  3495. }
  3496. function parse3(textDocument, config) {
  3497. var problems = [];
  3498. var lastProblemOffset = -1;
  3499. var text = textDocument.getText();
  3500. var scanner2 = createScanner2(text, false);
  3501. var commentRanges = config && config.collectComments ? [] : void 0;
  3502. function _scanNext() {
  3503. while (true) {
  3504. var token_1 = scanner2.scan();
  3505. _checkScanError();
  3506. switch (token_1) {
  3507. case 12:
  3508. case 13:
  3509. if (Array.isArray(commentRanges)) {
  3510. commentRanges.push(Range.create(textDocument.positionAt(scanner2.getTokenOffset()), textDocument.positionAt(scanner2.getTokenOffset() + scanner2.getTokenLength())));
  3511. }
  3512. break;
  3513. case 15:
  3514. case 14:
  3515. break;
  3516. default:
  3517. return token_1;
  3518. }
  3519. }
  3520. }
  3521. function _accept(token2) {
  3522. if (scanner2.getToken() === token2) {
  3523. _scanNext();
  3524. return true;
  3525. }
  3526. return false;
  3527. }
  3528. function _errorAtRange(message, code, startOffset, endOffset, severity) {
  3529. if (severity === void 0) {
  3530. severity = DiagnosticSeverity.Error;
  3531. }
  3532. if (problems.length === 0 || startOffset !== lastProblemOffset) {
  3533. var range = Range.create(textDocument.positionAt(startOffset), textDocument.positionAt(endOffset));
  3534. problems.push(Diagnostic.create(range, message, severity, code, textDocument.languageId));
  3535. lastProblemOffset = startOffset;
  3536. }
  3537. }
  3538. function _error(message, code, node, skipUntilAfter, skipUntil) {
  3539. if (node === void 0) {
  3540. node = void 0;
  3541. }
  3542. if (skipUntilAfter === void 0) {
  3543. skipUntilAfter = [];
  3544. }
  3545. if (skipUntil === void 0) {
  3546. skipUntil = [];
  3547. }
  3548. var start = scanner2.getTokenOffset();
  3549. var end = scanner2.getTokenOffset() + scanner2.getTokenLength();
  3550. if (start === end && start > 0) {
  3551. start--;
  3552. while (start > 0 && /\s/.test(text.charAt(start))) {
  3553. start--;
  3554. }
  3555. end = start + 1;
  3556. }
  3557. _errorAtRange(message, code, start, end);
  3558. if (node) {
  3559. _finalize(node, false);
  3560. }
  3561. if (skipUntilAfter.length + skipUntil.length > 0) {
  3562. var token_2 = scanner2.getToken();
  3563. while (token_2 !== 17) {
  3564. if (skipUntilAfter.indexOf(token_2) !== -1) {
  3565. _scanNext();
  3566. break;
  3567. } else if (skipUntil.indexOf(token_2) !== -1) {
  3568. break;
  3569. }
  3570. token_2 = _scanNext();
  3571. }
  3572. }
  3573. return node;
  3574. }
  3575. function _checkScanError() {
  3576. switch (scanner2.getTokenError()) {
  3577. case 4:
  3578. _error(localize2("InvalidUnicode", "Invalid unicode sequence in string."), ErrorCode.InvalidUnicode);
  3579. return true;
  3580. case 5:
  3581. _error(localize2("InvalidEscapeCharacter", "Invalid escape character in string."), ErrorCode.InvalidEscapeCharacter);
  3582. return true;
  3583. case 3:
  3584. _error(localize2("UnexpectedEndOfNumber", "Unexpected end of number."), ErrorCode.UnexpectedEndOfNumber);
  3585. return true;
  3586. case 1:
  3587. _error(localize2("UnexpectedEndOfComment", "Unexpected end of comment."), ErrorCode.UnexpectedEndOfComment);
  3588. return true;
  3589. case 2:
  3590. _error(localize2("UnexpectedEndOfString", "Unexpected end of string."), ErrorCode.UnexpectedEndOfString);
  3591. return true;
  3592. case 6:
  3593. _error(localize2("InvalidCharacter", "Invalid characters in string. Control characters must be escaped."), ErrorCode.InvalidCharacter);
  3594. return true;
  3595. }
  3596. return false;
  3597. }
  3598. function _finalize(node, scanNext) {
  3599. node.length = scanner2.getTokenOffset() + scanner2.getTokenLength() - node.offset;
  3600. if (scanNext) {
  3601. _scanNext();
  3602. }
  3603. return node;
  3604. }
  3605. function _parseArray(parent) {
  3606. if (scanner2.getToken() !== 3) {
  3607. return void 0;
  3608. }
  3609. var node = new ArrayASTNodeImpl(parent, scanner2.getTokenOffset());
  3610. _scanNext();
  3611. var count = 0;
  3612. var needsComma = false;
  3613. while (scanner2.getToken() !== 4 && scanner2.getToken() !== 17) {
  3614. if (scanner2.getToken() === 5) {
  3615. if (!needsComma) {
  3616. _error(localize2("ValueExpected", "Value expected"), ErrorCode.ValueExpected);
  3617. }
  3618. var commaOffset = scanner2.getTokenOffset();
  3619. _scanNext();
  3620. if (scanner2.getToken() === 4) {
  3621. if (needsComma) {
  3622. _errorAtRange(localize2("TrailingComma", "Trailing comma"), ErrorCode.TrailingComma, commaOffset, commaOffset + 1);
  3623. }
  3624. continue;
  3625. }
  3626. } else if (needsComma) {
  3627. _error(localize2("ExpectedComma", "Expected comma"), ErrorCode.CommaExpected);
  3628. }
  3629. var item = _parseValue(node);
  3630. if (!item) {
  3631. _error(localize2("PropertyExpected", "Value expected"), ErrorCode.ValueExpected, void 0, [], [4, 5]);
  3632. } else {
  3633. node.items.push(item);
  3634. }
  3635. needsComma = true;
  3636. }
  3637. if (scanner2.getToken() !== 4) {
  3638. return _error(localize2("ExpectedCloseBracket", "Expected comma or closing bracket"), ErrorCode.CommaOrCloseBacketExpected, node);
  3639. }
  3640. return _finalize(node, true);
  3641. }
  3642. var keyPlaceholder = new StringASTNodeImpl(void 0, 0, 0);
  3643. function _parseProperty(parent, keysSeen) {
  3644. var node = new PropertyASTNodeImpl(parent, scanner2.getTokenOffset(), keyPlaceholder);
  3645. var key = _parseString(node);
  3646. if (!key) {
  3647. if (scanner2.getToken() === 16) {
  3648. _error(localize2("DoubleQuotesExpected", "Property keys must be doublequoted"), ErrorCode.Undefined);
  3649. var keyNode = new StringASTNodeImpl(node, scanner2.getTokenOffset(), scanner2.getTokenLength());
  3650. keyNode.value = scanner2.getTokenValue();
  3651. key = keyNode;
  3652. _scanNext();
  3653. } else {
  3654. return void 0;
  3655. }
  3656. }
  3657. node.keyNode = key;
  3658. var seen = keysSeen[key.value];
  3659. if (seen) {
  3660. _errorAtRange(localize2("DuplicateKeyWarning", "Duplicate object key"), ErrorCode.DuplicateKey, node.keyNode.offset, node.keyNode.offset + node.keyNode.length, DiagnosticSeverity.Warning);
  3661. if (typeof seen === "object") {
  3662. _errorAtRange(localize2("DuplicateKeyWarning", "Duplicate object key"), ErrorCode.DuplicateKey, seen.keyNode.offset, seen.keyNode.offset + seen.keyNode.length, DiagnosticSeverity.Warning);
  3663. }
  3664. keysSeen[key.value] = true;
  3665. } else {
  3666. keysSeen[key.value] = node;
  3667. }
  3668. if (scanner2.getToken() === 6) {
  3669. node.colonOffset = scanner2.getTokenOffset();
  3670. _scanNext();
  3671. } else {
  3672. _error(localize2("ColonExpected", "Colon expected"), ErrorCode.ColonExpected);
  3673. if (scanner2.getToken() === 10 && textDocument.positionAt(key.offset + key.length).line < textDocument.positionAt(scanner2.getTokenOffset()).line) {
  3674. node.length = key.length;
  3675. return node;
  3676. }
  3677. }
  3678. var value = _parseValue(node);
  3679. if (!value) {
  3680. return _error(localize2("ValueExpected", "Value expected"), ErrorCode.ValueExpected, node, [], [2, 5]);
  3681. }
  3682. node.valueNode = value;
  3683. node.length = value.offset + value.length - node.offset;
  3684. return node;
  3685. }
  3686. function _parseObject(parent) {
  3687. if (scanner2.getToken() !== 1) {
  3688. return void 0;
  3689. }
  3690. var node = new ObjectASTNodeImpl(parent, scanner2.getTokenOffset());
  3691. var keysSeen = Object.create(null);
  3692. _scanNext();
  3693. var needsComma = false;
  3694. while (scanner2.getToken() !== 2 && scanner2.getToken() !== 17) {
  3695. if (scanner2.getToken() === 5) {
  3696. if (!needsComma) {
  3697. _error(localize2("PropertyExpected", "Property expected"), ErrorCode.PropertyExpected);
  3698. }
  3699. var commaOffset = scanner2.getTokenOffset();
  3700. _scanNext();
  3701. if (scanner2.getToken() === 2) {
  3702. if (needsComma) {
  3703. _errorAtRange(localize2("TrailingComma", "Trailing comma"), ErrorCode.TrailingComma, commaOffset, commaOffset + 1);
  3704. }
  3705. continue;
  3706. }
  3707. } else if (needsComma) {
  3708. _error(localize2("ExpectedComma", "Expected comma"), ErrorCode.CommaExpected);
  3709. }
  3710. var property = _parseProperty(node, keysSeen);
  3711. if (!property) {
  3712. _error(localize2("PropertyExpected", "Property expected"), ErrorCode.PropertyExpected, void 0, [], [2, 5]);
  3713. } else {
  3714. node.properties.push(property);
  3715. }
  3716. needsComma = true;
  3717. }
  3718. if (scanner2.getToken() !== 2) {
  3719. return _error(localize2("ExpectedCloseBrace", "Expected comma or closing brace"), ErrorCode.CommaOrCloseBraceExpected, node);
  3720. }
  3721. return _finalize(node, true);
  3722. }
  3723. function _parseString(parent) {
  3724. if (scanner2.getToken() !== 10) {
  3725. return void 0;
  3726. }
  3727. var node = new StringASTNodeImpl(parent, scanner2.getTokenOffset());
  3728. node.value = scanner2.getTokenValue();
  3729. return _finalize(node, true);
  3730. }
  3731. function _parseNumber(parent) {
  3732. if (scanner2.getToken() !== 11) {
  3733. return void 0;
  3734. }
  3735. var node = new NumberASTNodeImpl(parent, scanner2.getTokenOffset());
  3736. if (scanner2.getTokenError() === 0) {
  3737. var tokenValue = scanner2.getTokenValue();
  3738. try {
  3739. var numberValue = JSON.parse(tokenValue);
  3740. if (!isNumber(numberValue)) {
  3741. return _error(localize2("InvalidNumberFormat", "Invalid number format."), ErrorCode.Undefined, node);
  3742. }
  3743. node.value = numberValue;
  3744. } catch (e) {
  3745. return _error(localize2("InvalidNumberFormat", "Invalid number format."), ErrorCode.Undefined, node);
  3746. }
  3747. node.isInteger = tokenValue.indexOf(".") === -1;
  3748. }
  3749. return _finalize(node, true);
  3750. }
  3751. function _parseLiteral(parent) {
  3752. var node;
  3753. switch (scanner2.getToken()) {
  3754. case 7:
  3755. return _finalize(new NullASTNodeImpl(parent, scanner2.getTokenOffset()), true);
  3756. case 8:
  3757. return _finalize(new BooleanASTNodeImpl(parent, true, scanner2.getTokenOffset()), true);
  3758. case 9:
  3759. return _finalize(new BooleanASTNodeImpl(parent, false, scanner2.getTokenOffset()), true);
  3760. default:
  3761. return void 0;
  3762. }
  3763. }
  3764. function _parseValue(parent) {
  3765. return _parseArray(parent) || _parseObject(parent) || _parseString(parent) || _parseNumber(parent) || _parseLiteral(parent);
  3766. }
  3767. var _root = void 0;
  3768. var token = _scanNext();
  3769. if (token !== 17) {
  3770. _root = _parseValue(_root);
  3771. if (!_root) {
  3772. _error(localize2("Invalid symbol", "Expected a JSON object, array or literal."), ErrorCode.Undefined);
  3773. } else if (scanner2.getToken() !== 17) {
  3774. _error(localize2("End of file expected", "End of file expected."), ErrorCode.Undefined);
  3775. }
  3776. }
  3777. return new JSONDocument(_root, problems, commentRanges);
  3778. }
  3779. // node_modules/vscode-json-languageservice/lib/esm/utils/json.js
  3780. function stringifyObject(obj, indent, stringifyLiteral) {
  3781. if (obj !== null && typeof obj === "object") {
  3782. var newIndent = indent + " ";
  3783. if (Array.isArray(obj)) {
  3784. if (obj.length === 0) {
  3785. return "[]";
  3786. }
  3787. var result = "[\n";
  3788. for (var i = 0; i < obj.length; i++) {
  3789. result += newIndent + stringifyObject(obj[i], newIndent, stringifyLiteral);
  3790. if (i < obj.length - 1) {
  3791. result += ",";
  3792. }
  3793. result += "\n";
  3794. }
  3795. result += indent + "]";
  3796. return result;
  3797. } else {
  3798. var keys = Object.keys(obj);
  3799. if (keys.length === 0) {
  3800. return "{}";
  3801. }
  3802. var result = "{\n";
  3803. for (var i = 0; i < keys.length; i++) {
  3804. var key = keys[i];
  3805. result += newIndent + JSON.stringify(key) + ": " + stringifyObject(obj[key], newIndent, stringifyLiteral);
  3806. if (i < keys.length - 1) {
  3807. result += ",";
  3808. }
  3809. result += "\n";
  3810. }
  3811. result += indent + "}";
  3812. return result;
  3813. }
  3814. }
  3815. return stringifyLiteral(obj);
  3816. }
  3817. // node_modules/vscode-json-languageservice/lib/esm/services/jsonCompletion.js
  3818. var localize3 = loadMessageBundle();
  3819. var valueCommitCharacters = [",", "}", "]"];
  3820. var propertyCommitCharacters = [":"];
  3821. var JSONCompletion = function() {
  3822. function JSONCompletion2(schemaService, contributions, promiseConstructor, clientCapabilities) {
  3823. if (contributions === void 0) {
  3824. contributions = [];
  3825. }
  3826. if (promiseConstructor === void 0) {
  3827. promiseConstructor = Promise;
  3828. }
  3829. if (clientCapabilities === void 0) {
  3830. clientCapabilities = {};
  3831. }
  3832. this.schemaService = schemaService;
  3833. this.contributions = contributions;
  3834. this.promiseConstructor = promiseConstructor;
  3835. this.clientCapabilities = clientCapabilities;
  3836. }
  3837. JSONCompletion2.prototype.doResolve = function(item) {
  3838. for (var i = this.contributions.length - 1; i >= 0; i--) {
  3839. var resolveCompletion = this.contributions[i].resolveCompletion;
  3840. if (resolveCompletion) {
  3841. var resolver = resolveCompletion(item);
  3842. if (resolver) {
  3843. return resolver;
  3844. }
  3845. }
  3846. }
  3847. return this.promiseConstructor.resolve(item);
  3848. };
  3849. JSONCompletion2.prototype.doComplete = function(document, position, doc) {
  3850. var _this = this;
  3851. var result = {
  3852. items: [],
  3853. isIncomplete: false
  3854. };
  3855. var text = document.getText();
  3856. var offset = document.offsetAt(position);
  3857. var node = doc.getNodeFromOffset(offset, true);
  3858. if (this.isInComment(document, node ? node.offset : 0, offset)) {
  3859. return Promise.resolve(result);
  3860. }
  3861. if (node && offset === node.offset + node.length && offset > 0) {
  3862. var ch = text[offset - 1];
  3863. if (node.type === "object" && ch === "}" || node.type === "array" && ch === "]") {
  3864. node = node.parent;
  3865. }
  3866. }
  3867. var currentWord = this.getCurrentWord(document, offset);
  3868. var overwriteRange;
  3869. if (node && (node.type === "string" || node.type === "number" || node.type === "boolean" || node.type === "null")) {
  3870. overwriteRange = Range.create(document.positionAt(node.offset), document.positionAt(node.offset + node.length));
  3871. } else {
  3872. var overwriteStart = offset - currentWord.length;
  3873. if (overwriteStart > 0 && text[overwriteStart - 1] === '"') {
  3874. overwriteStart--;
  3875. }
  3876. overwriteRange = Range.create(document.positionAt(overwriteStart), position);
  3877. }
  3878. var supportsCommitCharacters = false;
  3879. var proposed = {};
  3880. var collector = {
  3881. add: function(suggestion) {
  3882. var label = suggestion.label;
  3883. var existing = proposed[label];
  3884. if (!existing) {
  3885. label = label.replace(/[\n]/g, "\u21B5");
  3886. if (label.length > 60) {
  3887. var shortendedLabel = label.substr(0, 57).trim() + "...";
  3888. if (!proposed[shortendedLabel]) {
  3889. label = shortendedLabel;
  3890. }
  3891. }
  3892. if (overwriteRange && suggestion.insertText !== void 0) {
  3893. suggestion.textEdit = TextEdit.replace(overwriteRange, suggestion.insertText);
  3894. }
  3895. if (supportsCommitCharacters) {
  3896. suggestion.commitCharacters = suggestion.kind === CompletionItemKind.Property ? propertyCommitCharacters : valueCommitCharacters;
  3897. }
  3898. suggestion.label = label;
  3899. proposed[label] = suggestion;
  3900. result.items.push(suggestion);
  3901. } else {
  3902. if (!existing.documentation) {
  3903. existing.documentation = suggestion.documentation;
  3904. }
  3905. if (!existing.detail) {
  3906. existing.detail = suggestion.detail;
  3907. }
  3908. }
  3909. },
  3910. setAsIncomplete: function() {
  3911. result.isIncomplete = true;
  3912. },
  3913. error: function(message) {
  3914. console.error(message);
  3915. },
  3916. log: function(message) {
  3917. console.log(message);
  3918. },
  3919. getNumberOfProposals: function() {
  3920. return result.items.length;
  3921. }
  3922. };
  3923. return this.schemaService.getSchemaForResource(document.uri, doc).then(function(schema) {
  3924. var collectionPromises = [];
  3925. var addValue = true;
  3926. var currentKey = "";
  3927. var currentProperty = void 0;
  3928. if (node) {
  3929. if (node.type === "string") {
  3930. var parent = node.parent;
  3931. if (parent && parent.type === "property" && parent.keyNode === node) {
  3932. addValue = !parent.valueNode;
  3933. currentProperty = parent;
  3934. currentKey = text.substr(node.offset + 1, node.length - 2);
  3935. if (parent) {
  3936. node = parent.parent;
  3937. }
  3938. }
  3939. }
  3940. }
  3941. if (node && node.type === "object") {
  3942. if (node.offset === offset) {
  3943. return result;
  3944. }
  3945. var properties = node.properties;
  3946. properties.forEach(function(p) {
  3947. if (!currentProperty || currentProperty !== p) {
  3948. proposed[p.keyNode.value] = CompletionItem.create("__");
  3949. }
  3950. });
  3951. var separatorAfter_1 = "";
  3952. if (addValue) {
  3953. separatorAfter_1 = _this.evaluateSeparatorAfter(document, document.offsetAt(overwriteRange.end));
  3954. }
  3955. if (schema) {
  3956. _this.getPropertyCompletions(schema, doc, node, addValue, separatorAfter_1, collector);
  3957. } else {
  3958. _this.getSchemaLessPropertyCompletions(doc, node, currentKey, collector);
  3959. }
  3960. var location_1 = getNodePath3(node);
  3961. _this.contributions.forEach(function(contribution) {
  3962. var collectPromise = contribution.collectPropertyCompletions(document.uri, location_1, currentWord, addValue, separatorAfter_1 === "", collector);
  3963. if (collectPromise) {
  3964. collectionPromises.push(collectPromise);
  3965. }
  3966. });
  3967. if (!schema && currentWord.length > 0 && text.charAt(offset - currentWord.length - 1) !== '"') {
  3968. collector.add({
  3969. kind: CompletionItemKind.Property,
  3970. label: _this.getLabelForValue(currentWord),
  3971. insertText: _this.getInsertTextForProperty(currentWord, void 0, false, separatorAfter_1),
  3972. insertTextFormat: InsertTextFormat.Snippet,
  3973. documentation: ""
  3974. });
  3975. collector.setAsIncomplete();
  3976. }
  3977. }
  3978. var types = {};
  3979. if (schema) {
  3980. _this.getValueCompletions(schema, doc, node, offset, document, collector, types);
  3981. } else {
  3982. _this.getSchemaLessValueCompletions(doc, node, offset, document, collector);
  3983. }
  3984. if (_this.contributions.length > 0) {
  3985. _this.getContributedValueCompletions(doc, node, offset, document, collector, collectionPromises);
  3986. }
  3987. return _this.promiseConstructor.all(collectionPromises).then(function() {
  3988. if (collector.getNumberOfProposals() === 0) {
  3989. var offsetForSeparator = offset;
  3990. if (node && (node.type === "string" || node.type === "number" || node.type === "boolean" || node.type === "null")) {
  3991. offsetForSeparator = node.offset + node.length;
  3992. }
  3993. var separatorAfter = _this.evaluateSeparatorAfter(document, offsetForSeparator);
  3994. _this.addFillerValueCompletions(types, separatorAfter, collector);
  3995. }
  3996. return result;
  3997. });
  3998. });
  3999. };
  4000. JSONCompletion2.prototype.getPropertyCompletions = function(schema, doc, node, addValue, separatorAfter, collector) {
  4001. var _this = this;
  4002. var matchingSchemas = doc.getMatchingSchemas(schema.schema, node.offset);
  4003. matchingSchemas.forEach(function(s) {
  4004. if (s.node === node && !s.inverted) {
  4005. var schemaProperties_1 = s.schema.properties;
  4006. if (schemaProperties_1) {
  4007. Object.keys(schemaProperties_1).forEach(function(key) {
  4008. var propertySchema = schemaProperties_1[key];
  4009. if (typeof propertySchema === "object" && !propertySchema.deprecationMessage && !propertySchema.doNotSuggest) {
  4010. var proposal = {
  4011. kind: CompletionItemKind.Property,
  4012. label: key,
  4013. insertText: _this.getInsertTextForProperty(key, propertySchema, addValue, separatorAfter),
  4014. insertTextFormat: InsertTextFormat.Snippet,
  4015. filterText: _this.getFilterTextForValue(key),
  4016. documentation: _this.fromMarkup(propertySchema.markdownDescription) || propertySchema.description || ""
  4017. };
  4018. if (propertySchema.suggestSortText !== void 0) {
  4019. proposal.sortText = propertySchema.suggestSortText;
  4020. }
  4021. if (proposal.insertText && endsWith(proposal.insertText, "$1" + separatorAfter)) {
  4022. proposal.command = {
  4023. title: "Suggest",
  4024. command: "editor.action.triggerSuggest"
  4025. };
  4026. }
  4027. collector.add(proposal);
  4028. }
  4029. });
  4030. }
  4031. var schemaPropertyNames_1 = s.schema.propertyNames;
  4032. if (typeof schemaPropertyNames_1 === "object" && !schemaPropertyNames_1.deprecationMessage && !schemaPropertyNames_1.doNotSuggest) {
  4033. var propertyNameCompletionItem = function(name, enumDescription2) {
  4034. if (enumDescription2 === void 0) {
  4035. enumDescription2 = void 0;
  4036. }
  4037. var proposal = {
  4038. kind: CompletionItemKind.Property,
  4039. label: name,
  4040. insertText: _this.getInsertTextForProperty(name, void 0, addValue, separatorAfter),
  4041. insertTextFormat: InsertTextFormat.Snippet,
  4042. filterText: _this.getFilterTextForValue(name),
  4043. documentation: enumDescription2 || _this.fromMarkup(schemaPropertyNames_1.markdownDescription) || schemaPropertyNames_1.description || ""
  4044. };
  4045. if (schemaPropertyNames_1.suggestSortText !== void 0) {
  4046. proposal.sortText = schemaPropertyNames_1.suggestSortText;
  4047. }
  4048. if (proposal.insertText && endsWith(proposal.insertText, "$1" + separatorAfter)) {
  4049. proposal.command = {
  4050. title: "Suggest",
  4051. command: "editor.action.triggerSuggest"
  4052. };
  4053. }
  4054. collector.add(proposal);
  4055. };
  4056. if (schemaPropertyNames_1.enum) {
  4057. for (var i = 0; i < schemaPropertyNames_1.enum.length; i++) {
  4058. var enumDescription = void 0;
  4059. if (schemaPropertyNames_1.markdownEnumDescriptions && i < schemaPropertyNames_1.markdownEnumDescriptions.length) {
  4060. enumDescription = _this.fromMarkup(schemaPropertyNames_1.markdownEnumDescriptions[i]);
  4061. } else if (schemaPropertyNames_1.enumDescriptions && i < schemaPropertyNames_1.enumDescriptions.length) {
  4062. enumDescription = schemaPropertyNames_1.enumDescriptions[i];
  4063. }
  4064. propertyNameCompletionItem(schemaPropertyNames_1.enum[i], enumDescription);
  4065. }
  4066. }
  4067. if (schemaPropertyNames_1.const) {
  4068. propertyNameCompletionItem(schemaPropertyNames_1.const);
  4069. }
  4070. }
  4071. }
  4072. });
  4073. };
  4074. JSONCompletion2.prototype.getSchemaLessPropertyCompletions = function(doc, node, currentKey, collector) {
  4075. var _this = this;
  4076. var collectCompletionsForSimilarObject = function(obj) {
  4077. obj.properties.forEach(function(p) {
  4078. var key = p.keyNode.value;
  4079. collector.add({
  4080. kind: CompletionItemKind.Property,
  4081. label: key,
  4082. insertText: _this.getInsertTextForValue(key, ""),
  4083. insertTextFormat: InsertTextFormat.Snippet,
  4084. filterText: _this.getFilterTextForValue(key),
  4085. documentation: ""
  4086. });
  4087. });
  4088. };
  4089. if (node.parent) {
  4090. if (node.parent.type === "property") {
  4091. var parentKey_1 = node.parent.keyNode.value;
  4092. doc.visit(function(n) {
  4093. if (n.type === "property" && n !== node.parent && n.keyNode.value === parentKey_1 && n.valueNode && n.valueNode.type === "object") {
  4094. collectCompletionsForSimilarObject(n.valueNode);
  4095. }
  4096. return true;
  4097. });
  4098. } else if (node.parent.type === "array") {
  4099. node.parent.items.forEach(function(n) {
  4100. if (n.type === "object" && n !== node) {
  4101. collectCompletionsForSimilarObject(n);
  4102. }
  4103. });
  4104. }
  4105. } else if (node.type === "object") {
  4106. collector.add({
  4107. kind: CompletionItemKind.Property,
  4108. label: "$schema",
  4109. insertText: this.getInsertTextForProperty("$schema", void 0, true, ""),
  4110. insertTextFormat: InsertTextFormat.Snippet,
  4111. documentation: "",
  4112. filterText: this.getFilterTextForValue("$schema")
  4113. });
  4114. }
  4115. };
  4116. JSONCompletion2.prototype.getSchemaLessValueCompletions = function(doc, node, offset, document, collector) {
  4117. var _this = this;
  4118. var offsetForSeparator = offset;
  4119. if (node && (node.type === "string" || node.type === "number" || node.type === "boolean" || node.type === "null")) {
  4120. offsetForSeparator = node.offset + node.length;
  4121. node = node.parent;
  4122. }
  4123. if (!node) {
  4124. collector.add({
  4125. kind: this.getSuggestionKind("object"),
  4126. label: "Empty object",
  4127. insertText: this.getInsertTextForValue({}, ""),
  4128. insertTextFormat: InsertTextFormat.Snippet,
  4129. documentation: ""
  4130. });
  4131. collector.add({
  4132. kind: this.getSuggestionKind("array"),
  4133. label: "Empty array",
  4134. insertText: this.getInsertTextForValue([], ""),
  4135. insertTextFormat: InsertTextFormat.Snippet,
  4136. documentation: ""
  4137. });
  4138. return;
  4139. }
  4140. var separatorAfter = this.evaluateSeparatorAfter(document, offsetForSeparator);
  4141. var collectSuggestionsForValues = function(value) {
  4142. if (value.parent && !contains2(value.parent, offset, true)) {
  4143. collector.add({
  4144. kind: _this.getSuggestionKind(value.type),
  4145. label: _this.getLabelTextForMatchingNode(value, document),
  4146. insertText: _this.getInsertTextForMatchingNode(value, document, separatorAfter),
  4147. insertTextFormat: InsertTextFormat.Snippet,
  4148. documentation: ""
  4149. });
  4150. }
  4151. if (value.type === "boolean") {
  4152. _this.addBooleanValueCompletion(!value.value, separatorAfter, collector);
  4153. }
  4154. };
  4155. if (node.type === "property") {
  4156. if (offset > (node.colonOffset || 0)) {
  4157. var valueNode = node.valueNode;
  4158. if (valueNode && (offset > valueNode.offset + valueNode.length || valueNode.type === "object" || valueNode.type === "array")) {
  4159. return;
  4160. }
  4161. var parentKey_2 = node.keyNode.value;
  4162. doc.visit(function(n) {
  4163. if (n.type === "property" && n.keyNode.value === parentKey_2 && n.valueNode) {
  4164. collectSuggestionsForValues(n.valueNode);
  4165. }
  4166. return true;
  4167. });
  4168. if (parentKey_2 === "$schema" && node.parent && !node.parent.parent) {
  4169. this.addDollarSchemaCompletions(separatorAfter, collector);
  4170. }
  4171. }
  4172. }
  4173. if (node.type === "array") {
  4174. if (node.parent && node.parent.type === "property") {
  4175. var parentKey_3 = node.parent.keyNode.value;
  4176. doc.visit(function(n) {
  4177. if (n.type === "property" && n.keyNode.value === parentKey_3 && n.valueNode && n.valueNode.type === "array") {
  4178. n.valueNode.items.forEach(collectSuggestionsForValues);
  4179. }
  4180. return true;
  4181. });
  4182. } else {
  4183. node.items.forEach(collectSuggestionsForValues);
  4184. }
  4185. }
  4186. };
  4187. JSONCompletion2.prototype.getValueCompletions = function(schema, doc, node, offset, document, collector, types) {
  4188. var offsetForSeparator = offset;
  4189. var parentKey = void 0;
  4190. var valueNode = void 0;
  4191. if (node && (node.type === "string" || node.type === "number" || node.type === "boolean" || node.type === "null")) {
  4192. offsetForSeparator = node.offset + node.length;
  4193. valueNode = node;
  4194. node = node.parent;
  4195. }
  4196. if (!node) {
  4197. this.addSchemaValueCompletions(schema.schema, "", collector, types);
  4198. return;
  4199. }
  4200. if (node.type === "property" && offset > (node.colonOffset || 0)) {
  4201. var valueNode_1 = node.valueNode;
  4202. if (valueNode_1 && offset > valueNode_1.offset + valueNode_1.length) {
  4203. return;
  4204. }
  4205. parentKey = node.keyNode.value;
  4206. node = node.parent;
  4207. }
  4208. if (node && (parentKey !== void 0 || node.type === "array")) {
  4209. var separatorAfter = this.evaluateSeparatorAfter(document, offsetForSeparator);
  4210. var matchingSchemas = doc.getMatchingSchemas(schema.schema, node.offset, valueNode);
  4211. for (var _i = 0, matchingSchemas_1 = matchingSchemas; _i < matchingSchemas_1.length; _i++) {
  4212. var s = matchingSchemas_1[_i];
  4213. if (s.node === node && !s.inverted && s.schema) {
  4214. if (node.type === "array" && s.schema.items) {
  4215. if (Array.isArray(s.schema.items)) {
  4216. var index = this.findItemAtOffset(node, document, offset);
  4217. if (index < s.schema.items.length) {
  4218. this.addSchemaValueCompletions(s.schema.items[index], separatorAfter, collector, types);
  4219. }
  4220. } else {
  4221. this.addSchemaValueCompletions(s.schema.items, separatorAfter, collector, types);
  4222. }
  4223. }
  4224. if (parentKey !== void 0) {
  4225. var propertyMatched = false;
  4226. if (s.schema.properties) {
  4227. var propertySchema = s.schema.properties[parentKey];
  4228. if (propertySchema) {
  4229. propertyMatched = true;
  4230. this.addSchemaValueCompletions(propertySchema, separatorAfter, collector, types);
  4231. }
  4232. }
  4233. if (s.schema.patternProperties && !propertyMatched) {
  4234. for (var _a = 0, _b = Object.keys(s.schema.patternProperties); _a < _b.length; _a++) {
  4235. var pattern = _b[_a];
  4236. var regex = extendedRegExp(pattern);
  4237. if (regex === null || regex === void 0 ? void 0 : regex.test(parentKey)) {
  4238. propertyMatched = true;
  4239. var propertySchema = s.schema.patternProperties[pattern];
  4240. this.addSchemaValueCompletions(propertySchema, separatorAfter, collector, types);
  4241. }
  4242. }
  4243. }
  4244. if (s.schema.additionalProperties && !propertyMatched) {
  4245. var propertySchema = s.schema.additionalProperties;
  4246. this.addSchemaValueCompletions(propertySchema, separatorAfter, collector, types);
  4247. }
  4248. }
  4249. }
  4250. }
  4251. if (parentKey === "$schema" && !node.parent) {
  4252. this.addDollarSchemaCompletions(separatorAfter, collector);
  4253. }
  4254. if (types["boolean"]) {
  4255. this.addBooleanValueCompletion(true, separatorAfter, collector);
  4256. this.addBooleanValueCompletion(false, separatorAfter, collector);
  4257. }
  4258. if (types["null"]) {
  4259. this.addNullValueCompletion(separatorAfter, collector);
  4260. }
  4261. }
  4262. };
  4263. JSONCompletion2.prototype.getContributedValueCompletions = function(doc, node, offset, document, collector, collectionPromises) {
  4264. if (!node) {
  4265. this.contributions.forEach(function(contribution) {
  4266. var collectPromise = contribution.collectDefaultCompletions(document.uri, collector);
  4267. if (collectPromise) {
  4268. collectionPromises.push(collectPromise);
  4269. }
  4270. });
  4271. } else {
  4272. if (node.type === "string" || node.type === "number" || node.type === "boolean" || node.type === "null") {
  4273. node = node.parent;
  4274. }
  4275. if (node && node.type === "property" && offset > (node.colonOffset || 0)) {
  4276. var parentKey_4 = node.keyNode.value;
  4277. var valueNode = node.valueNode;
  4278. if ((!valueNode || offset <= valueNode.offset + valueNode.length) && node.parent) {
  4279. var location_2 = getNodePath3(node.parent);
  4280. this.contributions.forEach(function(contribution) {
  4281. var collectPromise = contribution.collectValueCompletions(document.uri, location_2, parentKey_4, collector);
  4282. if (collectPromise) {
  4283. collectionPromises.push(collectPromise);
  4284. }
  4285. });
  4286. }
  4287. }
  4288. }
  4289. };
  4290. JSONCompletion2.prototype.addSchemaValueCompletions = function(schema, separatorAfter, collector, types) {
  4291. var _this = this;
  4292. if (typeof schema === "object") {
  4293. this.addEnumValueCompletions(schema, separatorAfter, collector);
  4294. this.addDefaultValueCompletions(schema, separatorAfter, collector);
  4295. this.collectTypes(schema, types);
  4296. if (Array.isArray(schema.allOf)) {
  4297. schema.allOf.forEach(function(s) {
  4298. return _this.addSchemaValueCompletions(s, separatorAfter, collector, types);
  4299. });
  4300. }
  4301. if (Array.isArray(schema.anyOf)) {
  4302. schema.anyOf.forEach(function(s) {
  4303. return _this.addSchemaValueCompletions(s, separatorAfter, collector, types);
  4304. });
  4305. }
  4306. if (Array.isArray(schema.oneOf)) {
  4307. schema.oneOf.forEach(function(s) {
  4308. return _this.addSchemaValueCompletions(s, separatorAfter, collector, types);
  4309. });
  4310. }
  4311. }
  4312. };
  4313. JSONCompletion2.prototype.addDefaultValueCompletions = function(schema, separatorAfter, collector, arrayDepth) {
  4314. var _this = this;
  4315. if (arrayDepth === void 0) {
  4316. arrayDepth = 0;
  4317. }
  4318. var hasProposals = false;
  4319. if (isDefined(schema.default)) {
  4320. var type = schema.type;
  4321. var value = schema.default;
  4322. for (var i = arrayDepth; i > 0; i--) {
  4323. value = [value];
  4324. type = "array";
  4325. }
  4326. collector.add({
  4327. kind: this.getSuggestionKind(type),
  4328. label: this.getLabelForValue(value),
  4329. insertText: this.getInsertTextForValue(value, separatorAfter),
  4330. insertTextFormat: InsertTextFormat.Snippet,
  4331. detail: localize3("json.suggest.default", "Default value")
  4332. });
  4333. hasProposals = true;
  4334. }
  4335. if (Array.isArray(schema.examples)) {
  4336. schema.examples.forEach(function(example) {
  4337. var type2 = schema.type;
  4338. var value2 = example;
  4339. for (var i2 = arrayDepth; i2 > 0; i2--) {
  4340. value2 = [value2];
  4341. type2 = "array";
  4342. }
  4343. collector.add({
  4344. kind: _this.getSuggestionKind(type2),
  4345. label: _this.getLabelForValue(value2),
  4346. insertText: _this.getInsertTextForValue(value2, separatorAfter),
  4347. insertTextFormat: InsertTextFormat.Snippet
  4348. });
  4349. hasProposals = true;
  4350. });
  4351. }
  4352. if (Array.isArray(schema.defaultSnippets)) {
  4353. schema.defaultSnippets.forEach(function(s) {
  4354. var type2 = schema.type;
  4355. var value2 = s.body;
  4356. var label = s.label;
  4357. var insertText;
  4358. var filterText;
  4359. if (isDefined(value2)) {
  4360. var type_1 = schema.type;
  4361. for (var i2 = arrayDepth; i2 > 0; i2--) {
  4362. value2 = [value2];
  4363. type_1 = "array";
  4364. }
  4365. insertText = _this.getInsertTextForSnippetValue(value2, separatorAfter);
  4366. filterText = _this.getFilterTextForSnippetValue(value2);
  4367. label = label || _this.getLabelForSnippetValue(value2);
  4368. } else if (typeof s.bodyText === "string") {
  4369. var prefix = "", suffix = "", indent = "";
  4370. for (var i2 = arrayDepth; i2 > 0; i2--) {
  4371. prefix = prefix + indent + "[\n";
  4372. suffix = suffix + "\n" + indent + "]";
  4373. indent += " ";
  4374. type2 = "array";
  4375. }
  4376. insertText = prefix + indent + s.bodyText.split("\n").join("\n" + indent) + suffix + separatorAfter;
  4377. label = label || insertText, filterText = insertText.replace(/[\n]/g, "");
  4378. } else {
  4379. return;
  4380. }
  4381. collector.add({
  4382. kind: _this.getSuggestionKind(type2),
  4383. label,
  4384. documentation: _this.fromMarkup(s.markdownDescription) || s.description,
  4385. insertText,
  4386. insertTextFormat: InsertTextFormat.Snippet,
  4387. filterText
  4388. });
  4389. hasProposals = true;
  4390. });
  4391. }
  4392. if (!hasProposals && typeof schema.items === "object" && !Array.isArray(schema.items) && arrayDepth < 5) {
  4393. this.addDefaultValueCompletions(schema.items, separatorAfter, collector, arrayDepth + 1);
  4394. }
  4395. };
  4396. JSONCompletion2.prototype.addEnumValueCompletions = function(schema, separatorAfter, collector) {
  4397. if (isDefined(schema.const)) {
  4398. collector.add({
  4399. kind: this.getSuggestionKind(schema.type),
  4400. label: this.getLabelForValue(schema.const),
  4401. insertText: this.getInsertTextForValue(schema.const, separatorAfter),
  4402. insertTextFormat: InsertTextFormat.Snippet,
  4403. documentation: this.fromMarkup(schema.markdownDescription) || schema.description
  4404. });
  4405. }
  4406. if (Array.isArray(schema.enum)) {
  4407. for (var i = 0, length = schema.enum.length; i < length; i++) {
  4408. var enm = schema.enum[i];
  4409. var documentation = this.fromMarkup(schema.markdownDescription) || schema.description;
  4410. if (schema.markdownEnumDescriptions && i < schema.markdownEnumDescriptions.length && this.doesSupportMarkdown()) {
  4411. documentation = this.fromMarkup(schema.markdownEnumDescriptions[i]);
  4412. } else if (schema.enumDescriptions && i < schema.enumDescriptions.length) {
  4413. documentation = schema.enumDescriptions[i];
  4414. }
  4415. collector.add({
  4416. kind: this.getSuggestionKind(schema.type),
  4417. label: this.getLabelForValue(enm),
  4418. insertText: this.getInsertTextForValue(enm, separatorAfter),
  4419. insertTextFormat: InsertTextFormat.Snippet,
  4420. documentation
  4421. });
  4422. }
  4423. }
  4424. };
  4425. JSONCompletion2.prototype.collectTypes = function(schema, types) {
  4426. if (Array.isArray(schema.enum) || isDefined(schema.const)) {
  4427. return;
  4428. }
  4429. var type = schema.type;
  4430. if (Array.isArray(type)) {
  4431. type.forEach(function(t) {
  4432. return types[t] = true;
  4433. });
  4434. } else if (type) {
  4435. types[type] = true;
  4436. }
  4437. };
  4438. JSONCompletion2.prototype.addFillerValueCompletions = function(types, separatorAfter, collector) {
  4439. if (types["object"]) {
  4440. collector.add({
  4441. kind: this.getSuggestionKind("object"),
  4442. label: "{}",
  4443. insertText: this.getInsertTextForGuessedValue({}, separatorAfter),
  4444. insertTextFormat: InsertTextFormat.Snippet,
  4445. detail: localize3("defaults.object", "New object"),
  4446. documentation: ""
  4447. });
  4448. }
  4449. if (types["array"]) {
  4450. collector.add({
  4451. kind: this.getSuggestionKind("array"),
  4452. label: "[]",
  4453. insertText: this.getInsertTextForGuessedValue([], separatorAfter),
  4454. insertTextFormat: InsertTextFormat.Snippet,
  4455. detail: localize3("defaults.array", "New array"),
  4456. documentation: ""
  4457. });
  4458. }
  4459. };
  4460. JSONCompletion2.prototype.addBooleanValueCompletion = function(value, separatorAfter, collector) {
  4461. collector.add({
  4462. kind: this.getSuggestionKind("boolean"),
  4463. label: value ? "true" : "false",
  4464. insertText: this.getInsertTextForValue(value, separatorAfter),
  4465. insertTextFormat: InsertTextFormat.Snippet,
  4466. documentation: ""
  4467. });
  4468. };
  4469. JSONCompletion2.prototype.addNullValueCompletion = function(separatorAfter, collector) {
  4470. collector.add({
  4471. kind: this.getSuggestionKind("null"),
  4472. label: "null",
  4473. insertText: "null" + separatorAfter,
  4474. insertTextFormat: InsertTextFormat.Snippet,
  4475. documentation: ""
  4476. });
  4477. };
  4478. JSONCompletion2.prototype.addDollarSchemaCompletions = function(separatorAfter, collector) {
  4479. var _this = this;
  4480. var schemaIds = this.schemaService.getRegisteredSchemaIds(function(schema) {
  4481. return schema === "http" || schema === "https";
  4482. });
  4483. schemaIds.forEach(function(schemaId) {
  4484. return collector.add({
  4485. kind: CompletionItemKind.Module,
  4486. label: _this.getLabelForValue(schemaId),
  4487. filterText: _this.getFilterTextForValue(schemaId),
  4488. insertText: _this.getInsertTextForValue(schemaId, separatorAfter),
  4489. insertTextFormat: InsertTextFormat.Snippet,
  4490. documentation: ""
  4491. });
  4492. });
  4493. };
  4494. JSONCompletion2.prototype.getLabelForValue = function(value) {
  4495. return JSON.stringify(value);
  4496. };
  4497. JSONCompletion2.prototype.getFilterTextForValue = function(value) {
  4498. return JSON.stringify(value);
  4499. };
  4500. JSONCompletion2.prototype.getFilterTextForSnippetValue = function(value) {
  4501. return JSON.stringify(value).replace(/\$\{\d+:([^}]+)\}|\$\d+/g, "$1");
  4502. };
  4503. JSONCompletion2.prototype.getLabelForSnippetValue = function(value) {
  4504. var label = JSON.stringify(value);
  4505. return label.replace(/\$\{\d+:([^}]+)\}|\$\d+/g, "$1");
  4506. };
  4507. JSONCompletion2.prototype.getInsertTextForPlainText = function(text) {
  4508. return text.replace(/[\\\$\}]/g, "\\$&");
  4509. };
  4510. JSONCompletion2.prototype.getInsertTextForValue = function(value, separatorAfter) {
  4511. var text = JSON.stringify(value, null, " ");
  4512. if (text === "{}") {
  4513. return "{$1}" + separatorAfter;
  4514. } else if (text === "[]") {
  4515. return "[$1]" + separatorAfter;
  4516. }
  4517. return this.getInsertTextForPlainText(text + separatorAfter);
  4518. };
  4519. JSONCompletion2.prototype.getInsertTextForSnippetValue = function(value, separatorAfter) {
  4520. var replacer = function(value2) {
  4521. if (typeof value2 === "string") {
  4522. if (value2[0] === "^") {
  4523. return value2.substr(1);
  4524. }
  4525. }
  4526. return JSON.stringify(value2);
  4527. };
  4528. return stringifyObject(value, "", replacer) + separatorAfter;
  4529. };
  4530. JSONCompletion2.prototype.getInsertTextForGuessedValue = function(value, separatorAfter) {
  4531. switch (typeof value) {
  4532. case "object":
  4533. if (value === null) {
  4534. return "${1:null}" + separatorAfter;
  4535. }
  4536. return this.getInsertTextForValue(value, separatorAfter);
  4537. case "string":
  4538. var snippetValue = JSON.stringify(value);
  4539. snippetValue = snippetValue.substr(1, snippetValue.length - 2);
  4540. snippetValue = this.getInsertTextForPlainText(snippetValue);
  4541. return '"${1:' + snippetValue + '}"' + separatorAfter;
  4542. case "number":
  4543. case "boolean":
  4544. return "${1:" + JSON.stringify(value) + "}" + separatorAfter;
  4545. }
  4546. return this.getInsertTextForValue(value, separatorAfter);
  4547. };
  4548. JSONCompletion2.prototype.getSuggestionKind = function(type) {
  4549. if (Array.isArray(type)) {
  4550. var array = type;
  4551. type = array.length > 0 ? array[0] : void 0;
  4552. }
  4553. if (!type) {
  4554. return CompletionItemKind.Value;
  4555. }
  4556. switch (type) {
  4557. case "string":
  4558. return CompletionItemKind.Value;
  4559. case "object":
  4560. return CompletionItemKind.Module;
  4561. case "property":
  4562. return CompletionItemKind.Property;
  4563. default:
  4564. return CompletionItemKind.Value;
  4565. }
  4566. };
  4567. JSONCompletion2.prototype.getLabelTextForMatchingNode = function(node, document) {
  4568. switch (node.type) {
  4569. case "array":
  4570. return "[]";
  4571. case "object":
  4572. return "{}";
  4573. default:
  4574. var content = document.getText().substr(node.offset, node.length);
  4575. return content;
  4576. }
  4577. };
  4578. JSONCompletion2.prototype.getInsertTextForMatchingNode = function(node, document, separatorAfter) {
  4579. switch (node.type) {
  4580. case "array":
  4581. return this.getInsertTextForValue([], separatorAfter);
  4582. case "object":
  4583. return this.getInsertTextForValue({}, separatorAfter);
  4584. default:
  4585. var content = document.getText().substr(node.offset, node.length) + separatorAfter;
  4586. return this.getInsertTextForPlainText(content);
  4587. }
  4588. };
  4589. JSONCompletion2.prototype.getInsertTextForProperty = function(key, propertySchema, addValue, separatorAfter) {
  4590. var propertyText = this.getInsertTextForValue(key, "");
  4591. if (!addValue) {
  4592. return propertyText;
  4593. }
  4594. var resultText = propertyText + ": ";
  4595. var value;
  4596. var nValueProposals = 0;
  4597. if (propertySchema) {
  4598. if (Array.isArray(propertySchema.defaultSnippets)) {
  4599. if (propertySchema.defaultSnippets.length === 1) {
  4600. var body = propertySchema.defaultSnippets[0].body;
  4601. if (isDefined(body)) {
  4602. value = this.getInsertTextForSnippetValue(body, "");
  4603. }
  4604. }
  4605. nValueProposals += propertySchema.defaultSnippets.length;
  4606. }
  4607. if (propertySchema.enum) {
  4608. if (!value && propertySchema.enum.length === 1) {
  4609. value = this.getInsertTextForGuessedValue(propertySchema.enum[0], "");
  4610. }
  4611. nValueProposals += propertySchema.enum.length;
  4612. }
  4613. if (isDefined(propertySchema.default)) {
  4614. if (!value) {
  4615. value = this.getInsertTextForGuessedValue(propertySchema.default, "");
  4616. }
  4617. nValueProposals++;
  4618. }
  4619. if (Array.isArray(propertySchema.examples) && propertySchema.examples.length) {
  4620. if (!value) {
  4621. value = this.getInsertTextForGuessedValue(propertySchema.examples[0], "");
  4622. }
  4623. nValueProposals += propertySchema.examples.length;
  4624. }
  4625. if (nValueProposals === 0) {
  4626. var type = Array.isArray(propertySchema.type) ? propertySchema.type[0] : propertySchema.type;
  4627. if (!type) {
  4628. if (propertySchema.properties) {
  4629. type = "object";
  4630. } else if (propertySchema.items) {
  4631. type = "array";
  4632. }
  4633. }
  4634. switch (type) {
  4635. case "boolean":
  4636. value = "$1";
  4637. break;
  4638. case "string":
  4639. value = '"$1"';
  4640. break;
  4641. case "object":
  4642. value = "{$1}";
  4643. break;
  4644. case "array":
  4645. value = "[$1]";
  4646. break;
  4647. case "number":
  4648. case "integer":
  4649. value = "${1:0}";
  4650. break;
  4651. case "null":
  4652. value = "${1:null}";
  4653. break;
  4654. default:
  4655. return propertyText;
  4656. }
  4657. }
  4658. }
  4659. if (!value || nValueProposals > 1) {
  4660. value = "$1";
  4661. }
  4662. return resultText + value + separatorAfter;
  4663. };
  4664. JSONCompletion2.prototype.getCurrentWord = function(document, offset) {
  4665. var i = offset - 1;
  4666. var text = document.getText();
  4667. while (i >= 0 && ' \n\r\v":{[,]}'.indexOf(text.charAt(i)) === -1) {
  4668. i--;
  4669. }
  4670. return text.substring(i + 1, offset);
  4671. };
  4672. JSONCompletion2.prototype.evaluateSeparatorAfter = function(document, offset) {
  4673. var scanner2 = createScanner2(document.getText(), true);
  4674. scanner2.setPosition(offset);
  4675. var token = scanner2.scan();
  4676. switch (token) {
  4677. case 5:
  4678. case 2:
  4679. case 4:
  4680. case 17:
  4681. return "";
  4682. default:
  4683. return ",";
  4684. }
  4685. };
  4686. JSONCompletion2.prototype.findItemAtOffset = function(node, document, offset) {
  4687. var scanner2 = createScanner2(document.getText(), true);
  4688. var children = node.items;
  4689. for (var i = children.length - 1; i >= 0; i--) {
  4690. var child = children[i];
  4691. if (offset > child.offset + child.length) {
  4692. scanner2.setPosition(child.offset + child.length);
  4693. var token = scanner2.scan();
  4694. if (token === 5 && offset >= scanner2.getTokenOffset() + scanner2.getTokenLength()) {
  4695. return i + 1;
  4696. }
  4697. return i;
  4698. } else if (offset >= child.offset) {
  4699. return i;
  4700. }
  4701. }
  4702. return 0;
  4703. };
  4704. JSONCompletion2.prototype.isInComment = function(document, start, offset) {
  4705. var scanner2 = createScanner2(document.getText(), false);
  4706. scanner2.setPosition(start);
  4707. var token = scanner2.scan();
  4708. while (token !== 17 && scanner2.getTokenOffset() + scanner2.getTokenLength() < offset) {
  4709. token = scanner2.scan();
  4710. }
  4711. return (token === 12 || token === 13) && scanner2.getTokenOffset() <= offset;
  4712. };
  4713. JSONCompletion2.prototype.fromMarkup = function(markupString) {
  4714. if (markupString && this.doesSupportMarkdown()) {
  4715. return {
  4716. kind: MarkupKind.Markdown,
  4717. value: markupString
  4718. };
  4719. }
  4720. return void 0;
  4721. };
  4722. JSONCompletion2.prototype.doesSupportMarkdown = function() {
  4723. if (!isDefined(this.supportsMarkdown)) {
  4724. var completion = this.clientCapabilities.textDocument && this.clientCapabilities.textDocument.completion;
  4725. this.supportsMarkdown = completion && completion.completionItem && Array.isArray(completion.completionItem.documentationFormat) && completion.completionItem.documentationFormat.indexOf(MarkupKind.Markdown) !== -1;
  4726. }
  4727. return this.supportsMarkdown;
  4728. };
  4729. JSONCompletion2.prototype.doesSupportsCommitCharacters = function() {
  4730. if (!isDefined(this.supportsCommitCharacters)) {
  4731. var completion = this.clientCapabilities.textDocument && this.clientCapabilities.textDocument.completion;
  4732. this.supportsCommitCharacters = completion && completion.completionItem && !!completion.completionItem.commitCharactersSupport;
  4733. }
  4734. return this.supportsCommitCharacters;
  4735. };
  4736. return JSONCompletion2;
  4737. }();
  4738. // node_modules/vscode-json-languageservice/lib/esm/services/jsonHover.js
  4739. var JSONHover = function() {
  4740. function JSONHover2(schemaService, contributions, promiseConstructor) {
  4741. if (contributions === void 0) {
  4742. contributions = [];
  4743. }
  4744. this.schemaService = schemaService;
  4745. this.contributions = contributions;
  4746. this.promise = promiseConstructor || Promise;
  4747. }
  4748. JSONHover2.prototype.doHover = function(document, position, doc) {
  4749. var offset = document.offsetAt(position);
  4750. var node = doc.getNodeFromOffset(offset);
  4751. if (!node || (node.type === "object" || node.type === "array") && offset > node.offset + 1 && offset < node.offset + node.length - 1) {
  4752. return this.promise.resolve(null);
  4753. }
  4754. var hoverRangeNode = node;
  4755. if (node.type === "string") {
  4756. var parent = node.parent;
  4757. if (parent && parent.type === "property" && parent.keyNode === node) {
  4758. node = parent.valueNode;
  4759. if (!node) {
  4760. return this.promise.resolve(null);
  4761. }
  4762. }
  4763. }
  4764. var hoverRange = Range.create(document.positionAt(hoverRangeNode.offset), document.positionAt(hoverRangeNode.offset + hoverRangeNode.length));
  4765. var createHover = function(contents) {
  4766. var result = {
  4767. contents,
  4768. range: hoverRange
  4769. };
  4770. return result;
  4771. };
  4772. var location = getNodePath3(node);
  4773. for (var i = this.contributions.length - 1; i >= 0; i--) {
  4774. var contribution = this.contributions[i];
  4775. var promise = contribution.getInfoContribution(document.uri, location);
  4776. if (promise) {
  4777. return promise.then(function(htmlContent) {
  4778. return createHover(htmlContent);
  4779. });
  4780. }
  4781. }
  4782. return this.schemaService.getSchemaForResource(document.uri, doc).then(function(schema) {
  4783. if (schema && node) {
  4784. var matchingSchemas = doc.getMatchingSchemas(schema.schema, node.offset);
  4785. var title_1 = void 0;
  4786. var markdownDescription_1 = void 0;
  4787. var markdownEnumValueDescription_1 = void 0, enumValue_1 = void 0;
  4788. matchingSchemas.every(function(s) {
  4789. if (s.node === node && !s.inverted && s.schema) {
  4790. title_1 = title_1 || s.schema.title;
  4791. markdownDescription_1 = markdownDescription_1 || s.schema.markdownDescription || toMarkdown(s.schema.description);
  4792. if (s.schema.enum) {
  4793. var idx = s.schema.enum.indexOf(getNodeValue3(node));
  4794. if (s.schema.markdownEnumDescriptions) {
  4795. markdownEnumValueDescription_1 = s.schema.markdownEnumDescriptions[idx];
  4796. } else if (s.schema.enumDescriptions) {
  4797. markdownEnumValueDescription_1 = toMarkdown(s.schema.enumDescriptions[idx]);
  4798. }
  4799. if (markdownEnumValueDescription_1) {
  4800. enumValue_1 = s.schema.enum[idx];
  4801. if (typeof enumValue_1 !== "string") {
  4802. enumValue_1 = JSON.stringify(enumValue_1);
  4803. }
  4804. }
  4805. }
  4806. }
  4807. return true;
  4808. });
  4809. var result = "";
  4810. if (title_1) {
  4811. result = toMarkdown(title_1);
  4812. }
  4813. if (markdownDescription_1) {
  4814. if (result.length > 0) {
  4815. result += "\n\n";
  4816. }
  4817. result += markdownDescription_1;
  4818. }
  4819. if (markdownEnumValueDescription_1) {
  4820. if (result.length > 0) {
  4821. result += "\n\n";
  4822. }
  4823. result += "`" + toMarkdownCodeBlock(enumValue_1) + "`: " + markdownEnumValueDescription_1;
  4824. }
  4825. return createHover([result]);
  4826. }
  4827. return null;
  4828. });
  4829. };
  4830. return JSONHover2;
  4831. }();
  4832. function toMarkdown(plain) {
  4833. if (plain) {
  4834. var res = plain.replace(/([^\n\r])(\r?\n)([^\n\r])/gm, "$1\n\n$3");
  4835. return res.replace(/[\\`*_{}[\]()#+\-.!]/g, "\\$&");
  4836. }
  4837. return void 0;
  4838. }
  4839. function toMarkdownCodeBlock(content) {
  4840. if (content.indexOf("`") !== -1) {
  4841. return "`` " + content + " ``";
  4842. }
  4843. return content;
  4844. }
  4845. // node_modules/vscode-uri/lib/esm/index.js
  4846. var LIB;
  4847. LIB = (() => {
  4848. "use strict";
  4849. var t = { 470: (t2) => {
  4850. function e2(t3) {
  4851. if (typeof t3 != "string")
  4852. throw new TypeError("Path must be a string. Received " + JSON.stringify(t3));
  4853. }
  4854. function r2(t3, e3) {
  4855. for (var r3, n2 = "", o = 0, i = -1, a2 = 0, h = 0; h <= t3.length; ++h) {
  4856. if (h < t3.length)
  4857. r3 = t3.charCodeAt(h);
  4858. else {
  4859. if (r3 === 47)
  4860. break;
  4861. r3 = 47;
  4862. }
  4863. if (r3 === 47) {
  4864. if (i === h - 1 || a2 === 1)
  4865. ;
  4866. else if (i !== h - 1 && a2 === 2) {
  4867. if (n2.length < 2 || o !== 2 || n2.charCodeAt(n2.length - 1) !== 46 || n2.charCodeAt(n2.length - 2) !== 46) {
  4868. if (n2.length > 2) {
  4869. var s = n2.lastIndexOf("/");
  4870. if (s !== n2.length - 1) {
  4871. s === -1 ? (n2 = "", o = 0) : o = (n2 = n2.slice(0, s)).length - 1 - n2.lastIndexOf("/"), i = h, a2 = 0;
  4872. continue;
  4873. }
  4874. } else if (n2.length === 2 || n2.length === 1) {
  4875. n2 = "", o = 0, i = h, a2 = 0;
  4876. continue;
  4877. }
  4878. }
  4879. e3 && (n2.length > 0 ? n2 += "/.." : n2 = "..", o = 2);
  4880. } else
  4881. n2.length > 0 ? n2 += "/" + t3.slice(i + 1, h) : n2 = t3.slice(i + 1, h), o = h - i - 1;
  4882. i = h, a2 = 0;
  4883. } else
  4884. r3 === 46 && a2 !== -1 ? ++a2 : a2 = -1;
  4885. }
  4886. return n2;
  4887. }
  4888. var n = { resolve: function() {
  4889. for (var t3, n2 = "", o = false, i = arguments.length - 1; i >= -1 && !o; i--) {
  4890. var a2;
  4891. i >= 0 ? a2 = arguments[i] : (t3 === void 0 && (t3 = process.cwd()), a2 = t3), e2(a2), a2.length !== 0 && (n2 = a2 + "/" + n2, o = a2.charCodeAt(0) === 47);
  4892. }
  4893. return n2 = r2(n2, !o), o ? n2.length > 0 ? "/" + n2 : "/" : n2.length > 0 ? n2 : ".";
  4894. }, normalize: function(t3) {
  4895. if (e2(t3), t3.length === 0)
  4896. return ".";
  4897. var n2 = t3.charCodeAt(0) === 47, o = t3.charCodeAt(t3.length - 1) === 47;
  4898. return (t3 = r2(t3, !n2)).length !== 0 || n2 || (t3 = "."), t3.length > 0 && o && (t3 += "/"), n2 ? "/" + t3 : t3;
  4899. }, isAbsolute: function(t3) {
  4900. return e2(t3), t3.length > 0 && t3.charCodeAt(0) === 47;
  4901. }, join: function() {
  4902. if (arguments.length === 0)
  4903. return ".";
  4904. for (var t3, r3 = 0; r3 < arguments.length; ++r3) {
  4905. var o = arguments[r3];
  4906. e2(o), o.length > 0 && (t3 === void 0 ? t3 = o : t3 += "/" + o);
  4907. }
  4908. return t3 === void 0 ? "." : n.normalize(t3);
  4909. }, relative: function(t3, r3) {
  4910. if (e2(t3), e2(r3), t3 === r3)
  4911. return "";
  4912. if ((t3 = n.resolve(t3)) === (r3 = n.resolve(r3)))
  4913. return "";
  4914. for (var o = 1; o < t3.length && t3.charCodeAt(o) === 47; ++o)
  4915. ;
  4916. for (var i = t3.length, a2 = i - o, h = 1; h < r3.length && r3.charCodeAt(h) === 47; ++h)
  4917. ;
  4918. for (var s = r3.length - h, f2 = a2 < s ? a2 : s, u = -1, c = 0; c <= f2; ++c) {
  4919. if (c === f2) {
  4920. if (s > f2) {
  4921. if (r3.charCodeAt(h + c) === 47)
  4922. return r3.slice(h + c + 1);
  4923. if (c === 0)
  4924. return r3.slice(h + c);
  4925. } else
  4926. a2 > f2 && (t3.charCodeAt(o + c) === 47 ? u = c : c === 0 && (u = 0));
  4927. break;
  4928. }
  4929. var l = t3.charCodeAt(o + c);
  4930. if (l !== r3.charCodeAt(h + c))
  4931. break;
  4932. l === 47 && (u = c);
  4933. }
  4934. var p = "";
  4935. for (c = o + u + 1; c <= i; ++c)
  4936. c !== i && t3.charCodeAt(c) !== 47 || (p.length === 0 ? p += ".." : p += "/..");
  4937. return p.length > 0 ? p + r3.slice(h + u) : (h += u, r3.charCodeAt(h) === 47 && ++h, r3.slice(h));
  4938. }, _makeLong: function(t3) {
  4939. return t3;
  4940. }, dirname: function(t3) {
  4941. if (e2(t3), t3.length === 0)
  4942. return ".";
  4943. for (var r3 = t3.charCodeAt(0), n2 = r3 === 47, o = -1, i = true, a2 = t3.length - 1; a2 >= 1; --a2)
  4944. if ((r3 = t3.charCodeAt(a2)) === 47) {
  4945. if (!i) {
  4946. o = a2;
  4947. break;
  4948. }
  4949. } else
  4950. i = false;
  4951. return o === -1 ? n2 ? "/" : "." : n2 && o === 1 ? "//" : t3.slice(0, o);
  4952. }, basename: function(t3, r3) {
  4953. if (r3 !== void 0 && typeof r3 != "string")
  4954. throw new TypeError('"ext" argument must be a string');
  4955. e2(t3);
  4956. var n2, o = 0, i = -1, a2 = true;
  4957. if (r3 !== void 0 && r3.length > 0 && r3.length <= t3.length) {
  4958. if (r3.length === t3.length && r3 === t3)
  4959. return "";
  4960. var h = r3.length - 1, s = -1;
  4961. for (n2 = t3.length - 1; n2 >= 0; --n2) {
  4962. var f2 = t3.charCodeAt(n2);
  4963. if (f2 === 47) {
  4964. if (!a2) {
  4965. o = n2 + 1;
  4966. break;
  4967. }
  4968. } else
  4969. s === -1 && (a2 = false, s = n2 + 1), h >= 0 && (f2 === r3.charCodeAt(h) ? --h == -1 && (i = n2) : (h = -1, i = s));
  4970. }
  4971. return o === i ? i = s : i === -1 && (i = t3.length), t3.slice(o, i);
  4972. }
  4973. for (n2 = t3.length - 1; n2 >= 0; --n2)
  4974. if (t3.charCodeAt(n2) === 47) {
  4975. if (!a2) {
  4976. o = n2 + 1;
  4977. break;
  4978. }
  4979. } else
  4980. i === -1 && (a2 = false, i = n2 + 1);
  4981. return i === -1 ? "" : t3.slice(o, i);
  4982. }, extname: function(t3) {
  4983. e2(t3);
  4984. for (var r3 = -1, n2 = 0, o = -1, i = true, a2 = 0, h = t3.length - 1; h >= 0; --h) {
  4985. var s = t3.charCodeAt(h);
  4986. if (s !== 47)
  4987. o === -1 && (i = false, o = h + 1), s === 46 ? r3 === -1 ? r3 = h : a2 !== 1 && (a2 = 1) : r3 !== -1 && (a2 = -1);
  4988. else if (!i) {
  4989. n2 = h + 1;
  4990. break;
  4991. }
  4992. }
  4993. return r3 === -1 || o === -1 || a2 === 0 || a2 === 1 && r3 === o - 1 && r3 === n2 + 1 ? "" : t3.slice(r3, o);
  4994. }, format: function(t3) {
  4995. if (t3 === null || typeof t3 != "object")
  4996. throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof t3);
  4997. return function(t4, e3) {
  4998. var r3 = e3.dir || e3.root, n2 = e3.base || (e3.name || "") + (e3.ext || "");
  4999. return r3 ? r3 === e3.root ? r3 + n2 : r3 + "/" + n2 : n2;
  5000. }(0, t3);
  5001. }, parse: function(t3) {
  5002. e2(t3);
  5003. var r3 = { root: "", dir: "", base: "", ext: "", name: "" };
  5004. if (t3.length === 0)
  5005. return r3;
  5006. var n2, o = t3.charCodeAt(0), i = o === 47;
  5007. i ? (r3.root = "/", n2 = 1) : n2 = 0;
  5008. for (var a2 = -1, h = 0, s = -1, f2 = true, u = t3.length - 1, c = 0; u >= n2; --u)
  5009. if ((o = t3.charCodeAt(u)) !== 47)
  5010. s === -1 && (f2 = false, s = u + 1), o === 46 ? a2 === -1 ? a2 = u : c !== 1 && (c = 1) : a2 !== -1 && (c = -1);
  5011. else if (!f2) {
  5012. h = u + 1;
  5013. break;
  5014. }
  5015. return a2 === -1 || s === -1 || c === 0 || c === 1 && a2 === s - 1 && a2 === h + 1 ? s !== -1 && (r3.base = r3.name = h === 0 && i ? t3.slice(1, s) : t3.slice(h, s)) : (h === 0 && i ? (r3.name = t3.slice(1, a2), r3.base = t3.slice(1, s)) : (r3.name = t3.slice(h, a2), r3.base = t3.slice(h, s)), r3.ext = t3.slice(a2, s)), h > 0 ? r3.dir = t3.slice(0, h - 1) : i && (r3.dir = "/"), r3;
  5016. }, sep: "/", delimiter: ":", win32: null, posix: null };
  5017. n.posix = n, t2.exports = n;
  5018. }, 447: (t2, e2, r2) => {
  5019. var n;
  5020. if (r2.r(e2), r2.d(e2, { URI: () => g, Utils: () => O }), typeof process == "object")
  5021. n = process.platform === "win32";
  5022. else if (typeof navigator == "object") {
  5023. var o = navigator.userAgent;
  5024. n = o.indexOf("Windows") >= 0;
  5025. }
  5026. var i, a2, h = (i = function(t3, e3) {
  5027. return (i = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t4, e4) {
  5028. t4.__proto__ = e4;
  5029. } || function(t4, e4) {
  5030. for (var r3 in e4)
  5031. Object.prototype.hasOwnProperty.call(e4, r3) && (t4[r3] = e4[r3]);
  5032. })(t3, e3);
  5033. }, function(t3, e3) {
  5034. function r3() {
  5035. this.constructor = t3;
  5036. }
  5037. i(t3, e3), t3.prototype = e3 === null ? Object.create(e3) : (r3.prototype = e3.prototype, new r3());
  5038. }), s = /^\w[\w\d+.-]*$/, f2 = /^\//, u = /^\/\//, c = "", l = "/", p = /^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/, g = function() {
  5039. function t3(t4, e3, r3, n2, o2, i2) {
  5040. i2 === void 0 && (i2 = false), typeof t4 == "object" ? (this.scheme = t4.scheme || c, this.authority = t4.authority || c, this.path = t4.path || c, this.query = t4.query || c, this.fragment = t4.fragment || c) : (this.scheme = function(t5, e4) {
  5041. return t5 || e4 ? t5 : "file";
  5042. }(t4, i2), this.authority = e3 || c, this.path = function(t5, e4) {
  5043. switch (t5) {
  5044. case "https":
  5045. case "http":
  5046. case "file":
  5047. e4 ? e4[0] !== l && (e4 = l + e4) : e4 = l;
  5048. }
  5049. return e4;
  5050. }(this.scheme, r3 || c), this.query = n2 || c, this.fragment = o2 || c, function(t5, e4) {
  5051. if (!t5.scheme && e4)
  5052. throw new Error('[UriError]: Scheme is missing: {scheme: "", authority: "' + t5.authority + '", path: "' + t5.path + '", query: "' + t5.query + '", fragment: "' + t5.fragment + '"}');
  5053. if (t5.scheme && !s.test(t5.scheme))
  5054. throw new Error("[UriError]: Scheme contains illegal characters.");
  5055. if (t5.path) {
  5056. if (t5.authority) {
  5057. if (!f2.test(t5.path))
  5058. throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character');
  5059. } else if (u.test(t5.path))
  5060. throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")');
  5061. }
  5062. }(this, i2));
  5063. }
  5064. return t3.isUri = function(e3) {
  5065. return e3 instanceof t3 || !!e3 && typeof e3.authority == "string" && typeof e3.fragment == "string" && typeof e3.path == "string" && typeof e3.query == "string" && typeof e3.scheme == "string" && typeof e3.fsPath == "function" && typeof e3.with == "function" && typeof e3.toString == "function";
  5066. }, Object.defineProperty(t3.prototype, "fsPath", { get: function() {
  5067. return C(this, false);
  5068. }, enumerable: false, configurable: true }), t3.prototype.with = function(t4) {
  5069. if (!t4)
  5070. return this;
  5071. var e3 = t4.scheme, r3 = t4.authority, n2 = t4.path, o2 = t4.query, i2 = t4.fragment;
  5072. return e3 === void 0 ? e3 = this.scheme : e3 === null && (e3 = c), r3 === void 0 ? r3 = this.authority : r3 === null && (r3 = c), n2 === void 0 ? n2 = this.path : n2 === null && (n2 = c), o2 === void 0 ? o2 = this.query : o2 === null && (o2 = c), i2 === void 0 ? i2 = this.fragment : i2 === null && (i2 = c), e3 === this.scheme && r3 === this.authority && n2 === this.path && o2 === this.query && i2 === this.fragment ? this : new v(e3, r3, n2, o2, i2);
  5073. }, t3.parse = function(t4, e3) {
  5074. e3 === void 0 && (e3 = false);
  5075. var r3 = p.exec(t4);
  5076. return r3 ? new v(r3[2] || c, x(r3[4] || c), x(r3[5] || c), x(r3[7] || c), x(r3[9] || c), e3) : new v(c, c, c, c, c);
  5077. }, t3.file = function(t4) {
  5078. var e3 = c;
  5079. if (n && (t4 = t4.replace(/\\/g, l)), t4[0] === l && t4[1] === l) {
  5080. var r3 = t4.indexOf(l, 2);
  5081. r3 === -1 ? (e3 = t4.substring(2), t4 = l) : (e3 = t4.substring(2, r3), t4 = t4.substring(r3) || l);
  5082. }
  5083. return new v("file", e3, t4, c, c);
  5084. }, t3.from = function(t4) {
  5085. return new v(t4.scheme, t4.authority, t4.path, t4.query, t4.fragment);
  5086. }, t3.prototype.toString = function(t4) {
  5087. return t4 === void 0 && (t4 = false), A2(this, t4);
  5088. }, t3.prototype.toJSON = function() {
  5089. return this;
  5090. }, t3.revive = function(e3) {
  5091. if (e3) {
  5092. if (e3 instanceof t3)
  5093. return e3;
  5094. var r3 = new v(e3);
  5095. return r3._formatted = e3.external, r3._fsPath = e3._sep === d ? e3.fsPath : null, r3;
  5096. }
  5097. return e3;
  5098. }, t3;
  5099. }(), d = n ? 1 : void 0, v = function(t3) {
  5100. function e3() {
  5101. var e4 = t3 !== null && t3.apply(this, arguments) || this;
  5102. return e4._formatted = null, e4._fsPath = null, e4;
  5103. }
  5104. return h(e3, t3), Object.defineProperty(e3.prototype, "fsPath", { get: function() {
  5105. return this._fsPath || (this._fsPath = C(this, false)), this._fsPath;
  5106. }, enumerable: false, configurable: true }), e3.prototype.toString = function(t4) {
  5107. return t4 === void 0 && (t4 = false), t4 ? A2(this, true) : (this._formatted || (this._formatted = A2(this, false)), this._formatted);
  5108. }, e3.prototype.toJSON = function() {
  5109. var t4 = { $mid: 1 };
  5110. return this._fsPath && (t4.fsPath = this._fsPath, t4._sep = d), this._formatted && (t4.external = this._formatted), this.path && (t4.path = this.path), this.scheme && (t4.scheme = this.scheme), this.authority && (t4.authority = this.authority), this.query && (t4.query = this.query), this.fragment && (t4.fragment = this.fragment), t4;
  5111. }, e3;
  5112. }(g), m = ((a2 = {})[58] = "%3A", a2[47] = "%2F", a2[63] = "%3F", a2[35] = "%23", a2[91] = "%5B", a2[93] = "%5D", a2[64] = "%40", a2[33] = "%21", a2[36] = "%24", a2[38] = "%26", a2[39] = "%27", a2[40] = "%28", a2[41] = "%29", a2[42] = "%2A", a2[43] = "%2B", a2[44] = "%2C", a2[59] = "%3B", a2[61] = "%3D", a2[32] = "%20", a2);
  5113. function y(t3, e3) {
  5114. for (var r3 = void 0, n2 = -1, o2 = 0; o2 < t3.length; o2++) {
  5115. var i2 = t3.charCodeAt(o2);
  5116. if (i2 >= 97 && i2 <= 122 || i2 >= 65 && i2 <= 90 || i2 >= 48 && i2 <= 57 || i2 === 45 || i2 === 46 || i2 === 95 || i2 === 126 || e3 && i2 === 47)
  5117. n2 !== -1 && (r3 += encodeURIComponent(t3.substring(n2, o2)), n2 = -1), r3 !== void 0 && (r3 += t3.charAt(o2));
  5118. else {
  5119. r3 === void 0 && (r3 = t3.substr(0, o2));
  5120. var a3 = m[i2];
  5121. a3 !== void 0 ? (n2 !== -1 && (r3 += encodeURIComponent(t3.substring(n2, o2)), n2 = -1), r3 += a3) : n2 === -1 && (n2 = o2);
  5122. }
  5123. }
  5124. return n2 !== -1 && (r3 += encodeURIComponent(t3.substring(n2))), r3 !== void 0 ? r3 : t3;
  5125. }
  5126. function b(t3) {
  5127. for (var e3 = void 0, r3 = 0; r3 < t3.length; r3++) {
  5128. var n2 = t3.charCodeAt(r3);
  5129. n2 === 35 || n2 === 63 ? (e3 === void 0 && (e3 = t3.substr(0, r3)), e3 += m[n2]) : e3 !== void 0 && (e3 += t3[r3]);
  5130. }
  5131. return e3 !== void 0 ? e3 : t3;
  5132. }
  5133. function C(t3, e3) {
  5134. var r3;
  5135. return r3 = t3.authority && t3.path.length > 1 && t3.scheme === "file" ? "//" + t3.authority + t3.path : t3.path.charCodeAt(0) === 47 && (t3.path.charCodeAt(1) >= 65 && t3.path.charCodeAt(1) <= 90 || t3.path.charCodeAt(1) >= 97 && t3.path.charCodeAt(1) <= 122) && t3.path.charCodeAt(2) === 58 ? e3 ? t3.path.substr(1) : t3.path[1].toLowerCase() + t3.path.substr(2) : t3.path, n && (r3 = r3.replace(/\//g, "\\")), r3;
  5136. }
  5137. function A2(t3, e3) {
  5138. var r3 = e3 ? b : y, n2 = "", o2 = t3.scheme, i2 = t3.authority, a3 = t3.path, h2 = t3.query, s2 = t3.fragment;
  5139. if (o2 && (n2 += o2, n2 += ":"), (i2 || o2 === "file") && (n2 += l, n2 += l), i2) {
  5140. var f3 = i2.indexOf("@");
  5141. if (f3 !== -1) {
  5142. var u2 = i2.substr(0, f3);
  5143. i2 = i2.substr(f3 + 1), (f3 = u2.indexOf(":")) === -1 ? n2 += r3(u2, false) : (n2 += r3(u2.substr(0, f3), false), n2 += ":", n2 += r3(u2.substr(f3 + 1), false)), n2 += "@";
  5144. }
  5145. (f3 = (i2 = i2.toLowerCase()).indexOf(":")) === -1 ? n2 += r3(i2, false) : (n2 += r3(i2.substr(0, f3), false), n2 += i2.substr(f3));
  5146. }
  5147. if (a3) {
  5148. if (a3.length >= 3 && a3.charCodeAt(0) === 47 && a3.charCodeAt(2) === 58)
  5149. (c2 = a3.charCodeAt(1)) >= 65 && c2 <= 90 && (a3 = "/" + String.fromCharCode(c2 + 32) + ":" + a3.substr(3));
  5150. else if (a3.length >= 2 && a3.charCodeAt(1) === 58) {
  5151. var c2;
  5152. (c2 = a3.charCodeAt(0)) >= 65 && c2 <= 90 && (a3 = String.fromCharCode(c2 + 32) + ":" + a3.substr(2));
  5153. }
  5154. n2 += r3(a3, true);
  5155. }
  5156. return h2 && (n2 += "?", n2 += r3(h2, false)), s2 && (n2 += "#", n2 += e3 ? s2 : y(s2, false)), n2;
  5157. }
  5158. function w(t3) {
  5159. try {
  5160. return decodeURIComponent(t3);
  5161. } catch (e3) {
  5162. return t3.length > 3 ? t3.substr(0, 3) + w(t3.substr(3)) : t3;
  5163. }
  5164. }
  5165. var _ = /(%[0-9A-Za-z][0-9A-Za-z])+/g;
  5166. function x(t3) {
  5167. return t3.match(_) ? t3.replace(_, function(t4) {
  5168. return w(t4);
  5169. }) : t3;
  5170. }
  5171. var O, P = r2(470), j = function() {
  5172. for (var t3 = 0, e3 = 0, r3 = arguments.length; e3 < r3; e3++)
  5173. t3 += arguments[e3].length;
  5174. var n2 = Array(t3), o2 = 0;
  5175. for (e3 = 0; e3 < r3; e3++)
  5176. for (var i2 = arguments[e3], a3 = 0, h2 = i2.length; a3 < h2; a3++, o2++)
  5177. n2[o2] = i2[a3];
  5178. return n2;
  5179. }, U = P.posix || P;
  5180. !function(t3) {
  5181. t3.joinPath = function(t4) {
  5182. for (var e3 = [], r3 = 1; r3 < arguments.length; r3++)
  5183. e3[r3 - 1] = arguments[r3];
  5184. return t4.with({ path: U.join.apply(U, j([t4.path], e3)) });
  5185. }, t3.resolvePath = function(t4) {
  5186. for (var e3 = [], r3 = 1; r3 < arguments.length; r3++)
  5187. e3[r3 - 1] = arguments[r3];
  5188. var n2 = t4.path || "/";
  5189. return t4.with({ path: U.resolve.apply(U, j([n2], e3)) });
  5190. }, t3.dirname = function(t4) {
  5191. var e3 = U.dirname(t4.path);
  5192. return e3.length === 1 && e3.charCodeAt(0) === 46 ? t4 : t4.with({ path: e3 });
  5193. }, t3.basename = function(t4) {
  5194. return U.basename(t4.path);
  5195. }, t3.extname = function(t4) {
  5196. return U.extname(t4.path);
  5197. };
  5198. }(O || (O = {}));
  5199. } }, e = {};
  5200. function r(n) {
  5201. if (e[n])
  5202. return e[n].exports;
  5203. var o = e[n] = { exports: {} };
  5204. return t[n](o, o.exports, r), o.exports;
  5205. }
  5206. return r.d = (t2, e2) => {
  5207. for (var n in e2)
  5208. r.o(e2, n) && !r.o(t2, n) && Object.defineProperty(t2, n, { enumerable: true, get: e2[n] });
  5209. }, r.o = (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r.r = (t2) => {
  5210. typeof Symbol != "undefined" && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true });
  5211. }, r(447);
  5212. })();
  5213. var { URI, Utils } = LIB;
  5214. // node_modules/vscode-json-languageservice/lib/esm/utils/glob.js
  5215. function createRegex(glob, opts) {
  5216. if (typeof glob !== "string") {
  5217. throw new TypeError("Expected a string");
  5218. }
  5219. var str = String(glob);
  5220. var reStr = "";
  5221. var extended = opts ? !!opts.extended : false;
  5222. var globstar = opts ? !!opts.globstar : false;
  5223. var inGroup = false;
  5224. var flags = opts && typeof opts.flags === "string" ? opts.flags : "";
  5225. var c;
  5226. for (var i = 0, len = str.length; i < len; i++) {
  5227. c = str[i];
  5228. switch (c) {
  5229. case "/":
  5230. case "$":
  5231. case "^":
  5232. case "+":
  5233. case ".":
  5234. case "(":
  5235. case ")":
  5236. case "=":
  5237. case "!":
  5238. case "|":
  5239. reStr += "\\" + c;
  5240. break;
  5241. case "?":
  5242. if (extended) {
  5243. reStr += ".";
  5244. break;
  5245. }
  5246. case "[":
  5247. case "]":
  5248. if (extended) {
  5249. reStr += c;
  5250. break;
  5251. }
  5252. case "{":
  5253. if (extended) {
  5254. inGroup = true;
  5255. reStr += "(";
  5256. break;
  5257. }
  5258. case "}":
  5259. if (extended) {
  5260. inGroup = false;
  5261. reStr += ")";
  5262. break;
  5263. }
  5264. case ",":
  5265. if (inGroup) {
  5266. reStr += "|";
  5267. break;
  5268. }
  5269. reStr += "\\" + c;
  5270. break;
  5271. case "*":
  5272. var prevChar = str[i - 1];
  5273. var starCount = 1;
  5274. while (str[i + 1] === "*") {
  5275. starCount++;
  5276. i++;
  5277. }
  5278. var nextChar = str[i + 1];
  5279. if (!globstar) {
  5280. reStr += ".*";
  5281. } else {
  5282. var isGlobstar = starCount > 1 && (prevChar === "/" || prevChar === void 0 || prevChar === "{" || prevChar === ",") && (nextChar === "/" || nextChar === void 0 || nextChar === "," || nextChar === "}");
  5283. if (isGlobstar) {
  5284. if (nextChar === "/") {
  5285. i++;
  5286. } else if (prevChar === "/" && reStr.endsWith("\\/")) {
  5287. reStr = reStr.substr(0, reStr.length - 2);
  5288. }
  5289. reStr += "((?:[^/]*(?:/|$))*)";
  5290. } else {
  5291. reStr += "([^/]*)";
  5292. }
  5293. }
  5294. break;
  5295. default:
  5296. reStr += c;
  5297. }
  5298. }
  5299. if (!flags || !~flags.indexOf("g")) {
  5300. reStr = "^" + reStr + "$";
  5301. }
  5302. return new RegExp(reStr, flags);
  5303. }
  5304. // node_modules/vscode-json-languageservice/lib/esm/services/jsonSchemaService.js
  5305. var localize4 = loadMessageBundle();
  5306. var BANG = "!";
  5307. var PATH_SEP = "/";
  5308. var FilePatternAssociation = function() {
  5309. function FilePatternAssociation2(pattern, uris) {
  5310. this.globWrappers = [];
  5311. try {
  5312. for (var _i = 0, pattern_1 = pattern; _i < pattern_1.length; _i++) {
  5313. var patternString = pattern_1[_i];
  5314. var include = patternString[0] !== BANG;
  5315. if (!include) {
  5316. patternString = patternString.substring(1);
  5317. }
  5318. if (patternString.length > 0) {
  5319. if (patternString[0] === PATH_SEP) {
  5320. patternString = patternString.substring(1);
  5321. }
  5322. this.globWrappers.push({
  5323. regexp: createRegex("**/" + patternString, { extended: true, globstar: true }),
  5324. include
  5325. });
  5326. }
  5327. }
  5328. ;
  5329. this.uris = uris;
  5330. } catch (e) {
  5331. this.globWrappers.length = 0;
  5332. this.uris = [];
  5333. }
  5334. }
  5335. FilePatternAssociation2.prototype.matchesPattern = function(fileName) {
  5336. var match = false;
  5337. for (var _i = 0, _a = this.globWrappers; _i < _a.length; _i++) {
  5338. var _b = _a[_i], regexp = _b.regexp, include = _b.include;
  5339. if (regexp.test(fileName)) {
  5340. match = include;
  5341. }
  5342. }
  5343. return match;
  5344. };
  5345. FilePatternAssociation2.prototype.getURIs = function() {
  5346. return this.uris;
  5347. };
  5348. return FilePatternAssociation2;
  5349. }();
  5350. var SchemaHandle = function() {
  5351. function SchemaHandle2(service, url, unresolvedSchemaContent) {
  5352. this.service = service;
  5353. this.url = url;
  5354. this.dependencies = {};
  5355. if (unresolvedSchemaContent) {
  5356. this.unresolvedSchema = this.service.promise.resolve(new UnresolvedSchema(unresolvedSchemaContent));
  5357. }
  5358. }
  5359. SchemaHandle2.prototype.getUnresolvedSchema = function() {
  5360. if (!this.unresolvedSchema) {
  5361. this.unresolvedSchema = this.service.loadSchema(this.url);
  5362. }
  5363. return this.unresolvedSchema;
  5364. };
  5365. SchemaHandle2.prototype.getResolvedSchema = function() {
  5366. var _this = this;
  5367. if (!this.resolvedSchema) {
  5368. this.resolvedSchema = this.getUnresolvedSchema().then(function(unresolved) {
  5369. return _this.service.resolveSchemaContent(unresolved, _this.url, _this.dependencies);
  5370. });
  5371. }
  5372. return this.resolvedSchema;
  5373. };
  5374. SchemaHandle2.prototype.clearSchema = function() {
  5375. this.resolvedSchema = void 0;
  5376. this.unresolvedSchema = void 0;
  5377. this.dependencies = {};
  5378. };
  5379. return SchemaHandle2;
  5380. }();
  5381. var UnresolvedSchema = function() {
  5382. function UnresolvedSchema2(schema, errors) {
  5383. if (errors === void 0) {
  5384. errors = [];
  5385. }
  5386. this.schema = schema;
  5387. this.errors = errors;
  5388. }
  5389. return UnresolvedSchema2;
  5390. }();
  5391. var ResolvedSchema = function() {
  5392. function ResolvedSchema2(schema, errors) {
  5393. if (errors === void 0) {
  5394. errors = [];
  5395. }
  5396. this.schema = schema;
  5397. this.errors = errors;
  5398. }
  5399. ResolvedSchema2.prototype.getSection = function(path) {
  5400. var schemaRef = this.getSectionRecursive(path, this.schema);
  5401. if (schemaRef) {
  5402. return asSchema(schemaRef);
  5403. }
  5404. return void 0;
  5405. };
  5406. ResolvedSchema2.prototype.getSectionRecursive = function(path, schema) {
  5407. if (!schema || typeof schema === "boolean" || path.length === 0) {
  5408. return schema;
  5409. }
  5410. var next = path.shift();
  5411. if (schema.properties && typeof schema.properties[next]) {
  5412. return this.getSectionRecursive(path, schema.properties[next]);
  5413. } else if (schema.patternProperties) {
  5414. for (var _i = 0, _a = Object.keys(schema.patternProperties); _i < _a.length; _i++) {
  5415. var pattern = _a[_i];
  5416. var regex = extendedRegExp(pattern);
  5417. if (regex === null || regex === void 0 ? void 0 : regex.test(next)) {
  5418. return this.getSectionRecursive(path, schema.patternProperties[pattern]);
  5419. }
  5420. }
  5421. } else if (typeof schema.additionalProperties === "object") {
  5422. return this.getSectionRecursive(path, schema.additionalProperties);
  5423. } else if (next.match("[0-9]+")) {
  5424. if (Array.isArray(schema.items)) {
  5425. var index = parseInt(next, 10);
  5426. if (!isNaN(index) && schema.items[index]) {
  5427. return this.getSectionRecursive(path, schema.items[index]);
  5428. }
  5429. } else if (schema.items) {
  5430. return this.getSectionRecursive(path, schema.items);
  5431. }
  5432. }
  5433. return void 0;
  5434. };
  5435. return ResolvedSchema2;
  5436. }();
  5437. var JSONSchemaService = function() {
  5438. function JSONSchemaService2(requestService, contextService, promiseConstructor) {
  5439. this.contextService = contextService;
  5440. this.requestService = requestService;
  5441. this.promiseConstructor = promiseConstructor || Promise;
  5442. this.callOnDispose = [];
  5443. this.contributionSchemas = {};
  5444. this.contributionAssociations = [];
  5445. this.schemasById = {};
  5446. this.filePatternAssociations = [];
  5447. this.registeredSchemasIds = {};
  5448. }
  5449. JSONSchemaService2.prototype.getRegisteredSchemaIds = function(filter) {
  5450. return Object.keys(this.registeredSchemasIds).filter(function(id) {
  5451. var scheme = URI.parse(id).scheme;
  5452. return scheme !== "schemaservice" && (!filter || filter(scheme));
  5453. });
  5454. };
  5455. Object.defineProperty(JSONSchemaService2.prototype, "promise", {
  5456. get: function() {
  5457. return this.promiseConstructor;
  5458. },
  5459. enumerable: false,
  5460. configurable: true
  5461. });
  5462. JSONSchemaService2.prototype.dispose = function() {
  5463. while (this.callOnDispose.length > 0) {
  5464. this.callOnDispose.pop()();
  5465. }
  5466. };
  5467. JSONSchemaService2.prototype.onResourceChange = function(uri) {
  5468. var _this = this;
  5469. this.cachedSchemaForResource = void 0;
  5470. var hasChanges = false;
  5471. uri = normalizeId(uri);
  5472. var toWalk = [uri];
  5473. var all = Object.keys(this.schemasById).map(function(key) {
  5474. return _this.schemasById[key];
  5475. });
  5476. while (toWalk.length) {
  5477. var curr = toWalk.pop();
  5478. for (var i = 0; i < all.length; i++) {
  5479. var handle = all[i];
  5480. if (handle && (handle.url === curr || handle.dependencies[curr])) {
  5481. if (handle.url !== curr) {
  5482. toWalk.push(handle.url);
  5483. }
  5484. handle.clearSchema();
  5485. all[i] = void 0;
  5486. hasChanges = true;
  5487. }
  5488. }
  5489. }
  5490. return hasChanges;
  5491. };
  5492. JSONSchemaService2.prototype.setSchemaContributions = function(schemaContributions2) {
  5493. if (schemaContributions2.schemas) {
  5494. var schemas = schemaContributions2.schemas;
  5495. for (var id in schemas) {
  5496. var normalizedId = normalizeId(id);
  5497. this.contributionSchemas[normalizedId] = this.addSchemaHandle(normalizedId, schemas[id]);
  5498. }
  5499. }
  5500. if (Array.isArray(schemaContributions2.schemaAssociations)) {
  5501. var schemaAssociations = schemaContributions2.schemaAssociations;
  5502. for (var _i = 0, schemaAssociations_1 = schemaAssociations; _i < schemaAssociations_1.length; _i++) {
  5503. var schemaAssociation = schemaAssociations_1[_i];
  5504. var uris = schemaAssociation.uris.map(normalizeId);
  5505. var association = this.addFilePatternAssociation(schemaAssociation.pattern, uris);
  5506. this.contributionAssociations.push(association);
  5507. }
  5508. }
  5509. };
  5510. JSONSchemaService2.prototype.addSchemaHandle = function(id, unresolvedSchemaContent) {
  5511. var schemaHandle = new SchemaHandle(this, id, unresolvedSchemaContent);
  5512. this.schemasById[id] = schemaHandle;
  5513. return schemaHandle;
  5514. };
  5515. JSONSchemaService2.prototype.getOrAddSchemaHandle = function(id, unresolvedSchemaContent) {
  5516. return this.schemasById[id] || this.addSchemaHandle(id, unresolvedSchemaContent);
  5517. };
  5518. JSONSchemaService2.prototype.addFilePatternAssociation = function(pattern, uris) {
  5519. var fpa = new FilePatternAssociation(pattern, uris);
  5520. this.filePatternAssociations.push(fpa);
  5521. return fpa;
  5522. };
  5523. JSONSchemaService2.prototype.registerExternalSchema = function(uri, filePatterns, unresolvedSchemaContent) {
  5524. var id = normalizeId(uri);
  5525. this.registeredSchemasIds[id] = true;
  5526. this.cachedSchemaForResource = void 0;
  5527. if (filePatterns) {
  5528. this.addFilePatternAssociation(filePatterns, [id]);
  5529. }
  5530. return unresolvedSchemaContent ? this.addSchemaHandle(id, unresolvedSchemaContent) : this.getOrAddSchemaHandle(id);
  5531. };
  5532. JSONSchemaService2.prototype.clearExternalSchemas = function() {
  5533. this.schemasById = {};
  5534. this.filePatternAssociations = [];
  5535. this.registeredSchemasIds = {};
  5536. this.cachedSchemaForResource = void 0;
  5537. for (var id in this.contributionSchemas) {
  5538. this.schemasById[id] = this.contributionSchemas[id];
  5539. this.registeredSchemasIds[id] = true;
  5540. }
  5541. for (var _i = 0, _a = this.contributionAssociations; _i < _a.length; _i++) {
  5542. var contributionAssociation = _a[_i];
  5543. this.filePatternAssociations.push(contributionAssociation);
  5544. }
  5545. };
  5546. JSONSchemaService2.prototype.getResolvedSchema = function(schemaId) {
  5547. var id = normalizeId(schemaId);
  5548. var schemaHandle = this.schemasById[id];
  5549. if (schemaHandle) {
  5550. return schemaHandle.getResolvedSchema();
  5551. }
  5552. return this.promise.resolve(void 0);
  5553. };
  5554. JSONSchemaService2.prototype.loadSchema = function(url) {
  5555. if (!this.requestService) {
  5556. var errorMessage = localize4("json.schema.norequestservice", "Unable to load schema from '{0}'. No schema request service available", toDisplayString(url));
  5557. return this.promise.resolve(new UnresolvedSchema({}, [errorMessage]));
  5558. }
  5559. return this.requestService(url).then(function(content) {
  5560. if (!content) {
  5561. var errorMessage2 = localize4("json.schema.nocontent", "Unable to load schema from '{0}': No content.", toDisplayString(url));
  5562. return new UnresolvedSchema({}, [errorMessage2]);
  5563. }
  5564. var schemaContent = {};
  5565. var jsonErrors = [];
  5566. schemaContent = parse2(content, jsonErrors);
  5567. var errors = jsonErrors.length ? [localize4("json.schema.invalidFormat", "Unable to parse content from '{0}': Parse error at offset {1}.", toDisplayString(url), jsonErrors[0].offset)] : [];
  5568. return new UnresolvedSchema(schemaContent, errors);
  5569. }, function(error) {
  5570. var errorMessage2 = error.toString();
  5571. var errorSplit = error.toString().split("Error: ");
  5572. if (errorSplit.length > 1) {
  5573. errorMessage2 = errorSplit[1];
  5574. }
  5575. if (endsWith(errorMessage2, ".")) {
  5576. errorMessage2 = errorMessage2.substr(0, errorMessage2.length - 1);
  5577. }
  5578. return new UnresolvedSchema({}, [localize4("json.schema.nocontent", "Unable to load schema from '{0}': {1}.", toDisplayString(url), errorMessage2)]);
  5579. });
  5580. };
  5581. JSONSchemaService2.prototype.resolveSchemaContent = function(schemaToResolve, schemaURL, dependencies) {
  5582. var _this = this;
  5583. var resolveErrors = schemaToResolve.errors.slice(0);
  5584. var schema = schemaToResolve.schema;
  5585. if (schema.$schema) {
  5586. var id = normalizeId(schema.$schema);
  5587. if (id === "http://json-schema.org/draft-03/schema") {
  5588. return this.promise.resolve(new ResolvedSchema({}, [localize4("json.schema.draft03.notsupported", "Draft-03 schemas are not supported.")]));
  5589. } else if (id === "https://json-schema.org/draft/2019-09/schema") {
  5590. resolveErrors.push(localize4("json.schema.draft201909.notsupported", "Draft 2019-09 schemas are not yet fully supported."));
  5591. }
  5592. }
  5593. var contextService = this.contextService;
  5594. var findSection = function(schema2, path) {
  5595. if (!path) {
  5596. return schema2;
  5597. }
  5598. var current = schema2;
  5599. if (path[0] === "/") {
  5600. path = path.substr(1);
  5601. }
  5602. path.split("/").some(function(part) {
  5603. part = part.replace(/~1/g, "/").replace(/~0/g, "~");
  5604. current = current[part];
  5605. return !current;
  5606. });
  5607. return current;
  5608. };
  5609. var merge = function(target, sourceRoot, sourceURI, refSegment) {
  5610. var path = refSegment ? decodeURIComponent(refSegment) : void 0;
  5611. var section = findSection(sourceRoot, path);
  5612. if (section) {
  5613. for (var key in section) {
  5614. if (section.hasOwnProperty(key) && !target.hasOwnProperty(key)) {
  5615. target[key] = section[key];
  5616. }
  5617. }
  5618. } else {
  5619. resolveErrors.push(localize4("json.schema.invalidref", "$ref '{0}' in '{1}' can not be resolved.", path, sourceURI));
  5620. }
  5621. };
  5622. var resolveExternalLink = function(node, uri, refSegment, parentSchemaURL, parentSchemaDependencies) {
  5623. if (contextService && !/^[A-Za-z][A-Za-z0-9+\-.+]*:\/\/.*/.test(uri)) {
  5624. uri = contextService.resolveRelativePath(uri, parentSchemaURL);
  5625. }
  5626. uri = normalizeId(uri);
  5627. var referencedHandle = _this.getOrAddSchemaHandle(uri);
  5628. return referencedHandle.getUnresolvedSchema().then(function(unresolvedSchema) {
  5629. parentSchemaDependencies[uri] = true;
  5630. if (unresolvedSchema.errors.length) {
  5631. var loc = refSegment ? uri + "#" + refSegment : uri;
  5632. resolveErrors.push(localize4("json.schema.problemloadingref", "Problems loading reference '{0}': {1}", loc, unresolvedSchema.errors[0]));
  5633. }
  5634. merge(node, unresolvedSchema.schema, uri, refSegment);
  5635. return resolveRefs(node, unresolvedSchema.schema, uri, referencedHandle.dependencies);
  5636. });
  5637. };
  5638. var resolveRefs = function(node, parentSchema, parentSchemaURL, parentSchemaDependencies) {
  5639. if (!node || typeof node !== "object") {
  5640. return Promise.resolve(null);
  5641. }
  5642. var toWalk = [node];
  5643. var seen = [];
  5644. var openPromises = [];
  5645. var collectEntries = function() {
  5646. var entries = [];
  5647. for (var _i = 0; _i < arguments.length; _i++) {
  5648. entries[_i] = arguments[_i];
  5649. }
  5650. for (var _a = 0, entries_1 = entries; _a < entries_1.length; _a++) {
  5651. var entry = entries_1[_a];
  5652. if (typeof entry === "object") {
  5653. toWalk.push(entry);
  5654. }
  5655. }
  5656. };
  5657. var collectMapEntries = function() {
  5658. var maps = [];
  5659. for (var _i = 0; _i < arguments.length; _i++) {
  5660. maps[_i] = arguments[_i];
  5661. }
  5662. for (var _a = 0, maps_1 = maps; _a < maps_1.length; _a++) {
  5663. var map = maps_1[_a];
  5664. if (typeof map === "object") {
  5665. for (var k in map) {
  5666. var key = k;
  5667. var entry = map[key];
  5668. if (typeof entry === "object") {
  5669. toWalk.push(entry);
  5670. }
  5671. }
  5672. }
  5673. }
  5674. };
  5675. var collectArrayEntries = function() {
  5676. var arrays = [];
  5677. for (var _i = 0; _i < arguments.length; _i++) {
  5678. arrays[_i] = arguments[_i];
  5679. }
  5680. for (var _a = 0, arrays_1 = arrays; _a < arrays_1.length; _a++) {
  5681. var array = arrays_1[_a];
  5682. if (Array.isArray(array)) {
  5683. for (var _b = 0, array_1 = array; _b < array_1.length; _b++) {
  5684. var entry = array_1[_b];
  5685. if (typeof entry === "object") {
  5686. toWalk.push(entry);
  5687. }
  5688. }
  5689. }
  5690. }
  5691. };
  5692. var handleRef = function(next2) {
  5693. var seenRefs = [];
  5694. while (next2.$ref) {
  5695. var ref = next2.$ref;
  5696. var segments = ref.split("#", 2);
  5697. delete next2.$ref;
  5698. if (segments[0].length > 0) {
  5699. openPromises.push(resolveExternalLink(next2, segments[0], segments[1], parentSchemaURL, parentSchemaDependencies));
  5700. return;
  5701. } else {
  5702. if (seenRefs.indexOf(ref) === -1) {
  5703. merge(next2, parentSchema, parentSchemaURL, segments[1]);
  5704. seenRefs.push(ref);
  5705. }
  5706. }
  5707. }
  5708. collectEntries(next2.items, next2.additionalItems, next2.additionalProperties, next2.not, next2.contains, next2.propertyNames, next2.if, next2.then, next2.else);
  5709. collectMapEntries(next2.definitions, next2.properties, next2.patternProperties, next2.dependencies);
  5710. collectArrayEntries(next2.anyOf, next2.allOf, next2.oneOf, next2.items);
  5711. };
  5712. while (toWalk.length) {
  5713. var next = toWalk.pop();
  5714. if (seen.indexOf(next) >= 0) {
  5715. continue;
  5716. }
  5717. seen.push(next);
  5718. handleRef(next);
  5719. }
  5720. return _this.promise.all(openPromises);
  5721. };
  5722. return resolveRefs(schema, schema, schemaURL, dependencies).then(function(_) {
  5723. return new ResolvedSchema(schema, resolveErrors);
  5724. });
  5725. };
  5726. JSONSchemaService2.prototype.getSchemaForResource = function(resource, document) {
  5727. if (document && document.root && document.root.type === "object") {
  5728. var schemaProperties = document.root.properties.filter(function(p) {
  5729. return p.keyNode.value === "$schema" && p.valueNode && p.valueNode.type === "string";
  5730. });
  5731. if (schemaProperties.length > 0) {
  5732. var valueNode = schemaProperties[0].valueNode;
  5733. if (valueNode && valueNode.type === "string") {
  5734. var schemeId = getNodeValue3(valueNode);
  5735. if (schemeId && startsWith(schemeId, ".") && this.contextService) {
  5736. schemeId = this.contextService.resolveRelativePath(schemeId, resource);
  5737. }
  5738. if (schemeId) {
  5739. var id = normalizeId(schemeId);
  5740. return this.getOrAddSchemaHandle(id).getResolvedSchema();
  5741. }
  5742. }
  5743. }
  5744. }
  5745. if (this.cachedSchemaForResource && this.cachedSchemaForResource.resource === resource) {
  5746. return this.cachedSchemaForResource.resolvedSchema;
  5747. }
  5748. var seen = Object.create(null);
  5749. var schemas = [];
  5750. var normalizedResource = normalizeResourceForMatching(resource);
  5751. for (var _i = 0, _a = this.filePatternAssociations; _i < _a.length; _i++) {
  5752. var entry = _a[_i];
  5753. if (entry.matchesPattern(normalizedResource)) {
  5754. for (var _b = 0, _c = entry.getURIs(); _b < _c.length; _b++) {
  5755. var schemaId = _c[_b];
  5756. if (!seen[schemaId]) {
  5757. schemas.push(schemaId);
  5758. seen[schemaId] = true;
  5759. }
  5760. }
  5761. }
  5762. }
  5763. var resolvedSchema = schemas.length > 0 ? this.createCombinedSchema(resource, schemas).getResolvedSchema() : this.promise.resolve(void 0);
  5764. this.cachedSchemaForResource = { resource, resolvedSchema };
  5765. return resolvedSchema;
  5766. };
  5767. JSONSchemaService2.prototype.createCombinedSchema = function(resource, schemaIds) {
  5768. if (schemaIds.length === 1) {
  5769. return this.getOrAddSchemaHandle(schemaIds[0]);
  5770. } else {
  5771. var combinedSchemaId = "schemaservice://combinedSchema/" + encodeURIComponent(resource);
  5772. var combinedSchema = {
  5773. allOf: schemaIds.map(function(schemaId) {
  5774. return { $ref: schemaId };
  5775. })
  5776. };
  5777. return this.addSchemaHandle(combinedSchemaId, combinedSchema);
  5778. }
  5779. };
  5780. JSONSchemaService2.prototype.getMatchingSchemas = function(document, jsonDocument, schema) {
  5781. if (schema) {
  5782. var id = schema.id || "schemaservice://untitled/matchingSchemas/" + idCounter++;
  5783. return this.resolveSchemaContent(new UnresolvedSchema(schema), id, {}).then(function(resolvedSchema) {
  5784. return jsonDocument.getMatchingSchemas(resolvedSchema.schema).filter(function(s) {
  5785. return !s.inverted;
  5786. });
  5787. });
  5788. }
  5789. return this.getSchemaForResource(document.uri, jsonDocument).then(function(schema2) {
  5790. if (schema2) {
  5791. return jsonDocument.getMatchingSchemas(schema2.schema).filter(function(s) {
  5792. return !s.inverted;
  5793. });
  5794. }
  5795. return [];
  5796. });
  5797. };
  5798. return JSONSchemaService2;
  5799. }();
  5800. var idCounter = 0;
  5801. function normalizeId(id) {
  5802. try {
  5803. return URI.parse(id).toString();
  5804. } catch (e) {
  5805. return id;
  5806. }
  5807. }
  5808. function normalizeResourceForMatching(resource) {
  5809. try {
  5810. return URI.parse(resource).with({ fragment: null, query: null }).toString();
  5811. } catch (e) {
  5812. return resource;
  5813. }
  5814. }
  5815. function toDisplayString(url) {
  5816. try {
  5817. var uri = URI.parse(url);
  5818. if (uri.scheme === "file") {
  5819. return uri.fsPath;
  5820. }
  5821. } catch (e) {
  5822. }
  5823. return url;
  5824. }
  5825. // node_modules/vscode-json-languageservice/lib/esm/services/jsonValidation.js
  5826. var localize5 = loadMessageBundle();
  5827. var JSONValidation = function() {
  5828. function JSONValidation2(jsonSchemaService, promiseConstructor) {
  5829. this.jsonSchemaService = jsonSchemaService;
  5830. this.promise = promiseConstructor;
  5831. this.validationEnabled = true;
  5832. }
  5833. JSONValidation2.prototype.configure = function(raw) {
  5834. if (raw) {
  5835. this.validationEnabled = raw.validate !== false;
  5836. this.commentSeverity = raw.allowComments ? void 0 : DiagnosticSeverity.Error;
  5837. }
  5838. };
  5839. JSONValidation2.prototype.doValidation = function(textDocument, jsonDocument, documentSettings, schema) {
  5840. var _this = this;
  5841. if (!this.validationEnabled) {
  5842. return this.promise.resolve([]);
  5843. }
  5844. var diagnostics = [];
  5845. var added = {};
  5846. var addProblem = function(problem) {
  5847. var signature = problem.range.start.line + " " + problem.range.start.character + " " + problem.message;
  5848. if (!added[signature]) {
  5849. added[signature] = true;
  5850. diagnostics.push(problem);
  5851. }
  5852. };
  5853. var getDiagnostics = function(schema2) {
  5854. var trailingCommaSeverity = (documentSettings === null || documentSettings === void 0 ? void 0 : documentSettings.trailingCommas) ? toDiagnosticSeverity(documentSettings.trailingCommas) : DiagnosticSeverity.Error;
  5855. var commentSeverity = (documentSettings === null || documentSettings === void 0 ? void 0 : documentSettings.comments) ? toDiagnosticSeverity(documentSettings.comments) : _this.commentSeverity;
  5856. var schemaValidation = (documentSettings === null || documentSettings === void 0 ? void 0 : documentSettings.schemaValidation) ? toDiagnosticSeverity(documentSettings.schemaValidation) : DiagnosticSeverity.Warning;
  5857. var schemaRequest = (documentSettings === null || documentSettings === void 0 ? void 0 : documentSettings.schemaRequest) ? toDiagnosticSeverity(documentSettings.schemaRequest) : DiagnosticSeverity.Warning;
  5858. if (schema2) {
  5859. if (schema2.errors.length && jsonDocument.root && schemaRequest) {
  5860. var astRoot = jsonDocument.root;
  5861. var property = astRoot.type === "object" ? astRoot.properties[0] : void 0;
  5862. if (property && property.keyNode.value === "$schema") {
  5863. var node = property.valueNode || property;
  5864. var range = Range.create(textDocument.positionAt(node.offset), textDocument.positionAt(node.offset + node.length));
  5865. addProblem(Diagnostic.create(range, schema2.errors[0], schemaRequest, ErrorCode.SchemaResolveError));
  5866. } else {
  5867. var range = Range.create(textDocument.positionAt(astRoot.offset), textDocument.positionAt(astRoot.offset + 1));
  5868. addProblem(Diagnostic.create(range, schema2.errors[0], schemaRequest, ErrorCode.SchemaResolveError));
  5869. }
  5870. } else if (schemaValidation) {
  5871. var semanticErrors = jsonDocument.validate(textDocument, schema2.schema, schemaValidation);
  5872. if (semanticErrors) {
  5873. semanticErrors.forEach(addProblem);
  5874. }
  5875. }
  5876. if (schemaAllowsComments(schema2.schema)) {
  5877. commentSeverity = void 0;
  5878. }
  5879. if (schemaAllowsTrailingCommas(schema2.schema)) {
  5880. trailingCommaSeverity = void 0;
  5881. }
  5882. }
  5883. for (var _i = 0, _a = jsonDocument.syntaxErrors; _i < _a.length; _i++) {
  5884. var p = _a[_i];
  5885. if (p.code === ErrorCode.TrailingComma) {
  5886. if (typeof trailingCommaSeverity !== "number") {
  5887. continue;
  5888. }
  5889. p.severity = trailingCommaSeverity;
  5890. }
  5891. addProblem(p);
  5892. }
  5893. if (typeof commentSeverity === "number") {
  5894. var message_1 = localize5("InvalidCommentToken", "Comments are not permitted in JSON.");
  5895. jsonDocument.comments.forEach(function(c) {
  5896. addProblem(Diagnostic.create(c, message_1, commentSeverity, ErrorCode.CommentNotPermitted));
  5897. });
  5898. }
  5899. return diagnostics;
  5900. };
  5901. if (schema) {
  5902. var id = schema.id || "schemaservice://untitled/" + idCounter2++;
  5903. return this.jsonSchemaService.resolveSchemaContent(new UnresolvedSchema(schema), id, {}).then(function(resolvedSchema) {
  5904. return getDiagnostics(resolvedSchema);
  5905. });
  5906. }
  5907. return this.jsonSchemaService.getSchemaForResource(textDocument.uri, jsonDocument).then(function(schema2) {
  5908. return getDiagnostics(schema2);
  5909. });
  5910. };
  5911. return JSONValidation2;
  5912. }();
  5913. var idCounter2 = 0;
  5914. function schemaAllowsComments(schemaRef) {
  5915. if (schemaRef && typeof schemaRef === "object") {
  5916. if (isBoolean(schemaRef.allowComments)) {
  5917. return schemaRef.allowComments;
  5918. }
  5919. if (schemaRef.allOf) {
  5920. for (var _i = 0, _a = schemaRef.allOf; _i < _a.length; _i++) {
  5921. var schema = _a[_i];
  5922. var allow = schemaAllowsComments(schema);
  5923. if (isBoolean(allow)) {
  5924. return allow;
  5925. }
  5926. }
  5927. }
  5928. }
  5929. return void 0;
  5930. }
  5931. function schemaAllowsTrailingCommas(schemaRef) {
  5932. if (schemaRef && typeof schemaRef === "object") {
  5933. if (isBoolean(schemaRef.allowTrailingCommas)) {
  5934. return schemaRef.allowTrailingCommas;
  5935. }
  5936. var deprSchemaRef = schemaRef;
  5937. if (isBoolean(deprSchemaRef["allowsTrailingCommas"])) {
  5938. return deprSchemaRef["allowsTrailingCommas"];
  5939. }
  5940. if (schemaRef.allOf) {
  5941. for (var _i = 0, _a = schemaRef.allOf; _i < _a.length; _i++) {
  5942. var schema = _a[_i];
  5943. var allow = schemaAllowsTrailingCommas(schema);
  5944. if (isBoolean(allow)) {
  5945. return allow;
  5946. }
  5947. }
  5948. }
  5949. }
  5950. return void 0;
  5951. }
  5952. function toDiagnosticSeverity(severityLevel) {
  5953. switch (severityLevel) {
  5954. case "error":
  5955. return DiagnosticSeverity.Error;
  5956. case "warning":
  5957. return DiagnosticSeverity.Warning;
  5958. case "ignore":
  5959. return void 0;
  5960. }
  5961. return void 0;
  5962. }
  5963. // node_modules/vscode-json-languageservice/lib/esm/utils/colors.js
  5964. var Digit0 = 48;
  5965. var Digit9 = 57;
  5966. var A = 65;
  5967. var a = 97;
  5968. var f = 102;
  5969. function hexDigit(charCode) {
  5970. if (charCode < Digit0) {
  5971. return 0;
  5972. }
  5973. if (charCode <= Digit9) {
  5974. return charCode - Digit0;
  5975. }
  5976. if (charCode < a) {
  5977. charCode += a - A;
  5978. }
  5979. if (charCode >= a && charCode <= f) {
  5980. return charCode - a + 10;
  5981. }
  5982. return 0;
  5983. }
  5984. function colorFromHex(text) {
  5985. if (text[0] !== "#") {
  5986. return void 0;
  5987. }
  5988. switch (text.length) {
  5989. case 4:
  5990. return {
  5991. red: hexDigit(text.charCodeAt(1)) * 17 / 255,
  5992. green: hexDigit(text.charCodeAt(2)) * 17 / 255,
  5993. blue: hexDigit(text.charCodeAt(3)) * 17 / 255,
  5994. alpha: 1
  5995. };
  5996. case 5:
  5997. return {
  5998. red: hexDigit(text.charCodeAt(1)) * 17 / 255,
  5999. green: hexDigit(text.charCodeAt(2)) * 17 / 255,
  6000. blue: hexDigit(text.charCodeAt(3)) * 17 / 255,
  6001. alpha: hexDigit(text.charCodeAt(4)) * 17 / 255
  6002. };
  6003. case 7:
  6004. return {
  6005. red: (hexDigit(text.charCodeAt(1)) * 16 + hexDigit(text.charCodeAt(2))) / 255,
  6006. green: (hexDigit(text.charCodeAt(3)) * 16 + hexDigit(text.charCodeAt(4))) / 255,
  6007. blue: (hexDigit(text.charCodeAt(5)) * 16 + hexDigit(text.charCodeAt(6))) / 255,
  6008. alpha: 1
  6009. };
  6010. case 9:
  6011. return {
  6012. red: (hexDigit(text.charCodeAt(1)) * 16 + hexDigit(text.charCodeAt(2))) / 255,
  6013. green: (hexDigit(text.charCodeAt(3)) * 16 + hexDigit(text.charCodeAt(4))) / 255,
  6014. blue: (hexDigit(text.charCodeAt(5)) * 16 + hexDigit(text.charCodeAt(6))) / 255,
  6015. alpha: (hexDigit(text.charCodeAt(7)) * 16 + hexDigit(text.charCodeAt(8))) / 255
  6016. };
  6017. }
  6018. return void 0;
  6019. }
  6020. // node_modules/vscode-json-languageservice/lib/esm/services/jsonDocumentSymbols.js
  6021. var JSONDocumentSymbols = function() {
  6022. function JSONDocumentSymbols2(schemaService) {
  6023. this.schemaService = schemaService;
  6024. }
  6025. JSONDocumentSymbols2.prototype.findDocumentSymbols = function(document, doc, context) {
  6026. var _this = this;
  6027. if (context === void 0) {
  6028. context = { resultLimit: Number.MAX_VALUE };
  6029. }
  6030. var root = doc.root;
  6031. if (!root) {
  6032. return [];
  6033. }
  6034. var limit = context.resultLimit || Number.MAX_VALUE;
  6035. var resourceString = document.uri;
  6036. if (resourceString === "vscode://defaultsettings/keybindings.json" || endsWith(resourceString.toLowerCase(), "/user/keybindings.json")) {
  6037. if (root.type === "array") {
  6038. var result_1 = [];
  6039. for (var _i = 0, _a = root.items; _i < _a.length; _i++) {
  6040. var item = _a[_i];
  6041. if (item.type === "object") {
  6042. for (var _b = 0, _c = item.properties; _b < _c.length; _b++) {
  6043. var property = _c[_b];
  6044. if (property.keyNode.value === "key" && property.valueNode) {
  6045. var location = Location.create(document.uri, getRange(document, item));
  6046. result_1.push({ name: getNodeValue3(property.valueNode), kind: SymbolKind.Function, location });
  6047. limit--;
  6048. if (limit <= 0) {
  6049. if (context && context.onResultLimitExceeded) {
  6050. context.onResultLimitExceeded(resourceString);
  6051. }
  6052. return result_1;
  6053. }
  6054. }
  6055. }
  6056. }
  6057. }
  6058. return result_1;
  6059. }
  6060. }
  6061. var toVisit = [
  6062. { node: root, containerName: "" }
  6063. ];
  6064. var nextToVisit = 0;
  6065. var limitExceeded = false;
  6066. var result = [];
  6067. var collectOutlineEntries = function(node, containerName) {
  6068. if (node.type === "array") {
  6069. node.items.forEach(function(node2) {
  6070. if (node2) {
  6071. toVisit.push({ node: node2, containerName });
  6072. }
  6073. });
  6074. } else if (node.type === "object") {
  6075. node.properties.forEach(function(property2) {
  6076. var valueNode = property2.valueNode;
  6077. if (valueNode) {
  6078. if (limit > 0) {
  6079. limit--;
  6080. var location2 = Location.create(document.uri, getRange(document, property2));
  6081. var childContainerName = containerName ? containerName + "." + property2.keyNode.value : property2.keyNode.value;
  6082. result.push({ name: _this.getKeyLabel(property2), kind: _this.getSymbolKind(valueNode.type), location: location2, containerName });
  6083. toVisit.push({ node: valueNode, containerName: childContainerName });
  6084. } else {
  6085. limitExceeded = true;
  6086. }
  6087. }
  6088. });
  6089. }
  6090. };
  6091. while (nextToVisit < toVisit.length) {
  6092. var next = toVisit[nextToVisit++];
  6093. collectOutlineEntries(next.node, next.containerName);
  6094. }
  6095. if (limitExceeded && context && context.onResultLimitExceeded) {
  6096. context.onResultLimitExceeded(resourceString);
  6097. }
  6098. return result;
  6099. };
  6100. JSONDocumentSymbols2.prototype.findDocumentSymbols2 = function(document, doc, context) {
  6101. var _this = this;
  6102. if (context === void 0) {
  6103. context = { resultLimit: Number.MAX_VALUE };
  6104. }
  6105. var root = doc.root;
  6106. if (!root) {
  6107. return [];
  6108. }
  6109. var limit = context.resultLimit || Number.MAX_VALUE;
  6110. var resourceString = document.uri;
  6111. if (resourceString === "vscode://defaultsettings/keybindings.json" || endsWith(resourceString.toLowerCase(), "/user/keybindings.json")) {
  6112. if (root.type === "array") {
  6113. var result_2 = [];
  6114. for (var _i = 0, _a = root.items; _i < _a.length; _i++) {
  6115. var item = _a[_i];
  6116. if (item.type === "object") {
  6117. for (var _b = 0, _c = item.properties; _b < _c.length; _b++) {
  6118. var property = _c[_b];
  6119. if (property.keyNode.value === "key" && property.valueNode) {
  6120. var range = getRange(document, item);
  6121. var selectionRange = getRange(document, property.keyNode);
  6122. result_2.push({ name: getNodeValue3(property.valueNode), kind: SymbolKind.Function, range, selectionRange });
  6123. limit--;
  6124. if (limit <= 0) {
  6125. if (context && context.onResultLimitExceeded) {
  6126. context.onResultLimitExceeded(resourceString);
  6127. }
  6128. return result_2;
  6129. }
  6130. }
  6131. }
  6132. }
  6133. }
  6134. return result_2;
  6135. }
  6136. }
  6137. var result = [];
  6138. var toVisit = [
  6139. { node: root, result }
  6140. ];
  6141. var nextToVisit = 0;
  6142. var limitExceeded = false;
  6143. var collectOutlineEntries = function(node, result2) {
  6144. if (node.type === "array") {
  6145. node.items.forEach(function(node2, index) {
  6146. if (node2) {
  6147. if (limit > 0) {
  6148. limit--;
  6149. var range2 = getRange(document, node2);
  6150. var selectionRange2 = range2;
  6151. var name = String(index);
  6152. var symbol = { name, kind: _this.getSymbolKind(node2.type), range: range2, selectionRange: selectionRange2, children: [] };
  6153. result2.push(symbol);
  6154. toVisit.push({ result: symbol.children, node: node2 });
  6155. } else {
  6156. limitExceeded = true;
  6157. }
  6158. }
  6159. });
  6160. } else if (node.type === "object") {
  6161. node.properties.forEach(function(property2) {
  6162. var valueNode = property2.valueNode;
  6163. if (valueNode) {
  6164. if (limit > 0) {
  6165. limit--;
  6166. var range2 = getRange(document, property2);
  6167. var selectionRange2 = getRange(document, property2.keyNode);
  6168. var children = [];
  6169. var symbol = { name: _this.getKeyLabel(property2), kind: _this.getSymbolKind(valueNode.type), range: range2, selectionRange: selectionRange2, children, detail: _this.getDetail(valueNode) };
  6170. result2.push(symbol);
  6171. toVisit.push({ result: children, node: valueNode });
  6172. } else {
  6173. limitExceeded = true;
  6174. }
  6175. }
  6176. });
  6177. }
  6178. };
  6179. while (nextToVisit < toVisit.length) {
  6180. var next = toVisit[nextToVisit++];
  6181. collectOutlineEntries(next.node, next.result);
  6182. }
  6183. if (limitExceeded && context && context.onResultLimitExceeded) {
  6184. context.onResultLimitExceeded(resourceString);
  6185. }
  6186. return result;
  6187. };
  6188. JSONDocumentSymbols2.prototype.getSymbolKind = function(nodeType) {
  6189. switch (nodeType) {
  6190. case "object":
  6191. return SymbolKind.Module;
  6192. case "string":
  6193. return SymbolKind.String;
  6194. case "number":
  6195. return SymbolKind.Number;
  6196. case "array":
  6197. return SymbolKind.Array;
  6198. case "boolean":
  6199. return SymbolKind.Boolean;
  6200. default:
  6201. return SymbolKind.Variable;
  6202. }
  6203. };
  6204. JSONDocumentSymbols2.prototype.getKeyLabel = function(property) {
  6205. var name = property.keyNode.value;
  6206. if (name) {
  6207. name = name.replace(/[\n]/g, "\u21B5");
  6208. }
  6209. if (name && name.trim()) {
  6210. return name;
  6211. }
  6212. return '"' + name + '"';
  6213. };
  6214. JSONDocumentSymbols2.prototype.getDetail = function(node) {
  6215. if (!node) {
  6216. return void 0;
  6217. }
  6218. if (node.type === "boolean" || node.type === "number" || node.type === "null" || node.type === "string") {
  6219. return String(node.value);
  6220. } else {
  6221. if (node.type === "array") {
  6222. return node.children.length ? void 0 : "[]";
  6223. } else if (node.type === "object") {
  6224. return node.children.length ? void 0 : "{}";
  6225. }
  6226. }
  6227. return void 0;
  6228. };
  6229. JSONDocumentSymbols2.prototype.findDocumentColors = function(document, doc, context) {
  6230. return this.schemaService.getSchemaForResource(document.uri, doc).then(function(schema) {
  6231. var result = [];
  6232. if (schema) {
  6233. var limit = context && typeof context.resultLimit === "number" ? context.resultLimit : Number.MAX_VALUE;
  6234. var matchingSchemas = doc.getMatchingSchemas(schema.schema);
  6235. var visitedNode = {};
  6236. for (var _i = 0, matchingSchemas_1 = matchingSchemas; _i < matchingSchemas_1.length; _i++) {
  6237. var s = matchingSchemas_1[_i];
  6238. if (!s.inverted && s.schema && (s.schema.format === "color" || s.schema.format === "color-hex") && s.node && s.node.type === "string") {
  6239. var nodeId = String(s.node.offset);
  6240. if (!visitedNode[nodeId]) {
  6241. var color = colorFromHex(getNodeValue3(s.node));
  6242. if (color) {
  6243. var range = getRange(document, s.node);
  6244. result.push({ color, range });
  6245. }
  6246. visitedNode[nodeId] = true;
  6247. limit--;
  6248. if (limit <= 0) {
  6249. if (context && context.onResultLimitExceeded) {
  6250. context.onResultLimitExceeded(document.uri);
  6251. }
  6252. return result;
  6253. }
  6254. }
  6255. }
  6256. }
  6257. }
  6258. return result;
  6259. });
  6260. };
  6261. JSONDocumentSymbols2.prototype.getColorPresentations = function(document, doc, color, range) {
  6262. var result = [];
  6263. var red256 = Math.round(color.red * 255), green256 = Math.round(color.green * 255), blue256 = Math.round(color.blue * 255);
  6264. function toTwoDigitHex(n) {
  6265. var r = n.toString(16);
  6266. return r.length !== 2 ? "0" + r : r;
  6267. }
  6268. var label;
  6269. if (color.alpha === 1) {
  6270. label = "#" + toTwoDigitHex(red256) + toTwoDigitHex(green256) + toTwoDigitHex(blue256);
  6271. } else {
  6272. label = "#" + toTwoDigitHex(red256) + toTwoDigitHex(green256) + toTwoDigitHex(blue256) + toTwoDigitHex(Math.round(color.alpha * 255));
  6273. }
  6274. result.push({ label, textEdit: TextEdit.replace(range, JSON.stringify(label)) });
  6275. return result;
  6276. };
  6277. return JSONDocumentSymbols2;
  6278. }();
  6279. function getRange(document, node) {
  6280. return Range.create(document.positionAt(node.offset), document.positionAt(node.offset + node.length));
  6281. }
  6282. // node_modules/vscode-json-languageservice/lib/esm/services/configuration.js
  6283. var localize6 = loadMessageBundle();
  6284. var schemaContributions = {
  6285. schemaAssociations: [],
  6286. schemas: {
  6287. "http://json-schema.org/schema#": {
  6288. $ref: "http://json-schema.org/draft-07/schema#"
  6289. },
  6290. "http://json-schema.org/draft-04/schema#": {
  6291. "$schema": "http://json-schema.org/draft-04/schema#",
  6292. "definitions": {
  6293. "schemaArray": {
  6294. "type": "array",
  6295. "minItems": 1,
  6296. "items": {
  6297. "$ref": "#"
  6298. }
  6299. },
  6300. "positiveInteger": {
  6301. "type": "integer",
  6302. "minimum": 0
  6303. },
  6304. "positiveIntegerDefault0": {
  6305. "allOf": [
  6306. {
  6307. "$ref": "#/definitions/positiveInteger"
  6308. },
  6309. {
  6310. "default": 0
  6311. }
  6312. ]
  6313. },
  6314. "simpleTypes": {
  6315. "type": "string",
  6316. "enum": [
  6317. "array",
  6318. "boolean",
  6319. "integer",
  6320. "null",
  6321. "number",
  6322. "object",
  6323. "string"
  6324. ]
  6325. },
  6326. "stringArray": {
  6327. "type": "array",
  6328. "items": {
  6329. "type": "string"
  6330. },
  6331. "minItems": 1,
  6332. "uniqueItems": true
  6333. }
  6334. },
  6335. "type": "object",
  6336. "properties": {
  6337. "id": {
  6338. "type": "string",
  6339. "format": "uri"
  6340. },
  6341. "$schema": {
  6342. "type": "string",
  6343. "format": "uri"
  6344. },
  6345. "title": {
  6346. "type": "string"
  6347. },
  6348. "description": {
  6349. "type": "string"
  6350. },
  6351. "default": {},
  6352. "multipleOf": {
  6353. "type": "number",
  6354. "minimum": 0,
  6355. "exclusiveMinimum": true
  6356. },
  6357. "maximum": {
  6358. "type": "number"
  6359. },
  6360. "exclusiveMaximum": {
  6361. "type": "boolean",
  6362. "default": false
  6363. },
  6364. "minimum": {
  6365. "type": "number"
  6366. },
  6367. "exclusiveMinimum": {
  6368. "type": "boolean",
  6369. "default": false
  6370. },
  6371. "maxLength": {
  6372. "allOf": [
  6373. {
  6374. "$ref": "#/definitions/positiveInteger"
  6375. }
  6376. ]
  6377. },
  6378. "minLength": {
  6379. "allOf": [
  6380. {
  6381. "$ref": "#/definitions/positiveIntegerDefault0"
  6382. }
  6383. ]
  6384. },
  6385. "pattern": {
  6386. "type": "string",
  6387. "format": "regex"
  6388. },
  6389. "additionalItems": {
  6390. "anyOf": [
  6391. {
  6392. "type": "boolean"
  6393. },
  6394. {
  6395. "$ref": "#"
  6396. }
  6397. ],
  6398. "default": {}
  6399. },
  6400. "items": {
  6401. "anyOf": [
  6402. {
  6403. "$ref": "#"
  6404. },
  6405. {
  6406. "$ref": "#/definitions/schemaArray"
  6407. }
  6408. ],
  6409. "default": {}
  6410. },
  6411. "maxItems": {
  6412. "allOf": [
  6413. {
  6414. "$ref": "#/definitions/positiveInteger"
  6415. }
  6416. ]
  6417. },
  6418. "minItems": {
  6419. "allOf": [
  6420. {
  6421. "$ref": "#/definitions/positiveIntegerDefault0"
  6422. }
  6423. ]
  6424. },
  6425. "uniqueItems": {
  6426. "type": "boolean",
  6427. "default": false
  6428. },
  6429. "maxProperties": {
  6430. "allOf": [
  6431. {
  6432. "$ref": "#/definitions/positiveInteger"
  6433. }
  6434. ]
  6435. },
  6436. "minProperties": {
  6437. "allOf": [
  6438. {
  6439. "$ref": "#/definitions/positiveIntegerDefault0"
  6440. }
  6441. ]
  6442. },
  6443. "required": {
  6444. "allOf": [
  6445. {
  6446. "$ref": "#/definitions/stringArray"
  6447. }
  6448. ]
  6449. },
  6450. "additionalProperties": {
  6451. "anyOf": [
  6452. {
  6453. "type": "boolean"
  6454. },
  6455. {
  6456. "$ref": "#"
  6457. }
  6458. ],
  6459. "default": {}
  6460. },
  6461. "definitions": {
  6462. "type": "object",
  6463. "additionalProperties": {
  6464. "$ref": "#"
  6465. },
  6466. "default": {}
  6467. },
  6468. "properties": {
  6469. "type": "object",
  6470. "additionalProperties": {
  6471. "$ref": "#"
  6472. },
  6473. "default": {}
  6474. },
  6475. "patternProperties": {
  6476. "type": "object",
  6477. "additionalProperties": {
  6478. "$ref": "#"
  6479. },
  6480. "default": {}
  6481. },
  6482. "dependencies": {
  6483. "type": "object",
  6484. "additionalProperties": {
  6485. "anyOf": [
  6486. {
  6487. "$ref": "#"
  6488. },
  6489. {
  6490. "$ref": "#/definitions/stringArray"
  6491. }
  6492. ]
  6493. }
  6494. },
  6495. "enum": {
  6496. "type": "array",
  6497. "minItems": 1,
  6498. "uniqueItems": true
  6499. },
  6500. "type": {
  6501. "anyOf": [
  6502. {
  6503. "$ref": "#/definitions/simpleTypes"
  6504. },
  6505. {
  6506. "type": "array",
  6507. "items": {
  6508. "$ref": "#/definitions/simpleTypes"
  6509. },
  6510. "minItems": 1,
  6511. "uniqueItems": true
  6512. }
  6513. ]
  6514. },
  6515. "format": {
  6516. "anyOf": [
  6517. {
  6518. "type": "string",
  6519. "enum": [
  6520. "date-time",
  6521. "uri",
  6522. "email",
  6523. "hostname",
  6524. "ipv4",
  6525. "ipv6",
  6526. "regex"
  6527. ]
  6528. },
  6529. {
  6530. "type": "string"
  6531. }
  6532. ]
  6533. },
  6534. "allOf": {
  6535. "allOf": [
  6536. {
  6537. "$ref": "#/definitions/schemaArray"
  6538. }
  6539. ]
  6540. },
  6541. "anyOf": {
  6542. "allOf": [
  6543. {
  6544. "$ref": "#/definitions/schemaArray"
  6545. }
  6546. ]
  6547. },
  6548. "oneOf": {
  6549. "allOf": [
  6550. {
  6551. "$ref": "#/definitions/schemaArray"
  6552. }
  6553. ]
  6554. },
  6555. "not": {
  6556. "allOf": [
  6557. {
  6558. "$ref": "#"
  6559. }
  6560. ]
  6561. }
  6562. },
  6563. "dependencies": {
  6564. "exclusiveMaximum": [
  6565. "maximum"
  6566. ],
  6567. "exclusiveMinimum": [
  6568. "minimum"
  6569. ]
  6570. },
  6571. "default": {}
  6572. },
  6573. "http://json-schema.org/draft-07/schema#": {
  6574. "definitions": {
  6575. "schemaArray": {
  6576. "type": "array",
  6577. "minItems": 1,
  6578. "items": { "$ref": "#" }
  6579. },
  6580. "nonNegativeInteger": {
  6581. "type": "integer",
  6582. "minimum": 0
  6583. },
  6584. "nonNegativeIntegerDefault0": {
  6585. "allOf": [
  6586. { "$ref": "#/definitions/nonNegativeInteger" },
  6587. { "default": 0 }
  6588. ]
  6589. },
  6590. "simpleTypes": {
  6591. "enum": [
  6592. "array",
  6593. "boolean",
  6594. "integer",
  6595. "null",
  6596. "number",
  6597. "object",
  6598. "string"
  6599. ]
  6600. },
  6601. "stringArray": {
  6602. "type": "array",
  6603. "items": { "type": "string" },
  6604. "uniqueItems": true,
  6605. "default": []
  6606. }
  6607. },
  6608. "type": ["object", "boolean"],
  6609. "properties": {
  6610. "$id": {
  6611. "type": "string",
  6612. "format": "uri-reference"
  6613. },
  6614. "$schema": {
  6615. "type": "string",
  6616. "format": "uri"
  6617. },
  6618. "$ref": {
  6619. "type": "string",
  6620. "format": "uri-reference"
  6621. },
  6622. "$comment": {
  6623. "type": "string"
  6624. },
  6625. "title": {
  6626. "type": "string"
  6627. },
  6628. "description": {
  6629. "type": "string"
  6630. },
  6631. "default": true,
  6632. "readOnly": {
  6633. "type": "boolean",
  6634. "default": false
  6635. },
  6636. "examples": {
  6637. "type": "array",
  6638. "items": true
  6639. },
  6640. "multipleOf": {
  6641. "type": "number",
  6642. "exclusiveMinimum": 0
  6643. },
  6644. "maximum": {
  6645. "type": "number"
  6646. },
  6647. "exclusiveMaximum": {
  6648. "type": "number"
  6649. },
  6650. "minimum": {
  6651. "type": "number"
  6652. },
  6653. "exclusiveMinimum": {
  6654. "type": "number"
  6655. },
  6656. "maxLength": { "$ref": "#/definitions/nonNegativeInteger" },
  6657. "minLength": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
  6658. "pattern": {
  6659. "type": "string",
  6660. "format": "regex"
  6661. },
  6662. "additionalItems": { "$ref": "#" },
  6663. "items": {
  6664. "anyOf": [
  6665. { "$ref": "#" },
  6666. { "$ref": "#/definitions/schemaArray" }
  6667. ],
  6668. "default": true
  6669. },
  6670. "maxItems": { "$ref": "#/definitions/nonNegativeInteger" },
  6671. "minItems": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
  6672. "uniqueItems": {
  6673. "type": "boolean",
  6674. "default": false
  6675. },
  6676. "contains": { "$ref": "#" },
  6677. "maxProperties": { "$ref": "#/definitions/nonNegativeInteger" },
  6678. "minProperties": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
  6679. "required": { "$ref": "#/definitions/stringArray" },
  6680. "additionalProperties": { "$ref": "#" },
  6681. "definitions": {
  6682. "type": "object",
  6683. "additionalProperties": { "$ref": "#" },
  6684. "default": {}
  6685. },
  6686. "properties": {
  6687. "type": "object",
  6688. "additionalProperties": { "$ref": "#" },
  6689. "default": {}
  6690. },
  6691. "patternProperties": {
  6692. "type": "object",
  6693. "additionalProperties": { "$ref": "#" },
  6694. "propertyNames": { "format": "regex" },
  6695. "default": {}
  6696. },
  6697. "dependencies": {
  6698. "type": "object",
  6699. "additionalProperties": {
  6700. "anyOf": [
  6701. { "$ref": "#" },
  6702. { "$ref": "#/definitions/stringArray" }
  6703. ]
  6704. }
  6705. },
  6706. "propertyNames": { "$ref": "#" },
  6707. "const": true,
  6708. "enum": {
  6709. "type": "array",
  6710. "items": true,
  6711. "minItems": 1,
  6712. "uniqueItems": true
  6713. },
  6714. "type": {
  6715. "anyOf": [
  6716. { "$ref": "#/definitions/simpleTypes" },
  6717. {
  6718. "type": "array",
  6719. "items": { "$ref": "#/definitions/simpleTypes" },
  6720. "minItems": 1,
  6721. "uniqueItems": true
  6722. }
  6723. ]
  6724. },
  6725. "format": { "type": "string" },
  6726. "contentMediaType": { "type": "string" },
  6727. "contentEncoding": { "type": "string" },
  6728. "if": { "$ref": "#" },
  6729. "then": { "$ref": "#" },
  6730. "else": { "$ref": "#" },
  6731. "allOf": { "$ref": "#/definitions/schemaArray" },
  6732. "anyOf": { "$ref": "#/definitions/schemaArray" },
  6733. "oneOf": { "$ref": "#/definitions/schemaArray" },
  6734. "not": { "$ref": "#" }
  6735. },
  6736. "default": true
  6737. }
  6738. }
  6739. };
  6740. var descriptions = {
  6741. id: localize6("schema.json.id", "A unique identifier for the schema."),
  6742. $schema: localize6("schema.json.$schema", "The schema to verify this document against."),
  6743. title: localize6("schema.json.title", "A descriptive title of the element."),
  6744. description: localize6("schema.json.description", "A long description of the element. Used in hover menus and suggestions."),
  6745. default: localize6("schema.json.default", "A default value. Used by suggestions."),
  6746. multipleOf: localize6("schema.json.multipleOf", "A number that should cleanly divide the current value (i.e. have no remainder)."),
  6747. maximum: localize6("schema.json.maximum", "The maximum numerical value, inclusive by default."),
  6748. exclusiveMaximum: localize6("schema.json.exclusiveMaximum", "Makes the maximum property exclusive."),
  6749. minimum: localize6("schema.json.minimum", "The minimum numerical value, inclusive by default."),
  6750. exclusiveMinimum: localize6("schema.json.exclusiveMininum", "Makes the minimum property exclusive."),
  6751. maxLength: localize6("schema.json.maxLength", "The maximum length of a string."),
  6752. minLength: localize6("schema.json.minLength", "The minimum length of a string."),
  6753. pattern: localize6("schema.json.pattern", "A regular expression to match the string against. It is not implicitly anchored."),
  6754. additionalItems: localize6("schema.json.additionalItems", "For arrays, only when items is set as an array. If it is a schema, then this schema validates items after the ones specified by the items array. If it is false, then additional items will cause validation to fail."),
  6755. items: localize6("schema.json.items", "For arrays. Can either be a schema to validate every element against or an array of schemas to validate each item against in order (the first schema will validate the first element, the second schema will validate the second element, and so on."),
  6756. maxItems: localize6("schema.json.maxItems", "The maximum number of items that can be inside an array. Inclusive."),
  6757. minItems: localize6("schema.json.minItems", "The minimum number of items that can be inside an array. Inclusive."),
  6758. uniqueItems: localize6("schema.json.uniqueItems", "If all of the items in the array must be unique. Defaults to false."),
  6759. maxProperties: localize6("schema.json.maxProperties", "The maximum number of properties an object can have. Inclusive."),
  6760. minProperties: localize6("schema.json.minProperties", "The minimum number of properties an object can have. Inclusive."),
  6761. required: localize6("schema.json.required", "An array of strings that lists the names of all properties required on this object."),
  6762. additionalProperties: localize6("schema.json.additionalProperties", "Either a schema or a boolean. If a schema, then used to validate all properties not matched by 'properties' or 'patternProperties'. If false, then any properties not matched by either will cause this schema to fail."),
  6763. definitions: localize6("schema.json.definitions", "Not used for validation. Place subschemas here that you wish to reference inline with $ref."),
  6764. properties: localize6("schema.json.properties", "A map of property names to schemas for each property."),
  6765. patternProperties: localize6("schema.json.patternProperties", "A map of regular expressions on property names to schemas for matching properties."),
  6766. dependencies: localize6("schema.json.dependencies", "A map of property names to either an array of property names or a schema. An array of property names means the property named in the key depends on the properties in the array being present in the object in order to be valid. If the value is a schema, then the schema is only applied to the object if the property in the key exists on the object."),
  6767. enum: localize6("schema.json.enum", "The set of literal values that are valid."),
  6768. type: localize6("schema.json.type", "Either a string of one of the basic schema types (number, integer, null, array, object, boolean, string) or an array of strings specifying a subset of those types."),
  6769. format: localize6("schema.json.format", "Describes the format expected for the value."),
  6770. allOf: localize6("schema.json.allOf", "An array of schemas, all of which must match."),
  6771. anyOf: localize6("schema.json.anyOf", "An array of schemas, where at least one must match."),
  6772. oneOf: localize6("schema.json.oneOf", "An array of schemas, exactly one of which must match."),
  6773. not: localize6("schema.json.not", "A schema which must not match."),
  6774. $id: localize6("schema.json.$id", "A unique identifier for the schema."),
  6775. $ref: localize6("schema.json.$ref", "Reference a definition hosted on any location."),
  6776. $comment: localize6("schema.json.$comment", "Comments from schema authors to readers or maintainers of the schema."),
  6777. readOnly: localize6("schema.json.readOnly", "Indicates that the value of the instance is managed exclusively by the owning authority."),
  6778. examples: localize6("schema.json.examples", "Sample JSON values associated with a particular schema, for the purpose of illustrating usage."),
  6779. contains: localize6("schema.json.contains", 'An array instance is valid against "contains" if at least one of its elements is valid against the given schema.'),
  6780. propertyNames: localize6("schema.json.propertyNames", "If the instance is an object, this keyword validates if every property name in the instance validates against the provided schema."),
  6781. const: localize6("schema.json.const", "An instance validates successfully against this keyword if its value is equal to the value of the keyword."),
  6782. contentMediaType: localize6("schema.json.contentMediaType", "Describes the media type of a string property."),
  6783. contentEncoding: localize6("schema.json.contentEncoding", "Describes the content encoding of a string property."),
  6784. if: localize6("schema.json.if", 'The validation outcome of the "if" subschema controls which of the "then" or "else" keywords are evaluated.'),
  6785. then: localize6("schema.json.then", 'The "if" subschema is used for validation when the "if" subschema succeeds.'),
  6786. else: localize6("schema.json.else", 'The "else" subschema is used for validation when the "if" subschema fails.')
  6787. };
  6788. for (schemaName in schemaContributions.schemas) {
  6789. schema = schemaContributions.schemas[schemaName];
  6790. for (property in schema.properties) {
  6791. propertyObject = schema.properties[property];
  6792. if (typeof propertyObject === "boolean") {
  6793. propertyObject = schema.properties[property] = {};
  6794. }
  6795. description = descriptions[property];
  6796. if (description) {
  6797. propertyObject["description"] = description;
  6798. } else {
  6799. console.log(property + ": localize('schema.json." + property + `', "")`);
  6800. }
  6801. }
  6802. }
  6803. var schema;
  6804. var propertyObject;
  6805. var description;
  6806. var property;
  6807. var schemaName;
  6808. // node_modules/vscode-json-languageservice/lib/esm/services/jsonFolding.js
  6809. function getFoldingRanges(document, context) {
  6810. var ranges = [];
  6811. var nestingLevels = [];
  6812. var stack = [];
  6813. var prevStart = -1;
  6814. var scanner2 = createScanner2(document.getText(), false);
  6815. var token = scanner2.scan();
  6816. function addRange(range2) {
  6817. ranges.push(range2);
  6818. nestingLevels.push(stack.length);
  6819. }
  6820. while (token !== 17) {
  6821. switch (token) {
  6822. case 1:
  6823. case 3: {
  6824. var startLine = document.positionAt(scanner2.getTokenOffset()).line;
  6825. var range = { startLine, endLine: startLine, kind: token === 1 ? "object" : "array" };
  6826. stack.push(range);
  6827. break;
  6828. }
  6829. case 2:
  6830. case 4: {
  6831. var kind = token === 2 ? "object" : "array";
  6832. if (stack.length > 0 && stack[stack.length - 1].kind === kind) {
  6833. var range = stack.pop();
  6834. var line = document.positionAt(scanner2.getTokenOffset()).line;
  6835. if (range && line > range.startLine + 1 && prevStart !== range.startLine) {
  6836. range.endLine = line - 1;
  6837. addRange(range);
  6838. prevStart = range.startLine;
  6839. }
  6840. }
  6841. break;
  6842. }
  6843. case 13: {
  6844. var startLine = document.positionAt(scanner2.getTokenOffset()).line;
  6845. var endLine = document.positionAt(scanner2.getTokenOffset() + scanner2.getTokenLength()).line;
  6846. if (scanner2.getTokenError() === 1 && startLine + 1 < document.lineCount) {
  6847. scanner2.setPosition(document.offsetAt(Position.create(startLine + 1, 0)));
  6848. } else {
  6849. if (startLine < endLine) {
  6850. addRange({ startLine, endLine, kind: FoldingRangeKind.Comment });
  6851. prevStart = startLine;
  6852. }
  6853. }
  6854. break;
  6855. }
  6856. case 12: {
  6857. var text = document.getText().substr(scanner2.getTokenOffset(), scanner2.getTokenLength());
  6858. var m = text.match(/^\/\/\s*#(region\b)|(endregion\b)/);
  6859. if (m) {
  6860. var line = document.positionAt(scanner2.getTokenOffset()).line;
  6861. if (m[1]) {
  6862. var range = { startLine: line, endLine: line, kind: FoldingRangeKind.Region };
  6863. stack.push(range);
  6864. } else {
  6865. var i = stack.length - 1;
  6866. while (i >= 0 && stack[i].kind !== FoldingRangeKind.Region) {
  6867. i--;
  6868. }
  6869. if (i >= 0) {
  6870. var range = stack[i];
  6871. stack.length = i;
  6872. if (line > range.startLine && prevStart !== range.startLine) {
  6873. range.endLine = line;
  6874. addRange(range);
  6875. prevStart = range.startLine;
  6876. }
  6877. }
  6878. }
  6879. }
  6880. break;
  6881. }
  6882. }
  6883. token = scanner2.scan();
  6884. }
  6885. var rangeLimit = context && context.rangeLimit;
  6886. if (typeof rangeLimit !== "number" || ranges.length <= rangeLimit) {
  6887. return ranges;
  6888. }
  6889. if (context && context.onRangeLimitExceeded) {
  6890. context.onRangeLimitExceeded(document.uri);
  6891. }
  6892. var counts = [];
  6893. for (var _i = 0, nestingLevels_1 = nestingLevels; _i < nestingLevels_1.length; _i++) {
  6894. var level = nestingLevels_1[_i];
  6895. if (level < 30) {
  6896. counts[level] = (counts[level] || 0) + 1;
  6897. }
  6898. }
  6899. var entries = 0;
  6900. var maxLevel = 0;
  6901. for (var i = 0; i < counts.length; i++) {
  6902. var n = counts[i];
  6903. if (n) {
  6904. if (n + entries > rangeLimit) {
  6905. maxLevel = i;
  6906. break;
  6907. }
  6908. entries += n;
  6909. }
  6910. }
  6911. var result = [];
  6912. for (var i = 0; i < ranges.length; i++) {
  6913. var level = nestingLevels[i];
  6914. if (typeof level === "number") {
  6915. if (level < maxLevel || level === maxLevel && entries++ < rangeLimit) {
  6916. result.push(ranges[i]);
  6917. }
  6918. }
  6919. }
  6920. return result;
  6921. }
  6922. // node_modules/vscode-json-languageservice/lib/esm/services/jsonSelectionRanges.js
  6923. function getSelectionRanges(document, positions, doc) {
  6924. function getSelectionRange(position) {
  6925. var offset = document.offsetAt(position);
  6926. var node = doc.getNodeFromOffset(offset, true);
  6927. var result = [];
  6928. while (node) {
  6929. switch (node.type) {
  6930. case "string":
  6931. case "object":
  6932. case "array":
  6933. var cStart = node.offset + 1, cEnd = node.offset + node.length - 1;
  6934. if (cStart < cEnd && offset >= cStart && offset <= cEnd) {
  6935. result.push(newRange(cStart, cEnd));
  6936. }
  6937. result.push(newRange(node.offset, node.offset + node.length));
  6938. break;
  6939. case "number":
  6940. case "boolean":
  6941. case "null":
  6942. case "property":
  6943. result.push(newRange(node.offset, node.offset + node.length));
  6944. break;
  6945. }
  6946. if (node.type === "property" || node.parent && node.parent.type === "array") {
  6947. var afterCommaOffset = getOffsetAfterNextToken(node.offset + node.length, 5);
  6948. if (afterCommaOffset !== -1) {
  6949. result.push(newRange(node.offset, afterCommaOffset));
  6950. }
  6951. }
  6952. node = node.parent;
  6953. }
  6954. var current = void 0;
  6955. for (var index = result.length - 1; index >= 0; index--) {
  6956. current = SelectionRange.create(result[index], current);
  6957. }
  6958. if (!current) {
  6959. current = SelectionRange.create(Range.create(position, position));
  6960. }
  6961. return current;
  6962. }
  6963. function newRange(start, end) {
  6964. return Range.create(document.positionAt(start), document.positionAt(end));
  6965. }
  6966. var scanner2 = createScanner2(document.getText(), true);
  6967. function getOffsetAfterNextToken(offset, expectedToken) {
  6968. scanner2.setPosition(offset);
  6969. var token = scanner2.scan();
  6970. if (token === expectedToken) {
  6971. return scanner2.getTokenOffset() + scanner2.getTokenLength();
  6972. }
  6973. return -1;
  6974. }
  6975. return positions.map(getSelectionRange);
  6976. }
  6977. // node_modules/vscode-json-languageservice/lib/esm/services/jsonLinks.js
  6978. function findLinks(document, doc) {
  6979. var links = [];
  6980. doc.visit(function(node) {
  6981. var _a;
  6982. if (node.type === "property" && node.keyNode.value === "$ref" && ((_a = node.valueNode) === null || _a === void 0 ? void 0 : _a.type) === "string") {
  6983. var path = node.valueNode.value;
  6984. var targetNode = findTargetNode(doc, path);
  6985. if (targetNode) {
  6986. var targetPos = document.positionAt(targetNode.offset);
  6987. links.push({
  6988. target: document.uri + "#" + (targetPos.line + 1) + "," + (targetPos.character + 1),
  6989. range: createRange(document, node.valueNode)
  6990. });
  6991. }
  6992. }
  6993. return true;
  6994. });
  6995. return Promise.resolve(links);
  6996. }
  6997. function createRange(document, node) {
  6998. return Range.create(document.positionAt(node.offset + 1), document.positionAt(node.offset + node.length - 1));
  6999. }
  7000. function findTargetNode(doc, path) {
  7001. var tokens = parseJSONPointer(path);
  7002. if (!tokens) {
  7003. return null;
  7004. }
  7005. return findNode(tokens, doc.root);
  7006. }
  7007. function findNode(pointer, node) {
  7008. if (!node) {
  7009. return null;
  7010. }
  7011. if (pointer.length === 0) {
  7012. return node;
  7013. }
  7014. var token = pointer.shift();
  7015. if (node && node.type === "object") {
  7016. var propertyNode = node.properties.find(function(propertyNode2) {
  7017. return propertyNode2.keyNode.value === token;
  7018. });
  7019. if (!propertyNode) {
  7020. return null;
  7021. }
  7022. return findNode(pointer, propertyNode.valueNode);
  7023. } else if (node && node.type === "array") {
  7024. if (token.match(/^(0|[1-9][0-9]*)$/)) {
  7025. var index = Number.parseInt(token);
  7026. var arrayItem = node.items[index];
  7027. if (!arrayItem) {
  7028. return null;
  7029. }
  7030. return findNode(pointer, arrayItem);
  7031. }
  7032. }
  7033. return null;
  7034. }
  7035. function parseJSONPointer(path) {
  7036. if (path === "#") {
  7037. return [];
  7038. }
  7039. if (path[0] !== "#" || path[1] !== "/") {
  7040. return null;
  7041. }
  7042. return path.substring(2).split(/\//).map(unescape);
  7043. }
  7044. function unescape(str) {
  7045. return str.replace(/~1/g, "/").replace(/~0/g, "~");
  7046. }
  7047. // node_modules/vscode-json-languageservice/lib/esm/jsonLanguageService.js
  7048. function getLanguageService(params) {
  7049. var promise = params.promiseConstructor || Promise;
  7050. var jsonSchemaService = new JSONSchemaService(params.schemaRequestService, params.workspaceContext, promise);
  7051. jsonSchemaService.setSchemaContributions(schemaContributions);
  7052. var jsonCompletion = new JSONCompletion(jsonSchemaService, params.contributions, promise, params.clientCapabilities);
  7053. var jsonHover = new JSONHover(jsonSchemaService, params.contributions, promise);
  7054. var jsonDocumentSymbols = new JSONDocumentSymbols(jsonSchemaService);
  7055. var jsonValidation = new JSONValidation(jsonSchemaService, promise);
  7056. return {
  7057. configure: function(settings) {
  7058. jsonSchemaService.clearExternalSchemas();
  7059. if (settings.schemas) {
  7060. settings.schemas.forEach(function(settings2) {
  7061. jsonSchemaService.registerExternalSchema(settings2.uri, settings2.fileMatch, settings2.schema);
  7062. });
  7063. }
  7064. jsonValidation.configure(settings);
  7065. },
  7066. resetSchema: function(uri) {
  7067. return jsonSchemaService.onResourceChange(uri);
  7068. },
  7069. doValidation: jsonValidation.doValidation.bind(jsonValidation),
  7070. parseJSONDocument: function(document) {
  7071. return parse3(document, { collectComments: true });
  7072. },
  7073. newJSONDocument: function(root, diagnostics) {
  7074. return newJSONDocument(root, diagnostics);
  7075. },
  7076. getMatchingSchemas: jsonSchemaService.getMatchingSchemas.bind(jsonSchemaService),
  7077. doResolve: jsonCompletion.doResolve.bind(jsonCompletion),
  7078. doComplete: jsonCompletion.doComplete.bind(jsonCompletion),
  7079. findDocumentSymbols: jsonDocumentSymbols.findDocumentSymbols.bind(jsonDocumentSymbols),
  7080. findDocumentSymbols2: jsonDocumentSymbols.findDocumentSymbols2.bind(jsonDocumentSymbols),
  7081. findDocumentColors: jsonDocumentSymbols.findDocumentColors.bind(jsonDocumentSymbols),
  7082. getColorPresentations: jsonDocumentSymbols.getColorPresentations.bind(jsonDocumentSymbols),
  7083. doHover: jsonHover.doHover.bind(jsonHover),
  7084. getFoldingRanges,
  7085. getSelectionRanges,
  7086. findDefinition: function() {
  7087. return Promise.resolve([]);
  7088. },
  7089. findLinks,
  7090. format: function(d, r, o) {
  7091. var range = void 0;
  7092. if (r) {
  7093. var offset = d.offsetAt(r.start);
  7094. var length = d.offsetAt(r.end) - offset;
  7095. range = { offset, length };
  7096. }
  7097. var options = { tabSize: o ? o.tabSize : 4, insertSpaces: (o === null || o === void 0 ? void 0 : o.insertSpaces) === true, insertFinalNewline: (o === null || o === void 0 ? void 0 : o.insertFinalNewline) === true, eol: "\n" };
  7098. return format2(d.getText(), range, options).map(function(e) {
  7099. return TextEdit.replace(Range.create(d.positionAt(e.offset), d.positionAt(e.offset + e.length)), e.content);
  7100. });
  7101. }
  7102. };
  7103. }
  7104. // src/json/jsonWorker.ts
  7105. var defaultSchemaRequestService;
  7106. if (typeof fetch !== "undefined") {
  7107. defaultSchemaRequestService = function(url) {
  7108. return fetch(url).then((response) => response.text());
  7109. };
  7110. }
  7111. var JSONWorker = class {
  7112. constructor(ctx, createData) {
  7113. this._ctx = ctx;
  7114. this._languageSettings = createData.languageSettings;
  7115. this._languageId = createData.languageId;
  7116. this._languageService = getLanguageService({
  7117. workspaceContext: {
  7118. resolveRelativePath: (relativePath, resource) => {
  7119. const base = resource.substr(0, resource.lastIndexOf("/") + 1);
  7120. return resolvePath(base, relativePath);
  7121. }
  7122. },
  7123. schemaRequestService: createData.enableSchemaRequest ? defaultSchemaRequestService : void 0
  7124. });
  7125. this._languageService.configure(this._languageSettings);
  7126. }
  7127. async doValidation(uri) {
  7128. let document = this._getTextDocument(uri);
  7129. if (document) {
  7130. let jsonDocument = this._languageService.parseJSONDocument(document);
  7131. return this._languageService.doValidation(document, jsonDocument, this._languageSettings);
  7132. }
  7133. return Promise.resolve([]);
  7134. }
  7135. async doComplete(uri, position) {
  7136. let document = this._getTextDocument(uri);
  7137. if (!document) {
  7138. return null;
  7139. }
  7140. let jsonDocument = this._languageService.parseJSONDocument(document);
  7141. return this._languageService.doComplete(document, position, jsonDocument);
  7142. }
  7143. async doResolve(item) {
  7144. return this._languageService.doResolve(item);
  7145. }
  7146. async doHover(uri, position) {
  7147. let document = this._getTextDocument(uri);
  7148. if (!document) {
  7149. return null;
  7150. }
  7151. let jsonDocument = this._languageService.parseJSONDocument(document);
  7152. return this._languageService.doHover(document, position, jsonDocument);
  7153. }
  7154. async format(uri, range, options) {
  7155. let document = this._getTextDocument(uri);
  7156. if (!document) {
  7157. return [];
  7158. }
  7159. let textEdits = this._languageService.format(document, range, options);
  7160. return Promise.resolve(textEdits);
  7161. }
  7162. async resetSchema(uri) {
  7163. return Promise.resolve(this._languageService.resetSchema(uri));
  7164. }
  7165. async findDocumentSymbols(uri) {
  7166. let document = this._getTextDocument(uri);
  7167. if (!document) {
  7168. return [];
  7169. }
  7170. let jsonDocument = this._languageService.parseJSONDocument(document);
  7171. let symbols = this._languageService.findDocumentSymbols(document, jsonDocument);
  7172. return Promise.resolve(symbols);
  7173. }
  7174. async findDocumentColors(uri) {
  7175. let document = this._getTextDocument(uri);
  7176. if (!document) {
  7177. return [];
  7178. }
  7179. let jsonDocument = this._languageService.parseJSONDocument(document);
  7180. let colorSymbols = this._languageService.findDocumentColors(document, jsonDocument);
  7181. return Promise.resolve(colorSymbols);
  7182. }
  7183. async getColorPresentations(uri, color, range) {
  7184. let document = this._getTextDocument(uri);
  7185. if (!document) {
  7186. return [];
  7187. }
  7188. let jsonDocument = this._languageService.parseJSONDocument(document);
  7189. let colorPresentations = this._languageService.getColorPresentations(document, jsonDocument, color, range);
  7190. return Promise.resolve(colorPresentations);
  7191. }
  7192. async getFoldingRanges(uri, context) {
  7193. let document = this._getTextDocument(uri);
  7194. if (!document) {
  7195. return [];
  7196. }
  7197. let ranges = this._languageService.getFoldingRanges(document, context);
  7198. return Promise.resolve(ranges);
  7199. }
  7200. async getSelectionRanges(uri, positions) {
  7201. let document = this._getTextDocument(uri);
  7202. if (!document) {
  7203. return [];
  7204. }
  7205. let jsonDocument = this._languageService.parseJSONDocument(document);
  7206. let ranges = this._languageService.getSelectionRanges(document, positions, jsonDocument);
  7207. return Promise.resolve(ranges);
  7208. }
  7209. _getTextDocument(uri) {
  7210. let models = this._ctx.getMirrorModels();
  7211. for (let model of models) {
  7212. if (model.uri.toString() === uri) {
  7213. return TextDocument2.create(uri, this._languageId, model.version, model.getValue());
  7214. }
  7215. }
  7216. return null;
  7217. }
  7218. };
  7219. var Slash = "/".charCodeAt(0);
  7220. var Dot = ".".charCodeAt(0);
  7221. function isAbsolutePath(path) {
  7222. return path.charCodeAt(0) === Slash;
  7223. }
  7224. function resolvePath(uriString, path) {
  7225. if (isAbsolutePath(path)) {
  7226. const uri = URI.parse(uriString);
  7227. const parts = path.split("/");
  7228. return uri.with({ path: normalizePath(parts) }).toString();
  7229. }
  7230. return joinPath(uriString, path);
  7231. }
  7232. function normalizePath(parts) {
  7233. const newParts = [];
  7234. for (const part of parts) {
  7235. if (part.length === 0 || part.length === 1 && part.charCodeAt(0) === Dot) {
  7236. } else if (part.length === 2 && part.charCodeAt(0) === Dot && part.charCodeAt(1) === Dot) {
  7237. newParts.pop();
  7238. } else {
  7239. newParts.push(part);
  7240. }
  7241. }
  7242. if (parts.length > 1 && parts[parts.length - 1].length === 0) {
  7243. newParts.push("");
  7244. }
  7245. let res = newParts.join("/");
  7246. if (parts[0].length === 0) {
  7247. res = "/" + res;
  7248. }
  7249. return res;
  7250. }
  7251. function joinPath(uriString, ...paths) {
  7252. const uri = URI.parse(uriString);
  7253. const parts = uri.path.split("/");
  7254. for (let path of paths) {
  7255. parts.push(...path.split("/"));
  7256. }
  7257. return uri.with({ path: normalizePath(parts) }).toString();
  7258. }
  7259. function create(ctx, createData) {
  7260. return new JSONWorker(ctx, createData);
  7261. }
  7262. return jsonWorker_exports;
  7263. })();
  7264. return moduleExports;
  7265. });