@@ -96,37 +96,34 @@ private class ConsPath extends Path, TConsPath {
96
96
private string pathRegex ( ) { result = "(.*)(?:/|^)(([^/]*?)(\\.([^.]*))?)" }
97
97
98
98
/**
99
- * A string value that represents a (relative or absolute) file system path.
100
- *
101
- * Each path string is associated with one or more root folders relative to
102
- * which the path may be resolved. For instance, paths inside a module are
103
- * usually resolved relative to the module's folder, with a default
104
- * lookup path as the fallback.
99
+ * A `string` with some additional member predicates for extracting parts of a file path.
105
100
*/
106
- abstract class PathString extends string {
101
+ class FilePath extends string {
107
102
bindingset [ this ]
108
- PathString ( ) { any ( ) }
109
-
110
- /** Gets a root folder relative to which this path can be resolved. */
111
- abstract Folder getARootFolder ( ) ;
103
+ FilePath ( ) { any ( ) }
112
104
113
105
/** Gets the `i`th component of this path. */
106
+ bindingset [ this ]
114
107
string getComponent ( int i ) { result = this .splitAt ( "/" , i ) }
115
108
116
109
/** Gets the number of components of this path. */
110
+ bindingset [ this ]
117
111
int getNumComponent ( ) { result = count ( int i | exists ( this .getComponent ( i ) ) ) }
118
112
119
113
/** Gets the base name of the folder or file this path refers to. */
114
+ bindingset [ this ]
120
115
string getBaseName ( ) { result = this .regexpCapture ( pathRegex ( ) , 2 ) }
121
116
122
117
/**
123
118
* Gets stem of the folder or file this path refers to, that is, the prefix of its base name
124
119
* up to (but not including) the last dot character if there is one, or the entire
125
120
* base name if there is not
126
121
*/
122
+ bindingset [ this ]
127
123
string getStem ( ) { result = this .regexpCapture ( pathRegex ( ) , 3 ) }
128
124
129
125
/** Gets the path of the parent folder of the folder or file this path refers to. */
126
+ bindingset [ this ]
130
127
string getDirName ( ) { result = this .regexpCapture ( pathRegex ( ) , 1 ) }
131
128
132
129
/**
@@ -135,8 +132,26 @@ abstract class PathString extends string {
135
132
*
136
133
* Has no result if the base name does not contain a dot.
137
134
*/
135
+ bindingset [ this ]
138
136
string getExtension ( ) { result = this .regexpCapture ( pathRegex ( ) , 4 ) }
139
137
138
+ }
139
+
140
+ /**
141
+ * A string value that represents a (relative or absolute) file system path.
142
+ *
143
+ * Each path string is associated with one or more root folders relative to
144
+ * which the path may be resolved. For instance, paths inside a module are
145
+ * usually resolved relative to the module's folder, with a default
146
+ * lookup path as the fallback.
147
+ */
148
+ abstract class PathString extends FilePath {
149
+ bindingset [ this ]
150
+ PathString ( ) { any ( ) }
151
+
152
+ /** Gets a root folder relative to which this path can be resolved. */
153
+ abstract Folder getARootFolder ( ) ;
154
+
140
155
/**
141
156
* Gets the absolute path that the sub-path consisting of the first `n`
142
157
* components of this path refers to when resolved relative to the
0 commit comments