diff --git a/extension/server/src/providers/linter/index.ts b/extension/server/src/providers/linter/index.ts index 415d7547..288a47b6 100644 --- a/extension/server/src/providers/linter/index.ts +++ b/extension/server/src/providers/linter/index.ts @@ -314,8 +314,7 @@ export function getActions(document: TextDocument, errors: IssueRange[]) { case `SpecificCasing`: case `IncorrectVariableCase`: - case `DirectiveCasing`: - case `UppercaseDirectives`: + case `DirectiveCase`: if (error.newValue) { action = CodeAction.create(`Correct casing to '${error.newValue}'`, CodeActionKind.QuickFix); action.edit = { diff --git a/language/linter.ts b/language/linter.ts index 8494902b..d5cf6933 100644 --- a/language/linter.ts +++ b/language/linter.ts @@ -26,8 +26,7 @@ const errorText = { 'StringLiteralDupe': `Same string literal used more than once. Consider using a constant instead.`, 'RequireBlankSpecial': `\`*BLANK\` should be used over empty string literals.`, 'CopybookDirective': `Directive does not match requirement.`, - 'DirectiveCasing': `Does not match required case.`, - 'UppercaseDirectives': `Directives must be in uppercase. UppercaseDirectives option is deprecated, consider using DirectiveCasing.`, + 'DirectiveCase': `Does not match required case.`, 'NoSQLJoins': `SQL joins are not allowed. Consider creating a view instead.`, 'NoGlobalsInProcedures': `Global variables should not be referenced in procedures.`, 'NoCTDATA': `\`CTDATA\` is not allowed.`, @@ -285,7 +284,7 @@ export default class Linter { if (rules.CopybookDirective) { let correctDirective = `/${rules.CopybookDirective.toUpperCase()}`; let correctValue = value.toUpperCase(); - if (rules.DirectiveCasing === `lower`) { + if (rules.DirectiveCase === `lower`) { correctDirective = correctDirective.toLowerCase(); correctValue = value.toLowerCase(); } @@ -300,31 +299,21 @@ export default class Linter { } } - if (rules.DirectiveCasing === `lower`) { + if (rules.DirectiveCase === `lower`) { if (value !== value.toLowerCase()) { errors.push({ offset: { position: statement[0].range.start, end: statement[0].range.end }, - type: `DirectiveCasing`, + type: `DirectiveCase`, newValue: value.toLowerCase() }); } } - if (rules.DirectiveCasing === `upper`) { + if (rules.DirectiveCase === `upper`) { if (value !== value.toUpperCase()) { errors.push({ offset: { position: statement[0].range.start, end: statement[0].range.end }, - type: `DirectiveCasing`, - newValue: value.toUpperCase() - }); - } - } - - if (rules.UppercaseDirectives) { - if (value !== value.toUpperCase()) { - errors.push({ - offset: { position: statement[0].range.start, end: statement[0].range.end }, - type: `UppercaseDirectives`, + type: `DirectiveCase`, newValue: value.toUpperCase() }); } diff --git a/language/parserTypes.ts b/language/parserTypes.ts index 29a69d03..085404d0 100644 --- a/language/parserTypes.ts +++ b/language/parserTypes.ts @@ -41,8 +41,7 @@ export interface Rules { literalMinimum?: number; RequireBlankSpecial?: boolean; CopybookDirective?: "copy"|"include"; - DirectiveCasing?: "lower"|"upper"; - UppercaseDirectives?: boolean; + DirectiveCase?: "lower"|"upper"; NoSQLJoins?: boolean; NoGlobalsInProcedures?: boolean; SpecificCasing?: {operation: string, expected: string}[]; diff --git a/tests/suite/directives.test.ts b/tests/suite/directives.test.ts index c5f92878..cbe36da8 100644 --- a/tests/suite/directives.test.ts +++ b/tests/suite/directives.test.ts @@ -517,53 +517,20 @@ test('uppercase1', async () => { const cache = await parser.getDocs(uri, lines, { withIncludes: true, ignoreCache: true }); const { errors } = Linter.getErrors({ uri, content: lines }, { - DirectiveCasing: `upper` + DirectiveCase: `upper` }, cache); expect(errors.length).toBe(2); expect(errors[0]).toEqual({ offset: { position: 31, end: 36 }, - type: `DirectiveCasing`, + type: `DirectiveCase`, newValue: `/COPY` }); expect(errors[1]).toEqual({ offset: { position: 65, end: 70 }, - type: `DirectiveCasing`, - newValue: `/COPY` - }); -}) - -test('uppercase2', async () => { - const lines = [ - `**FREE`, - `Ctl-Opt DftActGrp(*No);`, - `/copy './tests/rpgle/copy1.rpgle'`, - `/Copy './tests/rpgle/copy2.rpgle'`, - `/COPY './tests/rpgle/copy3.rpgle'`, - `Dcl-S MyCustomerName1 like(CustomerName_t);`, - `MyCustomerName1 = 'John Smith';`, - `dsply MyCustomerName1;`, - `Return;` - ].join(`\n`); - - const cache = await parser.getDocs(uri, lines, { withIncludes: true, ignoreCache: true }); - const { errors } = Linter.getErrors({ uri, content: lines }, { - UppercaseDirectives: true - }, cache); - - expect(errors.length).toBe(2); - - expect(errors[0]).toEqual({ - offset: { position: 31, end: 36 }, - type: `UppercaseDirectives`, - newValue: `/COPY` - }); - - expect(errors[1]).toEqual({ - offset: { position: 65, end: 70 }, - type: `UppercaseDirectives`, + type: `DirectiveCase`, newValue: `/COPY` }); }) @@ -583,20 +550,20 @@ test('lowercase1', async () => { const cache = await parser.getDocs(uri, lines, { withIncludes: true, ignoreCache: true }); const { errors } = Linter.getErrors({ uri, content: lines }, { - DirectiveCasing: `lower` + DirectiveCase: `lower` }, cache); expect(errors.length).toBe(2); expect(errors[0]).toEqual({ offset: { position: 65, end: 70 }, - type: `DirectiveCasing`, + type: `DirectiveCase`, newValue: `/copy` }); expect(errors[1]).toEqual({ offset: { position: 99, end: 104 }, - type: `DirectiveCasing`, + type: `DirectiveCase`, newValue: `/copy` }); }) \ No newline at end of file