Search in sources :

Example 21 with TemplateState

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

the class JavaSurroundWithTest method doTestWithTemplateFinish.

private void doTestWithTemplateFinish(@NotNull String fileName, Surrounder surrounder, @Nullable String textToType) {
    TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable());
    configureByFile(BASE_PATH + fileName + ".java");
    SurroundWithHandler.invoke(getProject(), getEditor(), getFile(), surrounder);
    if (textToType != null) {
        type(textToType);
    }
    TemplateState templateState = TemplateManagerImpl.getTemplateState(getEditor());
    assertNotNull(templateState);
    templateState.nextTab();
    checkResultByFile(BASE_PATH + fileName + "_after.java");
}
Also used : TemplateState(com.intellij.codeInsight.template.impl.TemplateState)

Example 22 with TemplateState

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

the class DelegateWithDefaultParamValueTest method doAction.

@Override
protected void doAction(@NotNull ActionHint actionHint, String testFullPath, String testName) throws Exception {
    TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable());
    super.doAction(actionHint, testFullPath, testName);
    if (actionHint.shouldPresent()) {
        TemplateState state = TemplateManagerImpl.getTemplateState(getEditor());
        if (state != null) {
            state.gotoEnd(false);
        }
    }
}
Also used : TemplateState(com.intellij.codeInsight.template.impl.TemplateState)

Example 23 with TemplateState

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

the class AddMissingRequiredAnnotationParametersTest method testValueTyping.

public void testValueTyping() {
    configureByFile(getBasePath() + "/beforeValueTyping.java");
    TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable());
    doAction("Add missing annotation parameters - value3, value2, value1");
    final TemplateState state = TemplateManagerImpl.getTemplateState(getEditor());
    assertNotNull(state);
    type("\"value33\"");
    state.nextTab();
    type("\"value22\"");
    state.nextTab();
    type("\"value11\"");
    state.nextTab();
    assertTrue(state.isFinished());
    checkResultByFile(getBasePath() + "/afterValueTyping.java");
}
Also used : TemplateState(com.intellij.codeInsight.template.impl.TemplateState)

Example 24 with TemplateState

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

the class InstanceofPostfixTemplateTest method testSingleExpressionTemplate.

public void testSingleExpressionTemplate() {
    TemplateManagerImpl.setTemplateTesting(getProject(), myFixture.getTestRootDisposable());
    myFixture.configureByFile(getTestName(true) + ".java");
    myFixture.type('\t');
    TemplateState templateState = TemplateManagerImpl.getTemplateState(myFixture.getEditor());
    assertNotNull(templateState);
    assertFalse(templateState.isFinished());
    myFixture.type("Integer");
    templateState.nextTab();
    assertTrue(templateState.isFinished());
    myFixture.checkResultByFile(getTestName(true) + "_after.java", true);
}
Also used : TemplateState(com.intellij.codeInsight.template.impl.TemplateState)

Example 25 with TemplateState

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

the class DartIntroduceTestBase method doTestInplace.

protected void doTestInplace(@Nullable Consumer<DartIntroduceOperation> customization) {
    String name = getTestName(false);
    myFixture.configureByFile(name + getFileExtension());
    final boolean enabled = myFixture.getEditor().getSettings().isVariableInplaceRenameEnabled();
    try {
        TemplateManagerImpl.setTemplateTesting(getProject(), myFixture.getTestRootDisposable());
        myFixture.getEditor().getSettings().setVariableInplaceRenameEnabled(true);
        DartIntroduceHandler handler = createHandler();
        final DartIntroduceOperation introduceOperation = new DartIntroduceOperation(myFixture.getProject(), myFixture.getEditor(), myFixture.getFile(), "a");
        introduceOperation.setReplaceAll(true);
        if (customization != null) {
            customization.consume(introduceOperation);
        }
        handler.performAction(introduceOperation);
        TemplateState state = TemplateManagerImpl.getTemplateState(myFixture.getEditor());
        assert state != null;
        state.gotoEnd(false);
        myFixture.checkResultByFile(name + ".after" + getFileExtension(), true);
    } finally {
        myFixture.getEditor().getSettings().setVariableInplaceRenameEnabled(enabled);
    }
}
Also used : DartIntroduceOperation(com.jetbrains.lang.dart.ide.refactoring.introduce.DartIntroduceOperation) DartIntroduceHandler(com.jetbrains.lang.dart.ide.refactoring.introduce.DartIntroduceHandler) 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