Explorar o código

Quick fix for matches not display properly in the report viewer.

Sebastian Hahner %!s(int64=4) %!d(string=hai) anos
pai
achega
db30cab101

+ 1 - 0
report-viewer/package.json

@@ -4,6 +4,7 @@
   "private": true,
   "scripts": {
     "serve": "vue-cli-service serve",
+    "dev": "vue-cli-service serve",
     "build": "vue-cli-service build",
     "lint": "vue-cli-service lint"
   },

+ 1 - 1
report-viewer/src/components/FilesContainer.vue

@@ -58,7 +58,7 @@ export default defineComponent({
      * Matche of submission.
      */
     matches: {
-     type: Map<string,MatchInSingleFile>,
+     type: Map<string,MatchInSingleFile[]>,
       required: true,
     },
   },

+ 13 - 0
report-viewer/src/model/factories/ComparisonFactory.ts

@@ -21,6 +21,13 @@ export class ComparisonFactory {
     );
 
     const matches = json.matches as Array<Record<string, unknown>>;
+    
+    // Quick fix for issue #658, requires deeper insights to be resolved completely
+    matches.forEach((match: Record<string, unknown>) => {
+      match["file1"] = this.removePathFromFileName(match["file1"] as string ?? "");
+      match["file2"] = this.removePathFromFileName(match["file2"] as string ?? "");
+    })
+
     const colors = this.generateColorsForMatches(matches.length);
     const coloredMatches = matches.map((match, index) =>
       this.mapMatch(match, colors[index])
@@ -71,9 +78,11 @@ export class ComparisonFactory {
     matches.forEach((val) => {
       const name =
         index === 1 ? (val.firstFile as string) : (val.secondFile as string);
+
       if (!acc.get(name)) {
         acc.set(name, []);
       }
+
       if (index === 1) {
         const newVal: MatchInSingleFile = {
           start: val.startInFirst as number,
@@ -99,6 +108,10 @@ export class ComparisonFactory {
     return acc;
   }
 
+  private static removePathFromFileName(filePath: string): string {
+    return  filePath.substring(filePath.lastIndexOf("\\") + 1).substring(filePath.lastIndexOf("/") + 1);
+  }
+
   private static generateColorsForMatches(num: number): Array<string> {
     const colors = [];
     const hueDelta = Math.trunc(360 / num);

+ 1 - 0
report-viewer/vue.config.js

@@ -11,5 +11,6 @@ module.exports = defineConfig({
         chunks: "all",
       },
     },
+    devtool: 'source-map'
   },
 });