Merge pull request #352 from susliko/next-line-derives

Fix `derives` clause on a new line
pull/659/head
eugene yokota 2023-09-19 01:12:04 +07:00 committed by GitHub
commit 27a40cf3cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 11 deletions

@ -502,7 +502,9 @@ class A
================================================================================
Class definitions (Scala 3)
================================================================================
final case class C() extends A derives B, C.D
final case class C()
extends A
derives B, C.D
--------------------------------------------------------------------------------
(compilation_unit

@ -42,6 +42,7 @@ module.exports = grammar({
"catch",
"finally",
"extends",
"derives",
"with",
],

@ -5,7 +5,7 @@
SCALA_SCALA_LIBRARY_EXPECTED=100
SCALA_SCALA_COMPILER_EXPECTED=96
DOTTY_COMPILER_EXPECTED=84
SYNTAX_COMPLEXITY_CEILING=1300
SYNTAX_COMPLEXITY_CEILING=1400
if [ ! -d "$SCALA_SCALA_DIR" ]; then
echo "\$SCALA_SCALA_DIR must be set"

27
src/scanner.c vendored

@ -18,6 +18,7 @@ enum TokenType {
CATCH,
FINALLY,
EXTENDS,
DERIVES,
WITH,
};
@ -255,25 +256,33 @@ bool tree_sitter_scala_external_scanner_scan(void *payload, TSLexer *lexer,
}
if (valid_symbols[CATCH]) {
if (lexer->lookahead == 'c') {
return !scan_word(lexer, "catch");
}
if (lexer->lookahead == 'f') {
return !scan_word(lexer, "finally");
if (scan_word(lexer, "catch")) {
return false;
}
return true;
}
if (valid_symbols[FINALLY]) {
return !scan_word(lexer, "finally");
if (scan_word(lexer, "finally")) {
return false;
}
}
if (valid_symbols[EXTENDS]) {
return !scan_word(lexer, "extends");
if (scan_word(lexer, "extends")) {
return false;
}
}
if (valid_symbols[WITH]) {
return !scan_word(lexer, "with");
if (scan_word(lexer, "with")) {
return false;
}
}
if (valid_symbols[DERIVES]) {
if (scan_word(lexer, "derives")) {
return false;
}
}
if (newline_count > 1) {