@@ -12,7 +12,7 @@ import { TextDocument } from 'vscode-languageserver-textdocument'
1212import type { ConfigGenerator } from '../Config.js'
1313import siteConfig from '../Config.js'
1414import { computeIfAbsent , genPath } from '../Utils.js'
15- import type { VersionMeta } from './DataFetcher.js'
15+ import type { VanillaMcdocSymbols , VersionMeta } from './DataFetcher.js'
1616import { fetchBlockStates , fetchRegistries , fetchVanillaMcdoc , fetchVersions , getVersionChecksum } from './DataFetcher.js'
1717import { IndexedDbFileSystem } from './FileSystem.js'
1818import type { VersionId } from './Versions.js'
@@ -302,7 +302,7 @@ export class SpyglassService {
302302 defaultConfig : core . ConfigService . merge ( core . VanillaConfig , {
303303 env : {
304304 gameVersion : version . dynamic ? version . id : version . ref ,
305- dependencies : [ '@vanilla-mcdoc' , '@ misode-mcdoc'] ,
305+ dependencies : [ '@misode-mcdoc' ] ,
306306 customResources : {
307307 text_component : {
308308 category : 'text_component' ,
@@ -366,11 +366,10 @@ async function compressBall(files: [string, string][]): Promise<Uint8Array> {
366366const initialize : core . ProjectInitializer = async ( ctx ) => {
367367 const { config, logger, meta, externals, cacheRoot } = ctx
368368
369- meta . registerDependencyProvider ( '@vanilla-mcdoc' , async ( ) => {
370- const uri : string = new core . Uri ( 'downloads/vanilla-mcdoc.tar.gz' , cacheRoot ) . toString ( )
371- const buffer = await fetchVanillaMcdoc ( )
372- await core . fileUtil . writeFile ( externals , uri , new Uint8Array ( buffer ) )
373- return { info : { startDepth : 1 } , uri }
369+ const vanillaMcdoc = await fetchVanillaMcdoc ( )
370+ meta . registerSymbolRegistrar ( 'vanilla-mcdoc' , {
371+ checksum : vanillaMcdoc . ref ,
372+ registrar : vanillaMcdocRegistrar ( vanillaMcdoc ) ,
374373 } )
375374
376375 meta . registerDependencyProvider ( '@misode-mcdoc' , async ( ) => {
@@ -476,3 +475,31 @@ function registerAttributes(meta: core.MetaRegistry, release: ReleaseVersion, ve
476475 } ,
477476 } )
478477}
478+
479+ const VanillaMcdocUri = 'mcdoc://vanilla-mcdoc/symbols.json'
480+
481+ function vanillaMcdocRegistrar ( vanillaMcdoc : VanillaMcdocSymbols ) : core . SymbolRegistrar {
482+ return ( symbols ) => {
483+ const start = performance . now ( )
484+ for ( const [ id , typeDef ] of Object . entries ( vanillaMcdoc . mcdoc ) ) {
485+ symbols . query ( VanillaMcdocUri , 'mcdoc' , id ) . enter ( {
486+ data : { data : { typeDef } } ,
487+ usage : { type : 'declaration' } ,
488+ } )
489+ }
490+ for ( const [ dispatcher , ids ] of Object . entries ( vanillaMcdoc [ 'mcdoc/dispatcher' ] ) ) {
491+ symbols . query ( VanillaMcdocUri , 'mcdoc/dispatcher' , dispatcher )
492+ . enter ( { usage : { type : 'declaration' } } )
493+ . onEach ( Object . entries ( ids ) , ( [ id , typeDef ] , query ) => {
494+ query . member ( id , ( memberQuery ) => {
495+ memberQuery . enter ( {
496+ data : { data : { typeDef } } ,
497+ usage : { type : 'declaration' } ,
498+ } )
499+ } )
500+ } )
501+ }
502+ const duration = performance . now ( ) - start
503+ console . log ( `[vanillaMcdocRegistrar] Done in ${ duration } ms` )
504+ }
505+ }
0 commit comments