if (analysisContext.computeKindOf(importedSource) != SourceKind.LIBRARY) {
ErrorCode errorCode = importElement.isDeferred()
? StaticWarningCode.IMPORT_OF_NON_LIBRARY
: CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY;
errorListener.onError(new AnalysisError(
library.getLibrarySource(),
uriLiteral.getOffset(),
uriLiteral.getLength(),
errorCode,
uriLiteral.toSource()));
}
}
}
} else if (directive instanceof ExportDirective) {
ExportDirective exportDirective = (ExportDirective) directive;
Source exportedSource = exportDirective.getSource();
if (exportedSource != null) {
// The exported source will be null if the URI in the export directive was invalid.
Library exportedLibrary = libraryMap.get(exportedSource);
if (exportedLibrary != null) {
ExportElementImpl exportElement = new ExportElementImpl();
StringLiteral uriLiteral = exportDirective.getUri();
exportElement.setUriOffset(uriLiteral.getOffset());
exportElement.setUriEnd(uriLiteral.getEnd());
exportElement.setUri(exportDirective.getUriContent());
exportElement.setCombinators(buildCombinators(exportDirective));
LibraryElement exportedLibraryElement = exportedLibrary.getLibraryElement();
if (exportedLibraryElement != null) {
exportElement.setExportedLibrary(exportedLibraryElement);
}
directive.setElement(exportElement);
exports.add(exportElement);
if (analysisContext.computeKindOf(exportedSource) != SourceKind.LIBRARY) {
errorListener.onError(new AnalysisError(
library.getLibrarySource(),
uriLiteral.getOffset(),
uriLiteral.getLength(),
CompileTimeErrorCode.EXPORT_OF_NON_LIBRARY,
uriLiteral.toSource()));