Add returns class command to common language features - #2271
Add returns class command to common language features#2271ZachWatkins wants to merge 16 commits into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 45267ee4a8
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
I think this is fundamentally the wrong level for this change. If a language has class types, then those class types should be part of the |
|
Feedback from community session. We prefer if this would be part of the |
This pull request is related to issue #2266, PR #2271, and PR #2272. It implements the "returns global class <user.text>" command in ./lang/php/php.talon. PHP uses [namespaces](https://www.php.net/manual/en/language.namespaces.definition.php) for class, interface, function, and constant definitions. Namespaces use the `\` character to declare subnamespaces, and a global namespace reference can be made by prefixing it with `\`. When a namespace is declared, namespace resolution first checks whether proceeding classes and functions are registered in that namespace. Prefixing them with "\" explicitly declares they use the global space. Simple example: ```php <?php namespace App; function currentDate(): \DateTime { return new \DateTime(); } ``` I believe PHP is almost unique in this behavior, which is why I am submitting this PR to add this command to it instead of the common language features. I couldn't find any evidence that coding languages other than C# have a prefix which can declare that a class reference in a type definition must resolve to the global namespace instead of the current namespace.
I will work on the changes you requested. Thank you for merging my PRs for PHP language features. |
I have implemented a change which intercepts |
|
Question for backlog session: Should we prefix the user types? |
…ommon-language-features
for more information, see https://pre-commit.ci
…functions.py as requested
for more information, see https://pre-commit.ci
|
I've made the requested changes, but as implemented my solution at this point causes the phrase "returns class date time" to insert |
|
After applying the latest changes, the following phrases resolve in a PHP file as follows: "returns class date time" -> When not speaking the word "class", these are the results: "returns date time" -> Edit: It was not acceptable to have the context capture insert arbitrary user text, so I've modified the PR. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2e7e5e0c4d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
This pull request is related to issue #2266. It implements the "returns class <user.text>" command in
./lang/tags/functions.talon.Since
./core/snippets/snippets/classDeclaration.snippetuses PUBLIC_CAMEL_CASE as the only insertion formatter, I will assume it is fine to use for this new command.I will submit a separate PR for the "returns global class <user.text>" command, since I am not sure whether it would be useful for languages other than PHP.