XML : Intellij Completion Contributor

i am developing a plugin for intellij and i want to add custom sugestions to xml editor based on a xsd. up to now i can get required suggestions from xsd file. i have implemented a completion contributor for xml as follows `

      import com.intellij.codeInsight.completion.*;      import com.intellij.codeInsight.lookup.LookupElementBuilder;      import com.intellij.patterns.PlatformPatterns;      import com.intellij.psi.xml.XmlElementType;      import com.intellij.util.ProcessingContext;      import com.intellij.lang.xml.*;`      import org.jetbrains.annotations.NotNull;          public class SimpleCompletionContributor extends CompletionContributor {      public SimpleCompletionContributor() {      extend(CompletionType.BASIC,PlatformPatterns.psiElement(XmlElementType.XML_ATTRIBUTE_VALUE).withLanguage(XMLLanguage.INSTANCE),              new CompletionProvider<CompletionParameters>() {                  public void addCompletions(@NotNull CompletionParameters parameters,                                             ProcessingContext context,                                             @NotNull CompletionResultSet resultSet) {                      resultSet.addElement(LookupElementBuilder.create("Hello"));                  }              }      );  }    

} but this did not provide any suggestion. but when i implement custom language it works. My objective is to view the context of the cursor position and provide suggestion based on it. as an example when user starts a tag on xml file plugin should provide attributes as code completion. I'm new to this Custom language. so can anyone help me with this completion contributor

No comments:

Post a Comment