Skip to content

Commit 5baa48d

Browse files
author
Ben Iofel
authored
Gir: explicitly add the .gir path (#88)
* Gir: explicitly add the .gir path Sometimes we would add the .vapi instead, relying on libvala's fallback behavior * remove unnecessary line
1 parent 358178e commit 5baa48d

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/girdocumentation.vala

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
class 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

Comments
 (0)