* Add ts_rs feature to work with indexmap * Add feature for schemars to work with indexmap * Add module ID to intern module paths * Update code to use new source range with three fields * Update generated files * Update docs * Fix wasm * Fix TS code to use new SourceRange * Fix TS tests to use new SourceRange and moduleId * Fix formatting * Fix to filter errors and source ranges to only show the top-level module * Fix to reuse module IDs * Fix to disallow empty path for import * Revert unneeded Self change * Rename field to be clearer * Fix parser tests * Update snapshots * Change to not serialize module_id of 0 * Update snapshots after adding default module_id * Move module_id functions to separate module * Fix tests for console errors * Proposal: module ID = 0 gets skipped when serializing tokens too (#4422) Just like in AST nodes. Also I think "is_top_level" communicates intention better than is_default --------- Co-authored-by: Adam Chalmers <adam.chalmers@zoo.dev>
56 lines
1.1 KiB
TypeScript
56 lines
1.1 KiB
TypeScript
import { kclErrorsToDiagnostics, KCLError } from './errors'
|
|
|
|
describe('test kclErrToDiagnostic', () => {
|
|
it('converts KCL errors to CodeMirror diagnostics', () => {
|
|
const errors: KCLError[] = [
|
|
{
|
|
name: '',
|
|
message: '',
|
|
kind: 'semantic',
|
|
msg: 'Semantic error',
|
|
sourceRanges: [
|
|
[0, 1, 0],
|
|
[2, 3, 0],
|
|
],
|
|
},
|
|
{
|
|
name: '',
|
|
message: '',
|
|
kind: 'type',
|
|
msg: 'Type error',
|
|
sourceRanges: [
|
|
[4, 5, 0],
|
|
[6, 7, 0],
|
|
],
|
|
},
|
|
]
|
|
const diagnostics = kclErrorsToDiagnostics(errors)
|
|
expect(diagnostics).toEqual([
|
|
{
|
|
from: 0,
|
|
to: 1,
|
|
message: 'Semantic error',
|
|
severity: 'error',
|
|
},
|
|
{
|
|
from: 2,
|
|
to: 3,
|
|
message: 'Semantic error',
|
|
severity: 'error',
|
|
},
|
|
{
|
|
from: 4,
|
|
to: 5,
|
|
message: 'Type error',
|
|
severity: 'error',
|
|
},
|
|
{
|
|
from: 6,
|
|
to: 7,
|
|
message: 'Type error',
|
|
severity: 'error',
|
|
},
|
|
])
|
|
})
|
|
})
|