Swift: add diagnostics to dbscheme

This commit is contained in:
Alex Denisov
2022-11-03 12:13:36 +01:00
parent e01cbb2ffa
commit 62c26f8f27
11 changed files with 82 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ import codeql.swift.elements.Callable
import codeql.swift.elements.Comment
import codeql.swift.elements.DbFile
import codeql.swift.elements.DbLocation
import codeql.swift.elements.Diagnostics
import codeql.swift.elements.Element
import codeql.swift.elements.File
import codeql.swift.elements.Locatable

View File

@@ -0,0 +1,4 @@
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
private import codeql.swift.generated.Diagnostics
class Diagnostics extends Generated::Diagnostics { }

View File

@@ -0,0 +1,4 @@
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
private import codeql.swift.generated.Raw
predicate constructDiagnostics(Raw::Diagnostics id) { any() }

View File

@@ -0,0 +1,20 @@
// generated by codegen/codegen.py
private import codeql.swift.generated.Synth
private import codeql.swift.generated.Raw
import codeql.swift.elements.Locatable
module Generated {
class Diagnostics extends Synth::TDiagnostics, Locatable {
override string getAPrimaryQlClass() { result = "Diagnostics" }
/**
* Gets the text of this diagnostics.
*/
string getText() { result = Synth::convertDiagnosticsToRaw(this).(Raw::Diagnostics).getText() }
/**
* Gets the kind of this diagnostics.
*/
int getKind() { result = Synth::convertDiagnosticsToRaw(this).(Raw::Diagnostics).getKind() }
}
}

View File

@@ -135,6 +135,21 @@ private module Impl {
)
}
private Element getImmediateChildOfDiagnostics(
Diagnostics e, int index, string partialPredicateCall
) {
exists(int b, int bLocatable, int n |
b = 0 and
bLocatable = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLocatable(e, i, _)) | i) and
n = bLocatable and
(
none()
or
result = getImmediateChildOfLocatable(e, index - b, partialPredicateCall)
)
)
}
private Element getImmediateChildOfUnknownFile(
UnknownFile e, int index, string partialPredicateCall
) {
@@ -4882,6 +4897,8 @@ private module Impl {
or
result = getImmediateChildOfDbLocation(e, index, partialAccessor)
or
result = getImmediateChildOfDiagnostics(e, index, partialAccessor)
or
result = getImmediateChildOfUnknownFile(e, index, partialAccessor)
or
result = getImmediateChildOfUnknownLocation(e, index, partialAccessor)

View File

@@ -51,6 +51,14 @@ module Raw {
override string toString() { result = "DbLocation" }
}
class Diagnostics extends @diagnostics, Locatable {
override string toString() { result = "Diagnostics" }
string getText() { diagnostics(this, result, _) }
int getKind() { diagnostics(this, _, result) }
}
class UnspecifiedElement extends @unspecified_element, Locatable {
override string toString() { result = "UnspecifiedElement" }

View File

@@ -8,6 +8,7 @@ module Synth {
TComment(Raw::Comment id) { constructComment(id) } or
TDbFile(Raw::DbFile id) { constructDbFile(id) } or
TDbLocation(Raw::DbLocation id) { constructDbLocation(id) } or
TDiagnostics(Raw::Diagnostics id) { constructDiagnostics(id) } or
TUnknownFile() or
TUnknownLocation() or
TUnspecifiedElement(Raw::UnspecifiedElement id) { constructUnspecifiedElement(id) } or
@@ -322,7 +323,7 @@ module Synth {
class TFile = TDbFile or TUnknownFile;
class TLocatable = TArgument or TAstNode or TComment or TUnspecifiedElement;
class TLocatable = TArgument or TAstNode or TComment or TDiagnostics or TUnspecifiedElement;
class TLocation = TDbLocation or TUnknownLocation;
@@ -494,6 +495,9 @@ module Synth {
cached
TDbLocation convertDbLocationFromRaw(Raw::Element e) { result = TDbLocation(e) }
cached
TDiagnostics convertDiagnosticsFromRaw(Raw::Element e) { result = TDiagnostics(e) }
cached
TUnknownFile convertUnknownFileFromRaw(Raw::Element e) { none() }
@@ -1471,6 +1475,8 @@ module Synth {
or
result = convertCommentFromRaw(e)
or
result = convertDiagnosticsFromRaw(e)
or
result = convertUnspecifiedElementFromRaw(e)
}
@@ -2201,6 +2207,9 @@ module Synth {
cached
Raw::Element convertDbLocationToRaw(TDbLocation e) { e = TDbLocation(result) }
cached
Raw::Element convertDiagnosticsToRaw(TDiagnostics e) { e = TDiagnostics(result) }
cached
Raw::Element convertUnknownFileToRaw(TUnknownFile e) { none() }
@@ -3176,6 +3185,8 @@ module Synth {
or
result = convertCommentToRaw(e)
or
result = convertDiagnosticsToRaw(e)
or
result = convertUnspecifiedElementToRaw(e)
}

View File

@@ -2,6 +2,7 @@
import codeql.swift.elements.CommentConstructor
import codeql.swift.elements.DbFileConstructor
import codeql.swift.elements.DbLocationConstructor
import codeql.swift.elements.DiagnosticsConstructor
import codeql.swift.elements.UnspecifiedElementConstructor
import codeql.swift.elements.decl.AccessorDeclConstructor
import codeql.swift.elements.decl.AssociatedTypeDeclConstructor

View File

@@ -66,6 +66,7 @@ files(
@argument
| @ast_node
| @comment
| @diagnostics
| @unspecified_element
;
@@ -125,6 +126,12 @@ db_locations(
unique int id: @db_location
);
diagnostics(
unique int id: @diagnostics,
string text: string ref,
int kind: int ref
);
unknown_files(
unique int id: @unknown_file
);

View File

@@ -0,0 +1,4 @@
// generated by codegen/codegen.py
After a swift source file is added in this directory and codegen/codegen.py is run again, test queries
will appear and this file will be deleted

View File

@@ -47,6 +47,10 @@ class UnspecifiedElement(Locatable):
class Comment(Locatable):
text: string
class Diagnostics(Locatable):
text: string
kind: int
class DbFile(File):
pass