Questions about structure view

Hi,

I implemented a structure view in my custom language plugin, but I have two questions related to this:

- my StructureViewModel implements StructureViewModel.ExpandInfoProvider to automatically collapse certains nodes, but why does it only work in the structure tool window, not the popup?
- how can I add more than one color in a StructureViewTreeElement's label? It seems that PresentationData supports it via its myColoredText attribute, but it's never populated in PresentationData.updateFrom(ItemPresentation presentation)

For the second question, it seems that the only way to achieve this is to create a whole new component for the structure view, I didn't find any way to override TreeElementWrapper#update(PresentationData presentation).
Perhaps you could add a method named getColoredFragments() in ColoredItemPresentation, or add a new interface like ColoredFragmentAware, and handle this change in PresentationData.updateFrom(ItemPresentation presentation) ?

0
Avatar
Permanently deleted user

In relation to question1: I also created a InheritedMembersNodeProvider to show parent members, but they are only shown in the tool window, not in the popup?!

0
Avatar
Permanently deleted user

Also, I noticed a strange thing: I have a filter that implements FileStructureFilter, so that it's also shown in the structure popup. Note that this filter is not reverted. Now, when I open the structure popup, the nodes matched by the filters are not displayed, although the checkbox is not checked. The correct behaviour should be: the nodes shouldn't be displayed only if the checkbox is checked (unless the filter is reverted).

I traced it down to FileStructurePopup#addCheckbox(JPanel, TreeAction), which assumes the filter is always reverted:

 
myTreeActionsOwner.setActionIncluded(action, action instanceof FileStructureFilter ? !selected : selected);


So in my case, if the checkbox is not selected, the filter is applied and nodes are removed. I think the correct impl should be:

 
myTreeActionsOwner.setActionIncluded(action, action instanceof FileStructureFilter && ((FileStructureFilter) action).isReverted() ? !selected : selected);


The only implementations I found is PyInheritedMembersFilter, and the old JavaAnonymousMembersFilter[1], which are both reverted filters, so I guess my problem never occured.

Should I open an issue for this?

[1] https://github.com/JetBrains/intellij-community/blob/9739a4d3c47d1a1f5eb3033d60b08cc6827af125/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaAnonymousMembersFilter.java

0
Avatar
Konstantin Bulenkov

Hello Bastien!
Good catch! Also, I think we should add extra check a few lines below as well. Take a look at the patch attached



Attachment(s):
fix_FileStructurePopup_for_non-reverted_File_Structure_Filters.patch.zip
0
Avatar
Permanently deleted user

Yes, I saw that too. I submitted an issue to track the bug and a created a PR a few hours ago to fix it:

https://youtrack.jetbrains.com/issue/IDEA-142411
https://github.com/JetBrains/intellij-community/pull/285

I also made a similar change in FileStructureDialog, even though I don't know where it's used.

About my other problems, I submitted a second PR to allow multiple colors in nodes shown in the structure view:

https://github.com/JetBrains/intellij-community/pull/286

I would be grateful if you could merge those pull requests :)

Thanks

0
Avatar
Permanently deleted user

Is the behavior in the following screenshot normal?

Capture d’écran 2015-07-09 à 09.40.58.png

The tool window shows members inherited from Object in both classes, but the popup does not show every inherited member under Test2, because it considers they are duplicates of those under Test1. In my opinion, this is not the correct behavior. What do you think?

0

请先登录再写评论。