[Outline] Support for all containerName != null
Closed this issue · 7 comments
I believe that not all LS will provide symbols information ready to be converted to tree. It would be nice to have outline option to switch between tree/flat structure. By flat structure I mean list of SymbolInformation elements as is.
How would an option be helpful? What about showing a Tree when there are enough informations, and a list otherwise? I believe the current TreeContentProvider already works that way.
Hmm if we can detect when tree cannot be created then I think it will be the best solution. I'm talking about case where e.g. there are no elements with containerName=null. Such case will result with empty outline. I have such problem in PHP LS. Class has containerName because its in namespace but namespace isn't indexed (stored in symbols set). I understand that most probably such situation should be fixed in LS but it would be nice to have plan B :)
The outline tree is built according to the range in SymbolInformation ( https://github.com/eclipselabs/eclipse-language-service/blob/master/org.eclipse.languageserver/src/org/eclipse/languageserver/outline/LSSymbolsContentProvider.java#L113 ).
Only the getElements(...)
would need to be changed then (https://github.com/eclipselabs/eclipse-language-service/blob/master/org.eclipse.languageserver/src/org/eclipse/languageserver/outline/LSSymbolsContentProvider.java#L87 ) to return the top-level symbols according to ranges.
Yes, good point! Works as expected when I changed getElement into this.lastResponse.stream().filter(symbol -> getParent(symbol) == null).toArray();
Would you like to make a PR or do you prefer me to implement this change?
If you have time make PR, if not I will do this tomorrow :)
Fixed with b75055c