idea-php-symfony2-plugin icon indicating copy to clipboard operation
idea-php-symfony2-plugin copied to clipboard

Expression Language support

Open adamwojs opened this issue 3 years ago • 2 comments

Added support for Expression Language component (https://symfony.com/doc/current/components/expression_language.html)

TODO

  • [X] Impl. Parser
  • [X] Impl. Syntax Highlighter
  • [x] Impl. Syntax Highlighter settings
  • [X] Impl. Brace Matcher
  • [X] Impl. Quote Handler

Auto inject expression language into:

  • [X] \Symfony\Component\ExpressionLanguage\ExpressionLanguage::{evaluate,compile,parse}
  • [x] \Symfony\Component\ExpressionLanguage\Expression::__construct
  • [x] https://symfony.com/doc/current/routing.html#matching-expressions
  • [x]     ├ Annotation
  • [x]     ├ Attribute
  • [x]     ├ PHP
  • [x]     ├ YAML
  • [x]     └ XML
  • [ ] https://symfony.com/doc/current/reference/constraints/Expression.html
  • [x]     ├ Annotation
  • [x]     ├ Attribute
  • [x]     ├ PHP
  • [ ]     ├ YAML
  • [ ]     └ XML
  • [ ] ~https://symfony.com/doc/current/reference/twig_reference.html#expression~ Missing PsiLanguageInjectionHost impl. on TwigCompositeElement
  • [x] https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/security.html#security
  • [x]     ├ Annotation
  • [x]     └ Attribute
  • [x] https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/cache.html#http-validation-strategies
  • [x]     ├ Annotation
  • [x]     └ Attribute
  • [x] https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html#fetch-via-an-expression
  • [x]     ├ Annotation
  • [x]     └ Attribute
  • [x] https://symfony.com/doc/current/service_container/expression_language.html
  • [x]     ├ PHP
  • [x]     ├ YAML
  • [x]     └ XML
  • [ ] ...

Note for reviewers

Expression Language parser

  • Implementation is mainly based on https://plugins.jetbrains.com/docs/intellij/custom-language-support-tutorial.html and is placed under fr.adrienbrault.idea.symfony2plugin.expressionLanguage package
  • Expression language lexer & parser are generated from ExpressionLanguage.bnf and ExpressionLanguage.flex files as part of the plugin build process using https://github.com/JetBrains/gradle-grammar-kit-plugin
  • Expression Language grammar is based on https://github.com/JetBrains/Grammar-Kit/blob/master/HOWTO.md#24-compact-expression-parsing-with-priorities

Language Injections

  • Deprecated fr.adrienbrault.idea.symfony2plugin.lang.ParameterLanguageInjector in favour of fr.adrienbrault.idea.symfony2plugin.lang.StringLiteralLanguageInjector
  • In compare to previous impl. StringLiteralLanguageInjector allows inject language into string literals used in various contexts: Attributes, Annotations, Constructor/Function/Method call argument, Variable assigment and also takes into account named arguments introduced in PHP 8
  • Expression Language is injected into YAML/XML files by YamlLanguageInjector / XmlLanguageInjector

Links

  • https://plugins.jetbrains.com/docs/intellij/custom-language-support-tutorial.html
  • https://github.com/JetBrains/Grammar-Kit/blob/master/HOWTO.md#24-compact-expression-parsing-with-priorities
  • https://github.com/JetBrains/gradle-grammar-kit-plugin
  • https://symfony.com/doc/current/components/expression_language/syntax.html

adamwojs avatar Jun 03 '21 17:06 adamwojs

I had the same idea in mind a while ago. But since it's time consuming i didn't start working on it.

Sounds good! 👍

Is it possible to (auto-)inject it inside DocTags and/or PHP8 attributes?

King2500 avatar Jun 03 '21 18:06 King2500

Thank you for feedback @King2500!

Is it possible to (auto-)inject it inside DocTags and/or PHP8 attributes?

Yes, I think it's possible. I will go through symfony documentation and try identify all possible spots before moving PR from draft to "Ready for review" state.

adamwojs avatar Jun 04 '21 09:06 adamwojs