你好 在最新的idea中无法设置<completionService implementation="com.example.MyCompletionService"/>这一属性 你的回答错误
时间: 2023-08-21 09:02:44 浏览: 34
非常抱歉,我的回答有误。在最新版本的 IntelliJ IDEA 中,`<completionService>` 标签已经被弃用,不能再用于声明扩展点。正确的方式是使用 `com.intellij.codeInsight.completion.CompletionContributor` 类来扩展代码自动完成功能。
具体而言,在你的插件中,你需要创建一个类来继承 `CompletionContributor`,并覆盖其中的 `fillCompletionVariants()` 方法,以提供自定义的代码自动完成功能。然后,你需要在 `plugin.xml` 文件中添加如下的代码:
```xml
<extensions defaultExtensionNs="com.intellij">
<completion.contributor implementation="com.example.MyCompletionContributor"/>
</extensions>
```
其中,`implementation` 属性的值应该为你实现的 `CompletionContributor` 类的完整类名。这样,当你的插件被加载时,Idea 就会自动创建并注册一个 `CompletionContributor` 的实例,并将其集成到代码自动完成的功能中。
相关问题
在IDEA的java代码<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> <configuration> <typeAliases> <typeAlias alias="admin" type="com.entil.Admin"/> <typeAlias alias="users" type="com.entity.Users" /> <typeAlias alias="banner" type="com.entity.Banner" /> <typeAlias alias="article" type="com.entity.Article" /> <typeAlias alias="programs" type="com.entity.Programs" /> <typeAlias alias="house" type="com.entity.House" /> <typeAlias alias="money" type="com.entity.Money" /> <typeAlias alias="pays" type="com.entity.Pays" /> <typeAlias alias="serves" type="com.entity.Servs" /> <typeAlias alias="orders" type="com.entity.Orders" /> <typeAlias alias="broken" type="com.entity.Broken" /> <typeAlias alias="complains" type="com.entity.Complains" /> <typeAlias alias="bbs" type="com.entity.Bbs" /> <typeAlias alias="rebus" type="com.entity.Rebbs" /> </typeAliases> <mappers> <mapper resource="mapper/admin.xml" /> <mapper resource="mapper/users.xml" /> <mapper resource="mapper/banner.xml" /> <mapper resource="mapper/article.xml" /> <mapper resource="mapper/programs.xml" /> <mapper resource="mapper/house.xml" /> <mapper resource="mapper/money.xml" /> <mapper resource="mapper/pays.xml" /> <mapper resource="mapper/serves.xml" /> <mapper resource="mapper/orders.xml" /> <mapper resource="mapper/broken.xml" /> <mapper resource="mapper/complains.xml" /> <mapper resource="mapper/bbs.xml" /> <mapper resource="mapper/rebus.xml" /> </mappers> </configuration>你怎么看
这段代码是一个 MyBatis 的配置文件,用于配置 Java 对象和 XML 映射之间的关系,以便使用 MyBatis 进行数据库操作。其中,<typeAliases> 标签用于定义 Java 对象类型别名,方便 MyBatis 映射器中的数据映射;<mappers> 标签用于指定 MyBatis 映射器的位置,即 XML 映射文件。这段配置文件中定义了多个 Java 对象别名和对应的映射器位置,用于对多个数据表进行操作。
我就是这么放得,以下是代码:<idea-plugin> <id>com.your.company.unique.plugin.id</id> <name>wkx_plugin</name> <version>1.0</version> <vendor email="wangkexin6@yourcompany.com" url="http://www.hikvision.com">HikVision</vendor> <!-- description><![CDATA[ xml和excel互相转换插件.<br> <em>www.wkx666.com</em></description --> <!-- change-notes><![CDATA[ Add change notes here.<br> <em>most HTML tags may be used</em> ]]> </change-notes--> <!-- please see https://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description --> <idea-version since-build="173.0"/> <!-- please see https://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html on how to target different products --> <depends>com.intellij.modules.platform</depends> <extensions defaultExtensionNs="com.intellij"> <!-- Add your extensions here --> <actions> <action id="myAction" class="com.example.MyAction" text="My Action" description="My description"> <add-to-group group-id="MainMenu.Tools" anchor="last"/> <keyboard-shortcut first-keystroke="control alt A"/> </actions> </extensions> <actions> <!-- Add your actions here --> </actions> </idea-plugin>
感谢提供您的代码。根据您提供的代码,我注意到您在 `<actions>` 标签中缺少了一个闭合的 `</action>` 标签,导致 XML 结构错误。请将您的代码修改如下:
```xml
<idea-plugin>
<id>com.your.company.unique.plugin.id</id>
<name>wkx_plugin</name>
<version>1.0</version>
<vendor email="wangkexin6@yourcompany.com" url="http://www.hikvision.com">HikVision</vendor>
<!-- description><![CDATA[
xml和excel互相转换插件.<br>
<em>www.wkx666.com</em></description -->
<!-- change-notes><![CDATA[
Add change notes here.<br>
<em>most HTML tags may be used</em>
]]>
</change-notes-->
<!-- please see https://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description -->
<idea-version since-build="173.0"/>
<!-- please see https://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html
on how to target different products -->
<depends>com.intellij.modules.platform</depends>
<extensions defaultExtensionNs="com.intellij">
<!-- Add your extensions here -->
<actions>
<action id="myAction" class="com.example.MyAction" text="My Action" description="My description">
<add-to-group group-id="MainMenu.Tools" anchor="last"/>
<keyboard-shortcut first-keystroke="control alt A"/>
</action> <!-- 添加一个闭合的 </action> 标签 -->
</actions>
</extensions>
<actions>
<!-- Add your actions here -->
</actions>
</idea-plugin>
```
请确保 `<action>` 标签被正确地嵌套在 `<actions>` 标签内,并且每个 `<action>` 标签都有相应的闭合标签 `</action>`。
完成修改后,重新编译和运行插件,您应该能够在 "Tools" 菜单中看到您的新 action。如果问题仍然存在,请提供更多关于错误信息或其他相关代码的详细信息,以便我们能够更好地帮助您解决问题。