Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikhail Sennikovsky2007-02-26 16:48:47 +0000
committerMikhail Sennikovsky2007-02-26 16:48:47 +0000
commit7360d17945bff6fbe2b9f91e0a0acc54427a90e6 (patch)
tree9c0fec47ea79f0c3b6cb8313a0281fd7c7f4206f
parentfdc6c2b7fedf5ad9b8001e31fcbf8f537c4785f4 (diff)
downloadorg.eclipse.cdt-7360d17945bff6fbe2b9f91e0a0acc54427a90e6.tar.gz
org.eclipse.cdt-7360d17945bff6fbe2b9f91e0a0acc54427a90e6.tar.xz
org.eclipse.cdt-7360d17945bff6fbe2b9f91e0a0acc54427a90e6.zip
CDT Variables (macros) resolving for the language setting entries
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingEntry.java2
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java64
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSetting.java7
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSettingCache.java24
4 files changed, 90 insertions, 7 deletions
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingEntry.java
index bf381bc35f3..274f66a4f30 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingEntry.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingEntry.java
@@ -37,7 +37,7 @@ public interface ICSettingEntry {
boolean isBuiltIn();
-// boolean isResolved();
+ boolean isResolved();
boolean equalsByName(ICLanguageSettingEntry entry);
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java
index 240c64bf1e7..c05320b6c0d 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java
@@ -15,6 +15,19 @@ import java.util.List;
import java.util.Random;
import java.util.StringTokenizer;
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariableManager;
+import org.eclipse.cdt.core.settings.model.CIncludeFileEntry;
+import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
+import org.eclipse.cdt.core.settings.model.CLibraryFileEntry;
+import org.eclipse.cdt.core.settings.model.CLibraryPathEntry;
+import org.eclipse.cdt.core.settings.model.CMacroEntry;
+import org.eclipse.cdt.core.settings.model.CMacroFileEntry;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+
public class CDataUtil {
private static Random randomNumber;
public static final String[] EMPTY_STRING_ARRAY = new String[0];
@@ -73,5 +86,56 @@ public class CDataUtil {
}
return (String[])list.toArray(new String[list.size()]);
}
+
+ public static ICLanguageSettingEntry[] resolveEntries(ICLanguageSettingEntry entries[], ICConfigurationDescription cfgDes){
+ if(entries.length == 0)
+ return entries;
+
+ ICLanguageSettingEntry[] resolved = new ICLanguageSettingEntry[entries.length];
+ ICdtVariableManager mngr = CCorePlugin.getDefault().getCdtVariableManager();
+
+ for(int i = 0; i < entries.length; i++){
+ ICLanguageSettingEntry entry = entries[i];
+ resolved[i] = createResolvedEntry(entry, cfgDes, mngr);
+ }
+
+ return resolved;
+ }
+
+ private static ICLanguageSettingEntry createResolvedEntry(ICLanguageSettingEntry entry, ICConfigurationDescription cfg, ICdtVariableManager mngr){
+ if(entry.isResolved())
+ return entry;
+
+ String name = entry.getName();
+ try {
+ name = mngr.resolveValue(name, "", " ", cfg); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch (CdtVariableException e) {
+ CCorePlugin.log(e);
+ }
+
+ switch (entry.getKind()) {
+ case ICLanguageSettingEntry.INCLUDE_PATH:
+ return new CIncludePathEntry(name, ICSettingEntry.RESOLVED | entry.getFlags());
+ case ICLanguageSettingEntry.INCLUDE_FILE:
+ return new CIncludeFileEntry(name, ICSettingEntry.RESOLVED | entry.getFlags());
+ case ICLanguageSettingEntry.MACRO:
+ String value = entry.getValue();
+ try {
+ value = mngr.resolveValue(value, "", " ", cfg); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch (CdtVariableException e) {
+ CCorePlugin.log(e);
+ }
+ return new CMacroEntry(name, value, ICSettingEntry.RESOLVED | entry.getFlags());
+ case ICLanguageSettingEntry.MACRO_FILE:
+ return new CMacroFileEntry(name, ICSettingEntry.RESOLVED | entry.getFlags());
+ case ICLanguageSettingEntry.LIBRARY_PATH:
+ return new CLibraryPathEntry(name, ICSettingEntry.RESOLVED | entry.getFlags());
+ case ICLanguageSettingEntry.LIBRARY_FILE:
+ return new CLibraryFileEntry(name, ICSettingEntry.RESOLVED | entry.getFlags());
+ default:
+ throw new IllegalArgumentException();
+ }
+ }
+
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSetting.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSetting.java
index 4469d99c6f8..18b9504bd27 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSetting.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSetting.java
@@ -20,8 +20,8 @@ import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICSettingBase;
import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultLanguageData;
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.core.settings.model.util.EntryStore;
-import org.eclipse.cdt.core.settings.model.util.KindBasedStore;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.runtime.Platform;
@@ -380,8 +380,9 @@ public class CLanguageSetting extends CDataProxy implements
// }
public ICLanguageSettingEntry[] getResolvedSettingEntries(int kind) {
- // TODO Auto-generated method stub
- return getSettingEntries(kind);
+ ICLanguageSettingEntry entries[] = getSettingEntries(kind);
+ entries = CDataUtil.resolveEntries(entries, getConfiguration());
+ return entries;
}
public void setSourceContentTypeIds(String[] ids) {
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSettingCache.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSettingCache.java
index bf05580b7c5..a599cdcad73 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSettingCache.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSettingCache.java
@@ -19,10 +19,14 @@ import org.eclipse.cdt.core.settings.model.ICResourceDescription;
import org.eclipse.cdt.core.settings.model.ICSettingContainer;
import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultLanguageData;
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+import org.eclipse.cdt.core.settings.model.util.EntryStore;
public class CLanguageSettingCache extends CDefaultLanguageData implements
ICLanguageSetting, ICachedData {
private ICResourceDescription fParent;
+ protected EntryStore fResolvedEntriesStore;
+
public CLanguageSettingCache(CLanguageData base, CFolderDescriptionCache folderCache) {
fId = base.getId();
fParent = folderCache;
@@ -41,10 +45,24 @@ public class CLanguageSettingCache extends CDefaultLanguageData implements
}
*/
public ICLanguageSettingEntry[] getResolvedSettingEntries(int kind) {
- // TODO Auto-generated method stub
- return getSettingEntries(kind);
+ ICLanguageSettingEntry[] entries = getSettingEntries(kind);
+ if(entries.length != 0){
+ if(fResolvedEntriesStore == null){
+ fResolvedEntriesStore = new EntryStore();
+ }
+
+ ICLanguageSettingEntry[] resolved = fResolvedEntriesStore.getEntries();
+ if(resolved.length == 0){
+ resolved = CDataUtil.resolveEntries(entries, getConfiguration());
+ fResolvedEntriesStore.storeEntries(kind, resolved);
+ }
+
+ entries = resolved;
+ }
+ return entries;
}
-
+
+
public ICLanguageSettingEntry[] getSettingEntries(int kind) {
// int kinds[] = KindBasedStore.getSupportedKinds();
// List list = new ArrayList();

Back to the top