Skip to content

Add QuickFix links for missing configs and translations#443

Open
N1ebieski wants to merge 31 commits intolaravel:mainfrom
N1ebieski:Improvements-for-linked-parameter-vscodeDiagnosticcode-for-diagnosticProvider-#55
Open

Add QuickFix links for missing configs and translations#443
N1ebieski wants to merge 31 commits intolaravel:mainfrom
N1ebieski:Improvements-for-linked-parameter-vscodeDiagnosticcode-for-diagnosticProvider-#55

Conversation

@N1ebieski
Copy link
Contributor

@N1ebieski N1ebieski commented Aug 24, 2025

This PR improves my previous PR #415

  1. Currently clicking on the link in the popover takes the user to the file. This PR adds support for a specific line where the new key should be inserted if the new key has a parent, for example:

ezgif-63208729a3c33e

  1. PR adds support for .env values:
obraz

@TitasGailius
Copy link
Collaborator

hey @N1ebieski,

This is a great feature. Thanks for working on it!

For environment variables, we currently have a "quick fix" in place:

Screenshot 2025-12-18 at 16 56 01

Would it be possible to add something similar for translations, instead of linking to them from the hover card?

@TitasGailius TitasGailius marked this pull request as draft December 18, 2025 15:00
@N1ebieski
Copy link
Contributor Author

N1ebieski commented Dec 20, 2025

@TitasGailius This wasn't easy to achieve...

config
trans

Needs more testing.

Contains #513

@N1ebieski N1ebieski marked this pull request as ready for review December 20, 2025 13:34
@N1ebieski N1ebieski marked this pull request as draft December 21, 2025 10:00
@N1ebieski N1ebieski marked this pull request as ready for review December 21, 2025 10:07
@N1ebieski N1ebieski marked this pull request as draft December 22, 2025 11:41
@N1ebieski
Copy link
Contributor Author

Changes required according to: #513 (comment)

@N1ebieski N1ebieski marked this pull request as ready for review December 22, 2025 19:44
@N1ebieski
Copy link
Contributor Author

@TitasGailius ok, summary:

  1. I’ve removed the hover links and reverted the changes from Fix for QuickFix for vscode.Diagnostic.code #513
  2. There are only "QuickFix" links:
  • Add config to the file
  • Add translation to the PHP file
  • Add translation to the JSON file
  1. Translation supports the locale parameter

@TitasGailius TitasGailius marked this pull request as draft December 29, 2025 11:13
@N1ebieski N1ebieski marked this pull request as ready for review December 29, 2025 12:54
@TitasGailius
Copy link
Collaborator

@N1ebieski this is much simpler now. Thanks.

One thought: since we already have all available config paths in getConfigs().items.configs, would it make sense to simply check for a match recursively?

For example, for nested.feature.item we could try, in order:

  • nested.feature.item
  • nested.feature
  • nested

And if none match, we skip the code action.

@N1ebieski
Copy link
Contributor Author

@TitasGailius We can do this for configs, but probably not for translations, because they only contain final keys. Did you check this?

@TitasGailius
Copy link
Collaborator

@N1ebieski you're right. We can do this for configs, but not for translations.

@N1ebieski
Copy link
Contributor Author

N1ebieski commented Dec 29, 2025

@TitasGailius OK, let me know if I understand this correctly. Let’s assume we have a nested.php config file with the following contents:

return [
   'feature' => [
      'item' => 'value'
   ]
];

The user wants to access config('nested.new-feature.new-item'), so the extension recursively searches as follows:

  1. nested.new-feature (not found),
  2. nested (found).

As a result, it adds the following to the file:

return [
   'new-feature' => [
      'new-item' => ''
   ],
   'feature' => [
      'item' => 'value'
   ]
];

@TitasGailius
Copy link
Collaborator

@N1ebieski yep, I think that would cover all cases. Unless you have a better idea. 🙂

@N1ebieski N1ebieski marked this pull request as draft December 29, 2025 13:54
@N1ebieski
Copy link
Contributor Author

N1ebieski commented Dec 30, 2025

@TitasGailius another summary:

  1. I've changed the logic to support nested keys, according to Add QuickFix links for missing configs and translations #443 (comment)
  2. For configs the code is simpler, because we have all the keys in the repository
  3. For translations the code is more complicated, because we only have the final keys. I don't have a better idea how to simplify this further. I'm afraid that without changes of php-templates/translations.php this is impossible, but I would prefer to avoid modifying this file (so many other features depend on it)

ezgif-2820d1e8bf0f22b5

@N1ebieski N1ebieski marked this pull request as ready for review December 30, 2025 14:21
@N1ebieski N1ebieski changed the title Improvements for linked parameter vscode.Diagnostic.code for diagnosticProvider Add QuickFix links for missing configs and translations Dec 30, 2025
@N1ebieski N1ebieski marked this pull request as draft December 30, 2025 17:06
@N1ebieski N1ebieski marked this pull request as ready for review December 30, 2025 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants