mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Sort LSE by kinds
This commit is contained in:
parent
f02dc2e531
commit
64982d49e8
4 changed files with 191 additions and 72 deletions
|
@ -770,46 +770,21 @@ public class GCCBuildCommandParserTest extends TestCase {
|
||||||
|
|
||||||
// check populated entries
|
// check populated entries
|
||||||
List<ICLanguageSettingEntry> entries = parser.getSettingEntries(cfgDescription, file, languageId);
|
List<ICLanguageSettingEntry> entries = parser.getSettingEntries(cfgDescription, file, languageId);
|
||||||
|
String device = project.getLocation().getDevice();
|
||||||
// + " -I/path0 "
|
// + " -I/path0 "
|
||||||
{
|
assertEquals(new CIncludePathEntry(new Path("/path0").setDevice(device), 0), entries.get(0));
|
||||||
IPath path = new Path("/path0").setDevice(project.getLocation().getDevice());
|
|
||||||
CIncludePathEntry expected = new CIncludePathEntry(path, 0);
|
|
||||||
assertEquals(expected, entries.get(0));
|
|
||||||
}
|
|
||||||
// + " -DMACRO1=value"
|
|
||||||
{
|
|
||||||
CMacroEntry expected = new CMacroEntry("MACRO1", "value", 0);
|
|
||||||
assertEquals(expected, entries.get(1));
|
|
||||||
}
|
|
||||||
// + " -ldomain"
|
|
||||||
{
|
|
||||||
CLibraryFileEntry expected = new CLibraryFileEntry("libdomain.a", 0);
|
|
||||||
assertEquals(expected, entries.get(2));
|
|
||||||
}
|
|
||||||
// + " -I /path1 "
|
// + " -I /path1 "
|
||||||
{
|
assertEquals(new CIncludePathEntry(new Path("/path1").setDevice(device), 0), entries.get(1));
|
||||||
IPath path = new Path("/path1").setDevice(project.getLocation().getDevice());
|
|
||||||
CIncludePathEntry expected = new CIncludePathEntry(path, 0);
|
|
||||||
assertEquals(expected, entries.get(3));
|
|
||||||
}
|
|
||||||
// + " -DMACRO2=\"value with spaces\""
|
|
||||||
{
|
|
||||||
CMacroEntry expected = new CMacroEntry("MACRO2", "value with spaces", 0);
|
|
||||||
assertEquals(expected, entries.get(4));
|
|
||||||
}
|
|
||||||
// + " -I\"/path with spaces\""
|
// + " -I\"/path with spaces\""
|
||||||
{
|
assertEquals(new CIncludePathEntry(new Path("/path with spaces").setDevice(device), 0), entries.get(2));
|
||||||
IPath path = new Path("/path with spaces").setDevice(project.getLocation().getDevice());
|
// + " -DMACRO1=value"
|
||||||
CIncludePathEntry expected = new CIncludePathEntry(path, 0);
|
assertEquals(new CMacroEntry("MACRO1", "value", 0), entries.get(3));
|
||||||
assertEquals(expected, entries.get(5));
|
// + " -DMACRO2=\"value with spaces\""
|
||||||
}
|
assertEquals(new CMacroEntry("MACRO2", "value with spaces", 0), entries.get(4));
|
||||||
// + " -L/usr/lib"
|
// + " -L/usr/lib"
|
||||||
{
|
assertEquals(new CLibraryPathEntry(new Path("/usr/lib").setDevice(device), 0), entries.get(5));
|
||||||
IPath path = new Path("/usr/lib").setDevice(project.getLocation().getDevice());
|
// + " -ldomain"
|
||||||
CLibraryPathEntry expected = new CLibraryPathEntry(path, 0);
|
assertEquals(new CLibraryFileEntry("libdomain.a", 0), entries.get(6));
|
||||||
assertEquals(expected, entries.get(6));
|
|
||||||
}
|
|
||||||
|
|
||||||
assertEquals(7, entries.size());
|
assertEquals(7, entries.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1811,11 +1786,11 @@ public class GCCBuildCommandParserTest extends TestCase {
|
||||||
// check populated entries
|
// check populated entries
|
||||||
{
|
{
|
||||||
List<ICLanguageSettingEntry> entries = parser.getSettingEntries(cfgDescription, file, languageId);
|
List<ICLanguageSettingEntry> entries = parser.getSettingEntries(cfgDescription, file, languageId);
|
||||||
assertEquals(new CMacroEntry("BOOST_ALL_NO_LIB", "1", 0), entries.get(0));
|
assertEquals(new CIncludePathEntry(project.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(0));
|
||||||
assertEquals(new CMacroEntry("BOOST_PYTHON_SOURCE", "", 0), entries.get(1));
|
assertEquals(new CIncludePathEntry(new Path("/Python1025/Include").setDevice(project.getLocation().getDevice()), 0), entries.get(1));
|
||||||
assertEquals(new CMacroEntry("BOOST_PYTHON_STATIC_LIB", "", 0), entries.get(2));
|
assertEquals(new CMacroEntry("BOOST_ALL_NO_LIB", "1", 0), entries.get(2));
|
||||||
assertEquals(new CIncludePathEntry(project.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(3));
|
assertEquals(new CMacroEntry("BOOST_PYTHON_SOURCE", "", 0), entries.get(3));
|
||||||
assertEquals(new CIncludePathEntry(new Path("/Python1025/Include").setDevice(project.getLocation().getDevice()), 0), entries.get(4));
|
assertEquals(new CMacroEntry("BOOST_PYTHON_STATIC_LIB", "", 0), entries.get(4));
|
||||||
assertEquals(5, entries.size());
|
assertEquals(5, entries.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,7 +196,6 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
mappedRootURI = null;
|
mappedRootURI = null;
|
||||||
|
|
||||||
if (detectedSettingEntries!=null && detectedSettingEntries.size()>0) {
|
if (detectedSettingEntries!=null && detectedSettingEntries.size()>0) {
|
||||||
groupEntries(detectedSettingEntries);
|
|
||||||
setSettingEntries(currentCfgDescription, currentResource, currentLanguageId, detectedSettingEntries);
|
setSettingEntries(currentCfgDescription, currentResource, currentLanguageId, detectedSettingEntries);
|
||||||
|
|
||||||
IStatus status = new Status(IStatus.INFO, MakeCorePlugin.PLUGIN_ID, getClass().getSimpleName()
|
IStatus status = new Status(IStatus.INFO, MakeCorePlugin.PLUGIN_ID, getClass().getSimpleName()
|
||||||
|
@ -213,33 +212,6 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
currentCommandResolved = null;
|
currentCommandResolved = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void groupEntries(List<ICLanguageSettingEntry> inputEntries) {
|
|
||||||
Map<Integer, List<ICLanguageSettingEntry>> groupedEntries = new HashMap<Integer, List<ICLanguageSettingEntry>>();
|
|
||||||
int kindMax = 0;
|
|
||||||
for (ICLanguageSettingEntry entry : inputEntries) {
|
|
||||||
int kind = entry.getKind();
|
|
||||||
if (kind>kindMax) {
|
|
||||||
kindMax = kind;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ICLanguageSettingEntry> entries = groupedEntries.get(kind);
|
|
||||||
if (entries==null) {
|
|
||||||
entries = new ArrayList<ICLanguageSettingEntry>();
|
|
||||||
groupedEntries.put(kind, entries);
|
|
||||||
}
|
|
||||||
entries.add(entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
inputEntries.clear();
|
|
||||||
|
|
||||||
for (int kind=1;kind<=kindMax;kind++) {
|
|
||||||
List<ICLanguageSettingEntry> entries = groupedEntries.get(kind);
|
|
||||||
if (entries!=null) {
|
|
||||||
inputEntries.addAll(entries);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void run(IProject project, String languageId, IPath workingDirectory, String[] env,
|
public void run(IProject project, String languageId, IPath workingDirectory, String[] env,
|
||||||
IProgressMonitor monitor) throws CoreException, IOException {
|
IProgressMonitor monitor) throws CoreException, IOException {
|
||||||
if (isRunOnce() && !isEmpty()) {
|
if (isRunOnce() && !isEmpty()) {
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.eclipse.cdt.core.settings.model.CMacroEntry;
|
||||||
import org.eclipse.cdt.core.settings.model.CMacroFileEntry;
|
import org.eclipse.cdt.core.settings.model.CMacroFileEntry;
|
||||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
||||||
|
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
|
||||||
import org.eclipse.cdt.core.testplugin.CModelMock;
|
import org.eclipse.cdt.core.testplugin.CModelMock;
|
||||||
import org.eclipse.cdt.core.testplugin.ResourceHelper;
|
import org.eclipse.cdt.core.testplugin.ResourceHelper;
|
||||||
import org.eclipse.cdt.internal.core.XmlUtil;
|
import org.eclipse.cdt.internal.core.XmlUtil;
|
||||||
|
@ -797,9 +798,9 @@ public class LanguageSettingsSerializableTests extends TestCase {
|
||||||
public void testMixedSettingEntries() throws Exception {
|
public void testMixedSettingEntries() throws Exception {
|
||||||
Element elementProvider;
|
Element elementProvider;
|
||||||
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
|
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
|
||||||
entries.add(new CMacroEntry("MACRO0", "value0",1));
|
|
||||||
entries.add(new CIncludePathEntry("path0", 1));
|
entries.add(new CIncludePathEntry("path0", 1));
|
||||||
entries.add(new CIncludePathEntry("path1", 1));
|
entries.add(new CIncludePathEntry("path1", 1));
|
||||||
|
entries.add(new CMacroEntry("MACRO0", "value0",1));
|
||||||
{
|
{
|
||||||
// create a provider and serialize its settings
|
// create a provider and serialize its settings
|
||||||
LanguageSettingsSerializable provider = new LanguageSettingsSerializable(PROVIDER_1, PROVIDER_NAME_1);
|
LanguageSettingsSerializable provider = new LanguageSettingsSerializable(PROVIDER_1, PROVIDER_NAME_1);
|
||||||
|
@ -822,6 +823,156 @@ public class LanguageSettingsSerializableTests extends TestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public void testSort_Kinds() throws Exception {
|
||||||
|
// create sample entries
|
||||||
|
CIncludePathEntry includePathEntry1 = new CIncludePathEntry("path1", 0);
|
||||||
|
CIncludePathEntry includePathEntry2 = new CIncludePathEntry("path2", 0);
|
||||||
|
CMacroEntry macroEntry1 = new CMacroEntry("MACRO1", null, 0);
|
||||||
|
CMacroEntry macroEntry2 = new CMacroEntry("MACRO2", null, 0);
|
||||||
|
CIncludeFileEntry includeFileEntry1 = new CIncludeFileEntry("file1", 0);
|
||||||
|
CIncludeFileEntry includeFileEntry2 = new CIncludeFileEntry("file2", 0);
|
||||||
|
CMacroFileEntry macroFileEntry1 = new CMacroFileEntry("file1", 0);
|
||||||
|
CMacroFileEntry macroFileEntry2 = new CMacroFileEntry("file2", 0);
|
||||||
|
CLibraryPathEntry libraryPathEntry1 = new CLibraryPathEntry("lib1", 0);
|
||||||
|
CLibraryPathEntry libraryPathEntry2 = new CLibraryPathEntry("lib2", 0);
|
||||||
|
CLibraryFileEntry libraryFileEntry1 = new CLibraryFileEntry("file1", 0);
|
||||||
|
CLibraryFileEntry libraryFileEntry2 = new CLibraryFileEntry("file2", 0);
|
||||||
|
|
||||||
|
// place entries in unsorted list
|
||||||
|
List<ICLanguageSettingEntry> unsortedEntries = new ArrayList<ICLanguageSettingEntry>();
|
||||||
|
unsortedEntries.add(macroEntry1);
|
||||||
|
unsortedEntries.add(macroFileEntry1);
|
||||||
|
unsortedEntries.add(macroEntry2);
|
||||||
|
unsortedEntries.add(includePathEntry1);
|
||||||
|
unsortedEntries.add(includeFileEntry1);
|
||||||
|
unsortedEntries.add(macroFileEntry2);
|
||||||
|
unsortedEntries.add(libraryFileEntry1);
|
||||||
|
unsortedEntries.add(includeFileEntry2);
|
||||||
|
unsortedEntries.add(libraryFileEntry2);
|
||||||
|
unsortedEntries.add(libraryPathEntry1);
|
||||||
|
unsortedEntries.add(includePathEntry2);
|
||||||
|
unsortedEntries.add(libraryPathEntry2);
|
||||||
|
|
||||||
|
// create a provider and set the entries
|
||||||
|
LanguageSettingsSerializable provider = new LanguageSettingsSerializable(PROVIDER_1, PROVIDER_NAME_1);
|
||||||
|
provider.setSettingEntries(null, null, null, unsortedEntries);
|
||||||
|
|
||||||
|
// retrieve and check that language settings got sorted properly
|
||||||
|
assertEquals(PROVIDER_1, provider.getId());
|
||||||
|
int i=0;
|
||||||
|
List<ICLanguageSettingEntry> actual = provider.getSettingEntries(null, null, null);
|
||||||
|
assertEquals(includePathEntry1, actual.get(i++));
|
||||||
|
assertEquals(includePathEntry2, actual.get(i++));
|
||||||
|
assertEquals(includeFileEntry1, actual.get(i++));
|
||||||
|
assertEquals(includeFileEntry2, actual.get(i++));
|
||||||
|
assertEquals(macroEntry1, actual.get(i++));
|
||||||
|
assertEquals(macroEntry2, actual.get(i++));
|
||||||
|
assertEquals(macroFileEntry1, actual.get(i++));
|
||||||
|
assertEquals(macroFileEntry2, actual.get(i++));
|
||||||
|
assertEquals(libraryPathEntry1, actual.get(i++));
|
||||||
|
assertEquals(libraryPathEntry2, actual.get(i++));
|
||||||
|
assertEquals(libraryFileEntry1, actual.get(i++));
|
||||||
|
assertEquals(libraryFileEntry2, actual.get(i++));
|
||||||
|
|
||||||
|
assertEquals(unsortedEntries.size(), actual.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public void testSort_Entries() throws Exception {
|
||||||
|
// create sample entries
|
||||||
|
CIncludePathEntry includePathEntry1 = new CIncludePathEntry("path_B", 0);
|
||||||
|
CIncludePathEntry includePathEntry2 = new CIncludePathEntry("path_A", 0);
|
||||||
|
CMacroEntry macroEntry1 = new CMacroEntry("MACRO_A", null, 0);
|
||||||
|
CMacroEntry macroEntry2 = new CMacroEntry("MACRO_B", null, 0);
|
||||||
|
CIncludeFileEntry includeFileEntry1 = new CIncludeFileEntry("file_B", 0);
|
||||||
|
CIncludeFileEntry includeFileEntry2 = new CIncludeFileEntry("file_A", 0);
|
||||||
|
CMacroFileEntry macroFileEntry1 = new CMacroFileEntry("file_B", 0);
|
||||||
|
CMacroFileEntry macroFileEntry2 = new CMacroFileEntry("file_A", 0);
|
||||||
|
CLibraryPathEntry libraryPathEntry1 = new CLibraryPathEntry("lib_B", 0);
|
||||||
|
CLibraryPathEntry libraryPathEntry2 = new CLibraryPathEntry("lib_A", 0);
|
||||||
|
CLibraryFileEntry libraryFileEntry1 = new CLibraryFileEntry("file_B", 0);
|
||||||
|
CLibraryFileEntry libraryFileEntry2 = new CLibraryFileEntry("file_A", 0);
|
||||||
|
|
||||||
|
// place entries in unsorted list
|
||||||
|
List<ICLanguageSettingEntry> unsortedEntries = new ArrayList<ICLanguageSettingEntry>();
|
||||||
|
// macros will be sorted by name
|
||||||
|
unsortedEntries.add(macroEntry2);
|
||||||
|
unsortedEntries.add(macroEntry1);
|
||||||
|
// paths are not sorted only grouped by kind
|
||||||
|
unsortedEntries.add(macroFileEntry1);
|
||||||
|
unsortedEntries.add(macroFileEntry2);
|
||||||
|
unsortedEntries.add(includePathEntry1);
|
||||||
|
unsortedEntries.add(includePathEntry2);
|
||||||
|
unsortedEntries.add(includeFileEntry1);
|
||||||
|
unsortedEntries.add(includeFileEntry2);
|
||||||
|
unsortedEntries.add(libraryFileEntry1);
|
||||||
|
unsortedEntries.add(libraryFileEntry2);
|
||||||
|
unsortedEntries.add(libraryPathEntry1);
|
||||||
|
unsortedEntries.add(libraryPathEntry2);
|
||||||
|
|
||||||
|
// create a provider and set the entries
|
||||||
|
LanguageSettingsSerializable provider = new LanguageSettingsSerializable(PROVIDER_1, PROVIDER_NAME_1);
|
||||||
|
provider.setSettingEntries(null, null, null, unsortedEntries);
|
||||||
|
|
||||||
|
// retrieve and check that language settings got sorted properly
|
||||||
|
assertEquals(PROVIDER_1, provider.getId());
|
||||||
|
int i=0;
|
||||||
|
List<ICLanguageSettingEntry> actual = provider.getSettingEntries(null, null, null);
|
||||||
|
assertEquals(includePathEntry1, actual.get(i++));
|
||||||
|
assertEquals(includePathEntry2, actual.get(i++));
|
||||||
|
assertEquals(includeFileEntry1, actual.get(i++));
|
||||||
|
assertEquals(includeFileEntry2, actual.get(i++));
|
||||||
|
assertEquals(macroEntry1, actual.get(i++));
|
||||||
|
assertEquals(macroEntry2, actual.get(i++));
|
||||||
|
assertEquals(macroFileEntry1, actual.get(i++));
|
||||||
|
assertEquals(macroFileEntry2, actual.get(i++));
|
||||||
|
assertEquals(libraryPathEntry1, actual.get(i++));
|
||||||
|
assertEquals(libraryPathEntry2, actual.get(i++));
|
||||||
|
assertEquals(libraryFileEntry1, actual.get(i++));
|
||||||
|
assertEquals(libraryFileEntry2, actual.get(i++));
|
||||||
|
|
||||||
|
assertEquals(unsortedEntries.size(), actual.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public void testSort_Undef() throws Exception {
|
||||||
|
// create sample entries
|
||||||
|
CMacroEntry macroEntry1 = new CMacroEntry("MACRO_1", null, 0);
|
||||||
|
CMacroEntry macroEntry2A = new CMacroEntry("MACRO_2", null, ICSettingEntry.UNDEFINED);
|
||||||
|
CMacroEntry macroEntry2B = new CMacroEntry("MACRO_2", null, 0);
|
||||||
|
CMacroEntry macroEntry2C = new CMacroEntry("MACRO_2", null, ICSettingEntry.BUILTIN);
|
||||||
|
CMacroEntry macroEntry3 = new CMacroEntry("MACRO_3", null, 0);
|
||||||
|
|
||||||
|
// place entries in unsorted list
|
||||||
|
List<ICLanguageSettingEntry> unsortedEntries = new ArrayList<ICLanguageSettingEntry>();
|
||||||
|
// macros will be sorted by name and keep order for the same name
|
||||||
|
unsortedEntries.add(macroEntry2A);
|
||||||
|
unsortedEntries.add(macroEntry3);
|
||||||
|
unsortedEntries.add(macroEntry2B);
|
||||||
|
unsortedEntries.add(macroEntry1);
|
||||||
|
unsortedEntries.add(macroEntry2C);
|
||||||
|
|
||||||
|
// create a provider and set the entries
|
||||||
|
LanguageSettingsSerializable provider = new LanguageSettingsSerializable(PROVIDER_1, PROVIDER_NAME_1);
|
||||||
|
provider.setSettingEntries(null, null, null, unsortedEntries);
|
||||||
|
|
||||||
|
// retrieve and check that language settings got sorted properly
|
||||||
|
assertEquals(PROVIDER_1, provider.getId());
|
||||||
|
int i=0;
|
||||||
|
List<ICLanguageSettingEntry> actual = provider.getSettingEntries(null, null, null);
|
||||||
|
assertEquals(macroEntry1, actual.get(i++));
|
||||||
|
assertEquals(macroEntry2A, actual.get(i++));
|
||||||
|
assertEquals(macroEntry2B, actual.get(i++));
|
||||||
|
assertEquals(macroEntry2C, actual.get(i++));
|
||||||
|
assertEquals(macroEntry3, actual.get(i++));
|
||||||
|
|
||||||
|
assertEquals(unsortedEntries.size(), actual.size());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public void testLanguageAndNull() throws Exception {
|
public void testLanguageAndNull() throws Exception {
|
||||||
|
@ -1056,9 +1207,9 @@ public class LanguageSettingsSerializableTests extends TestCase {
|
||||||
public void testClone() throws Exception {
|
public void testClone() throws Exception {
|
||||||
// define sample data
|
// define sample data
|
||||||
List<ICLanguageSettingEntry> sampleEntries_1 = new ArrayList<ICLanguageSettingEntry>();
|
List<ICLanguageSettingEntry> sampleEntries_1 = new ArrayList<ICLanguageSettingEntry>();
|
||||||
sampleEntries_1.add(new CMacroEntry("MACRO0", "value0",1));
|
|
||||||
sampleEntries_1.add(new CIncludePathEntry("path0", 1));
|
sampleEntries_1.add(new CIncludePathEntry("path0", 1));
|
||||||
sampleEntries_1.add(new CIncludePathEntry("path1", 1));
|
sampleEntries_1.add(new CIncludePathEntry("path1", 1));
|
||||||
|
sampleEntries_1.add(new CMacroEntry("MACRO0", "value0",1));
|
||||||
|
|
||||||
List<ICLanguageSettingEntry> sampleEntries_2 = new ArrayList<ICLanguageSettingEntry>();
|
List<ICLanguageSettingEntry> sampleEntries_2 = new ArrayList<ICLanguageSettingEntry>();
|
||||||
sampleEntries_2.add(new CIncludePathEntry("path0", 1));
|
sampleEntries_2.add(new CIncludePathEntry("path0", 1));
|
||||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.core.language.settings.providers;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -119,7 +120,8 @@ public class LanguageSettingsSerializable extends LanguageSettingsBaseProvider {
|
||||||
langMap = new HashMap<String, List<ICLanguageSettingEntry>>();
|
langMap = new HashMap<String, List<ICLanguageSettingEntry>>();
|
||||||
fStorage.put(languageId, langMap);
|
fStorage.put(languageId, langMap);
|
||||||
}
|
}
|
||||||
langMap.put(rcProjectPath, entries);
|
List<ICLanguageSettingEntry> sortedEntries = sortEntries(entries);
|
||||||
|
langMap.put(rcProjectPath, sortedEntries);
|
||||||
} else {
|
} else {
|
||||||
// do not keep nulls in the tables
|
// do not keep nulls in the tables
|
||||||
Map<String, List<ICLanguageSettingEntry>> langMap = fStorage.get(languageId);
|
Map<String, List<ICLanguageSettingEntry>> langMap = fStorage.get(languageId);
|
||||||
|
@ -132,6 +134,25 @@ public class LanguageSettingsSerializable extends LanguageSettingsBaseProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected List<ICLanguageSettingEntry> sortEntries(List<ICLanguageSettingEntry> entries) {
|
||||||
|
List<ICLanguageSettingEntry> sortedEntries = new ArrayList<ICLanguageSettingEntry>(entries);
|
||||||
|
Collections.sort(sortedEntries, new Comparator<ICLanguageSettingEntry>(){
|
||||||
|
/**
|
||||||
|
* This comparator sorts by kinds first and the macros are sorted additionally by name.
|
||||||
|
*/
|
||||||
|
public int compare(ICLanguageSettingEntry entry0, ICLanguageSettingEntry entry1) {
|
||||||
|
int kind0 = entry0.getKind();
|
||||||
|
int kind1 = entry1.getKind();
|
||||||
|
if (kind0==ICSettingEntry.MACRO && kind1==ICSettingEntry.MACRO) {
|
||||||
|
return entry0.getName().compareTo(entry1.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
return kind0 - kind1;
|
||||||
|
}});
|
||||||
|
|
||||||
|
return sortedEntries;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets language settings entries for the provider.
|
* Sets language settings entries for the provider.
|
||||||
* Note that the entries are not persisted at that point. To persist use TODO
|
* Note that the entries are not persisted at that point. To persist use TODO
|
||||||
|
|
Loading…
Add table
Reference in a new issue