@@ -4,11 +4,51 @@ private import codeql.util.test.InlineExpectationsTest
44module Impl implements InlineExpectationsTestSig {
55 private import codeql.ruby.ast.internal.TreeSitter
66
7+ private newtype TAnyComment =
8+ RubyComment ( Ruby:: Comment comment ) or
9+ ErbComment ( R:: ErbComment comment )
10+
11+ private class AnyComment extends TAnyComment {
12+ string toString ( ) {
13+ exists ( Ruby:: Comment c |
14+ this = RubyComment ( c ) and
15+ result = c .toString ( )
16+ )
17+ or
18+ exists ( R:: ErbComment c |
19+ this = ErbComment ( c ) and
20+ result = c .toString ( )
21+ )
22+ }
23+
24+ Location getLocation ( ) {
25+ exists ( Ruby:: Comment c |
26+ this = RubyComment ( c ) and
27+ result = c .getLocation ( )
28+ )
29+ or
30+ exists ( R:: ErbComment c |
31+ this = ErbComment ( c ) and
32+ result = c .getLocation ( )
33+ )
34+ }
35+ }
36+
737 /**
838 * A class representing line comments in Ruby.
939 */
10- class ExpectationComment extends Ruby:: Comment {
11- string getContents ( ) { result = this .getValue ( ) .suffix ( 1 ) }
40+ class ExpectationComment extends AnyComment {
41+ string getContents ( ) {
42+ exists ( Ruby:: Comment c |
43+ this = RubyComment ( c ) and
44+ result = c .getValue ( ) .suffix ( 1 )
45+ )
46+ or
47+ exists ( R:: ErbComment c |
48+ this = ErbComment ( c ) and
49+ result = c .getValue ( ) .suffix ( 1 )
50+ )
51+ }
1252 }
1353
1454 class Location = R:: Location ;
0 commit comments