Skip to content

Commit 4b61b9b

Browse files
committed
combine the shared Location and FileSystem implementations into a single module, for simplicity
1 parent 3801d21 commit 4b61b9b

File tree

7 files changed

+252
-287
lines changed

7 files changed

+252
-287
lines changed

javascript/ql/lib/semmle/javascript/internal/FileSystemImpl.qll

Lines changed: 0 additions & 29 deletions
This file was deleted.

javascript/ql/lib/semmle/javascript/internal/LocationsImpl.qll

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,36 @@
22
* Provides an implementation of `LocationsSig` from the `codeql/utils` package.
33
*/
44

5-
private import FileSystemImpl::FileSystemImpl as FSImpl
6-
private import codeql.utils.FileSystem as FS
75
private import codeql.utils.Locations as Locs
86

97
/** An implementation of `LocationsSig`. */
10-
module LocationsImpl implements Locs::LocationsSig<FSImpl> {
8+
module LocationsImpl implements Locs::LocationsSig {
9+
abstract class Container extends @container {
10+
abstract string getAbsolutePath();
11+
12+
string toString() { result = this.getAbsolutePath() }
13+
14+
Container getParentContainer() { containerparent(result, this) }
15+
}
16+
17+
class File extends @file, Container {
18+
override string getAbsolutePath() { files(this, result) }
19+
}
20+
21+
class Folder extends @folder, Container {
22+
override string getAbsolutePath() { folders(this, result) }
23+
}
24+
25+
string getSourceLocationPrefix() { sourceLocationPrefix(result) }
26+
1127
class Location = @location;
1228

1329
predicate locations(
14-
Location loc, FSImpl::File file, int startLine, int startColum, int endLine, int endColumn
30+
Location loc, File file, int startLine, int startColum, int endLine, int endColumn
1531
) {
1632
locations_default(loc, file, startLine, startColum, endLine, endColumn)
1733
}
1834
}
1935

2036
/** An instantiation of the shared Locations module. */
21-
module Inst = Locs::Make<FSImpl, LocationsImpl>;
37+
module Inst = Locs::Make<LocationsImpl>;
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
import codeql.ruby.internal.FileSystemImpl::Inst
1+
private import codeql.ruby.internal.LocationsImpl
2+
3+
class Container = Inst::Container;
4+
5+
class File = Inst::File;
6+
7+
class Folder = Inst::Folder;

ruby/ql/lib/codeql/ruby/internal/FileSystemImpl.qll

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,37 @@
11
/**
2-
* Provides an implementation of `FileSystemSig` from the `codeql/utils` package.
2+
* Provides an implementation of `LocationsSig` from the `codeql/utils` package.
33
*/
44

55
private import codeql.utils.Locations as Locs
6-
private import FileSystemImpl::FileSystemImpl as FSImpl
76

8-
/** An implementation of `FileSystemSig`. */
9-
module LocationsImpl implements Locs::LocationsSig<FSImpl> {
7+
/** An implementation of `LocationsSig`. */
8+
module LocationsImpl implements Locs::LocationsSig {
9+
abstract class Container extends @container {
10+
abstract string getAbsolutePath();
11+
12+
Container getParentContainer() { containerparent(result, this) }
13+
14+
string toString() { result = this.getAbsolutePath() }
15+
}
16+
17+
class File extends @file, Container {
18+
override string getAbsolutePath() { files(this, result) }
19+
}
20+
21+
class Folder extends Container, @folder {
22+
override string getAbsolutePath() { folders(this, result) }
23+
}
24+
25+
string getSourceLocationPrefix() { sourceLocationPrefix(result) }
26+
1027
class Location = @location_default;
1128

1229
predicate locations(
13-
Location loc, FSImpl::File file, int startLine, int startColum, int endLine, int endColumn
30+
Location loc, File file, int startLine, int startColum, int endLine, int endColumn
1431
) {
1532
locations_default(loc, file, startLine, startColum, endLine, endColumn)
1633
}
1734
}
1835

1936
/** An instantiation of the shared Locations module. */
20-
module Inst = Locs::Make<FSImpl, LocationsImpl>;
37+
module Inst = Locs::Make<LocationsImpl>;

shared/utils/codeql/utils/FileSystem.qll

Lines changed: 0 additions & 210 deletions
This file was deleted.

0 commit comments

Comments
 (0)