Skip to content

Commit 94b5c4e

Browse files
committed
Python: Drop redundant columns from files and folders relations
1 parent d3caa80 commit 94b5c4e

File tree

3 files changed

+7
-438
lines changed

3 files changed

+7
-438
lines changed

python/ql/lib/semmle/python/Files.qll

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import python
22

33
/** A file */
4-
class File extends Container {
5-
File() { files(this, _, _, _, _) }
6-
4+
class File extends Container, @file {
75
/** DEPRECATED: Use `getAbsolutePath` instead. */
86
deprecated override string getName() { result = this.getAbsolutePath() }
97

@@ -34,9 +32,7 @@ class File extends Container {
3432
}
3533

3634
/** Gets a short name for this file (just the file name) */
37-
string getShortName() {
38-
exists(string simple, string ext | files(this, _, simple, ext, _) | result = simple + ext)
39-
}
35+
string getShortName() { result = this.getBaseName() }
4036

4137
private int lastLine() {
4238
result = max(int i | exists(Location l | l.getFile() = this and l.getEndLine() = i))
@@ -55,7 +51,7 @@ class File extends Container {
5551
)
5652
}
5753

58-
override string getAbsolutePath() { files(this, result, _, _, _) }
54+
override string getAbsolutePath() { files(this, result) }
5955

6056
/** Gets the URL of this file. */
6157
override string getURL() { result = "file://" + this.getAbsolutePath() + ":0:0:0:0" }
@@ -118,15 +114,10 @@ private predicate occupied_line(File f, int n) {
118114
}
119115

120116
/** A folder (directory) */
121-
class Folder extends Container {
122-
Folder() { folders(this, _, _) }
123-
117+
class Folder extends Container, @folder {
124118
/** DEPRECATED: Use `getAbsolutePath` instead. */
125119
deprecated override string getName() { result = this.getAbsolutePath() }
126120

127-
/** DEPRECATED: Use `getBaseName` instead. */
128-
deprecated string getSimple() { folders(this, _, result) }
129-
130121
/**
131122
* Holds if this element is at the specified location.
132123
* The location spans column `startcolumn` of line `startline` to
@@ -144,7 +135,7 @@ class Folder extends Container {
144135
endcolumn = 0
145136
}
146137

147-
override string getAbsolutePath() { folders(this, result, _) }
138+
override string getAbsolutePath() { folders(this, result) }
148139

149140
/** Gets the URL of this folder. */
150141
override string getURL() { result = "folder://" + this.getAbsolutePath() }

python/ql/lib/semmlecode.python.dbscheme

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,10 @@ svnchurn(
122122

123123
/* fromSource is ignored */
124124
files(unique int id: @file,
125-
varchar(900) name: string ref,
126-
varchar(900) simple: string ref,
127-
varchar(900) ext: string ref,
128-
int fromSource: int ref);
125+
varchar(900) name: string ref);
129126

130127
folders(unique int id: @folder,
131-
varchar(900) name: string ref,
132-
varchar(900) simple: string ref);
128+
varchar(900) name: string ref);
133129

134130
@container = @folder | @file;
135131

0 commit comments

Comments
 (0)