Intellij idea插件如何实现代码结构化视图

 时间:2024-10-11 23:00:34

1、创建一个结构化视图工厂类实现PsiStructureViewFactory接口。如图

Intellij idea插件如何实现代码结构化视图

2、创建一个结构化视图的StructureViewModel类,继承自StructureViewModelBase类。如图

Intellij idea插件如何实现代码结构化视图

3、实现StructureViewModel的ElementInfoProvider元素提供器接口,控制是否显示加号和叶子节点。如图

Intellij idea插件如何实现代码结构化视图

4、在结构视图中,想控制排序,需要重写getSorters方法。如图

Intellij idea插件如何实现代码结构化视图

5、创建ProtobufStructureViewElement类,实现StructureV坡纠课柩iewTreeElement, SortableTreeElement接口。如图

Intellij idea插件如何实现代码结构化视图

6、实现相关的排序方法和导航控制方法。如图。

Intellij idea插件如何实现代码结构化视图Intellij idea插件如何实现代码结构化视图Intellij idea插件如何实现代码结构化视图

7、在ProtobufStructureViewModel构造函数中传ProtobufStructureViewElement类实例。如图

Intellij idea插件如何实现代码结构化视图

8、在ProtobufStructureViewFactory类中实例化TreeBasedStructureVi髫潋啜缅ewBuilder,并实现方法createStructureViewModel返回ProtobufStructureViewModel实例。

Intellij idea插件如何实现代码结构化视图Intellij idea插件如何实现代码结构化视图

9、最后代码结构化视图工厂类注册到plugin.xml文件的extensions标签中。运行工程即可。如图

Intellij idea插件如何实现代码结构化视图
  • 怎样使用phpstudy搭建TP5框架的php项目
  • 泡脚需注意哪些事项
  • 空心千斤顶如何使用
  • 糖尿病人应慎吃无糖食品
  • 全自动水泥透水砖机制品裂缝的原因及防护措施
  • 热门搜索
    斗鱼鱼丸怎么获得 儿童学画大全 动漫头像大全 恐龙游戏大全 宝宝起名字大全 健身操视频大全 人民币图片大全 词语接龙大全 抗日电视剧大全 大鹅的做法大全