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

TYPE: display notification panel when a file is not included in the module tree #3826

Merged
merged 2 commits into from
May 10, 2019

Conversation

Kobzol
Copy link
Member

@Kobzol Kobzol commented May 10, 2019

This PR adds a notification panel that warns about files which are not included in any module tree.
Currently the file has to be re-opened for the notification bar to update.

Corresponding issue: #1675

@vlad20012
Copy link
Member

Currently the file has to be re-opened for the notification bar to update.

Just add this code to init block:

subscribe(RUST_STRUCTURE_CHANGE_TOPIC, object : RustStructureChangeListener {
                override fun rustStructureChanged(file: PsiFile?, changedElement: PsiElement?) {
                    notifications.updateAllNotifications()
                }
            })

@vlad20012
Copy link
Member

Btw #3426 can be solved by some action (see createActionLabel)

@Kobzol
Copy link
Member Author

Kobzol commented May 10, 2019

Just add this code to init block:

Thank you, it works nicely :)

Considering #3426, what should the action do? Let's say there's a file a.rs in directory b. If I wanted to include this file in the tree, in theory it could be included either to b/mod.rs, b.rs, or lib.rs/main.rs/whatever the root file is called. So I need to get from the containing directory of the said file to a module root file. Is there an API for that? I tried using toPsiDirectory for the parent of the file, but I don't know how to get from a PsiDirectory to anything Rust related (e.g. RsElement).

@vlad20012
Copy link
Member

vlad20012 commented May 10, 2019

what should the action do? Let's say there's a file a.rs in directory b. If I wanted to include this file in the tree, in theory it could be included either to b/mod.rs, b.rs, or lib.rs/main.rs/whatever the root file is called.

... or anywhere else via #[path] attribute or include!() macro, or it shouldn't be included anywhere at all because it is just a code sample/test (like in IntelliJ Rust tests) etc etc etc

Yes, this is not trivial =) And I can't suggest anything for now.

I think this PR is finished. Thanks!
bors r+

bors bot added a commit that referenced this pull request May 10, 2019
3826: TYPE: display notification panel when a file is not included in the module tree r=vlad20012 a=Kobzol

This PR adds a notification panel that warns about files which are not included in any module tree.
Currently the file has to be re-opened for the notification bar to update.

Corresponding issue: #1675

Co-authored-by: Jakub Beránek <berykubik@gmail.com>
@Kobzol
Copy link
Member Author

Kobzol commented May 10, 2019

Speaking of include!, this will probably show false positives for files included with it, at least until #1908 and similar are resolved, but there's probably not much that can be done about that. Thank you.

@vlad20012
Copy link
Member

I don't think we should call it "false positive". This bar says that "analysis is not available", and it actually is not available :)

@Kobzol
Copy link
Member Author

Kobzol commented May 10, 2019

Indeed, the false positive part is actually File is not included in module tree :)

@bors
Copy link
Contributor

bors bot commented May 10, 2019

Build succeeded

@bors bors bot merged commit 7298b8e into intellij-rust:master May 10, 2019
@Kobzol Kobzol deleted the notification-file-nomodule branch May 10, 2019 15:44
@Undin Undin added the feature label May 12, 2019
@mchernyavsky mchernyavsky added this to the v98 milestone May 23, 2019
bors bot added a commit that referenced this pull request Jun 19, 2019
3961: UI: introduce detached notification provider r=vlad20012 a=Undin

Extract "File is not included in module tree, ..." notification introduced in #3826 to separate notification provider and allow to disable such notifications (#771 (comment))


Co-authored-by: Arseniy Pendryak <a.pendryak@yandex.ru>
bors bot added a commit that referenced this pull request Jun 19, 2019
3961: UI: introduce detached notification provider r=vlad20012 a=Undin

Extract "File is not included in module tree, ..." notification introduced in #3826 to separate notification provider and allow to disable such notifications (#771 (comment))


Co-authored-by: Arseniy Pendryak <a.pendryak@yandex.ru>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants