From a5ca50d00272cbb05c18104ec1411306e5aa7648 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Mon, 3 Jun 2013 10:03:42 -0700 Subject: [PATCH] did some more experiments only to hit additional problems --- core/src/main/resources/dsld/IntelliJ.gdsl | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/core/src/main/resources/dsld/IntelliJ.gdsl b/core/src/main/resources/dsld/IntelliJ.gdsl index 19c6ada61b..e643112e4b 100644 --- a/core/src/main/resources/dsld/IntelliJ.gdsl +++ b/core/src/main/resources/dsld/IntelliJ.gdsl @@ -44,6 +44,53 @@ contributor(ctx) { } } +/* + Adding methods that's not defined in Java works, but trying to define a method of the same name + as Java doesn't. See http://youtrack.jetbrains.com/issue/IDEA-108355 + + One work around that appears to work is to add a dummy 2nd parameter. + +TO BE FILED: +Title: GDSL: With named parameter type information, undefined properties should be flagged + +IDEA-71141 adds the named parameter support. However, I did a bit of experiments and noticed that if I +type in the parameter name that's not defined in the source code, IDEA does not flag it as undefined. + +Example: +my.gdsl: +{code} +contributor(context(ctype:"my.Foo")) { + def named = [ + parameter(name: 'a', type: Integer), + parameter(name: 'b', type: Integer) + ] + method name: "bar", type: void, params:[args:named] +} +{code} +something.groovy: +{code} +Foo foo = new Foo(); +foo.bar(a:1, b:2, c:3) +{code} + +If I give a string value to the "a" argument, that gets flagged as a type error, so I know that the GDSL +definition is taking an effect. It just appears to be lacking a validation for undefined argument names. +In my humble opinion, this significantly reduces the value of defining named argument type information. + +It should be either made a warning just like incorrect type, or it should be the same underscore given +to any undefined property access/method invocations. + +*/ + +// experiment +contributor(context(ctype:"lib.FormTagLib")) { + def named = [ + parameter(name: 'param1', type: String, doc: 'My doc'), + parameter(name: 'param2', type: Integer), + ] + method name: "textbox3", type: void, params:[args:named, c:Closure] +} + // Record of past experiments /* try to infer "it" from the class name of Groovy page -- GitLab