public void test_CompilationUnitImpl_getSource_Clock() throws Exception { CompilationUnitImpl unit = getCompUnit("testsource/Clock.dart"); Type[] types = unit.getTypes(); assertEquals(7, types.length); Type type = unit.getType("Number"); assertNotNull(type); assertEquals(7, type.getFields().length); assertEquals(2, type.getMethods().length); assertEquals(9, type.getChildren().length); assertEquals(unit, type.getParent()); }
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; }