From 96e650bf000bf4fe8fdf9e443ff7244d460db95a Mon Sep 17 00:00:00 2001 From: Andrew Gvozdev Date: Sat, 13 Mar 2010 04:18:04 +0000 Subject: [PATCH] bug 305748: Place deprecated error parsers on the bottom of the list --- .../tests/RegexErrorParserTests.java | 30 ++++++++++++++++--- .../core/CCorePluginResources.properties | 1 + .../ErrorParserExtensionManager.java | 23 +++++++++++++- 3 files changed, 49 insertions(+), 5 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/RegexErrorParserTests.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/RegexErrorParserTests.java index 3f5ac32666a..0757de8ef6d 100644 --- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/RegexErrorParserTests.java +++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/RegexErrorParserTests.java @@ -25,6 +25,7 @@ import org.eclipse.cdt.core.ProblemMarkerInfo; import org.eclipse.cdt.core.errorparsers.ErrorParserNamedWrapper; import org.eclipse.cdt.core.errorparsers.RegexErrorParser; import org.eclipse.cdt.core.errorparsers.RegexErrorPattern; +import org.eclipse.cdt.core.testplugin.CTestPlugin; import org.eclipse.cdt.core.testplugin.ResourceHelper; import org.eclipse.cdt.internal.errorparsers.ErrorParserExtensionManager; import org.eclipse.cdt.internal.errorparsers.GASErrorParser; @@ -309,19 +310,40 @@ public class RegexErrorParserTests extends TestCase { } /** - * Make sure extensions contributed through extension point are sorted by name. + * Make sure extensions contributed through extension point are sorted by name + * unless deprecated or contributed by test plugin. * * @throws Exception... */ public void testExtensionsSorting() throws Exception { { String[] ids = ErrorParserManager.getErrorParserExtensionIds(); - String lastName=""; - // error parsers created from extensions are to be sorted by names + String lastName = ""; + boolean lastIsDeprecated = false; + boolean lastIsTestPlugin = false; + // first regular error parsers + // then deprecated ones + // then contributed by test plugin for (String id : ids) { String name = ErrorParserManager.getErrorParserCopy(id).getName(); - assertTrue(lastName.compareTo(name)<=0); + boolean isDeprecated = name.contains("(Deprecated)"); + boolean isTestPlugin = id.startsWith(CTestPlugin.PLUGIN_ID); + String message = "Parser ["+lastName+"] preceeds ["+name+"]"; + + // inside the same category sorted by names + if (lastIsDeprecated==isDeprecated && lastIsTestPlugin==isTestPlugin) { + assertTrue(message, lastName.compareTo(name)<=0); + } + // deprecated follow non-deprecated (unless parsers from test plugin show up) + if (lastIsTestPlugin==isTestPlugin) { + assertFalse(message, lastIsDeprecated==true && isDeprecated==false); + } + // error parsers from test plugin are the last + assertFalse(message, lastIsTestPlugin==true && isTestPlugin==false); + lastName = name; + lastIsDeprecated = isDeprecated; + lastIsTestPlugin = isTestPlugin; } } } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePluginResources.properties b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePluginResources.properties index 928e98920b1..44d8af158f9 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePluginResources.properties +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePluginResources.properties @@ -31,6 +31,7 @@ CommandLauncher.error.commandCanceled=Command canceled CCProjectNature.exception.noNature=Project must have a cnature CCorePlugin.exception.noBinaryFormat=No Binary Format +CCorePlugin.Deprecated=(Deprecated) CDescriptorManager.exception.invalid_ownerID=Invalid CDT Project owner ID CDescriptorManager.exception.alreadyConfigured=CDT Project already configured diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/ErrorParserExtensionManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/ErrorParserExtensionManager.java index d2e4ba56b9b..ecacb15e6da 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/ErrorParserExtensionManager.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/ErrorParserExtensionManager.java @@ -212,9 +212,30 @@ public class ErrorParserExtensionManager { * @noreference This method is not intended to be referenced by clients. */ synchronized public static void loadErrorParserExtensions() { - // sort by name - for the error parsers taken from platform extensions Set sortedErrorParsers = new TreeSet(new Comparator() { + // For the error parsers taken from platform extensions following sorting order applies: + // - first regular error parsers + // - then deprecated ones + // - then contributed by test plugin + // inside the same category sort by parser name public int compare(IErrorParserNamed errorParser1, IErrorParserNamed errorParser2) { + final String TEST_PLUGIN_ID="org.eclipse.cdt.core.tests"; //$NON-NLS-1$ + final String DEPRECATED=CCorePlugin.getResourceString("CCorePlugin.Deprecated"); //$NON-NLS-1$ + + boolean isTestPlugin1 = errorParser1.getId().startsWith(TEST_PLUGIN_ID); + boolean isTestPlugin2 = errorParser2.getId().startsWith(TEST_PLUGIN_ID); + if (isTestPlugin1==true && isTestPlugin2==false) + return 1; + if (isTestPlugin1==false && isTestPlugin2==true) + return -1; + + boolean isDeprecated1 = errorParser1.getName().contains(DEPRECATED); + boolean isDeprecated2 = errorParser2.getName().contains(DEPRECATED); + if (isDeprecated1==true && isDeprecated2==false) + return 1; + if (isDeprecated1==false && isDeprecated2==true) + return -1; + return errorParser1.getName().compareTo(errorParser2.getName()); } });