Skip to content

Commit ac0482e

Browse files
authored
Merge pull request #30 from usethesource/fix/correct-clone-loc
Fixed length of abbreviated loc for a clone
2 parents 3c8472d + ecfc767 commit ac0482e

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/analysis/typepal/Collector.rsc

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,17 @@ Collector newCollector(str modelName, map[str,Tree] namedTrees, TypePalConfig co
10111011
paths += tm.paths;
10121012
}
10131013
1014+
loc limitLocToFirstLine(loc l){
1015+
try {
1016+
str txt = readFile(l);
1017+
int k = findFirst(txt, "\n");
1018+
if(k >= 0){
1019+
return l[length=k][end=<l.begin.line,k>];
1020+
}
1021+
} catch _:;
1022+
return l;
1023+
}
1024+
10141025
map[loc,loc] buildLogical2physical(Defines defines){
10151026
map[loc,loc] my_logical2physical = logical2physical;
10161027
map[loc,loc] my_physical2logical = ();
@@ -1030,7 +1041,7 @@ Collector newCollector(str modelName, map[str,Tree] namedTrees, TypePalConfig co
10301041
info("Clone of `<def.id>`", def.defined)
10311042
];
10321043
// restrict clone location to first line for readability
1033-
messages += error("Remove code clone for <prettyRole(def.idRole)> `<def.id>`", def.defined[end=<def.defined.begin.line+1,0>], causes=causes);
1044+
messages += error("Remove code clone for <prettyRole(def.idRole)> `<def.id>`", limitLocToFirstLine(def.defined), causes=causes);
10341045
}
10351046
}
10361047
my_logical2physical[logicalLoc] = def.defined;

0 commit comments

Comments
 (0)