Orphan symbol ?
It seems that some symbols are orphans. Example : a block inside block, which is inside another block, ... The block exists (in current example, between lines 11 & 15), but this symbol doesn't have parent node. This is a problem for dev tools like Gvls, because without parents, we can't go upstream inside symbol tree, and so, and therefore no symbols as result
Toto.vala
static void titi (int nombre, SourceFunc delegue) {
string var_a = "toto";
double var_b = 33.3363;
}
static void toto() {
var nombre = 25.36536;
titi (33, () => {
var chaine = "toto";
return false;
});
}
static void main() {}
main.vala
public static void main (string[] args) {
var context = new Vala.CodeContext();
context.set_target_profile (Vala.Profile.GOBJECT);
context.add_external_package ("gio-2.0");
var path = Vala.CodeContext.realpath ("Toto.vala");
context.add_source_filename (path);
var parser = new Vala.Parser();
Vala.CodeContext.push (context);
parser.parse (context);
foreach (var sf in context.get_source_files()) {
print ("%s\n", sf.filename);
if (sf.filename == path) {
var locator = new BlockLocator();
var block = locator.locate (sf, 13, 1);
if (block != null) {
print ("parent node : %s\n", (block.parent_node == null).to_string());
print ("parent symbol : %s\n", (block.parent_symbol == null).to_string());
/*
parent node : true
parent symbol : true
*/
}
}
}
}
For the test, I use locator from Anjuta project https://gitlab.gnome.org/GNOME/anjuta/-/blob/master/plugins/language-support-vala/locator.vala
Edited by Yannick Inizan