// resolve AngularComponentElement template URIs
// TODO(scheglov) resolve to HtmlElement to allow F3 ?
Set<Source> angularElementsSources = Sets.newHashSet();
for (AngularElement angularElement : angularElements) {
if (angularElement instanceof AngularHasTemplateElement) {
AngularHasTemplateElement hasTemplate = (AngularHasTemplateElement) angularElement;
angularElementsSources.add(angularElement.getSource());
String templateUri = hasTemplate.getTemplateUri();
if (templateUri == null) {
continue;
}
try {
Source templateSource = context.getSourceFactory().forUri(
source.resolveRelativeUri(new URI(templateUri)));
if (!context.exists(templateSource)) {
templateSource = context.getSourceFactory().resolveUri(source, "package:" + templateUri);
if (!context.exists(templateSource)) {
errorListener.onError(new AnalysisError(
angularElement.getSource(),
hasTemplate.getTemplateUriOffset(),
templateUri.length(),
AngularCode.URI_DOES_NOT_EXIST,
templateUri));
continue;
}
}
if (!AnalysisEngine.isHtmlFileName(templateUri)) {
continue;
}
if (hasTemplate instanceof AngularComponentElementImpl) {
((AngularComponentElementImpl) hasTemplate).setTemplateSource(templateSource);
}
if (hasTemplate instanceof AngularViewElementImpl) {
((AngularViewElementImpl) hasTemplate).setTemplateSource(templateSource);
}
} catch (URISyntaxException exception) {
errorListener.onError(new AnalysisError(
angularElement.getSource(),
hasTemplate.getTemplateUriOffset(),
templateUri.length(),
AngularCode.INVALID_URI,
templateUri));
}
}