@Override public LibrarySource getImportFor(String relPath) { if (relPath == null || relPath.isEmpty()) { return null; } try { // Force the creation of an escaped relative URI to deal with spaces, etc. URI uri = getUri().resolve(new URI(null, null, relPath, null, null)).normalize(); String path = uri.getPath(); // Resolve relative reference out of one system library into another if (PackageLibraryManager.isDartUri(uri)) { if (path != null && path.startsWith("/..")) { URI fileUri = packageLibraryManager.resolveDartUri(uri); URI shortUri = packageLibraryManager.getShortUri(fileUri); if (shortUri != null) { uri = shortUri; } } } else if (PackageLibraryManager.isPackageUri(uri)) { URI fileUri = packageLibraryManager.resolveDartUri(uri); if (fileUri != null) { uri = fileUri; } } else if (!resourceExists(uri)) { // resolve against package root directories to find file uri = packageLibraryManager.findExistingFileInPackages(uri); } return createLibrarySource(uri, packageLibraryManager); } catch (Throwable e) { return null; } }
@Override public DartSource getSourceFor(final String relPath) { if (relPath == null || relPath.isEmpty()) { return null; } try { // Force the creation of an escaped relative URI to deal with spaces, etc. URI uri = getUri().resolve(new URI(null, null, relPath, null, null)).normalize(); if (PackageLibraryManager.isPackageUri(uri)) { URI fileUri = packageLibraryManager.resolveDartUri(uri); if (fileUri != null) { uri = fileUri; } } return createDartSource(uri, relPath, this, packageLibraryManager); } catch (Throwable e) { return null; } }