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

feat: Add library semantic token modifier to items from other crates #8942

Merged
merged 7 commits into from
May 25, 2021

Conversation

lunacookies
Copy link
Contributor

Closes #5772.

A lot of code here is pretty repetitive; please let me know if you have any ideas how to improve it, or whether it’s fine as-is.

Side-note: How can I add tests for this? I don’t see a way for the test Rust code in test_highlighting to reference other crates to observe the new behaviour.

@lunacookies lunacookies marked this pull request as draft May 23, 2021 13:49
crates/hir/src/lib.rs Outdated Show resolved Hide resolved
@Veykril
Copy link
Member

Veykril commented May 23, 2021

Regarding the tests you should be able to just do the following as the fixture source:

//- /main.rs crate:main deps:dep
use dep::Foo;
...
//- /lib.rs crate:dep
pub struct Foo;

If I see this right you should only get stuff from main.rs(the first fixture part, order is important) highlighted back by the test infra.

Edit: Turns out we already do something like that here https://github.com/rust-analyzer/rust-analyzer/blob/f04daf693aec9f3ffbd98bd368b79646246d506b/crates/ide/src/syntax_highlighting/tests.rs#L666-L681

@matklad
Copy link
Member

matklad commented May 23, 2021 via email

@lunacookies
Copy link
Contributor Author

Should built-in types have the library modifier?

@lunacookies lunacookies changed the title Add ‘foreign’ semantic token modifier to items from other crates Add library semantic token modifier to items from other crates May 24, 2021
@lunacookies lunacookies marked this pull request as ready for review May 24, 2021 05:01
@Veykril
Copy link
Member

Veykril commented May 24, 2021

I would say no, since technically they don't come from a library and they already have the BuiltinType tag so they can already be colored separately if desired anyways.

@lunacookies
Copy link
Contributor Author

@Veykril Makes sense. Do you have any other feedback for me? :)

@Veykril
Copy link
Member

Veykril commented May 24, 2021

bors d+

@bors
Copy link
Contributor

bors bot commented May 24, 2021

✌️ arzg can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@lunacookies
Copy link
Contributor Author

bors r+

@bors
Copy link
Contributor

bors bot commented May 25, 2021

@bors bors bot merged commit 8b049ec into rust-lang:master May 25, 2021
@lunacookies lunacookies deleted the foreign branch May 25, 2021 02:40
@lnicola lnicola changed the title Add library semantic token modifier to items from other crates fix: Add library semantic token modifier to items from other crates May 25, 2021
@lnicola lnicola changed the title fix: Add library semantic token modifier to items from other crates feat: Add library semantic token modifier to items from other crates May 25, 2021
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.

In-project vs external semantic highlighting
3 participants