From c753a2bc4bd581eee15ac8d9b30d00e0e0e4dbec Mon Sep 17 00:00:00 2001 From: Alex | Kronox Date: Thu, 15 Aug 2024 13:59:01 +0200 Subject: [PATCH 1/4] use identifiers instead of names in report for language --- .../reportobject/ReportObjectFactory.java | 2 +- report-viewer/src/model/Language.ts | 36 +++++++++---------- .../unit/model/factories/ValidOptions.json | 2 +- .../unit/model/factories/ValidOverview.json | 2 +- 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/core/src/main/java/de/jplag/reporting/reportobject/ReportObjectFactory.java b/core/src/main/java/de/jplag/reporting/reportobject/ReportObjectFactory.java index bb1fb4d399..a1520f92bb 100644 --- a/core/src/main/java/de/jplag/reporting/reportobject/ReportObjectFactory.java +++ b/core/src/main/java/de/jplag/reporting/reportobject/ReportObjectFactory.java @@ -149,7 +149,7 @@ private void writeOverview(JPlagResult result) { missingComparisons); OverviewReport overviewReport = new OverviewReport(REPORT_VIEWER_VERSION, folders.stream().map(File::getPath).toList(), // submissionFolderPath baseCodePath, // baseCodeFolderPath - result.getOptions().language().getName(), // language + result.getOptions().language().getIdentifier(), // language result.getOptions().fileSuffixes(), // fileExtensions submissionNameToIdMap.entrySet().stream().collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey)), // submissionIds submissionNameToNameToComparisonFileName, // result.getOptions().getMinimumTokenMatch(), diff --git a/report-viewer/src/model/Language.ts b/report-viewer/src/model/Language.ts index 198f28399d..35c0937e4b 100644 --- a/report-viewer/src/model/Language.ts +++ b/report-viewer/src/model/Language.ts @@ -2,28 +2,26 @@ * Enum for the language parsers JPlag supports */ enum ParserLanguage { - JAVA = 'Javac based AST plugin', - PYTHON = 'Python3 Parser', - C = 'C Scanner', - CPP_OLD = 'C/C++ Scanner [basic markup]', - CPP = 'C++ Parser', - CPP_2 = 'C/C++ Parser', - C_SHARP = 'C# 6 Parser', + JAVA = 'java', + PYTHON = 'python3', + C = 'c', + CPP = 'cpp', + C_SHARP = 'csharp', EMF_METAMODEL_DYNAMIC = 'emf-dynamic', EMF_METAMODEL = 'EMF metamodel', EMF_MODEL = 'EMF models (dynamically created token set)', - GO = 'Go Parser', - KOTLIN = 'Kotlin Parser', - R_LANG = 'R Parser', - RUST = 'Rust Language Module', - SCALA = 'Scala parser', - SCHEME = 'SchemeR4RS Parser [basic markup]', - SWIFT = 'Swift Parser', - TEXT = 'Text Parser (naive)', - SCXML = 'SCXML (Statechart XML)', - LLVM = 'LLVMIR Parser', - JAVASCRIPT = 'JavaScript', - TYPESCRIPT = 'Typescript Parser' + GO = 'go', + KOTLIN = 'kotlin', + R_LANG = 'rlang', + RUST = 'rust', + SCALA = 'scale', + SCHEME = 'scheme', + SWIFT = 'swift', + TEXT = 'text', + SCXML = 'scxml', + LLVM = 'llvmir', + JAVASCRIPT = 'javascript', + TYPESCRIPT = 'typescript' } type Language = ParserLanguage | 'unknown language' diff --git a/report-viewer/tests/unit/model/factories/ValidOptions.json b/report-viewer/tests/unit/model/factories/ValidOptions.json index 7081e8a80a..1c4fbb595d 100644 --- a/report-viewer/tests/unit/model/factories/ValidOptions.json +++ b/report-viewer/tests/unit/model/factories/ValidOptions.json @@ -1,5 +1,5 @@ { - "language": "Javac based AST plugin", + "language": "java", "min_token_match": 9, "submission_directories": [ ".\\files" diff --git a/report-viewer/tests/unit/model/factories/ValidOverview.json b/report-viewer/tests/unit/model/factories/ValidOverview.json index 44787eea5e..1ddfd238ef 100644 --- a/report-viewer/tests/unit/model/factories/ValidOverview.json +++ b/report-viewer/tests/unit/model/factories/ValidOverview.json @@ -2,7 +2,7 @@ "jplag_version": { "major": 6, "minor": 0, "patch": 0 }, "submission_folder_path": ["files"], "base_code_folder_path": "", - "language": "Javac based AST plugin", + "language": "java", "file_extensions": [".java", ".JAVA"], "submission_id_to_display_name": { "A": "A", "B": "B", "C": "C", "D": "D" }, "submission_ids_to_comparison_file_name": { From 3af6c7a851c5cd1b5eb03370886d2e599318ce8c Mon Sep 17 00:00:00 2001 From: Alex | Kronox Date: Thu, 15 Aug 2024 14:04:17 +0200 Subject: [PATCH 2/4] fix wrong emf identifiers --- report-viewer/src/model/Language.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/report-viewer/src/model/Language.ts b/report-viewer/src/model/Language.ts index 35c0937e4b..4a206b49d3 100644 --- a/report-viewer/src/model/Language.ts +++ b/report-viewer/src/model/Language.ts @@ -8,8 +8,8 @@ enum ParserLanguage { CPP = 'cpp', C_SHARP = 'csharp', EMF_METAMODEL_DYNAMIC = 'emf-dynamic', - EMF_METAMODEL = 'EMF metamodel', - EMF_MODEL = 'EMF models (dynamically created token set)', + EMF_METAMODEL = 'emf', + EMF_MODEL = 'emf-model', GO = 'go', KOTLIN = 'kotlin', R_LANG = 'rlang', From 1129588724ddd06b924e771eae2b41131342c13d Mon Sep 17 00:00:00 2001 From: Alex | Kronox Date: Thu, 15 Aug 2024 14:06:03 +0200 Subject: [PATCH 3/4] fix use of remove languages --- report-viewer/src/utils/CodeHighlighter.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/report-viewer/src/utils/CodeHighlighter.ts b/report-viewer/src/utils/CodeHighlighter.ts index ae3e958cbc..3191840e03 100644 --- a/report-viewer/src/utils/CodeHighlighter.ts +++ b/report-viewer/src/utils/CodeHighlighter.ts @@ -40,8 +40,6 @@ function getHighlightLanguage(lang: Language) { case ParserLanguage.C: return 'c' case ParserLanguage.CPP: - case ParserLanguage.CPP_OLD: - case ParserLanguage.CPP_2: return 'cpp' case ParserLanguage.C_SHARP: return 'csharp' From 9c82157320061ee471d700903cdf60838a23f1df Mon Sep 17 00:00:00 2001 From: Alex | Kronox Date: Thu, 15 Aug 2024 14:17:47 +0200 Subject: [PATCH 4/4] fix unit tests --- .../tests/unit/model/factories/OverviewFactory.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/report-viewer/tests/unit/model/factories/OverviewFactory.test.ts b/report-viewer/tests/unit/model/factories/OverviewFactory.test.ts index 6852f5fbfd..6104668ce3 100644 --- a/report-viewer/tests/unit/model/factories/OverviewFactory.test.ts +++ b/report-viewer/tests/unit/model/factories/OverviewFactory.test.ts @@ -2,6 +2,7 @@ import { beforeAll, describe, expect, it, vi } from 'vitest' import { OverviewFactory } from '@/model/factories/OverviewFactory' import { MetricType } from '@/model/MetricType' import { Distribution } from '@/model/Distribution' +import { ParserLanguage } from '@/model/Language' import validNew from './ValidOverview.json' import outdated from './OutdatedOverview.json' @@ -41,7 +42,7 @@ describe('Test JSON to Overview', () => { expect(await OverviewFactory.getOverview()).toEqual({ _submissionFolderPath: ['files'], _baseCodeFolderPath: '', - _language: 'Javac based AST plugin', + _language: ParserLanguage.JAVA, _fileExtensions: ['.java', '.JAVA'], _matchSensitivity: 9, _dateOfExecution: '12/07/23',