Skip to content

Crystal tool context/implementations with ECR #14280

Open
@nobodywasishere

Description

Feature Request

I am developing the vscode extension and it would be useful to improve the experience writing ECR through type information / jump to definition. The context and implementation tools should both be able to accept an .ecr file just the same as it currently does a .cr file, with line/col information, and if there exists a method/variable/etc at the location, it should return relevant information. The only other solution would be a custom ECR parser, but it would be better to have this integrated into the compiler itself. This does not break backwards compatibility.

greeter.ecr

<%
  my_var = name
%>

greeter.cr

require "ecr"

class Greeter
  getter name : String

  def initialize(@name : String)
  end

  ECR.def_to_s "greeter.ecr"
end

Greeter.new("John").to_s # => "Greetings, John!\n"
$ crystal tool context -c greeter.ecr:2:12 greeter.cr

1 possible context found

| Expr | Type   |
| name | String |
$ crystal tool implementations -c greeter.ecr:2:12 greeter.cr

1 implementation found
/path/to/greeter.cr:4:3
 ~> macro getter: expanded macro: macro_12341234:123:12

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions