mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 09:16:02 +02:00
bug 305748: Place deprecated error parsers on the bottom of the list
This commit is contained in:
parent
c393671389
commit
96e650bf00
3 changed files with 49 additions and 5 deletions
|
@ -25,6 +25,7 @@ import org.eclipse.cdt.core.ProblemMarkerInfo;
|
||||||
import org.eclipse.cdt.core.errorparsers.ErrorParserNamedWrapper;
|
import org.eclipse.cdt.core.errorparsers.ErrorParserNamedWrapper;
|
||||||
import org.eclipse.cdt.core.errorparsers.RegexErrorParser;
|
import org.eclipse.cdt.core.errorparsers.RegexErrorParser;
|
||||||
import org.eclipse.cdt.core.errorparsers.RegexErrorPattern;
|
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.core.testplugin.ResourceHelper;
|
||||||
import org.eclipse.cdt.internal.errorparsers.ErrorParserExtensionManager;
|
import org.eclipse.cdt.internal.errorparsers.ErrorParserExtensionManager;
|
||||||
import org.eclipse.cdt.internal.errorparsers.GASErrorParser;
|
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...
|
* @throws Exception...
|
||||||
*/
|
*/
|
||||||
public void testExtensionsSorting() throws Exception {
|
public void testExtensionsSorting() throws Exception {
|
||||||
{
|
{
|
||||||
String[] ids = ErrorParserManager.getErrorParserExtensionIds();
|
String[] ids = ErrorParserManager.getErrorParserExtensionIds();
|
||||||
String lastName="";
|
String lastName = "";
|
||||||
// error parsers created from extensions are to be sorted by names
|
boolean lastIsDeprecated = false;
|
||||||
|
boolean lastIsTestPlugin = false;
|
||||||
|
// first regular error parsers
|
||||||
|
// then deprecated ones
|
||||||
|
// then contributed by test plugin
|
||||||
for (String id : ids) {
|
for (String id : ids) {
|
||||||
String name = ErrorParserManager.getErrorParserCopy(id).getName();
|
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;
|
lastName = name;
|
||||||
|
lastIsDeprecated = isDeprecated;
|
||||||
|
lastIsTestPlugin = isTestPlugin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ CommandLauncher.error.commandCanceled=Command canceled
|
||||||
CCProjectNature.exception.noNature=Project must have a cnature
|
CCProjectNature.exception.noNature=Project must have a cnature
|
||||||
|
|
||||||
CCorePlugin.exception.noBinaryFormat=No Binary Format
|
CCorePlugin.exception.noBinaryFormat=No Binary Format
|
||||||
|
CCorePlugin.Deprecated=(Deprecated)
|
||||||
|
|
||||||
CDescriptorManager.exception.invalid_ownerID=Invalid CDT Project owner ID
|
CDescriptorManager.exception.invalid_ownerID=Invalid CDT Project owner ID
|
||||||
CDescriptorManager.exception.alreadyConfigured=CDT Project already configured
|
CDescriptorManager.exception.alreadyConfigured=CDT Project already configured
|
||||||
|
|
|
@ -212,9 +212,30 @@ public class ErrorParserExtensionManager {
|
||||||
* @noreference This method is not intended to be referenced by clients.
|
* @noreference This method is not intended to be referenced by clients.
|
||||||
*/
|
*/
|
||||||
synchronized public static void loadErrorParserExtensions() {
|
synchronized public static void loadErrorParserExtensions() {
|
||||||
// sort by name - for the error parsers taken from platform extensions
|
|
||||||
Set<IErrorParserNamed> sortedErrorParsers = new TreeSet<IErrorParserNamed>(new Comparator<IErrorParserNamed>() {
|
Set<IErrorParserNamed> sortedErrorParsers = new TreeSet<IErrorParserNamed>(new Comparator<IErrorParserNamed>() {
|
||||||
|
// 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) {
|
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());
|
return errorParser1.getName().compareTo(errorParser2.getName());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue