Skip to content

Commit

Permalink
fix: bug in diagnostics for objects with no identifier (#572)
Browse files Browse the repository at this point in the history
Fix bug in diagnostics for objects with no identifier
  • Loading branch information
vetlek authored May 23, 2024
1 parent 6d78b0c commit 76e9b5f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions server/src/language-service/diagnosticsProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,9 @@ function validateDuplicateIdentifiers(
refProvider: SepticReferenceProvider,
doc: ITextDocument
): Diagnostic[] {
if (!obj.identifier) {
return [];
}
let validationFunction: RefValidationFunction;
if (obj.isXvr()) {
validationFunction = hasDuplicateReferenceXvr;
Expand All @@ -834,6 +837,7 @@ function validateDuplicateIdentifiers(
} else {
return [];
}

let validRef = refProvider.validateRef(
obj.identifier!.name,
validationFunction
Expand Down
20 changes: 20 additions & 0 deletions server/src/test/diagnostics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,26 @@ describe("Test validation of object references", () => {
);
expect(diagFilterd.length).to.equal(0);
});
it("Expect no diagnostics for sopcxvr without identifier", () => {
const text = `
SopcEvr:
Evr: TestEvr
`;
const doc = new MockDocument(text);
const cnfg = parseSepticSync(doc.getText());
const objectInfo = metaInfoProvider.getObject("MvrList");
let diag = validateObjectReferences(
cnfg.objects[0],
doc,
cnfg,
objectInfo!
);
let diagFilterd = diag.filter(
(d) => d.code === DiagnosticCode.duplicate
);
expect(diagFilterd.length).to.equal(0);
});
});

describe("Test validation of object structure", () => {
Expand Down

0 comments on commit 76e9b5f

Please sign in to comment.