Autocomplete doesn't work properly for classes within modules

Feedback Case Number: 64783.

This bug has been present forever but it’s increasingly driving me nuts.

Autocomplete essentially fails completely to suggest fields on a class in a module if the instance was not declared using its fully qualified class name.

What do I mean? Well, do this:

  1. Create a module (Module1).
  2. Create a class within this module (Class1).
  3. Add a method to Class1 called Echo(s As String) As String.
  4. In App.Open put this code:
Var c1 As New Class1
Var s As String = c1.Echo("Something")

As you type c1. you will not be given any autocomplete options. You should be given the option to autocomplete Echo.

However, if you declare an instance of Class1 using its fully qualified class name, autocomplete works as expected:

Var c2 As New Module1.Class1
Var s As String = c2.Echo("Something")

This is an important bug that should be addressed. Since we can’t rely on the IDE’s autocomplete when using classes in modules unless we use their fully qualified class name to leads to two issues:

  1. Code bloat and extra noise. Why should I have to do this:
Var doc1 As New Mammals.People.Professionals.Doctor
Var doc2 As New Mammals.People.Professionals.Doctor
Var doc3 As New Mammals.People.Professionals.Doctor
Var doc4 As New Mammals.People.Professionals.Doctor
Var b1 As New Mammals.People.Tradesmen

When I could do this?

Using Mammals.People.Professionals
Using Mammals.People.Tradesmen
Var doc1 As New Doctor
Var doc2 As New Doctor
Var doc3 As New Doctor
Var doc4 As New Doctor
Var b1 As New Builder

I’d like to point out that Using is a real keyword in the Xojo language that is terribly broken for reasons also related to autocompletion.

  1. People stop putting classes in modules and instead stuff them in the global namespace with ugly prefixes or suffixes. Doing this means autocomplete will always work but then you end up with ugly class names and it’s increasingly difficult to reuse code and share it as classes are not properly namespaced:
Var doc1 As New MPPDoctor
Var doc2 As New MPPDoctor
Var doc3 As New MPPDoctor
Var doc4 As New MPPDoctor
Var b1 As New MPTBuilder

Can anyone send some love to this case?

Classes within modules are only supported for text format. Whenever I have to update - for instance - Kaju I have the redo all classes because of the namespace use.

To use “using” is a bad idea IMO because it makes the classes implicit. You have the using somewhere and then you forget it.

You shouldn’t do such a deep class hierarchy anyways. “Favour composition over inheritance” if I remember correctly.

That was just an example - I never do that. It’s just to illustrate that autocomplete is broken and should be able to handle this scenario.

Not true. It doesn’t matter whether you save the project in binary, XML or “Xojo Project” format, you cannot include classes in a module if they are externally referenced. You can if they are internal.

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.