Using PsiShortNamesCache will not automatically import packages after entering the class name and pressing enter

import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiFile;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.PsiShortNamesCache;
import org.jetbrains.annotations.NotNull;
import com.intellij.psi.impl.light.LightClass;
import com.intellij.psi.PsiModifierList;
import com.intellij.psi.PsiManager;
import com.intellij.lang.java.JavaLanguage;
import com.intellij.psi.impl.PsiManagerImpl;
import com.intellij.openapi.project.Project;

public class CustomPsiShortNamesCache extends PsiShortNamesCache {

    private static final String MY_CUSTOM_CLASS_NAME = "MyInjectedClass";
    private final Project myProject;

    public CustomPsiShortNamesCache(Project project) {
        this.myProject = project;
    }

    @Override
    public PsiClass @NotNull [] getClassesByName(@NotNull String name, @NotNull GlobalSearchScope scope) {
        if (MY_CUSTOM_CLASS_NAME.equals(name)) {
            PsiClass customClass = createMyCustomPsiClass(name); 
            return new PsiClass[]{customClass};
        }
        return PsiClass.EMPTY_ARRAY;
    }

    @Override
    public String @NotNull [] getAllClassNames() {
        return new String[]{MY_CUSTOM_CLASS_NAME};
    }

    @Override
    public PsiFile @NotNull [] getFilesByName(@NotNull String name) {
        return PsiFile.EMPTY_ARRAY;
    }


    @Override
    public PsiClass @NotNull [] getClassesByFQName(@NotNull String name, @NotNull GlobalSearchScope scope) {
        return PsiClass.EMPTY_ARRAY;
    }

    @Override
    public String @NotNull [] getAllClassNames(@NotNull GlobalSearchScope scope) {
        return new String[]{MY_CUSTOM_CLASS_NAME};
    }

    private PsiClass createMyCustomPsiClass(String name) {
          PsiFile psiFile = PsiFileFactory.getInstance(project).createFileFromText(
                "MyClass" + ".java",
                JavaLanguage.INSTANCE,
                "package com.myclass.test;\n" +
                        "public interface MyClass{}"
        );

        if (psiFile instanceof PsiJavaFile) {
            return ((PsiJavaFile) psiFile).getClasses()[0];
        }
    }
}
<extensions defaultExtensionNs="com.intellij">
    <psi.shortNamesCache implementation="com.your.package.CustomPsiShortNamesCache"/>
</extensions>

When I enter MyClass and press enter in the code editor, Idea does not automatically insert import com.myclass.test.MyClass at the top of the file, but inserts com.myclass.test.before the current class name;

My expectation is to insert an import at the top when importing a class. What should I do

Can only say that PsiShortNamesCache is not API to implement resolve of PsiClass, it is only used as an actual cache for performance reasons.

The right direction would be