Skip to content

Commit cd632dc

Browse files
committed
Swift: minor tweaks
Replace string singleton with a newtype-based one, and fix some doc comment cosmetics.
1 parent 47b905b commit cd632dc

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

swift/ql/lib/codeql/swift/printast/PrintAst.qll

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,16 @@
55
import swift
66
import codeql.swift.generated.ParentChild
77

8+
private newtype TPrintAstConfiguration = TMakePrintAstConfiguration()
9+
810
/**
9-
* Hook to customize the files and functions printed by this module.
10-
*
11-
* For an AstNode to be printed, it always requires `shouldPrintFile(f)` to hold
12-
* for its containing file `f`, and additionally requires `shouldPrintFunction(fun)`
13-
* to hold if it is, or is a child of, function `fun`.
11+
* The hook to customize the files and functions printed by this module.
1412
*/
15-
class PrintAstConfiguration extends string {
13+
class PrintAstConfiguration extends TPrintAstConfiguration {
1614
/**
17-
* Restrict to a single string, making this a singleton type.
15+
* Gets the string representation of this singleton
1816
*/
19-
PrintAstConfiguration() { this = "PrintAstConfiguration" }
17+
string toString() { result = "PrintAstConfiguration" }
2018

2119
/**
2220
* Holds if the AST for `e` should be printed. By default, holds for all.

swift/ql/src/queries/ide-contextual-queries/printast.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ import codeql.swift.printast.PrintAst
1212
import IDEContextual
1313

1414
/**
15-
* The source file to generate an AST from.
15+
* Gets the source file to generate an AST from.
1616
*/
1717
external string selectedSourceFile();
1818

1919
class PrintAstConfigurationOverride extends PrintAstConfiguration {
2020
/**
2121
* Holds if the location matches the selected file in the VS Code extension and
22-
* the element is `fromSource`.
22+
* the element is `e`.
2323
*/
2424
override predicate shouldPrint(Locatable e) {
2525
super.shouldPrint(e) and

swift/ql/test/library-tests/ast/PrintAst.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import codeql.swift.printast.PrintAst
77
import TestUtils
88

99
/**
10-
* Hook to customize the functions printed by this query.
10+
* The hook to customize the entities printed by this query.
1111
*/
1212
class PrintAstConfigurationOverride extends PrintAstConfiguration {
1313
override predicate shouldPrint(Locatable e) { super.shouldPrint(e) and toBeTested(e) }

0 commit comments

Comments
 (0)