Skip to content

Commit d913c71

Browse files
committed
fix tests emitting invalid AST
1 parent 17ccd45 commit d913c71

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

apps/language_server/test/support/plugins/ecto/query.ex

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ defmodule Ecto.Query do
77
Creates a query.
88
"""
99
defmacro from(expr, kw \\ []) do
10-
{expr, kw}
10+
quote do
11+
{unquote(expr), unquote(kw)}
12+
end
1113
end
1214

1315
@doc """
@@ -40,7 +42,9 @@ defmodule Ecto.Query do
4042
4143
"""
4244
defmacro select(query, binding \\ [], expr) do
43-
{query, binding, expr}
45+
quote do
46+
{unquote(query), unquote(binding), unquote(expr)}
47+
end
4448
end
4549

4650
@doc """
@@ -76,7 +80,9 @@ defmodule Ecto.Query do
7680
it will default to the source, `p` in the example above.
7781
"""
7882
defmacro select_merge(query, binding \\ [], expr) do
79-
{query, binding, expr}
83+
quote do
84+
{unquote(query), unquote(binding), unquote(expr)}
85+
end
8086
end
8187

8288
@doc """
@@ -112,6 +118,8 @@ defmodule Ecto.Query do
112118
113119
"""
114120
defmacro distinct(query, binding \\ [], expr) do
115-
{query, binding, expr}
121+
quote do
122+
{unquote(query), unquote(binding), unquote(expr)}
123+
end
116124
end
117125
end

apps/language_server/test/support/plugins/ecto/schema.ex

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,38 @@ defmodule Ecto.Schema do
77
Defines a field on the schema with given name and type.
88
"""
99
defmacro field(name, type \\ :string, opts \\ []) do
10-
{name, type, opts}
10+
quote do
11+
{unquote(name), unquote(type), unquote(opts)}
12+
end
1113
end
1214

1315
defmacro schema(source, do: block) do
14-
{source, block}
16+
quote do
17+
{unquote(source), unquote(block)}
18+
end
1519
end
1620

1721
defmacro has_many(name, queryable, opts \\ []) do
18-
{name, queryable, opts}
22+
quote do
23+
{unquote(name), unquote(queryable), unquote(opts)}
24+
end
1925
end
2026

2127
defmacro has_one(name, queryable, opts \\ []) do
22-
{name, queryable, opts}
28+
quote do
29+
{unquote(name), unquote(queryable), unquote(opts)}
30+
end
2331
end
2432

2533
defmacro belongs_to(name, queryable, opts \\ []) do
26-
{name, queryable, opts}
34+
quote do
35+
{unquote(name), unquote(queryable), unquote(opts)}
36+
end
2737
end
2838

2939
defmacro many_to_many(name, queryable, opts \\ []) do
30-
{name, queryable, opts}
40+
quote do
41+
{unquote(name), unquote(queryable), unquote(opts)}
42+
end
3143
end
3244
end

0 commit comments

Comments
 (0)