GoType enclosingType = compositeValue.getType();
List<Reference> references = enclosingType.underlyingType().accept(new UpdatingTypeVisitor<List<Reference>>() {
@Override
public void visitStruct(GoTypeStruct type, List<Reference> data, TypeVisitor<List<Reference>> visitor) {
data.add(new StructFieldReference(identifier, type));
}
@Override
public void visitMap(GoTypeMap type, List<Reference> data, TypeVisitor<List<Reference>> visitor) {
data.add(new TypedConstReference(identifier, type.getKeyType()));
}
}, new ArrayList<Reference>()
);
return references.toArray(new PsiReference[references.size()]);
}
if (FunctionOrTypeNameReference.MATCHER.accepts(this))
return new PsiReference[]{new FunctionOrTypeNameReference(this)};
if (ShortVarReference.SHORT_VAR_DECLARATION.accepts(this))
return new PsiReference[]{new ShortVarReference(this)};
if (SELECTOR_MATCHER.accepts(this)) {
GoSelectorExpression selectorExpression = (GoSelectorExpression) getParent();
List<Reference> references = new ArrayList<Reference>();
GoType baseTypes[] = selectorExpression.getBaseExpression().getType();
if (baseTypes.length >= 1 && baseTypes[0] != null)
references = baseTypes[0].accept(
new UpdatingTypeVisitor<List<Reference>>() {
final GoLiteralIdentifier ident = GoLiteralIdentifierImpl.this;
@Override
public void visitPointer(GoTypePointer type, List<Reference> data, TypeVisitor<List<Reference>> visitor) {
type.getTargetType().accept(visitor);
}
@Override
public void visitPackage(GoTypePackage type, List<Reference> data, TypeVisitor<List<Reference>> visitor) {
GoPackage goPackage = type.getPackage();
if (goPackage != GoPackages.C)
data.add(new PackageSymbolReference(ident, goPackage));
}
@Override
public void visitName(GoTypeName type, List<Reference> data, TypeVisitor<List<Reference>> visitor) {
data.add(new InterfaceMethodReference(ident, type));
data.add(new MethodReference(ident, type));
// HACK: I should not have to do this here
if (type != type.underlyingType() && !(type.underlyingType() instanceof GoTypeName))
type.underlyingType().accept(visitor);
}
@Override
public void visitPrimitive(GoTypePrimitive type, List<Reference> data, TypeVisitor<List<Reference>> visitor) {
data.add(new MethodReference(ident, type));
}
@Override
public void visitStruct(GoTypeStruct type, List<Reference> data, TypeVisitor<List<Reference>> visitor) {
data.add(new StructFieldReference(ident, type));
}
}, new ArrayList<Reference>()
);
return references.toArray(new PsiReference[references.size()]);