CustomScopeProvider: is there a way to add/remove scopes dynamically?


Based on changed plugin configuration I'd like to add/remove custom scopes.
Is there a way to accomplish this?


7 comments


Any ideas?
I've tried using DependencyValidationManager#getScopes()/setScopes(), but
that results is duplication of the built-in scopes (Production/Tests/Problems).


0

Hello Taras,

@NotNull public List getPredefinedScopes() { if (myPredifinedScopes == null){ myPredifinedScopes = new ArrayList(); final CustomScopesProvider[] scopesProviders = myProject.getExtensions(CustomScopesProvider.CUSTOM_SCOPES_PROVIDER); if (scopesProviders != null) { for (CustomScopesProvider scopesProvider : scopesProviders) { myPredifinedScopes.addAll(scopesProvider.getCustomScopes()); } } } return myPredifinedScopes; } ]]>

I can make it eager. Could you please describe your usecase in detail?

Thank you.

-


Anna Kozlova
JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

Based on changed plugin configuration I'd like to add/remove custom
scopes. Is there a way to accomplish this?



0

Hello Anna,

I can make it eager. Could you please describe your usecase in detail?


Inside my plugin configuration dialog, it's possible to enable/disable some
custom scopes contributed by this plugin.
At the moment this requires a project reload to take effect, which is a bit
drastic. That is all.

Taras


0

Hello Taras,

Done.

Thank you

-


Anna Kozlova
JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

Hello Anna,

>> I can make it eager. Could you please describe your usecase in
>> detail?
>>

Inside my plugin configuration dialog, it's possible to enable/disable
some
custom scopes contributed by this plugin.
At the moment this requires a project reload to take effect, which is
a bit
drastic. That is all.
Taras



0

Hello Anna,

Done.


Thanks. Now things work like I want them to. Some small questions:

1)
I use this code to force a refresh of the available scopes:
---
DependencyValidationManager scopesHolder =
DependencyValidationManager.getInstance(project);
scopesHolder.setScopes(new NamedScope[0]);
---
After this, all my ScopeProviders are re-queried (getCustomScopes()), and
the ones that are enabled return their scopes.

This seems to work, but I'm not sure if I remove too much by calling setScopes()
with an empty array. Should I do it this way?

2)
After testing my custom scopes, I noticed leak reports in the console:
-


      • The following objects were not disposed:

      • com.intellij.ide.scopeView.ScopeTreeViewPanel[,0,0,400x809,layout=java.awt.BorderLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=]

of class class com.intellij.ide.scopeView.ScopeTreeViewPanel

      • com.intellij.ide.scopeView.ScopeTreeViewPanel[,0,0,400x809,layout=java.awt.BorderLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=]

of class class com.intellij.ide.scopeView.ScopeTreeViewPanel

      • com.intellij.ide.scopeView.ScopeTreeViewPanel[,0,0,400x809,layout=java.awt.BorderLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=]

of class class com.intellij.ide.scopeView.ScopeTreeViewPanel

      • com.intellij.ide.scopeView.ScopeTreeViewPanel[,0,0,400x809,layout=java.awt.BorderLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=]

of class class com.intellij.ide.scopeView.ScopeTreeViewPanel

      • com.intellij.ide.scopeView.ScopeTreeViewPanel[,0,0,400x809,layout=java.awt.BorderLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=]

of class class com.intellij.ide.scopeView.ScopeTreeViewPanel

      • com.intellij.ide.scopeView.ScopeViewPane@1f67dee of class class com.intellij.ide.scopeView.ScopeViewPane

      • com.intellij.ide.scopeView.ScopeTreeViewPanel[,0,0,400x809,layout=java.awt.BorderLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=]

of class class com.intellij.ide.scopeView.ScopeTreeViewPanel
-



I don't know if it's related, but I'm calling "ProjectView.getInstance(project).refresh();"
when the "rules" for my custom scope have changed, to force re-evaluation
of what files are now part of the scope.
Can I help diagnose the problem somehow?

Kind regards,
Taras


0

Hello Taras,

I use this code to force a refresh of the available scopes:
---
DependencyValidationManager scopesHolder =
DependencyValidationManager.getInstance(project);
scopesHolder.setScopes(new NamedScope[0]);
---
After this, all my ScopeProviders are re-queried (getCustomScopes()),
and
the ones that are enabled return their scopes.
This seems to work, but I'm not sure if I remove too much by calling
setScopes() with an empty array. Should I do it this way?


You may remove all scopes configured by user.

Please use NamedScopesHolder.fireScopeListeners() (now public) in order to
enforce repainting project view. all other activities do not cache scopes
as far I remember ...

2)
After testing my custom scopes, I noticed leak reports in the console:


Could you please after closing project get a snapshot and upload it to ftp://intellij.net/.uploads
or just describe steps to reproduce? I've checked some time ago and there
were no memory leak with Scope View but unfortunately I can't be sure.

-------

      • The following objects were not disposed:

***
com.intellij.ide.scopeView.ScopeTreeViewPanel[,0,0,400x809,layout=java
.awt.BorderLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximu
mSize=,minimumSize=,preferredSize=]
of class class com.intellij.ide.scopeView.ScopeTreeViewPanel
***
com.intellij.ide.scopeView.ScopeTreeViewPanel[,0,0,400x809,layout=java
.awt.BorderLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximu
mSize=,minimumSize=,preferredSize=]
of class class com.intellij.ide.scopeView.ScopeTreeViewPanel
***
com.intellij.ide.scopeView.ScopeTreeViewPanel[,0,0,400x809,layout=java
.awt.BorderLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximu
mSize=,minimumSize=,preferredSize=]
of class class com.intellij.ide.scopeView.ScopeTreeViewPanel
***
com.intellij.ide.scopeView.ScopeTreeViewPanel[,0,0,400x809,layout=java
.awt.BorderLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximu
mSize=,minimumSize=,preferredSize=]
of class class com.intellij.ide.scopeView.ScopeTreeViewPanel
***
com.intellij.ide.scopeView.ScopeTreeViewPanel[,0,0,400x809,layout=java
.awt.BorderLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximu
mSize=,minimumSize=,preferredSize=]
of class class com.intellij.ide.scopeView.ScopeTreeViewPanel

      • com.intellij.ide.scopeView.ScopeViewPane@1f67dee of class class

com.intellij.ide.scopeView.ScopeViewPane
***
com.intellij.ide.scopeView.ScopeTreeViewPanel[,0,0,400x809,layout=java
.awt.BorderLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximu
mSize=,minimumSize=,preferredSize=]
of class class com.intellij.ide.scopeView.ScopeTreeViewPanel
-------
I don't know if it's related, but I'm calling
"ProjectView.getInstance(project).refresh();"
when the "rules" for my custom scope have changed, to force
re-evaluation
of what files are now part of the scope.
Can I help diagnose the problem somehow?
Kind regards,
Taras


Thank you.

-


Anna Kozlova
JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"


0

Hello Anna,

2)
After testing my custom scopes, I noticed leak

reports in the console:

Could you please after closing project get a snapshot
and upload it to ftp://intellij.net/.uploads
or just describe steps to reproduce? I've checked
some time ago and there
were no memory leak with Scope View but unfortunately
I can't be sure.


See IDEA-14116 for details, including a memory snapshot.
Please comment here (or in JIRA) if you need more information.

Regards,

Taras

0

Please sign in to leave a comment.