Skip to content

Conversation

@edwood-grant
Copy link

@edwood-grant edwood-grant commented Sep 23, 2025

What does this do/fix

When inheriting from struct as an alias you can use all fo its inherited properties as is, without issues. Currently the VLs doesn't show this.

Added the required piece of code that enables looking for struct_sym.base_struct and add it to the list of code complete data if needed.

Some info on aliases in vala:

https://gnome.pages.gitlab.gnome.org/vala/manual/structs.html
https://docs.vala.dev/tutorials/programming-language/main/02-00-basics/02-04-data-types.html (section 2.4.7. Defining new Type from other)

This if approved, fixes #300.

Test

The code provided on the issue should work OK with this change:

struct Foo {
    public int a;
    public int b;
    public const int FOO_CONST = 10; // Should not be shown

    public static void foo_static_method () { // Should not be shown either
        print ("Hey static foo!\n");
    }

    public void print_foo () {
        print ("Hey foo!\n");
    }
}

struct Bar : foo {
    public int c;
    public const int BAR_CONST = 20;
    
    public static void bar_static_method () {
        print ("Hey static bar!\n");
    }

    public void print_bar () {
        print ("Hey bar !\n");
    }	
}

void main() {
    Bar f;
    f.
    // should show all code-complete items here
    // that is: print_bar, print_foo, a, b, c, BAR_CONST

    Bar.
    // Should show only bar_static_method and BAR_CONST
}

Remarks

Not sure if this is good code though, not very versed on the whole LSP but it seems innocent enough, feel free to point to any issues about it.

Edit: added a commit that also filters const values and static/creation methods from the base, since those are technically not form the derived and cannot be used (either way vala throws and error, so they still shouldn't be shown).

@Prince781 Prince781 self-assigned this Sep 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VLS cant see function of an alias

2 participants