本文整理汇总了Java中com.intellij.testFramework.PsiTestUtil.checkFileStructure方法的典型用法代码示例。如果您正苦于以下问题:Java PsiTestUtil.checkFileStructure方法的具体用法?Java PsiTestUtil.checkFileStructure怎么用?Java PsiTestUtil.checkFileStructure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.testFramework.PsiTestUtil
的用法示例。
在下文中一共展示了PsiTestUtil.checkFileStructure方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testAdd
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
public void testAdd() throws IncorrectOperationException {
PsiJavaFile file = (PsiJavaFile)createLightFile("Test.java", "class Test extends Type {\n}");
PsiClass aClass = file.getClasses()[0];
PsiJavaCodeReferenceElement ref = aClass.getExtendsList().getReferenceElements()[0];
PsiReferenceParameterList list = ref.getParameterList();
PsiElementFactory factory = getJavaFacade().getElementFactory();
PsiTypeElement typeElement1 = factory.createTypeElement(factory.createTypeFromText("A", null));
list.add(typeElement1);
assertEquals("class Test extends Type<A> {\n}", file.getText());
PsiTestUtil.checkFileStructure(file);
PsiTypeElement typeElement2 = factory.createTypeElement(factory.createTypeFromText("B", null));
list.add(typeElement2);
assertEquals("class Test extends Type<A, B> {\n}", file.getText());
PsiTestUtil.checkFileStructure(file);
PsiTypeElement typeElement3 = factory.createTypeElement(factory.createTypeFromText("C", null));
list.addAfter(typeElement3, null);
assertEquals("class Test extends Type<C, A, B> {\n}", file.getText());
PsiTestUtil.checkFileStructure(file);
}
示例2: testRemove
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
public void testRemove() throws IncorrectOperationException {
final PsiJavaFile file = (PsiJavaFile)createLightFile("Test.java", "class Test extends Type<A, B, C, D> {\n}");
PsiClass aClass = file.getClasses()[0];
PsiJavaCodeReferenceElement ref = aClass.getExtendsList().getReferenceElements()[0];
PsiReferenceParameterList list = ref.getParameterList();
final PsiTypeElement[] parms = list.getTypeParameterElements();
WriteCommandAction.runWriteCommandAction(null, new Runnable() {
@Override
public void run() {
parms[0].delete();
assertEquals("class Test extends Type< B, C, D> {\n}", file.getText());
PsiTestUtil.checkFileStructure(file);
parms[2].delete();
assertEquals("class Test extends Type< B, D> {\n}", file.getText());
PsiTestUtil.checkFileStructure(file);
parms[3].delete();
assertEquals("class Test extends Type< B > {\n}", file.getText());
PsiTestUtil.checkFileStructure(file);
parms[1].delete();
}
});
assertEquals("class Test extends Type {\n}", file.getText());
PsiTestUtil.checkFileStructure(file);
}
示例3: doTest
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
private void doTest() throws Exception {
PsiElement element = configureByFileWithMarker(BASE_PATH + "/" + getTestName(false) + ".java", "<var>");
assertTrue(element instanceof PsiIdentifier);
assertTrue(element.getParent() instanceof PsiVariable);
((PsiVariable)element.getParent()).normalizeDeclaration();
String textAfter = loadFile(getTestName(false) + "_after.java");
PostprocessReformattingAspect.getInstance(getProject()).doPostponedFormatting();
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
String fileText = myFile.getText();
assertEquals(textAfter, fileText);
PsiTestUtil.checkFileStructure(myFile);
}
示例4: test
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
public void test() throws Exception {
VirtualFile root = PsiTestUtil.createTestProjectStructure(myProject, myModule, myFilesToDelete);
PsiDirectory dir = myPsiManager.findDirectory(root);
assertNotNull(dir);
PsiFile file = dir.createFile("AAA.java");
PsiClass aClass = myJavaFacade.getElementFactory().createClass("AAA");
file.add(aClass);
PsiTestUtil.checkFileStructure(file);
}