diff --git a/blueprintcompiler/formatter.py b/blueprintcompiler/formatter.py index 60d87b4..35da5d2 100644 --- a/blueprintcompiler/formatter.py +++ b/blueprintcompiler/formatter.py @@ -146,10 +146,8 @@ def format(data, tab_size=2, insert_space=True): is_child_type = False elif str_item in CLOSING_TOKENS: - if str_item == "]" and str(last_not_whitespace) != "[": + if str_item == "]" and last_not_whitespace != ",": current_line = current_line[:-1] - if str(last_not_whitespace) != ",": - current_line += "," commit_current_line() current_line = "]" elif str(last_not_whitespace) in OPENING_TOKENS: diff --git a/blueprintcompiler/language/gobject_signal.py b/blueprintcompiler/language/gobject_signal.py index 9c27b97..b052e3c 100644 --- a/blueprintcompiler/language/gobject_signal.py +++ b/blueprintcompiler/language/gobject_signal.py @@ -143,13 +143,12 @@ class Signal(AstNode): @property def document_symbol(self) -> DocumentSymbol: - detail = self.ranges["detail_start", "detail_end"] return DocumentSymbol( self.full_name, SymbolKind.Event, self.range, self.group.tokens["name"].range, - detail.text if detail is not None else None, + self.ranges["detail_start", "detail_end"].text, ) def get_reference(self, idx: int) -> T.Optional[LocationLink]: diff --git a/blueprintcompiler/language/values.py b/blueprintcompiler/language/values.py index 5556d99..6d60724 100644 --- a/blueprintcompiler/language/values.py +++ b/blueprintcompiler/language/values.py @@ -487,14 +487,6 @@ class ArrayValue(AstNode): range=quoted_literal.range, ) ) - elif isinstance(value.child, Translated): - errors.append( - CompileError( - "Arrays can't contain translated strings", - range=value.child.range, - ) - ) - if len(errors) > 0: raise MultipleErrors(errors) diff --git a/blueprintcompiler/lsp.py b/blueprintcompiler/lsp.py index c4076b4..0659154 100644 --- a/blueprintcompiler/lsp.py +++ b/blueprintcompiler/lsp.py @@ -118,7 +118,6 @@ class LanguageServer: self.client_capabilities = {} self.client_supports_completion_choice = False self._open_files: T.Dict[str, OpenFile] = {} - self._exited = False def run(self): # Read tags from gir files. During normal compilation these are @@ -126,7 +125,7 @@ class LanguageServer: xml_reader.PARSE_GIR.add("doc") try: - while not self._exited: + while True: line = "" content_len = -1 while content_len == -1 or (line != "\n" and line != "\r\n"): @@ -222,14 +221,6 @@ class LanguageServer: }, ) - @command("shutdown") - def shutdown(self, id, params): - self._send_response(id, None) - - @command("exit") - def exit(self, id, params): - self._exited = True - @command("textDocument/didOpen") def didOpen(self, id, params): doc = params.get("textDocument") diff --git a/tests/formatting/lists_in.blp b/tests/formatting/lists_in.blp deleted file mode 100644 index 66b37a2..0000000 --- a/tests/formatting/lists_in.blp +++ /dev/null @@ -1,21 +0,0 @@ -using Gtk 4.0; - -Box { - styles [] -} - -Box { - styles ["a"] -} - -Box { - styles ["a",] -} - -Box { - styles ["a", "b"] -} - -Box { - styles ["a", "b",] -} diff --git a/tests/formatting/lists_out.blp b/tests/formatting/lists_out.blp deleted file mode 100644 index 7f1fe4a..0000000 --- a/tests/formatting/lists_out.blp +++ /dev/null @@ -1,31 +0,0 @@ -using Gtk 4.0; - -Box { - styles [] -} - -Box { - styles [ - "a", - ] -} - -Box { - styles [ - "a", - ] -} - -Box { - styles [ - "a", - "b", - ] -} - -Box { - styles [ - "a", - "b", - ] -} diff --git a/tests/formatting/out.blp b/tests/formatting/out.blp index b84c25f..9d9a8b4 100644 --- a/tests/formatting/out.blp +++ b/tests/formatting/out.blp @@ -11,7 +11,7 @@ Overlay { notify::icon-name => $on_icon_name_changed(label) swapped; styles [ - "destructive", + "destructive" ] } diff --git a/tests/sample_errors/incomplete_signal.blp b/tests/sample_errors/incomplete_signal.blp deleted file mode 100644 index 4ec693d..0000000 --- a/tests/sample_errors/incomplete_signal.blp +++ /dev/null @@ -1,5 +0,0 @@ -using Gtk 4.0; - -Label { - notify:: -} diff --git a/tests/sample_errors/incomplete_signal.err b/tests/sample_errors/incomplete_signal.err deleted file mode 100644 index 901ef3b..0000000 --- a/tests/sample_errors/incomplete_signal.err +++ /dev/null @@ -1,2 +0,0 @@ -5,1,0,Expected a signal detail name -4,9,3,Unexpected tokens \ No newline at end of file diff --git a/tests/sample_errors/translated_string_array.blp b/tests/sample_errors/translated_string_array.blp deleted file mode 100644 index 451d900..0000000 --- a/tests/sample_errors/translated_string_array.blp +++ /dev/null @@ -1,7 +0,0 @@ -using Gtk 4.0; - -StringList { - strings: [ - _("Test") - ]; -} diff --git a/tests/sample_errors/translated_string_array.err b/tests/sample_errors/translated_string_array.err deleted file mode 100644 index 0beb7e5..0000000 --- a/tests/sample_errors/translated_string_array.err +++ /dev/null @@ -1 +0,0 @@ -5,5,9,Arrays can't contain translated strings \ No newline at end of file diff --git a/tests/samples/string_array.blp b/tests/samples/string_array.blp index 85a68fe..2542d17 100644 --- a/tests/samples/string_array.blp +++ b/tests/samples/string_array.blp @@ -5,6 +5,6 @@ AboutDialog about { authors: [ "Jane doe ", - "Jhonny D ", + "Jhonny D " ]; } diff --git a/tests/samples/style.blp b/tests/samples/style.blp index 63720de..fe20f52 100644 --- a/tests/samples/style.blp +++ b/tests/samples/style.blp @@ -3,6 +3,6 @@ using Gtk 4.0; Label { styles [ "class-1", - "class-2", + "class-2" ] } diff --git a/tests/test_formatter.py b/tests/test_formatter.py index a2cb60f..af4f9f5 100644 --- a/tests/test_formatter.py +++ b/tests/test_formatter.py @@ -47,4 +47,3 @@ class TestFormatter(unittest.TestCase): self.assert_format_test("correct1.blp", "correct1.blp") self.assert_format_test("string_in.blp", "string_out.blp") self.assert_format_test("comment_in.blp", "comment_out.blp") - self.assert_format_test("lists_in.blp", "lists_out.blp")