PrestonKnopp / tree-sitter-gdscript

Tree sitter grammar for Godot's GDScript
https://www.npmjs.com/package/tree-sitter-gdscript
MIT License
50 stars 11 forks source link

Add support for typed arrays #18

Closed PrestonKnopp closed 9 months ago

PrestonKnopp commented 9 months ago
class IClass:
    class IIClass:
        var prop
    var prop

const iclass = IClass

var a1: Array[IClass.IIClass]
var a2: Array[iclass.IIClass]
var a3: Array[int]

Support can be added by rewriting the type node to be a non-terminal composed of (identifier)s, (subscript)s, and (attribute)s. This new type node will replace (dotted_type).

Array[IClass.IIClass] could be represented like

(type
  (subscript
    (identifier)
    (attribute
      (identifier)
      (identifier))))

Where

Additionally, highlight queries can use convention to differentiate between members and types.