package com.jetbrains.python.validation;

import com.jetbrains.python.psi.PyArgumentList;
import com.jetbrains.python.psi.PyExpression;
import com.jetbrains.python.psi.PyGeneratorExpression;

/**
 * @author yole
 */
public class GeneratorInArgumentListAnnotator extends PyAnnotator {
  @Override
  public void visitPyArgumentList(PyArgumentList node) {
    if (node.getArguments().length > 1) {
      for (PyExpression expression : node.getArguments()) {
        if (expression instanceof PyGeneratorExpression) {
          markError(expression, "Generator expression must be parenthesized if not sole argument");
        }
      }
    }
  }
}

@@ -35,16 +35,92 @@
 ation;%0A%0A
+import com.intellij.lang.ASTNode;%0Aimport com.jetbrains.python.PyTokenTypes;%0A
 import c
@@ -579,24 +579,173 @@
 pression) %7B%0A
+          ASTNode firstChildNode = expression.getNode().getFirstChildNode();%0A          if (firstChildNode.getElementType() != PyTokenTypes.LPAR) %7B%0A  
           ma
@@ -832,16 +832,28 @@
 ment%22);%0A
+          %7D%0A
         

test fix