Skip to content

Commit 90fd94e

Browse files
committed
Optionally filter by Scope in CommandDescriptionBuilder.verifyManuallyAdded
1 parent 749d47a commit 90fd94e

1 file changed

Lines changed: 35 additions & 2 deletions

File tree

‎src/main/java/org/scijava/ui/behaviour/io/gui/CommandDescriptionsBuilder.java‎

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,45 @@ public void discoverProviders( final Predicate< CommandDescriptionProvider > pre
137137
* otherwise.
138138
*/
139139
public void verifyManuallyAdded()
140+
{
141+
verifyManuallyAdded( ( List< CommandDescriptionProvider.Scope > ) null );
142+
}
143+
144+
/**
145+
* Debugging helper. Checks whether all manually added providers are
146+
* automatically discovered, and vice versa. Prints warnings to stderr
147+
* otherwise.
148+
* <p>
149+
* Only {@code CommandDescriptionProvider}s with {@link CommandDescriptionProvider#getScope() scope}
150+
* matching any of the provided {@code discoveryScopes} are considered.
151+
*
152+
* @param discoveryScopes
153+
* only consider CommandDescriptionProviders having any of these scopes
154+
*/
155+
public void verifyManuallyAdded( final CommandDescriptionProvider.Scope... discoveryScopes )
156+
{
157+
verifyManuallyAdded( Arrays.asList( discoveryScopes ) );
158+
}
159+
160+
/**
161+
* Debugging helper. Checks whether all manually added providers are
162+
* automatically discovered, and vice versa. Prints warnings to stderr
163+
* otherwise.
164+
* <p>
165+
* If {@code discoveryScopes} is provided, only {@code CommandDescriptionProvider}s
166+
* with matching {@link CommandDescriptionProvider#getScope() scope}s are considered.
167+
*
168+
* @param discoveryScopes
169+
* only consider CommandDescriptionProviders having any of the listed scopes. If this is {@code null}, all scopes are considered.
170+
*/
171+
private void verifyManuallyAdded( final List< CommandDescriptionProvider.Scope > discoveryScopes )
140172
{
141173
final List< ProviderAndContext > discovered = new ArrayList<>();
142174
final List< CommandDescriptionProvider > providers = pluginService.createInstancesOfType( CommandDescriptionProvider.class );
143175
for ( final CommandDescriptionProvider provider : providers )
144-
for ( final String context : provider.getExpectedContexts() )
145-
discovered.add( new ProviderAndContext( provider, context ) );
176+
if ( discoveryScopes == null || discoveryScopes.contains( provider.getScope() ) )
177+
for ( final String context : provider.getExpectedContexts() )
178+
discovered.add( new ProviderAndContext( provider, context ) );
146179

147180
// Can all registered providers be discovered?
148181
boolean anyFailed = false;

0 commit comments

Comments
 (0)