-
Notifications
You must be signed in to change notification settings - Fork 1.8k
All languages: Use shared FileSystem library and minor regex performance improvement. #14321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Go 👍🏻
@@ -11,11 +11,15 @@ signature module InputSig { | |||
/** | |||
* 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I didn't want to change things so I just left it in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed in order to cast the result?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. It's used elsewhere to implement a signature so the exact return type is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C++ 👍
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