@Override
public Void visitCommentReference(CommentReference node) {
Identifier identifier = node.getIdentifier();
if (identifier instanceof SimpleIdentifier) {
SimpleIdentifier simpleIdentifier = (SimpleIdentifier) identifier;
Element element = resolveSimpleIdentifier(simpleIdentifier);
if (element == null) {
//
// This might be a reference to an imported name that is missing the prefix.
//
element = findImportWithoutPrefix(simpleIdentifier);
if (element instanceof MultiplyDefinedElement) {
// TODO(brianwilkerson) Report this error?
element = null;
}
}
if (element == null) {
// TODO(brianwilkerson) Report this error?
// resolver.reportError(
// StaticWarningCode.UNDEFINED_IDENTIFIER,
// simpleIdentifier,
// simpleIdentifier.getName());
} else {
if (element.getLibrary() == null || !element.getLibrary().equals(definingLibrary)) {
// TODO(brianwilkerson) Report this error?
}
simpleIdentifier.setStaticElement(element);
if (node.getNewKeyword() != null) {
if (element instanceof ClassElement) {
ConstructorElement constructor = ((ClassElement) element).getUnnamedConstructor();
if (constructor == null) {
// TODO(brianwilkerson) Report this error.
} else {
simpleIdentifier.setStaticElement(constructor);
}
} else {
// TODO(brianwilkerson) Report this error.
}
}
}
} else if (identifier instanceof PrefixedIdentifier) {
PrefixedIdentifier prefixedIdentifier = (PrefixedIdentifier) identifier;
SimpleIdentifier prefix = prefixedIdentifier.getPrefix();
SimpleIdentifier name = prefixedIdentifier.getIdentifier();
Element element = resolveSimpleIdentifier(prefix);
if (element == null) {
// resolver.reportError(StaticWarningCode.UNDEFINED_IDENTIFIER, prefix, prefix.getName());
} else {
if (element instanceof PrefixElement) {
prefix.setStaticElement(element);
// TODO(brianwilkerson) The prefix needs to be resolved to the element for the import that
// defines the prefix, not the prefix's element.
// TODO(brianwilkerson) Report this error?
element = resolver.getNameScope().lookup(identifier, definingLibrary);
name.setStaticElement(element);
return null;
}
LibraryElement library = element.getLibrary();
if (library == null) {
// TODO(brianwilkerson) We need to understand how the library could ever be null.
AnalysisEngine.getInstance().getLogger().logError(
"Found element with null library: " + element.getName());
} else if (!library.equals(definingLibrary)) {
// TODO(brianwilkerson) Report this error.
}
name.setStaticElement(element);
if (node.getNewKeyword() == null) {
if (element instanceof ClassElement) {
Element memberElement = lookupGetterOrMethod(
((ClassElement) element).getType(),
name.getName());
if (memberElement == null) {
memberElement = ((ClassElement) element).getNamedConstructor(name.getName());
if (memberElement == null) {