ceylon / ceylon-runtime

DEPRECATED
24 stars 5 forks source link

'ceylon run --run' error when class or method is not found is unhelpful #67

Closed lucaswerkmeister closed 10 years ago

lucaswerkmeister commented 10 years ago

ceylon run --run=run my.module says that it couldn’t find the toplevel method 'run'.

At the very least, the error message should indicate that the name must be fully qualified.

And certainly it must somehow be possible to choose a sensible default package for the function? ceylon run my.module somehow finds an appropriate run function, couldn’t we use that?

quintesse commented 10 years ago

Well given the fact that on IRC I already said that "finding the run" could create ambiguities I don't know what else we could do. javac doesn't do any of this either if you pass it the wrong class name to start.

(Edit:) and the name isn't always fully qualified, you could be running something from the default module or even from a legacy Java module.

We could maybe in the error message say something like: "the name of the function to run should be the fully qualified name of the module and the function itself separated by a double colon"... but for completeness sake we'd have to add "except in the case of the default module where you use only the name of the function itself". I'm not sure, but that sounds pretty unwieldy.

We could go find a list of toplevel methods to run and show the ones with the names that seem to match like we do for the ceylon command (for example, typing ceylon hilp shows "ceylon: 'hlp' is not a ceylon command Did you mean? help"). But I don't know how good that code it at matching "technical names". ( @tombentley ? can that code be repurposed for something like that? )

tombentley commented 10 years ago

It just uses the Levenstein distance between the given string and the valid possibilities. It should be easily generalised.

quintesse commented 10 years ago

In the end trying to find similar classes and methods names would just be too costly for very little gain. So I decided to go for the original idea of telling the user to use fully qualified names, but only when the module specified is not the default module and only when the class/method name does not have a period in it.

So now you'll get something like:

$ ceylon run --run xxx hello
ceylon run: Could not find toplevel method 'xxx'. Class and method names need
to be fully qualified, maybe you meant 'hello::xxx'?
$ ceylon run --run hello::xxx hello
ceylon run: Could not find toplevel method 'hello.xxx'.

Hopefully this will help a bit. Closing.

lucaswerkmeister commented 10 years ago

That seems a lot better, thanks!