Search in sources :

Example 6 with MapDataContext

use of com.intellij.testFramework.MapDataContext in project intellij-community by JetBrains.

the class CCTaskFileActionTest method getActionEvent.

@NotNull
private TestActionEvent getActionEvent(VirtualFile virtualFile, AnAction action) {
    MapDataContext context = new MapDataContext();
    context.put(CommonDataKeys.VIRTUAL_FILE, virtualFile);
    context.put(CommonDataKeys.PROJECT, getProject());
    return new TestActionEvent(context, action);
}
Also used : MapDataContext(com.intellij.testFramework.MapDataContext) TestActionEvent(com.intellij.testFramework.TestActionEvent) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with MapDataContext

use of com.intellij.testFramework.MapDataContext in project intellij-community by JetBrains.

the class JavaFXRenameTest method doTestPropertyRenameHandler.

public void doTestPropertyRenameHandler(String... files) throws Exception {
    myFixture.configureByFiles(files);
    final MapDataContext dataContext = new MapDataContext();
    dataContext.put(CommonDataKeys.EDITOR, getEditor());
    final RenameHandler renameHandler = RenameHandlerRegistry.getInstance().getRenameHandler(dataContext);
    assertTrue(renameHandler instanceof JavaFxPropertyRenameHandler);
}
Also used : JavaFxPropertyRenameHandler(org.jetbrains.plugins.javaFX.refactoring.JavaFxPropertyRenameHandler) MapDataContext(com.intellij.testFramework.MapDataContext) PsiElementRenameHandler(com.intellij.refactoring.rename.PsiElementRenameHandler) JavaFxPropertyRenameHandler(org.jetbrains.plugins.javaFX.refactoring.JavaFxPropertyRenameHandler) MemberInplaceRenameHandler(com.intellij.refactoring.rename.inplace.MemberInplaceRenameHandler) RenameHandler(com.intellij.refactoring.rename.RenameHandler)

Example 8 with MapDataContext

use of com.intellij.testFramework.MapDataContext in project intellij-community by JetBrains.

the class JavaFXRenameTest method doTestStaticProperty.

public void doTestStaticProperty(@NonNls String newName, String className) throws Exception {
    myFixture.configureByFiles(getTestName(true) + ".fxml", className.replace('.', '/') + ".java");
    final MapDataContext dataContext = new MapDataContext();
    dataContext.put(CommonDataKeys.EDITOR, getEditor());
    dataContext.put(PsiElementRenameHandler.DEFAULT_NAME, newName);
    final JavaFxPropertyRenameHandler renameHandler = new JavaFxPropertyRenameHandler();
    assertTrue(renameHandler.isAvailableOnDataContext(dataContext));
    renameHandler.invoke(getProject(), getEditor(), null, dataContext);
    myFixture.checkResultByFile(getTestName(true) + "_after.fxml");
    final PsiClass psiClass = myFixture.findClass(className);
    assertNotNull(psiClass);
    final String propName = newName.substring(0, 1).toUpperCase() + newName.substring(1);
    assertMethodExists(psiClass, "set" + propName);
}
Also used : JavaFxPropertyRenameHandler(org.jetbrains.plugins.javaFX.refactoring.JavaFxPropertyRenameHandler) MapDataContext(com.intellij.testFramework.MapDataContext) PsiClass(com.intellij.psi.PsiClass)

Example 9 with MapDataContext

use of com.intellij.testFramework.MapDataContext in project intellij-community by JetBrains.

the class JavaFXRenameTest method doTestHandler.

@NotNull
public PsiClass doTestHandler(String newName, String className) throws Exception {
    if (className == null) {
        className = getTestName(false);
        myFixture.configureByFiles(getTestName(true) + ".fxml", getTestName(false) + ".java");
    } else {
        myFixture.configureByFiles(getTestName(true) + ".fxml", getTestName(false) + ".java", className.replace('.', '/') + ".java");
    }
    final MapDataContext dataContext = new MapDataContext();
    dataContext.put(CommonDataKeys.EDITOR, getEditor());
    dataContext.put(PsiElementRenameHandler.DEFAULT_NAME, newName);
    final JavaFxPropertyRenameHandler renameHandler = new JavaFxPropertyRenameHandler();
    assertTrue(renameHandler.isAvailableOnDataContext(dataContext));
    renameHandler.invoke(getProject(), getEditor(), null, dataContext);
    myFixture.checkResultByFile(getTestName(true) + "_after.fxml");
    final PsiClass psiClass = myFixture.findClass(className);
    assertNotNull(psiClass);
    return psiClass;
}
Also used : JavaFxPropertyRenameHandler(org.jetbrains.plugins.javaFX.refactoring.JavaFxPropertyRenameHandler) MapDataContext(com.intellij.testFramework.MapDataContext) PsiClass(com.intellij.psi.PsiClass) NotNull(org.jetbrains.annotations.NotNull)

Example 10 with MapDataContext

use of com.intellij.testFramework.MapDataContext in project kotlin by JetBrains.

the class AbstractHierarchyTest method getDataContext.

private DataContext getDataContext() {
    Editor editor = getEditor();
    PsiFile psiFile = getFile();
    MapDataContext context = new MapDataContext();
    context.put(CommonDataKeys.PROJECT, getProject());
    context.put(CommonDataKeys.EDITOR, editor);
    context.put(CommonDataKeys.PSI_ELEMENT, psiFile.findElementAt(editor.getCaretModel().getOffset()));
    return context;
}
Also used : MapDataContext(com.intellij.testFramework.MapDataContext) Editor(com.intellij.openapi.editor.Editor)

Aggregations

MapDataContext (com.intellij.testFramework.MapDataContext)25 PsiClass (com.intellij.psi.PsiClass)8 Module (com.intellij.openapi.module.Module)6 RenameHandler (com.intellij.refactoring.rename.RenameHandler)4 PsiPackage (com.intellij.psi.PsiPackage)3 PsiElementRenameHandler (com.intellij.refactoring.rename.PsiElementRenameHandler)3 NotNull (org.jetbrains.annotations.NotNull)3 JavaFxPropertyRenameHandler (org.jetbrains.plugins.javaFX.refactoring.JavaFxPropertyRenameHandler)3 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)2 ApplicationConfiguration (com.intellij.execution.application.ApplicationConfiguration)2 TestActionEvent (com.intellij.testFramework.TestActionEvent)2 JavaOverrideMethodsHandler (com.intellij.codeInsight.generation.JavaOverrideMethodsHandler)1 PsiLocation (com.intellij.execution.PsiLocation)1 ConfigurationFromContext (com.intellij.execution.actions.ConfigurationFromContext)1 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)1 JUnitConfiguration (com.intellij.execution.junit.JUnitConfiguration)1 PsiElement2UsageTargetAdapter (com.intellij.find.findUsages.PsiElement2UsageTargetAdapter)1 DataProvider (com.intellij.openapi.actionSystem.DataProvider)1 Editor (com.intellij.openapi.editor.Editor)1 Project (com.intellij.openapi.project.Project)1