Line edits can target any lines in a source file, including empty and comment-only lines. The constructors currently target one or two of these lines chosen uniformly at random. It might make more sense that comment/empty lines are excluded from the edit source and destination lines.
It is already possible to get a list of lines excluding those that are empty/comments by calling SourceFileLine.getLineIDsNonEmptyOrComments(). The samplers and enumerators do this, choose a pair of line numbers from that list, and call the Line edit constructors with specific line numbers rather than just an RNG and a source file. Something like this:
[code]
List allLines = sourceFile.getLineIDsNonEmptyOrComments(false);
List targetMethodLines = sourceFile.getLineIDsNonEmptyOrComments(true);
CopyLine cl = new CopyLine(sourceFile,targetMethodLines.get(rng.nextInt(targetMethodLines.size())), sourceFile, allLines.get(rng.nextInt(allLines.size())));
[/code]
We could either change the standard (SourceFile, RNG) constructors for Line edits to do this; or make an extended version of Line edits that only target non-empty/comment lines. My preference is for the latter; anyone have any thoughts either way?
Changed default behaviour to exclude empty and comment lines. This is now consistent with the way the statement edits work and with the results in the paper.
Line edits can target any lines in a source file, including empty and comment-only lines. The constructors currently target one or two of these lines chosen uniformly at random. It might make more sense that comment/empty lines are excluded from the edit source and destination lines.
It is already possible to get a list of lines excluding those that are empty/comments by calling SourceFileLine.getLineIDsNonEmptyOrComments(). The samplers and enumerators do this, choose a pair of line numbers from that list, and call the Line edit constructors with specific line numbers rather than just an RNG and a source file. Something like this:
[code] List allLines = sourceFile.getLineIDsNonEmptyOrComments(false);
List targetMethodLines = sourceFile.getLineIDsNonEmptyOrComments(true);
CopyLine cl = new CopyLine(sourceFile,targetMethodLines.get(rng.nextInt(targetMethodLines.size())), sourceFile, allLines.get(rng.nextInt(allLines.size())));
[/code]
We could either change the standard (SourceFile, RNG) constructors for Line edits to do this; or make an extended version of Line edits that only target non-empty/comment lines. My preference is for the latter; anyone have any thoughts either way?