Skip to content

Commit 5744356

Browse files
committed
Python: Add a bunch more toString docs.
1 parent e72e662 commit 5744356

25 files changed

+40
-0
lines changed

python/ql/src/Lexical/CommentedOutCode.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ class CommentedOutCodeLine extends Comment {
175175
class CommentedOutCodeBlock extends @py_comment {
176176
CommentedOutCodeBlock() { commented_out_code_block(this, _) }
177177

178+
/** Gets a textual representation of this element. */
178179
string toString() { result = "Commented out code" }
179180

180181
/** Whether this commented-out code block contains the comment c */

python/ql/src/analysis/DefinitionTracking.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ private newtype TDefinition =
1010

1111
/** A definition for the purposes of jump-to-definition. */
1212
class Definition extends TLocalDefinition {
13+
/** Gets a textual representation of this element. */
1314
string toString() { result = "Definition " + this.getAstNode().getLocation().toString() }
1415

1516
AstNode getAstNode() { this = TLocalDefinition(result) }
@@ -467,6 +468,7 @@ Definition getUniqueDefinition(Expr use) {
467468

468469
/** Helper class to get suitable locations for attributes */
469470
class NiceLocationExpr extends @py_expr {
471+
/** Gets a textual representation of this element. */
470472
string toString() { result = this.(Expr).toString() }
471473
/**
472474
* Holds if this element is at the specified location.

python/ql/src/external/ExternalArtifact.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class ExternalDefect extends @externalDefect {
1818

1919
Location getLocation() { externalDefects(this, _, result, _, _) }
2020

21+
/** Gets a textual representation of this element. */
2122
string toString() { result = getQueryPath() + ": " + getLocation() + " - " + getMessage() }
2223
}
2324

@@ -28,6 +29,7 @@ class ExternalMetric extends @externalMetric {
2829

2930
Location getLocation() { externalMetrics(this, _, result, _) }
3031

32+
/** Gets a textual representation of this element. */
3133
string toString() { result = getQueryPath() + ": " + getLocation() + " - " + getValue() }
3234
}
3335

python/ql/src/external/VCS.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class Commit extends @svnentry {
1010
)
1111
}
1212

13+
/** Gets a textual representation of this element. */
1314
string toString() { result = this.getRevisionName() }
1415

1516
string getRevisionName() { svnentries(this, result, _, _, _) }

python/ql/src/semmle/python/Comment.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class Comment extends @py_comment {
1414

1515
Location getLocation() { py_comments(this, _, result) }
1616

17+
/** Gets a textual representation of this element. */
1718
string toString() { result = "Comment " + this.getText() }
1819

1920
/**
@@ -55,6 +56,7 @@ class CommentBlock extends @py_comment {
5556

5657
private Comment last() { comment_block_part(this, result, this.length()) }
5758

59+
/** Gets a textual representation of this element. */
5860
string toString() { result = "Comment block" }
5961

6062
/** The length of this comment block (in comments) */

python/ql/src/semmle/python/Exprs.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class Expr extends Expr_, AstNode {
77
/** Gets the scope of this expression */
88
override Scope getScope() { py_scopes(this, result) }
99

10+
/** Gets a textual representation of this element. */
1011
override string toString() { result = "Expression" }
1112

1213
/** Gets the module in which this expression occurs */

python/ql/src/semmle/python/Files.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ class Location extends @location {
393393
locations_ast(this, _, _, _, _, result)
394394
}
395395

396+
/** Gets a textual representation of this element. */
396397
string toString() {
397398
result = this.getPath().getAbsolutePath() + ":" + this.getStartLine().toString()
398399
}
@@ -433,6 +434,7 @@ class Line extends @py_line {
433434
)
434435
}
435436

437+
/** Gets a textual representation of this element. */
436438
string toString() {
437439
exists(Module m | py_line_lengths(this, m, _, _) |
438440
result = m.getFile().getShortName() + ":" + this.getLineNumber().toString()

python/ql/src/semmle/python/Flow.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ class ControlFlowNode extends @py_flow_node {
139139
/** Gets the syntactic element corresponding to this flow node */
140140
AstNode getNode() { py_flow_bb_node(this, result, _, _) }
141141

142+
/** Gets a textual representation of this element. */
142143
string toString() {
143144
exists(Scope s | s.getEntryNode() = this | result = "Entry node for " + s.toString())
144145
or
@@ -1014,6 +1015,7 @@ class BasicBlock extends @py_flow_node {
10141015
/** Gets the nth node in this basic block */
10151016
ControlFlowNode getNode(int n) { py_flow_bb_node(result, _, this, n) }
10161017

1018+
/** Gets a textual representation of this element. */
10171019
string toString() { result = "BasicBlock" }
10181020

10191021
/** Whether this basic block strictly dominates the other */

python/ql/src/semmle/python/SSA.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ class SsaVariable extends @py_ssa_var {
7676
result = this.getAPhiInput().getAnUltimateDefinition()
7777
}
7878

79+
/** Gets a textual representation of this element. */
7980
string toString() { result = "SSA Variable " + this.getId() }
8081

8182
Location getLocation() { result = this.getDefinition().getLocation() }

python/ql/src/semmle/python/Variables.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class Variable extends @py_variable {
1313
/** Gets the identifier (name) of this variable */
1414
string getId() { variable(this, _, result) }
1515

16+
/** Gets a textual representation of this element. */
1617
string toString() { result = "Variable " + this.getId() }
1718

1819
/** Gets an access (load or store) of this variable */

0 commit comments

Comments
 (0)