Commit 8ecfc1f0 authored by Daniel Espinosa Ortiz's avatar Daniel Espinosa Ortiz

server: test add local defined namespace

parent 53b32ce8
......@@ -72,6 +72,11 @@ public class GVls.GServer : GLib.Object, ContainerHashable, Server
source = new Vala.SourceFile (context, Vala.SourceFileType.SOURCE, file.get_path ());
_file = file;
parse_content (source);
if (root_server != null) {
root_server.vapi_dirs.add (file.get_parent ());
} else {
vapi_dirs.add (file.get_parent ());
}
}
public void parse_string (string str) throws GLib.Error {
......
......@@ -197,6 +197,7 @@ public interface GVls.Server : GLib.Object, ContainerHashable
}
GLib.File nsf = null;
if (root_server != null) {
message ("Number of vapidirs: %u", root_server.vapi_dirs.get_n_items ());
nsf = root_server.find_namespace_file (ns);
} else {
nsf = find_namespace_file (ns);
......
......@@ -64,8 +64,8 @@ namespace GVlsEdit {
var prov = view.get_data<GVlsui.CompletionProvider> ("gvls-provider");
if (prov == null) return;
try {
prov.current_server.parse (doc.get_file ().location);
prov.server = _server;
prov.current_server.parse (doc.get_file ().location);
} catch (GLib.Error e) {
message ("Error parsing document: %s", e.message);
}
......
......@@ -30,6 +30,7 @@ public class GVlsui.CompletionProvider : GLib.Object, Gtk.SourceCompletionProvid
_server = value;
try {
_server.add_server (current_server);
assert (current_server.root_server != null);
} catch (GLib.Error e) {
message ("Error setting completion provider's server': %s", e.message);
}
......
......@@ -323,14 +323,10 @@ class Tests {
});
Test.add_func ("/gvls/parse/using/namespace/unversioned",
()=>{
var envp = GLib.Environ.get ();
string SRC_DIR = GLib.Environ.get_variable (envp, "SRC_DIR");
GLib.File file = GLib.File.new_for_path (SRC_DIR+"/namespace.vala");
assert (file.query_exists ());
Server server = new GServer () as Server;
server.add_default_namespaces ();
assert (server.vapi_dirs.get_n_items () == 2);
try {
server.add_default_namespaces ();
assert (server.vapi_dirs.get_n_items () > 1);
server.add_namespace ("Gee");
assert (server.get_symbol ("Gee") != null);
server.add_namespace ("Vala");
......@@ -340,6 +336,27 @@ class Tests {
assert_not_reached ();
}
});
Test.add_func ("/gvls/parse/using/namespace/localdir",
()=>{
var envp = GLib.Environ.get ();
string SRC_DIR = GLib.Environ.get_variable (envp, "SRC_DIR");
GLib.File file1 = GLib.File.new_for_path (SRC_DIR+"/test.vapi");
GLib.File file2 = GLib.File.new_for_path (SRC_DIR+"/parse.vala");
assert (file1.query_exists ());
assert (file2.query_exists ());
Server server = new GServer () as Server;
Server server1 = new GServer () as Server;
try {
server.add_server (server1);
server1.parse (file2);
assert (server.vapi_dirs.get_n_items () == 3);
assert (server.add_namespace ("Test"));
assert (server.get_symbol ("Test") != null);
} catch (GLib.Error e) {
message ("Error: %s", e.message);
assert_not_reached ();
}
});
Test.add_func ("/gvls/parse/documentation",
()=>{
var envp = GLib.Environ.get ();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment