Fix braceless functions #62
Conversation
| - include: '#macro-reification' | ||
| - include: '#method-name' | ||
| - include: '#method-name-post' | ||
| - include: '#method-block' |
There was a problem hiding this comment.
#method-block is no longer referenced anywhere. somehow restoring this line doesn't change output.
it doesn't feel right that #method-block seems to no longer be needed
There was a problem hiding this comment.
Is there much sense for syntax highlighter to separate method blocks from other blocks? As example dart has very flat scope system. TS has very descriptive, but regex logic for it is kinda insane.
Although this change can be too radical, so maybe there is better and less breaking fix for current problem, I'm just not good enough at this format to find it.
There was a problem hiding this comment.
currently it adds meta.method.block.hx to the list of scope names. searching all of github, I could find mostly Haxe repos having that name. I didn't find any themes (unless I missed them). so there might not be any themes out there that would have different colors for "method blocks" as opposed to "regular blocks".
so we might get away with dropping #method-block without messing up anyone's colors.
There was a problem hiding this comment.
Do you think we can merge this?
There was a problem hiding this comment.
the diffs remove a lot of meta.method.hx from baselines and that doesn't seem correct, because usually scopes are added going deeper. meaning everything carries all their outer scopes plus their new / specific ones.
I've looked at e.g. typescript baseline files and they have meta.function.ts for everything from function signature to all things inside it's body. just like what we had with meta.method.hx.
so I'm not sure if it's a good idea to remove those.
There was a problem hiding this comment.
The problem is that TS requires brackets for anon functions, but in Haxe we cannot detect end of meta.method.hx group to close it.
function f() {
final v = function() foo();
}
123; // stays in unclosed meta.method.hx
abstract Callback<T>(CallbackData<T>) from CallbackData<T> {} // same
// or this case:
class Hello {
function main(args: String)
println("Hello, world")
function main2(args: String) // still in prev meta.method.hx
println("Hello, world")
}I found that Scala has such braceless functions, and it has flat structure too.
object Hello {
def main(args: Array[String]) =
println("Hello, world") // just source.scala scope
def main2(args: Array[String]) =
println("Hello, world") // so no problem
}Tested if i can find some matching workaround again, but still don't see other solutions that drop method scope here.
This makes tree more flat, there is no more
methodscope and method return typehint is handled in global, since there is no a good way to catchfunction():Hint body, i think. Needs some testing.Closes #60
Closes #46
Closes #19
Closes #3