11class Vls.GirDocumentation {
22 private Vala . CodeContext context;
3+ private Gee . HashSet<string> added = new Gee .HashSet<string> ();
34
45 private class Sink : Vala .Report {
56 public override void depr (Vala .SourceReference ? sr , string message ) { /* do nothing */ }
@@ -8,6 +9,14 @@ class Vls.GirDocumentation {
89 public override void note (Vala .SourceReference ? sr , string message ) { /* do nothing */ }
910 }
1011
12+ private void add_gir (string package ) {
13+ string ? girpath = context. get_gir_path (package);
14+ if (girpath != null ) {
15+ context. add_source_file (new Vala .SourceFile (context, Vala . SourceFileType . PACKAGE , girpath));
16+ added. add (package);
17+ }
18+ }
19+
1120 /**
1221 * Create a new holder for GIR docs by adding all GIRs found in
1322 * `/usr/share/gir-1.0` and `/usr/local/share/gir-1.0`
@@ -19,11 +28,9 @@ class Vls.GirDocumentation {
1928 context. add_define (" GOBJECT" );
2029
2130 // add packages
22- var added = new Gee .HashSet<string> ();
23- context. add_external_package (" GObject-2.0" );
24- added. add (" GObject-2.0" );
25- context. add_external_package (" GLib-2.0" );
26- added. add (" GLib-2.0" );
31+ add_gir (" GLib-2.0" );
32+ add_gir (" GObject-2.0" );
33+
2734 foreach (string data_dir in Environment . get_system_data_dirs ()) {
2835 File dir = File . new_for_path (Path . build_filename (data_dir, " gir-1.0" ));
2936 if (! dir. query_exists ())
@@ -45,8 +52,7 @@ class Vls.GirDocumentation {
4552 pkg = > pkg. gir_version != null && @" $(pkg.gir_namespace)-$(pkg.gir_version)" == gir_pkg);
4653 if (! added. contains (gir_pkg) && vapi_pkg_match != null ) {
4754 debug (@" adding GIR $gir_pkg for package $(vapi_pkg_match.package_name)" );
48- context. add_external_package (gir_pkg);
49- added. add (gir_pkg);
55+ add_gir (gir_pkg);
5056 }
5157 }
5258 } catch (Error e) {
0 commit comments