protected static String buildStubTreeText(@NotNull Project project, @NotNull VirtualFile file, @NotNull String fileContent, boolean checkErrors) throws IOException { String path = file.getPath(); PsiFile psi = PsiFileFactory.getInstance(project).createFileFromText(file.getName(), file.getFileType(), fileContent); if (checkErrors) { assertFalse(path + " contains error elements", DebugUtil.psiToString(psi, true).contains("PsiErrorElement")); } String full = DebugUtil.stubTreeToString(GoFileElementType.INSTANCE.getBuilder().buildStubTree(psi)); psi.putUserData(IndexingDataKeys.VIRTUAL_FILE, file); FileContentImpl content = new FileContentImpl(file, fileContent, file.getCharset()); PsiFile psiFile = content.getPsiFile(); String fast = DebugUtil.stubTreeToString(GoFileElementType.INSTANCE.getBuilder().buildStubTree(psiFile)); if (!Comparing.strEqual(full, fast)) { System.err.println(path); UsefulTestCase.assertSameLines(full, fast); } return fast; }