All languages: Use shared FileSystem library and minor regex performance improvement.#14321
All languages: Use shared FileSystem library and minor regex performance improvement.#14321aschackmull merged 10 commits intogithub:mainfrom
Conversation
| * Gets the absolute path of this container. | ||
| * | ||
| * Typically `containerparent(result, this)`. | ||
| * Typically `folders(this, result) or files(this, result)`. |
There was a problem hiding this comment.
Now that we are touching this file anyway, could we make the three user-facing classes Container, Folder, and File final through final aliases, make the existing classes private and add an Impl suffix to the name, and make ContainerImpl and ContainerImpl::getUrl abstract?
There was a problem hiding this comment.
That causes the need for all sorts of cascading changes throughout the Java class hierarchy. And maybe also for the some of the other languages. So I'm not going to try to fit that into this PR.
yoff
left a comment
There was a problem hiding this comment.
Looks fine from the Python side. Just a few questions to make sure I understand the refactor.
| ) | ||
| } | ||
| class Container extends Impl::Container { | ||
| Container getParent() { result = this.getParentContainer() } |
There was a problem hiding this comment.
Looks like we have an extra class predicate here that we should clean up (users should just use getParentContainer instead)?
There was a problem hiding this comment.
Yeah, I didn't want to change things so I just left it in.
There was a problem hiding this comment.
That is fine, we can clean it up later :-)
| } | ||
|
|
||
| Container getParentContainer() { this = result.getAChildContainer() } | ||
| override Container getParentContainer() { result = super.getParentContainer() } |
There was a problem hiding this comment.
This is needed in order to cast the result?
There was a problem hiding this comment.
Yes. It's used elsewhere to implement a signature so the exact return type is needed.
Looks like C++ might need updated test expectations. |
Mmm, I must have mis-clicked when looking at the test regressions. I didn't see that. I'd actually like to know why this changes. This seems somewhat suspect. |
Previously C++ didn't have a |
Looking at the test, I think |
|
Maybe |
Yup. So, I'm happy with just accepting the test change. I do think we maybe should consider deprecating/removing |
Or the opposite. Remove |
That also makes sense. I don't have any particular preference here. |
721cdc0 to
80f00bc
Compare
In any case, I think that's best handled as follow-up. |
Agreed. |
This switches C++, Go, Java, JavaScript, Python, and QL to the shared FileSystem library as a followup to #12289.
I've also made a small performance tweak to the regex matching that extracts base name, stem, and extension from absolute file paths by reusing the same regex instead of calculating the same match 3 times.
Fixes https://github.com/github/codeql-c-team/issues/1598 and https://github.com/github/codeql-go-team/issues/325