holgerbrandl / r4intellij

An integration of the R programming language into Intellij IDEA
BSD 2-Clause "Simplified" License
148 stars 28 forks source link

The plugin freezes the IDE by making a ton of project model modifications. #109

Open trespasserw opened 7 years ago

trespasserw commented 7 years ago

First, forcing a dependency into each and every module is a bad practice.

The code in LibraryUtil.createLibrary performs multiple model commits, and each commit triggers a lot of activity in the IDE. Wrapping commits with ProjectRootManagerEx.mergeRootsChangesDuring() will reduce the pressure.

trespasserw commented 7 years ago

Original request: https://youtrack.jetbrains.com/issue/IDEA-174818

holgerbrandl commented 7 years ago

I also did not like the "forcing" but I did not know how to better. I've asked under https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000440770-How-to-search-global-library-without-module-attachment and hopefully they help to find a better solution.

trespasserw commented 7 years ago

I also asked a colleague to look into this - maybe he'll come with a better idea.

kshchepanovskyi commented 6 years ago

Hi, I came across this issue when I was working on similar issue for https://plugins.jetbrains.com/plugin/8277-protobuf-support. I implemented suggestion from JetBrains forum in my plugin, it works well.

If you still need solution, here's my implementation: https://github.com/protostuff/protobuf-jetbrains-plugin/blob/f5078318167000c5a57741e321d8e5d3be8e6790/src/main/java/io/protostuff/jetbrains/plugin/ProtostuffPluginController.java#L95

holgerbrandl commented 6 years ago

Thanks for the pointer. Currently we wrap the complete set of modification already with ApplicationManager.getApplication().runWriteAction. Shouldn't this be sufficient? See https://github.com/holgerbrandl/r4intellij/blob/ce16868defca7634747852bff1656420f2b280da/src/com/r4intellij/settings/LibraryUtil.java#L34

At what level should we wrap with ProjectRootManagerEx mergeRootsChangesDuring()?

kshchepanovskyi commented 6 years ago

It's not about level, it's about this comment:

Clarification: there is nothing wrong in having the R package in dependencies of a module. The bad practice is adding the dependency to all modules - even to those which don't have a single R file in it.

holgerbrandl commented 6 years ago

I see, instead of all we update the project on the fly if an R file is opened. I like, and will try to implement this way. Thanks again for your help.