CodeCompletion not work after set language of LanguageTextField

Answered

Full  demo code

import com.google.common.collect.Lists;
import com.intellij.icons.AllIcons;
import com.intellij.json.json5.Json5Language;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.ui.TextFieldWithAutoCompletion;
import com.intellij.util.textCompletion.TextCompletionUtil;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;

public class DemoDialogWrapper extends DialogWrapper {
    private final Project project;

    public DemoDialogWrapper(@Nullable Project project) {
        super(project, false);
        this.project = project;
        init();
        setSize(400, 300);
        setTitle("demo");
    }


    @Override
    protected @Nullable JComponent createCenterPanel() {
        TextFieldWithAutoCompletion.StringsCompletionProvider completionProvider = new TextFieldWithAutoCompletion.StringsCompletionProvider(Lists.newArrayList("a", "b"), AllIcons.Nodes.Method);
        TextCompletionUtil.DocumentWithCompletionCreator documentWithCompletionCreator = new TextCompletionUtil.DocumentWithCompletionCreator(completionProvider, false, false);
        return new com.intellij.ui.LanguageTextField(com.intellij.json.json5.Json5Language.INSTANCE, project, "", documentWithCompletionCreator, false);
        
        //Change Json5Language.INSTANCE to com.intellij.openapi.fileTypes.PlainTextLanguage 
        //CodeCompletion works

    }
}

 

Another img: https://intellij-support.jetbrains.com/hc/user_images/01J538QGB96BMPDMDMB3BF7RP7.png

0

Post is closed for comments.