mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
1. Additional Fix for [Bug 174936] [Scanner Discovery] Per file scanner discovery is broken with the New Project Model functionality
2. Bug-fixes
This commit is contained in:
parent
1ae4154fb6
commit
f0cccf7f71
21 changed files with 598 additions and 142 deletions
|
@ -19,6 +19,8 @@ import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
public final class PathInfo {
|
public final class PathInfo {
|
||||||
private static final Path[] EMPTY_PATH_ARRAY = new Path[0];
|
private static final Path[] EMPTY_PATH_ARRAY = new Path[0];
|
||||||
|
public final static PathInfo EMPTY_INFO = new PathInfo(null, null, null, null, null);
|
||||||
|
|
||||||
private static int EMPTY_CODE = 53;
|
private static int EMPTY_CODE = 53;
|
||||||
|
|
||||||
private IPath[] fIncludePaths;
|
private IPath[] fIncludePaths;
|
||||||
|
|
|
@ -23,6 +23,7 @@ import org.eclipse.cdt.build.internal.core.scannerconfig2.CfgScannerConfigProfil
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.settings.model.ICSettingBase;
|
import org.eclipse.cdt.core.settings.model.ICSettingBase;
|
||||||
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
|
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
|
||||||
|
import org.eclipse.cdt.core.settings.model.extension.CFolderData;
|
||||||
import org.eclipse.cdt.core.settings.model.extension.CResourceData;
|
import org.eclipse.cdt.core.settings.model.extension.CResourceData;
|
||||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager;
|
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager;
|
||||||
|
@ -202,7 +203,7 @@ public class CfgDiscoveredPathManager implements IResourceChangeListener {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PerFileSettingsCalculator calculator = new PerFileSettingsCalculator();
|
PerFileSettingsCalculator calculator = new PerFileSettingsCalculator();
|
||||||
IRcSettingInfo[] rcInfos = calculator.getSettingInfos(data, info);
|
IRcSettingInfo[] rcInfos = calculator.getSettingInfos(cInfo.fLoadContext.getConfiguration().getOwner().getProject(), data, info, true);
|
||||||
|
|
||||||
CResourceData rcDatas[] = data.getResourceDatas();
|
CResourceData rcDatas[] = data.getResourceDatas();
|
||||||
Map rcDataMap = new HashMap(rcDatas.length);
|
Map rcDataMap = new HashMap(rcDatas.length);
|
||||||
|
@ -223,12 +224,19 @@ public class CfgDiscoveredPathManager implements IResourceChangeListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!rcDataMap.isEmpty()){
|
if(!rcDataMap.isEmpty()){
|
||||||
|
CResourceData tmpRcData;
|
||||||
for(Iterator iter = rcDataMap.values().iterator(); iter.hasNext();){
|
for(Iterator iter = rcDataMap.values().iterator(); iter.hasNext();){
|
||||||
clearCache((CResourceData)iter.next());
|
tmpRcData = (CResourceData)iter.next();
|
||||||
|
if(tmpRcData.getPath().segmentCount() == 0 && tmpRcData.getType() == ICSettingBase.SETTING_FOLDER){
|
||||||
|
cache(cInfo, PerFileSettingsCalculator.createEmptyRcSettingInfo((CFolderData)tmpRcData));
|
||||||
|
} else {
|
||||||
|
clearCache(tmpRcData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void cache(ContextInfo cInfo, IRcSettingInfo rcSetting){
|
private void cache(ContextInfo cInfo, IRcSettingInfo rcSetting){
|
||||||
CResourceData rcData = rcSetting.getResourceData();
|
CResourceData rcData = rcSetting.getResourceData();
|
||||||
clearCache(rcData);
|
clearCache(rcData);
|
||||||
|
|
|
@ -27,9 +27,10 @@ import org.eclipse.cdt.core.settings.model.extension.CResourceData;
|
||||||
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
|
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
|
||||||
import org.eclipse.cdt.core.settings.model.util.IPathSettingsContainerVisitor;
|
import org.eclipse.cdt.core.settings.model.util.IPathSettingsContainerVisitor;
|
||||||
import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer;
|
import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.PathInfo;
|
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager;
|
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager;
|
||||||
|
import org.eclipse.cdt.make.core.scannerconfig.PathInfo;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
@ -59,7 +60,7 @@ public class PerFileSettingsCalculator {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class RcSettingInfo implements IRcSettingInfo{
|
private static class RcSettingInfo implements IRcSettingInfo{
|
||||||
private List fLangInfoList;
|
private ArrayList fLangInfoList;
|
||||||
private CResourceData fRcData;
|
private CResourceData fRcData;
|
||||||
|
|
||||||
RcSettingInfo(CResourceData rcData){
|
RcSettingInfo(CResourceData rcData){
|
||||||
|
@ -629,7 +630,110 @@ public class PerFileSettingsCalculator {
|
||||||
return rcSet;
|
return rcSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IRcSettingInfo[] getSettingInfos(CConfigurationData data, IDiscoveredPathManager.IPerFileDiscoveredPathInfo2 discoveredInfo){
|
/*
|
||||||
|
* utility method for creating empty IRcSettingInfo
|
||||||
|
*/
|
||||||
|
public static IRcSettingInfo createEmptyRcSettingInfo(CFolderData data){
|
||||||
|
RcSettingInfo rcInfo = new RcSettingInfo(data);
|
||||||
|
CLanguageData[] lDatas = data.getLanguageDatas();
|
||||||
|
addEmptyLanguageInfos(rcInfo, lDatas);
|
||||||
|
return rcInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void addEmptyLanguageInfos(RcSettingInfo rcInfo, CLanguageData[] lDatas){
|
||||||
|
ArrayList list = rcInfo.fLangInfoList;
|
||||||
|
if(list == null){
|
||||||
|
list = new ArrayList(lDatas.length);
|
||||||
|
rcInfo.fLangInfoList = list;
|
||||||
|
} else {
|
||||||
|
list.ensureCapacity(lDatas.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i = 0; i < lDatas.length; i++){
|
||||||
|
list.add(new LangSettingInfo(lDatas[i], PathInfo.EMPTY_INFO));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private IRcSettingInfo[] mapFileDiscoveredInfo(IProject project, CConfigurationData data, RcSetSettings rcSet, Map map){
|
||||||
|
IResource rc;
|
||||||
|
PathInfo pInfo;
|
||||||
|
Map.Entry entry;
|
||||||
|
IPath projRelPath;
|
||||||
|
CResourceData rcData;
|
||||||
|
// RcSetSettings dataSetting;
|
||||||
|
List list = new ArrayList(map.size());
|
||||||
|
RcSettingInfo rcInfo;
|
||||||
|
LangSettingInfo lInfo;
|
||||||
|
CLanguageData lData;
|
||||||
|
ArrayList tmpList;
|
||||||
|
|
||||||
|
for(Iterator iter = map.entrySet().iterator(); iter.hasNext();){
|
||||||
|
entry = (Map.Entry)iter.next();
|
||||||
|
rc = (IResource)entry.getKey();
|
||||||
|
pInfo = (PathInfo)entry.getValue();
|
||||||
|
if(pInfo.isEmpty())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
switch(rc.getType()){
|
||||||
|
case IResource.FILE:
|
||||||
|
projRelPath = rc.getProjectRelativePath();
|
||||||
|
// dataSetting = rcSet.getChild(projRelPath, false);
|
||||||
|
// rcData = dataSetting.fRcData;
|
||||||
|
rcData = rcSet.getChild(projRelPath, false).fRcData;
|
||||||
|
if(!rcData.getPath().equals(projRelPath)){
|
||||||
|
if(rcData.getType() == ICSettingBase.SETTING_FOLDER){
|
||||||
|
CFolderData foData = (CFolderData)rcData;
|
||||||
|
lData = CDataUtil.findLanguagDataForFile(projRelPath.lastSegment(), project, (CFolderData)rcData);
|
||||||
|
try {
|
||||||
|
rcData = createFileData(data, projRelPath, foData, lData);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
rcData = null;
|
||||||
|
ManagedBuilderCorePlugin.log(e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
rcData = createFileData(data, projRelPath, (CFileData)rcData);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
rcData = null;
|
||||||
|
ManagedBuilderCorePlugin.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if(rcData != null)
|
||||||
|
// dataSetting = rcSet.createChild(projRelPath, rcData, false);
|
||||||
|
// else
|
||||||
|
// dataSetting = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(rcData != null){
|
||||||
|
if(rcData.getType() == ICSettingBase.SETTING_FILE){
|
||||||
|
lData = ((CFileData)rcData).getLanguageData();
|
||||||
|
} else {
|
||||||
|
lData = CDataUtil.findLanguagDataForFile(projRelPath.lastSegment(), project, (CFolderData)rcData);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(lData != null){
|
||||||
|
rcInfo = new RcSettingInfo(rcData);
|
||||||
|
lInfo = new LangSettingInfo(lData, pInfo);
|
||||||
|
tmpList = new ArrayList(1);
|
||||||
|
tmpList.add(lInfo);
|
||||||
|
rcInfo.fLangInfoList = tmpList;
|
||||||
|
list.add(rcInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (RcSettingInfo[])list.toArray(new RcSettingInfo[list.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IRcSettingInfo[] getSettingInfos(IProject project, CConfigurationData data, IDiscoveredPathManager.IPerFileDiscoveredPathInfo2 discoveredInfo, boolean fileDataMode){
|
||||||
|
if(fileDataMode){
|
||||||
|
RcSetSettings rcSettings = createRcSetInfo(data);
|
||||||
|
return mapFileDiscoveredInfo(project, data, rcSettings, discoveredInfo.getPathInfoMap());
|
||||||
|
}
|
||||||
RcSetSettings settings = createRcSetSettings(data, discoveredInfo);
|
RcSetSettings settings = createRcSetSettings(data, discoveredInfo);
|
||||||
return createInfos(data, settings);
|
return createInfos(data, settings);
|
||||||
}
|
}
|
||||||
|
|
|
@ -233,11 +233,11 @@ public class EntryStorage {
|
||||||
levels[0].setReadOnly(false);
|
levels[0].setReadOnly(false);
|
||||||
|
|
||||||
levels[1].setFlagsToClear(ICSettingEntry.BUILTIN);
|
levels[1].setFlagsToClear(ICSettingEntry.BUILTIN);
|
||||||
levels[1].setFlagsToSet(ICSettingEntry.READONLY);
|
levels[1].setFlagsToSet(ICSettingEntry.READONLY | ICSettingEntry.RESOLVED);
|
||||||
levels[1].setReadOnly(true);
|
levels[1].setReadOnly(true);
|
||||||
|
|
||||||
levels[2].setFlagsToClear(0);
|
levels[2].setFlagsToClear(0);
|
||||||
levels[2].setFlagsToSet(ICSettingEntry.READONLY | ICSettingEntry.BUILTIN);
|
levels[2].setFlagsToSet(ICSettingEntry.READONLY | ICSettingEntry.BUILTIN | ICSettingEntry.RESOLVED);
|
||||||
levels[2].setReadOnly(true);
|
levels[2].setReadOnly(true);
|
||||||
|
|
||||||
return settings;
|
return settings;
|
||||||
|
|
|
@ -37,6 +37,7 @@ import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICExternalSetting;
|
import org.eclipse.cdt.core.settings.model.ICExternalSetting;
|
||||||
import org.eclipse.cdt.core.settings.model.ICFileDescription;
|
import org.eclipse.cdt.core.settings.model.ICFileDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICFolderDescription;
|
import org.eclipse.cdt.core.settings.model.ICFolderDescription;
|
||||||
|
import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
|
||||||
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
||||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
|
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
|
||||||
|
@ -444,6 +445,10 @@ class MockConfig implements ICConfigurationDescription {
|
||||||
|
|
||||||
public void removeStorage(String id) throws CoreException {
|
public void removeStorage(String id) throws CoreException {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ICLanguageSetting getLanguageSettingForFile(IPath path) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -16,7 +16,12 @@ import org.eclipse.cdt.core.CCProjectNature;
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.CProjectNature;
|
import org.eclipse.cdt.core.CProjectNature;
|
||||||
import org.eclipse.cdt.core.resources.IPathEntryStore;
|
import org.eclipse.cdt.core.resources.IPathEntryStore;
|
||||||
|
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||||
|
import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
|
||||||
|
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
||||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||||
|
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
|
||||||
|
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
|
||||||
import org.eclipse.cdt.core.settings.model.WriteAccessException;
|
import org.eclipse.cdt.core.settings.model.WriteAccessException;
|
||||||
import org.eclipse.cdt.internal.core.model.APathEntry;
|
import org.eclipse.cdt.internal.core.model.APathEntry;
|
||||||
import org.eclipse.cdt.internal.core.model.BatchOperation;
|
import org.eclipse.cdt.internal.core.model.BatchOperation;
|
||||||
|
@ -32,6 +37,7 @@ import org.eclipse.cdt.internal.core.model.OutputEntry;
|
||||||
import org.eclipse.cdt.internal.core.model.PathEntryManager;
|
import org.eclipse.cdt.internal.core.model.PathEntryManager;
|
||||||
import org.eclipse.cdt.internal.core.model.ProjectEntry;
|
import org.eclipse.cdt.internal.core.model.ProjectEntry;
|
||||||
import org.eclipse.cdt.internal.core.model.SourceEntry;
|
import org.eclipse.cdt.internal.core.model.SourceEntry;
|
||||||
|
import org.eclipse.cdt.internal.core.settings.model.CProjectDescription;
|
||||||
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
|
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IFolder;
|
import org.eclipse.core.resources.IFolder;
|
||||||
|
@ -1223,8 +1229,40 @@ public class CoreModel {
|
||||||
* @param resource
|
* @param resource
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static boolean isScannerInformationEmpty(IResource resource) {
|
public static boolean isScannerInformationEmpty(IResource resource) {
|
||||||
|
IProject project = resource.getProject();
|
||||||
|
CProjectDescriptionManager mngr = CProjectDescriptionManager.getInstance();
|
||||||
|
CProjectDescription des = (CProjectDescription)mngr.getProjectDescription(project, false);
|
||||||
|
if(des != null){
|
||||||
|
ICConfigurationDescription indexCfg = des.getIndexConfiguration();
|
||||||
|
if(indexCfg != null){
|
||||||
|
if(!mngr.isNewStyleCfg(indexCfg)){
|
||||||
|
return oldIsScannerInformationEmpty(resource);
|
||||||
|
}
|
||||||
|
ICLanguageSetting lSetting = indexCfg.getLanguageSettingForFile(resource.getProjectRelativePath());
|
||||||
|
if(lSetting != null){
|
||||||
|
ICLanguageSettingEntry[] entries = lSetting.getSettingEntries(ICLanguageSettingEntry.INCLUDE_PATH);
|
||||||
|
if(entries.length != 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
entries = lSetting.getSettingEntries(ICLanguageSettingEntry.MACRO);
|
||||||
|
if(entries.length != 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
entries = lSetting.getSettingEntries(ICLanguageSettingEntry.INCLUDE_FILE);
|
||||||
|
if(entries.length != 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
entries = lSetting.getSettingEntries(ICLanguageSettingEntry.MACRO_FILE);
|
||||||
|
if(entries.length != 0)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean oldIsScannerInformationEmpty(IResource resource) {
|
||||||
final int PATH_ENTRY_MASK = IPathEntry.CDT_INCLUDE | IPathEntry.CDT_MACRO |
|
final int PATH_ENTRY_MASK = IPathEntry.CDT_INCLUDE | IPathEntry.CDT_MACRO |
|
||||||
IPathEntry.CDT_INCLUDE_FILE | IPathEntry.CDT_MACRO_FILE;
|
IPathEntry.CDT_INCLUDE_FILE | IPathEntry.CDT_MACRO_FILE;
|
||||||
boolean rc = true;
|
boolean rc = true;
|
||||||
|
|
|
@ -352,4 +352,13 @@ public interface ICConfigurationDescription extends ICSettingContainer, ICSettin
|
||||||
void remove(String extensionPoint) throws CoreException;
|
void remove(String extensionPoint) throws CoreException;
|
||||||
|
|
||||||
boolean isPreferenceConfiguration();
|
boolean isPreferenceConfiguration();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* convenience method to return a language setting for the file
|
||||||
|
* with the specified project-relative path
|
||||||
|
*
|
||||||
|
* @param path - file project relative path
|
||||||
|
* @return ICLanguageSetting or null if not found
|
||||||
|
*/
|
||||||
|
ICLanguageSetting getLanguageSettingForFile(IPath path);
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,6 @@ public class CDefaultConfigurationData extends CConfigurationData {
|
||||||
if(base == null)
|
if(base == null)
|
||||||
return;
|
return;
|
||||||
fDescription = base.getDescription();
|
fDescription = base.getDescription();
|
||||||
CResourceData[] rcDatas = base.getResourceDatas();
|
|
||||||
|
|
||||||
fTargetPlatformData = copyTargetPlatformData(base.getTargetPlatformData(), clone);
|
fTargetPlatformData = copyTargetPlatformData(base.getTargetPlatformData(), clone);
|
||||||
fSourcePaths = base.getSourcePaths();
|
fSourcePaths = base.getSourcePaths();
|
||||||
|
@ -106,7 +105,9 @@ public class CDefaultConfigurationData extends CConfigurationData {
|
||||||
CFolderData baseRootFolderData = base.getRootFolderData();
|
CFolderData baseRootFolderData = base.getRootFolderData();
|
||||||
fRootFolderData = copyFolderData(baseRootFolderData.getPath(), baseRootFolderData, clone);
|
fRootFolderData = copyFolderData(baseRootFolderData.getPath(), baseRootFolderData, clone);
|
||||||
addRcData(fRootFolderData);
|
addRcData(fRootFolderData);
|
||||||
|
|
||||||
|
CResourceData[] rcDatas = base.getResourceDatas();
|
||||||
|
|
||||||
for(int i = 0; i < rcDatas.length; i++){
|
for(int i = 0; i < rcDatas.length; i++){
|
||||||
CResourceData rcData = rcDatas[i];
|
CResourceData rcData = rcDatas[i];
|
||||||
if(baseRootFolderData == rcData)
|
if(baseRootFolderData == rcData)
|
||||||
|
|
|
@ -19,6 +19,9 @@ import org.eclipse.cdt.core.settings.model.util.EntryStore;
|
||||||
import org.eclipse.cdt.core.settings.model.util.KindBasedStore;
|
import org.eclipse.cdt.core.settings.model.util.KindBasedStore;
|
||||||
|
|
||||||
public class CDefaultLanguageData extends CLanguageData {
|
public class CDefaultLanguageData extends CLanguageData {
|
||||||
|
protected final static int OP_COPY = 1;
|
||||||
|
protected final static int OP_SET = 2;
|
||||||
|
|
||||||
protected String fName;
|
protected String fName;
|
||||||
protected String fId;
|
protected String fId;
|
||||||
protected String fLanguageId;
|
protected String fLanguageId;
|
||||||
|
@ -84,11 +87,16 @@ public class CDefaultLanguageData extends CLanguageData {
|
||||||
int kinds[] = KindBasedStore.getLanguageEntryKinds();
|
int kinds[] = KindBasedStore.getLanguageEntryKinds();
|
||||||
for(int i = 0; i < kinds.length; i++){
|
for(int i = 0; i < kinds.length; i++){
|
||||||
ICLanguageSettingEntry entries[] = data.getEntries(kinds[i]);
|
ICLanguageSettingEntry entries[] = data.getEntries(kinds[i]);
|
||||||
|
entries = processStoredEntries(entries, OP_COPY);
|
||||||
store.storeEntries(kinds[i], entries);
|
store.storeEntries(kinds[i], entries);
|
||||||
}
|
}
|
||||||
return store;
|
return store;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ICLanguageSettingEntry[] processStoredEntries(ICLanguageSettingEntry[] entries, int op){
|
||||||
|
return entries;
|
||||||
|
}
|
||||||
|
|
||||||
protected EntryStore createStore(){
|
protected EntryStore createStore(){
|
||||||
return new EntryStore(true);
|
return new EntryStore(true);
|
||||||
}
|
}
|
||||||
|
@ -174,6 +182,7 @@ public class CDefaultLanguageData extends CLanguageData {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEntries(int kind, ICLanguageSettingEntry entries[]) {
|
public void setEntries(int kind, ICLanguageSettingEntry entries[]) {
|
||||||
|
entries = processStoredEntries(entries, OP_SET);
|
||||||
fStore.storeEntries(kind, entries);
|
fStore.storeEntries(kind, entries);
|
||||||
|
|
||||||
setModified(true);
|
setModified(true);
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
package org.eclipse.cdt.core.settings.model.util;
|
package org.eclipse.cdt.core.settings.model.util;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
@ -24,9 +25,22 @@ import org.eclipse.cdt.core.settings.model.CLibraryFileEntry;
|
||||||
import org.eclipse.cdt.core.settings.model.CLibraryPathEntry;
|
import org.eclipse.cdt.core.settings.model.CLibraryPathEntry;
|
||||||
import org.eclipse.cdt.core.settings.model.CMacroEntry;
|
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.COutputEntry;
|
||||||
|
import org.eclipse.cdt.core.settings.model.CSourceEntry;
|
||||||
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.settings.model.ICSettingEntry;
|
||||||
|
import org.eclipse.cdt.core.settings.model.extension.CFolderData;
|
||||||
|
import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
|
||||||
|
import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultLanguageData;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.ProjectScope;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.core.runtime.Platform;
|
||||||
|
import org.eclipse.core.runtime.content.IContentType;
|
||||||
|
import org.eclipse.core.runtime.content.IContentTypeManager;
|
||||||
|
import org.eclipse.core.runtime.content.IContentTypeSettings;
|
||||||
|
import org.eclipse.core.runtime.preferences.IScopeContext;
|
||||||
|
|
||||||
public class CDataUtil {
|
public class CDataUtil {
|
||||||
private static Random randomNumber;
|
private static Random randomNumber;
|
||||||
|
@ -164,4 +178,147 @@ public class CDataUtil {
|
||||||
}
|
}
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ICSettingEntry createEntry(int kind, String name, String value, IPath[] exclusionPatterns, int flags){
|
||||||
|
switch (kind){
|
||||||
|
case ICLanguageSettingEntry.INCLUDE_PATH:
|
||||||
|
return new CIncludePathEntry(name, flags);
|
||||||
|
case ICLanguageSettingEntry.MACRO:
|
||||||
|
return new CMacroEntry(name, value, flags);
|
||||||
|
case ICLanguageSettingEntry.INCLUDE_FILE:
|
||||||
|
return new CIncludeFileEntry(name, flags);
|
||||||
|
case ICLanguageSettingEntry.MACRO_FILE:
|
||||||
|
return new CMacroFileEntry(name, flags);
|
||||||
|
case ICLanguageSettingEntry.LIBRARY_PATH:
|
||||||
|
return new CLibraryPathEntry(name, flags);
|
||||||
|
case ICLanguageSettingEntry.LIBRARY_FILE:
|
||||||
|
return new CLibraryFileEntry(name, flags);
|
||||||
|
case ICLanguageSettingEntry.OUTPUT_PATH:
|
||||||
|
return new COutputEntry(name, exclusionPatterns, flags);
|
||||||
|
case ICLanguageSettingEntry.SOURCE_PATH:
|
||||||
|
return new CSourceEntry(name, exclusionPatterns, flags);
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String[] getSourceExtensions(IProject project, CLanguageData data) {
|
||||||
|
String[] exts = null;
|
||||||
|
String[] typeIds = data.getSourceContentTypeIds();
|
||||||
|
if(typeIds != null && typeIds.length != 0){
|
||||||
|
exts = getExtensionsFromContentTypes(project, typeIds);
|
||||||
|
} else {
|
||||||
|
exts = data.getSourceExtensions();
|
||||||
|
if(exts != null && exts.length != 0)
|
||||||
|
exts = (String[])exts.clone();
|
||||||
|
else
|
||||||
|
exts = CDefaultLanguageData.EMPTY_STRING_ARRAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(exts == null)
|
||||||
|
exts = CDefaultLanguageData.EMPTY_STRING_ARRAY;
|
||||||
|
return exts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String[] getExtensionsFromContentTypes(IProject project, String[] typeIds){
|
||||||
|
String[] exts = null;
|
||||||
|
if(typeIds != null && typeIds.length != 0){
|
||||||
|
IContentTypeManager manager = Platform.getContentTypeManager();
|
||||||
|
IContentType type;
|
||||||
|
if(typeIds.length == 1){
|
||||||
|
type = manager.getContentType(typeIds[0]);
|
||||||
|
if(type != null)
|
||||||
|
exts = getContentTypeFileSpecs(project, type);
|
||||||
|
} else {
|
||||||
|
List list = new ArrayList();
|
||||||
|
for(int i = 0; i < typeIds.length; i++){
|
||||||
|
type = manager.getContentType(typeIds[i]);
|
||||||
|
if(type != null) {
|
||||||
|
list.addAll(Arrays.asList(getContentTypeFileSpecs(project, type)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exts = (String[])list.toArray(new String[list.size()]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(exts == null)
|
||||||
|
exts = CDefaultLanguageData.EMPTY_STRING_ARRAY;
|
||||||
|
return exts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String[] getContentTypeFileSpecs (IProject project, IContentType type) {
|
||||||
|
String[] globalSpecs = type.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
|
||||||
|
IContentTypeSettings settings = null;
|
||||||
|
if (project != null) {
|
||||||
|
IScopeContext projectScope = new ProjectScope(project);
|
||||||
|
try {
|
||||||
|
settings = type.getSettings(projectScope);
|
||||||
|
} catch (Exception e) {}
|
||||||
|
if (settings != null) {
|
||||||
|
String[] specs = settings.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
|
||||||
|
if (specs.length > 0) {
|
||||||
|
int total = globalSpecs.length + specs.length;
|
||||||
|
String[] projSpecs = new String[total];
|
||||||
|
int i=0;
|
||||||
|
for (int j=0; j<specs.length; j++) {
|
||||||
|
projSpecs[i] = specs[j];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
for (int j=0; j<globalSpecs.length; j++) {
|
||||||
|
projSpecs[i] = globalSpecs[j];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return projSpecs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return globalSpecs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CLanguageData findLanguagDataForFile(String fileName, IProject project, CFolderData fData){
|
||||||
|
return findLanguagDataForFile(fileName, project, fData.getLanguageDatas());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CLanguageData findLanguagDataForFile(String fileName, IProject project, CLanguageData datas[]){
|
||||||
|
// if(cType != null){
|
||||||
|
// setting = findLanguageSettingForContentTypeId(cType.getId(), settings, true);
|
||||||
|
// if(setting == null)
|
||||||
|
// setting = findLanguageSettingForContentTypeId(cType.getId(), settings, false);
|
||||||
|
// }
|
||||||
|
CLanguageData data = null;
|
||||||
|
int index = fileName.lastIndexOf('.');
|
||||||
|
if(index > 0){
|
||||||
|
String ext = fileName.substring(index + 1).trim();
|
||||||
|
if(ext.length() > 0){
|
||||||
|
data = findLanguageDataForExtension(ext, datas);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CLanguageData findLanguageDataForExtension(String ext, CLanguageData datas[]/*, boolean src*/){
|
||||||
|
CLanguageData data;
|
||||||
|
for(int i = 0; i < datas.length; i++){
|
||||||
|
data = datas[i];
|
||||||
|
String exts[] = data.getSourceExtensions();
|
||||||
|
/* if(src){
|
||||||
|
if(setting.getSourceContentType() == null){
|
||||||
|
exts = setting.getSourceExtensions();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(setting.getHeaderContentType() == null){
|
||||||
|
exts = setting.getHeaderExtensions();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
if(exts != null && exts.length != 0){
|
||||||
|
for(int j = 0; j < exts.length; j++){
|
||||||
|
if(ext.equals(exts[j]))
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,121 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Intel Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Intel Corporation - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.core.settings.model.util;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.settings.model.ICExclusionPatternPathEntry;
|
||||||
|
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
||||||
|
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
|
public class CSettingEntryFactory {
|
||||||
|
private static final HashSet EMPTY_SET = new HashSet(0);
|
||||||
|
|
||||||
|
private KindBasedStore fStore = new KindBasedStore(false);
|
||||||
|
|
||||||
|
private HashMap getNameMap(int kind, boolean create){
|
||||||
|
HashMap map = (HashMap)fStore.get(kind);
|
||||||
|
if(map == null && create){
|
||||||
|
map = new HashMap();
|
||||||
|
fStore.put(kind, map);
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
private HashMap getValueMap(String name, boolean create){
|
||||||
|
HashMap nameMap = getNameMap(ICSettingEntry.MACRO, create);
|
||||||
|
if(nameMap != null){
|
||||||
|
return getMap(nameMap, name, create);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private HashMap getFlagMap(int kind, String name, String value, IPath[] exclusionPatters, boolean create){
|
||||||
|
switch(kind){
|
||||||
|
case ICSettingEntry.MACRO:
|
||||||
|
HashMap valueMap = getValueMap(name, create);
|
||||||
|
if(valueMap != null){
|
||||||
|
return getMap(valueMap, name, create);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
case ICSettingEntry.SOURCE_PATH:
|
||||||
|
case ICSettingEntry.OUTPUT_PATH:
|
||||||
|
HashMap excPatternMap = getExclusionPatternsMap(kind, name, create);
|
||||||
|
if(excPatternMap != null){
|
||||||
|
HashSet setKey = exclusionPatters == null || exclusionPatters.length == 0 ? EMPTY_SET : new HashSet(Arrays.asList(exclusionPatters));
|
||||||
|
return getMap(excPatternMap, setKey, create);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
default:
|
||||||
|
HashMap nameMap = getNameMap(kind, create);
|
||||||
|
if(nameMap != null){
|
||||||
|
return getMap(nameMap, name, create);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private HashMap getExclusionPatternsMap(int kind, String name, boolean create){
|
||||||
|
HashMap nameMap = getNameMap(kind, create);
|
||||||
|
if(nameMap != null){
|
||||||
|
return getMap(nameMap, name, create);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static HashMap getMap(HashMap container, Object key, boolean create){
|
||||||
|
HashMap map = (HashMap)container.get(key);
|
||||||
|
if(map == null && create){
|
||||||
|
map = new HashMap();
|
||||||
|
container.put(key, map);
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICSettingEntry getEntry(ICSettingEntry entry){
|
||||||
|
switch(entry.getKind()){
|
||||||
|
case ICSettingEntry.OUTPUT_PATH:
|
||||||
|
case ICSettingEntry.SOURCE_PATH:
|
||||||
|
return getEntry(entry.getKind(), entry.getName(), null, ((ICExclusionPatternPathEntry)entry).getExclusionPatterns(), entry.getFlags(), entry, true);
|
||||||
|
default:
|
||||||
|
return getLanguageSettingEntry((ICLanguageSettingEntry)entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICLanguageSettingEntry getLanguageSettingEntry(ICLanguageSettingEntry lEntry){
|
||||||
|
return (ICLanguageSettingEntry)getEntry(lEntry.getKind(), lEntry.getName(), lEntry.getValue(), null, lEntry.getFlags(), lEntry, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICSettingEntry getEntry(int kind, String name, String value, IPath[] exclusionPatterns, int flags, boolean create){
|
||||||
|
return getEntry(kind, name, value, exclusionPatterns, flags, null, create);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ICSettingEntry getEntry(int kind, String name, String value, IPath[] exclusionPatterns, int flags, ICSettingEntry baseEntry, boolean create){
|
||||||
|
HashMap flagMap = getFlagMap(kind, name, value, exclusionPatterns, create);
|
||||||
|
if(flagMap != null){
|
||||||
|
Integer iFlags = new Integer(flags);
|
||||||
|
ICSettingEntry entry = (ICSettingEntry)flagMap.get(iFlags);
|
||||||
|
if(entry == null && create){
|
||||||
|
entry = baseEntry != null ? baseEntry : CDataUtil.createEntry(kind, name, value, exclusionPatterns, flags);
|
||||||
|
flagMap.put(iFlags, entry);
|
||||||
|
}
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear(){
|
||||||
|
fStore.clear();
|
||||||
|
}
|
||||||
|
}
|
|
@ -67,7 +67,6 @@ import org.eclipse.cdt.internal.core.model.CModelStatus;
|
||||||
import org.eclipse.cdt.internal.core.model.PathEntry;
|
import org.eclipse.cdt.internal.core.model.PathEntry;
|
||||||
import org.eclipse.cdt.internal.core.settings.model.CConfigurationDescriptionCache;
|
import org.eclipse.cdt.internal.core.settings.model.CConfigurationDescriptionCache;
|
||||||
import org.eclipse.cdt.internal.core.settings.model.CExternalSetting;
|
import org.eclipse.cdt.internal.core.settings.model.CExternalSetting;
|
||||||
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
|
|
||||||
import org.eclipse.cdt.internal.core.settings.model.IInternalCCfgInfo;
|
import org.eclipse.cdt.internal.core.settings.model.IInternalCCfgInfo;
|
||||||
import org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver;
|
import org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver;
|
||||||
import org.eclipse.core.resources.IContainer;
|
import org.eclipse.core.resources.IContainer;
|
||||||
|
@ -1103,7 +1102,7 @@ public class PathEntryTranslator {
|
||||||
for(Iterator iter = composerList.iterator(); iter.hasNext();){
|
for(Iterator iter = composerList.iterator(); iter.hasNext();){
|
||||||
PathEntryComposer cs = (PathEntryComposer)iter.next();
|
PathEntryComposer cs = (PathEntryComposer)iter.next();
|
||||||
ICSettingEntry entry = cs.getSettingEntry();
|
ICSettingEntry entry = cs.getSettingEntry();
|
||||||
if(checkFilter(entry, flags)){
|
if(checkFilter(cs, entry, flags)){
|
||||||
IPathEntry pe = cs.toPathEntry();
|
IPathEntry pe = cs.toPathEntry();
|
||||||
if(pe != null)
|
if(pe != null)
|
||||||
list.add(pe);
|
list.add(pe);
|
||||||
|
@ -1114,9 +1113,12 @@ public class PathEntryTranslator {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean checkFilter(ICSettingEntry entry, int flags){
|
private static boolean checkFilter(PathEntryComposer cs, ICSettingEntry entry, int flags){
|
||||||
boolean builtIn = entry != null ?
|
boolean builtIn = entry != null ?
|
||||||
entry.isBuiltIn() || entry.isReadOnly() : false;
|
entry.isBuiltIn() || entry.isReadOnly() : false;
|
||||||
|
|
||||||
|
if(builtIn && cs.getPath().segmentCount() > 1)
|
||||||
|
return false;
|
||||||
if((flags & INCLUDE_BUILT_INS) != 0 && builtIn)
|
if((flags & INCLUDE_BUILT_INS) != 0 && builtIn)
|
||||||
return true;
|
return true;
|
||||||
if((flags & INCLUDE_USER) != 0 && !builtIn)
|
if((flags & INCLUDE_USER) != 0 && !builtIn)
|
||||||
|
@ -1596,7 +1598,7 @@ public class PathEntryTranslator {
|
||||||
} else {
|
} else {
|
||||||
CFolderData folderData = (CFolderData)base;
|
CFolderData folderData = (CFolderData)base;
|
||||||
CLanguageData lDatas[] = folderData.getLanguageDatas();
|
CLanguageData lDatas[] = folderData.getLanguageDatas();
|
||||||
CLanguageData baseLData = CProjectDescriptionManager.getInstance().findLanguagDataForFile(rcInfo.fRc.getFullPath().lastSegment(), fProject, lDatas);
|
CLanguageData baseLData = CDataUtil.findLanguagDataForFile(rcInfo.fRc.getFullPath().lastSegment(), fProject, lDatas);
|
||||||
newRcData = fCfgData.createFileData(path, folderData, baseLData);
|
newRcData = fCfgData.createFileData(path, folderData, baseLData);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICExternalSetting;
|
import org.eclipse.cdt.core.settings.model.ICExternalSetting;
|
||||||
import org.eclipse.cdt.core.settings.model.ICFileDescription;
|
import org.eclipse.cdt.core.settings.model.ICFileDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICFolderDescription;
|
import org.eclipse.cdt.core.settings.model.ICFolderDescription;
|
||||||
|
import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
|
||||||
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
||||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
|
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
|
||||||
|
@ -724,4 +725,8 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC
|
||||||
CConfigurationDescriptionCache data = (CConfigurationDescriptionCache)doGetData();
|
CConfigurationDescriptionCache data = (CConfigurationDescriptionCache)doGetData();
|
||||||
return data.isInitializing();
|
return data.isInitializing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ICLanguageSetting getLanguageSettingForFile(IPath path) {
|
||||||
|
return CProjectDescriptionManager.getLanguageSettingForFile(this, path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICExternalSetting;
|
import org.eclipse.cdt.core.settings.model.ICExternalSetting;
|
||||||
import org.eclipse.cdt.core.settings.model.ICFileDescription;
|
import org.eclipse.cdt.core.settings.model.ICFileDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICFolderDescription;
|
import org.eclipse.cdt.core.settings.model.ICFolderDescription;
|
||||||
|
import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
|
||||||
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
||||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
|
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
|
||||||
|
@ -40,6 +41,7 @@ import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
|
||||||
import org.eclipse.cdt.core.settings.model.extension.CResourceData;
|
import org.eclipse.cdt.core.settings.model.extension.CResourceData;
|
||||||
import org.eclipse.cdt.core.settings.model.extension.CTargetPlatformData;
|
import org.eclipse.cdt.core.settings.model.extension.CTargetPlatformData;
|
||||||
import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultConfigurationData;
|
import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultConfigurationData;
|
||||||
|
import org.eclipse.cdt.core.settings.model.util.CSettingEntryFactory;
|
||||||
import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer;
|
import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer;
|
||||||
import org.eclipse.cdt.internal.core.cdtvariables.CdtVariableManager;
|
import org.eclipse.cdt.internal.core.cdtvariables.CdtVariableManager;
|
||||||
import org.eclipse.cdt.internal.core.cdtvariables.StorableCdtVariables;
|
import org.eclipse.cdt.internal.core.cdtvariables.StorableCdtVariables;
|
||||||
|
@ -60,6 +62,7 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData
|
||||||
private boolean fDataLoadded;
|
private boolean fDataLoadded;
|
||||||
private boolean fInitializing;
|
private boolean fInitializing;
|
||||||
private ICConfigurationDescription fBaseDescription;
|
private ICConfigurationDescription fBaseDescription;
|
||||||
|
private CSettingEntryFactory fSettingsFactory;
|
||||||
|
|
||||||
CConfigurationDescriptionCache(ICStorageElement storage, CProjectDescription parent) throws CoreException{
|
CConfigurationDescriptionCache(ICStorageElement storage, CProjectDescription parent) throws CoreException{
|
||||||
super(null);
|
super(null);
|
||||||
|
@ -77,15 +80,20 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData
|
||||||
return fInitializing;
|
return fInitializing;
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadData() throws CoreException{
|
void loadData(CSettingEntryFactory factory) throws CoreException{
|
||||||
if(fDataLoadded)
|
if(fDataLoadded)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fDataLoadded = true;
|
fDataLoadded = true;
|
||||||
|
|
||||||
fData = CProjectDescriptionManager.getInstance().loadData(this, null);
|
fData = CProjectDescriptionManager.getInstance().loadData(this, null);
|
||||||
|
|
||||||
|
fSettingsFactory = factory;
|
||||||
|
|
||||||
copySettingsFrom(fData, true);
|
copySettingsFrom(fData, true);
|
||||||
|
|
||||||
|
fSettingsFactory = null;
|
||||||
|
|
||||||
fSpecSettings.reconsileExtensionSettings(true);
|
fSpecSettings.reconsileExtensionSettings(true);
|
||||||
((CBuildSettingCache)fBuildData).initEnvironmentCache();
|
((CBuildSettingCache)fBuildData).initEnvironmentCache();
|
||||||
ICdtVariable vars[] = CdtVariableManager.getDefault().getVariables(this);
|
ICdtVariable vars[] = CdtVariableManager.getDefault().getVariables(this);
|
||||||
|
@ -121,7 +129,7 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData
|
||||||
// fInitializing = false;
|
// fInitializing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void applyData() throws CoreException{
|
void applyData(CSettingEntryFactory factory) throws CoreException{
|
||||||
if(fBaseDescription == null)
|
if(fBaseDescription == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -129,9 +137,12 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData
|
||||||
fDataLoadded = true;
|
fDataLoadded = true;
|
||||||
fName = fData.getName();
|
fName = fData.getName();
|
||||||
fId = fData.getId();
|
fId = fData.getId();
|
||||||
|
fSettingsFactory = factory;
|
||||||
|
|
||||||
copySettingsFrom(fData, true);
|
copySettingsFrom(fData, true);
|
||||||
|
|
||||||
|
fSettingsFactory = null;
|
||||||
|
|
||||||
ICdtVariable vars[] = CdtVariableManager.getDefault().getVariables(this);
|
ICdtVariable vars[] = CdtVariableManager.getDefault().getVariables(this);
|
||||||
fMacros = new StorableCdtVariables(vars, true);
|
fMacros = new StorableCdtVariables(vars, true);
|
||||||
// if(saving)
|
// if(saving)
|
||||||
|
@ -141,6 +152,10 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData
|
||||||
// fInitializing = false;
|
// fInitializing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CSettingEntryFactory getSettingsFactory(){
|
||||||
|
return fSettingsFactory;
|
||||||
|
}
|
||||||
|
|
||||||
public StorableCdtVariables getCachedVariables(){
|
public StorableCdtVariables getCachedVariables(){
|
||||||
return fMacros;
|
return fMacros;
|
||||||
}
|
}
|
||||||
|
@ -424,4 +439,8 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData
|
||||||
void doneInitialization(){
|
void doneInitialization(){
|
||||||
fInitializing = false;
|
fInitializing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ICLanguageSetting getLanguageSettingForFile(IPath path) {
|
||||||
|
return CProjectDescriptionManager.getLanguageSettingForFile(this, path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,9 +28,11 @@ public class CFileDescriptionCache extends CDefaultFileData implements
|
||||||
private ResourceDescriptionHolder fRcDesHolder;
|
private ResourceDescriptionHolder fRcDesHolder;
|
||||||
|
|
||||||
public CFileDescriptionCache(CFileData base, CConfigurationDescriptionCache cfg) {
|
public CFileDescriptionCache(CFileData base, CConfigurationDescriptionCache cfg) {
|
||||||
super(base.getId(), base.getPath(), base, cfg, null, true);
|
super(base.getId(), base.getPath(), cfg, null);
|
||||||
fCfg = cfg;
|
fCfg = cfg;
|
||||||
fCfg.addResourceDescription(this);
|
fCfg.addResourceDescription(this);
|
||||||
|
|
||||||
|
copyDataFrom(base, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CLanguageData copyLanguageData(CLanguageData data, boolean clone) {
|
protected CLanguageData copyLanguageData(CLanguageData data, boolean clone) {
|
||||||
|
|
|
@ -18,8 +18,10 @@ import org.eclipse.cdt.core.settings.model.ICSettingBase;
|
||||||
import org.eclipse.cdt.core.settings.model.ICSettingContainer;
|
import org.eclipse.cdt.core.settings.model.ICSettingContainer;
|
||||||
import org.eclipse.cdt.core.settings.model.ICSettingObject;
|
import org.eclipse.cdt.core.settings.model.ICSettingObject;
|
||||||
import org.eclipse.cdt.core.settings.model.WriteAccessException;
|
import org.eclipse.cdt.core.settings.model.WriteAccessException;
|
||||||
|
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
|
||||||
import org.eclipse.cdt.core.settings.model.extension.CFolderData;
|
import org.eclipse.cdt.core.settings.model.extension.CFolderData;
|
||||||
import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
|
import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
|
||||||
|
import org.eclipse.cdt.core.settings.model.extension.impl.CDataFacroty;
|
||||||
import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultFolderData;
|
import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultFolderData;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
@ -31,9 +33,11 @@ public class CFolderDescriptionCache extends CDefaultFolderData implements
|
||||||
private ResourceDescriptionHolder fRcDesHolder;
|
private ResourceDescriptionHolder fRcDesHolder;
|
||||||
|
|
||||||
public CFolderDescriptionCache(CFolderData base, CConfigurationDescriptionCache cfg) {
|
public CFolderDescriptionCache(CFolderData base, CConfigurationDescriptionCache cfg) {
|
||||||
super(base.getId(), base.getPath(), base, cfg, null, true);
|
super(base.getId(), base.getPath(), cfg, null);
|
||||||
fCfg = cfg;
|
fCfg = cfg;
|
||||||
fCfg.addResourceDescription(this);
|
fCfg.addResourceDescription(this);
|
||||||
|
|
||||||
|
copyDataFrom(base, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICLanguageSetting getLanguageSettingForFile(String fileName) {
|
public ICLanguageSetting getLanguageSettingForFile(String fileName) {
|
||||||
|
|
|
@ -113,21 +113,22 @@ public class CLanguageSetting extends CDataProxy implements
|
||||||
*/
|
*/
|
||||||
public String[] getSourceExtensions() {
|
public String[] getSourceExtensions() {
|
||||||
CLanguageData data = getCLanguageData(false);
|
CLanguageData data = getCLanguageData(false);
|
||||||
String[] exts = null;
|
return CDataUtil.getSourceExtensions(getProject(), data);
|
||||||
String[] typeIds = data.getSourceContentTypeIds();
|
// String[] exts = null;
|
||||||
if(typeIds != null && typeIds.length != 0){
|
// String[] typeIds = data.getSourceContentTypeIds();
|
||||||
exts = CProjectDescriptionManager.getInstance().getExtensionsFromContentTypes(getProject(), typeIds);
|
// if(typeIds != null && typeIds.length != 0){
|
||||||
} else {
|
// exts = CProjectDescriptionManager.getInstance().getExtensionsFromContentTypes(getProject(), typeIds);
|
||||||
exts = data.getSourceExtensions();
|
// } else {
|
||||||
if(exts != null && exts.length != 0)
|
// exts = data.getSourceExtensions();
|
||||||
exts = (String[])exts.clone();
|
// if(exts != null && exts.length != 0)
|
||||||
else
|
// exts = (String[])exts.clone();
|
||||||
exts = CDefaultLanguageData.EMPTY_STRING_ARRAY;
|
// else
|
||||||
}
|
// exts = CDefaultLanguageData.EMPTY_STRING_ARRAY;
|
||||||
|
// }
|
||||||
if(exts == null)
|
//
|
||||||
exts = CDefaultLanguageData.EMPTY_STRING_ARRAY;
|
// if(exts == null)
|
||||||
return exts;
|
// exts = CDefaultLanguageData.EMPTY_STRING_ARRAY;
|
||||||
|
// return exts;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -20,6 +20,7 @@ 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.CLanguageData;
|
||||||
import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultLanguageData;
|
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.CDataUtil;
|
||||||
|
import org.eclipse.cdt.core.settings.model.util.CSettingEntryFactory;
|
||||||
import org.eclipse.cdt.core.settings.model.util.EntryStore;
|
import org.eclipse.cdt.core.settings.model.util.EntryStore;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
|
||||||
|
@ -74,7 +75,7 @@ public class CLanguageSettingCache extends CDefaultLanguageData implements
|
||||||
String[] typeIds = getSourceContentTypeIds();
|
String[] typeIds = getSourceContentTypeIds();
|
||||||
String exts[] = null;
|
String exts[] = null;
|
||||||
if(typeIds != null && typeIds.length != 0){
|
if(typeIds != null && typeIds.length != 0){
|
||||||
exts = CProjectDescriptionManager.getInstance().getExtensionsFromContentTypes(getProject(), typeIds);
|
exts = CDataUtil.getExtensionsFromContentTypes(getProject(), typeIds);
|
||||||
} else {
|
} else {
|
||||||
exts = super.getSourceExtensions();
|
exts = super.getSourceExtensions();
|
||||||
if(exts != null && exts.length != 0)
|
if(exts != null && exts.length != 0)
|
||||||
|
@ -156,4 +157,18 @@ public class CLanguageSettingCache extends CDefaultLanguageData implements
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ICLanguageSettingEntry[] processStoredEntries(
|
||||||
|
ICLanguageSettingEntry[] entries, int op) {
|
||||||
|
if(entries.length != 0){
|
||||||
|
CConfigurationDescriptionCache cfgCache = (CConfigurationDescriptionCache)getConfiguration();
|
||||||
|
CSettingEntryFactory factory = cfgCache.getSettingsFactory();
|
||||||
|
if(factory != null){
|
||||||
|
for(int i = 0; i < entries.length; i++){
|
||||||
|
entries[i] = factory.getLanguageSettingEntry(entries[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return entries;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import org.eclipse.cdt.core.settings.model.ICSettingsStorage;
|
||||||
import org.eclipse.cdt.core.settings.model.ICStorageElement;
|
import org.eclipse.cdt.core.settings.model.ICStorageElement;
|
||||||
import org.eclipse.cdt.core.settings.model.WriteAccessException;
|
import org.eclipse.cdt.core.settings.model.WriteAccessException;
|
||||||
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
|
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
|
||||||
|
import org.eclipse.cdt.core.settings.model.util.CSettingEntryFactory;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.QualifiedName;
|
import org.eclipse.core.runtime.QualifiedName;
|
||||||
|
@ -72,10 +73,11 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
if(!fIsReadOnly || !fIsLoadding)
|
if(!fIsReadOnly || !fIsLoadding)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
CSettingEntryFactory factory = new CSettingEntryFactory();
|
||||||
for(Iterator iter = fCfgMap.values().iterator(); iter.hasNext();){
|
for(Iterator iter = fCfgMap.values().iterator(); iter.hasNext();){
|
||||||
CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache)iter.next();
|
CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache)iter.next();
|
||||||
try {
|
try {
|
||||||
cache.loadData();
|
cache.loadData(factory);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
iter.remove();
|
iter.remove();
|
||||||
|
@ -83,6 +85,9 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
}
|
}
|
||||||
|
|
||||||
doneInitializing();
|
doneInitializing();
|
||||||
|
|
||||||
|
factory.clear();
|
||||||
|
|
||||||
fIsLoadding = false;
|
fIsLoadding = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,10 +95,11 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
if(!fIsReadOnly || !fIsApplying)
|
if(!fIsReadOnly || !fIsApplying)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
CSettingEntryFactory factory = new CSettingEntryFactory();
|
||||||
for(Iterator iter = fCfgMap.values().iterator(); iter.hasNext();){
|
for(Iterator iter = fCfgMap.values().iterator(); iter.hasNext();){
|
||||||
CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache)iter.next();
|
CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache)iter.next();
|
||||||
try {
|
try {
|
||||||
cache.applyData();
|
cache.applyData(factory);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
iter.remove();
|
iter.remove();
|
||||||
|
@ -102,6 +108,8 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
|
|
||||||
doneInitializing();
|
doneInitializing();
|
||||||
|
|
||||||
|
factory.clear();
|
||||||
|
|
||||||
fIsApplying = false;
|
fIsApplying = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +157,7 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
configurationCreated(cfg);
|
configurationCreated(cfg);
|
||||||
}
|
}
|
||||||
} catch (CoreException e){
|
} catch (CoreException e){
|
||||||
//TODO: log
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,8 +68,8 @@ import org.eclipse.cdt.core.settings.model.extension.CResourceData;
|
||||||
import org.eclipse.cdt.core.settings.model.extension.ICProjectConverter;
|
import org.eclipse.cdt.core.settings.model.extension.ICProjectConverter;
|
||||||
import org.eclipse.cdt.core.settings.model.extension.impl.CDataFacroty;
|
import org.eclipse.cdt.core.settings.model.extension.impl.CDataFacroty;
|
||||||
import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultConfigurationData;
|
import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultConfigurationData;
|
||||||
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.CDataUtil;
|
||||||
|
import org.eclipse.cdt.core.settings.model.util.CSettingEntryFactory;
|
||||||
import org.eclipse.cdt.core.settings.model.util.KindBasedStore;
|
import org.eclipse.cdt.core.settings.model.util.KindBasedStore;
|
||||||
import org.eclipse.cdt.core.settings.model.util.ListComparator;
|
import org.eclipse.cdt.core.settings.model.util.ListComparator;
|
||||||
import org.eclipse.cdt.internal.core.CConfigBasedDescriptorManager;
|
import org.eclipse.cdt.internal.core.CConfigBasedDescriptorManager;
|
||||||
|
@ -87,7 +87,6 @@ import org.eclipse.core.resources.ISavedState;
|
||||||
import org.eclipse.core.resources.IWorkspace;
|
import org.eclipse.core.resources.IWorkspace;
|
||||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||||
import org.eclipse.core.resources.ProjectScope;
|
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IExtension;
|
import org.eclipse.core.runtime.IExtension;
|
||||||
|
@ -102,11 +101,9 @@ import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||||
import org.eclipse.core.runtime.content.IContentType;
|
import org.eclipse.core.runtime.content.IContentType;
|
||||||
import org.eclipse.core.runtime.content.IContentTypeManager;
|
import org.eclipse.core.runtime.content.IContentTypeManager;
|
||||||
import org.eclipse.core.runtime.content.IContentTypeSettings;
|
|
||||||
import org.eclipse.core.runtime.jobs.IJobManager;
|
import org.eclipse.core.runtime.jobs.IJobManager;
|
||||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||||
import org.eclipse.core.runtime.jobs.Job;
|
import org.eclipse.core.runtime.jobs.Job;
|
||||||
import org.eclipse.core.runtime.preferences.IScopeContext;
|
|
||||||
import org.osgi.framework.Version;
|
import org.osgi.framework.Version;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
@ -1402,49 +1399,6 @@ public class CProjectDescriptionManager {
|
||||||
return setting;
|
return setting;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CLanguageData findLanguagDataForFile(String fileName, IProject project, CLanguageData datas[]){
|
|
||||||
// if(cType != null){
|
|
||||||
// setting = findLanguageSettingForContentTypeId(cType.getId(), settings, true);
|
|
||||||
// if(setting == null)
|
|
||||||
// setting = findLanguageSettingForContentTypeId(cType.getId(), settings, false);
|
|
||||||
// }
|
|
||||||
CLanguageData data = null;
|
|
||||||
int index = fileName.lastIndexOf('.');
|
|
||||||
if(index > 0){
|
|
||||||
String ext = fileName.substring(index + 1).trim();
|
|
||||||
if(ext.length() > 0){
|
|
||||||
data = findLanguageDataForExtension(ext, datas);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CLanguageData findLanguageDataForExtension(String ext, CLanguageData datas[]/*, boolean src*/){
|
|
||||||
CLanguageData data;
|
|
||||||
for(int i = 0; i < datas.length; i++){
|
|
||||||
data = datas[i];
|
|
||||||
String exts[] = data.getSourceExtensions();
|
|
||||||
/* if(src){
|
|
||||||
if(setting.getSourceContentType() == null){
|
|
||||||
exts = setting.getSourceExtensions();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(setting.getHeaderContentType() == null){
|
|
||||||
exts = setting.getHeaderExtensions();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
if(exts != null && exts.length != 0){
|
|
||||||
for(int j = 0; j < exts.length; j++){
|
|
||||||
if(ext.equals(exts[j]))
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public ICLanguageSetting findLanguageSettingForContentTypeId(String id, ICLanguageSetting settings[]/*, boolean src*/){
|
public ICLanguageSetting findLanguageSettingForContentTypeId(String id, ICLanguageSetting settings[]/*, boolean src*/){
|
||||||
for(int i = 0; i < settings.length; i++){
|
for(int i = 0; i < settings.length; i++){
|
||||||
String ids[] = settings[i].getSourceContentTypeIds();
|
String ids[] = settings[i].getSourceContentTypeIds();
|
||||||
|
@ -2848,9 +2802,10 @@ public class CProjectDescriptionManager {
|
||||||
ICStorageElement baseRootEl = settings.getRootStorageElement();
|
ICStorageElement baseRootEl = settings.getRootStorageElement();
|
||||||
rootEl = rootParent.importChild(baseRootEl);
|
rootEl = rootParent.importChild(baseRootEl);
|
||||||
CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache(des, baseData, cfgDes.getSpecSettings(), null, rootEl);
|
CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache(des, baseData, cfgDes.getSpecSettings(), null, rootEl);
|
||||||
cache.applyData();
|
CSettingEntryFactory factory = new CSettingEntryFactory();
|
||||||
|
cache.applyData(factory);
|
||||||
cache.doneInitialization();
|
cache.doneInitialization();
|
||||||
|
factory.clear();
|
||||||
return cache;
|
return cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2926,8 +2881,10 @@ public class CProjectDescriptionManager {
|
||||||
|
|
||||||
}
|
}
|
||||||
CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache(cfgEl, null);
|
CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache(cfgEl, null);
|
||||||
cache.loadData();
|
CSettingEntryFactory factory = new CSettingEntryFactory();
|
||||||
|
cache.loadData(factory);
|
||||||
cache.doneInitialization();
|
cache.doneInitialization();
|
||||||
|
factory.clear();
|
||||||
return cache;
|
return cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3111,59 +3068,38 @@ public class CProjectDescriptionManager {
|
||||||
return data != null && !PathEntryConfigurationDataProvider.isPathEntryData(data);
|
return data != null && !PathEntryConfigurationDataProvider.isPathEntryData(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getContentTypeFileSpecs (IProject project, IContentType type) {
|
// public String[] getContentTypeFileSpecs (IProject project, IContentType type) {
|
||||||
String[] globalSpecs = type.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
|
// String[] globalSpecs = type.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
|
||||||
IContentTypeSettings settings = null;
|
// IContentTypeSettings settings = null;
|
||||||
if (project != null) {
|
// if (project != null) {
|
||||||
IScopeContext projectScope = new ProjectScope(project);
|
// IScopeContext projectScope = new ProjectScope(project);
|
||||||
try {
|
// try {
|
||||||
settings = type.getSettings(projectScope);
|
// settings = type.getSettings(projectScope);
|
||||||
} catch (Exception e) {}
|
// } catch (Exception e) {}
|
||||||
if (settings != null) {
|
// if (settings != null) {
|
||||||
String[] specs = settings.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
|
// String[] specs = settings.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
|
||||||
if (specs.length > 0) {
|
// if (specs.length > 0) {
|
||||||
int total = globalSpecs.length + specs.length;
|
// int total = globalSpecs.length + specs.length;
|
||||||
String[] projSpecs = new String[total];
|
// String[] projSpecs = new String[total];
|
||||||
int i=0;
|
// int i=0;
|
||||||
for (int j=0; j<specs.length; j++) {
|
// for (int j=0; j<specs.length; j++) {
|
||||||
projSpecs[i] = specs[j];
|
// projSpecs[i] = specs[j];
|
||||||
i++;
|
// i++;
|
||||||
}
|
// }
|
||||||
for (int j=0; j<globalSpecs.length; j++) {
|
// for (int j=0; j<globalSpecs.length; j++) {
|
||||||
projSpecs[i] = globalSpecs[j];
|
// projSpecs[i] = globalSpecs[j];
|
||||||
i++;
|
// i++;
|
||||||
}
|
// }
|
||||||
return projSpecs;
|
// return projSpecs;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return globalSpecs;
|
// return globalSpecs;
|
||||||
}
|
// }
|
||||||
public String[] getExtensionsFromContentTypes(IProject project, String[] typeIds){
|
|
||||||
String[] exts = null;
|
// public String[] getExtensionsFromContentTypes(IProject project, String[] typeIds){
|
||||||
if(typeIds != null && typeIds.length != 0){
|
// return CDataUtil.getExtensionsFromContentTypes(project, typeIds);
|
||||||
IContentTypeManager manager = Platform.getContentTypeManager();
|
// }
|
||||||
IContentType type;
|
|
||||||
if(typeIds.length == 1){
|
|
||||||
type = manager.getContentType(typeIds[0]);
|
|
||||||
if(type != null)
|
|
||||||
exts = getContentTypeFileSpecs(project, type);
|
|
||||||
} else {
|
|
||||||
List list = new ArrayList();
|
|
||||||
for(int i = 0; i < typeIds.length; i++){
|
|
||||||
type = manager.getContentType(typeIds[i]);
|
|
||||||
if(type != null) {
|
|
||||||
list.addAll(Arrays.asList(getContentTypeFileSpecs(project, type)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exts = (String[])list.toArray(new String[list.size()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(exts == null)
|
|
||||||
exts = CDefaultLanguageData.EMPTY_STRING_ARRAY;
|
|
||||||
return exts;
|
|
||||||
}
|
|
||||||
|
|
||||||
ICProjectDescription getDescriptionApplying(IProject project){
|
ICProjectDescription getDescriptionApplying(IProject project){
|
||||||
Map map = getDescriptionApplyingMap(false);
|
Map map = getDescriptionApplyingMap(false);
|
||||||
|
@ -3186,4 +3122,16 @@ public class CProjectDescriptionManager {
|
||||||
if(map != null)
|
if(map != null)
|
||||||
map.remove(project);
|
map.remove(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ICLanguageSetting getLanguageSettingForFile(ICConfigurationDescription cfgDes, IPath path){
|
||||||
|
int segCount = path.segmentCount();
|
||||||
|
if(segCount == 0)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
ICResourceDescription rcDes = cfgDes.getResourceDescription(path, false);
|
||||||
|
if(rcDes.getType() == ICSettingBase.SETTING_FOLDER){
|
||||||
|
return ((ICFolderDescription)rcDes).getLanguageSettingForFile(path.lastSegment());
|
||||||
|
}
|
||||||
|
return ((ICFileDescription)rcDes).getLanguageSetting();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,6 @@ import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.naming.OperationNotSupportedException;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.settings.model.ICSettingsStorage;
|
import org.eclipse.cdt.core.settings.model.ICSettingsStorage;
|
||||||
import org.eclipse.cdt.core.settings.model.ICStorageElement;
|
import org.eclipse.cdt.core.settings.model.ICStorageElement;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
Loading…
Add table
Reference in a new issue