Child pages
  • Scripting IDE for DSL awareness

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
def gdslScriptContext = context(scope: scriptScope(), filetypes: ["gdsl"])

contributor([gdslScriptContext]) {
  method name: "context", params: [args: [:]], type: "java.lang.Object"
  method name: "contributor", params: [contexts: "java.util.List", body: {}], type: void

  // scopes
  property name: "closureScope", type: {}
  property name: "scriptScope", type: {}
}

def contributorBody = context(scope: closureScope(isArg: true))

contributor([contributorBody]) {
  if (enclosingCall("contributor")) {
    method name: "method", type: "void", params: [args: [
            parameter(name:'name', type:String.name, doc:'Method name'),
            parameter(name:'params', type:Map.name, doc:'A map representing method parameters'),
            parameter(name:'namedParams', type:Object.name, doc:'''A list representing method named parameters.<br>
Its elements should be calls to <code>parameter</code> method.'''),
            parameter(name:'type', type:Object.name, doc:'Return type name of the method'),
            parameter(name:'doc', type:String.name, doc:'Method documentation text'),
    ]], doc:'Describe a DSL method'
    method name: "property", type: "void", params: [args: [
            parameter(name:'name', type:String.name, doc:'Property name'),
            parameter(name:'type', type:Object.name, doc:'Property type name'),
            parameter(name:'doc', type:String.name, doc:'Property documentation text'),
    ]], doc:'Describe a DSL property'
    method name: "parameter", type: "Parameter", params: [args: [
            parameter(name:'name', type:String.name, doc:'Parameter name'),
            parameter(name:'type', type:Object.name, doc:'Parameter type name'),
            parameter(name:'doc', type:String.name, doc:'Parameter documentation text'),
    ]], doc:'Describe a method named parameter'

    method name: "add", type: "void", params: [member: "com.intellij.psi.PsiMember"]
    method name: "findClass", type: "com.intellij.psi.PsiClass", params: [name: "java.lang.String"]
    method name: "delegatesTo", type: "void", params: [elem: "com.intellij.psi.PsiElement"]

    method name: "enclosingCall",
           type: "com.intellij.psi.PsiElement",
           params: [methodName: "java.lang.String"]

    method name: "enclosingMethod", type: "com.intellij.psi.PsiMethod"
    method name: "enclosingMember", type: "com.intellij.psi.PsiMember"
    method name: "enclosingClass", type: "com.intellij.psi.PsiClass"

    property name: "place", type: "com.intellij.psi.PsiElement"
    property name: "classType", type: "com.intellij.psi.PsiClass"
  }
}

def psiClassContext = context(scope: closureScope(isArg: true), ctype: "com.intellij.psi.PsiClass")
contributor([psiClassContext]) {
  method name: "getMethods", type: "java.util.Collection"
  method name: "getQualName", type: "java.lang.String"
}

def psiMemberContext = context(scope: closureScope(isArg: true), ctype: "com.intellij.psi.PsiMember")
contributor([psiMemberContext]) {
  method name: "hasAnnotation", params: [name: "java.lang.String"], type: "boolean"
  method name: "hasAnnotation", type: "boolean"
  method name: "getAnnotation", params: [name: "java.lang.String"], type: "com.intellij.psi.PsiAnnotation"
  method name: "getAnnotations", params: [name: "java.lang.String"], type: "java.util.Collection<com.intellij.psi.PsiAnnotation>"
}

def psiFieldContext = context(scope: closureScope(isArg: true), ctype: "com.intellij.psi.PsiField")
contributor([psiFieldContext]) {
  method name: "getClassType", type: "com.intellij.psi.PsiClass"
}

def psiMethodContext = context(scope: closureScope(isArg: true), ctype: "com.intellij.psi.PsiMethod")
contributor([psiMethodContext]) {
  method name: "getParamStringVector", type: "java.util.Map"
}

def psiElementContext = context(scope: closureScope(isArg: true), ctype: "com.intellij.psi.PsiElement")
contributor([psiElementContext]) {
  method name: "bind", type: "com.intellij.psi.PsiElement"
  method name: "eval", type: "java.lang.Object"
  method name: "asList", type: "java.util.collection<com.intellij.psi.PsiElement>"
  method name: "getQualifier", type: "com.intellij.psi.PsiElement"
}

def expressionContext = context(scope: closureScope(isArg: true),
                                ctype: "org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression")
contributor([expressionContext]) {
  method name: "getArguments", type: "java.util.Collection"
  method name: "getClassType", type: "com.intellij.psi.PsiClass"
}

...