Advertisement
Guest User

Untitled

a guest
Dec 13th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. module Duplicates
  2.  
  3. import String;
  4. import IO;
  5. import Relation;
  6. import List;
  7. import util::Resources;
  8.  
  9. loc project = |project://smallsql|;
  10. //loc project = |project://hsqldb|;
  11.  
  12. // Although locations got a line-number, it seems it is not settable
  13. alias LocationLinePair = tuple[loc, int];
  14.  
  15.  
  16. public rel[LocationLinePair, str] read_project_trimmed(set[loc] files) {
  17. rel[LocationLinePair, str] ret = {};
  18. for (file <- files) {
  19. file_contents = readFileLines(file);
  20. for (<i, line> <- zip([0..size(file_contents)], file_contents)) {
  21. LocationLinePair llp = <file, i>;
  22. ret = ret + {<llp, line>};
  23. }
  24. }
  25. return ret;
  26. }
  27.  
  28.  
  29. public void main() {
  30. set[loc] project_files = { x | /file(x) <- getProject(project), x.extension == "java" };
  31.  
  32. project_lines = read_project_trimmed(project_files);
  33. map[str, set[LocationLinePair]] duplicate_lines = index(invert(project_lines));
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement