These are chat archives for ceylon/ceylon-ide-eclipse

25th
Apr 2016
Bastien Jansen
@bjansen
Apr 25 2016 08:16
@gavinking I noticed that "terminate statement" will add braces/semicolons/etc even if they are already present in the next lines
void foo() { <call terminate statement here>
}
will generate this:
void foo() { }
}
and the code does basically if (that.mainEndToken != searchedToken || that.stopIndex > endOfCodeInLine) { addSearchedToken() }
is there a reason why we're ignoring things that are not in the current line?
Gavin King
@gavinking
Apr 25 2016 08:37
@bjansen yes, correct. it means “terminate on the current line"
otherwise it can’t know where the statement is supposed to end
Bastien Jansen
@bjansen
Apr 25 2016 08:37
well it doesn't seem right to terminate something that's already terminated
if the parser was able to detect a function body, why should we add an extra }?
“terminate on the current line" != "look for termination on the current line"
Gavin King
@gavinking
Apr 25 2016 08:42
because that might not be what the next { is supposed to be!
it might be the beginning of a comprehension
but because the current statement isn’t terminated yet, it’s been mis-parsed
Bastien Jansen
@bjansen
Apr 25 2016 08:50
hm
I wanted to add new lines when {} is inserted, but then the loop will try to complete the statement again, and I end up with
void foo() { }

}
Gavin King
@gavinking
Apr 25 2016 08:58
that’s contrary to the whole concept of thething
Bastien Jansen
@bjansen
Apr 25 2016 08:59
what's contrary? inserting new lines?
Gavin King
@gavinking
Apr 25 2016 08:59
yes
Bastien Jansen
@bjansen
Apr 25 2016 08:59
why?
Gavin King
@gavinking
Apr 25 2016 08:59
or trying to make it do anything beyond the current line
Bastien Jansen
@bjansen
Apr 25 2016 08:59
you will end up hitting enter anyway
Gavin King
@gavinking
Apr 25 2016 09:00
because the entire concept is: make the current statement end on the current line
add in any punctuation needed to make that happen
and no, you don’t necessarily follow terminate statement by adding a newline
Bastien Jansen
@bjansen
Apr 25 2016 09:01
I don't agree, the concept is "terminate the statement on this line", and IMO it should produce something that requires as less typing as possible
Gavin King
@gavinking
Apr 25 2016 09:01
I almost never want it to add a newline
one of the main things i use it for is when I’m adding code above an existing statement
Bastien Jansen
@bjansen
Apr 25 2016 09:01
when you add braces to a function, you always put things on a new line
Gavin King
@gavinking
Apr 25 2016 09:01
and the current line is being mis-parsed as an annotation
Bastien Jansen
@bjansen
Apr 25 2016 09:01
you don't write
void foo() { print("hello"); }
Gavin King
@gavinking
Apr 25 2016 09:02
what you’re trying to do won’t work
Bastien Jansen
@bjansen
Apr 25 2016 09:02
ok maybe we have different use cases then
I use it as a shortcut, to avoid typing braces and newlines (in IntelliJ)
Gavin King
@gavinking
Apr 25 2016 09:03
i don’t use it for that
the IDE already adds a closing brace when you hit newline after an opening brace
Bastien Jansen
@bjansen
Apr 25 2016 09:03
yeah but I don't type the opening brace
usually I'm in a state like this:
if (myCondition<call terminate statement here>)
Gavin King
@gavinking
Apr 25 2016 09:04
like I said: what you’re trying to do won’t work
Bastien Jansen
@bjansen
Apr 25 2016 09:04
so I skip the closing paren, a space, an opening curly brace and a return
Gavin King
@gavinking
Apr 25 2016 09:04
it’s not what it’s designed for
Bastien Jansen
@bjansen
Apr 25 2016 09:04
well it works pretty good in Java
Gavin King
@gavinking
Apr 25 2016 09:05
you would have to rewrite it from scratch
Bastien Jansen
@bjansen
Apr 25 2016 09:05
so perhaps you didn't design it with the same idea in mind
so the use case above will work, but the body will be on the same line
I improved it to put the caret between the braces, which is already an improvement, since I only have to press enter to be in the state I'd like
Gavin King
@gavinking
Apr 25 2016 09:12
i really don’t want it to start moving the caret around
if I want to position my caret at the end of the line, I have almost no use for this feature
Bastien Jansen
@bjansen
Apr 25 2016 09:12
you already do, when a ; is inserted
Gavin King
@gavinking
Apr 25 2016 09:13
it’s sweet spot is when I want to add a semicolon or a closing brace or whatever without moving the caret
no, that’s not correct
Terminate Statement leaves the caret where it is
at least, it’s supposed to, unless it’s broken...
Bastien Jansen
@bjansen
Apr 25 2016 09:16
I don't see the point of the current behavior then. If you reach a state where a statement is incomplete, it means you were modifying this exact place in the code. If missing braces were inserted, chances are you'll be adding stuff in the body, so you'll have to move your caret anyway. If a semicolon was added, moving the caret after it is somewhat logical, because your statement is complete and you might want to add another one under it.
Gavin King
@gavinking
Apr 25 2016 09:23
well no
what I want to do is get a semi at the end of the line
so that I can keep editing the current line
without the whole rest of the file being parsed incorrectly
Bastien Jansen
@bjansen
Apr 25 2016 09:24
I usually call this action when I'm done editing the line
Gavin King
@gavinking
Apr 25 2016 09:24
that’s not what it’s for
it has very very little value in that context
where it’s really useful is when it saves me from having to move to the end of the line and back again just to add a semicolon
Bastien Jansen
@bjansen
Apr 25 2016 09:25
so it's more a "make the parser happy" action than a "make me write efficiently" action?
Gavin King
@gavinking
Apr 25 2016 09:26
it helps me get rid of all the stupid errors that show up when i have incompletely-written code, yes
however, it does indeed appear to be broken currently
it’s moving the caret to the end of the line
didn’t used to do that
Bastien Jansen
@bjansen
Apr 25 2016 09:27
well that's because I changed it that way
(if you pulled the changes I made this week end)
Gavin King
@gavinking
Apr 25 2016 09:27
would you do me a favor and change it back please?
Bastien Jansen
@bjansen
Apr 25 2016 09:28
can you see how the behavior I am expecting could be useful too?
Gavin King
@gavinking
Apr 25 2016 09:28
well what you want to do can already be done in two keypresses
so why do I need a special thing for that
Bastien Jansen
@bjansen
Apr 25 2016 09:29
what keypresses?
Gavin King
@gavinking
Apr 25 2016 09:29
⌘→;
which is hardly more difficult to type than ⌘;
Bastien Jansen
@bjansen
Apr 25 2016 09:29
it's more than two keypresses when you want to add braces, have the cursor between them, and start a new line
Gavin King
@gavinking
Apr 25 2016 09:30
it is: ⌘→{↩︎
three keypresses, to be precise
Bastien Jansen
@bjansen
Apr 25 2016 09:31
so maybe I can revert to the old behavior in Eclipse, and do the stuff I want in IntelliJ
so everyone's happy
Gavin King
@gavinking
Apr 25 2016 09:32
I suppose you could add a preference setting
Bastien Jansen
@bjansen
Apr 25 2016 09:35
there, should be fixed
Gavin King
@gavinking
Apr 25 2016 09:41
what did you do?
Bastien Jansen
@bjansen
Apr 25 2016 09:41
I removed the part that moves the cursor
Gavin King
@gavinking
Apr 25 2016 09:41
ok
thanks
i’m perfectly happy if you add a preference to adjust that behavior
Bastien Jansen
@bjansen
Apr 25 2016 09:42
ok