元素格式(Element Patterns)

走着路睡觉大约 2 分钟

元素格式(Element Patterns)

像正则检查一样,插件开发者需要检查PSI元素是否符合特定的结构,所以PSI元素的嵌套结构里设置元素格式 。元素格式在IntelliJ Platform里主要2下面2个应用场景:

插件开发者基本不需要直接实现ElementPatternopen in new window 接口。推荐使用 IntelliJ Platform 封装好的元素格式类,列表如下:

功能示例
StandardPatternsopen in new window字符和字符串的格式;and,or,not之类的逻辑操作的格式LogbackReferenceContributoropen in new window
RegExpCompletionContributoropen in new window
PlatformPatternsopen in new windowFactory for PSI-, IElement-, and VirtualFile-patternsFxmlReferencesContributor
PyDataclassCompletionContributor
PsiElementPatternopen in new windowPSI的父子兄弟格式XmlCompletionContributoropen in new window
CollectionPatternopen in new window过滤和检查collection的格式;Mainly used to provide functionality for other high-level pattern classesPsiElementPatternopen in new window
TreeElementPatternopen in new window检查PSI tree的结构格式PyMetaClassCompletionContributoropen in new window
StringPatternopen in new window检查String的格式,长度,beginWith,endWith,one of collectionAbstractGradleCompletionContributoropen in new window
CharPatternopen in new window检查字符是空格,数字或java标识符CompletionUtilopen in new window

Some built-in languages in the IntelliJ Platform implement their own pattern classes and can provide additional examples:

IntelliJ Platform 上构建的编程语言实现了一些格式类,如下:

示例

--------省略,需要idea支持新编程语言时才需要

上次编辑于:
贡献者: zhaojingbo
Loading...