Skip to content
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

Language injection for CSS, XPath, JSON and DQL #1301

Merged
merged 7 commits into from
May 21, 2019

Conversation

King2500
Copy link
Contributor

@King2500 King2500 commented Apr 12, 2019

This adds automatic language injection for method parameters for the following languages:

  • CSS Selectors and XPath in CssSelector and DomCrawler component
  • JSON for JsonResponse
  • DQL for Doctrine Queries (Parameter for createQuery and $dql = assignments) (JetBrains added official DQL Support since PhpStorm 2018.3, but you had to inject manually or use <<<DQL heredoc)

Advantages:

  • full syntax highlight
  • syntax error check
  • autocompletion

CSS Selectors:
image
and
image

XPath:
image

DQL:
image

I also wrote tests for these injections.

One question for me remains:
Should we add checkboxes to disable these languages injections (by each language) in settings dialog?

@King2500
Copy link
Contributor Author

King2500 commented Apr 12, 2019

I did test the feature locally in 2018.3, 2019.1 and 2019.1.1 Preview

@King2500
Copy link
Contributor Author

King2500 commented Apr 15, 2019

Maybe add Yaml injection for Yaml::parse('yaml here')

(Edit: I rethought this and think it's not very common to have Yaml::parse called with literals directly, so it's not worth injecting this language automatically.)

@King2500 King2500 closed this Apr 15, 2019
@King2500 King2500 reopened this Apr 15, 2019
@@ -611,6 +613,7 @@
<depends>org.jetbrains.plugins.yaml</depends>
<depends>de.espend.idea.php.annotation</depends>

<depends optional="true">com.jetbrains.php.dql</depends>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should make the DQL plugin mandatory. Both from a usability POV, but also because we dont currently check whether the plugin is installed. WDYT?

Suggested change
<depends optional="true">com.jetbrains.php.dql</depends>
<depends>com.jetbrains.php.dql</depends>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IntelliJ is smart enough to handle unknown languages (i.e. DQL plugin is not installed), when calling registrar.startInjecting(language). So there is no need to check that explicitly.

I'm not sure if it is a good idea to have this dependency mandatory. I think there are a lot people out there who only use some Symfony components and thus have the Symfony plugin installed, but don't need/use Doctrine/DQL.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can see, "DQL Support" is bundled by default in PhpStorm. So this affects only people with IntelliJ IDEA Ultimate who have installed PHP plugin manually.

@Haehnchen Haehnchen merged commit b189a8d into Haehnchen:master May 21, 2019
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.

None yet

3 participants