diff --git a/.gitignore b/.gitignore index 35a1f5c..2709ddf 100644 --- a/.gitignore +++ b/.gitignore @@ -5,22 +5,21 @@ !*/ # Include specific file patterns -!/.github/workflows/*.yaml -!/.github/workflows/*.yml -!/.gitignore -!/.mocharc.json -!/.vscodeignore -!/README.md !/client/package.json !/client/src/*.ts -!/client/test/spec/**/*.ts !/client/testFixture/*.txt +!/client/test/spec/**/*.ts !/client/tsconfig.json !/esbuild.js !/eslint.config.mjs +!/.github/workflows/*.yaml +!/.github/workflows/*.yml +!/.gitignore !/integ/spec/**/*.ts !/integ/tsconfig.json +!/.mocharc.json !/package.json +!/README.md !/scripts/*.sh !/server/package.json !/server/src/*.ts @@ -30,7 +29,9 @@ !/server/tsconfig.json !/settings.json !/tsconfig.json +!/.vscodeignore # Exclude problematic file patterns /.test-extensions /lfortran +/**/*.bak diff --git a/.vscodeignore b/.vscodeignore index 6455c1a..20b3bb9 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -20,3 +20,4 @@ versions.txt .vscode-test out/integ lfortran +lfortran.bak diff --git a/eslint.config.mjs b/eslint.config.mjs index e64ccc5..a7b856f 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -5,8 +5,19 @@ import tseslint from "typescript-eslint"; /** @type {import('eslint').Linter.Config[]} */ export default [ - {files: ["**/*.{js,mjs,cjs,ts}"]}, - {languageOptions: { globals: globals.browser }}, + { + files: ["**/*.{js,mjs,cjs,ts}"] + }, + { + languageOptions: { + globals: globals.browser + } + }, pluginJs.configs.recommended, ...tseslint.configs.recommended, -]; \ No newline at end of file + { + rules: { + "@typescript-eslint/no-namespace": "off" + } + } +]; diff --git a/server/src/lfortran-accessors.ts b/server/src/lfortran-accessors.ts index 2f9ced4..dfcc7c0 100644 --- a/server/src/lfortran-accessors.ts +++ b/server/src/lfortran-accessors.ts @@ -4,18 +4,16 @@ import { import { Diagnostic, - DiagnosticSeverity, Location, Position, Range, SymbolInformation, - SymbolKind, TextEdit, } from 'vscode-languageserver/node'; import { ExampleSettings, - ErrorDiagnostics + ErrorDiagnostics, } from './lfortran-types'; import which from 'which'; @@ -184,7 +182,7 @@ export class LFortranCLIAccessor implements LFortranAccessor { settings: ExampleSettings): Promise { const flags = ["--show-document-symbols"]; const stdout = await this.runCompiler(settings, flags, text); - let results; + let results: SymbolInformation[]; try { results = JSON.parse(stdout); } catch (error) { @@ -207,8 +205,6 @@ export class LFortranCLIAccessor implements LFortranAccessor { const end: Position = range.end; end.character--; - - symbol.kind = SymbolKind.Function; } return symbols; } @@ -285,8 +281,8 @@ export class LFortranCLIAccessor implements LFortranAccessor { const k = Math.min(results.diagnostics.length, settings.maxNumberOfProblems); for (let i = 0; i < k; i++) { const diagnostic: Diagnostic = results.diagnostics[i]; - diagnostic.severity = DiagnosticSeverity.Warning; diagnostic.source = "lfortran-lsp"; + diagnostic.range.start.character--; diagnostics.push(diagnostic); } } diff --git a/server/test/spec/lfortran-accessors.spec.ts b/server/test/spec/lfortran-accessors.spec.ts index 49ec425..101cd75 100644 --- a/server/test/spec/lfortran-accessors.spec.ts +++ b/server/test/spec/lfortran-accessors.spec.ts @@ -214,7 +214,7 @@ describe("LFortranCLIAccessor", () => { range: { start: { line: 0, - character: 10 + character: 9 }, end: { line: 2, @@ -229,7 +229,7 @@ describe("LFortranCLIAccessor", () => { range: { start: { line: 5, - character: 13 + character: 12 }, end: { line: 5, @@ -244,7 +244,38 @@ describe("LFortranCLIAccessor", () => { ]; const stdout = JSON.stringify({ - diagnostics: expected + diagnostics: [ + { + range: { + start: { + line: 0, + character: 10 + }, + end: { + line: 2, + character: 20 + } + }, + severity: DiagnosticSeverity.Warning, + source: "lfortran-lsp", + message: "foo should be bar" + }, + { + range: { + start: { + line: 5, + character: 13 + }, + end: { + line: 5, + character: 17 + } + }, + severity: DiagnosticSeverity.Warning, + source: "lfortran-lsp", + message: "baz should be qux" + }, + ] }); sinon.stub(lfortran, "runCompiler").resolves(stdout); diff --git a/server/test/spec/lfortran-language-server.spec.ts b/server/test/spec/lfortran-language-server.spec.ts index 658fb46..4853ee4 100644 --- a/server/test/spec/lfortran-language-server.spec.ts +++ b/server/test/spec/lfortran-language-server.spec.ts @@ -31,7 +31,9 @@ import { import { TextDocument } from "vscode-languageserver-textdocument"; -import { ExampleSettings } from '../../src/lfortran-types'; +import { + ExampleSettings, +} from '../../src/lfortran-types'; import { LFortranCLIAccessor } from "../../src/lfortran-accessors"; @@ -287,7 +289,7 @@ describe("LFortranLanguageServer", () => { range: { start: { line: 0, - character: 10 + character: 9 }, end: { line: 2, @@ -302,7 +304,7 @@ describe("LFortranLanguageServer", () => { range: { start: { line: 5, - character: 13 + character: 12 }, end: { line: 5, @@ -317,7 +319,39 @@ describe("LFortranLanguageServer", () => { ]; const stdout = JSON.stringify({ - diagnostics: diagnostics + diagnostics: [ + { + range: { + start: { + line: 0, + character: 10 + }, + end: { + line: 2, + character: 20 + } + }, + severity: DiagnosticSeverity.Warning, + source: "lfortran-lsp", + message: "foo should be bar" + }, + { + range: { + start: { + line: 5, + character: 13 + }, + end: { + line: 5, + character: 17 + } + }, + // NOTE: Right now, the severity is hard-coded to Warning ... + severity: DiagnosticSeverity.Warning, + source: "lfortran-lsp", + message: "baz should be qux" + }, + ] }); sinon.stub(lfortran, "runCompiler").resolves(stdout); document.getText.returns("");