Injected language completion error
Hello. I'm trying to develop custom language plugin for Rythm template engine.
I implemented Java language injection via LanguageInjector interface.
public class RythmJavaInjector implements LanguageInjector {
@Override public void getLanguagesToInject(@NotNull PsiLanguageInjectionHost psiLanguageInjectionHost, @NotNull InjectedLanguagePlaces injectedLanguagePlaces) { if (psiLanguageInjectionHost instanceof RythmJavaCodeLiteral) { RythmJavaCodeLiteral literal = (RythmJavaCodeLiteral) psiLanguageInjectionHost; injectedLanguagePlaces.addPlace(JavaLanguage.INSTANCE, new TextRange(0, literal.getTextLength()), "class Test{", "}"); } } }
Language injection works well, except completion of variable declaration.
When i'm typing something like "BufferedRe.." and press Alt+Enter for autocompletion - i've got an exception:
[1451518] ERROR - Insight.lookup.impl.LookupImpl - import java.io.BufferedReader;class Test{ java.io.BufferedReader }/class Test{ java.lang.AssertionError: import java.io.BufferedReader;class Test{ java.io.BufferedReader }/class Test{ at com.intellij.injected.editor.DocumentWindowImpl.calculateMinEditSequence(DocumentWindowImpl.java:808) at com.intellij.psi.impl.source.tree.injected.InjectedFileViewProvider.rootChanged(InjectedFileViewProvider.java:76) at com.intellij.psi.impl.source.PsiFileImpl.subtreeChanged(PsiFileImpl.java:443) at com.intellij.psi.impl.source.PsiJavaFileBaseImpl.subtreeChanged(PsiJavaFileBaseImpl.java:82) at com.intellij.psi.impl.source.tree.CompositeElement.subtreeChanged(CompositeElement.java:99) at com.intellij.psi.impl.source.tree.CompositeElement.rawAddChildren(CompositeElement.java:803) at com.intellij.psi.impl.source.tree.CompositeElement.add(CompositeElement.java:877) at com.intellij.psi.impl.source.tree.CompositeElement.access$100(CompositeElement.java:51) at com.intellij.psi.impl.source.tree.CompositeElement$2.makeChange(CompositeElement.java:653) at com.intellij.psi.impl.source.tree.ChangeUtil$1.runInner(ChangeUtil.java:175) at com.intellij.pom.impl.PomTransactionBase.run(PomTransactionBase.java:44) at com.intellij.pom.core.impl.PomModelImpl.runTransaction(PomModelImpl.java:151) at com.intellij.psi.impl.source.tree.ChangeUtil.prepareAndRunChangeAction(ChangeUtil.java:169) at com.intellij.psi.impl.source.tree.CompositeElement.addChild(CompositeElement.java:646) at com.intellij.psi.impl.source.tree.CompositeElement.addChildren(CompositeElement.java:753) at com.intellij.psi.impl.source.codeStyle.CodeEditUtil.addChildren(CodeEditUtil.java:82) at com.intellij.psi.impl.source.tree.CompositeElement.addInternal(CompositeElement.java:532) at com.intellij.psi.impl.source.tree.java.ImportListElement.addInternal(ImportListElement.java:45) at com.intellij.psi.impl.source.JavaStubPsiElement.add(JavaStubPsiElement.java:79) at com.intellij.psi.impl.source.codeStyle.ImportHelper.addImport(ImportHelper.java:435) at com.intellij.psi.impl.source.codeStyle.JavaCodeStyleManagerImpl.addImport(JavaCodeStyleManagerImpl.java:130) at com.intellij.psi.impl.source.PsiJavaFileBaseImpl.importClass(PsiJavaFileBaseImpl.java:426) at com.intellij.psi.impl.source.codeStyle.JavaReferenceAdjuster.getClassReferenceToShorten(JavaReferenceAdjuster.java:244) at com.intellij.psi.impl.source.codeStyle.JavaReferenceAdjuster.makeShortReference(JavaReferenceAdjuster.java:218) at com.intellij.psi.impl.source.codeStyle.JavaReferenceAdjuster.process(JavaReferenceAdjuster.java:110) at com.intellij.psi.impl.source.codeStyle.JavaReferenceAdjuster.process(JavaReferenceAdjuster.java:135) at com.intellij.psi.impl.source.codeStyle.JavaCodeStyleManagerImpl.shortenClassReferences(JavaCodeStyleManagerImpl.java:80) at com.intellij.psi.impl.source.PsiJavaCodeReferenceElementImpl.bindToClass(PsiJavaCodeReferenceElementImpl.java:587) at com.intellij.psi.impl.source.PsiJavaCodeReferenceElementImpl.bindToElement(PsiJavaCodeReferenceElementImpl.java:515) at com.intellij.codeInsight.completion.JavaCompletionUtil.insertClassReference(JavaCompletionUtil.java:674) at com.intellij.codeInsight.lookup.PsiTypeLookupItem.addImportForItem(PsiTypeLookupItem.java:294) at com.intellij.codeInsight.completion.JavaClassNameInsertHandler.handleInsert(JavaClassNameInsertHandler.java:95) at com.intellij.codeInsight.completion.JavaClassNameInsertHandler.handleInsert(JavaClassNameInsertHandler.java:39) at com.intellij.codeInsight.lookup.LookupItem.handleInsert(LookupItem.java:193) at com.intellij.codeInsight.completion.CodeCompletionHandlerBase$9.run(CodeCompletionHandlerBase.java:721) at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:984) at com.intellij.codeInsight.completion.CodeCompletionHandlerBase.insertItem(CodeCompletionHandlerBase.java:711) at com.intellij.codeInsight.completion.CodeCompletionHandlerBase.access$400(CodeCompletionHandlerBase.java:72) at com.intellij.codeInsight.completion.CodeCompletionHandlerBase$7.perform(CodeCompletionHandlerBase.java:630) at com.intellij.injected.editor.CaretModelWindow$2.perform(CaretModelWindow.java:256) at com.intellij.openapi.editor.impl.CaretModelImpl$3.run(CaretModelImpl.java:353) at com.intellij.openapi.editor.impl.CaretModelImpl.doWithCaretMerging(CaretModelImpl.java:424) at com.intellij.openapi.editor.impl.CaretModelImpl.runForEachCaret(CaretModelImpl.java:347) at com.intellij.injected.editor.CaretModelWindow.runForEachCaret(CaretModelWindow.java:253) at com.intellij.codeInsight.completion.CodeCompletionHandlerBase.insertItemHonorBlockSelection(CodeCompletionHandlerBase.java:627) at com.intellij.codeInsight.completion.CodeCompletionHandlerBase.lookupItemSelected(CodeCompletionHandlerBase.java:568) at com.intellij.codeInsight.completion.CompletionProgressIndicator$2.itemSelected(CompletionProgressIndicator.java:110) at com.intellij.codeInsight.lookup.impl.LookupImpl.fireItemSelected(LookupImpl.java:1055) at com.intellij.codeInsight.lookup.impl.LookupImpl.finishLookup(LookupImpl.java:673) at com.intellij.codeInsight.lookup.impl.LookupImpl.finishLookup(LookupImpl.java:612) at com.intellij.codeInsight.lookup.impl.actions.ChooseItemAction$Handler.execute(ChooseItemAction.java:73) at com.intellij.openapi.editor.actionSystem.EditorActionHandler.doExecute(EditorActionHandler.java:93) at com.intellij.openapi.editor.actionSystem.EditorActionHandler.execute(EditorActionHandler.java:125) at com.intellij.openapi.editor.actionSystem.EditorAction$1.run(EditorAction.java:83) at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:124) at com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:94) at com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:68) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher$3.performAction(IdeKeyEventDispatcher.java:564) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:611) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.inInitState(IdeKeyEventDispatcher.java:463) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:206) at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:493) at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:335) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:82) [1451518] ERROR - Insight.lookup.impl.LookupImpl - IntelliJ IDEA 13.1.1 Build #IC-135.480 [1451518] ERROR - Insight.lookup.impl.LookupImpl - JDK: 1.8.0-ea [1451518] ERROR - Insight.lookup.impl.LookupImpl - VM: Java HotSpot(TM) 64-Bit Server VM [1451518] ERROR - Insight.lookup.impl.LookupImpl - Vendor: Oracle Corporation [1451518] ERROR - Insight.lookup.impl.LookupImpl - OS: Linux [1451518] ERROR - Insight.lookup.impl.LookupImpl - Last Action: EditorChooseLookupItem [1451518] ERROR - Insight.lookup.impl.LookupImpl - Current Command: Choose Lookup Item
But if i change injection prefix from "class Test{" to "" - autocompletion works without exceptions.
Tell me please, what I'm doing wrong
Please sign in to leave a comment.
Did you solved the problem?
I'm also trying to develop a plugin for rythm template engine.
I would really appreciate it if you could help me.