Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Duplicates
- import String;
- import IO;
- import Relation;
- import List;
- import util::Resources;
- loc project = |project://smallsql|;
- //loc project = |project://hsqldb|;
- // Although locations got a line-number, it seems it is not settable
- alias LocationLinePair = tuple[loc, int];
- public rel[LocationLinePair, str] read_project_trimmed(set[loc] files) {
- rel[LocationLinePair, str] ret = {};
- for (file <- files) {
- file_contents = readFileLines(file);
- for (<i, line> <- zip([0..size(file_contents)], file_contents)) {
- LocationLinePair llp = <file, i>;
- ret = ret + {<llp, line>};
- }
- }
- return ret;
- }
- public void main() {
- set[loc] project_files = { x | /file(x) <- getProject(project), x.extension == "java" };
- project_lines = read_project_trimmed(project_files);
- map[str, set[LocationLinePair]] duplicate_lines = index(invert(project_lines));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement