@Override public Source fromFileUri(URI uri) { File file = new File(uri); String filePath = file.getAbsolutePath(); String libPath = getLibraryDirectory().getAbsolutePath(); if (!filePath.startsWith(libPath + File.separator)) { return null; } filePath = filePath.substring(libPath.length() + 1); for (SdkLibrary library : libraryMap.getSdkLibraries()) { String libraryPath = library.getPath(); if (filePath.replace('\\', '/').equals(libraryPath)) { String path = library.getShortName(); try { return new FileBasedSource(new URI(path), file); } catch (URISyntaxException exception) { AnalysisEngine.getInstance() .getLogger() .logInformation("Failed to create URI: " + path, exception); return null; } } libraryPath = new File(libraryPath).getParent(); if (filePath.startsWith(libraryPath + File.separator)) { String path = library.getShortName() + "/" + filePath.substring(libraryPath.length() + 1); try { return new FileBasedSource(new URI(path), file); } catch (URISyntaxException exception) { AnalysisEngine.getInstance() .getLogger() .logInformation("Failed to create URI: " + path, exception); return null; } } } return null; }
/** * Return an array containing the library URI's for the libraries defined in this SDK. * * @return the library URI's for the libraries defined in this SDK */ @Override public String[] getUris() { return libraryMap.getUris(); }
@Override public SdkLibrary getSdkLibrary(String dartUri) { return libraryMap.getLibrary(dartUri); }
@Override public SdkLibrary[] getSdkLibraries() { return libraryMap.getSdkLibraries(); }