PluginRegistry class is the single point of coordination for all language analysis plugins. It maps language identifiers and file extensions to AnalyzerPlugin instances, and provides a unified API for analyzing files without callers needing to know which plugin handles a given language.
Built-in extension mapping
The registry ships with a built-in map from file extension to language identifier:| Extension(s) | Language |
|---|---|
.ts, .tsx | typescript |
.js, .jsx | javascript |
.py | python |
.go | go |
.rs | rust |
.rb | ruby |
.java | java |
.kt | kotlin |
.cs | csharp |
.cpp | cpp |
.c | c |
.swift | swift |
.php | php |
["typescript", "javascript"]) in their languages property. The registry links file extensions to plugins through these identifiers.
Class: PluginRegistry
register
Adds a plugin to the registry and maps all of its declared languages to it.The plugin instance to register. Every language in
plugin.languages is mapped to this plugin, overwriting any previous registration for that language.unregister
Removes a plugin by name and rebuilds the internal language map.The
plugin.name of the plugin to remove. If no plugin with that name is registered, the call is a no-op.getPluginForLanguage
Returns the plugin registered for a given language identifier.A language identifier (e.g.
"typescript", "python").null if no plugin is registered for the language.
getPluginForFile
Returns the plugin that handles the given file, based on its extension.Any file path. The extension is extracted, lowercased, and looked up in the built-in extension map.
null when the extension is unknown or no plugin is registered for the mapped language.
analyzeFile
Finds the appropriate plugin forfilePath and delegates to its analyzeFile method.
Path to the file being analyzed. Used only for extension/language resolution.
Full source code of the file as a string.
null if no plugin handles the file type. Otherwise returns a StructuralAnalysis.
resolveImports
Finds the appropriate plugin forfilePath and delegates to its resolveImports method.
Path to the file. Used for extension/language resolution and for resolving relative import paths.
Full source code of the file as a string.
null if no plugin handles the file type. Otherwise returns an array of ImportResolution.