Search in sources :

Example 6 with InsertHandler

use of com.intellij.codeInsight.completion.InsertHandler in project intellij-community by JetBrains.

the class TaskAutoCompletionListProvider method createInsertHandler.

@Override
protected InsertHandler<LookupElement> createInsertHandler(@NotNull final Task task) {
    return new InsertHandler<LookupElement>() {

        @Override
        public void handleInsert(InsertionContext context, LookupElement item) {
            Document document = context.getEditor().getDocument();
            String s = ((TaskManagerImpl) TaskManager.getManager(context.getProject())).getChangelistName(task);
            s = StringUtil.convertLineSeparators(s);
            document.replaceString(context.getStartOffset(), context.getTailOffset(), s);
            context.getEditor().getCaretModel().moveToOffset(context.getStartOffset() + s.length());
            TaskAutoCompletionListProvider.this.handleInsert(task);
        }
    };
}
Also used : TaskManagerImpl(com.intellij.tasks.impl.TaskManagerImpl) InsertHandler(com.intellij.codeInsight.completion.InsertHandler) InsertionContext(com.intellij.codeInsight.completion.InsertionContext) LookupElement(com.intellij.codeInsight.lookup.LookupElement) Document(com.intellij.openapi.editor.Document)

Aggregations

InsertHandler (com.intellij.codeInsight.completion.InsertHandler)6 InsertionContext (com.intellij.codeInsight.completion.InsertionContext)5 LookupElement (com.intellij.codeInsight.lookup.LookupElement)5 Document (com.intellij.openapi.editor.Document)4 Editor (com.intellij.openapi.editor.Editor)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 NotNull (org.jetbrains.annotations.NotNull)2 CharTailType (com.intellij.codeInsight.CharTailType)1 TailType (com.intellij.codeInsight.TailType)1 PrioritizedLookupElement (com.intellij.codeInsight.completion.PrioritizedLookupElement)1 XmlTagInsertHandler (com.intellij.codeInsight.completion.XmlTagInsertHandler)1 ParenthesesInsertHandler (com.intellij.codeInsight.completion.util.ParenthesesInsertHandler)1 LookupElementBuilder (com.intellij.codeInsight.lookup.LookupElementBuilder)1 TemplateState (com.intellij.codeInsight.template.impl.TemplateState)1 CfmlMappingsConfig (com.intellij.coldFusion.UI.config.CfmlMappingsConfig)1 CfmlProjectConfiguration (com.intellij.coldFusion.UI.config.CfmlProjectConfiguration)1 CfmlFile (com.intellij.coldFusion.model.files.CfmlFile)1 RangeMarker (com.intellij.openapi.editor.RangeMarker)1 TextRange (com.intellij.openapi.util.TextRange)1 SuggestedNameInfo (com.intellij.psi.codeStyle.SuggestedNameInfo)1