Stream: t-compiler/wg-rls-2.0

Topic: resolve_path between fixture files


Timo Freiberg (May 03 2020 at 19:20, on Zulip):

Hey all, I've created the following fixture for my work on https://github.com/rust-analyzer/rust-analyzer/pull/4273:

            r"//- /main.rs
              mod foo;
              fn main() { foo::Foo<|> }

              //- /foo.rs
              struct Foo;
              ",
            r"

But resolve_path can't resolve the path foo::Foo.
Testing the same case manually works, so something is broken with the test setup.
Can anyone tell me what I'm doing wrong?

Edwin Cheng (May 03 2020 at 19:21, on Zulip):

pub struct Foo; ?

Timo Freiberg (May 03 2020 at 19:30, on Zulip):

well that's what the assist is meant to add :/
it works in a manual test!

Timo Freiberg (May 03 2020 at 19:31, on Zulip):

and even with pub struct Foo;, resolve_path returns None

matklad (May 03 2020 at 19:34, on Zulip):

r"//- could you add a \n here? perhaps "strip indent" logic is going haywire?

Edwin Cheng (May 03 2020 at 19:34, on Zulip):

try this:

    #[test]
    fn change_visibility_of_adt_in_other_file_via_path() {
        check_assist(
            change_visibility,
            r"
              //- /main.rs
              mod foo;
              fn main() { foo::Foo<|> }

              //- /foo.rs
              struct Foo;
              ",
            r"
            <|>pub(crate) struct Foo;
            ",
        );
    }
Edwin Cheng (May 03 2020 at 19:34, on Zulip):

@matklad yes, I just tried my version, it works

Timo Freiberg (May 03 2020 at 19:35, on Zulip):

yep that's it.
thanks a ton!

matklad (May 03 2020 at 19:35, on Zulip):

(also, the format of fixtures needs some docs... I regularly forget the syntax myself :( )

Timo Freiberg (May 03 2020 at 19:35, on Zulip):

i'm gonna try to improve those areas a bit in the PR while I'm there :)

matklad (May 03 2020 at 19:35, on Zulip):

And, in this particular case, seems like we can implement some sort of a check? basically, if any file contains "//-" panic!(":-(")

Edwin Cheng (May 03 2020 at 19:36, on Zulip):

Speaking of formatting, any plan to works on ra_fmt ?

Edwin Cheng (May 03 2020 at 19:37, on Zulip):

I would like to implement it for better output of expanded macro display .... but it seem like needing more design works.

matklad (May 03 2020 at 19:40, on Zulip):

fwiw, I kinda like IntelliJ's design

matklad (May 03 2020 at 19:41, on Zulip):

The problem is, it's not trivial to understand what that design is, among thousands of highly OOP Java loc :D

Edwin Cheng (May 03 2020 at 19:51, on Zulip):

https://www.jetbrains.org/intellij/sdk/docs/reference_guide/custom_language_support/code_formatting.html

Last update: May 29 2020 at 16:40UTC