Skip to content

Commit

Permalink
Fixed PR issues
Browse files Browse the repository at this point in the history
  • Loading branch information
goetzrrGit committed Oct 22, 2024
1 parent 6064a32 commit 933ea97
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
12 changes: 6 additions & 6 deletions src/utilities/codemirror/custom-folder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ VARIABLE INT "MIN...MAX | ...MAX | MIN..." "VALUE_1, VALUE_2, ..."
const LOCALS = [
`@LOCALS_BEGIN
VARIABLE INT
TEST FLOAT ENUM
TEST FLOAT
@LOCALS_END`,
];

Expand Down Expand Up @@ -363,8 +363,8 @@ describe('foldRequest', () => {

describe('foldVariables', () => {
test('Parameters should return the correct from and to', () => {
PARAMETERS.forEach(parameter => {
const doc = `${parameter}`;
PARAMETERS.forEach((parameter: string) => {
const doc = parameter;
const tree = parser.parse(doc);
const state = EditorState.create({ doc });

Expand All @@ -380,9 +380,9 @@ describe('foldVariables', () => {
}
});
});
test('Parameters should return the correct from and to', () => {
LOCALS.forEach(local => {
const doc = `${local}`;
test('Locals should return the correct from and to', () => {
LOCALS.forEach((local: string) => {
const doc = local;
const tree = parser.parse(doc);
const state = EditorState.create({ doc });

Expand Down
32 changes: 20 additions & 12 deletions src/utilities/sequence-editor/sequence-linter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ function validateVariables(inputParams: SyntaxNode[], text: string, type: 'INPUT
inputParam =>
({
...getFromAndTo([inputParam]),
message: `There is a maximum of ${type} directive per sequence`,
message: `There is a maximum of one ${type} directive per sequence`,
severity: 'error',
}) as const,
),
Expand All @@ -345,32 +345,40 @@ function validateVariables(inputParams: SyntaxNode[], text: string, type: 'INPUT

if (type) {
if (['FLOAT', 'INT', 'STRING', 'UINT', 'ENUM'].includes(type) === false) {
const node = typeNode ?? objectNode ?? parameter;
const { from, to } = node;
diagnostics.push({
from: typeNode?.from ?? objectNode?.from ?? parameter.from,
from,
message: 'Invalid type. Must be FLOAT, INT, STRING, UINT, or ENUM.',
severity: 'error',
to: typeNode?.to ?? objectNode?.to ?? parameter.to,
to,
});
} else if (type.toLocaleLowerCase() === 'enum' && !enumName) {
const node = typeNode ?? objectNode ?? parameter;
const { from, to } = node;
diagnostics.push({
from: typeNode?.from ?? objectNode?.from ?? parameter.from,
from,
message: '"enum_name" is required for ENUM type.',
severity: 'error',
to: typeNode?.to ?? objectNode?.to ?? parameter.to,
to,
});
} else if (type.toLocaleLowerCase() !== 'enum' && enumName) {
const node = enumNode ?? objectNode ?? parameter;
const { from, to } = node;
diagnostics.push({
from: enumNode?.from ?? objectNode?.from ?? parameter.from,
from,
message: '"enum_name" is only required for ENUM type.',
severity: 'error',
to: enumNode?.to ?? objectNode?.to ?? parameter.to,
to,
});
} else if (type.toLocaleLowerCase() === 'string' && range) {
const node = rangeNode ?? objectNode ?? parameter;
const { from, to } = node;
diagnostics.push({
from: rangeNode?.from ?? objectNode?.from ?? parameter.from,
from,
message: '"allowable_ranges" is not required for STRING type',
severity: 'error',
to: rangeNode?.to ?? objectNode?.to ?? parameter.to,
to,
});
}
}
Expand Down Expand Up @@ -401,12 +409,12 @@ function getVariableInfo(
} {
const nameNode = parameter.getChild('Enum');
const typeNode = parameter.getChild('Type');
const enumNode = parameter.getChild('EnumName');
const rangeNode = parameter.getChild('Range');
const valuesNode = parameter.getChild('Values');
const objectNode = parameter.getChild('Object');

if (typeNode) {
const enumNode = parameter.getChild('EnumName');
const rangeNode = parameter.getChild('Range');
const valuesNode = parameter.getChild('Values');
return {
enumName: enumNode ? text.slice(enumNode.from, enumNode.to) : undefined,
name: nameNode ? text.slice(nameNode.from, nameNode.to) : undefined,
Expand Down

0 comments on commit 933ea97

Please sign in to comment.