[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/kotlin-mode 70de2560a6 09/10: Support closed range operato
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/kotlin-mode 70de2560a6 09/10: Support closed range operator |
Date: |
Tue, 17 Jan 2023 15:08:09 -0500 (EST) |
branch: elpa/kotlin-mode
commit 70de2560a6e201b02aa4fc65c520c805db14c950
Author: taku0 <mxxouy6x3m_github@tatapa.org>
Commit: taku0 <mxxouy6x3m_github@tatapa.org>
Support closed range operator
---
kotlin-mode-lexer.el | 68 ++++++++++++++++++++++++++--------------------------
test/pathological.kt | 22 ++++++++++-------
2 files changed, 48 insertions(+), 42 deletions(-)
diff --git a/kotlin-mode-lexer.el b/kotlin-mode-lexer.el
index 8e99415247..c19e999bc4 100644
--- a/kotlin-mode-lexer.el
+++ b/kotlin-mode-lexer.el
@@ -685,7 +685,7 @@ expression as a token with one of the following types:
(kotlin-mode--token-text previous-token)
'("(" "{" "[" "*" "%" "/" "+" "-" "&&" "||" ":" "&"
"=" "+=" "-=" "*=" "/=" "%="
- "->" "." ".." "::" "?:" "?." "<=" ">=" "!=" "!==" "==" "==="
+ "->" "." ".." "..<" "::" "?:" "?." "<=" ">=" "!=" "!==" "==" "==="
"as" "as?" "is" "!is" "in" "!in" "," ";" "{" "[" "("
;; "class" will be handled later.
"package" "import" "interface" "fun" "object"
@@ -791,7 +791,7 @@ expression as a token with one of the following types:
(member
(kotlin-mode--token-text next-token)
'("*" "%" "/" "&" "&&" "||" ":" "=" "+=" "-=" "*=" "/=" "%="
- "->" "." ".." "::" "?:" "?." "?" "<" ">" "<=" ">="
+ "->" "." ".." "..<" "::" "?:" "?." "?" "<" ">" "<=" ">="
"!=" "!==" "==" "==="
"," ";" ")" "]" "}"
"as" "as?" "get" "set" "by" "where" "else" "catch" "finally"
@@ -1487,7 +1487,7 @@ It is a type parameter list if:
"is" "!is" "!in" "as" "as?"
"!"
"=" "+=" "-=" "*=" "/=" "%="
- ".." "::" "?:" "?." "<=" ">=" "==" "==="
+ ".." "..<" "::" "?:" "?." "<=" ">=" "==" "==="
"package" "import" "class" "interface" "fun" "object" "val" "var"
"typealias" "constructor" "by" "companion" "init" "if" "else" "when"
"try" "catch" "finally" "for" "do" "while" "throw"
@@ -1825,9 +1825,9 @@ This function does not return `implicit-;'."
"!==" "!="
(seq "!is" word-end) (seq "!in" word-end) "as?"
"!"
- "=" "+=" "-=" "*=" "/=" "%="
"->"
- ".." "." "?:" "?." "?" "<" ">" "<=" ">=" "==" "==="
+ "..<" ".." "." "?:" "?." "?" "<" ">" "<=" ">=" "===" "=="
+ "=" "+=" "-=" "*=" "/=" "%="
"*" "%" "/" "+" "-" "&")))
(let ((text (match-string-no-properties 0))
(start (match-beginning 0))
@@ -2151,6 +2151,35 @@ This function does not return `implicit-;'"
:start (point)
:end (1+ (point))))
+ ;; Operator (3 letters)
+ ((member (buffer-substring-no-properties
+ (max (point-min) (- (point) 3))
+ (point))
+ '("===" "!==" "!is" "!in" "..<"))
+ (backward-char 3)
+ (make-instance 'kotlin-mode--token
+ :type 'operator
+ :text (buffer-substring-no-properties (point) (+ 3 (point)))
+ :start (point)
+ :end (+ 3 (point))))
+
+ ;; Operator (2 letters, other than as, in, or is)
+ ((member (buffer-substring-no-properties
+ (max (point-min) (- (point) 2))
+ (point))
+ '("++" "--"
+ "&&" "||"
+ "+=" "-=" "*=" "/=" "%="
+ ".." "?."
+ "<=" ">=" "!=" "=="
+ "->"))
+ (backward-char 2)
+ (make-instance 'kotlin-mode--token
+ :type 'operator
+ :text (buffer-substring-no-properties (point) (+ 2 (point)))
+ :start (point)
+ :end (+ 2 (point))))
+
;; Open angle bracket for type parameters
;;
;; We use a heuristic: spaces are inserted around inequality sign,
@@ -2185,35 +2214,6 @@ This function does not return `implicit-;'"
:start (point)
:end (1+ (point))))
- ;; Operator (3 letters)
- ((member (buffer-substring-no-properties
- (max (point-min) (- (point) 3))
- (point))
- '("===" "!==" "!is" "!in"))
- (backward-char 3)
- (make-instance 'kotlin-mode--token
- :type 'operator
- :text (buffer-substring-no-properties (point) (+ 3 (point)))
- :start (point)
- :end (+ 3 (point))))
-
- ;; Operator (2 letters, other than as, in, or is)
- ((member (buffer-substring-no-properties
- (max (point-min) (- (point) 2))
- (point))
- '("++" "--"
- "&&" "||"
- "+=" "-=" "*=" "/=" "%="
- ".." "?."
- "<=" ">=" "!=" "=="
- "->"))
- (backward-char 2)
- (make-instance 'kotlin-mode--token
- :type 'operator
- :text (buffer-substring-no-properties (point) (+ 2 (point)))
- :start (point)
- :end (+ 2 (point))))
-
;; ? or as?
((eq (char-before) ??)
(let ((pos-before-comment (point)))
diff --git a/test/pathological.kt b/test/pathological.kt
index b17d82a297..2c2624ad86 100644
--- a/test/pathological.kt
+++ b/test/pathological.kt
@@ -667,18 +667,20 @@ fun foo() {
val x =
a shl // Line breaks are allowed after infix function.
b // KNOWN_BUG
+ val y = 1 // KNOWN_BUG
- var shl = 1 // KNOWN_BUG
- val x = shl shl shl
- shl < 100 && foo() // this is not a continuation of the previous line.
+ var shl = 1
+ val x = shl shl shl
+ shl < 100 && foo() // this is not a continuation of the previous line.
- var shl = 1
- val x = shl shl
- shl < 100 && foo() // this is a continuation of the previous line. //
KNOWN_BUG
+ var shl = 1
+ val x = shl shl
+ shl < 100 && foo() // this is a continuation of the previous line. //
KNOWN_BUG
+ val y = 1 // KNOWN_BUG
- // This is not a infix function call; line breaks are // KNOWN_BUG
+ // This is not a infix function call; line breaks are
// prohibited before infix function.
- val x = // KNOWN_BUG
+ val x =
a
f (b) // So this line should not indented.
@@ -686,6 +688,10 @@ fun foo() {
a .. // Line breaks are prohibited before range operator.
b
+ val x =
+ a ..< // Line breaks are prohibited before closed range operator.
+ b
+
val x =
a + // Line breaks are prohibited before additive operators.
b -
- [nongnu] elpa/kotlin-mode updated (ff4637c4ea -> 3a84689d0b), ELPA Syncer, 2023/01/17
- [nongnu] elpa/kotlin-mode e8969a6214 02/10: Move lexical level routines to kotlin-mode-lexer.el, ELPA Syncer, 2023/01/17
- [nongnu] elpa/kotlin-mode 0a41f8b7fd 03/10: Fix ckeckdoc errors, ELPA Syncer, 2023/01/17
- [nongnu] elpa/kotlin-mode 115a7dd7e3 04/10: Rewrite indentation logic, ELPA Syncer, 2023/01/17
- [nongnu] elpa/kotlin-mode 23a693d264 05/10: Add documentation of indentation logic, ELPA Syncer, 2023/01/17
- [nongnu] elpa/kotlin-mode 1854330e27 06/10: Fix for 24.x when template string is incomplete, ELPA Syncer, 2023/01/17
- [nongnu] elpa/kotlin-mode c7d5c67ebc 01/10: Improve detection of line continuation, ELPA Syncer, 2023/01/17
- [nongnu] elpa/kotlin-mode 2f64645460 08/10: Support definitely non-nullable type, ELPA Syncer, 2023/01/17
- [nongnu] elpa/kotlin-mode eb2af1723e 07/10: Support value modifier, ELPA Syncer, 2023/01/17
- [nongnu] elpa/kotlin-mode 70de2560a6 09/10: Support closed range operator,
ELPA Syncer <=
- [nongnu] elpa/kotlin-mode 3a84689d0b 10/10: Merge pull request #53 from taku0/rewite-indentation, ELPA Syncer, 2023/01/17