SublimeText / QML

QML support for Sublime Text and Sublime Merge
MIT License
28 stars 4 forks source link

Wrong highlighting for inline JS objects #3

Closed grassator closed 2 years ago

grassator commented 10 years ago

Sample code:

QtObject {
    property var test: { sdf: "sdfs", sdfg: "sdfsd" }
}

Screenshot: screen shot 2014-03-12 at 20 26 14

ratijas commented 2 years ago

This is invalid QML syntax. Object literal in a binding position without (parenthesis) will be parsed as a code block. Thus, sdf becomes a label (for goto), "sdfs", sdfg is an expression with binary comma operator (which evaluates and discards left-hand-side value), and after that is an unparsable mess (colon :).

❯ qml source.qml
QQmlApplicationEngine failed to load component
file:///home/ratijas/tmp/source.qml:2:43: Expected token `,'
qml: Did not load any objects, exiting.

Anyway, proper JavaScript code blocks and expressions are implemented in https://github.com/ratijas/Sublime-QML/commit/89b0fa880a947300b35742377ece69460a9d89a2