Package ro.redeul.google.go.inspection.fix

Source Code of ro.redeul.google.go.inspection.fix.CreateLocalVariableFixTest

package ro.redeul.google.go.inspection.fix;

import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import ro.redeul.google.go.GoEditorAwareTestCase;
import ro.redeul.google.go.lang.psi.GoFile;
import ro.redeul.google.go.lang.psi.expressions.literals.GoLiteralIdentifier;

import static ro.redeul.google.go.lang.psi.utils.GoPsiUtils.findParentOfType;

public class CreateLocalVariableFixTest extends GoEditorAwareTestCase {
    public void testSimple() throws Exception { doTest(); }
    public void testIdentifierIsWholeStatement() throws Exception { doTest(); }

    @Override
    protected void invoke(final Project project, final Editor editor, final GoFile file) {
        PsiElement element = file.findElementAt(editor.getSelectionModel().getSelectionStart());
        final GoLiteralIdentifier identifier = findParentOfType(element, GoLiteralIdentifier.class);
        assertNotNull(identifier);

        CommandProcessor.getInstance().executeCommand(project, new Runnable() {
            @Override
            public void run() {
                new CreateLocalVariableFix(identifier).invoke(project, file, editor, identifier, identifier);
            }
        }, "", null);
    }

    @Override
    protected String getTestDataRelativePath() {
        return "fixes/createLocalVariable/";
    }
}
TOP

Related Classes of ro.redeul.google.go.inspection.fix.CreateLocalVariableFixTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.