Merge pull request #8036 from jketema/remove-legacy-relations-2

C++: Remove some unused legacy relations from the DB scheme - Take 2
This commit is contained in:
Mathias Vorreiter Pedersen
2022-02-15 10:56:25 +00:00
committed by GitHub
10 changed files with 8501 additions and 2537 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,2 @@
description: Remove unused legacy relations
compatibility: backwards

View File

@@ -135,52 +135,11 @@ externalData(
string value : string ref string value : string ref
); );
/**
* The date of the snapshot.
*/
snapshotDate(unique date snapshotDate : date ref);
/** /**
* The source location of the snapshot. * The source location of the snapshot.
*/ */
sourceLocationPrefix(string prefix : string ref); sourceLocationPrefix(string prefix : string ref);
/**
* Data used by the 'duplicate code' detection.
*/
duplicateCode(
unique int id : @duplication,
string relativePath : string ref,
int equivClass : int ref
);
/**
* Data used by the 'similar code' detection.
*/
similarCode(
unique int id : @similarity,
string relativePath : string ref,
int equivClass : int ref
);
/**
* Data used by the 'duplicate code' and 'similar code' detection.
*/
@duplication_or_similarity = @duplication | @similarity
/**
* Data used by the 'duplicate code' and 'similar code' detection.
*/
#keyset[id, offset]
tokens(
int id : @duplication_or_similarity ref,
int offset : int ref,
int beginLine : int ref,
int beginColumn : int ref,
int endLine : int ref,
int endColumn : int ref
);
/** /**
* Information about packages that provide code used during compilation. * Information about packages that provide code used during compilation.
* The `id` is just a unique identifier. * The `id` is just a unique identifier.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,6 @@
description: Remove unused legacy relations
compatibility: full
snapshotDate.rel: delete
duplicateCode.rel: delete
similarCode.rel: delete
tokens.rel: delete

View File

@@ -0,0 +1,4 @@
---
category: deprecated
---
* The `CodeDuplication.Copy`, `CodeDuplication.DuplicateBlock`, and `CodeDuplication.SimilarBlock` classes have been deprecated.

View File

@@ -2,59 +2,40 @@
import cpp import cpp
private string relativePath(File file) { result = file.getRelativePath().replaceAll("\\", "/") } private newtype TDuplicationOrSimilarity = MKDuplicationOrSimilarity()
cached
private predicate tokenLocation(string path, int sl, int sc, int ec, int el, Copy copy, int index) {
path = copy.sourceFile().getAbsolutePath() and
tokens(copy, index, sl, sc, ec, el)
}
/** A token block used for detection of duplicate and similar code. */
class Copy extends @duplication_or_similarity {
/** Gets the index of the last token in this block. */
private int lastToken() { result = max(int i | tokens(this, i, _, _, _, _) | i) }
/**
* DEPRECATED: This class is no longer used.
*
* A token block used for detection of duplicate and similar code.
*/
class Copy extends TDuplicationOrSimilarity {
/** Gets the index of the token in this block starting at the location `loc`, if any. */ /** Gets the index of the token in this block starting at the location `loc`, if any. */
int tokenStartingAt(Location loc) { int tokenStartingAt(Location loc) { none() }
exists(string filepath, int startline, int startcol |
loc.hasLocationInfo(filepath, startline, startcol, _, _) and
tokenLocation(filepath, startline, startcol, _, _, this, result)
)
}
/** Gets the index of the token in this block ending at the location `loc`, if any. */ /** Gets the index of the token in this block ending at the location `loc`, if any. */
int tokenEndingAt(Location loc) { int tokenEndingAt(Location loc) { none() }
exists(string filepath, int endline, int endcol |
loc.hasLocationInfo(filepath, _, _, endline, endcol) and
tokenLocation(filepath, _, _, endline, endcol, this, result)
)
}
/** Gets the line on which the first token in this block starts. */ /** Gets the line on which the first token in this block starts. */
int sourceStartLine() { tokens(this, 0, result, _, _, _) } int sourceStartLine() { none() }
/** Gets the column on which the first token in this block starts. */ /** Gets the column on which the first token in this block starts. */
int sourceStartColumn() { tokens(this, 0, _, result, _, _) } int sourceStartColumn() { none() }
/** Gets the line on which the last token in this block ends. */ /** Gets the line on which the last token in this block ends. */
int sourceEndLine() { tokens(this, this.lastToken(), _, _, result, _) } int sourceEndLine() { none() }
/** Gets the column on which the last token in this block ends. */ /** Gets the column on which the last token in this block ends. */
int sourceEndColumn() { tokens(this, this.lastToken(), _, _, _, result) } int sourceEndColumn() { none() }
/** Gets the number of lines containing at least (part of) one token in this block. */ /** Gets the number of lines containing at least (part of) one token in this block. */
int sourceLines() { result = this.sourceEndLine() + 1 - this.sourceStartLine() } int sourceLines() { result = this.sourceEndLine() + 1 - this.sourceStartLine() }
/** Gets an opaque identifier for the equivalence class of this block. */ /** Gets an opaque identifier for the equivalence class of this block. */
int getEquivalenceClass() { duplicateCode(this, _, result) or similarCode(this, _, result) } int getEquivalenceClass() { none() }
/** Gets the source file in which this block appears. */ /** Gets the source file in which this block appears. */
File sourceFile() { File sourceFile() { none() }
exists(string name | duplicateCode(this, name, _) or similarCode(this, name, _) |
name.replaceAll("\\", "/") = relativePath(result)
)
}
/** /**
* Holds if this element is at the specified location. * Holds if this element is at the specified location.
@@ -77,15 +58,23 @@ class Copy extends @duplication_or_similarity {
string toString() { none() } string toString() { none() }
} }
/** A block of duplicated code. */ /**
class DuplicateBlock extends Copy, @duplication { * DEPRECATED: This class is no longer used.
*
* A block of duplicated code.
*/
class DuplicateBlock extends Copy {
override string toString() { override string toString() {
result = "Duplicate code: " + this.sourceLines() + " duplicated lines." result = "Duplicate code: " + this.sourceLines() + " duplicated lines."
} }
} }
/** A block of similar code. */ /**
class SimilarBlock extends Copy, @similarity { * DEPRECATED: This class is no longer used.
*
* A block of similar code.
*/
class SimilarBlock extends Copy {
override string toString() { override string toString() {
result = "Similar code: " + this.sourceLines() + " almost duplicated lines." result = "Similar code: " + this.sourceLines() + " almost duplicated lines."
} }