Skip to content
This repository has been archived by the owner on Nov 3, 2024. It is now read-only.

Commit

Permalink
activate EM support for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mplushnikov committed Dec 26, 2020
1 parent a9570a8 commit 53002ca
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.intellij.testFramework.LightJavaCodeInsightTestCase;
import com.intellij.testFramework.LightProjectDescriptor;

import de.plushnikov.intellij.plugin.settings.ProjectSettings;
import junit.framework.AssertionFailedError;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -40,12 +41,18 @@ private void checkMethod(final PsiMethod method, final boolean successful) {
private PsiMethod createTestMethod(final String body) { return PsiTreeUtil.findChildOfType(createTestFile("static void f() {" + body + "}"), PsiMethod.class); }

private PsiFile createTestFile(final String body) {
enableExtensionMethodSupport();

return createFile("test.java", "import java.util.*; import java.util.function.*;" +
"@lombok.experimental.ExtensionMethod({" +
"Objects.class, Arrays.class" +
"}) class TestExtensionMethod { " + body + "}");
}

private void enableExtensionMethodSupport() {
ProjectSettings.setEnabled(getProject(), ProjectSettings.IS_EXTENSION_METHOD_ENABLED, true);
}

@NotNull
@Override
protected LightProjectDescriptor getProjectDescriptor() { return LombokTestUtil.getProjectDescriptor(); }
Expand Down

0 comments on commit 53002ca

Please sign in to comment.