Skip to content

Commit 1c1c465

Browse files
authored
Merge pull request #6708 from hvitved/python/files-folders-drop-columns
Python: Drop redundant columns from `files` and `folders` relations
2 parents 783233d + 9f10018 commit 1c1c465

File tree

6 files changed

+2004
-439
lines changed

6 files changed

+2004
-439
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 & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,11 @@ svnchurn(
120120
Python dbscheme
121121
****************************/
122122

123-
/* fromSource is ignored */
124123
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);
124+
varchar(900) name: string ref);
129125

130126
folders(unique int id: @folder,
131-
varchar(900) name: string ref,
132-
varchar(900) simple: string ref);
127+
varchar(900) name: string ref);
133128

134129
@container = @folder | @file;
135130

0 commit comments

Comments
 (0)