Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • vala vala
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 771
    • Issues 771
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 76
    • Merge requests 76
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GNOMEGNOME
  • valavala
  • Issues
  • #1062
Closed
Open
Issue created Aug 13, 2020 by Yannick Inizan@BZHDeveloper

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 Aug 13, 2020 by Yannick Inizan
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking