Swift: use File from QL library

This commit is contained in:
Alex Denisov
2022-04-25 16:58:30 +02:00
parent 6f0ddaa431
commit 355504a86a
3 changed files with 22 additions and 26 deletions

View File

@@ -1,4 +1,24 @@
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
private import codeql.swift.generated.File
class File extends FileBase { }
class File extends FileBase {
/** toString */
string toString() { result = getAbsolutePath() }
/** Gets the name of this file. */
string getName() { files(this, result) }
/** Gets the absolute path of this file. */
string getAbsolutePath() { result = getName() }
/** Gets the full name of this file. */
string getFullName() { result = getAbsolutePath() }
/** Gets the URL of this file. */
string getURL() { result = "file://" + this.getAbsolutePath() + ":0:0:0:0" }
/** Gets the base name of this file. */
string getBaseName() {
result = this.getAbsolutePath().regexpCapture(".*/(([^/]*?)(?:\\.([^.]*))?)", 1)
}
}

View File

@@ -1,3 +1,3 @@
/** Top-level import for the Swift language pack */
import swift.File
import codeql.swift.elements

View File

@@ -1,24 +0,0 @@
/** TODO: to be replaced */
/** A file. */
class File extends @file {
/** toString */
string toString() { result = getAbsolutePath() }
/** Gets the name of this file. */
string getName() { files(this, result) }
/** Gets the absolute path of this file. */
string getAbsolutePath() { result = getName() }
/** Gets the full name of this file. */
string getFullName() { result = getAbsolutePath() }
/** Gets the URL of this file. */
string getURL() { result = "file://" + this.getAbsolutePath() + ":0:0:0:0" }
/** Gets the base name of this file. */
string getBaseName() {
result = this.getAbsolutePath().regexpCapture(".*/(([^/]*?)(?:\\.([^.]*))?)", 1)
}
}