22
33import cpp
44
5- private string relativePath ( File file ) { result = file .getRelativePath ( ) .replaceAll ( "\\" , "/" ) }
6-
7- cached
8- private predicate tokenLocation ( string path , int sl , int sc , int ec , int el , Copy copy , int index ) {
9- path = copy .sourceFile ( ) .getAbsolutePath ( ) and
10- tokens ( copy , index , sl , sc , ec , el )
11- }
12-
13- /** A token block used for detection of duplicate and similar code. */
14- class Copy extends @duplication_or_similarity {
15- /** Gets the index of the last token in this block. */
16- private int lastToken ( ) { result = max ( int i | tokens ( this , i , _, _, _, _) | i ) }
5+ private newtype TDuplicationOrSimilarity = MKDuplicationOrSimilarity ( )
176
7+ /**
8+ * DEPRECATED: This class is no longer used.
9+ *
10+ * A token block used for detection of duplicate and similar code.
11+ */
12+ class Copy extends TDuplicationOrSimilarity {
1813 /** Gets the index of the token in this block starting at the location `loc`, if any. */
19- int tokenStartingAt ( Location loc ) {
20- exists ( string filepath , int startline , int startcol |
21- loc .hasLocationInfo ( filepath , startline , startcol , _, _) and
22- tokenLocation ( filepath , startline , startcol , _, _, this , result )
23- )
24- }
14+ int tokenStartingAt ( Location loc ) { none ( ) }
2515
2616 /** Gets the index of the token in this block ending at the location `loc`, if any. */
27- int tokenEndingAt ( Location loc ) {
28- exists ( string filepath , int endline , int endcol |
29- loc .hasLocationInfo ( filepath , _, _, endline , endcol ) and
30- tokenLocation ( filepath , _, _, endline , endcol , this , result )
31- )
32- }
17+ int tokenEndingAt ( Location loc ) { none ( ) }
3318
3419 /** Gets the line on which the first token in this block starts. */
35- int sourceStartLine ( ) { tokens ( this , 0 , result , _ , _ , _ ) }
20+ int sourceStartLine ( ) { none ( ) }
3621
3722 /** Gets the column on which the first token in this block starts. */
38- int sourceStartColumn ( ) { tokens ( this , 0 , _ , result , _ , _ ) }
23+ int sourceStartColumn ( ) { none ( ) }
3924
4025 /** Gets the line on which the last token in this block ends. */
41- int sourceEndLine ( ) { tokens ( this , this . lastToken ( ) , _ , _ , result , _ ) }
26+ int sourceEndLine ( ) { none ( ) }
4227
4328 /** Gets the column on which the last token in this block ends. */
44- int sourceEndColumn ( ) { tokens ( this , this . lastToken ( ) , _ , _ , _ , result ) }
29+ int sourceEndColumn ( ) { none ( ) }
4530
4631 /** Gets the number of lines containing at least (part of) one token in this block. */
4732 int sourceLines ( ) { result = this .sourceEndLine ( ) + 1 - this .sourceStartLine ( ) }
4833
4934 /** Gets an opaque identifier for the equivalence class of this block. */
50- int getEquivalenceClass ( ) { duplicateCode ( this , _ , result ) or similarCode ( this , _ , result ) }
35+ int getEquivalenceClass ( ) { none ( ) }
5136
5237 /** Gets the source file in which this block appears. */
53- File sourceFile ( ) {
54- exists ( string name | duplicateCode ( this , name , _) or similarCode ( this , name , _) |
55- name .replaceAll ( "\\" , "/" ) = relativePath ( result )
56- )
57- }
38+ File sourceFile ( ) { none ( ) }
5839
5940 /**
6041 * Holds if this element is at the specified location.
@@ -77,15 +58,23 @@ class Copy extends @duplication_or_similarity {
7758 string toString ( ) { none ( ) }
7859}
7960
80- /** A block of duplicated code. */
81- class DuplicateBlock extends Copy , @duplication {
61+ /**
62+ * DEPRECATED: This class is no longer used.
63+ *
64+ * A block of duplicated code.
65+ */
66+ class DuplicateBlock extends Copy {
8267 override string toString ( ) {
8368 result = "Duplicate code: " + this .sourceLines ( ) + " duplicated lines."
8469 }
8570}
8671
87- /** A block of similar code. */
88- class SimilarBlock extends Copy , @similarity {
72+ /**
73+ * DEPRECATED: This class is no longer used.
74+ *
75+ * A block of similar code.
76+ */
77+ class SimilarBlock extends Copy {
8978 override string toString ( ) {
9079 result = "Similar code: " + this .sourceLines ( ) + " almost duplicated lines."
9180 }
0 commit comments