Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix trait source locations #1146

Merged
merged 1 commit into from
Mar 22, 2022
Merged

Fix trait source locations #1146

merged 1 commit into from
Mar 22, 2022

Conversation

JordonPhillips
Copy link
Contributor

@JordonPhillips JordonPhillips commented Mar 22, 2022

This fixes trait source locations from the IDL to start at the trait
itself rather than at the start of the trait's node definition. This
is particularly important for annotation traits where the source
location previously pointed to the column after the trait, which
doesn't necessarily even exist.

The following shows where the source location used to point:

@annotation
           ^

@annotationWithParens()
                       ^

@listTrait(["foo"])
           ^

@structuredTrait({
                 ^
    "foo": "bar"
})

@structuredTraitWithoutBraces(
    foo: "bar"
    ^
)

@primitiveTrait(true)
                ^

And this shows where they point now:

@annotation
^

@annotationWithParens()
^

@listTrait(["foo"])
^

@structuredTrait({
^
    "foo": "bar"
})

@structuredTraitWithoutBraces(
^
    foo: "bar"
)

@primitiveTrait(true)
^

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

This fixes trait source locations from the IDL to start at the trait
itself rather than at the start of the trait's node definition. This
is particularly important for annotation traits where the source
location previously pointed to the column *after* the trait, which
doesn't necessarily even exist.

The following shows where the source location used to point:

```
@annotation
           ^

@annotationWithParens()
                       ^

@listTrait(["foo"])
            ^

@structuredTrait({
                 ^
    "foo": "bar"
})

@structuredTraitWithoutBraces(
    foo: "bar"
    ^
)

@primitiveTrait(true)
                ^
```

And this shows where they point now:

```
@annotation
^

@annotationWithParens()
^

@listTrait(["foo"])
^

@structuredTrait({
^
    "foo": "bar"
})

@structuredTraitWithoutBraces(
^
    foo: "bar"
)

@primitiveTrait(true)
^
```
@JordonPhillips JordonPhillips requested a review from a team as a code owner March 22, 2022 16:33
@@ -68,6 +70,26 @@ public void loadsAppropriateSourceLocations() {
});
}

@Test
public void loadsAppropriateTraitSourceLocations() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is genius

@mtdowling mtdowling merged commit 7ba8de2 into idl-2.0 Mar 22, 2022
@mtdowling mtdowling deleted the fix-trait-locations branch April 8, 2022 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants