muffinmad / anakin-language-server

Yet another Jedi Python language server
GNU General Public License v3.0
37 stars 3 forks source link

`@property` should map to an LSP Property kind (or Field) #15

Closed rwols closed 4 years ago

rwols commented 4 years ago
class Foo:

    @property
    def bar(self):
        return 42

foo = Foo()
foo.b|

This will report bar as a function, but it should be a property (or field).

muffinmad commented 4 years ago

The simple and brittle solution that comes to mind is to look if line before completion candidate definition is @property.

But let's expand Jedi's types range by little if we can! ;)

@davidhalter Can you please tell whether it is possible to make this test pass in Jedi:

def test_completion_property(Script):
    script = Script(dedent('''\
        class Foo:

            @property
            def bar(self):
                return 42

        foo = Foo()
        foo.b
        '''))
    c, = script.complete(9, 5)
    assert c.type == 'property'

Thanks!

davidhalter commented 4 years ago

Going to include that in 0.18.0 probably. But note that this is not going to be perfect and more like a heuristic (which is probably good enough).

davidhalter commented 4 years ago

This will be fixed in 0.18.0. IMO it was never really a bug, but it's definitely nicer this way.

muffinmad commented 4 years ago

@davidhalter Awesome! Thanks!

@rwols You can install latest Jedi's master, anakinls v1.18.1 already supports Jedi's property completion type.