How do I add java-psi-impl which contains JavaElementType to my plugin project?
已回答
I started a new intellij platform plugin project with gradle as it described in the documentation. My gradle.build looks like this (I haven't touched it since its creation):
plugins {
id 'java'
id 'org.jetbrains.intellij' version '0.4.15'
}
group 'com.github.neshkeev.functions'
version '0.0.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
}
// See https://github.com/JetBrains/gradle-intellij-plugin/
intellij {
version '2019.3'
}
patchPluginXml {
changeNotes """
Add change notes here.<br>
<em>most HTML tags may be used</em>"""
}
I need to add new entries for method references (e.g. Objects::toString) into CompletionResultSet, so I added a new CompletionContributor instance:
public class MethodReferenceCompletion extends CompletionContributor {
public MethodReferenceCompletion() {
extend(
CompletionType.BASIC,
PlatformPatterns.psiElement(),
new MethodReferenceCompletionProvider()
);
}
}
And new entries appears for all elements in the completion dialog. If I change the ElementPattern parameter to
PlatformPatterns.psiElement(/* method or ctor */).withParent(JavaElementType.METHOD_REF_EXPRESSION)
the compilation fails, because JavaElementType is not present on the classpath. I discovered that the class belongs to the java-psi-impl module, but it is not available on Maven Central, so I cannot forcibly add it to my build.gradle, how do I add the module?
请先登录再写评论。
Please see https://blog.jetbrains.com/platform/2019/06/java-functionality-extracted-as-a-plugin/
Thank you, it works
I would recommend you to refrain from link only responses, because the link might not be available in future, so the solution will remain unknown. It would be great if you briefly add the key points from the blog.
The blog and the equivalent reference content under "Notes about Module and Plugin Dependency (2)" https://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html are under JetBrains' control, so we will make sure it does not disappear :)