|
57 | 57 | */ |
58 | 58 |
|
59 | 59 | private import Impl as Impl |
| 60 | +import AccessPathSyntax |
60 | 61 |
|
61 | 62 | private class Unit = Impl::Unit; |
62 | 63 |
|
@@ -257,31 +258,16 @@ predicate isRelevantFullPath(string package, string type, string path) { |
257 | 258 | ) |
258 | 259 | } |
259 | 260 |
|
260 | | -/** |
261 | | - * A string that occurs as an access path (either identifying or input/output spec) |
262 | | - * which might be relevant for this database. |
263 | | - */ |
264 | | -class AccessPath extends string { |
265 | | - AccessPath() { |
| 261 | +/** A string from a CSV row that should be parsed as an access path. */ |
| 262 | +private class AccessPathRange extends AccessPath::Range { |
| 263 | + AccessPathRange() { |
266 | 264 | isRelevantFullPath(_, _, this) |
267 | 265 | or |
268 | 266 | exists(string package | isRelevantPackage(package) | |
269 | 267 | summaryModel(package, _, _, this, _, _) or |
270 | 268 | summaryModel(package, _, _, _, this, _) |
271 | 269 | ) |
272 | 270 | } |
273 | | - |
274 | | - /** Gets the `n`th token on the access path as a string. */ |
275 | | - string getRawToken(int n) { |
276 | | - this != "" and // The empty path should have zero tokens, not a single empty token |
277 | | - result = this.splitAt(".", n) |
278 | | - } |
279 | | - |
280 | | - /** Gets the `n`th token on the access path. */ |
281 | | - AccessPathToken getToken(int n) { result = this.getRawToken(n) } |
282 | | - |
283 | | - /** Gets the number of tokens on the path. */ |
284 | | - int getNumToken() { result = count(int n | exists(this.getRawToken(n))) } |
285 | 271 | } |
286 | 272 |
|
287 | 273 | /** |
@@ -431,35 +417,6 @@ private API::Node getNodeFromInputOutputPath(API::InvokeNode baseNode, AccessPat |
431 | 417 | result = getNodeFromInputOutputPath(baseNode, path, path.getNumToken()) |
432 | 418 | } |
433 | 419 |
|
434 | | -/** |
435 | | - * An access part token such as `Argument[1]` or `ReturnValue`, appearing in one or more access paths. |
436 | | - */ |
437 | | -class AccessPathToken extends string { |
438 | | - AccessPathToken() { this = any(AccessPath path).getRawToken(_) } |
439 | | - |
440 | | - private string getPart(int part) { |
441 | | - result = this.regexpCapture("([^\\[]+)(?:\\[([^\\]]*)\\])?", part) |
442 | | - } |
443 | | - |
444 | | - /** Gets the name of the token, such as `Member` from `Member[x]` */ |
445 | | - string getName() { result = this.getPart(1) } |
446 | | - |
447 | | - /** |
448 | | - * Gets the argument list, such as `1,2` from `Member[1,2]`, |
449 | | - * or has no result if there are no arguments. |
450 | | - */ |
451 | | - string getArgumentList() { result = this.getPart(2) } |
452 | | - |
453 | | - /** Gets the `n`th argument to this token, such as `x` or `y` from `Member[x,y]`. */ |
454 | | - string getArgument(int n) { result = this.getArgumentList().splitAt(",", n) } |
455 | | - |
456 | | - /** Gets an argument to this token, such as `x` or `y` from `Member[x,y]`. */ |
457 | | - string getAnArgument() { result = this.getArgument(_) } |
458 | | - |
459 | | - /** Gets the number of arguments to this token, such as 2 for `Member[x,y]` or zero for `ReturnValue`. */ |
460 | | - int getNumArgument() { result = count(int n | exists(this.getArgument(n))) } |
461 | | -} |
462 | | - |
463 | 420 | /** |
464 | 421 | * Convenience-predicate for extracting two capture groups at once. |
465 | 422 | */ |
|
0 commit comments