Record Source Annotations#216
Conversation
|
@jimsynz In the issue you asked for column info. Unfortunately, |
|
So, I'm ecstatic about this change, but I'm not a huge fan of the fact that entities have to add the source annotations within themselves. Its data that will be passed around during introspection for example. It probably doesn't matter? It is nice because it solves for entities that don't have identifiers, because we'd have to use the identifier feature otherwise...yeah, okay. This is the best way in general then. As for updating entities, most of the time when updating entities you don't create a new one, you just update some fields and then replace it. I don't know of any place that we do otherwise. As for errors, most of the time people are raising |
My goal of this PR is clarity related: I would like to have the location info in ash structs like I'd prefer not to have to dig around
Makes sense. I initially wrote the docs where I had a statically named field. But with the
Ah yes, I can use that one in the exception example.
Elixir right now does only line info in errors as far as I can see with the exception of stacktraces. I would probably add the full |
The main question is just will it be compatible with red squiggles from the language servers 😆 Now, you may still need to dig around in spark for this stuff eventually, if you want to show options or section location. |
|
@zachdaniel There's specific clauses in Expert to be able to handle CompileErrors: https://github.com/elixir-lang/expert/blob/d9099800cb4168be1b4239e661b20f59c7db0bc6/apps/engine/lib/engine/build/error.ex#L94-L109 It will therefore for sure not work right now. |
0004c83 to
f5e07c5
Compare
|
We could turn all Dsl Errors that are raised or returned from transformations with locations into compile errors automatically. We'd also want to extract that location info for warnings that we create. |
That sounds like a breaking change. Are you ok to do a new major release for this?
That sounds like a good idea. But warnings are just strings & IO. I don't think we can pass the structured location info anywhere... |
Right you are, no I'm not :laughing
We can at least include the location in the warning. I could swear Elixir warnings can get you yellow squiggles, so someone is doing it somehow. 😆 |
TIL, I added a second commit that takes care of the warnings. Basically the module will either take a user supplied location or a stacktrace. If nothing is provided, it will use the current stacktrace. |
|
@zachdaniel Ok, I believe this should be ready :) |
| defmodule MyLibrary.Validator.Dsl do | ||
| defmodule Field do | ||
| defstruct [:name, :type, :transform, :check] | ||
| # The __spark_metadata__ field is required for Spark entities |
There was a problem hiding this comment.
its not required though is it? Its optional, but will add extra information if present.
There was a problem hiding this comment.
If we rely on it for errors and warnings, I would make it required.
There was a problem hiding this comment.
But this would break every current DSL that doesn't have that field? That wouldn't be an option unless we want to do a major release.
|
🚀 |

Implements #65
Features
erl_annofor sections, section options, entities, and entity propertiesSpark.Warning(internal) for emitting warnings. Supports intentional locations as well as stacktraces.Missing / Incomplete
token_metadataparser option to be enabled.columnmeta intoMacro.Env.Contributor checklist
Leave anything that you believe does not apply unchecked.