GrVariableDeclaration (String @NotNull [] modifiers, @NotNull String identifier, @Nullable GrExpression initializer, @Nullable PsiType type) { final String varDeclaration = createVariableDeclaration(modifiers, initializer, type, identifier).getText(); final GroovyFileBase file = createGroovyFileChecked("class A { " + varDeclaration + "}"); final GrTypeDefinitionBody body = file.getTypeDefinitions()[0].getBody(); LOG.assertTrue(body.getMemberDeclarations().length == 1 && body.getMemberDeclarations()[0] instanceof GrVariableDeclaration, "ident = <" + identifier + "> initializer = " + (initializer == null ? "_null_" : ("<" + initializer.getText()) + ">")); return (GrVariableDeclaration) body.getMemberDeclarations()[0]; }