@@ -1920,3 +1920,37 @@ private YamlMappingLikeNode resolveMatrixAccessPath(
19201920 else result = resolveMatrixAccessPath ( newRoot , rest )
19211921 )
19221922}
1923+
1924+ predicate yamlCommentHasLocationInfo (
1925+ @yaml_comment c , File file , int startline , int startcolumn , int endline , int endcolumn
1926+ ) {
1927+ exists ( @location l |
1928+ hasLocation ( c , l ) and
1929+ locations_default ( l , file , startline , startcolumn , endline , endcolumn )
1930+ )
1931+ }
1932+
1933+ /**
1934+ * A comment.
1935+ *
1936+ * Example:
1937+ *
1938+ * ```
1939+ * # here is a comment
1940+ * ```
1941+ */
1942+ class Comment extends @yaml_comment {
1943+ /** Gets the text of this comment, not including delimiters. */
1944+ string getText ( ) { comments ( this , _, _, result , _) }
1945+
1946+ Location getLocation ( ) {
1947+ exists ( File file , string filepath , int startline , int startcolumn , int endline , int endcolumn |
1948+ yamlCommentHasLocationInfo ( this , file , startline , startcolumn , endline , endcolumn ) and
1949+ filepath = file .getAbsolutePath ( ) and
1950+ result .hasLocationInfo ( filepath , startline , startcolumn , endline , endcolumn )
1951+ )
1952+ }
1953+
1954+ /** Gets a string representation of this comment. */
1955+ string toString ( ) { comments ( this , _, _, _, result ) }
1956+ }
0 commit comments