Search in sources :

Example 1 with CodeInsightTestFixtureImpl

use of com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl in project kotlin by JetBrains.

the class AbstractKotlinFoldingTest method assertFoldingRegionsForFile.

// Rewritten version of CodeInsightTestFixtureImpl.testFoldingRegions(verificationFileName, true).
// Configure test with custom file name to force creating different editors for normal and inverted tests.
private void assertFoldingRegionsForFile(String verificationFileName, boolean doCheckCollapseStatus) {
    String START_FOLD = "<fold\\stext=\'[^\']*\'(\\sexpand=\'[^\']*\')*>";
    String END_FOLD = "</fold>";
    String expectedContent;
    File file = new File(verificationFileName);
    try {
        expectedContent = FileUtil.loadFile(file);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    Assert.assertNotNull(expectedContent);
    expectedContent = StringUtil.replace(expectedContent, "\r", "");
    String cleanContent = expectedContent.replaceAll(START_FOLD, "").replaceAll(END_FOLD, "");
    myFixture.configureByText(file.getName(), cleanContent);
    String actual = ((CodeInsightTestFixtureImpl) myFixture).getFoldingDescription(doCheckCollapseStatus);
    Assert.assertEquals(expectedContent, actual);
}
Also used : CodeInsightTestFixtureImpl(com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl) IOException(java.io.IOException) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 2 with CodeInsightTestFixtureImpl

use of com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl in project intellij-plugins by JetBrains.

the class DartExtractLocalVariableRefactoringTest method createRefactoring.

@NotNull
private ServerExtractLocalVariableRefactoring createRefactoring(String filePath) {
    ((CodeInsightTestFixtureImpl) myFixture).canChangeDocumentDuringHighlighting(true);
    final PsiFile psiFile = myFixture.configureByFile(filePath);
    ApplicationManager.getApplication().runWriteAction(() -> {
        try {
            VfsUtil.saveText(psiFile.getVirtualFile(), StringUtil.convertLineSeparators(psiFile.getText(), "\r\n"));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    });
    // make sure server is warmed up
    myFixture.doHighlighting();
    // find the Element to rename
    final SelectionModel selectionModel = getEditor().getSelectionModel();
    int offset = selectionModel.getSelectionStart();
    final int length = selectionModel.getSelectionEnd() - offset;
    return new ServerExtractLocalVariableRefactoring(getProject(), psiFile.getVirtualFile(), offset, length);
}
Also used : ServerExtractLocalVariableRefactoring(com.jetbrains.lang.dart.ide.refactoring.ServerExtractLocalVariableRefactoring) CodeInsightTestFixtureImpl(com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl) SelectionModel(com.intellij.openapi.editor.SelectionModel) PsiFile(com.intellij.psi.PsiFile) IOException(java.io.IOException) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with CodeInsightTestFixtureImpl

use of com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl in project intellij-plugins by JetBrains.

the class DartInlineLocalRefactoringTest method createInlineLocalRefactoring.

@NotNull
private ServerInlineLocalRefactoring createInlineLocalRefactoring(String filePath) {
    ((CodeInsightTestFixtureImpl) myFixture).canChangeDocumentDuringHighlighting(true);
    final PsiFile psiFile = myFixture.configureByFile(filePath);
    // make sure server is warmed up
    myFixture.doHighlighting();
    // find the Element to rename
    final int offset = getEditor().getCaretModel().getOffset();
    return new ServerInlineLocalRefactoring(getProject(), psiFile.getVirtualFile(), offset, 0);
}
Also used : CodeInsightTestFixtureImpl(com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl) ServerInlineLocalRefactoring(com.jetbrains.lang.dart.ide.refactoring.ServerInlineLocalRefactoring) PsiFile(com.intellij.psi.PsiFile) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with CodeInsightTestFixtureImpl

use of com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoReferenceImporterTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    myFixture.enableInspections(GoUnresolvedReferenceInspection.class);
    ((CodeInsightTestFixtureImpl) myFixture).canChangeDocumentDuringHighlighting(true);
    CodeInsightSettings codeInsightSettings = CodeInsightSettings.getInstance();
    defaultJavaOnTheFly = codeInsightSettings.ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY;
    defaultJavaMemberOnTheFly = codeInsightSettings.ADD_MEMBER_IMPORTS_ON_THE_FLY;
    defaultGoOnTheFly = GoCodeInsightSettings.getInstance().isAddUnambiguousImportsOnTheFly();
    codeInsightSettings.ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = true;
    codeInsightSettings.ADD_MEMBER_IMPORTS_ON_THE_FLY = true;
}
Also used : CodeInsightSettings(com.intellij.codeInsight.CodeInsightSettings) CodeInsightTestFixtureImpl(com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl)

Example 5 with CodeInsightTestFixtureImpl

use of com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl in project intellij-plugins by JetBrains.

the class DartInlineMethodRefactoringTest method createRefactoring.

@NotNull
private ServerInlineMethodRefactoring createRefactoring(String filePath) {
    ((CodeInsightTestFixtureImpl) myFixture).canChangeDocumentDuringHighlighting(true);
    final PsiFile psiFile = myFixture.configureByFile(filePath);
    // make sure server is warmed up
    myFixture.doHighlighting();
    // find the Element to rename
    final int offset = getEditor().getCaretModel().getOffset();
    return new ServerInlineMethodRefactoring(getProject(), psiFile.getVirtualFile(), offset, 0);
}
Also used : CodeInsightTestFixtureImpl(com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl) PsiFile(com.intellij.psi.PsiFile) ServerInlineMethodRefactoring(com.jetbrains.lang.dart.ide.refactoring.ServerInlineMethodRefactoring) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

CodeInsightTestFixtureImpl (com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl)6 PsiFile (com.intellij.psi.PsiFile)4 NotNull (org.jetbrains.annotations.NotNull)4 SelectionModel (com.intellij.openapi.editor.SelectionModel)2 IOException (java.io.IOException)2 CodeInsightSettings (com.intellij.codeInsight.CodeInsightSettings)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 ServerExtractLocalVariableRefactoring (com.jetbrains.lang.dart.ide.refactoring.ServerExtractLocalVariableRefactoring)1 ServerExtractMethodRefactoring (com.jetbrains.lang.dart.ide.refactoring.ServerExtractMethodRefactoring)1 ServerInlineLocalRefactoring (com.jetbrains.lang.dart.ide.refactoring.ServerInlineLocalRefactoring)1 ServerInlineMethodRefactoring (com.jetbrains.lang.dart.ide.refactoring.ServerInlineMethodRefactoring)1 File (java.io.File)1