CompletionContributor help

Hello,

I've plugged in a CompletionContributor, however before it gets to return the variants I'm getting an Exception.

With a newly-created / completely empty file in my custom language, hitting ctrl-space gives this:

[ 333641]  ERROR - llij.ide.plugins.PluginManager - Wrong end: 3; document length=0; start=3 
java.lang.IllegalArgumentException: Wrong end: 3; document length=0; start=3
     at com.intellij.openapi.editor.impl.RangeMarkerImpl.<init>(RangeMarkerImpl.java:47)
     at com.intellij.openapi.editor.impl.DocumentImpl.createRangeMarker(DocumentImpl.java:303)
     at com.intellij.codeInsight.completion.OffsetMap.addOffset(OffsetMap.java:68)
     at com.intellij.codeInsight.completion.CompletionInitializationContext.<init>(CompletionInitializationContext.java:58)
     at com.intellij.codeInsight.completion.CodeCompletionHandlerBase$2.run(CodeCompletionHandlerBase.java:147)
     at com.intellij.openapi.application.RunResult.run(RunResult.java:37)
     at com.intellij.openapi.command.WriteCommandAction$2$1.run(WriteCommandAction.java:122)
     at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:754)
     at com.intellij.openapi.command.WriteCommandAction$2.run(WriteCommandAction.java:120)
     at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:110)
     at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:86)
     at com.intellij.openapi.command.WriteCommandAction.performWriteCommandAction(WriteCommandAction.java:118)
     at com.intellij.openapi.command.WriteCommandAction.access$000(WriteCommandAction.java:34)
     at com.intellij.openapi.command.WriteCommandAction$1.run(WriteCommandAction.java:73)
     at com.intellij.openapi.command.WriteCommandAction.execute(WriteCommandAction.java:78)
     at com.intellij.codeInsight.completion.CodeCompletionHandlerBase.invokeCompletion(CodeCompletionHandlerBase.java:139)
     at com.intellij.codeInsight.completion.CodeCompletionHandlerBase.invoke(CodeCompletionHandlerBase.java:93)
     at com.intellij.codeInsight.completion.actions.BaseCodeCompletionAction.actionPerformedImpl(BaseCodeCompletionAction.java:43)
     at com.intellij.codeInsight.completion.actions.CodeCompletionAction.actionPerformedImpl(CodeCompletionAction.java:34)
     at com.intellij.codeInsight.actions.CodeInsightAction.actionPerformed(CodeInsightAction.java:40)
     at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher$2.performAction(IdeKeyEventDispatcher.java:496)
     ...


Yet when I enter 3 spaces in the document (so the length is now 3), hit home to go to the start and then hit ctrl-space, the code completion drop-down works!

It seems I am missing something regarding the functionality around document length - does anyone have some tips ?

Cheers,
Steve

1 comment

Ok I solved this by downloading the community editor source and stepping through it.

As it turns out, I had overridden PsiFile.getText() in a bad way.

All good now.

0

Please sign in to leave a comment.