# Implementing JvmElementProvider does not automatically add imports

**URL:** <https://platform.jetbrains.com/t/implementing-jvmelementprovider-does-not-automatically-add-imports/3326>\
**Category:** IntelliJ Platform\
**Tags:** plugin-development\
**Created:** [December 13, 2025, 5:40am UTC](https://platform.jetbrains.com/t/implementing-jvmelementprovider-does-not-automatically-add-imports/3326 "2025-12-13T05:40:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hxl49508](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/hxl49508/32/1117_2.png) [@hxl49508](https://platform.jetbrains.com/u/hxl49508)\
**Post date:** [December 13, 2025, 5:40am UTC](https://platform.jetbrains.com/t/implementing-jvmelementprovider-does-not-automatically-add-imports/3326/1 "2025-12-13T05:40:36Z")

</div>

I have implemented the `JvmElementProvider` interface and created a `PsiFile` using `PsiFileFactory.getInstance(project).createFileFromText`. The code is as follows:

```auto
PsiFile psiFile = PsiFileFactory.getInstance(project).createFileFromText(
                "demo.java", 
                JavaFileType.INSTANCE, "xxx");

```

I have also implemented `PsiShortNamesCache`. While coding, code completion works fine, but during auto-import, IDEA does not automatically add import statements. Instead, it completes the class name with its fully qualified name. During debugging, I found that an exception was thrown in the following code.

 ![image](https://us1.discourse-cdn.com/flex001/uploads/jetbrains_platform/original/2X/a/af5806d08574786774793cb5e867dbd9267b0cec.png)  
 ![image](https://us1.discourse-cdn.com/flex001/uploads/jetbrains_platform/original/2X/b/bffe2439682bce00cd6f87a13aa38cc9d412e93f.png)

My expectation was for IDEA to automatically import the necessary package.
