本文整理汇总了Java中com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture类的典型用法代码示例。如果您正苦于以下问题:Java JavaCodeInsightTestFixture类的具体用法?Java JavaCodeInsightTestFixture怎么用?Java JavaCodeInsightTestFixture使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JavaCodeInsightTestFixture类属于com.intellij.testFramework.fixtures包,在下文中一共展示了JavaCodeInsightTestFixture类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addLibrary
import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture; //导入依赖的package包/类
public static void addLibrary(@NotNull JavaCodeInsightTestFixture parent, Module module, String libName, String libPath, String jarArr) {
Disposable projectDisposable;
try {
// projectDisposable = parent.getTestRootDisposable();
final MethodHandle methodHandle = MethodHandles.lookup().findVirtual(JavaCodeInsightTestFixture.class, "getProjectDisposable", MethodType.methodType(Disposable.class));
projectDisposable = (Disposable) methodHandle.invoke(parent);
} catch (Throwable throwable) {
projectDisposable = null;
}
if (null == projectDisposable) {
PsiTestUtil.addLibrary(module, libName, libPath, jarArr);
} else {
addLibrary(projectDisposable, module, libName, libPath, jarArr);
}
}
示例2: addJavaClassTo
import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture; //导入依赖的package包/类
static PsiClass addJavaClassTo(JavaCodeInsightTestFixture fixture) throws IOException {
return fixture.addClass("package my.pack; " +
" public class MyClass {" +
" public int xField1;" +
" private int prop1;" +
" public int getProp1() { return prop1; }" +
" public void setProp1(int prop1) { this.prop1 = prop1; }" +
" private int prop2;" +
" public int getProp2() { return prop2; }" +
" public MyClass getPropObject() { return this; }" +
" private int prop3;" +
" public void setProp3(int prop3) { this.prop3 = prop3; }" +
" public static void meth1() { ; }" +
" public MyClass returnObj() { return this; }" +
" }");
}
示例3: addJavaxDefaultNullabilityAnnotations
import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture; //导入依赖的package包/类
public static void addJavaxDefaultNullabilityAnnotations(final JavaCodeInsightTestFixture fixture) {
fixture.addClass("package javax.annotation;" +
"@javax.annotation.meta.TypeQualifierDefault(java.lang.annotation.ElementType.PARAMETER) @javax.annotation.Nonnull " +
"public @interface ParametersAreNonnullByDefault {}");
fixture.addClass("package javax.annotation;" +
"@javax.annotation.meta.TypeQualifierDefault(java.lang.annotation.ElementType.PARAMETER) @javax.annotation.Nullable " +
"public @interface ParametersAreNullableByDefault {}");
}
示例4: addJavaxNullabilityAnnotations
import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture; //导入依赖的package包/类
public static void addJavaxNullabilityAnnotations(final JavaCodeInsightTestFixture fixture) {
fixture.addClass("package javax.annotation;" +
"public @interface Nonnull {}");
fixture.addClass("package javax.annotation;" +
"public @interface Nullable {}");
fixture.addClass("package javax.annotation.meta;" +
"public @interface TypeQualifierDefault { java.lang.annotation.ElementType[] value() default {};}");
}
示例5: getRootStub
import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture; //导入依赖的package包/类
public static ElementStub getRootStub(@TestDataFile String filePath, JavaCodeInsightTestFixture fixture) {
PsiFile psiFile = fixture.configureByFile(filePath);
StubTreeLoader loader = StubTreeLoader.getInstance();
VirtualFile file = psiFile.getVirtualFile();
assertTrue(loader.canHaveStub(file));
ObjectStubTree stubTree = loader.readFromVFile(fixture.getProject(), file);
assertNotNull(stubTree);
ElementStub root = (ElementStub)stubTree.getRoot();
assertNotNull(root);
return root;
}
示例6: findUsages
import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture; //导入依赖的package包/类
private static Collection<UsageInfo> findUsages(String fileName, final JavaCodeInsightTestFixture fixture, String newFilePath)
throws Throwable {
VirtualFile file = fixture.copyFileToProject(BASE_PATH + fileName, newFilePath);
fixture.configureFromExistingVirtualFile(file);
final UsageTarget[] targets = UsageTargetUtil.findUsageTargets(new DataProvider() {
@Override
public Object getData(@NonNls String dataId) {
return ((EditorEx)fixture.getEditor()).getDataContext().getData(dataId);
}
});
assert targets != null && targets.length > 0 && targets[0] instanceof PsiElementUsageTarget;
return fixture.findUsages(((PsiElementUsageTarget)targets[0]).getElement());
}
示例7: checkCompletionContains
import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture; //导入依赖的package包/类
public static void checkCompletionContains(JavaCodeInsightTestFixture fixture, String ... expectedVariants) {
LookupElement[] lookupElements = fixture.completeBasic();
Assert.assertNotNull(lookupElements);
Set<String> missedVariants = ContainerUtil.newHashSet(expectedVariants);
for (LookupElement lookupElement : lookupElements) {
String lookupString = lookupElement.getLookupString();
missedVariants.remove(lookupString);
Object object = lookupElement.getObject();
if (object instanceof ResolveResult) {
object = ((ResolveResult)object).getElement();
}
if (object instanceof PsiMethod) {
missedVariants.remove(lookupString + "()");
}
else if (object instanceof PsiVariable) {
missedVariants.remove('@' + lookupString);
}
else if (object instanceof NamedArgumentDescriptor) {
missedVariants.remove(lookupString + ':');
}
}
if (missedVariants.size() > 0) {
Assert.assertTrue("Some completion variants are missed " + missedVariants, false);
}
}
示例8: getRootStub
import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture; //导入依赖的package包/类
public static ElementStub getRootStub(String filePath, JavaCodeInsightTestFixture fixture) {
PsiFile psiFile = fixture.configureByFile(filePath);
StubTreeLoader loader = StubTreeLoader.getInstance();
VirtualFile file = psiFile.getVirtualFile();
assertTrue(loader.canHaveStub(file));
ObjectStubTree stubTree = loader.readFromVFile(fixture.getProject(), file);
assertNotNull(stubTree);
ElementStub root = (ElementStub)stubTree.getRoot();
assertNotNull(root);
return root;
}
示例9: addJavaSubclassTo
import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture; //导入依赖的package包/类
static PsiClass addJavaSubclassTo(JavaCodeInsightTestFixture fixture) throws IOException {
addJavaClassTo(fixture);
return fixture.addClass("package my.pack; " +
" public class Subclass extends MyClass {" +
" protected void meth12() { ; }" +
" void meth13() { ; }" +
" private void meth14() { ; }" +
" public void meth11() { ; }" +
" }");
}
示例10: addJavaClassWithInnerClassTo
import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture; //导入依赖的package包/类
static PsiClass addJavaClassWithInnerClassTo(JavaCodeInsightTestFixture fixture) throws IOException {
return fixture.addClass("package my.pack; " +
" public class Class2 {" +
" public void meth11() { ; }" +
" public class InnerClass { } " +
" public interface InnerInterface { } " +
" }");
}
示例11: addJavaInterfaceWithOverloadedMethodTo
import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture; //导入依赖的package包/类
static PsiClass addJavaInterfaceWithOverloadedMethodTo(JavaCodeInsightTestFixture fixture) throws IOException {
fixture.addClass("package java.lang; public @interface Deprecated {}");
return fixture.addClass("package my.pack; " +
"public interface SomeInterface {" +
" public void foo();" +
" public void foo(int a);" +
" public void foo(String a);" +
" public void foo(String a, int b);" +
" @Deprecated public void foo(int a, String b);" +
" public void foo(String a, String b, String c);" +
" public int[] getNumbers();" +
"}");
}
示例12: addJavaClassWith3Getters
import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture; //导入依赖的package包/类
static PsiClass addJavaClassWith3Getters(JavaCodeInsightTestFixture fixture) throws IOException {
return fixture.addClass("package my.pack; " +
"public class GetterOwner {" +
" public Object getlowerCase() { return null;}" +
" public Object getLowerCase() { return null;}" +
" public Object get(String s) { return s;}" +
"}");
}
示例13: addJavaClassWith2Getters
import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture; //导入依赖的package包/类
static PsiClass addJavaClassWith2Getters(JavaCodeInsightTestFixture fixture) throws IOException {
return fixture.addClass("package my.pack; " +
"public class GetterOwner {" +
" public Object getUpperCase() { return null;}" +
" public Object get(String s) { return s;}" +
"}");
}
示例14: AutoValuePluginTestUtils
import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture; //导入依赖的package包/类
public AutoValuePluginTestUtils(JavaCodeInsightTestFixture myFixture) {
this.myFixture = myFixture;
}
示例15: addEmptyJavaClassTo
import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture; //导入依赖的package包/类
static PsiClass addEmptyJavaClassTo(JavaCodeInsightTestFixture fixture) throws IOException {
return fixture.addClass("package foo; public class Bar {}");
}