@@ -22,6 +22,10 @@ function freeze_attrs(graph::SyntaxGraph)
2222 SyntaxGraph (graph. edge_ranges, graph. edges, frozen_attrs)
2323end
2424
25+ function unfreeze_attrs (graph:: SyntaxGraph )
26+ SyntaxGraph (graph. edge_ranges, graph. edges, Dict (pairs (graph. attributes)... ))
27+ end
28+
2529function _show_attrs (io, attributes:: Dict )
2630 show (io, MIME (" text/plain" ), attributes)
2731end
@@ -33,6 +37,10 @@ function attrnames(graph::SyntaxGraph)
3337 keys (graph. attributes)
3438end
3539
40+ function attrtypes (graph:: SyntaxGraph )
41+ [(k, typeof (v). parameters[2 ]) for (k, v) in pairs (graph. attributes)]
42+ end
43+
3644function Base. show (io:: IO , :: MIME"text/plain" , graph:: SyntaxGraph )
3745 print (io, typeof (graph),
3846 " with $(length (graph. edge_ranges)) vertices, $(length (graph. edges)) edges, and attributes:\n " )
@@ -54,7 +62,7 @@ function ensure_attributes!(graph::SyntaxGraph{<:Dict}; kws...)
5462end
5563
5664function ensure_attributes (graph:: SyntaxGraph ; kws... )
57- g = SyntaxGraph (graph. edge_ranges, graph . edges, Dict ( pairs (graph . attributes) ... ) )
65+ g = unfreeze_attrs (graph)
5866 ensure_attributes! (g; kws... )
5967 freeze_attrs (g)
6068end
0 commit comments