mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PsiElementConcatenationInspectionTest: mock library interfaces instead of actually loading them as library (IDEA-CR-15335)
This commit is contained in:
+9
@@ -252,6 +252,15 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected static VirtualFile createAndSaveFile(@NotNull String relativePath, @NotNull String fileText) throws IOException {
|
||||
return WriteCommandAction.runWriteCommandAction(getProject(), (ThrowableComputable<VirtualFile, IOException>)() -> {
|
||||
VirtualFile myVFile = VfsTestUtil.createFile(getSourceRoot(),relativePath);
|
||||
VfsUtil.saveText(myVFile, fileText);
|
||||
return myVFile;
|
||||
});
|
||||
}
|
||||
|
||||
private static void setupEditorForInjectedLanguage() {
|
||||
if (myEditor != null) {
|
||||
final Ref<EditorWindow> editorWindowRef = new Ref<>();
|
||||
|
||||
@@ -18,29 +18,31 @@ package org.jetbrains.idea.devkit.inspections;
|
||||
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixParameterizedTestCase;
|
||||
import com.intellij.codeInspection.LocalInspectionTool;
|
||||
import com.intellij.openapi.application.PluginPathManager;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.roots.ContentEntry;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiElementFactory;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import com.intellij.testFramework.PsiTestUtil;
|
||||
import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor;
|
||||
import com.intellij.util.PathUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
|
||||
public class PsiElementConcatenationInspectionTest extends LightQuickFixParameterizedTestCase {
|
||||
@NotNull
|
||||
@Override
|
||||
protected LightProjectDescriptor getProjectDescriptor() {
|
||||
return new DefaultLightProjectDescriptor() {
|
||||
@Override
|
||||
public void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model, @NotNull ContentEntry contentEntry) {
|
||||
super.configureModule(module, model, contentEntry);
|
||||
PsiTestUtil.addLibrary(module, model, "core-api", "", PathUtil.getJarPathForClass(PsiElement.class));
|
||||
PsiTestUtil.addLibrary(module, model, "java-psi-api", "", PathUtil.getJarPathForClass(PsiElementFactory.class));
|
||||
}
|
||||
};
|
||||
protected void beforeActionStarted(String testName, String contents) {
|
||||
try {
|
||||
createAndSaveFile("com/intellij/psi/PsiElement.java",
|
||||
"package com.intellij.psi;interface PsiElement {}");
|
||||
createAndSaveFile("com/intellij/psi/PsiExpression.java",
|
||||
"package com.intellij.psi;interface PsiExpression extends PsiElement {}");
|
||||
createAndSaveFile("com/intellij/psi/PsiType.java",
|
||||
"package com.intellij.psi;interface PsiType {}");
|
||||
createAndSaveFile("com/intellij/psi/PsiElementFactory.java",
|
||||
"package com.intellij.psi;\n" +
|
||||
"interface PsiElementFactory {\n" +
|
||||
"PsiExpression createExpressionFromText(String str, PsiElement context);\n" +
|
||||
"}");
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
super.beforeActionStarted(testName, contents);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user