hi, Sometimes we need to add specific properties in the closures which are passed to methods with a particular name. This can be simply done as follows Suppose we need to add the property named requestMethod of type String in all closures passed to method with name “withREST” [java] //Get the context for […]
hi, If we want to contribute to classes which matches a particular path/name pattern, then we can use PSI Class patterns to do it. the code is as follows: [java] import com.intellij.patterns.PsiJavaPatterns import com.intellij.patterns.PlatformPatterns //get the context of all files, and enable path matching. Note: Don’t change anything in context here. def ctx […]
Hi, Sometimes we need to contribute dynamically using current target class type. Lets take the example of .get() and .list() methods of Grails domain class. The signature of each method is as follows: public <DomainClassType> get(Long id) , Example: DemoClass.get(1) will return an object of “DemoClass” public List<DomainClassType> list() The GDSL Script […]
Hi, I have been using the Grails mail plugin for a while now, this plugin injects a method named “sendMail” to all controllers and services. Our aim will be to provide auto-completes for this method and the closure inside. The GDSL Script is as follows: [java] import com.intellij.patterns.PsiJavaPatterns import com.intellij.patterns.PlatformPatterns //Let Us […]
Hi, Here i will illustrate how you can get the code of a method within GDSL Script: The script is as follows: [java] import com.intellij.patterns.PsiJavaPatterns import com.intellij.patterns.PlatformPatterns def mongoContext = context( ctype: PsiJavaPatterns.psiClass().withName(PlatformPatterns.string().matches(/.*/)) ) contributor(mongoContext) { def path = "" try { path = psiClass.containingFile.originalFile.virtualFile.path } catch (Exception e) { } if (path […]
Hi, Here is an example which uses a lot of gdsl concepts. This example tries to simulate injecting properties to Domains. The Example is as follows: (The code is self explanatory and can be used as a reference) [java] import com.intellij.patterns.PsiJavaPatterns import com.intellij.patterns.PlatformPatterns def mongoContext = context( ctype: PsiJavaPatterns.psiClass().withName(PlatformPatterns.string().matches(/.*/)) ) contributor(mongoContext) { def […]
Here is an example of how to design Grails domain class with Intellij Idea.For this we need to have blank domain classes. So lets say we created three Domain Classes Company,Book,Author To see relationship diagram, Selected Domain Class, and selected tab Domain Class Dependencies.It should look like this Lets assume the relation that publication has many […]