Community
Participate
Working Groups
While doing the dead-code analysis I found this code in org.eclipse.team.internal.ui.registry.TeamContentProviderDescriptor.readExtension(IExtension): for (int i = 0; i < count; i++) { IConfigurationElement element = elements[i]; configElement = element; String name = element.getName(); if (name.equalsIgnoreCase(TAG_TEAM_CONTENT_PROVIDER)) { modelProviderId = element.getAttribute(ATT_MODEL_PROVIDER_ID); contentExtensionId = element.getAttribute(ATT_CONTENT_EXTENSION_ID); String supportsFlatLayoutString = element.getAttribute(ATT_SUPPORTS_FLAT_LAYOUT); if (supportsFlatLayoutString != null) { supportsFlatLayout = Boolean.valueOf(supportsFlatLayoutString).booleanValue(); } contentProviderName = extension.getLabel(); } break; } Obviously the loop is either useless as it will at most handle elements[0] or it is broken.
This fancy trick looks like an alternative for the if statement ;-)
>This fancy trick looks like an alternative for the if statement ;-) Does it LOOK LIKE or IS IT? If it is, then it is a polish bug but otherwise it's simply broken code that needs work and isn't polish.
It looks like. During M5 I'll take a closer look at it.
To me, it looks like the code loops through all the elements of the extension until it finds one that is a team content provider. I don't have access to the schema at the moment but it seems to me that the code is valid if the schema allow for multiple unordered elements in the extension, one of which can be a team content provider (or am I missing something?).
>To me, it looks like the code loops The point is that it DOES NOT loop as the first iteration hits the 'break'
Ah, missed that one (and clearly I missed it when I wrote the code too ;-) The intent was what I described in comment 4.
>Ah, missed that one Yeah, we had such code too in our plug-ins. The Dead code analysis is cool!
(In reply to comment #6) > Ah, missed that one (and clearly I missed it when I wrote the code too ;-) The > intent was what I described in comment 4. > Confusing was that break; was added during API cleaning. This is what the commit comment says at least. Thanks Michael.
Created attachment 118981 [details] Fix v01
Created attachment 118982 [details] Fix v02 Slightly modified fix, added a message shown in a situation when the number of elements is different then 1.
Created attachment 118983 [details] mylyn/context/zip
Released to HEAD.