use of com.goide.psi.GoUnaryExpr in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoAssignmentToReceiverInspection method buildGoVisitor.
@NotNull
@Override
protected GoVisitor buildGoVisitor(@NotNull ProblemsHolder holder, @NotNull LocalInspectionToolSession session) {
return new GoVisitor() {
@Override
public void visitReferenceExpression(@NotNull GoReferenceExpression o) {
super.visitReferenceExpression(o);
if (o.getReadWriteAccess() == ReadWriteAccessDetector.Access.Write) {
PsiElement resolve = o.resolve();
if (resolve instanceof GoReceiver) {
String message = "Assignment to method receiver doesn't propagate to other calls";
if (((GoReceiver) resolve).getType() instanceof GoPointerType) {
if (o.getParent() instanceof GoUnaryExpr) {
GoUnaryExpr p = (GoUnaryExpr) o.getParent();
if (p.getMul() != null) {
// pointer dereference
return;
}
}
message = "Assignment to method receiver propagates only to callees but not to callers";
}
holder.registerProblem(o, message, WEAK_WARNING);
}
}
}
};
}
Aggregations