@@ -128,6 +128,14 @@ abstract class PathString extends string {
128128 /** Gets the path of the parent folder of the folder or file this path refers to. */
129129 string getDirName ( ) { result = this .regexpCapture ( pathRegex ( ) , 1 ) }
130130
131+ /**
132+ * Gets the extension of the folder or file this path refers to, that is, the suffix of the base name
133+ * starting at the last dot character, if there is one.
134+ *
135+ * Has no result if the base name does not contain a dot.
136+ */
137+ string getExtension ( ) { result = this .regexpCapture ( pathRegex ( ) , 4 ) }
138+
131139 /**
132140 * Gets the absolute path that the sub-path consisting of the first `n`
133141 * components of this path refers to when resolved relative to the
@@ -208,6 +216,14 @@ abstract class PathExpr extends PathExprBase {
208216 /** Gets the stem, that is, base name without extension, of the folder or file this path refers to. */
209217 string getStem ( ) { result = getValue ( ) .( PathString ) .getStem ( ) }
210218
219+ /**
220+ * Gets the extension of the folder or file this path refers to, that is, the suffix of the base name
221+ * starting at the last dot character, if there is one.
222+ *
223+ * Has no result if the base name does not contain a dot.
224+ */
225+ string getExtension ( ) { result = getValue ( ) .( PathString ) .getExtension ( ) }
226+
211227 /**
212228 * Gets the file or folder that the first `n` components of this path refer to
213229 * when resolved relative to the root folder of the given `priority`.
0 commit comments