mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
1. fix for [Bug 187822] Problem with setRawPathEntries
2.backward compatibility fixes 3. source/output entries fixes
This commit is contained in:
parent
61c043fc3a
commit
75a3ae8890
16 changed files with 471 additions and 181 deletions
|
@ -1104,7 +1104,10 @@ public class BuildDescriptionModelTests extends TestCase {
|
||||||
//in this the build system is initiating the core settings update (ICProjectDescription cache refresh)
|
//in this the build system is initiating the core settings update (ICProjectDescription cache refresh)
|
||||||
//the refresh is scheduled as a job, so in case we do not wait here the job may not be completed by the time
|
//the refresh is scheduled as a job, so in case we do not wait here the job may not be completed by the time
|
||||||
//the test is run
|
//the test is run
|
||||||
|
try {
|
||||||
|
Thread.sleep(10000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
}
|
||||||
|
|
||||||
CCorePlugin.getIndexManager().joinIndexer(-1, new NullProgressMonitor());
|
CCorePlugin.getIndexManager().joinIndexer(-1, new NullProgressMonitor());
|
||||||
|
|
||||||
|
|
|
@ -336,7 +336,11 @@ public class ProjectModelTests extends TestCase implements IElementChangedListen
|
||||||
project.delete(false, true, new NullProgressMonitor());
|
project.delete(false, true, new NullProgressMonitor());
|
||||||
|
|
||||||
project = root.getProject(projectName);
|
project = root.getProject(projectName);
|
||||||
|
assertFalse(project.exists());
|
||||||
|
assertFalse(project.isOpen());
|
||||||
des = coreModel.getProjectDescription(project);
|
des = coreModel.getProjectDescription(project);
|
||||||
|
assertFalse(project.exists());
|
||||||
|
assertFalse(project.isOpen());
|
||||||
assertNull("project description is not null for removed project", des);
|
assertNull("project description is not null for removed project", des);
|
||||||
|
|
||||||
project = createProject(projectName);
|
project = createProject(projectName);
|
||||||
|
@ -376,6 +380,8 @@ public class ProjectModelTests extends TestCase implements IElementChangedListen
|
||||||
project.delete(false, true, new NullProgressMonitor());
|
project.delete(false, true, new NullProgressMonitor());
|
||||||
|
|
||||||
project = root.getProject(projectName);
|
project = root.getProject(projectName);
|
||||||
|
assertFalse(project.exists());
|
||||||
|
assertFalse(project.isOpen());
|
||||||
des = coreModel.getProjectDescription(project);
|
des = coreModel.getProjectDescription(project);
|
||||||
assertNull("project description is not null for removed project", des);
|
assertNull("project description is not null for removed project", des);
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,12 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.settings.model;
|
package org.eclipse.cdt.core.settings.model;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||||
|
@ -20,11 +26,12 @@ import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
||||||
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.IPath;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
public class BackwardCompatibilityTests extends BaseTestCase {
|
public class BackwardCompatibilityTests extends BaseTestCase {
|
||||||
private static final String PROJ_NAME_PREFIX = "BackwardCompatibilityTests_";
|
private static final String PROJ_NAME_PREFIX = "BackwardCompatibilityTests_";
|
||||||
ICProject p1;
|
ICProject p1, p2;
|
||||||
|
|
||||||
public static TestSuite suite() {
|
public static TestSuite suite() {
|
||||||
return suite(BackwardCompatibilityTests.class, "_");
|
return suite(BackwardCompatibilityTests.class, "_");
|
||||||
|
@ -54,7 +61,6 @@ public class BackwardCompatibilityTests extends BaseTestCase {
|
||||||
CoreModel.newSourceEntry(project.getFullPath()),
|
CoreModel.newSourceEntry(project.getFullPath()),
|
||||||
CoreModel.newOutputEntry(project.getFullPath()),
|
CoreModel.newOutputEntry(project.getFullPath()),
|
||||||
};
|
};
|
||||||
assertEquals(expectedRawEntries.length, entries.length);
|
|
||||||
checkEntriesMatch(expectedRawEntries, entries);
|
checkEntriesMatch(expectedRawEntries, entries);
|
||||||
|
|
||||||
IPathEntry[] expectedResolvedEntries = new IPathEntry[]{
|
IPathEntry[] expectedResolvedEntries = new IPathEntry[]{
|
||||||
|
@ -67,7 +73,6 @@ public class BackwardCompatibilityTests extends BaseTestCase {
|
||||||
CoreModel.newIncludeEntry(project.getFullPath(), project.getFullPath().makeRelative(), new Path("g/h/i")),
|
CoreModel.newIncludeEntry(project.getFullPath(), project.getFullPath().makeRelative(), new Path("g/h/i")),
|
||||||
CoreModel.newIncludeEntry(project.getFullPath(), new Path("j"), new Path("k/l")),
|
CoreModel.newIncludeEntry(project.getFullPath(), new Path("j"), new Path("k/l")),
|
||||||
};
|
};
|
||||||
assertEquals(expectedResolvedEntries.length, resolvedentries.length);
|
|
||||||
checkEntriesMatch(expectedResolvedEntries, resolvedentries);
|
checkEntriesMatch(expectedResolvedEntries, resolvedentries);
|
||||||
|
|
||||||
IPathEntry[] newEntries = new IPathEntry[entries.length + 1];
|
IPathEntry[] newEntries = new IPathEntry[entries.length + 1];
|
||||||
|
@ -81,7 +86,6 @@ public class BackwardCompatibilityTests extends BaseTestCase {
|
||||||
CoreModel.setRawPathEntries(p1, newEntries, null);
|
CoreModel.setRawPathEntries(p1, newEntries, null);
|
||||||
|
|
||||||
entries = CoreModel.getRawPathEntries(p1);
|
entries = CoreModel.getRawPathEntries(p1);
|
||||||
assertEquals(newExpectedRawEntries.length, entries.length);
|
|
||||||
checkEntriesMatch(entries, newExpectedRawEntries);
|
checkEntriesMatch(entries, newExpectedRawEntries);
|
||||||
|
|
||||||
IPathEntry[] newExpectedResolved = new IPathEntry[resolvedentries.length + 1];
|
IPathEntry[] newExpectedResolved = new IPathEntry[resolvedentries.length + 1];
|
||||||
|
@ -89,9 +93,125 @@ public class BackwardCompatibilityTests extends BaseTestCase {
|
||||||
newExpectedResolved[resolvedentries.length] = CoreModel.newIncludeEntry(project.getFullPath().append("d"), null, new Path("/C/d/e"), true, new Path[]{new Path("a"), new Path("b")}, false);
|
newExpectedResolved[resolvedentries.length] = CoreModel.newIncludeEntry(project.getFullPath().append("d"), null, new Path("/C/d/e"), true, new Path[]{new Path("a"), new Path("b")}, false);
|
||||||
resolvedentries = CoreModel.getResolvedPathEntries(p1);
|
resolvedentries = CoreModel.getResolvedPathEntries(p1);
|
||||||
checkEntriesMatch(resolvedentries, newExpectedResolved);
|
checkEntriesMatch(resolvedentries, newExpectedResolved);
|
||||||
|
|
||||||
|
entries = concatEntries(entries, new IPathEntry[]{
|
||||||
|
CoreModel.newSourceEntry(project.getFullPath().append("test_src")),
|
||||||
|
CoreModel.newOutputEntry(project.getFullPath().append("test_out")),});
|
||||||
|
|
||||||
|
newExpectedRawEntries = concatEntries(newExpectedRawEntries, new IPathEntry[]{
|
||||||
|
CoreModel.newSourceEntry(project.getFullPath().append("test_src")),
|
||||||
|
CoreModel.newOutputEntry(project.getFullPath().append("test_out")),});
|
||||||
|
|
||||||
|
for(int i = 0; i < newExpectedRawEntries.length; i++){
|
||||||
|
IPathEntry entry = newExpectedRawEntries[i];
|
||||||
|
if(entry.getEntryKind() == IPathEntry.CDT_SOURCE && entry.getPath().equals(project.getFullPath())){
|
||||||
|
newExpectedRawEntries[i] = CoreModel.newSourceEntry(project.getFullPath(), new Path[]{new Path("test_src")});
|
||||||
|
}
|
||||||
|
// if(entry.getEntryKind() == IPathEntry.CDT_OUTPUT && entry.getPath().equals(project.getFullPath())){
|
||||||
|
// newExpectedRawEntries[i] = CoreModel.newOutputEntry(project.getFullPath(), new Path[]{new Path("test_out")});
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkEntriesMatch(IPathEntry[] e1, IPathEntry[] e2){
|
newExpectedResolved = concatEntries(newExpectedResolved, new IPathEntry[]{
|
||||||
|
CoreModel.newSourceEntry(project.getFullPath().append("test_src")),
|
||||||
|
CoreModel.newOutputEntry(project.getFullPath().append("test_out")),});
|
||||||
|
|
||||||
|
for(int i = 0; i < newExpectedResolved.length; i++){
|
||||||
|
IPathEntry entry = newExpectedResolved[i];
|
||||||
|
if(entry.getEntryKind() == IPathEntry.CDT_SOURCE && entry.getPath().equals(project.getFullPath())){
|
||||||
|
newExpectedResolved[i] = CoreModel.newSourceEntry(project.getFullPath(), new Path[]{new Path("test_src")});
|
||||||
|
}
|
||||||
|
// if(entry.getEntryKind() == IPathEntry.CDT_OUTPUT && entry.getPath().equals(project.getFullPath())){
|
||||||
|
// newExpectedResolved[i] = CoreModel.newOutputEntry(project.getFullPath(), new Path[]{new Path("test_out")});
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
CoreModel.setRawPathEntries(p1, entries, null);
|
||||||
|
|
||||||
|
entries = CoreModel.getRawPathEntries(p1);
|
||||||
|
resolvedentries = CoreModel.getResolvedPathEntries(p1);
|
||||||
|
|
||||||
|
checkEntriesMatch(newExpectedRawEntries, entries);
|
||||||
|
checkEntriesMatch(newExpectedResolved, resolvedentries);
|
||||||
|
|
||||||
|
CoreModel.setRawPathEntries(p1, expectedRawEntries, null);
|
||||||
|
entries = CoreModel.getRawPathEntries(p1);
|
||||||
|
resolvedentries = CoreModel.getResolvedPathEntries(p1);
|
||||||
|
|
||||||
|
checkEntriesMatch(expectedRawEntries, entries);
|
||||||
|
checkEntriesMatch(expectedResolvedEntries, resolvedentries);
|
||||||
|
|
||||||
|
//check to see that setting the same entries do not give errors
|
||||||
|
CoreModel.setRawPathEntries(p1, expectedRawEntries, null);
|
||||||
|
entries = CoreModel.getRawPathEntries(p1);
|
||||||
|
resolvedentries = CoreModel.getResolvedPathEntries(p1);
|
||||||
|
|
||||||
|
checkEntriesMatch(expectedRawEntries, entries);
|
||||||
|
checkEntriesMatch(expectedResolvedEntries, resolvedentries);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testCPathEntriesForOldStyle() throws Exception {
|
||||||
|
p2 = CProjectHelper.createCCProject(PROJ_NAME_PREFIX + "b", null, IPDOMManager.ID_NO_INDEXER);
|
||||||
|
ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
|
||||||
|
IProject project = p2.getProject();
|
||||||
|
ICProjectDescription des = mngr.getProjectDescription(project, false);
|
||||||
|
assertNotNull(des);
|
||||||
|
assertEquals(1, des.getConfigurations().length);
|
||||||
|
assertFalse(mngr.isNewStyleProject(des));
|
||||||
|
assertFalse(mngr.isNewStyleProject(project));
|
||||||
|
|
||||||
|
IPathEntry[] entries = CoreModel.getRawPathEntries(p2);
|
||||||
|
entries = concatEntries(entries, new IPathEntry[]{
|
||||||
|
CoreModel.newSourceEntry(project.getFullPath().append("test_src")),
|
||||||
|
CoreModel.newOutputEntry(project.getFullPath().append("test_out")),});
|
||||||
|
|
||||||
|
CoreModel.setRawPathEntries(p2, entries, null);
|
||||||
|
|
||||||
|
ICSourceEntry[] expectedSourceEntries = new ICSourceEntry[]{
|
||||||
|
new CSourceEntry(project.getFullPath(), new IPath[] {new Path("test_src")}, ICSettingEntry.RESOLVED),
|
||||||
|
new CSourceEntry(project.getFullPath().append("test_src"), null, ICSettingEntry.RESOLVED),
|
||||||
|
};
|
||||||
|
|
||||||
|
ICOutputEntry[] expectedOutputEntries = new ICOutputEntry[]{
|
||||||
|
new COutputEntry(project.getFullPath(), null, ICSettingEntry.RESOLVED | ICSettingEntry.VALUE_WORKSPACE_PATH),
|
||||||
|
new COutputEntry(project.getFullPath().append("test_out"), null, ICSettingEntry.RESOLVED | ICSettingEntry.VALUE_WORKSPACE_PATH),
|
||||||
|
};
|
||||||
|
|
||||||
|
des = mngr.getProjectDescription(project, false);
|
||||||
|
ICConfigurationDescription cfg = des.getDefaultSettingConfiguration();
|
||||||
|
ICSourceEntry[] sEntries = cfg.getSourceEntries();
|
||||||
|
ICOutputEntry[] oEntries = cfg.getBuildSetting().getOutputDirectories();
|
||||||
|
|
||||||
|
checkCEntriesMatch(expectedSourceEntries, sEntries);
|
||||||
|
checkCEntriesMatch(expectedOutputEntries, oEntries);
|
||||||
|
|
||||||
|
des = mngr.getProjectDescription(project, true);
|
||||||
|
cfg = des.getDefaultSettingConfiguration();
|
||||||
|
sEntries = cfg.getSourceEntries();
|
||||||
|
oEntries = cfg.getBuildSetting().getOutputDirectories();
|
||||||
|
|
||||||
|
checkCEntriesMatch(expectedSourceEntries, sEntries);
|
||||||
|
checkCEntriesMatch(expectedOutputEntries, oEntries);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IPathEntry[] concatEntries(IPathEntry[] entries1, IPathEntry[] entries2){
|
||||||
|
List list = new ArrayList(entries1.length + entries2.length);
|
||||||
|
list.addAll(Arrays.asList(entries1));
|
||||||
|
list.addAll(Arrays.asList(entries2));
|
||||||
|
return (IPathEntry[])list.toArray(new IPathEntry[list.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void checkCEntriesMatch(ICSettingEntry[] e1, ICSettingEntry[] e2){
|
||||||
|
if(e1.length != e2.length)
|
||||||
|
fail("entries num do not match");
|
||||||
|
|
||||||
|
Set set = new HashSet(Arrays.asList(e1));
|
||||||
|
set.removeAll(Arrays.asList(e2));
|
||||||
|
if(set.size() != 0)
|
||||||
|
fail("entries do not match");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void checkEntriesMatch(IPathEntry[] e1, IPathEntry[] e2){
|
||||||
if(e1.length != e2.length)
|
if(e1.length != e2.length)
|
||||||
fail("entries arrays have different length \ne1: " + dumpArray(e1) +"\ne2:" + dumpArray(e2) + "\n");
|
fail("entries arrays have different length \ne1: " + dumpArray(e1) +"\ne2:" + dumpArray(e2) + "\n");
|
||||||
|
|
||||||
|
@ -110,7 +230,7 @@ public class BackwardCompatibilityTests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String dumpArray(Object array[]){
|
public static String dumpArray(Object array[]){
|
||||||
if(array == null)
|
if(array == null)
|
||||||
return "null";
|
return "null";
|
||||||
|
|
||||||
|
|
|
@ -128,6 +128,8 @@ public class CDataFacroty {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setModified(CDataObject data, boolean modified){
|
public void setModified(CDataObject data, boolean modified){
|
||||||
|
if(data == null)
|
||||||
|
return;
|
||||||
switch (data.getType()) {
|
switch (data.getType()) {
|
||||||
case ICSettingBase.SETTING_CONFIGURATION:
|
case ICSettingBase.SETTING_CONFIGURATION:
|
||||||
((CDefaultConfigurationData)data).setModified(modified);
|
((CDefaultConfigurationData)data).setModified(modified);
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.settings.model.util;
|
package org.eclipse.cdt.core.settings.model.util;
|
||||||
|
|
||||||
|
import java.lang.reflect.Array;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -758,7 +759,7 @@ public class CDataUtil {
|
||||||
return adjustEntries(entries, false, null);
|
return adjustEntries(entries, false, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ICSourceEntry[] getDefaultEntries(boolean absolute, IProject project){
|
private static ICSourceEntry[] getDefaultSourceEntries(boolean absolute, IProject project){
|
||||||
ICSourceEntry entry;
|
ICSourceEntry entry;
|
||||||
if(absolute){
|
if(absolute){
|
||||||
if(project != null)
|
if(project != null)
|
||||||
|
@ -771,9 +772,29 @@ public class CDataUtil {
|
||||||
return new ICSourceEntry[]{entry};
|
return new ICSourceEntry[]{entry};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static ICOutputEntry[] getDefaultOutputEntries(boolean absolute, IProject project){
|
||||||
|
ICOutputEntry entry;
|
||||||
|
if(absolute){
|
||||||
|
if(project != null)
|
||||||
|
entry = new COutputEntry(project.getFullPath(), null, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSourceEntry.RESOLVED);
|
||||||
|
else
|
||||||
|
entry = new COutputEntry(Path.EMPTY, null, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSourceEntry.RESOLVED);
|
||||||
|
} else {
|
||||||
|
entry = new COutputEntry(Path.EMPTY, null, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSourceEntry.RESOLVED);
|
||||||
|
}
|
||||||
|
return new ICOutputEntry[]{entry};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ICOutputEntry[] adjustEntries(ICOutputEntry entries[], boolean makeAbsolute, IProject project){
|
||||||
|
if(entries == null || entries.length == 0)
|
||||||
|
return getDefaultOutputEntries(makeAbsolute, project);
|
||||||
|
|
||||||
|
return makeAbsolute ? checkMakeAbsolute(project, entries) : checkMakeRelative(project, entries);
|
||||||
|
}
|
||||||
|
|
||||||
public static ICSourceEntry[] adjustEntries(ICSourceEntry entries[], boolean makeAbsolute, IProject project){
|
public static ICSourceEntry[] adjustEntries(ICSourceEntry entries[], boolean makeAbsolute, IProject project){
|
||||||
if(entries == null)
|
if(entries == null || entries.length == 0)
|
||||||
return getDefaultEntries(makeAbsolute, project);
|
return getDefaultSourceEntries(makeAbsolute, project);
|
||||||
|
|
||||||
ICSourceEntry ei, ej;
|
ICSourceEntry ei, ej;
|
||||||
LinkedHashMap map = new LinkedHashMap();
|
LinkedHashMap map = new LinkedHashMap();
|
||||||
|
@ -837,31 +858,35 @@ public class CDataUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ICSourceEntry makeAbsolute(IProject project, ICSourceEntry entry){
|
public static ICSourceEntry makeAbsolute(IProject project, ICSourceEntry entry){
|
||||||
if(project == null)
|
return (ICSourceEntry)makeAbsolute(project, entry, true);
|
||||||
return entry;
|
|
||||||
|
|
||||||
IPath path = new Path(entry.getName());
|
|
||||||
if(path.isAbsolute())
|
|
||||||
return entry;
|
|
||||||
|
|
||||||
path = project.getFullPath().append(path);
|
|
||||||
|
|
||||||
return new CSourceEntry(path, entry.getExclusionPatterns(), entry.getFlags());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ICSourceEntry makeRelative(IProject project, ICSourceEntry entry){
|
public static ICSourceEntry makeRelative(IProject project, ICSourceEntry entry){
|
||||||
IPath path = new Path(entry.getName());
|
return (ICSourceEntry)makeRelative(project, entry, true);
|
||||||
if(!path.isAbsolute())
|
}
|
||||||
return entry;
|
|
||||||
|
|
||||||
// if(project != null){
|
public static ICSourceEntry[] makeRelative(IProject project, ICSourceEntry[] entries){
|
||||||
//
|
return (ICSourceEntry[])makeRelative(project, entries, true);
|
||||||
// IPath projPath = project.getFullPath();
|
}
|
||||||
//
|
|
||||||
// }
|
|
||||||
// if(pro)
|
|
||||||
|
|
||||||
return new CSourceEntry(path.removeFirstSegments(1).makeRelative(), entry.getExclusionPatterns(), entry.getFlags());
|
public static ICSourceEntry[] makeAbsolute(IProject project, ICSourceEntry[] entries){
|
||||||
|
return (ICSourceEntry[])makeAbsolute(project, entries, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ICOutputEntry checkMakeAbsolute(IProject project, ICOutputEntry entry){
|
||||||
|
return (ICOutputEntry)makeAbsolute(project, entry, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ICOutputEntry checkMakeRelative(IProject project, ICOutputEntry entry){
|
||||||
|
return (ICOutputEntry)makeRelative(project, entry, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ICOutputEntry[] checkMakeAbsolute(IProject project, ICOutputEntry[] entries){
|
||||||
|
return (ICOutputEntry[])makeAbsolute(project, entries, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ICOutputEntry[] checkMakeRelative(IProject project, ICOutputEntry[] entries){
|
||||||
|
return (ICOutputEntry[])makeRelative(project, entries, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Collection removePrefix(IPath prefix, Collection paths, Collection result){
|
private static Collection removePrefix(IPath prefix, Collection paths, Collection result){
|
||||||
|
@ -984,4 +1009,56 @@ public class CDataUtil {
|
||||||
set.removeAll(Arrays.asList(o2));
|
set.removeAll(Arrays.asList(o2));
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ICExclusionPatternPathEntry makeAbsolute(IProject project, ICExclusionPatternPathEntry entry, boolean force){
|
||||||
|
if(!entry.isValueWorkspacePath() && !force)
|
||||||
|
return entry;
|
||||||
|
|
||||||
|
IPath path = new Path(entry.getName());
|
||||||
|
IPath projPath = project.getFullPath();
|
||||||
|
if(!path.isAbsolute() || (force && !projPath.isPrefixOf(path))){
|
||||||
|
path = projPath.append(path).makeAbsolute();
|
||||||
|
return (ICExclusionPatternPathEntry)CDataUtil.createEntry(entry.getKind(), path.toString(), null, entry.getExclusionPatterns(), entry.getFlags());
|
||||||
|
}
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ICExclusionPatternPathEntry makeRelative(IProject project, ICExclusionPatternPathEntry entry, boolean force){
|
||||||
|
if(!entry.isValueWorkspacePath() && !force)
|
||||||
|
return entry;
|
||||||
|
|
||||||
|
IPath path = new Path(entry.getName());
|
||||||
|
IPath projPath = project.getFullPath();
|
||||||
|
|
||||||
|
if(path.isAbsolute()){
|
||||||
|
if(projPath.isPrefixOf(path))
|
||||||
|
path = path.removeFirstSegments(projPath.segmentCount()).makeRelative();
|
||||||
|
else if (force)
|
||||||
|
path = path.makeRelative();
|
||||||
|
return (ICExclusionPatternPathEntry)CDataUtil.createEntry(entry.getKind(), entry.getName(), entry.getValue(), entry.getExclusionPatterns(), entry.getFlags());
|
||||||
|
}
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ICExclusionPatternPathEntry[] makeRelative(IProject project, ICExclusionPatternPathEntry[] entries, boolean force){
|
||||||
|
if(entries == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
ICExclusionPatternPathEntry[] relEntries = (ICExclusionPatternPathEntry[])Array.newInstance(entries.getClass().getComponentType(), entries.length);
|
||||||
|
for(int i = 0; i < entries.length; i++){
|
||||||
|
relEntries[i] = makeRelative(project, entries[i], force);
|
||||||
|
}
|
||||||
|
return relEntries;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ICExclusionPatternPathEntry[] makeAbsolute(IProject project, ICExclusionPatternPathEntry[] entries, boolean force){
|
||||||
|
if(entries == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
ICExclusionPatternPathEntry[] relEntries = (ICExclusionPatternPathEntry[])Array.newInstance(entries.getClass().getComponentType(), entries.length);
|
||||||
|
for(int i = 0; i < entries.length; i++){
|
||||||
|
relEntries[i] = makeAbsolute(project, entries[i], force);
|
||||||
|
}
|
||||||
|
return relEntries;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ import org.eclipse.cdt.core.model.IIncludeFileEntry;
|
||||||
import org.eclipse.cdt.core.model.ILibraryEntry;
|
import org.eclipse.cdt.core.model.ILibraryEntry;
|
||||||
import org.eclipse.cdt.core.model.IMacroEntry;
|
import org.eclipse.cdt.core.model.IMacroEntry;
|
||||||
import org.eclipse.cdt.core.model.IMacroFileEntry;
|
import org.eclipse.cdt.core.model.IMacroFileEntry;
|
||||||
|
import org.eclipse.cdt.core.model.IOutputEntry;
|
||||||
import org.eclipse.cdt.core.model.IPathEntry;
|
import org.eclipse.cdt.core.model.IPathEntry;
|
||||||
import org.eclipse.cdt.core.model.ISourceEntry;
|
import org.eclipse.cdt.core.model.ISourceEntry;
|
||||||
import org.eclipse.cdt.core.resources.IPathEntryVariableManager;
|
import org.eclipse.cdt.core.resources.IPathEntryVariableManager;
|
||||||
|
@ -44,6 +45,7 @@ import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
|
||||||
import org.eclipse.cdt.core.settings.model.CLibraryFileEntry;
|
import org.eclipse.cdt.core.settings.model.CLibraryFileEntry;
|
||||||
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.CSourceEntry;
|
||||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICExclusionPatternPathEntry;
|
import org.eclipse.cdt.core.settings.model.ICExclusionPatternPathEntry;
|
||||||
|
@ -975,6 +977,7 @@ public class PathEntryTranslator {
|
||||||
Map nameKeyMap = getEntriesNameKeyMap(kind, true);
|
Map nameKeyMap = getEntriesNameKeyMap(kind, true);
|
||||||
for(int i = 0; i < entries.length; i++){
|
for(int i = 0; i < entries.length; i++){
|
||||||
ICExclusionPatternPathEntry entry = entries[i];
|
ICExclusionPatternPathEntry entry = entries[i];
|
||||||
|
entry = CDataUtil.makeAbsolute(fProject, entry, kind == ICSettingEntry.SOURCE_PATH);
|
||||||
EntryNameKey nameKey = new EntryNameKey(entry);
|
EntryNameKey nameKey = new EntryNameKey(entry);
|
||||||
PathEntryComposer old = (PathEntryComposer)nameKeyMap.get(nameKey);
|
PathEntryComposer old = (PathEntryComposer)nameKeyMap.get(nameKey);
|
||||||
if(old != null){
|
if(old != null){
|
||||||
|
@ -1510,6 +1513,7 @@ public class PathEntryTranslator {
|
||||||
List projList = new ArrayList();
|
List projList = new ArrayList();
|
||||||
List exportSettingsList = new ArrayList();
|
List exportSettingsList = new ArrayList();
|
||||||
ICSourceEntry srcEntries[] = null;
|
ICSourceEntry srcEntries[] = null;
|
||||||
|
ICOutputEntry outEntries[] = null;
|
||||||
// PathSettingsContainer child;
|
// PathSettingsContainer child;
|
||||||
ResolvedEntry rEntry;
|
ResolvedEntry rEntry;
|
||||||
IPath projPath;
|
IPath projPath;
|
||||||
|
@ -1525,7 +1529,7 @@ public class PathEntryTranslator {
|
||||||
srcList.add(rEntry.fEntry);
|
srcList.add(rEntry.fEntry);
|
||||||
break;
|
break;
|
||||||
case IPathEntry.CDT_OUTPUT:
|
case IPathEntry.CDT_OUTPUT:
|
||||||
outList.add(rEntry);
|
outList.add(rEntry.fEntry);
|
||||||
break;
|
break;
|
||||||
case IPathEntry.CDT_PROJECT:
|
case IPathEntry.CDT_PROJECT:
|
||||||
projList.add(rEntry);
|
projList.add(rEntry);
|
||||||
|
@ -1551,6 +1555,11 @@ public class PathEntryTranslator {
|
||||||
if(srcList.size() != 0){
|
if(srcList.size() != 0){
|
||||||
srcEntries = toCSourceEntries(srcList);
|
srcEntries = toCSourceEntries(srcList);
|
||||||
} else {
|
} else {
|
||||||
|
// srcPaths = new IPath[]{new Path("")}; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
if(outList.size() != 0){
|
||||||
|
outEntries = toCOutputEntries(outList);
|
||||||
|
} else {
|
||||||
// srcPaths = new IPath[]{new Path("")}; //$NON-NLS-1$
|
// srcPaths = new IPath[]{new Path("")}; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1575,6 +1584,7 @@ public class PathEntryTranslator {
|
||||||
//applying settings
|
//applying settings
|
||||||
|
|
||||||
//applySourcePaths(srcPaths, op);
|
//applySourcePaths(srcPaths, op);
|
||||||
|
applyOutputEntries(outEntries, op);
|
||||||
applySourceEntries(srcEntries, op);
|
applySourceEntries(srcEntries, op);
|
||||||
applyLangSettings(cr, op);
|
applyLangSettings(cr, op);
|
||||||
|
|
||||||
|
@ -1611,6 +1621,15 @@ public class PathEntryTranslator {
|
||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static ICOutputEntry[] toCOutputEntries(List list){
|
||||||
|
ICOutputEntry[] entries = new ICOutputEntry[list.size()];
|
||||||
|
for(int i = 0; i < entries.length; i++){
|
||||||
|
entries[i] = toCOutputEntry((IOutputEntry)list.get(i), true);
|
||||||
|
}
|
||||||
|
return entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private static ICSourceEntry toCSourceEntry(ISourceEntry entry, boolean makeProjRelative){
|
private static ICSourceEntry toCSourceEntry(ISourceEntry entry, boolean makeProjRelative){
|
||||||
IPath path = entry.getPath();
|
IPath path = entry.getPath();
|
||||||
if(makeProjRelative && path.isAbsolute())
|
if(makeProjRelative && path.isAbsolute())
|
||||||
|
@ -1621,6 +1640,16 @@ public class PathEntryTranslator {
|
||||||
| ICSourceEntry.RESOLVED);
|
| ICSourceEntry.RESOLVED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static ICOutputEntry toCOutputEntry(IOutputEntry entry, boolean makeProjRelative){
|
||||||
|
IPath path = entry.getPath();
|
||||||
|
if(makeProjRelative && path.isAbsolute())
|
||||||
|
path = path.removeFirstSegments(1);
|
||||||
|
return new COutputEntry(path,
|
||||||
|
entry.getExclusionPatterns(),
|
||||||
|
ICSettingEntry.VALUE_WORKSPACE_PATH
|
||||||
|
| ICSourceEntry.RESOLVED);
|
||||||
|
}
|
||||||
|
|
||||||
private static ICSettingEntry[] replaceUserEntries(ICSettingEntry[] oldEntries, ICSettingEntry[] newUsrEntries){
|
private static ICSettingEntry[] replaceUserEntries(ICSettingEntry[] oldEntries, ICSettingEntry[] newUsrEntries){
|
||||||
Set set = new LinkedHashSet();
|
Set set = new LinkedHashSet();
|
||||||
Class componentType = null;
|
Class componentType = null;
|
||||||
|
@ -1655,23 +1684,23 @@ public class PathEntryTranslator {
|
||||||
|
|
||||||
private void applySourceEntries(ICSourceEntry entries[], int op){
|
private void applySourceEntries(ICSourceEntry entries[], int op){
|
||||||
ICSourceEntry[] oldEntries = fCfgData.getSourceEntries();
|
ICSourceEntry[] oldEntries = fCfgData.getSourceEntries();
|
||||||
|
oldEntries = (ICSourceEntry[])CDataUtil.makeRelative(fProject, oldEntries, true);
|
||||||
|
entries = (ICSourceEntry[])CDataUtil.makeRelative(fProject, entries, true);
|
||||||
entries = (ICSourceEntry[])replaceUserEntries(oldEntries, entries);
|
entries = (ICSourceEntry[])replaceUserEntries(oldEntries, entries);
|
||||||
|
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case OP_ADD:
|
case OP_ADD:
|
||||||
if(entries != null && entries.length != 0){
|
if(entries != null && entries.length != 0){
|
||||||
ICSourceEntry curEntries[] = fCfgData.getSourceEntries();
|
|
||||||
Set set = new LinkedHashSet();
|
Set set = new LinkedHashSet();
|
||||||
set.addAll(Arrays.asList(curEntries));
|
set.addAll(Arrays.asList(oldEntries));
|
||||||
set.addAll(Arrays.asList(entries));
|
set.addAll(Arrays.asList(entries));
|
||||||
fCfgData.setSourceEntries((ICSourceEntry[])set.toArray(new ICSourceEntry[set.size()]));
|
fCfgData.setSourceEntries((ICSourceEntry[])set.toArray(new ICSourceEntry[set.size()]));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OP_REMOVE:
|
case OP_REMOVE:
|
||||||
if(entries != null && entries.length != 0){
|
if(entries != null && entries.length != 0){
|
||||||
ICSourceEntry curEntries[] = fCfgData.getSourceEntries();
|
|
||||||
Set set = new HashSet();
|
Set set = new HashSet();
|
||||||
set.addAll(Arrays.asList(curEntries));
|
set.addAll(Arrays.asList(oldEntries));
|
||||||
set.removeAll(Arrays.asList(entries));
|
set.removeAll(Arrays.asList(entries));
|
||||||
fCfgData.setSourceEntries((ICSourceEntry[])set.toArray(new ICSourceEntry[set.size()]));
|
fCfgData.setSourceEntries((ICSourceEntry[])set.toArray(new ICSourceEntry[set.size()]));
|
||||||
}
|
}
|
||||||
|
@ -1687,6 +1716,46 @@ public class PathEntryTranslator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void applyOutputEntries(ICOutputEntry entries[], int op){
|
||||||
|
CBuildData bData = fCfgData.getBuildData();
|
||||||
|
if(bData == null){
|
||||||
|
CCorePlugin.log("PathEntryTranslator: failed to apply output entries: Build Data is null, ignoring..");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ICOutputEntry[] oldEntries = bData.getOutputDirectories();
|
||||||
|
oldEntries = (ICOutputEntry[])CDataUtil.makeRelative(fProject, oldEntries, false);
|
||||||
|
entries = (ICOutputEntry[])CDataUtil.makeRelative(fProject, entries, false);
|
||||||
|
entries = (ICOutputEntry[])replaceUserEntries(oldEntries, entries);
|
||||||
|
|
||||||
|
switch (op) {
|
||||||
|
case OP_ADD:
|
||||||
|
if(entries != null && entries.length != 0){
|
||||||
|
Set set = new LinkedHashSet();
|
||||||
|
set.addAll(Arrays.asList(oldEntries));
|
||||||
|
set.addAll(Arrays.asList(entries));
|
||||||
|
bData.setOutputDirectories((ICOutputEntry[])set.toArray(new ICOutputEntry[set.size()]));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case OP_REMOVE:
|
||||||
|
if(entries != null && entries.length != 0){
|
||||||
|
Set set = new HashSet();
|
||||||
|
set.addAll(Arrays.asList(oldEntries));
|
||||||
|
set.removeAll(Arrays.asList(entries));
|
||||||
|
bData.setOutputDirectories((ICOutputEntry[])set.toArray(new ICOutputEntry[set.size()]));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case OP_REPLACE:
|
||||||
|
default:
|
||||||
|
if(entries != null){
|
||||||
|
bData.setOutputDirectories(entries);
|
||||||
|
} else {
|
||||||
|
bData.setOutputDirectories(new ICOutputEntry[0]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void applyLangSettings(PathSettingsContainer cr, int op){
|
private void applyLangSettings(PathSettingsContainer cr, int op){
|
||||||
PathSettingsContainer crs[] = cr.getChildren(true);
|
PathSettingsContainer crs[] = cr.getChildren(true);
|
||||||
for(int i = 0; i < crs.length; i++){
|
for(int i = 0; i < crs.length; i++){
|
||||||
|
@ -2492,7 +2561,4 @@ public class PathEntryTranslator {
|
||||||
PathEntryCollector cr = collectEntries(project, cfg);
|
PathEntryCollector cr = collectEntries(project, cfg);
|
||||||
return cr.getEntries(flags, cfg);
|
return cr.getEntries(flags, cfg);
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// private
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class ThreadLocalMap {
|
||||||
|
private ThreadLocal fLocal = new ThreadLocal();
|
||||||
|
|
||||||
|
public Object get(Object key){
|
||||||
|
Map map = getMap(false);
|
||||||
|
return map != null ? map.get(key) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set(Object key, Object value){
|
||||||
|
if(value == null)
|
||||||
|
clear(key);
|
||||||
|
else {
|
||||||
|
Map map = getMap(true);
|
||||||
|
map.put(key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear(Object key){
|
||||||
|
Map map = getMap(false);
|
||||||
|
if(map != null){
|
||||||
|
map.remove(key);
|
||||||
|
if(map == null)
|
||||||
|
fLocal.set(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map getMap(boolean create){
|
||||||
|
Map map = (Map)fLocal.get();
|
||||||
|
if(map == null && create){
|
||||||
|
map = new HashMap();
|
||||||
|
fLocal.set(map);
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
}
|
|
@ -53,6 +53,7 @@ import org.eclipse.cdt.core.resources.IPathEntryStoreListener;
|
||||||
import org.eclipse.cdt.core.resources.PathEntryStoreChangedEvent;
|
import org.eclipse.cdt.core.resources.PathEntryStoreChangedEvent;
|
||||||
import org.eclipse.cdt.core.settings.model.util.PathEntryResolveInfo;
|
import org.eclipse.cdt.core.settings.model.util.PathEntryResolveInfo;
|
||||||
import org.eclipse.cdt.core.settings.model.util.PathEntryResolveInfoElement;
|
import org.eclipse.cdt.core.settings.model.util.PathEntryResolveInfoElement;
|
||||||
|
import org.eclipse.cdt.core.settings.model.util.ThreadLocalMap;
|
||||||
import org.eclipse.cdt.internal.core.settings.model.AbstractCExtensionProxy;
|
import org.eclipse.cdt.internal.core.settings.model.AbstractCExtensionProxy;
|
||||||
import org.eclipse.cdt.internal.core.settings.model.ConfigBasedPathEntryStore;
|
import org.eclipse.cdt.internal.core.settings.model.ConfigBasedPathEntryStore;
|
||||||
import org.eclipse.core.resources.IMarker;
|
import org.eclipse.core.resources.IMarker;
|
||||||
|
@ -112,6 +113,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
// Synchronized the access of the cache entries.
|
// Synchronized the access of the cache entries.
|
||||||
protected Map resolvedMap = new Hashtable();
|
protected Map resolvedMap = new Hashtable();
|
||||||
private Map resolvedInfoMap = new Hashtable();
|
private Map resolvedInfoMap = new Hashtable();
|
||||||
|
private ThreadLocalMap resolveInfoValidState = new ThreadLocalMap();
|
||||||
|
|
||||||
// Accessing the map is synch with the class
|
// Accessing the map is synch with the class
|
||||||
private Map storeMap = new HashMap();
|
private Map storeMap = new HashMap();
|
||||||
|
@ -415,10 +417,23 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
if(info == null){
|
if(info == null){
|
||||||
getResolvedPathEntries(cproject);
|
getResolvedPathEntries(cproject);
|
||||||
info = (PathEntryResolveInfo)resolvedInfoMap.get(cproject);
|
info = (PathEntryResolveInfo)resolvedInfoMap.get(cproject);
|
||||||
|
} else if(!getResolveInfoValidState(cproject)){
|
||||||
|
Object[] resolved = getResolvedPathEntries(cproject, false, false);
|
||||||
|
if(resolved != null)
|
||||||
|
info = (PathEntryResolveInfo)resolved[1];
|
||||||
}
|
}
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setResolveInfoValidState(ICProject cproject, boolean valid){
|
||||||
|
Object v = valid ? null : Boolean.FALSE;
|
||||||
|
resolveInfoValidState.set(cproject, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean getResolveInfoValidState(ICProject cproject){
|
||||||
|
return resolveInfoValidState.get(cproject) == null;
|
||||||
|
}
|
||||||
|
|
||||||
protected IPathEntry[] removeCachedResolvedPathEntries(ICProject cproject) {
|
protected IPathEntry[] removeCachedResolvedPathEntries(ICProject cproject) {
|
||||||
ArrayList resolvedListEntries = (ArrayList)resolvedMap.remove(cproject);
|
ArrayList resolvedListEntries = (ArrayList)resolvedMap.remove(cproject);
|
||||||
resolvedInfoMap.remove(cproject);
|
resolvedInfoMap.remove(cproject);
|
||||||
|
@ -485,7 +500,19 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
* @throws CModelException
|
* @throws CModelException
|
||||||
*/
|
*/
|
||||||
private ArrayList getResolvedPathEntries(ICProject cproject, boolean generateMarkers) throws CModelException {
|
private ArrayList getResolvedPathEntries(ICProject cproject, boolean generateMarkers) throws CModelException {
|
||||||
ArrayList resolvedEntries = (ArrayList)resolvedMap.get(cproject);
|
Object[] result = getResolvedPathEntries(cproject, generateMarkers, true);
|
||||||
|
if(result != null)
|
||||||
|
return (ArrayList)result[0];
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object[] getResolvedPathEntries(ICProject cproject, boolean generateMarkers, boolean useCache) throws CModelException {
|
||||||
|
ArrayList resolvedEntries = null;
|
||||||
|
PathEntryResolveInfo rInfo = null;
|
||||||
|
if(useCache){
|
||||||
|
resolvedEntries = (ArrayList)resolvedMap.get(cproject);
|
||||||
|
rInfo = (PathEntryResolveInfo)resolvedInfoMap.get(cproject);
|
||||||
|
}
|
||||||
if (resolvedEntries == null) {
|
if (resolvedEntries == null) {
|
||||||
List resolveInfoList = new ArrayList();
|
List resolveInfoList = new ArrayList();
|
||||||
IPath projectPath = cproject.getPath();
|
IPath projectPath = cproject.getPath();
|
||||||
|
@ -561,10 +588,13 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
resolvedEntries.removeAll(dups);
|
resolvedEntries.removeAll(dups);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rInfo = new PathEntryResolveInfo(resolveInfoList);
|
||||||
|
if(useCache){
|
||||||
resolvedMap.put(cproject, resolvedEntries);
|
resolvedMap.put(cproject, resolvedEntries);
|
||||||
resolvedInfoMap.put(cproject, new PathEntryResolveInfo(resolveInfoList));
|
resolvedInfoMap.put(cproject, rInfo);
|
||||||
}
|
}
|
||||||
return resolvedEntries;
|
}
|
||||||
|
return new Object[]{resolvedEntries, rInfo};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRawPathEntries(ICProject cproject, IPathEntry[] newEntries, IProgressMonitor monitor) throws CModelException {
|
public void setRawPathEntries(ICProject cproject, IPathEntry[] newEntries, IProgressMonitor monitor) throws CModelException {
|
||||||
|
@ -944,7 +974,9 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
list.toArray(newRawEntries);
|
list.toArray(newRawEntries);
|
||||||
IProject project = cproject.getProject();
|
IProject project = cproject.getProject();
|
||||||
IPathEntryStore store = getPathEntryStore(project, true);
|
IPathEntryStore store = getPathEntryStore(project, true);
|
||||||
|
setResolveInfoValidState(cproject, false);
|
||||||
store.setRawPathEntries(newRawEntries);
|
store.setRawPathEntries(newRawEntries);
|
||||||
|
setResolveInfoValidState(cproject, true);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
throw new CModelException(e);
|
throw new CModelException(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import org.eclipse.cdt.core.settings.model.ICOutputEntry;
|
||||||
import org.eclipse.cdt.core.settings.model.ICSettingBase;
|
import org.eclipse.cdt.core.settings.model.ICSettingBase;
|
||||||
import org.eclipse.cdt.core.settings.model.extension.CBuildData;
|
import org.eclipse.cdt.core.settings.model.extension.CBuildData;
|
||||||
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
|
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
public class CBuildSetting extends CDataProxy implements ICBuildSetting {
|
public class CBuildSetting extends CDataProxy implements ICBuildSetting {
|
||||||
|
@ -40,7 +41,10 @@ public class CBuildSetting extends CDataProxy implements ICBuildSetting {
|
||||||
|
|
||||||
public ICOutputEntry[] getOutputDirectories() {
|
public ICOutputEntry[] getOutputDirectories() {
|
||||||
CBuildData data = getBuildData(false);
|
CBuildData data = getBuildData(false);
|
||||||
return data.getOutputDirectories();
|
ICOutputEntry[] entries = data.getOutputDirectories();
|
||||||
|
IProject project = getProject();
|
||||||
|
entries = CDataUtil.adjustEntries(entries, true, project);
|
||||||
|
return entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBuilderCWD(IPath path) {
|
public void setBuilderCWD(IPath path) {
|
||||||
|
@ -55,6 +59,11 @@ public class CBuildSetting extends CDataProxy implements ICBuildSetting {
|
||||||
|
|
||||||
public void setOutputDirectories(ICOutputEntry[] entries) {
|
public void setOutputDirectories(ICOutputEntry[] entries) {
|
||||||
CBuildData data = getBuildData(true);
|
CBuildData data = getBuildData(true);
|
||||||
|
IProject project = getProject();
|
||||||
|
if(entries != null){
|
||||||
|
entries = CDataUtil.adjustEntries(entries, false, project);
|
||||||
|
}
|
||||||
|
|
||||||
data.setOutputDirectories(entries);
|
data.setOutputDirectories(entries);
|
||||||
if(entries == null){
|
if(entries == null){
|
||||||
CExternalSettingsManager.getInstance().restoreOutputEntryDefaults(getConfiguration());
|
CExternalSettingsManager.getInstance().restoreOutputEntryDefaults(getConfiguration());
|
||||||
|
|
|
@ -20,6 +20,7 @@ import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultBuildData;
|
||||||
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
|
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
|
||||||
import org.eclipse.cdt.internal.core.envvar.EnvironmentVariableManager;
|
import org.eclipse.cdt.internal.core.envvar.EnvironmentVariableManager;
|
||||||
import org.eclipse.cdt.utils.envvar.StorableEnvironment;
|
import org.eclipse.cdt.utils.envvar.StorableEnvironment;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
public class CBuildSettingCache extends CDefaultBuildData implements
|
public class CBuildSettingCache extends CDefaultBuildData implements
|
||||||
|
@ -27,6 +28,7 @@ public class CBuildSettingCache extends CDefaultBuildData implements
|
||||||
private CConfigurationDescriptionCache fCfgCache;
|
private CConfigurationDescriptionCache fCfgCache;
|
||||||
private StorableEnvironment fEnvironment;
|
private StorableEnvironment fEnvironment;
|
||||||
private StorableEnvironment fResolvedEnvironment;
|
private StorableEnvironment fResolvedEnvironment;
|
||||||
|
private ICOutputEntry[] fProjOutputEntries;
|
||||||
private ICOutputEntry[] fResolvedOutputEntries;
|
private ICOutputEntry[] fResolvedOutputEntries;
|
||||||
|
|
||||||
CBuildSettingCache(CBuildData base, CConfigurationDescriptionCache cfgCache){
|
CBuildSettingCache(CBuildData base, CConfigurationDescriptionCache cfgCache){
|
||||||
|
@ -97,4 +99,22 @@ public class CBuildSettingCache extends CDefaultBuildData implements
|
||||||
return fResolvedOutputEntries;
|
return fResolvedOutputEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ICOutputEntry[] getOutputDirectories() {
|
||||||
|
initOutputEntries();
|
||||||
|
return (ICOutputEntry[])fProjOutputEntries.clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initOutputEntries(){
|
||||||
|
if(fProjOutputEntries == null){
|
||||||
|
IProject project = getProject();
|
||||||
|
fProjOutputEntries = CDataUtil.adjustEntries(fOutputEntries, true, project);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private IProject getProject(){
|
||||||
|
ICConfigurationDescription cfg = getConfiguration();
|
||||||
|
return cfg.isPreferenceConfiguration() ? null : cfg.getProjectDescription().getProject();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -476,130 +476,15 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC
|
||||||
public void setSourceEntries(ICSourceEntry[] entries) throws CoreException {
|
public void setSourceEntries(ICSourceEntry[] entries) throws CoreException {
|
||||||
CConfigurationData data = getConfigurationData(true);
|
CConfigurationData data = getConfigurationData(true);
|
||||||
IProject project = fIsPreference ? null : getProjectDescription().getProject();
|
IProject project = fIsPreference ? null : getProjectDescription().getProject();
|
||||||
boolean restoreDefault = false;
|
if(entries != null){
|
||||||
if(entries == null)
|
|
||||||
restoreDefault = true;
|
|
||||||
else if(entries.length == 0)
|
|
||||||
entries = null;
|
|
||||||
entries = CDataUtil.adjustEntries(entries, false, project);
|
entries = CDataUtil.adjustEntries(entries, false, project);
|
||||||
|
}
|
||||||
|
|
||||||
data.setSourceEntries(entries);
|
data.setSourceEntries(entries);
|
||||||
|
|
||||||
if(restoreDefault){
|
if(entries == null){
|
||||||
CExternalSettingsManager.getInstance().restoreSourceEntryDefaults(this);
|
CExternalSettingsManager.getInstance().restoreSourceEntryDefaults(this);
|
||||||
}
|
}
|
||||||
// ICSourceEntry entry;
|
|
||||||
// IPath entryPath;
|
|
||||||
// IPath paths[];
|
|
||||||
// PathSettingsContainer cr = PathSettingsContainer.createRootContainer();
|
|
||||||
// cr.setValue(Boolean.valueOf(getRootFolderDescription().isExcluded()));
|
|
||||||
// Set srcPathSet = new HashSet();
|
|
||||||
// IProject project = fIsPreference ? null : getProjectDescription().getProject();
|
|
||||||
// IPath projPath = project != null ? project.getFullPath() : null;
|
|
||||||
//// Map exclusionMap = new HashMap();
|
|
||||||
//
|
|
||||||
//// HashSet pathSet = new HashSet();
|
|
||||||
//
|
|
||||||
// if(entries == null){
|
|
||||||
// IPath pasePath = projPath != null ? projPath : Path.EMPTY;
|
|
||||||
// entries = new ICSourceEntry[]{new CSourceEntry(pasePath, null, ICLanguageSettingEntry.RESOLVED | ICLanguageSettingEntry.VALUE_WORKSPACE_PATH)};
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// for(int i = 0 ; i < entries.length; i++){
|
|
||||||
// entry = entries[i];
|
|
||||||
// entryPath = entry.getFullPath();
|
|
||||||
// if(projPath != null){
|
|
||||||
// if(projPath.isPrefixOf(entryPath)){
|
|
||||||
// entryPath = entryPath.removeFirstSegments(projPath.segmentCount());
|
|
||||||
// } else {
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//// else {
|
|
||||||
//// if(entryPath.segmentCount() > 0)
|
|
||||||
//// entryPath = entryPath.removeFirstSegments(1);
|
|
||||||
//// else
|
|
||||||
//// continue;
|
|
||||||
//// }
|
|
||||||
// if(srcPathSet.add(entryPath)){
|
|
||||||
// // exclusionMap.put(entryPath, Boolean.TRUE);
|
|
||||||
// PathSettingsContainer entryCr = cr.getChildContainer(entryPath, true, true);
|
|
||||||
// entryCr.setValue(Boolean.TRUE);
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// paths = entry.getExclusionPatterns();
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// for(int j = 0; j < paths.length; j++){
|
|
||||||
// IPath path = paths[j];
|
|
||||||
// PathSettingsContainer exclusion = entryCr.getChildContainer(path, true, true);
|
|
||||||
// if(exclusion.getValue() == null)
|
|
||||||
// exclusion.setValue(Boolean.FALSE);
|
|
||||||
// // if(null == exclusionMap.get(path))
|
|
||||||
// // exclusionMap.put(path, Boolean.FALSE);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// CConfigurationData data = getConfigurationData(true);
|
|
||||||
// data.setSourcePaths((IPath[])srcPathSet.toArray(new IPath[srcPathSet.size()]));
|
|
||||||
// ICResourceDescription rcDess[] = getResourceDescriptions();
|
|
||||||
// ICResourceDescription rcDes;
|
|
||||||
// Set pathSet = new HashSet();
|
|
||||||
//
|
|
||||||
// for(int i = 0; i < rcDess.length; i++){
|
|
||||||
// rcDes = rcDess[i];
|
|
||||||
// IPath path = rcDes.getPath();
|
|
||||||
// pathSet.add(path);
|
|
||||||
//// Boolean b = (Boolean)exclusionMap.remove(path);
|
|
||||||
// Boolean b = (Boolean)cr.getChildContainer(path, false, false).getValue();
|
|
||||||
// assert (b != null);
|
|
||||||
// if(Boolean.TRUE == b) {
|
|
||||||
// if(rcDes.isExcluded())
|
|
||||||
// rcDes.setExcluded(false);
|
|
||||||
// } else {
|
|
||||||
// if(/*(rcDes.getType() == ICSettingBase.SETTING_FILE
|
|
||||||
// || !((ICFolderDescription)rcDes).isRoot())
|
|
||||||
// &&*/ !rcDes.isExcluded())
|
|
||||||
// rcDes.setExcluded(true);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// PathSettingsContainer crs[] = cr.getChildren(true);
|
|
||||||
// for(int i= 0; i < crs.length; i++){
|
|
||||||
// PathSettingsContainer c = crs[i];
|
|
||||||
// IPath path = c.getPath();
|
|
||||||
// if(!pathSet.remove(path)){
|
|
||||||
// Boolean b = (Boolean)c.getValue();
|
|
||||||
// assert (b != null);
|
|
||||||
// ICResourceDescription base = getResourceDescription(path, false);
|
|
||||||
// if(b == Boolean.TRUE){
|
|
||||||
// if(base.isExcluded()){
|
|
||||||
// ICResourceDescription newDes = createResourceDescription(path, base);
|
|
||||||
// if(newDes == null){
|
|
||||||
// ICResourceDescription fo = getResourceDescription(path, false);
|
|
||||||
// if(fo.getType() == ICSettingBase.SETTING_FILE){
|
|
||||||
// fo = getResourceDescription(path.removeLastSegments(1), false);
|
|
||||||
// }
|
|
||||||
// newDes = createFolderDescription(path, (ICFolderDescription)fo);
|
|
||||||
// }
|
|
||||||
// newDes.setExcluded(false);
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// if(!base.isExcluded()){
|
|
||||||
// ICResourceDescription newDes = createResourceDescription(path, base);
|
|
||||||
// if(newDes == null){
|
|
||||||
// ICResourceDescription fo = getResourceDescription(path, false);
|
|
||||||
// if(fo.getType() == ICSettingBase.SETTING_FILE){
|
|
||||||
// fo = getResourceDescription(path.removeLastSegments(1), false);
|
|
||||||
// }
|
|
||||||
// newDes = createFolderDescription(path, (ICFolderDescription)fo);
|
|
||||||
// }
|
|
||||||
// newDes.setExcluded(true);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// private ICResourceDescription createResourceDescription(IPath path, ICResourceDescription base){
|
// private ICResourceDescription createResourceDescription(IPath path, ICResourceDescription base){
|
||||||
|
|
|
@ -11,9 +11,11 @@
|
||||||
package org.eclipse.cdt.internal.core.settings.model;
|
package org.eclipse.cdt.internal.core.settings.model;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||||
|
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||||
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.extension.CDataObject;
|
import org.eclipse.cdt.core.settings.model.extension.CDataObject;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
|
||||||
public abstract class CDataProxy implements ICSettingObject {
|
public abstract class CDataProxy implements ICSettingObject {
|
||||||
protected ICDataProxyContainer fParent;
|
protected ICDataProxyContainer fParent;
|
||||||
|
@ -152,4 +154,16 @@ public abstract class CDataProxy implements ICSettingObject {
|
||||||
public boolean isReadOnly() {
|
public boolean isReadOnly() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected IProject getProject(){
|
||||||
|
ICConfigurationDescription cfg = getConfiguration();
|
||||||
|
if(cfg == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
ICProjectDescription projDes = cfg.getProjectDescription();
|
||||||
|
if(projDes == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return projDes.getProject();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,10 +91,6 @@ public class CLanguageSetting extends CDataProxy implements
|
||||||
return (getSupportedEntryKinds() & kind) == kind;
|
return (getSupportedEntryKinds() & kind) == kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IProject getProject(){
|
|
||||||
return getConfiguration().getProjectDescription().getProject();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* public String[] getHeaderExtensions() {
|
/* public String[] getHeaderExtensions() {
|
||||||
CLanguageData data = getCLanguageData(false);
|
CLanguageData data = getCLanguageData(false);
|
||||||
IContentType type = data.getHeaderContentType();
|
IContentType type = data.getHeaderContentType();
|
||||||
|
|
|
@ -216,6 +216,7 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
cache.applyData(factory);
|
cache.applyData(factory);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
|
e.printStackTrace();
|
||||||
iter.remove();
|
iter.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -422,7 +422,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
|
||||||
|
|
||||||
des = getDescriptionApplying(project);
|
des = getDescriptionApplying(project);
|
||||||
|
|
||||||
if(des == null)
|
if(des == null && project.isOpen())
|
||||||
des = getLoaddedDescription(project);
|
des = getLoaddedDescription(project);
|
||||||
|
|
||||||
if(des == null)
|
if(des == null)
|
||||||
|
@ -892,10 +892,15 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
|
||||||
if(!overwriteIfExists && fDescriptionMap.get(project) != null)
|
if(!overwriteIfExists && fDescriptionMap.get(project) != null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(des != null)
|
if(des != null){
|
||||||
|
if(project.exists() && project.isOpen()){
|
||||||
fDescriptionMap.put(project, des);
|
fDescriptionMap.put(project, des);
|
||||||
else
|
} else {
|
||||||
|
CCorePlugin.log("attempt to set description for the non-openned project");
|
||||||
|
}
|
||||||
|
}else {
|
||||||
fDescriptionMap.remove(project);
|
fDescriptionMap.remove(project);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
//// try {
|
//// try {
|
||||||
|
@ -2527,7 +2532,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
|
||||||
// }
|
// }
|
||||||
ICConfigurationDescription oldIndexCfg = oldDes.getDefaultSettingConfiguration();
|
ICConfigurationDescription oldIndexCfg = oldDes.getDefaultSettingConfiguration();
|
||||||
ICDescriptionDelta indexDelta;
|
ICDescriptionDelta indexDelta;
|
||||||
if(oldIndexCfg.getId().equals(indexCfg.getId())){
|
if(oldIndexCfg != null && oldIndexCfg.getId().equals(indexCfg.getId())){
|
||||||
indexDelta = findDelta(indexCfg.getId(), projDesDelta);
|
indexDelta = findDelta(indexCfg.getId(), projDesDelta);
|
||||||
} else {
|
} else {
|
||||||
indexDelta = createDelta(indexCfg, oldIndexCfg);
|
indexDelta = createDelta(indexCfg, oldIndexCfg);
|
||||||
|
|
|
@ -235,9 +235,13 @@ public class PathEntryConfigurationDataProvider extends
|
||||||
IProgressMonitor monitor)
|
IProgressMonitor monitor)
|
||||||
throws CoreException {
|
throws CoreException {
|
||||||
//TODO: check external/reference info here as well.
|
//TODO: check external/reference info here as well.
|
||||||
if(!fFactory.isModified(base))
|
if(!fFactory.isModified(base)){
|
||||||
|
try {
|
||||||
|
return createData(des);
|
||||||
|
} catch (Exception e){
|
||||||
|
}
|
||||||
return base;
|
return base;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
IProject project = des.getProjectDescription().getProject();
|
IProject project = des.getProjectDescription().getProject();
|
||||||
|
@ -250,7 +254,7 @@ public class PathEntryConfigurationDataProvider extends
|
||||||
List list = new ArrayList();
|
List list = new ArrayList();
|
||||||
list.addAll(Arrays.asList(entries));
|
list.addAll(Arrays.asList(entries));
|
||||||
for(int i = 0; i < curRawEntries.length; i++){
|
for(int i = 0; i < curRawEntries.length; i++){
|
||||||
if(curRawEntries[i].getEntryKind() == IPathEntry.CDT_CONTAINER){
|
if(curRawEntries[i].getEntryKind() != IPathEntry.CDT_CONTAINER){
|
||||||
list.add(curRawEntries[i]);
|
list.add(curRawEntries[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue