Skip to content
Snippets Groups Projects
Commit 8c959f8a authored by David Sehnal's avatar David Sehnal
Browse files

QueryRuntimeTable.removeSymbol/CustomProp

parent d42c9a6e
No related branches found
No related tags found
No related merge requests found
......@@ -71,8 +71,7 @@ export const RCSBValidationReport = PluginBehavior.create<{ autoAttach: boolean,
}
unregister() {
// TODO
// DefaultQueryRuntimeTable.removeCustomProp(this.provider.descriptor);
DefaultQueryRuntimeTable.removeCustomProp(this.provider.descriptor);
this.ctx.customStructureProperties.unregister(this.provider.descriptor.name);
......
......@@ -51,8 +51,7 @@ export const AccessibleSurfaceArea = PluginBehavior.create<{ autoAttach: boolean
}
unregister() {
// TODO
// DefaultQueryRuntimeTable.removeCustomProp(this.provider.descriptor);
DefaultQueryRuntimeTable.removeCustomProp(this.provider.descriptor);
this.ctx.customStructureProperties.unregister(this.provider.descriptor.name);
this.ctx.representation.structure.themes.colorThemeRegistry.remove(AccessibleSurfaceAreaColorThemeProvider);
......
......@@ -11,9 +11,13 @@ import { MSymbol } from '../../language/symbol';
export class QueryRuntimeTable {
private map = new Map<string, QuerySymbolRuntime>();
removeSymbol(runtime: QuerySymbolRuntime) {
this.map.delete(runtime.symbol.id);
}
addSymbol(runtime: QuerySymbolRuntime) {
if (this.map.has(runtime.symbol.id)) {
throw new Error(`Symbol '${runtime.symbol.id}' already added.`);
console.warn(`Symbol '${runtime.symbol.id}' already added. Call removeSymbol/removeCustomProps re-adding the symbol.`);
}
this.map.set(runtime.symbol.id, runtime);
}
......@@ -26,6 +30,14 @@ export class QueryRuntimeTable {
}
}
removeCustomProp(desc: CustomPropertyDescriptor<any>) {
if (!desc.symbols) return;
for (const k of Object.keys(desc.symbols)) {
this.removeSymbol((desc.symbols as any)[k]);
}
}
getRuntime(id: string) {
return this.map.get(id);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment