当前位置: 首页>>代码示例>>Java>>正文


Java PsiTestUtil.checkFileStructure方法代码示例

本文整理汇总了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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:AddRemoveInTypeParameterListTest.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:AddRemoveInTypeParameterListTest.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:NormalizeDeclarationTest.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:AddClassToFileTest.java


注:本文中的com.intellij.testFramework.PsiTestUtil.checkFileStructure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。