public CompilationUnitImpl getCompUnit(Class<?> base, String relPath) throws CoreException, IOException, DartModelException { DartLibraryImpl lib = getDartApp(); String expected = TestFileUtil.readResource(base, relPath); String fileName = relPath.substring(relPath.lastIndexOf('/') + 1); IFile file = getOrCreateFile(fileName, expected); DefaultWorkingCopyOwner wcopy = DefaultWorkingCopyOwner.getInstance(); CompilationUnitImpl unit = new CompilationUnitImpl(lib, file, wcopy); String actual = unit.getSource(); assertEquals(expected, actual); return unit; }
private IFile getOrCreateFile(String fileName) throws CoreException, IOException { return getOrCreateFile( fileName, TestFileUtil.readResource(getClass(), "testsource/" + fileName)); }