use of com.goide.psi.GoShortVarDeclaration in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoUsedAsValueInCondition method buildGoVisitor.
@NotNull
@Override
protected GoVisitor buildGoVisitor(@NotNull ProblemsHolder holder, @NotNull LocalInspectionToolSession session) {
return new GoVisitor() {
@Override
public void visitAssignmentStatement(@NotNull GoAssignmentStatement o) {
if (o.getParent() != null && o.getParent() instanceof GoIfStatement && ((GoIfStatement) o.getParent()).getExpression() == null) {
String left = GoPsiImplUtil.joinPsiElementText(o.getLeftHandExprList().getExpressionList());
String right = GoPsiImplUtil.joinPsiElementText(o.getExpressionList());
holder.registerProblem(o, left + " = " + right + " used as value", GENERIC_ERROR_OR_WARNING, new GoAssignmentToComparisonQuickFix());
}
}
@Override
public void visitShortVarDeclaration(@NotNull GoShortVarDeclaration o) {
PsiElement parent = o.getParent();
if (parent != null) {
PsiElement gradParent = parent.getParent();
if (gradParent instanceof GoIfStatement && ((GoIfStatement) gradParent).getExpression() == null) {
String left = GoPsiImplUtil.joinPsiElementText(o.getVarDefinitionList());
String right = GoPsiImplUtil.joinPsiElementText(o.getRightExpressionsList());
holder.registerProblem(o, left + " := " + right + " used as value", GENERIC_ERROR_OR_WARNING, new GoAssignmentToComparisonQuickFix());
}
}
}
};
}
Aggregations