Search in sources :

Example 1 with InlineAction

use of com.intellij.refactoring.actions.InlineAction in project android by JetBrains.

the class AndroidInlineLayoutTest method doTestCommonInlineAction.

private void doTestCommonInlineAction(boolean inlineThisOnly) {
    final String testName = getTestName(true);
    myFixture.copyFileToProject(BASE_PATH + testName + "_included.xml", "res/layout/included.xml");
    final VirtualFile f = myFixture.copyFileToProject(BASE_PATH + testName + ".xml", "res/layout/test.xml");
    myFixture.configureFromExistingVirtualFile(f);
    AndroidInlineLayoutHandler.setTestConfig(new AndroidInlineTestConfig(inlineThisOnly));
    try {
        final Presentation p = myFixture.testAction(new InlineAction());
        assertTrue(p.isEnabled());
        assertTrue(p.isVisible());
    } finally {
        AndroidInlineLayoutHandler.setTestConfig(null);
    }
    myFixture.checkResultByFile(BASE_PATH + testName + "_after.xml", true);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) InlineAction(com.intellij.refactoring.actions.InlineAction) Presentation(com.intellij.openapi.actionSystem.Presentation)

Example 2 with InlineAction

use of com.intellij.refactoring.actions.InlineAction in project android by JetBrains.

the class AndroidInlineLayoutTest method test22.

public void test22() throws Exception {
    myFixture.copyFileToProject(BASE_PATH + getTestName(true) + "_included.xml", "res/layout/included.xml");
    final VirtualFile f = myFixture.copyFileToProject(BASE_PATH + getTestName(true) + ".xml", "res/layout/test.xml");
    myFixture.configureFromExistingVirtualFile(f);
    AndroidInlineLayoutHandler.setTestConfig(new AndroidInlineTestConfig(true));
    try {
        myFixture.testAction(new InlineAction());
        fail();
    } catch (IncorrectOperationException e) {
        assertTrue(e.getMessage().length() > 0);
    } finally {
        AndroidInlineLayoutHandler.setTestConfig(null);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) InlineAction(com.intellij.refactoring.actions.InlineAction) IncorrectOperationException(com.intellij.util.IncorrectOperationException)

Example 3 with InlineAction

use of com.intellij.refactoring.actions.InlineAction in project android by JetBrains.

the class AndroidInlineLayoutTest method test9.

public void test9() throws Exception {
    final String testName = getTestName(true);
    myFixture.copyFileToProject(BASE_PATH + testName + ".xml", "res/layout/test.xml");
    final VirtualFile f = myFixture.copyFileToProject(BASE_PATH + testName + "_included.xml", "res/layout/included.xml");
    myFixture.configureFromExistingVirtualFile(f);
    AndroidInlineLayoutHandler.setTestConfig(new AndroidInlineTestConfig(true));
    try {
        final Presentation p = myFixture.testAction(new InlineAction());
        assertTrue(p.isEnabled());
        assertTrue(p.isVisible());
    } finally {
        AndroidInlineLayoutHandler.setTestConfig(null);
    }
    myFixture.checkResultByFile("res/layout/test.xml", BASE_PATH + testName + "_after.xml", true);
    assertNull(myFixture.getTempDirFixture().getFile("res/layout/included.xml"));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) InlineAction(com.intellij.refactoring.actions.InlineAction) Presentation(com.intellij.openapi.actionSystem.Presentation)

Example 4 with InlineAction

use of com.intellij.refactoring.actions.InlineAction in project android by JetBrains.

the class AndroidValueResourcesTest method testInlineResourceField.

public void testInlineResourceField() throws Exception {
    copyFileToProject("value_resources.xml", "res/values/value_resources.xml");
    VirtualFile virtualFile = copyFileToProject(getTestName(false) + ".java", "src/p1/p2/" + getTestName(false) + ".java");
    myFixture.configureFromExistingVirtualFile(virtualFile);
    try {
        myFixture.testAction(new InlineAction());
        fail();
    } catch (CommonRefactoringUtil.RefactoringErrorHintException e) {
    }
    myFixture.checkResultByFile(myTestFolder + '/' + getTestName(false) + ".java", true);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) CommonRefactoringUtil(com.intellij.refactoring.util.CommonRefactoringUtil) InlineAction(com.intellij.refactoring.actions.InlineAction)

Example 5 with InlineAction

use of com.intellij.refactoring.actions.InlineAction in project android by JetBrains.

the class AndroidInlineLayoutTest method doTestCommonInlineActionWithConflicts.

private void doTestCommonInlineActionWithConflicts(boolean inlineThisOnly, boolean configureFromIncludedFile) {
    final String testName = getTestName(true);
    final VirtualFile included = myFixture.copyFileToProject(BASE_PATH + testName + "_included.xml", "res/layout/included.xml");
    final VirtualFile f = myFixture.copyFileToProject(BASE_PATH + testName + ".xml", "res/layout/test.xml");
    myFixture.configureFromExistingVirtualFile(configureFromIncludedFile ? included : f);
    final AndroidInlineTestConfig config = new AndroidInlineTestConfig(inlineThisOnly);
    AndroidInlineLayoutHandler.setTestConfig(config);
    myFixture.testAction(new InlineAction());
    final MultiMap<PsiElement, String> conflicts = config.getConflicts();
    assertEquals(1, conflicts.keySet().size());
    assertEquals(1, conflicts.values().size());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) InlineAction(com.intellij.refactoring.actions.InlineAction) PsiElement(com.intellij.psi.PsiElement)

Aggregations

InlineAction (com.intellij.refactoring.actions.InlineAction)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 Presentation (com.intellij.openapi.actionSystem.Presentation)3 PsiElement (com.intellij.psi.PsiElement)1 CommonRefactoringUtil (com.intellij.refactoring.util.CommonRefactoringUtil)1 IncorrectOperationException (com.intellij.util.IncorrectOperationException)1