From cb844bdaedf5d99c03803cd498e7a9ab32f5a971 Mon Sep 17 00:00:00 2001 From: Andrew Gvozdev Date: Wed, 27 Oct 2010 16:55:27 +0000 Subject: [PATCH] bug 327897: [ScannerDiscovery80] Tidy up certain scanner discovery code --- .../model/util/PathEntryTranslator.java | 45 +++++++++---------- .../model/util/UtilMessages.properties | 2 +- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryTranslator.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryTranslator.java index a2002344bc0..c0d24bccd5e 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryTranslator.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryTranslator.java @@ -84,6 +84,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Status; public class PathEntryTranslator { public static final int OP_ADD = 1; @@ -2045,7 +2046,7 @@ public class PathEntryTranslator { PathEntryCollector child = cr.createChild(container.getPath()); for (int kind : kinds) { List list = new ArrayList(); - if(collectEntries(kind, data, list)){ + if(collectResourceDataEntries(kind, data, list)){ ICLanguageSettingEntry[] entries = list.toArray(new ICLanguageSettingEntry[list.size()]); child.setEntries(kind, entries, exportedSettings); } @@ -2058,36 +2059,32 @@ public class PathEntryTranslator { return cr; } - private static boolean collectEntries(int kind, CResourceData data, List list){ - if(data.getType() == ICSettingBase.SETTING_FOLDER){ - return collectEntries(kind, (CFolderData)data, list); + private static boolean collectResourceDataEntries(int kind, CResourceData data, List list){ + CLanguageData[] lDatas = null; + if(data instanceof CFolderData) { + lDatas = ((CFolderData)data).getLanguageDatas(); + } else if(data instanceof CFileData) { + CLanguageData lData = ((CFileData)data).getLanguageData(); + if (lData!=null) + lDatas = new CLanguageData[] {lData}; + } else { + Exception e = new Exception(UtilMessages.getString("PathEntryTranslator.1") + data.getClass().getName()); //$NON-NLS-1$ + IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, e.getMessage(), e); + CCorePlugin.log(status); + } + if (lDatas==null || lDatas.length==0) { + return false; } - return collectEntries(kind, (CFileData)data, list); - } - private static boolean collectEntries(int kind, CFolderData data, List list){ - - CLanguageData lDatas[] = data.getLanguageDatas(); boolean supported = false; - if(lDatas != null && lDatas.length != 0){ - for (CLanguageData lData : lDatas) { - if(collectEntries(kind, lData, list)) - supported = true; - } + for (CLanguageData lData : lDatas) { + if(collectLanguageDataEntries(kind, lData, list)) + supported = true; } return supported; } - private static boolean collectEntries(int kind, CFileData data, List list){ - - CLanguageData lData = data.getLanguageData(); - if(lData != null){ - return collectEntries(kind, lData, list); - } - return false; - } - - private static boolean collectEntries(int kind, CLanguageData lData, List list){ + private static boolean collectLanguageDataEntries(int kind, CLanguageData lData, List list){ if((kind & lData.getSupportedEntryKinds()) != 0){ ICLanguageSettingEntry[] entries = lData.getEntries(kind); if(entries != null && entries.length != 0){ diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/UtilMessages.properties b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/UtilMessages.properties index 4ca6ea0d57a..ee0d81914e2 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/UtilMessages.properties +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/UtilMessages.properties @@ -11,7 +11,7 @@ KindBasedStore.0=illegal kind KindBasedStore.1=illegal kind PathEntryTranslator.0=illegal kind -PathEntryTranslator.1=illegal kind +PathEntryTranslator.1=illegal type PathEntryTranslator.2=PathEntryTranslator: failed to apply output entries: Build Data is null, ignoring.. CDataSerializer.20=no id attribute for configuration CDataSerializer.21=failed to create configuration