如何在 PhpStorm 中按位置模式自动注入语言以实现功能



如何配置 PhpStorm 以自动在函数调用中注入 Bash run(...)?例如,我想在这里注入 bash:

run("mv source dest && echo 'bash';");

这不起作用:

+ phpLiteralExpression().withText("run")

尝试以下位置模式:

+ phpLiteralExpression().withSuperParent(2, phpFunctionReference().withText(string().startsWith("run(")))
不幸的是,没有

关于此功能的文档,实际上文档特别警告:

这些规则是 PhpStorm 内部规则,强烈建议您使用预定义的注入配置并避免创建新的注入配置。

因此,在实践中有必要查看IntelliJ IDEA的来源。感兴趣的类是com.intellij.patterns.PlatformPatterns类和com.intellij.patterns.PsiElementPattern类及其各种超类。

最新更新