Search in sources :

Example 46 with TemplateState

use of com.intellij.codeInsight.template.impl.TemplateState in project kotlin by JetBrains.

the class KotlinInplaceVariableIntroducer method buildTemplateAndStart.

@Override
protected boolean buildTemplateAndStart(Collection<PsiReference> refs, Collection<Pair<PsiElement, TextRange>> stringUsages, PsiElement scope, PsiFile containingFile) {
    myEditor.putUserData(INTRODUCE_RESTART, false);
    //noinspection ConstantConditions
    myEditor.getCaretModel().moveToOffset(getNameIdentifier().getTextOffset());
    boolean result = super.buildTemplateAndStart(refs, stringUsages, scope, containingFile);
    TemplateState templateState = TemplateManagerImpl.getTemplateState(InjectedLanguageUtil.getTopLevelEditor(myEditor));
    if (templateState != null && myDeclaration.getTypeReference() != null) {
        templateState.addTemplateStateListener(SpecifyTypeExplicitlyIntention.Companion.createTypeReferencePostprocessor(myDeclaration));
    }
    return result;
}
Also used : TemplateState(com.intellij.codeInsight.template.impl.TemplateState)

Example 47 with TemplateState

use of com.intellij.codeInsight.template.impl.TemplateState in project kotlin by JetBrains.

the class KotlinInplaceVariableIntroducer method stopIntroduce.

public void stopIntroduce() {
    final TemplateState templateState = TemplateManagerImpl.getTemplateState(myEditor);
    if (templateState != null) {
        Runnable runnable = new Runnable() {

            @Override
            public void run() {
                templateState.gotoEnd(true);
            }
        };
        CommandProcessor.getInstance().executeCommand(myProject, runnable, getCommandName(), getCommandName());
    }
}
Also used : TemplateState(com.intellij.codeInsight.template.impl.TemplateState)

Aggregations

TemplateState (com.intellij.codeInsight.template.impl.TemplateState)47 TextRange (com.intellij.openapi.util.TextRange)14 Editor (com.intellij.openapi.editor.Editor)11 Project (com.intellij.openapi.project.Project)8 AbstractInplaceIntroducer (com.intellij.refactoring.introduce.inplace.AbstractInplaceIntroducer)6 EditorWindow (com.intellij.injected.editor.EditorWindow)3 Document (com.intellij.openapi.editor.Document)3 SelectionModel (com.intellij.openapi.editor.SelectionModel)3 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 RelativePoint (com.intellij.ui.awt.RelativePoint)3 TypeExpression (com.intellij.codeInsight.intention.impl.TypeExpression)2 LookupImpl (com.intellij.codeInsight.lookup.impl.LookupImpl)2 TextResult (com.intellij.codeInsight.template.TextResult)2 Result (com.intellij.openapi.application.Result)2 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)2 CaretModel (com.intellij.openapi.editor.CaretModel)2 LogicalPosition (com.intellij.openapi.editor.LogicalPosition)2 DocumentAdapter (com.intellij.openapi.editor.event.DocumentAdapter)2 DocumentEvent (com.intellij.openapi.editor.event.DocumentEvent)2