当前位置: 首页 > news >正文

爱看视频的网站方城网站建设

爱看视频的网站,方城网站建设,千度搜索引擎,软件公司简介简介 Code Vision Hints是idea Inlay提示中的一种类型#xff0c;它只能提供block类型的inlay#xff0c;可以把它添加到字段、方法、类等上面#xff0c;一个元素如果包含多个提示的话#xff0c;这些inlay会被展示在同一行上。 Code vision hints可以展示在元素的上面、…简介 Code Vision Hints是idea Inlay提示中的一种类型它只能提供block类型的inlay可以把它添加到字段、方法、类等上面一个元素如果包含多个提示的话这些inlay会被展示在同一行上。 Code vision hints可以展示在元素的上面、右边、或者行末尾具体展示的位置可以在IDE中修改Preferences | Editor | Inlay Hints | Code vision。 目前已经有许多的插件都使用了Inlay例如 Java代码中会在链式调用的每行展示返回类型信息版本控制的项目中会展示提交者信息 有两个扩展点可以用于实现code vision: DaemonBoundCodeVisionProvider : PSI改变后会得到通知例如usages其他文件变动后会继续计算被使用信息CodeVisionProvider : 不依赖PSI改变通知例如git的提交信息。 目前在2022.2这个版本测试中发现CodeVisionProvider有很多bug很多废弃的方法也需要实现也许在新版本已经解决了这个问题如果你依赖IDE版本较老建议还是直接实现DaemonBoundCodeVisionProvider。 实现实例 新建VisionProvider的实现类 public class MyVisionProvider implements DaemonBoundCodeVisionProvider {public static final String GROUP_ID com.demo;public static final String ID myPlugin;public static final String NAME my plugin;NotNullOverridepublic CodeVisionAnchorKind getDefaultAnchor() {// 默认展示在元素的顶部return CodeVisionAnchorKind.Top;}NotNullOverridepublic String getId() {return ID;}NotNullOverridepublic String getGroupId() {return GROUP_ID;}NlsNotNullOverridepublic String getName() {return NAME;}NotNullOverridepublic ListCodeVisionRelativeOrdering getRelativeOrderings() {// 设置展示顺序为第一个return List.of(CodeVisionRelativeOrdering.CodeVisionRelativeOrderingFirst.INSTANCE);}// 设置展示场景java文件的方法上展示NotNullOverridepublic ListPairTextRange, CodeVisionEntry computeForEditor(NotNull Editor editor, NotNull PsiFile file) {ListPairTextRange, CodeVisionEntry lenses new ArrayList();String languageId file.getLanguage().getID();if (!JAVA.equalsIgnoreCase(languageId)) {return lenses;}SyntaxTraverserPsiElement traverser SyntaxTraverser.psiTraverser(file);for (PsiElement element : traverser) {if (!(element instanceof PsiMethod)) {continue;}if (!InlayHintsUtils.isFirstInLine(element)) {continue;}String hint getName();TextRange range InlayHintsUtils.INSTANCE.getTextRangeWithoutLeadingCommentsAndWhitespaces(element);lenses.add(new Pair(range, new ClickableTextCodeVisionEntry(hint, getId(), new MyClickHandler((PsiMethod) element), null, hint, , List.of())));}return lenses;}NotNullOverrideDeprecatedpublic ListPairTextRange, CodeVisionEntry computeForEditor(NotNull Editor editor) {// 过时方法不用实现return List.of();}// Inlay被点击后的处理逻辑Overridepublic void handleClick(NotNull Editor editor, NotNull TextRange textRange, NotNull CodeVisionEntry entry) {if (entry instanceof CodeVisionPredefinedActionEntry) {((CodeVisionPredefinedActionEntry)entry).onClick(editor);}}RequiredArgsConstructorstatic class MyClickHandler implements Function2MouseEvent, Editor, Unit {private final PsiMethod psiMethod;// 点击inlay后的响应打开一个popup显示一组菜单public Unit invoke(MouseEvent event, Editor editor) {TextRange range InlayHintsUtils.INSTANCE.getTextRangeWithoutLeadingCommentsAndWhitespaces(psiMethod);int startOffset range.getStartOffset();int endOffset range.getEndOffset();editor.getSelectionModel().setSelection(startOffset, endOffset);AnAction action1 ActionManager.getInstance().getAction(MyPlugin.Action1);AnAction action2 ActionManager.getInstance().getAction(MyPlugin.Action2);DefaultActionGroup actionGroup new DefaultActionGroup(List.of(action1, action2));ListPopup popup JBPopupFactory.getInstance().createActionGroupPopup(null, actionGroup, EditorUtil.getEditorDataContext(editor), JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, true);popup.show(new RelativePoint(event));return null;}} }注册VisionProvider的实现类 idea-pluginextensions defaultExtensionNscom.intellijcodeInsight.daemonBoundCodeVisionProvider implementationcom.demo.MyVisionProvider//extensions /idea-plugin参考文献 Code Vision Provider
http://www.yutouwan.com/news/41838/

相关文章:

  • 个人可以建设农资网站吗建网站要多少钱一台
  • 网站维护主要是做哪些网站解决方案模板
  • 阿里巴巴 网站 建设宁波外贸公司排行榜
  • 苏州 网站的公司哪家好京东云wordpress后台
  • TP5.1做的网站首页被挂马原因网站开发现在用什么语言
  • 规划建立一个网站如何再网站上做免费广告
  • 软件平台开发公司厦门seo网站建设费用
  • 做平面图片的网站wordpress默认模板
  • 鲜花网站建设的目标网页美工设计需求说明
  • 网站建设的工作内容wordpress插件更新推送
  • 高密专业网站建设价格如何建立一个网站链接的文档
  • 山东春季高考网站建设怎么创建视频网站
  • wp网站打开太慢怎么做优化九一人才网找工作赣州官网
  • 石家庄专业商城网站制作轻媒做的网站
  • 如何做高大上的网站 知乎网站开发人员属于
  • 开发网站开发工程师自建站网站
  • 做商城网站可以个人备案产品拍摄
  • 滨州建设网站旅游网页模板图片
  • 聊城高端网站建设山东网站
  • 北京东直门网站建设pythom 网站开发规范
  • 河南教育平台网站建设软文发布的平台与板块
  • 快捷的网站建设排行榜网站 别名
  • 做招商网站温州市职业中专学校
  • 郑州网站建设优化公司绿色食品网站开发步骤
  • 哪个省份做网站的多专业免费建站
  • 青岛微网站seo网站seo
  • 广西网站网站推广的基本方法为
  • 做网站有什么好处英文网站建设推广
  • 织梦怎么制作网站php 网站出现乱码
  • 免费设计装修公司网站网站备案主体变更