Skip to content

Commit 1e71fe4

Browse files
committed
C#
1 parent 50c247a commit 1e71fe4

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

csharp/ql/lib/semmle/code/csharp/Comments.qll

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
import Element
99
import Location
1010

11+
private Location unmapLoc(Location l) {
12+
result.(SourceLocation).getMappedLocation() = l
13+
or
14+
not exists(result.(SourceLocation).getMappedLocation()) and
15+
result = l
16+
}
17+
1118
/**
1219
* A single line of comment.
1320
*
@@ -19,7 +26,7 @@ class CommentLine extends @commentline {
1926
string toString() { none() }
2027

2128
/** Gets the location of this comment line. */
22-
Location getLocation() { commentline_location(this, result) }
29+
Location getLocation() { commentline_location(this, unmapLoc(result)) }
2330

2431
/** Gets the containing comment block. */
2532
CommentBlock getParent() { result.getAChild() = this }
@@ -159,7 +166,7 @@ class CommentBlock extends @commentblock {
159166
string toString() { result = this.getChild(0).toString() }
160167

161168
/** Gets the location of this comment block */
162-
Location getLocation() { commentblock_location(this, result) }
169+
Location getLocation() { commentblock_location(this, unmapLoc(result)) }
163170

164171
/** Gets the number of lines in this comment block. */
165172
int getNumLines() { result = count(this.getAChild()) }

0 commit comments

Comments
 (0)