mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-02 06:41:14 +00:00
napi: Fix access to diagnostics
Invoking the diagnostics getter would throw an exception because the JsDiagnostic type has no constructor. There's however no constructor that would allow for the previous laziness, so instead this PR bites the bullet: - When diagnostics are requested, we convert them all in one go into proper JavaScript objects. - The vector returned by line_column is replaced with more idiomatic column and lineNumber properties
This commit is contained in:
parent
4679bb6c38
commit
5d102bc838
2 changed files with 35 additions and 33 deletions
|
@ -196,3 +196,20 @@ test('globalCallbacks ComponentDefinition', (t) => {
|
|||
t.is(callbacks![0], "first-callback");
|
||||
t.is(callbacks![1], "second-callback");
|
||||
})
|
||||
|
||||
test('compiler diagnostics', (t) => {
|
||||
let compiler = new ComponentCompiler;
|
||||
t.is(compiler.buildFromSource(`export component App {
|
||||
garbage
|
||||
}`, "testsource.slint"), null);
|
||||
|
||||
const diags = compiler.diagnostics;
|
||||
t.is(diags.length, 1);
|
||||
t.deepEqual(diags[0], {
|
||||
level: 0,
|
||||
message: 'Parse error',
|
||||
lineNumber: 2,
|
||||
column: 12,
|
||||
sourceFile: 'testsource.slint'
|
||||
});
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue