Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikhail Sennikovsky2007-11-04 06:50:25 +0000
committerMikhail Sennikovsky2007-11-04 06:50:25 +0000
commit72767211236dc7199a3c061936f9212e650855ad (patch)
treeef8e6b96d3228978f81a5dc30e6116f5df27c987
parentdb41842f235322f1a6b4a336f9894ea49491a829 (diff)
downloadorg.eclipse.cdt-72767211236dc7199a3c061936f9212e650855ad.tar.gz
org.eclipse.cdt-72767211236dc7199a3c061936f9212e650855ad.tar.xz
org.eclipse.cdt-72767211236dc7199a3c061936f9212e650855ad.zip
Tool-chain modification status calculation enhancement
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml377
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ToolChainModificationTests.java351
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/META-INF/MANIFEST.MF1
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/plugin.xml7
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/schema/tcModificationInfo.exsd256
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java65
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java26
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java29
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/FolderInfo.java32
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/IRealBuildObjectAssociation.java36
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputType.java6
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceInfo.java20
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceInfoContainer.java20
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java41
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java46
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChainModificationHelper.java295
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/CollectionMap.java289
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ConfigurationModification.java201
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ConflictSet.java188
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/DbgTcmUtil.java102
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/FileInfoModification.java80
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/FolderInfoModification.java415
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/HashSetMap.java26
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/IObjectSet.java31
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/LinkedHashSetMap.java27
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ListMap.java290
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/Messages.java22
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ObjectSet.java75
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ObjectSetList.java30
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ObjectTypeBasedStorage.java86
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/PathComparator.java119
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/PathTreeSetMap.java25
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/PerTypeMapStorage.java33
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/PerTypeSetStorage.java34
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/TcModificationUtil.java494
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ToolChainModificationManager.java241
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ToolChainModificationMessages.properties7
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ToolListModification.java624
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/extension/ConflictDefinition.java24
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/extension/ConflictDefinitionElement.java23
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/extension/MatchObjectElement.java275
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/extension/MatchObjectList.java31
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/extension/ObjectSetListBasedDefinition.java29
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/extension/RulesManager.java294
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/CompatibilityStatus.java61
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IApplicableModification.java22
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IConfigurationModification.java54
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IConflict.java28
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IFileInfoModification.java15
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IFolderInfoModification.java52
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IModification.java17
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IModificationOperation.java33
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IToolChainModificationManager.java40
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IToolListModification.java63
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IToolModification.java58
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildListComparator.java27
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolChainEditTab.java380
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolSelectionDialog.java260
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/messages.properties14
59 files changed, 6413 insertions, 434 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml b/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml
index a76365be04c..ff1a2c230b4 100644
--- a/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml
+++ b/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml
@@ -6545,6 +6545,7 @@
<tool
id="lv.tests.tool.base"
isAbstract="false"
+ isSystem="true"
name="lv.tests tool">
<option
name="List Option in Top"
@@ -8806,7 +8807,379 @@
</configuration>
</projectType>
+ <!-- tcModificationInfo tests -->
+ <toolChain id="tcm.tc1" name="tcm.tc1" isSystem="true">
+ <builder id="tcm.b1" name="tcm.b1">
+ </builder>
+ <tool id="tcm.t1" name="tcm.t1">
+ <supportedProperties>
+ <property id="org.eclipse.cdt.build.core.buildArtefactType">
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.exe"/>
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </property>
+ </supportedProperties>
+ <option id="tcm.o1"/>
+ <inputType id="tcm.it.1" sources="tcmfoo"/>
+ </tool>
+ <tool id="tcm.t2" name="tcm.t2">
+ <option id="tcm.o2"/>
+ <inputType id="tcm.it.2" sources="tcmbar"/>
+ </tool>
+ </toolChain>
+
+ <toolChain id="tcm.tc2" name="tcm.tc2" isSystem="true">
+ <builder id="tcm.tc2.b1" name="tcm.tc2.b1">
+ </builder>
+ <tool id="tcm.tc2.t1" name="tcm.tc2.t1">
+ <supportedProperties>
+ <property id="org.eclipse.cdt.build.core.buildArtefactType">
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.exe"/>
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </property>
+ </supportedProperties>
+ <option id="tcm.tc2.o1"/>
+ <inputType id="tcm.it.3" sources="tcmfoo"/>
+ </tool>
+ <tool id="tcm.tc2.t2" name="tcm.tc2.t2">
+ <option id="tcm.tc2.o2"/>
+ <inputType id="tcm.it.4" sources="tcmbar"/>
+ </tool>
+ </toolChain>
+
+ <toolChain id="tcm.tc3" name="tcm.tc3" isSystem="true">
+ <builder id="tcm.tc3.b1" name="tcm.tc3.b1">
+ </builder>
+ <tool id="tcm.tc3.t1" name="tcm.tc3.t1">
+ <supportedProperties>
+ <property id="org.eclipse.cdt.build.core.buildArtefactType">
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.exe"/>
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </property>
+ </supportedProperties>
+ <option id="tcm.tc3.o1"/>
+ <inputType id="tcm.it.5" sources="tcmfoo"/>
+ </tool>
+ <tool id="tcm.tc3.t2" name="tcm.tc3.t2">
+ <option id="tcm.tc3.o2"/>
+ <inputType id="tcm.it.6" sources="tcmbar"/>
+ </tool>
+ </toolChain>
+
+ <toolChain id="tcm.tc4" name="tcm.tc4" isSystem="true">
+ <builder id="tcm.tc4.b1" name="tcm.tc4.b1">
+ </builder>
+ <tool id="tcm.tc4.t1" name="tcm.tc4.t1">
+ <supportedProperties>
+ <property id="org.eclipse.cdt.build.core.buildArtefactType">
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.exe"/>
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </property>
+ </supportedProperties>
+ <option id="tcm.tc4.o1"/>
+ <inputType id="tcm.it.7" sources="tcmfoo"/>
+ </tool>
+ <tool id="tcm.tc4.t2" name="tcm.tc4.t2">
+ <option id="tcm.tc4.o2"/>
+ <inputType id="tcm.it.8" sources="tcmbar"/>
+ </tool>
+ </toolChain>
+
+ <toolChain id="tcm.tc5" name="tcm.tc5" isSystem="true">
+ <builder id="tcm.tc5.b1" name="tcm.tc5.b1">
+ </builder>
+ <tool id="tcm.tc5.t1" name="tcm.tc5.t1">
+ <supportedProperties>
+ <property id="org.eclipse.cdt.build.core.buildArtefactType">
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.exe"/>
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </property>
+ </supportedProperties>
+ <option id="tcm.tc5.o1"/>
+ <inputType id="tcm.it.9" sources="tcmfoo"/>
+ </tool>
+ <tool id="tcm.tc5.t2" name="tcm.tc5.t2">
+ <option id="tcm.tc5.o2"/>
+ <inputType id="tcm.it.10" sources="tcmbar"/>
+ </tool>
+ </toolChain>
+
+ <projectType
+ id="tcm.pt" name="tcm.pt"
+ isTest="true"
+ buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe">
+ <configuration id="tcm.pt.cfg" name="test">
+ <toolChain id="tcm.pt.cfg.tc" superClass="tcm.tc1">
+ <builder id="tcm.pt.b1" superClass="tcm.b1" name="tcm.b1">
+ </builder>
+ <tool id="tcm.pt.cfg.t1" superClass="tcm.t1">
+ </tool>
+ <tool id="tcm.pt.cfg.t2" superClass="tcm.t2">
+ </tool>
+ </toolChain>
+ </configuration>
+ </projectType>
+
+ <projectType
+ id="tcm.pt2" name="tcm.pt2"
+ isTest="true"
+ buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe">
+ <configuration id="tcm.pt2.cfg" name="test">
+ <toolChain id="tcm.pt2.cfg.tc" superClass="tcm.tc1">
+ <builder id="tcm.pt2.b1" superClass="tcm.b1" name="tcm.b1">
+ </builder>
+ <tool id="tcm.pt2.cfg.t1" superClass="tcm.t1">
+ </tool>
+ <tool id="tcm.pt2.cfg.t2" superClass="tcm.t2">
+ </tool>
+ </toolChain>
+ </configuration>
+ </projectType>
+
+<!-- 2.1 -->
+ <toolChain id="tcm2.tc" name="tcm2.tc" isSystem="true">
+ <builder id="tcm2.tc.b1" name="tcm2.tc.b1">
+ </builder>
+ <tool id="tcm2.tc.t1" name="tcm2.tc.t1">
+ <supportedProperties>
+ <property id="org.eclipse.cdt.build.core.buildArtefactType">
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.exe"/>
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </property>
+ </supportedProperties>
+ <option id="tcm2.tc.o1"/>
+ <inputType id="tcm.it.11" sources="tcmfoo"/>
+ </tool>
+ <tool id="tcm2.tc.t2" name="tcm2.tc.t2">
+ <option id="tcm2.tc.o2"/>
+ <inputType id="tcm.it.12" sources="tcmfoo"/>
+ </tool>
+ </toolChain>
+
+ <toolChain id="tcm2.tc2" name="tcm2.tc2" isSystem="true">
+ <builder id="tcm2.tc2.b1" name="tcm2.tc2.b1">
+ </builder>
+ <tool id="tcm2.tc2.t1" name="tcm2.tc2.t1">
+ <supportedProperties>
+ <property id="org.eclipse.cdt.build.core.buildArtefactType">
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.exe"/>
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </property>
+ </supportedProperties>
+ <option id="tcm2.tc2.o1"/>
+ <inputType id="tcm.it.13" sources="tcmfoo"/>
+ </tool>
+ <tool id="tcm2.tc2.t2" name="tcm2.tc2.t2">
+ <option id="tcm2.tc2.o2"/>
+ <inputType id="tcm.it.14" sources="tcmbar"/>
+ </tool>
+ </toolChain>
+ <toolChain id="tcm2.tc2.derive" superClass="tcm2.tc2" name="tcm2.tc2.derive" isSystem="true">
+ </toolChain>
+ <toolChain id="tcm2.tc.derive" superClass="tcm2.tc" name="tcm2.tc.derive" isSystem="true">
+ </toolChain>
+
+ <toolChain id="tcm.base.tc" name="tcm.base.tc" isSystem="true">
+ <builder id="tcm.base.tc.b1" name="tcm.base.tc.b1">
+ </builder>
+ <tool id="tcm.base.tc.t1" name="tcm.base.tc.t1">
+ <supportedProperties>
+ <property id="org.eclipse.cdt.build.core.buildArtefactType">
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.exe"/>
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </property>
+ </supportedProperties>
+ <option id="tcm.base.tc.o1"/>
+ <inputType id="tcm.it.15" sources="tcmfoo"/>
+ </tool>
+ <tool id="tcm.base.tc.t2" name="tcm.base.tc.t2">
+ <option id="tcm.base.tc.o2"/>
+ <inputType id="tcm.it.16" sources="tcmbar"/>
+ </tool>
+ </toolChain>
+
+ <toolChain id="tcm.derive.tc1" superClass="tcm.base.tc" name="tcm.derive.tc1" isSystem="true">
+ <builder id="tcm.derive.tc1.b1" superClass="tcm.base.tc.b1" name="tcm.derive.tc1.b1">
+ </builder>
+ <tool id="tcm.derive.tc1.t1" superClass="tcm.base.tc.t1" name="tcm.derive.tc1.t1">
+ <supportedProperties>
+ <property id="org.eclipse.cdt.build.core.buildArtefactType">
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.exe"/>
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </property>
+ </supportedProperties>
+ <option id="tcm.derive.tc1.o1"/>
+ <inputType id="tcm.it.17" sources="tcmfoo"/>
+ </tool>
+ <tool id="tcm.derive.tc1.t2" superClass="tcm.base.tc.t2" name="tcm.derive.tc1.t2">
+ <option id="tcm.derive.tc1.o2"/>
+ <inputType id="tcm.it.18" sources="tcmbar"/>
+ </tool>
+ </toolChain>
+
+ <toolChain id="tcm.derive.tc2" superClass="tcm.base.tc" name="tcm.derive.tc2" isSystem="true">
+ <builder id="tcm.derive.tc2.b1" superClass="tcm.base.tc.b1" name="tcm.derive.tc2.b1">
+ </builder>
+ <tool id="tcm.derive.tc2.t1" superClass="tcm.base.tc.t1" name="tcm.derive.tc2.t1">
+ <supportedProperties>
+ <property id="org.eclipse.cdt.build.core.buildArtefactType">
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.exe"/>
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </property>
+ </supportedProperties>
+ <option id="tcm.derive.tc2.o1"/>
+ <inputType id="tcm.it.19" sources="tcmfoo"/>
+ </tool>
+ <tool id="tcm.derive.tc2.t2" superClass="tcm.base.tc.t2" name="tcm.derive.tc2.t2">
+ <option id="tcm.derive.tc2.o2"/>
+ <inputType id="tcm.it.20" sources="tcmbar"/>
+ </tool>
+ </toolChain>
+
+ <projectType
+ id="tcm.pt.derive1" name="tcm.pt.derive1"
+ isTest="true"
+ buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe">
+ <configuration id="tcm.pt.derive1.cfg" name="test">
+ <toolChain id="tcm.pt.derive.tc1" superClass="tcm.derive.tc1">
+ <builder id="tcm.pt.derive.b1" superClass="tcm.derive.tc1.b1">
+ </builder>
+ <tool id="tcm.pt.derive.t1" superClass="tcm.derive.tc1.t1">
+ </tool>
+ <tool id="tcm.pt.derive.t2" superClass="tcm.derive.tc1.t2">
+ </tool>
+ </toolChain>
+ </configuration>
+ </projectType>
+
+<!-- 2.2 -->
+
+ <toolChain id="tcm.base2.tc" name="tcm.base2.tc" isSystem="true">
+ <builder id="tcm.base2.tc.b1" name="tcm.base2.tc.b1">
+ </builder>
+ <tool id="tcm.base2.tc.t1" name="tcm.base2.tc.t1">
+ <supportedProperties>
+ <property id="org.eclipse.cdt.build.core.buildArtefactType">
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.exe"/>
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </property>
+ </supportedProperties>
+ <option id="tcm.base2.tc.o1"/>
+ <inputType id="tcm.it.21" sources="tcmfoo"/>
+ </tool>
+ <tool id="tcm.base2.tc.t2" name="tcm.base2.tc.t2">
+ <option id="tcm.base2.tc.o2"/>
+ <inputType id="tcm.it.22" sources="tcmbar"/>
+ </tool>
+ </toolChain>
+
+ <toolChain id="tcm.derive2.tc1" superClass="tcm.base2.tc" name="tcm.derive2.tc1" isSystem="true">
+ <builder id="tcm.derive2.tc1.b1" superClass="tcm.base2.tc.b1" name="tcm.derive2.tc1.b1">
+ </builder>
+ <tool id="tcm.derive2.tc1.t1" superClass="tcm.base2.tc.t1" name="tcm.derive2.tc1.t1">
+ <supportedProperties>
+ <property id="org.eclipse.cdt.build.core.buildArtefactType">
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.exe"/>
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </property>
+ </supportedProperties>
+ <option id="tcm.derive2.tc1.o1"/>
+ <inputType id="tcm.it.23" sources="tcmfoo"/>
+ </tool>
+ <tool id="tcm.derive2.tc1.t2" superClass="tcm.base2.tc.t2" name="tcm.derive2.tc1.t2">
+ <option id="tcm.derive2.tc1.o2"/>
+ <inputType id="tcm.it.24" sources="tcmbar"/>
+ </tool>
+ </toolChain>
+
+ <toolChain id="tcm.derive2.tc2" superClass="tcm.base2.tc" name="tcm.derive2.tc2" isSystem="true">
+ <builder id="tcm.derive2.tc2.b1" superClass="tcm.base2.tc.b1" name="tcm.derive2.tc2.b1">
+ </builder>
+ <tool id="tcm.derive2.tc2.t1" superClass="tcm.base2.tc.t1" name="tcm.derive2.tc2.t1">
+ <supportedProperties>
+ <property id="org.eclipse.cdt.build.core.buildArtefactType">
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.exe"/>
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </property>
+ </supportedProperties>
+ <option id="tcm.derive2.tc2.o1"/>
+ <inputType id="tcm.it.25" sources="tcmfoo"/>
+ </tool>
+ <tool id="tcm.derive2.tc2.t2" superClass="tcm.base2.tc.t2" name="tcm.derive2.tc2.t2">
+ <option id="tcm.derive2.tc2.o2"/>
+ <inputType id="tcm.it.26" sources="tcmbar"/>
+ </tool>
+ </toolChain>
+
+ </extension>
+ <extension
+ id="test.tcModificationInfo.extension.id1"
+ name="Test ToolChain Modification Info Extension"
+ point="org.eclipse.cdt.managedbuilder.core.tcModificationInfo">
+
+ <conflictDefinition>
+ <matchObject
+ objectIds="tcm.tc2"
+ objectType="toolChain"/>
+ <matchObject
+ objectIds="tcm.pt.cfg"
+ objectType="configuration"/>
+ </conflictDefinition>
+
+ <conflictDefinition>
+ <matchObject
+ objectIds="tcm.tc3"
+ objectType="toolChain"/>
+ <matchObject
+ objectIds="tcm.tc1"
+ objectType="toolChain"/>
+ </conflictDefinition>
+
+ <conflictDefinition>
+ <matchObject
+ objectIds="tcm.tc4.b1"
+ objectType="builder"/>
+ <matchObject
+ objectIds="tcm.tc1"
+ objectType="toolChain"/>
+ </conflictDefinition>
+
+ <conflictDefinition>
+ <matchObject
+ objectIds="tcm.tc5.t1"
+ objectType="tool"/>
+ <matchObject
+ objectIds="tcm.tc1"
+ objectType="toolChain"/>
+ </conflictDefinition>
+
+ <conflictDefinition>
+ <matchObject
+ objectIds="tcm.tc4.t1"
+ objectType="tool"/>
+ <matchObject
+ objectIds="tcm.tc3.t1"
+ objectType="tool"/>
+ </conflictDefinition>
+ </extension>
+ <!-- 2 -->
+ <extension
+ id="test.tcModificationInfo.extension.id2"
+ name="Test ToolChain Modification Info Extension2"
+ point="org.eclipse.cdt.managedbuilder.core.tcModificationInfo">
+
+ <conflictDefinition>
+ <matchObject
+ objectIds="tcm.base.tc"
+ objectType="toolChain"
+ searchScope="ALL_EXTENSION_SUPERCLASSES"/>
+ <matchObject
+ objectIds="tcm.base2.tc;tcm2.tc"
+ objectType="toolChain"
+ searchScope="ALL_EXTENSION_SUPERCLASSES">
+ <pattern
+ objectIds="tcm2.tc2"
+ searchScope="EXTENSION_OBJECT"/>
+ </matchObject>
+ </conflictDefinition>
</extension>
-
-
</plugin>
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ToolChainModificationTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ToolChainModificationTests.java
index 20457a22b5f..7f824363870 100644
--- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ToolChainModificationTests.java
+++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ToolChainModificationTests.java
@@ -10,10 +10,42 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.core.tests;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+import org.eclipse.cdt.managedbuilder.core.IBuildObject;
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.core.FolderInfo;
+import org.eclipse.cdt.managedbuilder.internal.core.ToolChain;
+import org.eclipse.cdt.managedbuilder.tcmodification.IConfigurationModification;
+import org.eclipse.cdt.managedbuilder.tcmodification.IFolderInfoModification;
+import org.eclipse.cdt.managedbuilder.tcmodification.IModificationOperation;
+import org.eclipse.cdt.managedbuilder.tcmodification.IToolChainModificationManager;
+import org.eclipse.cdt.managedbuilder.tcmodification.IToolModification;
+import org.eclipse.cdt.managedbuilder.testplugin.BuildSystemTestHelper;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+
public class ToolChainModificationTests extends BasicTestCase {
+ private static final String PROJ_NAME_PREFIX="TCM_";
public static Test suite() {
TestSuite suite = new TestSuite(ToolChainModificationTests.class);
@@ -21,7 +53,320 @@ public class ToolChainModificationTests extends BasicTestCase {
return suite;
}
-// public void testChangeToolChain(){
-//
-// }
+ public void testRootToolChainStatus() throws Exception {
+ final String projName = PROJ_NAME_PREFIX + "p1";
+ IProject project = BuildSystemTestHelper.createProject(projName);
+ BuildSystemTestHelper.createDescription(project, "tcm.pt");
+ ICProjectDescriptionManager desMngr = CoreModel.getDefault().getProjectDescriptionManager();
+
+ ICProjectDescription des = desMngr.getProjectDescription(project);
+ IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(des.getConfigurations()[0]);
+ IToolChainModificationManager mngr = ManagedBuildManager.getToolChainModificationManager();
+
+ IConfigurationModification cfgM = (IConfigurationModification)mngr.getModification(cfg.getRootFolderInfo());
+ assertTrue(cfgM.isToolChainCompatible());
+ assertTrue(cfgM.isBuilderCompatible());
+
+ IToolChain[] ctcs = cfgM.getCompatibleToolChains();
+ HashSet set = new HashSet();
+ FolderInfo foInfo = (FolderInfo)cfg.getRootFolderInfo();
+ ToolChain tc = (ToolChain)foInfo.getToolChain();
+ IToolChain[] allSys = ManagedBuildManager.getRealToolChains();
+ filterPropsSupported(foInfo, tc, allSys, set);
+ set.remove(ManagedBuildManager.getRealToolChain(tc));
+ IToolChain incompatibleTc = ManagedBuildManager.getExtensionToolChain("tcm.tc2");
+ incompatibleTc = ManagedBuildManager.getRealToolChain(incompatibleTc);
+ set.remove(incompatibleTc);
+ compare(Arrays.asList(ctcs), set);
+
+ HashSet incomp = new HashSet(Arrays.asList(allSys));
+ incomp.removeAll(Arrays.asList(ctcs));
+ assertTrue(incomp.contains(incompatibleTc));
+
+ IBuilder[] cbs = cfgM.getCompatibleBuilders();
+ Set bSet = new HashSet();
+ IBuilder[] allSysB = ManagedBuildManager.getRealBuilders();
+ filterPropsSupported(cfg, allSysB, bSet);
+ IBuilder incompatibleB = ManagedBuildManager.getExtensionBuilder("tcm.tc4.b1");
+ incompatibleB = ManagedBuildManager.getRealBuilder(incompatibleB);
+ bSet.remove(cfgM.getRealBuilder());
+ bSet.remove(incompatibleB);
+ compare(Arrays.asList(cbs), bSet);
+
+ HashSet incompB = new HashSet(Arrays.asList(allSysB));
+ incompB.removeAll(Arrays.asList(cbs));
+ assertTrue(incompB.contains(incompatibleB));
+
+ IToolChain tc3 = ManagedBuildManager.getExtensionToolChain("tcm.tc3");
+ cfgM.setToolChain(tc3);
+ assertEquals(tc3, cfgM.getToolChain());
+ assertEquals(tc3.getBuilder(), cfgM.getBuilder());
+
+ IBuilder b5 = ManagedBuildManager.getExtensionBuilder("tcm.tc5.b1");
+ cfgM.setBuilder(b5);
+ assertEquals(tc3, cfgM.getToolChain());
+ assertEquals(b5, cfgM.getBuilder());
+
+ project.delete(true, null);
+ }
+
+ private boolean contains(Object[] array, Object obj){
+ return new HashSet(Arrays.asList(array)).contains(obj);
+ }
+
+ private HashSet filterSupportedToolChains(IFolderInfo foInfo, IToolChain tc){
+ HashSet set = new HashSet();
+ IToolChain[] allSys = ManagedBuildManager.getRealToolChains();
+ filterPropsSupported((FolderInfo)foInfo, (ToolChain)tc, allSys, set);
+ set.remove(ManagedBuildManager.getRealToolChain(tc));
+ return set;
+ }
+
+ public void testChildToolChainStatus() throws Exception {
+ final String projName = PROJ_NAME_PREFIX + "p2";
+ IProject project = BuildSystemTestHelper.createProject(projName);
+ BuildSystemTestHelper.createDescription(project, "tcm.pt2");
+ ICProjectDescriptionManager desMngr = CoreModel.getDefault().getProjectDescriptionManager();
+
+ ICProjectDescription des = desMngr.getProjectDescription(project);
+ IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(des.getConfigurations()[0]);
+ IToolChainModificationManager mngr = ManagedBuildManager.getToolChainModificationManager();
+
+ IConfigurationModification cfgM = (IConfigurationModification)mngr.getModification(cfg.getRootFolderInfo());
+ assertEquals(cfgM.getToolChain(), cfg.getToolChain());
+ assertTrue(cfgM.isToolChainCompatible());
+ assertTrue(cfgM.isBuilderCompatible());
+
+ IPath foPath = new Path("a");
+ IFolder fo = project.getFolder(foPath);
+ fo.create(true, true, null);
+
+ IFolderInfo foInfo = cfg.createFolderInfo(foPath);
+ IFolderInfoModification foM = mngr.getModification(foInfo);
+ assertEquals(foM.getToolChain(), foInfo.getToolChain());
+ assertTrue(foM.isToolChainCompatible());
+
+ cfgM = (IConfigurationModification)mngr.getModification(cfg.getRootFolderInfo());
+ assertEquals(cfgM.getToolChain(), cfg.getToolChain());
+ assertTrue(cfgM.isToolChainCompatible());
+ assertTrue(cfgM.isBuilderCompatible());
+
+ HashSet set = filterSupportedToolChains(cfg.getRootFolderInfo(), cfg.getToolChain());
+ IToolChain[] tcs = cfgM.getCompatibleToolChains();
+ compare(Arrays.asList(tcs), set);
+
+ tcs = foM.getCompatibleToolChains();
+ set = filterSupportedToolChains(foInfo, foInfo.getToolChain());
+ IToolChain incompatibleTc = ManagedBuildManager.getExtensionToolChain("tcm.tc3");
+ incompatibleTc = ManagedBuildManager.getRealToolChain(incompatibleTc);
+ set.remove(incompatibleTc);
+ compare(Arrays.asList(tcs), set);
+
+ foM.setToolChain(incompatibleTc);
+ assertFalse(foM.isToolChainCompatible());
+ foInfo.changeToolChain(incompatibleTc, CDataUtil.genId("blah.blah"), incompatibleTc.getName());
+ cfgM = (IConfigurationModification)mngr.getModification(cfg.getRootFolderInfo());
+ assertTrue(cfgM.isToolChainCompatible());
+ foM = mngr.getModification(foInfo);
+ assertFalse(foM.isToolChainCompatible());
+
+ project.delete(true, null);
+ }
+
+ public void testChildToolChainStatus2() throws Exception {
+ final String projName = PROJ_NAME_PREFIX + "p3";
+ IProject project = BuildSystemTestHelper.createProject(projName);
+ BuildSystemTestHelper.createDescription(project, "tcm.pt.derive1");
+ ICProjectDescriptionManager desMngr = CoreModel.getDefault().getProjectDescriptionManager();
+
+ ICProjectDescription des = desMngr.getProjectDescription(project);
+ IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(des.getConfigurations()[0]);
+ IToolChainModificationManager mngr = ManagedBuildManager.getToolChainModificationManager();
+
+ IConfigurationModification cfgM = (IConfigurationModification)mngr.getModification(cfg.getRootFolderInfo());
+ assertEquals(cfgM.getToolChain(), cfg.getToolChain());
+ assertTrue(cfgM.isToolChainCompatible());
+ assertTrue(cfgM.isBuilderCompatible());
+
+ IPath foPath = new Path("a");
+ IFolder fo = project.getFolder(foPath);
+ fo.create(true, true, null);
+
+ IFolderInfo foInfo = cfg.createFolderInfo(foPath);
+ IFolderInfoModification foM = mngr.getModification(foInfo);
+ assertEquals(foM.getToolChain(), foInfo.getToolChain());
+ assertTrue(foM.isToolChainCompatible());
+
+ cfgM = (IConfigurationModification)mngr.getModification(cfg.getRootFolderInfo());
+ assertEquals(cfgM.getToolChain(), cfg.getToolChain());
+ assertTrue(cfgM.isToolChainCompatible());
+ assertTrue(cfgM.isBuilderCompatible());
+
+ HashSet set = filterSupportedToolChains(cfg.getRootFolderInfo(), cfg.getToolChain());
+ IToolChain[] tcs = cfgM.getCompatibleToolChains();
+ compare(Arrays.asList(tcs), set);
+
+ tcs = foM.getCompatibleToolChains();
+ set = filterSupportedToolChains(foInfo, foInfo.getToolChain());
+ rmToolChains(set, new String[]{
+ "tcm.base2.tc",
+ "tcm.derive2.tc1",
+ "tcm.derive2.tc2",
+ "tcm2.tc2",
+ "tcm2.tc",
+ "tcm2.tc.derive",
+ });
+
+ compare(Arrays.asList(tcs), set);
+
+ foM.setToolChain(ManagedBuildManager.getExtensionToolChain("tcm.derive2.tc1"));
+ assertFalse(foM.isToolChainCompatible());
+ foInfo.changeToolChain(ManagedBuildManager.getExtensionToolChain("tcm.derive2.tc1"), CDataUtil.genId("blah.blah"), null);
+ cfgM = (IConfigurationModification)mngr.getModification(cfg.getRootFolderInfo());
+ assertTrue(cfgM.isToolChainCompatible());
+ foM = mngr.getModification(foInfo);
+ assertFalse(foM.isToolChainCompatible());
+
+ project.delete(true, null);
+ }
+
+ private void rmToolChains(Set set, String[] ids){
+ for(int i = 0; i < ids.length; i++){
+ IToolChain incompatibleTc = ManagedBuildManager.getExtensionToolChain(ids[i]);
+ assertNotNull("no tool-chain of id " + ids[i], incompatibleTc);
+ incompatibleTc = ManagedBuildManager.getRealToolChain(incompatibleTc);
+ assertTrue("set does not contain tc \"" + incompatibleTc.getId()
+ + "\" which is a real tc for \"" + ids[i] + "\"", set.remove(incompatibleTc));
+ }
+ }
+
+ private IToolChain getRealToolChain(String id){
+ IToolChain tc = ManagedBuildManager.getExtensionToolChain(id);
+ return ManagedBuildManager.getRealToolChain(tc);
+ }
+
+ private void compare(Collection c1, Collection c2){
+ HashSet s1 = new HashSet(c1);
+ HashSet s1c = (HashSet)s1.clone();
+
+ HashSet s2 = new HashSet(c2);
+
+ s1.removeAll(s2);
+ s2.removeAll(s1c);
+ StringBuffer buf = new StringBuffer();
+ buf.append("checking c1..\n");
+ boolean fail = checkEmpty(s1, buf);
+ buf.append("checking c2..\n");
+ fail |= checkEmpty(s2, buf);
+
+ if(fail)
+ fail(buf.toString());
+ }
+
+ private boolean checkEmpty(Collection c, StringBuffer buf){
+ if(c.size() != 0){
+ buf.append("non-empty dump:\n");
+ for(Iterator iter = c.iterator(); iter.hasNext(); ){
+ buf.append("\t ").append((((IBuildObject)iter.next()).getId())).append('\n');
+ }
+ buf.append("end\n");
+ return true;
+ }
+ return false;
+ }
+
+ private Collection filterPropsSupported(FolderInfo foInfo, ToolChain tc, IToolChain[] tcs, Collection c){
+ if(c == null)
+ c = new ArrayList();
+ for(int i = 0; i < tcs.length; i++){
+ if(foInfo.isToolChainCompatible(tc, tcs[i]))
+ c.add(tcs[i]);
+ }
+
+ return c;
+ }
+
+ private Collection filterPropsSupported(IConfiguration cfg, IBuilder[] bs, Collection c){
+ if(c == null)
+ c = new ArrayList();
+ for(int i = 0; i < bs.length; i++){
+ if(cfg.isBuilderCompatible(bs[i]))
+ c.add(bs[i]);
+ }
+
+ return c;
+ }
+
+ private boolean getReplacementToolInfo(IModificationOperation[] ops, Set set){
+ boolean removable = false;
+ for(int i = 0; i < ops.length; i++){
+ ITool tool = ops[i].getReplacementTool();
+ if(tool == null){
+ removable = true;
+ } else {
+ set.add(tool);
+ }
+ }
+ return removable;
+ }
+
+ public void testToolModificationWithChild() throws Exception {
+ final String projName = PROJ_NAME_PREFIX + "p4";
+ IProject project = BuildSystemTestHelper.createProject(projName);
+ BuildSystemTestHelper.createDescription(project, "tcm.pt");
+
+ ICProjectDescriptionManager desMngr = CoreModel.getDefault().getProjectDescriptionManager();
+
+ ICProjectDescription des = desMngr.getProjectDescription(project);
+ IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(des.getConfigurations()[0]);
+ IToolChain tc4 = ManagedBuildManager.getExtensionToolChain("tcm.tc4");
+ cfg.getRootFolderInfo().changeToolChain(tc4, CDataUtil.genId(null), null);
+
+ IToolChainModificationManager mngr = ManagedBuildManager.getToolChainModificationManager();
+
+ IConfigurationModification cfgM = (IConfigurationModification)mngr.getModification(cfg.getRootFolderInfo());
+ assertEquals(cfgM.getToolChain(), cfg.getToolChain());
+ assertTrue(cfgM.isToolChainCompatible());
+ assertTrue(cfgM.isBuilderCompatible());
+
+ IPath foPath = new Path("a");
+ IFolder fo = project.getFolder(foPath);
+ fo.create(true, true, null);
+
+ IFolderInfo foInfo = cfg.createFolderInfo(foPath);
+ IFolderInfoModification foM = mngr.getModification(foInfo);
+ assertEquals(foM.getToolChain(), foInfo.getToolChain());
+ assertTrue(foM.isToolChainCompatible());
+
+ cfgM = (IConfigurationModification)mngr.getModification(cfg.getRootFolderInfo());
+ assertEquals(cfgM.getToolChain(), cfg.getToolChain());
+ assertTrue(cfgM.isToolChainCompatible());
+ assertTrue(cfgM.isBuilderCompatible());
+
+ ITool tool41 = ManagedBuildManager.getExtensionTool("tcm.tc4.t1");
+ IToolModification tm = cfgM.getToolModification(tool41);
+ assertTrue(tm.isProjectTool());
+
+ IModificationOperation[] ops = tm.getSupportedOperations();
+ ITool tool31 = ManagedBuildManager.getExtensionTool("tcm.tc3.t1");
+ Set replacement = new HashSet();
+ boolean removable = getReplacementToolInfo(ops, replacement);
+
+ assertFalse(removable);
+ assertTrue(replacement.contains(tool31));
+
+ tm = foM.getToolModification(tool41);
+ assertTrue(tm.isProjectTool());
+
+ ops = tm.getSupportedOperations();
+ replacement = new HashSet();
+ removable = getReplacementToolInfo(ops, replacement);
+
+ assertFalse(removable);
+ assertFalse(replacement.contains(tool31));
+
+ int tmp = IToolChainModificationManager.OBJECT_CONFIGURATION;
+
+ project.delete(true, null);
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.managedbuilder.core/META-INF/MANIFEST.MF
index 03740c2dec1..86e793bb08b 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/META-INF/MANIFEST.MF
+++ b/build/org.eclipse.cdt.managedbuilder.core/META-INF/MANIFEST.MF
@@ -24,6 +24,7 @@ Export-Package: org.eclipse.cdt.build.core.scannerconfig,
org.eclipse.cdt.managedbuilder.pdomdepgen,
org.eclipse.cdt.managedbuilder.projectconverter,
org.eclipse.cdt.managedbuilder.scannerconfig,
+ org.eclipse.cdt.managedbuilder.tcmodification;x-friends:="org.eclipse.cdt.ui,org.eclipse.cdt.managedbuilder.ui,org.eclipse.cdt.managedbuilder.core.tests",
org.eclipse.cdt.managedbuilder.templateengine,
org.eclipse.cdt.managedbuilder.templateengine.processes,
org.eclipse.cdt.newmake.core
diff --git a/build/org.eclipse.cdt.managedbuilder.core/plugin.xml b/build/org.eclipse.cdt.managedbuilder.core/plugin.xml
index f346ba4ce99..54c9c3c88f4 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/plugin.xml
+++ b/build/org.eclipse.cdt.managedbuilder.core/plugin.xml
@@ -6,6 +6,7 @@
<extension-point id="buildDefinitions" name="Managed Build Definitions" schema="schema/buildDefinitions.exsd"/>
<extension-point id="projectConverter" name="Managed Build Project Converter" schema="schema/Converter.exsd"/>
<extension-point id="buildProperties" name="Build Properties" schema="schema/buildProperties.exsd"/>
+ <extension-point id="tcModificationInfo" name="ToolChain Modification Info" schema="schema/tcModificationInfo.exsd"/>
<!-- =================================================================================== -->
@@ -445,6 +446,12 @@
id="org.eclipse.cdt.build.core.internal.builder"
name="%InternalBuilder.name">
</builder>
+
+ <tool
+ id="org.eclipse.cdt.build.core.default.tool"
+ isAbstract="true"
+ isSystem="true"/>
+
</extension>
<extension
diff --git a/build/org.eclipse.cdt.managedbuilder.core/schema/tcModificationInfo.exsd b/build/org.eclipse.cdt.managedbuilder.core/schema/tcModificationInfo.exsd
new file mode 100644
index 00000000000..60c132c122d
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/schema/tcModificationInfo.exsd
@@ -0,0 +1,256 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.managedbuilder.core">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.cdt.managedbuilder.core" id="tcModificationInfo" name="ToolChain Modification Info"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="conflictDefinition" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="matchObject">
+ <annotation>
+ <documentation>
+ specifies the buildObject pattern to be matched.
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="pattern" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="objectIds" type="string">
+ <annotation>
+ <documentation>
+ Required if no &quot;pattern&quot; objects are specified.
+&lt;br&gt;represents one or more buils object ID [patterns] separated with &quot;;&quot;
+&lt;br&gt;Note that specifying several IDs with one matchObject has exactly the same meaning as specifying those IDs in separate matchObjects combined with the &quot;select&quot; element.
+&lt;br&gt;When both &quot;pattern&quot; objects and &quot;objectIds&quot; are defined, patterns defined in both of them are treated as valid patterns.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="objectType" use="required">
+ <annotation>
+ <documentation>
+ Specifies the type of build objects presented with this element.
+&lt;br&gt;Can have one of the following values:
+&lt;br&gt;TOOL - to represent a tool
+&lt;br&gt;TOOLCHAIN - to represent a tool-chain
+&lt;br&gt;BUILDER - to represent a builder
+ </documentation>
+ </annotation>
+ <simpleType>
+ <restriction base="string">
+ <enumeration value="toolChain">
+ </enumeration>
+ <enumeration value="tool">
+ </enumeration>
+ <enumeration value="builder">
+ </enumeration>
+ <enumeration value="configuration">
+ </enumeration>
+ </restriction>
+ </simpleType>
+ </attribute>
+ <attribute name="searchScope" use="default" value="EXTENSION_SUPERCLASSES">
+ <annotation>
+ <documentation>
+ specifies how the object is to be searched.
+Can contain one of the following values:
+&lt;br&gt;1. EXTENSION_OBJECT - the direct extension superclass is to be checked
+&lt;br&gt;2. ALL_EXTENSION_SUPERCLASSES - object&apos;s extension supet-classes are to be checked.
+&lt;br&gt;The default value is &quot;EXTENSION_OBJECT&quot;
+ </documentation>
+ </annotation>
+ <simpleType>
+ <restriction base="string">
+ <enumeration value="ALL_EXTENSION_SUPERCLASSES">
+ </enumeration>
+ <enumeration value="EXTENSION_OBJECT">
+ </enumeration>
+ </restriction>
+ </simpleType>
+ </attribute>
+ <attribute name="objectIdsType" use="default" value="EXACT_MATCH">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ <simpleType>
+ <restriction base="string">
+ <enumeration value="REGEXP">
+ </enumeration>
+ <enumeration value="EXACT_MATCH">
+ </enumeration>
+ </restriction>
+ </simpleType>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="conflictDefinition">
+ <annotation>
+ <documentation>
+ represents templates for objects conflicting with each other.
+&lt;br&gt; See the &quot;Calculating Tool-chain modification info from the “objects-set” info&quot; section for more information
+&lt;br&gt;the &quot;status&quot; object for this element represents the status information to be applied in case the given conflictingSet information is not fulfilled.
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="matchObject" minOccurs="2" maxOccurs="2"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="pattern">
+ <annotation>
+ <documentation>
+ specifies a string pattern
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="objectIds" type="string" use="required">
+ <annotation>
+ <documentation>
+ pattern value
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="type" use="default" value="EXACT_MATCH">
+ <annotation>
+ <documentation>
+ specifies the value type.
+&lt;br&gt;May contain the following values:
+&lt;br&gt; EXACT_MATCH - value is exact string representation
+&lt;br&gt; REGEXP - value is a regular expressions
+&lt;br&gt;The default is &quot;EXACT_MATCH&quot;.
+ </documentation>
+ </annotation>
+ <simpleType>
+ <restriction base="string">
+ <enumeration value="EXACT_MATCH">
+ </enumeration>
+ <enumeration value="REGEXP">
+ </enumeration>
+ </restriction>
+ </simpleType>
+ </attribute>
+ <attribute name="searchScope" use="default" value="EXTENSION_SUPERCLASSES">
+ <annotation>
+ <documentation>
+ specifies how the object is to be searched.
+Can contain one of the following values:
+&lt;br&gt;1. EXTENSION_OBJECT - the direct extension superclass is to be checked
+&lt;br&gt;2. ALL_EXTENSION_SUPERCLASSES - object&apos;s extension supet-classes are to be checked.
+
+&lt;br&gt;If undefined, the parent search scope will be used, i.e. when used with the matchObject, search scope defined for that matchObject will be used
+ </documentation>
+ </annotation>
+ <simpleType>
+ <restriction base="string">
+ <enumeration value="ALL_EXTENSION_SUPERCLASSES">
+ </enumeration>
+ <enumeration value="EXTENSION_OBJECT">
+ </enumeration>
+ </restriction>
+ </simpleType>
+ </attribute>
+ <attribute name="objectIdsType">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ <simpleType>
+ <restriction base="string">
+ <enumeration value="REGEXP">
+ </enumeration>
+ <enumeration value="EXACT_MATCH">
+ </enumeration>
+ </restriction>
+ </simpleType>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java
index 9c869978e0b..cca30c24cf4 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java
@@ -94,10 +94,12 @@ import org.eclipse.cdt.managedbuilder.internal.dataprovider.BuildConfigurationDa
import org.eclipse.cdt.managedbuilder.internal.dataprovider.ConfigurationDataProvider;
import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider;
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
+import org.eclipse.cdt.managedbuilder.internal.tcmodification.ToolChainModificationManager;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
import org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator;
import org.eclipse.cdt.managedbuilder.projectconverter.UpdateManagedProjectManager;
+import org.eclipse.cdt.managedbuilder.tcmodification.IToolChainModificationManager;
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
@@ -418,6 +420,18 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
return extensionToolChainMap;
}
+ public static IToolChain[] getExtensionToolChains() {
+ try {
+ loadExtensions();
+ } catch (BuildException e) {
+ }
+
+ if (extensionToolChainMap == null) {
+ extensionToolChainMap = new TreeMap();
+ }
+ return (ToolChain[])extensionToolChainMap.values().toArray(new ToolChain[extensionToolChainMap.size()]);
+ }
+
/* (non-Javadoc)
* Safe accessor for the map of IDs to Tools
*
@@ -433,6 +447,17 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
}
return extensionToolMap;
}
+
+ public static ITool[] getExtensionTools() {
+ try {
+ loadExtensions();
+ } catch (BuildException e) {
+ }
+ if (extensionToolMap == null) {
+ extensionToolMap = new TreeMap();
+ }
+ return (Tool[])extensionToolMap.values().toArray(new Tool[extensionToolMap.size()]);
+ }
/* (non-Javadoc)
* Safe accessor for the map of IDs to TargetPlatforms
@@ -461,6 +486,17 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
}
return extensionBuilderMap;
}
+
+ public static IBuilder[] getExtensionBuilders() {
+ try {
+ loadExtensions();
+ } catch (BuildException e) {
+ }
+ if (extensionBuilderMap == null) {
+ extensionBuilderMap = new TreeMap();
+ }
+ return (Builder[])extensionBuilderMap.values().toArray(new Builder[extensionBuilderMap.size()]);
+ }
/* (non-Javadoc)
* Safe accessor for the map of IDs to Options
@@ -577,6 +613,18 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
return (IConfiguration) getExtensionConfigurationMap().get(id);
}
+ public static IConfiguration[] getExtensionConfigurations() {
+ try {
+ // Make sure the extensions are loaded
+ loadExtensions();
+ } catch (BuildException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return (IConfiguration[]) getExtensionConfigurationMap().values().toArray(new Configuration[getExtensionConfigurationMap().size()]);
+ }
+
/**
* Returns the resource configuration from the manifest with the ID specified in the argument
* or <code>null</code>.
@@ -2472,6 +2520,8 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
performAdjustments();
projectTypesLoading = false;
projectTypesLoaded = true;
+
+ ToolChainModificationManager.getInstance().start();
}
private static void performAdjustments(){
@@ -4267,7 +4317,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
public static ITool[] getRealTools(){
HashMap map = getSortedTools();
- ITool ts[] = new Tool[map.size()];
+ Tool ts[] = new Tool[map.size()];
int i = 0;
for(Iterator iter = map.values().iterator(); iter.hasNext();){
List list = (List)iter.next();
@@ -4313,6 +4363,8 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
}
public static ITool getRealTool(ITool tool){
+ if(tool == null)
+ return null;
ITool extTool = tool;
ITool realTool = null;
for(;extTool != null && !extTool.isExtensionElement(); extTool= extTool.getSuperClass());
@@ -4332,7 +4384,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
}
}
} else {
- //TODO:
+ realTool = getExtensionTool(Tool.DEFAULT_TOOL_ID);
}
return realTool;
}
@@ -4636,5 +4688,14 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
} catch (CoreException e) {
}
}
+
+ /**
+ * entry-point for the tool-chain modification validation functionality
+ *
+ * @return {@link IToolChainModificationManager}
+ */
+ public static IToolChainModificationManager getToolChainModificationManager(){
+ return ToolChainModificationManager.getInstance();
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java
index 367e0cd7029..213216b152f 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java
@@ -68,7 +68,7 @@ import org.eclipse.core.runtime.PluginVersionIdentifier;
import org.eclipse.core.variables.IStringVariableManager;
import org.eclipse.core.variables.VariablesPlugin;
-public class Builder extends BuildObject implements IBuilder, IMatchKeyProvider {
+public class Builder extends BuildObject implements IBuilder, IMatchKeyProvider, IRealBuildObjectAssociation {
private static final String EMPTY_STRING = ""; //$NON-NLS-1$
@@ -2680,4 +2680,28 @@ public class Builder extends BuildObject implements IBuilder, IMatchKeyProvider
return getSuperClassNum() - other.getSuperClassNum();
}
+
+ public IRealBuildObjectAssociation getExtensionObject() {
+ return (Builder)ManagedBuildManager.getExtensionBuilder(this);
+ }
+
+ public IRealBuildObjectAssociation[] getIdenticBuildObjects() {
+ return (IRealBuildObjectAssociation[])ManagedBuildManager.findIdenticalBuilders(this);
+ }
+
+ public IRealBuildObjectAssociation getRealBuildObject() {
+ return (Builder)ManagedBuildManager.getRealBuilder(this);
+ }
+
+ public IRealBuildObjectAssociation getSuperClassObject() {
+ return (Builder)getSuperClass();
+ }
+
+ public final int getType() {
+ return OBJECT_BUILDER;
+ }
+
+ public boolean isRealBuildObject() {
+ return ManagedBuildManager.getRealBuilder(this) == this;
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java
index ee5f6e43c5c..13e788fa40e 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java
@@ -87,7 +87,7 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.PluginVersionIdentifier;
import org.osgi.service.prefs.Preferences;
-public class Configuration extends BuildObject implements IConfiguration, IBuildPropertiesRestriction, IBuildPropertyChangeListener {
+public class Configuration extends BuildObject implements IConfiguration, IBuildPropertiesRestriction, IBuildPropertyChangeListener, IRealBuildObjectAssociation {
private static final String EMPTY_STRING = ""; //$NON-NLS-1$
private static final IPath EMPTY_PATH_ARRAY[] = new IPath[0];
@@ -3000,4 +3000,31 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
}
}
+ public IRealBuildObjectAssociation getExtensionObject() {
+ return isExtensionConfig ? this : (Configuration)getParent();
+ }
+
+ public IRealBuildObjectAssociation[] getIdenticBuildObjects() {
+ return new Configuration[]{(Configuration)getExtensionObject()};
+ }
+
+ public IRealBuildObjectAssociation getRealBuildObject() {
+ return getExtensionObject();
+ }
+
+ public IRealBuildObjectAssociation getSuperClassObject() {
+ return (IRealBuildObjectAssociation)getParent();
+ }
+
+ public int getType() {
+ return OBJECT_CONFIGURATION;
+ }
+
+ public boolean isRealBuildObject() {
+ return getRealBuildObject() == this;
+ }
+
+ public String getUniqueRealName() {
+ return getName();
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/FolderInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/FolderInfo.java
index 595b57d0be4..3601ef0177b 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/FolderInfo.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/FolderInfo.java
@@ -342,7 +342,7 @@ public class FolderInfo extends ResourceInfo implements IFolderInfo {
}
// Answer the filtered tools as an array
- return (ITool[])tools.toArray(new ITool[tools.size()]);
+ return (Tool[])tools.toArray(new Tool[tools.size()]);
}
public ITool[] getFilteredTools() {
@@ -779,10 +779,14 @@ public class FolderInfo extends ResourceInfo implements IFolderInfo {
return set;
}
-
+
public boolean isToolChainCompatible(IToolChain tCh){
+ return isToolChainCompatible(toolChain, tCh);
+ }
+
+ public boolean isToolChainCompatible(ToolChain fromTc, IToolChain tCh){
boolean compatible = false;
- if(tCh == toolChain)
+ if(tCh == fromTc)
return true;
if(tCh == null){
@@ -792,20 +796,20 @@ public class FolderInfo extends ResourceInfo implements IFolderInfo {
if(tCh == null)
return false;
- IToolChain curReal = ManagedBuildManager.getRealToolChain(toolChain);
+ IToolChain curReal = ManagedBuildManager.getRealToolChain(fromTc);
IToolChain newReal = ManagedBuildManager.getRealToolChain(tCh);
if(curReal == newReal)
return true;
if(tCh != null){
- if(getToolChainConverterInfo(tCh) != null)
+ if(getToolChainConverterInfo(fromTc, tCh) != null)
compatible = true;
if(!compatible)
compatible = isPropertiesModificationCompatible(tCh);
} else {
- compatible = this.toolChain != null && this.toolChain.isPreferenceToolChain();
+ compatible = fromTc != null && fromTc.isPreferenceToolChain();
}
return compatible;
}
@@ -836,7 +840,7 @@ public class FolderInfo extends ResourceInfo implements IFolderInfo {
if(extTc != null)
newSuperClass = extTc;
ToolChain oldToolChain = toolChain;
- ConverterInfo cInfo = getToolChainConverterInfo(newSuperClass);
+ ConverterInfo cInfo = getToolChainConverterInfo(toolChain, newSuperClass);
ITool oldTools[] = oldToolChain.getTools();
if(cInfo != null){
@@ -982,8 +986,8 @@ public class FolderInfo extends ResourceInfo implements IFolderInfo {
tch.updateParentFolderInfo(this);
}
- private ConverterInfo getToolChainConverterInfo(IToolChain toTc){
- IConfigurationElement el = getToolChainConverterElement(toTc);
+ private ConverterInfo getToolChainConverterInfo(ToolChain fromTc, IToolChain toTc){
+ IConfigurationElement el = getToolChainConverterElement(fromTc, toTc);
IToolChain foundToTc = toTc;
if(el == null){
IToolChain[] tcs = ManagedBuildManager.findIdenticalToolChains(toTc);
@@ -992,7 +996,7 @@ public class FolderInfo extends ResourceInfo implements IFolderInfo {
if(foundToTc == toTc)
continue;
- el = getToolChainConverterElement(foundToTc);
+ el = getToolChainConverterElement(fromTc, foundToTc);
if(el != null)
break;
}
@@ -1003,13 +1007,13 @@ public class FolderInfo extends ResourceInfo implements IFolderInfo {
return null;
}
- private IConfigurationElement getToolChainConverterElement(IToolChain tCh){
+ private IConfigurationElement getToolChainConverterElement(ToolChain fromTc, IToolChain tCh){
if(tCh == null)
return null;
- ToolChain curTc = (ToolChain)getToolChain();
- if(curTc != null){
- return curTc.getConverterModificationElement(tCh);
+// ToolChain curTc = (ToolChain)getToolChain();
+ if(fromTc != null){
+ return fromTc.getConverterModificationElement(tCh);
}
return null;
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/IRealBuildObjectAssociation.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/IRealBuildObjectAssociation.java
new file mode 100644
index 00000000000..64dd72dc23c
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/IRealBuildObjectAssociation.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * 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.managedbuilder.internal.core;
+
+import org.eclipse.cdt.managedbuilder.core.IBuildObject;
+
+public interface IRealBuildObjectAssociation extends IBuildObject {
+ int OBJECT_TOOLCHAIN = 1;
+ int OBJECT_TOOL = 1 << 1;
+ int OBJECT_BUILDER = 1 << 2;
+ int OBJECT_FILE_INFO = 1 << 3;
+ int OBJECT_FOLDER_INFO = 1 << 4;
+ int OBJECT_CONFIGURATION = 1 << 5;
+
+ int getType();
+
+ IRealBuildObjectAssociation getRealBuildObject();
+
+ IRealBuildObjectAssociation getExtensionObject();
+
+ boolean isRealBuildObject();
+
+ IRealBuildObjectAssociation[] getIdenticBuildObjects();
+
+ IRealBuildObjectAssociation getSuperClassObject();
+
+ String getUniqueRealName();
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputType.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputType.java
index 5ef88ea83b3..aaacaa0d821 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputType.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputType.java
@@ -1493,7 +1493,11 @@ public class InputType extends BuildObject implements IInputType {
* @see org.eclipse.cdt.core.build.managed.IInputType#isSourceExtension()
*/
public boolean isSourceExtension(ITool tool, String ext) {
- String[] exts = getSourceExtensions(tool);
+ return isSourceExtension(tool, ext, ((Tool)tool).getProject());
+ }
+
+ public boolean isSourceExtension(ITool tool, String ext, IProject project) {
+ String[] exts = getSourceExtensions(tool, project);
for (int i=0; i<exts.length; i++) {
if (ext.equals(exts[i])) return true;
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceInfo.java
index 5f965fb94f4..acf69646b44 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceInfo.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceInfo.java
@@ -11,8 +11,10 @@
package org.eclipse.cdt.managedbuilder.internal.core;
import java.util.Arrays;
+import java.util.List;
import java.util.Set;
+import org.eclipse.cdt.core.settings.model.ICSettingBase;
import org.eclipse.cdt.core.settings.model.ICStorageElement;
import org.eclipse.cdt.core.settings.model.extension.CResourceData;
import org.eclipse.cdt.managedbuilder.core.BuildException;
@@ -28,6 +30,8 @@ import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.OptionStringValue;
+import org.eclipse.cdt.managedbuilder.internal.tcmodification.ToolListModification;
+import org.eclipse.cdt.managedbuilder.tcmodification.IToolListModification;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
@@ -518,7 +522,7 @@ public abstract class ResourceInfo extends BuildObject implements IResourceInfo
return (ResourceInfo)getParent().getResourceInfo(path, false);
}
- protected IFolderInfo getParentFolderInfo(){
+ public IFolderInfo getParentFolderInfo(){
ResourceInfo parentRc = getParentResourceInfo();
for(; parentRc != null && !parentRc.isFolderInfo(); parentRc = parentRc.getParentResourceInfo());
@@ -564,4 +568,18 @@ public abstract class ResourceInfo extends BuildObject implements IResourceInfo
void performPostModificationAdjustments(ToolListModificationInfo info){
propertiesChanged();
}
+
+ public IResourceInfo[] getDirectChildResourceInfos(){
+ ResourceInfoContainer cr = getRcInfo();
+ return cr.getDirectChildResourceInfos();
+ }
+
+ public IResourceInfo[] getChildResourceInfos(){
+ ResourceInfoContainer cr = getRcInfo();
+ return cr.getResourceInfos();
+ }
+
+ public List getChildResourceInfoList(boolean includeCurrent){
+ return getRcInfo().getRcInfoList(ICSettingBase.SETTING_FILE | ICSettingBase.SETTING_FOLDER, includeCurrent);
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceInfoContainer.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceInfoContainer.java
index 347ee2fbc9c..5ab2c6b01c2 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceInfoContainer.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceInfoContainer.java
@@ -69,13 +69,29 @@ public class ResourceInfoContainer {
return (IResourceInfo[])list.toArray(datas);
}
-
+
+ public IResourceInfo[] getDirectChildResourceInfos(){
+ PathSettingsContainer[] children = fRcDataContainer.getDirectChildren();
+
+ IResourceInfo datas[] = new IResourceInfo[children.length];
+
+ for(int i = 0; i < datas.length; i++){
+ datas[i] = (IResourceInfo)children[i].getValue();
+ }
+
+ return datas;
+ }
+
public List getRcInfoList(final int kind){
+ return getRcInfoList(kind, fIncludeCurrent);
+ }
+
+ public List getRcInfoList(final int kind, final boolean includeCurrent){
final List list = new ArrayList();
fRcDataContainer.accept(new IPathSettingsContainerVisitor(){
public boolean visit(PathSettingsContainer container) {
- if(fIncludeCurrent || container != fRcDataContainer){
+ if(includeCurrent || container != fRcDataContainer){
IResourceInfo data = (IResourceInfo)container.getValue();
if((data.getKind() & kind) == data.getKind())
list.add(data);
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java
index d1a2b728ee1..c13f058b07d 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java
@@ -88,7 +88,7 @@ import org.eclipse.core.runtime.preferences.IScopeContext;
* Note that this class implements IOptionCategory to represent the top
* category.
*/
-public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatchKeyProvider {
+public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatchKeyProvider, IRealBuildObjectAssociation {
public static final String DEFAULT_PATTERN = "${COMMAND} ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}"; //$NON-NLS-1$
public static final String DEFAULT_CBS_PATTERN = "${COMMAND}"; //$NON-NLS-1$
@@ -106,6 +106,8 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
private static final boolean resolvedDefault = true;
+ public static final String DEFAULT_TOOL_ID = "org.eclipse.cdt.build.core.default.tool"; //$NON-NLS-1$
+
// Superclass
// Note that superClass itself is defined in the base and that the methods
// getSuperClass() and setSuperClassInternal(), defined in Tool must be used to
@@ -1864,11 +1866,15 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
* @see org.eclipse.cdt.managedbuilder.core.ITool#getInputInputType()
*/
public IInputType getInputType(String inputExtension) {
+ return getInputType(inputExtension, getProject());
+ }
+
+ public IInputType getInputType(String inputExtension, IProject project) {
IInputType type = null;
IInputType[] types = getInputTypes();
if (types != null && types.length > 0) {
for (int i=0; i<types.length; i++) {
- if (types[i].isSourceExtension(this, inputExtension)) {
+ if (((InputType)types[i]).isSourceExtension(this, inputExtension, project)) {
type = types[i];
break;
}
@@ -2733,10 +2739,15 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
* @see org.eclipse.cdt.core.build.managed.ITool#buildsFileType(java.lang.String)
*/
public boolean buildsFileType(String extension) {
+ return buildsFileType(extension, getProject());
+ }
+
+ public boolean buildsFileType(String extension, IProject project) {
+
if (extension == null) {
return false;
}
- IInputType it = getInputType(extension);
+ IInputType it = getInputType(extension, project);
if (it != null) {
// Decide whether we "build" this type of file
//
@@ -4174,4 +4185,28 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
return getSuperClassNum() - other.getSuperClassNum();
}
+
+ public IRealBuildObjectAssociation getExtensionObject() {
+ return (IRealBuildObjectAssociation)ManagedBuildManager.getExtensionTool(this);
+ }
+
+ public IRealBuildObjectAssociation[] getIdenticBuildObjects() {
+ return (IRealBuildObjectAssociation[])ManagedBuildManager.findIdenticalTools(this);
+ }
+
+ public IRealBuildObjectAssociation getRealBuildObject() {
+ return (IRealBuildObjectAssociation)ManagedBuildManager.getRealTool(this);
+ }
+
+ public IRealBuildObjectAssociation getSuperClassObject() {
+ return (IRealBuildObjectAssociation)getSuperClass();
+ }
+
+ public final int getType() {
+ return OBJECT_TOOL;
+ }
+
+ public boolean isRealBuildObject() {
+ return getRealBuildObject() == this;
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java
index c9f12df413d..c4f67f09c71 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java
@@ -56,7 +56,7 @@ import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.PluginVersionIdentifier;
-public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropertiesRestriction, IMatchKeyProvider {
+public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropertiesRestriction, IMatchKeyProvider, IRealBuildObjectAssociation {
private static final String EMPTY_STRING = new String();
@@ -984,8 +984,8 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
return tools;
}
- public ITool[] getAllTools(boolean includeCurrentUnused) {
- ITool[] tools = null;
+ public Tool[] getAllTools(boolean includeCurrentUnused) {
+ Tool[] tools = null;
// Merge our tools with our superclass' tools
if (getSuperClass() != null) {
tools = ((ToolChain)getSuperClass()).getAllTools(false);
@@ -1017,7 +1017,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
}
// No Match? Insert it (may be re-ordered)
if (j == tools.length) {
- ITool[] newTools = new ITool[tools.length + 1];
+ Tool[] newTools = new Tool[tools.length + 1];
for (int k = 0; k < tools.length; k++) {
newTools[k] = tools[k];
}
@@ -1041,12 +1041,12 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
// }
// }
} else {
- tools = new ITool[getToolList().size()];
+ tools = new Tool[getToolList().size()];
Iterator iter = getToolList().listIterator();
int i = 0;
while (iter.hasNext()) {
Tool tool = (Tool)iter.next();
- tools[i++] = (ITool)tool;
+ tools[i++] = (Tool)tool;
}
}
if(includeCurrentUnused)
@@ -1054,10 +1054,10 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
return filterUsedTools(tools, true);
}
- private ITool[] filterUsedTools(ITool tools[], boolean used){
+ private Tool[] filterUsedTools(Tool tools[], boolean used){
Set set = getUnusedChilrenSet();
if(set.size() == 0)
- return used ? tools : new ITool[0];
+ return used ? tools : new Tool[0];
List list = new ArrayList(tools.length);
for(int i = 0; i < tools.length; i++){
@@ -1065,11 +1065,11 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
list.add(tools[i]);
}
- return (ITool[])list.toArray(new ITool[list.size()]);
+ return (Tool[])list.toArray(new Tool[list.size()]);
}
- public ITool[] getUnusedTools(){
- ITool[] all = getAllTools(true);
+ public Tool[] getUnusedTools(){
+ Tool[] all = getAllTools(true);
return filterUsedTools(all, false);
}
@@ -2772,4 +2772,28 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
userDefinedMacros = null;
return vars;
}
+
+ public IRealBuildObjectAssociation getExtensionObject() {
+ return (IRealBuildObjectAssociation)ManagedBuildManager.getExtensionToolChain(this);
+ }
+
+ public IRealBuildObjectAssociation[] getIdenticBuildObjects() {
+ return (IRealBuildObjectAssociation[])ManagedBuildManager.findIdenticalToolChains(this);
+ }
+
+ public IRealBuildObjectAssociation getRealBuildObject() {
+ return (IRealBuildObjectAssociation)ManagedBuildManager.getRealToolChain(this);
+ }
+
+ public IRealBuildObjectAssociation getSuperClassObject() {
+ return (IRealBuildObjectAssociation)getSuperClass();
+ }
+
+ public final int getType() {
+ return OBJECT_TOOLCHAIN;
+ }
+
+ public boolean isRealBuildObject() {
+ return getRealBuildObject() == this;
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChainModificationHelper.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChainModificationHelper.java
index 5c24070f3df..68a7efb720e 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChainModificationHelper.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChainModificationHelper.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.core;
-import java.util.AbstractSet;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -24,299 +23,11 @@ import java.util.Set;
import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
-import org.eclipse.cdt.managedbuilder.internal.core.ToolChainModificationHelper.ListMap.CollectionEntry;
+import org.eclipse.cdt.managedbuilder.internal.tcmodification.ListMap;
+import org.eclipse.cdt.managedbuilder.internal.tcmodification.ListMap.CollectionEntry;
import org.eclipse.core.runtime.IConfigurationElement;
-class ToolChainModificationHelper {
-
- static class ListMap implements Cloneable {
- private HashMap fMap;
- private CollectionEntrySet fCollectionEntrySet;
-
- public ListMap(){
- fMap = new HashMap();
- }
-
- public class ValueIter {
- private Map fIterMap;
-
- public ValueIter() {
- fIterMap = new HashMap(fMap);
- for(Iterator iter = fIterMap.entrySet().iterator(); iter.hasNext();){
- Map.Entry entry = (Map.Entry)iter.next();
- Collection c = (Collection)entry.getValue();
- entry.setValue(c.iterator());
- }
- }
-
- public Iterator get(Object key){
- Iterator iter = (Iterator)fIterMap.get(key);
- if(iter != null && !iter.hasNext()){
- fIterMap.remove(key);
- return null;
- }
- return iter;
- }
- }
-
- public class CollectionEntry {
- private Map.Entry fEntry;
-
- CollectionEntry(Map.Entry entry){
- fEntry = entry;
- }
-
- public Object getKey(){
- return fEntry.getKey();
- }
-
- public List getValue(){
- return (List)fEntry.getValue();
- }
-
- public boolean equals(Object obj) {
- if(obj == this)
- return true;
-
- if(obj == null)
- return false;
-
- if(!(obj instanceof CollectionEntry))
- return false;
-
- return fEntry.equals(((CollectionEntry)obj).fEntry);
- }
-
- public int hashCode() {
- return fEntry.hashCode();
- }
- }
-
- private class CollectionEntrySet extends AbstractSet {
- private Set fMapEntrySet;
-
- private class Iter implements Iterator {
- private Iterator fIter;
-
- private Iter(){
- fIter = fMapEntrySet.iterator();
- }
- public boolean hasNext() {
- return fIter.hasNext();
- }
-
- public Object next() {
- return new CollectionEntry((Map.Entry)fIter.next());
- }
-
- public void remove() {
- fIter.remove();
- }
-
- }
-
- private CollectionEntrySet(){
- fMapEntrySet = fMap.entrySet();
- }
-
- public Iterator iterator() {
- return new Iter();
- }
-
- public int size() {
- return fMapEntrySet.size();
- }
- }
-
-
- public void add(Object key, Object value){
- List l = get(key, true);
- l.add(value);
- }
-
- public List removeAll(Object key){
- return (List)fMap.remove(key);
- }
-
- public List get(Object key, boolean create){
- List l = (List)fMap.get(key);
- if(l == null && create){
- l = newList(1);
- fMap.put(key, l);
- }
-
- return l;
- }
-
- public Collection valuesToCollection(Collection c){
- if(c == null)
- c = newList(20);
-
- for(Iterator iter = fMap.values().iterator(); iter.hasNext(); ){
- List l = (List)iter.next();
- c.addAll(l);
- }
-
- return c;
- }
-
- protected List newList(int size){
- return new ArrayList(size);
- }
-
- protected List cloneList(List l){
- return (List)((ArrayList)l).clone();
- }
-
- public Collection putValuesToCollection(Collection c){
- for(Iterator iter = collectionEntrySet().iterator(); iter.hasNext(); ){
- List l = ((CollectionEntry)iter.next()).getValue();
- c.addAll(l);
- }
- return c;
- }
-
- public void remove(Object key, Object value){
- Collection c = get(key, false);
- if(c != null){
- if(c.remove(value) && c.size() == 0){
- fMap.remove(key);
- }
- }
- }
-
- public Object get(Object key, int num){
- List l = get(key, false);
- if(l != null){
- return l.get(num);
- }
- return null;
- }
-
- public Object remove(Object key, int num){
- List l = get(key, false);
- if(l != null){
- Object result = null;
- if(l.size() > num){
- result = l.remove(num);
- }
-
- return result;
- }
- return null;
- }
-
- public Object removeLast(Object key){
- List l = get(key, false);
- if(l != null){
- Object result = null;
- if(l.size() > 0){
- result = l.remove(l.size() - 1);
- }
- return result;
- }
- return null;
- }
-
- public void removeAll(Object key, Collection values){
- Collection c = get(key, false);
- if(c != null){
- if(c.removeAll(values) && c.size() == 0){
- fMap.remove(key);
- }
- }
- }
-
- public void clearEmptyLists(){
- for(Iterator iter = fMap.entrySet().iterator(); iter.hasNext(); ){
- Map.Entry entry = (Map.Entry)iter.next();
- if(((List)entry.getValue()).size() == 0)
- iter.remove();
- }
- }
-
- public Set collectionEntrySet(){
- if(fCollectionEntrySet == null)
- fCollectionEntrySet = new CollectionEntrySet();
- return fCollectionEntrySet;
- }
-
- public void difference(ListMap map){
- for(Iterator iter = map.fMap.entrySet().iterator(); iter.hasNext(); ){
- Map.Entry entry = (Map.Entry)iter.next();
- Collection thisC = (Collection)fMap.get(entry.getKey());
- if(thisC != null){
- if(thisC.removeAll((Collection)entry.getValue()) && thisC == null){
- fMap.remove(entry.getKey());
- }
- }
- }
- }
-
- public ValueIter valueIter(){
- return new ValueIter();
- }
-
-// protected Collection createCollection(Object key){
-// return new ArrayList(1);
-// }
-
- protected Object clone() {
- try {
- ListMap clone = (ListMap)super.clone();
- clone.fMap = (HashMap)fMap.clone();
- for(Iterator iter = clone.fMap.entrySet().iterator(); iter.hasNext();){
- Map.Entry entry = (Map.Entry)iter.next();
- entry.setValue(cloneList((List)entry.getValue()));
- }
- } catch (CloneNotSupportedException e) {
- ManagedBuilderCorePlugin.log(e);
- }
- return null;
- }
-
-// protected Map getMap(boolean create){
-// if(fMap == null && create)
-// fMap = createMap();
-// return fMap;
-// }
-//
-// protected Map createMap(){
-// return new HashMap();
-// }
- }
-
-
-// private static class RealToolToToolIter {
-// private Map fMap;
-//
-// public RealToolToToolIter(Map rtListMap) {
-// fMap = getRealToToolIteratorMap(rtListMap, null);
-// }
-//
-// public ITool next(ITool realTool){
-// Iterator iter = (Iterator)fMap.get(realTool);
-// ITool tool = iter.hasNext() ? (ITool)iter.next() : null;
-// if(!iter.hasNext())
-// fMap.remove(realTool);
-//
-// return tool;
-// }
-// }
-
-// private static ITool[] createRealToolArray(ITool[] tools){
-// ITool[] rts = new ITool[tools.length];
-// for(int i = 0; i < tools.length; i++){
-// ITool t = tools[i];
-// ITool rt = ManagedBuildManager.getRealTool(t);
-// if(rt == null)
-// rt = t;
-// rts[i] = rt;
-// }
-// return rts;
-// }
-
+public class ToolChainModificationHelper {
private static ListMap createRealToToolMap(ITool[] tools, boolean ext){
ListMap lMap = new ListMap();
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/CollectionMap.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/CollectionMap.java
new file mode 100644
index 00000000000..c794d4c0512
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/CollectionMap.java
@@ -0,0 +1,289 @@
+/*******************************************************************************
+ * 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.managedbuilder.internal.tcmodification;
+
+import java.lang.reflect.Array;
+import java.util.AbstractSet;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+
+public class CollectionMap {
+ private HashMap fMap;
+ private CollectionEntrySet fCollectionEntrySet;
+
+ public CollectionMap(){
+ fMap = new HashMap();
+ }
+
+ public class ValueIter {
+ private Map fIterMap;
+
+ public ValueIter() {
+ fIterMap = new HashMap(fMap);
+ for(Iterator iter = fIterMap.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ Collection c = (Collection)entry.getValue();
+ entry.setValue(c.iterator());
+ }
+ }
+
+ public Iterator get(Object key){
+ Iterator iter = (Iterator)fIterMap.get(key);
+ if(iter != null && !iter.hasNext()){
+ fIterMap.remove(key);
+ return null;
+ }
+ return iter;
+ }
+ }
+
+ public class CollectionEntry {
+ private Map.Entry fEntry;
+
+ CollectionEntry(Map.Entry entry){
+ fEntry = entry;
+ }
+
+ public Object getKey(){
+ return fEntry.getKey();
+ }
+
+ public Collection getValue(){
+ return (Collection)fEntry.getValue();
+ }
+
+ public boolean equals(Object obj) {
+ if(obj == this)
+ return true;
+
+ if(obj == null)
+ return false;
+
+ if(!(obj instanceof CollectionEntry))
+ return false;
+
+ return fEntry.equals(((CollectionEntry)obj).fEntry);
+ }
+
+ public int hashCode() {
+ return fEntry.hashCode();
+ }
+ }
+
+ private class CollectionEntrySet extends AbstractSet {
+ private Collection fMapEntrySet;
+
+ private class Iter implements Iterator {
+ private Iterator fIter;
+
+ private Iter(){
+ fIter = fMapEntrySet.iterator();
+ }
+ public boolean hasNext() {
+ return fIter.hasNext();
+ }
+
+ public Object next() {
+ return new CollectionEntry((Map.Entry)fIter.next());
+ }
+
+ public void remove() {
+ fIter.remove();
+ }
+
+ }
+
+ private CollectionEntrySet(){
+ fMapEntrySet = fMap.entrySet();
+ }
+
+ public Iterator iterator() {
+ return new Iter();
+ }
+
+ public int size() {
+ return fMapEntrySet.size();
+ }
+ }
+
+
+ public void add(Object key, Object value){
+ Collection l = get(key, true);
+ l.add(value);
+ }
+
+ public Collection removeAll(Object key){
+ return (Collection)fMap.remove(key);
+ }
+
+ public Collection get(Object key, boolean create){
+ Collection l = (Collection)fMap.get(key);
+ if(l == null && create){
+ l = newCollection(1);
+ fMap.put(key, l);
+ }
+
+ return l;
+ }
+
+ public Collection valuesToCollection(Collection c){
+ if(c == null)
+ c = newCollection(20);
+
+ for(Iterator iter = fMap.values().iterator(); iter.hasNext(); ){
+ Collection l = (Collection)iter.next();
+ c.addAll(l);
+ }
+
+ return c;
+ }
+
+ public Collection getValues(){
+ return (Collection)valuesToCollection(null);
+ }
+
+ public Object[] getValuesArray(Class clazz){
+ Collection list = getValues();
+ Object[] result = (Object[])Array.newInstance(clazz, list.size());
+ return list.toArray(result);
+ }
+
+ protected Collection newCollection(int size){
+ return new ArrayList(size);
+ }
+
+ protected Collection cloneCollection(Collection l){
+ return (Collection)((ArrayList)l).clone();
+ }
+
+ public Collection putValuesToCollection(Collection c){
+ for(Iterator iter = collectionEntrySet().iterator(); iter.hasNext(); ){
+ Collection l = ((CollectionEntry)iter.next()).getValue();
+ c.addAll(l);
+ }
+ return c;
+ }
+
+ public void remove(Object key, Object value){
+ Collection c = get(key, false);
+ if(c != null){
+ if(c.remove(value) && c.size() == 0){
+ fMap.remove(key);
+ }
+ }
+ }
+
+// public Object get(Object key, int num){
+// Collection l = get(key, false);
+// if(l != null){
+// return l.get(num);
+// }
+// return null;
+// }
+
+// public Object remove(Object key, int num){
+// List l = get(key, false);
+// if(l != null){
+// Object result = null;
+// if(l.size() > num){
+// result = l.remove(num);
+// }
+//
+// return result;
+// }
+// return null;
+// }
+
+// public Object removeLast(Object key){
+// Collection l = get(key, false);
+// if(l != null){
+// Object result = null;
+// if(l.size() > 0){
+// result = l.remove(l.size() - 1);
+// }
+// return result;
+// }
+// return null;
+// }
+
+ public void removeAll(Object key, Collection values){
+ Collection c = get(key, false);
+ if(c != null){
+ if(c.removeAll(values) && c.size() == 0){
+ fMap.remove(key);
+ }
+ }
+ }
+
+ public void clearEmptyLists(){
+ for(Iterator iter = fMap.entrySet().iterator(); iter.hasNext(); ){
+ Map.Entry entry = (Map.Entry)iter.next();
+ if(((Collection)entry.getValue()).size() == 0)
+ iter.remove();
+ }
+ }
+
+ public Set collectionEntrySet(){
+ if(fCollectionEntrySet == null)
+ fCollectionEntrySet = new CollectionEntrySet();
+ return fCollectionEntrySet;
+ }
+
+ public void difference(CollectionMap map){
+ for(Iterator iter = map.fMap.entrySet().iterator(); iter.hasNext(); ){
+ Map.Entry entry = (Map.Entry)iter.next();
+ Collection thisC = (Collection)fMap.get(entry.getKey());
+ if(thisC != null){
+ if(thisC.removeAll((Collection)entry.getValue()) && thisC == null){
+ fMap.remove(entry.getKey());
+ }
+ }
+ }
+ }
+
+ public ValueIter valueIter(){
+ return new ValueIter();
+ }
+
+// protected Collection createCollection(Object key){
+// return new ArrayList(1);
+// }
+
+ public Object clone() {
+ try {
+ CollectionMap clone = (CollectionMap)super.clone();
+ clone.fMap = (HashMap)fMap.clone();
+ for(Iterator iter = clone.fMap.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ entry.setValue(cloneCollection((Collection)entry.getValue()));
+ }
+ } catch (CloneNotSupportedException e) {
+ ManagedBuilderCorePlugin.log(e);
+ }
+ return null;
+ }
+
+// protected Map getMap(boolean create){
+// if(fMap == null && create)
+// fMap = createMap();
+// return fMap;
+// }
+//
+// protected Map createMap(){
+// return new HashMap();
+// }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ConfigurationModification.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ConfigurationModification.java
new file mode 100644
index 00000000000..568afb4b555
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ConfigurationModification.java
@@ -0,0 +1,201 @@
+/*******************************************************************************
+ * 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.managedbuilder.internal.tcmodification;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.core.Builder;
+import org.eclipse.cdt.managedbuilder.internal.core.FolderInfo;
+import org.eclipse.cdt.managedbuilder.internal.core.IRealBuildObjectAssociation;
+import org.eclipse.cdt.managedbuilder.internal.tcmodification.ToolChainModificationManager.ConflictMatchSet;
+import org.eclipse.cdt.managedbuilder.tcmodification.CompatibilityStatus;
+import org.eclipse.cdt.managedbuilder.tcmodification.IConfigurationModification;
+import org.eclipse.core.runtime.IStatus;
+
+public class ConfigurationModification extends FolderInfoModification implements
+ IConfigurationModification {
+ private IBuilder fSelectedBuilder;
+ private IBuilder fRealBuilder;
+ private boolean fCompatibilityInfoInited;
+ private Map fCompatibleBuilders;
+ private Map fInCompatibleBuilders;
+ private ConflictMatchSet fConflicts;
+ private IBuilder[] fAllSysBuilders;
+ private BuilderCompatibilityInfoElement fCurrentBuilderCompatibilityInfo;
+
+
+ public static class BuilderCompatibilityInfoElement {
+ private Builder fBuilder;
+ private List fErrComflictMatchList;
+ private CompatibilityStatus fStatus;
+
+ BuilderCompatibilityInfoElement(Builder builder, List errConflictList){
+ fBuilder = builder;
+ if(errConflictList != null && errConflictList.size() != 0)
+ fErrComflictMatchList = errConflictList;
+ }
+
+ public CompatibilityStatus getCompatibilityStatus(){
+ if(fStatus == null){
+ int severity;
+ String message;
+ if(fErrComflictMatchList != null){
+ severity = IStatus.ERROR;
+ message = Messages.getString("ConfigurationModification.0"); //$NON-NLS-1$
+ } else {
+ severity = IStatus.OK;
+ message = ""; //$NON-NLS-1$
+ }
+ fStatus = new CompatibilityStatus(severity, message, new ConflictSet(fBuilder, fErrComflictMatchList, null));
+ }
+ return fStatus;
+ }
+
+ public boolean isCompatible(){
+ return fErrComflictMatchList == null;
+ }
+ }
+
+ public ConfigurationModification(FolderInfo foInfo) {
+ super(foInfo);
+
+ setBuilder(foInfo.getParent().getBuilder());
+ }
+
+ public IBuilder getBuilder() {
+ return fSelectedBuilder;
+ }
+
+ public IBuilder getRealBuilder() {
+ return fRealBuilder;
+ }
+
+ public CompatibilityStatus getBuilderCompatibilityStatus() {
+ return getCurrentBuilderCompatibilityInfo().getCompatibilityStatus();
+ }
+
+ private ConflictMatchSet getParentConflictMatchSet(){
+ if(fConflicts == null){
+ PerTypeMapStorage storage = getCompleteObjectStore();
+ Object restore = TcModificationUtil.removeBuilderInfo(storage, fRealBuilder);
+ try {
+ fConflicts = ToolChainModificationManager.getInstance().getConflictInfo(IRealBuildObjectAssociation.OBJECT_BUILDER, storage);
+ } finally {
+ if(restore != null)
+ TcModificationUtil.restoreBuilderInfo(storage, fRealBuilder, restore);
+ }
+ }
+ return fConflicts;
+ }
+
+ private IBuilder[] getAllSysBuilders(){
+ if(fAllSysBuilders == null)
+ fAllSysBuilders = ManagedBuildManager.getRealBuilders();
+ return fAllSysBuilders;
+ }
+
+ private void initCompatibilityInfo(){
+ if(fCompatibilityInfoInited)
+ return;
+
+ fCompatibleBuilders = new HashMap();
+ fInCompatibleBuilders = new HashMap();
+ ConflictMatchSet conflicts = getParentConflictMatchSet();
+ Builder sysBs[] = (Builder[])getAllSysBuilders();
+ Map conflictMap = conflicts.fObjToConflictListMap;
+ for(int i = 0; i < sysBs.length; i++){
+ Builder b = sysBs[i];
+ List l = (List)conflictMap.get(b);
+ BuilderCompatibilityInfoElement info = new BuilderCompatibilityInfoElement(b, l);
+ if(info.isCompatible()){
+ fCompatibleBuilders.put(b, info);
+ } else {
+ fInCompatibleBuilders.put(b, info);
+ }
+ }
+
+ fCompatibilityInfoInited = true;
+ }
+
+ private BuilderCompatibilityInfoElement getCurrentBuilderCompatibilityInfo(){
+ if(fCurrentBuilderCompatibilityInfo == null){
+ initCompatibilityInfo();
+ BuilderCompatibilityInfoElement info = (BuilderCompatibilityInfoElement)fCompatibleBuilders.get(fRealBuilder);
+ if(info == null)
+ info = (BuilderCompatibilityInfoElement)fInCompatibleBuilders.get(fRealBuilder);
+ fCurrentBuilderCompatibilityInfo = info;
+ }
+ return fCurrentBuilderCompatibilityInfo;
+ }
+
+ public IBuilder[] getCompatibleBuilders() {
+ initCompatibilityInfo();
+ List l = new ArrayList(fCompatibleBuilders.size());
+ IConfiguration cfg = getResourceInfo().getParent();
+
+ for(Iterator iter = fCompatibleBuilders.keySet().iterator(); iter.hasNext(); ){
+ Builder b = (Builder)iter.next();
+ if(b != fRealBuilder && cfg.isBuilderCompatible(b))
+ l.add(b);
+ }
+ return (Builder[])l.toArray(new Builder[l.size()]);
+ }
+
+ public boolean isBuilderCompatible() {
+ return getCurrentBuilderCompatibilityInfo().isCompatible();
+ }
+
+ public void setBuilder(IBuilder builder) {
+ if(builder == fSelectedBuilder)
+ return;
+
+ fSelectedBuilder = builder;
+ IBuilder realBuilder = ManagedBuildManager.getRealBuilder(builder);
+ if(realBuilder == fRealBuilder)
+ return;
+
+ fRealBuilder = realBuilder;
+
+ PerTypeMapStorage storage = getCompleteObjectStore();
+ TcModificationUtil.applyBuilder(storage, getResourceInfo().getPath(), fSelectedBuilder);
+
+ clearBuilderCompatibilityInfo();
+ clearToolChainCompatibilityInfo();
+ clearToolCompatibilityInfo();
+ }
+
+ public void setToolChain(IToolChain tc) {
+ setBuilder(tc.getBuilder());
+ super.setToolChain(tc);
+ }
+
+ public void changeProjectTools(ITool removeTool, ITool addTool) {
+ clearBuilderCompatibilityInfo();
+ super.changeProjectTools(removeTool, addTool);
+ }
+
+ protected void clearBuilderCompatibilityInfo(){
+ fInCompatibleBuilders = null;
+ fCompatibleBuilders = null;
+ fCompatibilityInfoInited = false;
+ fCurrentBuilderCompatibilityInfo = null;
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ConflictSet.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ConflictSet.java
new file mode 100644
index 00000000000..4ac4a574ad0
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ConflictSet.java
@@ -0,0 +1,188 @@
+/*******************************************************************************
+ * 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.managedbuilder.internal.tcmodification;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import org.eclipse.cdt.managedbuilder.core.IBuildObject;
+import org.eclipse.cdt.managedbuilder.internal.core.IRealBuildObjectAssociation;
+import org.eclipse.cdt.managedbuilder.internal.tcmodification.ToolChainModificationManager.ConflictMatch;
+import org.eclipse.cdt.managedbuilder.tcmodification.IConflict;
+import org.eclipse.core.runtime.IPath;
+
+public class ConflictSet {
+ public static final IConflict[] EMPTY_CONFLICT_ARRAY = new IConflict[0];
+ public static final IRealBuildObjectAssociation[] EMPTY_BO_ARRAY = new IRealBuildObjectAssociation[0];
+
+ private PerTypeMapStorage fConflictStorage;
+ private List fConflictMatchList;
+ private Set fExtConflictSet;
+ private IRealBuildObjectAssociation fRealObj;
+
+ public ConflictSet(IRealBuildObjectAssociation realObj, List conflictMatchList, Set extConflictSet){
+ fConflictMatchList = conflictMatchList;
+ fExtConflictSet = extConflictSet;
+ fRealObj = realObj;
+ }
+
+ private void init(){
+ if(fConflictStorage == null){
+ fConflictStorage = new PerTypeMapStorage();
+ if(fConflictMatchList != null && fConflictMatchList.size() != 0){
+ int size = fConflictMatchList.size();
+ PerTypeMapStorage result = new PerTypeMapStorage();
+ for(int i = 0; i < size; i++){
+ ConflictMatch match = (ConflictMatch)fConflictMatchList.get(i);
+ int objType = match.fMatchType;
+ Map cm = match.fRObjToPathMap;
+ Map cur = result.getMap(objType, true);
+
+ for(Iterator iter = cm.entrySet().iterator(); iter.hasNext(); ){
+ Map.Entry entry = (Map.Entry)iter.next();
+ Object obj = entry.getKey();
+ if(DbgTcmUtil.DEBUG){
+ if(((IRealBuildObjectAssociation)obj).getType() != objType)
+ DbgTcmUtil.fail();
+ }
+
+ TreeSet set = (TreeSet)cur.get(obj);
+ if(set == null){
+ set = new TreeSet(PathComparator.INSTANCE);
+ cur.put(obj, set);
+ }
+
+ set.addAll((Set)entry.getValue());
+ }
+ }
+
+ int types[] = ObjectTypeBasedStorage.getSupportedObjectTypes();
+ for(int i = 0; i < types.length; i++){
+ int type = types[i];
+ Map map = result.getMap(type, false);
+ if(map == null)
+ continue;
+
+ for(Iterator iter = map.entrySet().iterator(); iter.hasNext(); ){
+ Map.Entry entry = (Map.Entry)iter.next();
+
+ IRealBuildObjectAssociation obj = (IRealBuildObjectAssociation)entry.getKey();
+ TreeSet set = (TreeSet)entry.getValue();
+
+ Map cMap = fConflictStorage.getMap(type, true);
+ cMap.put(obj, new Conflict(IConflict.INCOMPATIBLE, obj, set));
+ }
+ }
+
+ }
+ }
+ }
+
+ private static class Conflict implements IConflict {
+ private IRealBuildObjectAssociation fObj;
+ private SortedSet fPathSet;
+ private int fType;
+
+ Conflict(int type, IRealBuildObjectAssociation obj, SortedSet paths){
+ fType = type;
+ fObj = obj;
+ fPathSet = paths;
+ }
+
+ public IBuildObject getBuildObject() {
+ return fObj;
+ }
+
+ public int getConflictType() {
+ return fType;
+ }
+
+ public int getObjectType() {
+ return fObj.getType();
+ }
+
+ public IPath[] getPaths() {
+ return (IPath[])fPathSet.toArray(new IPath[fPathSet.size()]);
+ }
+ }
+
+ public IConflict[] getConflicts(){
+ init();
+ int types[] = ObjectTypeBasedStorage.getSupportedObjectTypes();
+ List list = new ArrayList();
+ for(int i = 0; i < types.length; i++){
+ Map map = fConflictStorage.getMap(types[i], false);
+ if(map == null)
+ continue;
+
+ getConflicts(map, list);
+ }
+
+ return conflictArray(list);
+ }
+
+ private static List getConflicts(Map map, List list){
+ if(list == null)
+ list = new ArrayList();
+
+ for(Iterator iter = map.values().iterator(); iter.hasNext(); ){
+ list.add(iter.next());
+ }
+
+ return list;
+ }
+
+ private static Conflict[] conflictArray(Collection list){
+ return (Conflict[])list.toArray(new Conflict[list.size()]);
+ }
+
+ private static IRealBuildObjectAssociation[] objArray(Collection list){
+ return (IRealBuildObjectAssociation[])list.toArray(new IRealBuildObjectAssociation[list.size()]);
+ }
+
+ public IConflict[] getConflictsWith(int objectType){
+ init();
+ Map map = fConflictStorage.getMap(objectType, false);
+ if(map == null)
+ return EMPTY_CONFLICT_ARRAY;
+
+
+ return conflictArray(map.values());
+ }
+
+ public IBuildObject[] getConflictingObjects(int objectType){
+ init();
+ Map map = fConflictStorage.getMap(objectType, false);
+ if(map == null)
+ return EMPTY_BO_ARRAY;
+
+ return objArray(map.keySet());
+ }
+
+ public IConflict getConflictWith(IBuildObject bo){
+ init();
+ if(!(bo instanceof IRealBuildObjectAssociation))
+ return null;
+
+ IRealBuildObjectAssociation obj = (IRealBuildObjectAssociation)bo;
+ Map map = fConflictStorage.getMap(obj.getType(), false);
+ if(map == null)
+ return null;
+
+ return (IConflict)map.get(obj);
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/DbgTcmUtil.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/DbgTcmUtil.java
new file mode 100644
index 00000000000..2c1b89bba90
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/DbgTcmUtil.java
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * 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.managedbuilder.internal.tcmodification;
+
+import java.io.PrintStream;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.cdt.managedbuilder.internal.core.IRealBuildObjectAssociation;
+import org.eclipse.cdt.managedbuilder.internal.tcmodification.extension.MatchObjectElement;
+
+public class DbgTcmUtil {
+ private static final PrintStream OUT = System.out;
+ public static boolean DEBUG = true;
+
+ private DbgTcmUtil(){
+ }
+ public static final class DbgException extends RuntimeException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ private DbgException() {
+ super();
+ }
+
+ private DbgException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ private DbgException(String message) {
+ super(message);
+ }
+
+ private DbgException(Throwable cause) {
+ super(cause);
+ }
+ }
+
+ public static void print(String str){
+ OUT.print(str);
+ }
+
+ public static void println(String str){
+ OUT.println(str);
+ }
+
+ public static void fail(String msg){
+ println(msg);
+ throw new DbgException(msg);
+ }
+
+ public static void fail(){
+ DbgException e = new DbgException();
+ e.printStackTrace(OUT);
+ throw e;
+ }
+
+ public static void dumpStorage(PerTypeMapStorage storage){
+ println("starting storage dump.."); //$NON-NLS-1$
+ int[] types = ObjectTypeBasedStorage.getSupportedObjectTypes();
+ for(int i = 0; i < types.length; i++){
+ int type = types[i];
+ MatchObjectElement.TypeToStringAssociation assoc = MatchObjectElement.TypeToStringAssociation.getAssociation(type);
+ if(assoc == null)
+ continue;
+
+ println(" dumping for type " + assoc.getString()); //$NON-NLS-1$
+
+ Map map = storage.getMap(type, false);
+ if(map != null){
+ for(Iterator iter = map.entrySet().iterator(); iter.hasNext(); ){
+ Map.Entry entry = (Map.Entry)iter.next();
+ IRealBuildObjectAssociation obj = (IRealBuildObjectAssociation)entry.getKey();
+ println(" dumping " + assoc.getString() + " " + obj.getUniqueRealName()); //$NON-NLS-1$ //$NON-NLS-2$
+ Set set = (Set)entry.getValue();
+ if(set != null){
+ for(Iterator setIter = set.iterator(); setIter.hasNext(); ){
+ println(" path \"" + setIter.next() + "\""); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ println(" end dumping " + obj.getUniqueRealName()); //$NON-NLS-1$
+ }
+ }
+
+ println(" end type " + assoc.getString()); //$NON-NLS-1$
+ }
+ println("end storage dump"); //$NON-NLS-1$
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/FileInfoModification.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/FileInfoModification.java
new file mode 100644
index 00000000000..40424b73338
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/FileInfoModification.java
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * 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.managedbuilder.internal.tcmodification;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.internal.core.ResourceConfiguration;
+import org.eclipse.cdt.managedbuilder.internal.core.Tool;
+import org.eclipse.cdt.managedbuilder.tcmodification.IFileInfoModification;
+import org.eclipse.core.resources.IProject;
+
+public class FileInfoModification extends
+ ToolListModification implements IFileInfoModification {
+ private String fFileExt;
+ private Set fApplPathSet;
+ private IProject fProject;
+
+ public FileInfoModification(ResourceConfiguration rcInfo) {
+ super(rcInfo, rcInfo.getTools());
+ }
+
+ protected boolean canRemove(ITool realTool) {
+ return true;
+ }
+
+ protected boolean canAdd(Tool tool) {
+ String ext = getFileExtension();
+ return tool.buildsFileType(ext, getProject());
+ }
+
+ protected boolean canReplace(Tool fromTool, Tool toTool) {
+ String ext = getFileExtension();
+ return toTool.buildsFileType(ext, getProject());
+ }
+
+ protected Set getToolApplicabilityPathSet(Tool realTool, boolean isProject) {
+ if(fApplPathSet == null){
+ Set s = new HashSet(1);
+ s.add(getResourceInfo().getPath());
+ fApplPathSet = Collections.unmodifiableSet(s);
+ }
+ return fApplPathSet;
+ }
+
+ protected Set getExtensionConflictToolSet(Tool tool, Tool[] toos) {
+ return Collections.EMPTY_SET;
+ }
+
+ protected Tool[] filterTools(Tool[] tools) {
+ return tools;
+ }
+
+ private String getFileExtension(){
+ if(fFileExt == null){
+ fFileExt = getResourceInfo().getPath().getFileExtension();
+ if(fFileExt == null)
+ fFileExt = ""; //$NON-NLS-1$
+ }
+ return fFileExt;
+ }
+
+ private IProject getProject(){
+ if(fProject == null){
+ fProject = getResourceInfo().getParent().getOwner().getProject();
+ }
+ return fProject;
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/FolderInfoModification.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/FolderInfoModification.java
new file mode 100644
index 00000000000..4893bd96aae
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/FolderInfoModification.java
@@ -0,0 +1,415 @@
+/*******************************************************************************
+ * 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.managedbuilder.internal.tcmodification;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import org.eclipse.cdt.managedbuilder.core.IManagedProject;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.core.FolderInfo;
+import org.eclipse.cdt.managedbuilder.internal.core.IRealBuildObjectAssociation;
+import org.eclipse.cdt.managedbuilder.internal.core.Tool;
+import org.eclipse.cdt.managedbuilder.internal.core.ToolChain;
+import org.eclipse.cdt.managedbuilder.internal.tcmodification.ToolChainModificationManager.ConflictMatchSet;
+import org.eclipse.cdt.managedbuilder.tcmodification.CompatibilityStatus;
+import org.eclipse.cdt.managedbuilder.tcmodification.IFolderInfoModification;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+
+public class FolderInfoModification extends ToolListModification implements IFolderInfoModification {
+ private ToolChain fRealToolChain;
+ private ToolChainCompatibilityInfoElement fCurrentCompatibilityInfo;
+ private ToolChain fSelectedToolChain;
+ private IToolChain[] fAllSysToolChains;
+ private Map fCompatibleToolChains;
+ private Map fInCompatibleToolChains;
+ private PerTypeMapStorage fParentObjectStorage;
+ private ConflictMatchSet fParentConflicts;
+// private PerTypeMapStorage fChildObjectStorage;
+// private ConflictMatchSet fChildConflicts;
+ private boolean fCompatibilityInfoInited;
+ private ToolChainApplicabilityPaths fTcApplicabilityPaths;
+
+ public FolderInfoModification(FolderInfo foInfo) {
+ super(foInfo, foInfo.getTools());
+ fSelectedToolChain = (ToolChain)foInfo.getToolChain();
+ fRealToolChain = (ToolChain)ManagedBuildManager.getRealToolChain(fSelectedToolChain);
+ }
+
+ private ConflictMatchSet getParentConflictMatchSet(){
+ if(fParentConflicts == null){
+ PerTypeMapStorage storage = getParentObjectStorage();
+ fParentConflicts = ToolChainModificationManager.getInstance().getConflictInfo(IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, storage);
+ }
+ return fParentConflicts;
+ }
+
+ private PerTypeMapStorage getParentObjectStorage(){
+ if(fParentObjectStorage == null){
+ fParentObjectStorage = TcModificationUtil.createParentObjectsRealToolToPathSet((FolderInfo)getResourceInfo());
+ }
+ return fParentObjectStorage;
+ }
+
+ private IToolChain[] getAllSysToolChains(){
+ if(fAllSysToolChains == null)
+ fAllSysToolChains = ManagedBuildManager.getRealToolChains();
+ return fAllSysToolChains;
+ }
+
+ private static class ToolChainApplicabilityPaths {
+ private Set fFileInfoPaths = new HashSet();
+ private Set fFolderInfoPaths = new HashSet();
+ private Map fToolPathMap = new HashMap();
+ }
+
+ public static class ToolChainCompatibilityInfoElement {
+ private ToolChain fTc;
+ private List fErrComflictMatchList;
+ private List fWarningConflictMatchList;
+ private CompatibilityStatus fStatus;
+
+ ToolChainCompatibilityInfoElement(ToolChain tc, List errConflictList){
+ fTc = tc;
+ if(errConflictList != null && errConflictList.size() != 0)
+ fErrComflictMatchList = errConflictList;
+ }
+
+ public CompatibilityStatus getCompatibilityStatus(){
+ if(fStatus == null){
+ int severity;
+ String message;
+ if(fErrComflictMatchList != null){
+ severity = IStatus.ERROR;
+ message = Messages.getString("FolderInfoModification.0"); //$NON-NLS-1$
+ } else {
+ severity = IStatus.OK;
+ message = ""; //$NON-NLS-1$
+ }
+ fStatus = new CompatibilityStatus(severity, message, new ConflictSet(fTc, fErrComflictMatchList, null));
+ }
+ return fStatus;
+ }
+
+ public boolean isCompatible(){
+ return fErrComflictMatchList == null;
+ }
+ }
+
+ public IToolChain[] getCompatibleToolChains(){
+ initCompatibilityInfo();
+ FolderInfo foInfo = (FolderInfo)getResourceInfo();
+
+ List l = new ArrayList(fCompatibleToolChains.size());
+ for(Iterator iter = fCompatibleToolChains.keySet().iterator(); iter.hasNext(); ){
+ ToolChain tc = (ToolChain)iter.next();
+
+ if(tc != fRealToolChain && foInfo.isToolChainCompatible(fRealToolChain, tc))
+ l.add(tc);
+ }
+ return (ToolChain[])l.toArray(new ToolChain[l.size()]);
+ }
+
+ public CompatibilityStatus getToolChainCompatibilityStatus(){
+ return getCurrentCompatibilityInfo().getCompatibilityStatus();
+ }
+
+ private ToolChainCompatibilityInfoElement getCurrentCompatibilityInfo(){
+ if(fCurrentCompatibilityInfo == null){
+ initCompatibilityInfo();
+ ToolChainCompatibilityInfoElement info = (ToolChainCompatibilityInfoElement)fCompatibleToolChains.get(fRealToolChain);
+ if(info == null)
+ info = (ToolChainCompatibilityInfoElement)fInCompatibleToolChains.get(fRealToolChain);
+ fCurrentCompatibilityInfo = info;
+ }
+ return fCurrentCompatibilityInfo;
+ }
+
+ public boolean isToolChainCompatible(){
+ return getCurrentCompatibilityInfo().isCompatible();
+ }
+
+ private void initCompatibilityInfo(){
+ if(fCompatibilityInfoInited)
+ return;
+
+ fCompatibleToolChains = new HashMap();
+ fInCompatibleToolChains = new HashMap();
+ ConflictMatchSet parentConflicts = getParentConflictMatchSet();
+ ToolChain sysTCs[] = (ToolChain[])getAllSysToolChains();
+
+ Map conflictMap = parentConflicts.fObjToConflictListMap;
+ for(int i = 0; i < sysTCs.length; i++){
+ ToolChain tc = sysTCs[i];
+ List l = (List)conflictMap.get(tc);
+ ToolChainCompatibilityInfoElement info = new ToolChainCompatibilityInfoElement(tc, l);
+ if(info.isCompatible()){
+ fCompatibleToolChains.put(tc, info);
+ } else {
+ fInCompatibleToolChains.put(tc, info);
+ }
+ }
+
+ fCompatibilityInfoInited = true;
+ }
+
+ public IToolChain getToolChain(){
+ return fSelectedToolChain;
+ }
+
+ public void setToolChain(IToolChain tc){
+ if(tc == fSelectedToolChain)
+ return;
+
+ fSelectedToolChain = (ToolChain)tc;
+ IToolChain newReal = ManagedBuildManager.getRealToolChain(tc);
+ if(newReal == fRealToolChain)
+ return;
+
+ fRealToolChain = (ToolChain)newReal;
+
+// setProjectTools(tc.getTools());
+ applyToolChain(fSelectedToolChain);
+ clearToolInfo(tc.getTools());
+ fCurrentCompatibilityInfo = null;
+
+ }
+
+ protected void clearToolChainCompatibilityInfo(){
+ fCompatibilityInfoInited = false;
+ fCompatibleToolChains = null;
+ fInCompatibleToolChains = null;
+ fCurrentCompatibilityInfo = null;
+ }
+
+ protected boolean canRemove(ITool realTool) {
+ IToolChain extTc = ManagedBuildManager.getExtensionToolChain(fSelectedToolChain);
+ ITool[] tools = extTc.getTools();
+ for(int i = 0; i < tools.length; i++){
+ if(realTool == ManagedBuildManager.getRealTool(tools[i]))
+ return false;
+ }
+
+ return true;
+ }
+
+ protected boolean canAdd(Tool tool) {
+ return !TcModificationUtil.containCommonEntries(getInputExtsSet(), tool.getPrimaryInputExtensions());
+ }
+
+ protected boolean canReplace(Tool fromTool, Tool toTool) {
+ String[] exts = toTool.getPrimaryInputExtensions();
+ Set curInputExts = null;
+ Set inputExts = getInputExtsSet();
+ for(int k = 0; k < exts.length; k++){
+ if(inputExts.contains(exts[k])){
+ if(curInputExts == null)
+ curInputExts = new HashSet(Arrays.asList(fromTool.getPrimaryInputExtensions()));
+
+ if(curInputExts.contains(exts[k])){
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ protected Set getExtensionConflictToolSet(Tool tool, Tool[] tools) {
+ String exts[] = tool.getPrimaryInputExtensions();
+ Set extsSet = new HashSet(Arrays.asList(exts));
+ Set conflictsSet = null;
+ for(int i = 0; i < tools.length; i++){
+ Tool t = tools[i];
+ if(t == tool)
+ continue;
+ if(TcModificationUtil.containCommonEntries(extsSet, t.getPrimaryInputExtensions())){
+ if(conflictsSet == null)
+ conflictsSet = new HashSet();
+
+ conflictsSet.add(t);
+ }
+
+ }
+
+ if(conflictsSet == null)
+ conflictsSet = Collections.EMPTY_SET;
+ return conflictsSet;
+ }
+
+ protected Set getToolApplicabilityPathSet(Tool realTool, boolean isProject) {
+ if(isProject)
+ return (Set)getToolChainApplicabilityPaths().fToolPathMap.get(realTool);
+ return getToolChainApplicabilityPaths().fFolderInfoPaths;
+ }
+
+ protected Tool[] filterTools(Tool[] tools) {
+ IResourceInfo rcInfo = getResourceInfo();
+ return (Tool[])((FolderInfo)rcInfo).filterTools(tools, rcInfo.getParent().getManagedProject());
+ }
+
+ private ToolChainApplicabilityPaths getToolChainApplicabilityPaths(){
+ initToolChainApplicabilityPaths();
+ return fTcApplicabilityPaths;
+ }
+
+ private void initToolChainApplicabilityPaths(){
+ if(fTcApplicabilityPaths != null)
+ return;
+
+ ToolChainApplicabilityPaths tcApplicabilityPaths = new ToolChainApplicabilityPaths();
+ IPath path = getResourceInfo().getPath();
+
+ TreeMap pathMap = getCompletePathMapStorage();
+
+ PerTypeSetStorage oSet = (PerTypeSetStorage)pathMap.get(path);
+ Set toolSet = oSet.getSet(IRealBuildObjectAssociation.OBJECT_TOOL, false);
+ Set tcSet = oSet.getSet(IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, false);
+
+ ToolChain curTc = (ToolChain)tcSet.iterator().next();
+
+ Set foInfoPaths = tcApplicabilityPaths.fFolderInfoPaths;
+ Set fileInfoPaths = tcApplicabilityPaths.fFileInfoPaths;
+
+ foInfoPaths.add(path);
+
+ Map toolPathsMap = tcApplicabilityPaths.fToolPathMap;
+ for(Iterator iter = toolSet.iterator(); iter.hasNext(); ){
+ Set set = new HashSet();
+ toolPathsMap.put(iter.next(), set);
+ set.add(path);
+ }
+
+ calculateChildPaths(pathMap, path, curTc, foInfoPaths, toolPathsMap, fileInfoPaths);
+
+ fTcApplicabilityPaths = tcApplicabilityPaths;
+ }
+
+ protected void clearToolInfo(ITool[] tools){
+ super.clearToolInfo(tools);
+ fTcApplicabilityPaths = null;
+ }
+
+ private static void putToolInfo(Set ct, Map toolPathsMap, Set fileInfoPaths, Object p){
+ if(ct != null && ct.size() != 0){
+ for(Iterator toolIter = ct.iterator(); toolIter.hasNext(); ){
+ Object t = toolIter.next();
+ Set set = (Set)toolPathsMap.get(t);
+ if(set != null){
+ if(fileInfoPaths != null)
+ fileInfoPaths.add(p);
+ set.add(p);
+ }
+ }
+ }
+ }
+
+ private static void calculateChildPaths(TreeMap pathMap, IPath path, ToolChain tc, Set tcPaths, Map toolPathsMap, Set fileInfoPaths){
+ SortedMap directCMap = PathComparator.getDirectChildPathMap(pathMap, path);
+ for(Iterator iter = directCMap.entrySet().iterator(); iter.hasNext(); ){
+ Map.Entry entry = (Map.Entry)iter.next();
+ PerTypeSetStorage cst = (PerTypeSetStorage)entry.getValue();
+
+ Set ctc = cst.getSet(IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, false);
+ Set ct = cst.getSet(IRealBuildObjectAssociation.OBJECT_TOOL, false);
+
+
+ if(ctc == null || ctc.size() == 0){
+ //fileInfo, check for tools
+ putToolInfo(ct, toolPathsMap, fileInfoPaths, entry.getKey());
+ } else {
+ if(ctc.contains(tc)){
+ IPath cp = (IPath)entry.getKey();
+ tcPaths.add(cp);
+ putToolInfo(ct, toolPathsMap, null, entry.getKey());
+ //recurse
+ calculateChildPaths(pathMap, cp, tc, tcPaths, toolPathsMap, fileInfoPaths);
+ }
+ }
+ }
+ }
+
+ private void applyToolChain(ToolChain newNonRealTc){
+ ToolChain newRealTc = (ToolChain)ManagedBuildManager.getRealToolChain(newNonRealTc);
+
+ ToolChainApplicabilityPaths tcApplicability = getToolChainApplicabilityPaths();
+ PerTypeMapStorage storage = getCompleteObjectStore();
+
+ Map tcMap = storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, false);
+ Map toolMap = storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOL, false);
+
+
+ TcModificationUtil.removePaths(tcMap, fRealToolChain, tcApplicability.fFolderInfoPaths);
+ TcModificationUtil.addPaths(tcMap, newRealTc, tcApplicability.fFolderInfoPaths);
+ Tool[] newTools = (Tool[])newNonRealTc.getTools();
+
+ for(int i = 0; i < newTools.length; i++){
+ newTools[i] = (Tool)ManagedBuildManager.getRealTool(newTools[i]);
+ }
+
+ for(int i = 0; i < newTools.length; i++){
+ TcModificationUtil.addPaths(toolMap, newTools[i], tcApplicability.fFolderInfoPaths);
+ }
+
+ for(Iterator iter = tcApplicability.fToolPathMap.entrySet().iterator(); iter.hasNext(); ){
+ Map.Entry entry = (Map.Entry)iter.next();
+ Tool tool = (Tool)entry.getKey();
+ Set pathSet = (Set)entry.getValue();
+
+ TcModificationUtil.removePaths(toolMap, tool, pathSet);
+ }
+
+ if(tcApplicability.fFileInfoPaths.size() != 0){
+ FolderInfo foInfo = (FolderInfo)getResourceInfo();
+ IManagedProject mProj = foInfo.getParent().getManagedProject();
+ IProject project = mProj.getOwner().getProject();
+ Tool[] filtered = (Tool[])foInfo.filterTools(newTools, mProj);
+ if(filtered.length != 0){
+ for(Iterator iter = tcApplicability.fFileInfoPaths.iterator(); iter.hasNext(); ){
+ IPath p = (IPath)iter.next();
+ boolean found = false;
+ String ext = p.getFileExtension();
+ if(ext == null)
+ ext = ""; //$NON-NLS-1$
+ for(int i = 0; i < filtered.length; i++){
+ if(filtered[i].buildsFileType(ext, project)){
+ TcModificationUtil.addPath(toolMap, filtered[i], p);
+ found = true;
+ break;
+ }
+ }
+
+ if(!found){
+ if (DbgTcmUtil.DEBUG){
+ DbgTcmUtil.println("no tools found for path " + p); //$NON-NLS-1$
+ }
+ }
+ }
+
+ } else if (DbgTcmUtil.DEBUG){
+ DbgTcmUtil.println("no filtered tools"); //$NON-NLS-1$
+ }
+ }
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/HashSetMap.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/HashSetMap.java
new file mode 100644
index 00000000000..5287c8447bc
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/HashSetMap.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * 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.managedbuilder.internal.tcmodification;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+public class HashSetMap extends CollectionMap {
+
+ protected Collection cloneCollection(Collection l) {
+ return (Collection)((HashSet)l).clone();
+ }
+
+ protected Collection newCollection(int size) {
+ return new HashSet();
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/IObjectSet.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/IObjectSet.java
new file mode 100644
index 00000000000..be9b45bc1d4
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/IObjectSet.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * 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.managedbuilder.internal.tcmodification;
+
+import java.util.Collection;
+
+import org.eclipse.cdt.managedbuilder.internal.core.IRealBuildObjectAssociation;
+
+
+public interface IObjectSet {
+
+ int getObjectType();
+
+ IRealBuildObjectAssociation[] getRealBuildObjects();
+
+ Collection getRealBuildObjects(Collection list);
+
+ boolean matchesObject(IRealBuildObjectAssociation obj);
+
+ boolean retainMatches(Collection collection);
+
+ public int getNumObjects();
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/LinkedHashSetMap.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/LinkedHashSetMap.java
new file mode 100644
index 00000000000..be0b600885d
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/LinkedHashSetMap.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * 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.managedbuilder.internal.tcmodification;
+
+import java.util.Collection;
+import java.util.LinkedHashSet;
+
+public class LinkedHashSetMap extends CollectionMap {
+
+ protected Collection cloneCollection(Collection l) {
+ return (Collection)((LinkedHashSet)l).clone();
+ }
+
+ protected Collection newCollection(int size) {
+ return new LinkedHashSet();
+ }
+
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ListMap.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ListMap.java
new file mode 100644
index 00000000000..1242b1b7ca0
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ListMap.java
@@ -0,0 +1,290 @@
+/*******************************************************************************
+ * 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.managedbuilder.internal.tcmodification;
+
+import java.lang.reflect.Array;
+import java.util.AbstractSet;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+
+public class ListMap implements Cloneable {
+ private HashMap fMap;
+ private CollectionEntrySet fCollectionEntrySet;
+
+ public ListMap(){
+ fMap = new HashMap();
+ }
+
+ public class ValueIter {
+ private Map fIterMap;
+
+ public ValueIter() {
+ fIterMap = new HashMap(fMap);
+ for(Iterator iter = fIterMap.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ Collection c = (Collection)entry.getValue();
+ entry.setValue(c.iterator());
+ }
+ }
+
+ public Iterator get(Object key){
+ Iterator iter = (Iterator)fIterMap.get(key);
+ if(iter != null && !iter.hasNext()){
+ fIterMap.remove(key);
+ return null;
+ }
+ return iter;
+ }
+ }
+
+ public class CollectionEntry {
+ private Map.Entry fEntry;
+
+ CollectionEntry(Map.Entry entry){
+ fEntry = entry;
+ }
+
+ public Object getKey(){
+ return fEntry.getKey();
+ }
+
+ public List getValue(){
+ return (List)fEntry.getValue();
+ }
+
+ public boolean equals(Object obj) {
+ if(obj == this)
+ return true;
+
+ if(obj == null)
+ return false;
+
+ if(!(obj instanceof CollectionEntry))
+ return false;
+
+ return fEntry.equals(((CollectionEntry)obj).fEntry);
+ }
+
+ public int hashCode() {
+ return fEntry.hashCode();
+ }
+ }
+
+ private class CollectionEntrySet extends AbstractSet {
+ private Set fMapEntrySet;
+
+ private class Iter implements Iterator {
+ private Iterator fIter;
+
+ private Iter(){
+ fIter = fMapEntrySet.iterator();
+ }
+ public boolean hasNext() {
+ return fIter.hasNext();
+ }
+
+ public Object next() {
+ return new CollectionEntry((Map.Entry)fIter.next());
+ }
+
+ public void remove() {
+ fIter.remove();
+ }
+
+ }
+
+ private CollectionEntrySet(){
+ fMapEntrySet = fMap.entrySet();
+ }
+
+ public Iterator iterator() {
+ return new Iter();
+ }
+
+ public int size() {
+ return fMapEntrySet.size();
+ }
+ }
+
+
+ public void add(Object key, Object value){
+ List l = get(key, true);
+ l.add(value);
+ }
+
+ public List removeAll(Object key){
+ return (List)fMap.remove(key);
+ }
+
+ public List get(Object key, boolean create){
+ List l = (List)fMap.get(key);
+ if(l == null && create){
+ l = newList(1);
+ fMap.put(key, l);
+ }
+
+ return l;
+ }
+
+ public Collection valuesToCollection(Collection c){
+ if(c == null)
+ c = newList(20);
+
+ for(Iterator iter = fMap.values().iterator(); iter.hasNext(); ){
+ List l = (List)iter.next();
+ c.addAll(l);
+ }
+
+ return c;
+ }
+
+ public List getValues(){
+ return (List)valuesToCollection(null);
+ }
+
+ public Object[] getValuesArray(Class clazz){
+ List list = getValues();
+ Object[] result = (Object[])Array.newInstance(clazz, list.size());
+ return list.toArray(result);
+ }
+
+ protected List newList(int size){
+ return new ArrayList(size);
+ }
+
+ protected List cloneList(List l){
+ return (List)((ArrayList)l).clone();
+ }
+
+ public Collection putValuesToCollection(Collection c){
+ for(Iterator iter = collectionEntrySet().iterator(); iter.hasNext(); ){
+ List l = ((CollectionEntry)iter.next()).getValue();
+ c.addAll(l);
+ }
+ return c;
+ }
+
+ public void remove(Object key, Object value){
+ Collection c = get(key, false);
+ if(c != null){
+ if(c.remove(value) && c.size() == 0){
+ fMap.remove(key);
+ }
+ }
+ }
+
+ public Object get(Object key, int num){
+ List l = get(key, false);
+ if(l != null){
+ return l.get(num);
+ }
+ return null;
+ }
+
+ public Object remove(Object key, int num){
+ List l = get(key, false);
+ if(l != null){
+ Object result = null;
+ if(l.size() > num){
+ result = l.remove(num);
+ }
+
+ return result;
+ }
+ return null;
+ }
+
+ public Object removeLast(Object key){
+ List l = get(key, false);
+ if(l != null){
+ Object result = null;
+ if(l.size() > 0){
+ result = l.remove(l.size() - 1);
+ }
+ return result;
+ }
+ return null;
+ }
+
+ public void removeAll(Object key, Collection values){
+ Collection c = get(key, false);
+ if(c != null){
+ if(c.removeAll(values) && c.size() == 0){
+ fMap.remove(key);
+ }
+ }
+ }
+
+ public void clearEmptyLists(){
+ for(Iterator iter = fMap.entrySet().iterator(); iter.hasNext(); ){
+ Map.Entry entry = (Map.Entry)iter.next();
+ if(((List)entry.getValue()).size() == 0)
+ iter.remove();
+ }
+ }
+
+ public Set collectionEntrySet(){
+ if(fCollectionEntrySet == null)
+ fCollectionEntrySet = new CollectionEntrySet();
+ return fCollectionEntrySet;
+ }
+
+ public void difference(ListMap map){
+ for(Iterator iter = map.fMap.entrySet().iterator(); iter.hasNext(); ){
+ Map.Entry entry = (Map.Entry)iter.next();
+ Collection thisC = (Collection)fMap.get(entry.getKey());
+ if(thisC != null){
+ if(thisC.removeAll((Collection)entry.getValue()) && thisC == null){
+ fMap.remove(entry.getKey());
+ }
+ }
+ }
+ }
+
+ public ValueIter valueIter(){
+ return new ValueIter();
+ }
+
+// protected Collection createCollection(Object key){
+// return new ArrayList(1);
+// }
+
+ public Object clone() {
+ try {
+ ListMap clone = (ListMap)super.clone();
+ clone.fMap = (HashMap)fMap.clone();
+ for(Iterator iter = clone.fMap.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ entry.setValue(cloneList((List)entry.getValue()));
+ }
+ } catch (CloneNotSupportedException e) {
+ ManagedBuilderCorePlugin.log(e);
+ }
+ return null;
+ }
+
+// protected Map getMap(boolean create){
+// if(fMap == null && create)
+// fMap = createMap();
+// return fMap;
+// }
+//
+// protected Map createMap(){
+// return new HashMap();
+// }
+ } \ No newline at end of file
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/Messages.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/Messages.java
new file mode 100644
index 00000000000..fe29c622fd9
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/Messages.java
@@ -0,0 +1,22 @@
+package org.eclipse.cdt.managedbuilder.internal.tcmodification;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages {
+ private static final String BUNDLE_NAME = "org.eclipse.cdt.managedbuilder.internal.tcmodification.ToolChainModificationMessages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
+ .getBundle(BUNDLE_NAME);
+
+ private Messages() {
+ }
+
+ public static String getString(String key) {
+ try {
+ return RESOURCE_BUNDLE.getString(key);
+ } catch (MissingResourceException e) {
+ return '!' + key + '!';
+ }
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ObjectSet.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ObjectSet.java
new file mode 100644
index 00000000000..ec2cc619c05
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ObjectSet.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * 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.managedbuilder.internal.tcmodification;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.eclipse.cdt.managedbuilder.internal.core.IRealBuildObjectAssociation;
+import org.eclipse.cdt.managedbuilder.internal.tcmodification.extension.MatchObjectElement;
+
+public class ObjectSet implements IObjectSet {
+ private int fObjectType;
+ private Set fObjectSet;
+
+ public ObjectSet(int objectType, Set objectSet){
+ fObjectType = objectType;
+ fObjectSet = objectSet;
+ }
+
+ public final int getObjectType() {
+ return fObjectType;
+ }
+
+ public IRealBuildObjectAssociation[] getRealBuildObjects() {
+ return (IRealBuildObjectAssociation[])fObjectSet.toArray(new IRealBuildObjectAssociation[fObjectSet.size()]);
+ }
+
+ public Collection getRealBuildObjects(Collection set) {
+ if(set == null)
+ set = new HashSet();
+
+ set.addAll(fObjectSet);
+
+ return set;
+ }
+
+ public boolean matchesObject(IRealBuildObjectAssociation obj) {
+ return fObjectSet.contains(obj.getRealBuildObject());
+ }
+
+ public boolean retainMatches(Collection collection) {
+ return collection.retainAll(fObjectSet);
+ }
+
+ public int getNumObjects() {
+ return fObjectSet.size();
+ }
+
+ public String toString(){
+ StringBuffer buf = new StringBuffer();
+ buf.append(MatchObjectElement.TypeToStringAssociation.getAssociation(fObjectType).getString());
+ buf.append("["); //$NON-NLS-1$
+ boolean isFirst = true;
+ for(Iterator iter = fObjectSet.iterator(); iter.hasNext(); ){
+ if(isFirst){
+ buf.append(", "); //$NON-NLS-1$
+ isFirst = false;
+ }
+ buf.append(((IRealBuildObjectAssociation)iter.next()).getId());
+ }
+ buf.append("]"); //$NON-NLS-1$
+
+ return buf.toString();
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ObjectSetList.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ObjectSetList.java
new file mode 100644
index 00000000000..4ed5ca05b4d
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ObjectSetList.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * 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.managedbuilder.internal.tcmodification;
+
+
+public class ObjectSetList {
+ private IObjectSet[] fObjectSets;
+
+ public ObjectSetList(IObjectSet[] objects){
+ this(objects, true);
+ }
+
+ ObjectSetList(IObjectSet[] objects, boolean copy){
+ if(copy)
+ objects = (IObjectSet[])objects.clone();
+ fObjectSets = objects;
+ }
+
+ public IObjectSet[] getObjectSets(){
+ return (IObjectSet[])fObjectSets.clone();
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ObjectTypeBasedStorage.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ObjectTypeBasedStorage.java
new file mode 100644
index 00000000000..d215ddbc1b3
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ObjectTypeBasedStorage.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * 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.managedbuilder.internal.tcmodification;
+
+import org.eclipse.cdt.managedbuilder.internal.core.IRealBuildObjectAssociation;
+
+public final class ObjectTypeBasedStorage implements Cloneable {
+ private static final int TOOL_INDEX = 0;
+ private static final int TOOLCHAIN_INDEX = 1;
+ private static final int BUILDER_INDEX = 2;
+ private static final int CFG_INDEX = 3;
+ private static final int SIZE = 4;
+
+ private static final int[] OBJECT_TYPES = new int[]{
+ IRealBuildObjectAssociation.OBJECT_TOOL,
+ IRealBuildObjectAssociation.OBJECT_TOOLCHAIN,
+ IRealBuildObjectAssociation.OBJECT_BUILDER,
+ IRealBuildObjectAssociation.OBJECT_CONFIGURATION,
+ };
+
+ private Object fStorage[] = new Object[SIZE];
+
+ public static int[] getSupportedObjectTypes(){
+ return (int[])OBJECT_TYPES.clone();
+ }
+
+ private int getIndex(int type){
+ switch (type) {
+ case IRealBuildObjectAssociation.OBJECT_TOOL:
+ return TOOL_INDEX;
+ case IRealBuildObjectAssociation.OBJECT_TOOLCHAIN:
+ return TOOLCHAIN_INDEX;
+ case IRealBuildObjectAssociation.OBJECT_BUILDER:
+ return BUILDER_INDEX;
+ case IRealBuildObjectAssociation.OBJECT_CONFIGURATION:
+ return CFG_INDEX;
+ default:
+ throw new IllegalArgumentException();
+ }
+ }
+
+ private int getType(int index){
+ switch (index) {
+ case TOOL_INDEX:
+ return IRealBuildObjectAssociation.OBJECT_TOOL;
+ case TOOLCHAIN_INDEX:
+ return IRealBuildObjectAssociation.OBJECT_TOOLCHAIN;
+ case BUILDER_INDEX:
+ return IRealBuildObjectAssociation.OBJECT_BUILDER;
+ case CFG_INDEX:
+ return IRealBuildObjectAssociation.OBJECT_CONFIGURATION;
+ default:
+ throw new IllegalArgumentException();
+ }
+ }
+
+ public Object get(int type){
+ return fStorage[getIndex(type)];
+ }
+
+ public Object set(int type, Object value){
+ int index = getIndex(type);
+ Object oldValue = fStorage[index];
+ fStorage[index] = value;
+ return oldValue;
+ }
+
+ public Object clone(){
+ try {
+ ObjectTypeBasedStorage clone = (ObjectTypeBasedStorage)super.clone();
+ clone.fStorage = (Object[])fStorage.clone();
+ return clone;
+ } catch (CloneNotSupportedException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/PathComparator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/PathComparator.java
new file mode 100644
index 00000000000..19fc7e29c6e
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/PathComparator.java
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * 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.managedbuilder.internal.tcmodification;
+
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.SortedSet;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+import org.eclipse.core.runtime.IPath;
+
+public class PathComparator implements Comparator {
+ public static PathComparator INSTANCE = new PathComparator();
+// public static final SortedSet EMPTY_SET = Collections.unmodifiableSortedSet(new TreeSet(INSTANCE));
+// public static final SortedMap EMPTY_MAP = Collections.unmodifiableSortedMap(new TreeMap(INSTANCE));
+
+ private PathComparator(){
+ }
+
+ public int compare(Object arg0, Object arg1) {
+ if(arg0 == arg1)
+ return 0;
+
+ IPath path1 = (IPath)arg0;
+ IPath path2 = (IPath)arg1;
+
+ int length1 = path1.segmentCount();
+ int length2 = path2.segmentCount();
+ int i = 0;
+ for(; i < length1; i++){
+ if(i >= length2){
+ //path2 is a prefix of path1
+ return 1;
+ }
+ int comparison = path1.segment(i).compareTo(path2.segment(i));
+ if(comparison == 0)
+ continue;
+ //
+ return comparison;
+ }
+
+ if(length1 == length2){
+ //equal
+ return 0;
+ }
+ //path1 is a prefix of path2
+ return -1;
+ }
+
+ public static IPath getNext(IPath path){
+ if(path.segmentCount() == 0)
+ return null;
+ String newLast = path.lastSegment() + '\0';
+ return path.removeLastSegments(1).append(newLast);
+ }
+
+ public static IPath getFirstChild(IPath path){
+ return path.append("\0"); //$NON-NLS-1$
+ }
+
+ public static SortedMap getChildPathMap(SortedMap map, IPath path, boolean includeThis, boolean copy){
+ IPath start = includeThis ? path : getFirstChild(path);
+ IPath next = getNext(path);
+ SortedMap result = next != null ? map.subMap(start, next) : map.tailMap(start);
+ if(copy)
+ result = new TreeMap(result);
+ return result;
+ }
+
+ public static SortedSet getChildPathSet(SortedSet set, IPath path, boolean includeThis, boolean copy){
+ IPath start = includeThis ? path : getFirstChild(path);
+ IPath next = getNext(path);
+ SortedSet result = next != null ? set.subSet(start, next) : set.tailSet(start);
+ if(copy)
+ result = new TreeSet(result);
+ return result;
+ }
+
+ public static SortedSet getDirectChildPathSet(SortedSet set, IPath path){
+ //all children
+ SortedSet children = getChildPathSet(set, path, false, false);
+ SortedSet result = new TreeSet(INSTANCE);
+ for(Iterator iter = children.iterator(); iter.hasNext(); iter = children.iterator()){
+ IPath childPath = (IPath)iter.next();
+ result.add(childPath);
+
+ children = getChildPathSet(children, getNext(childPath), true, false);
+ }
+
+ return result;
+ }
+
+ public static SortedMap getDirectChildPathMap(SortedMap map, IPath path){
+ //all children
+ SortedMap children = getChildPathMap(map, path, false, false);
+ SortedMap result = new TreeMap(INSTANCE);
+ for(Iterator iter = children.entrySet().iterator(); iter.hasNext(); iter = children.entrySet().iterator()){
+ Map.Entry entry = (Map.Entry)iter.next();
+ IPath childPath = (IPath)entry.getKey();
+ result.put(childPath, entry.getValue());
+
+ children = getChildPathMap(children, getNext(childPath), true, false);
+ }
+
+ return result;
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/PathTreeSetMap.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/PathTreeSetMap.java
new file mode 100644
index 00000000000..8125579f3d3
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/PathTreeSetMap.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * 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.managedbuilder.internal.tcmodification;
+
+import java.util.Collection;
+import java.util.TreeSet;
+
+public class PathTreeSetMap extends CollectionMap {
+
+ protected Collection cloneCollection(Collection l) {
+ return (Collection)((TreeSet)l).clone();
+ }
+
+ protected Collection newCollection(int size) {
+ return new TreeSet(PathComparator.INSTANCE);
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/PerTypeMapStorage.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/PerTypeMapStorage.java
new file mode 100644
index 00000000000..4d9ef16f4c2
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/PerTypeMapStorage.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * 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.managedbuilder.internal.tcmodification;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class PerTypeMapStorage {
+ private ObjectTypeBasedStorage fStorage = new ObjectTypeBasedStorage();
+
+ public Map getMap(int type, boolean create){
+ Map map = (Map)fStorage.get(type);
+ if(map == null && create){
+ map = createMap(null);
+ fStorage.set(type, map);
+ }
+ return map;
+ }
+
+ protected Map createMap(Map map){
+ if(map == null)
+ return new HashMap();
+ return (Map)((HashMap)map).clone();
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/PerTypeSetStorage.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/PerTypeSetStorage.java
new file mode 100644
index 00000000000..3aae275e1e0
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/PerTypeSetStorage.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * 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.managedbuilder.internal.tcmodification;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class PerTypeSetStorage {
+ private ObjectTypeBasedStorage fStorage = new ObjectTypeBasedStorage();
+
+ public Set getSet(int type, boolean create){
+ Set set = (Set)fStorage.get(type);
+ if(set == null && create){
+ set = createSet(null);
+ fStorage.set(type, set);
+ }
+ return set;
+ }
+
+ protected Set createSet(Set set){
+ if(set == null)
+ return new HashSet();
+ return (Set)((HashSet)set).clone();
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/TcModificationUtil.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/TcModificationUtil.java
new file mode 100644
index 00000000000..158fecfc2aa
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/TcModificationUtil.java
@@ -0,0 +1,494 @@
+/*******************************************************************************
+ * 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.managedbuilder.internal.tcmodification;
+
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
+import org.eclipse.cdt.managedbuilder.internal.core.FolderInfo;
+import org.eclipse.cdt.managedbuilder.internal.core.IRealBuildObjectAssociation;
+import org.eclipse.cdt.managedbuilder.internal.core.ResourceConfiguration;
+import org.eclipse.core.runtime.IPath;
+
+public class TcModificationUtil {
+
+ private static void processFolderInfoChildren(FolderInfo foInfo, PerTypeMapStorage storage, IToolChain rtc, Map tcMap, Map toolMap, boolean addSkipInfo){
+ IResourceInfo rcInfos[] = foInfo.getDirectChildResourceInfos();
+ for(int i = 0; i < rcInfos.length; i++){
+ IResourceInfo rc = rcInfos[i];
+ if(rc instanceof ResourceConfiguration){
+ ResourceConfiguration fi = (ResourceConfiguration)rc;
+ IPath p = fi.getPath();
+ ITool[] tools = fi.getTools();
+ processTools(storage.getMap(IRealBuildObjectAssociation.OBJECT_FILE_INFO, true), p, tools, toolMap, addSkipInfo);
+ } else {
+ FolderInfo childFoInfo = (FolderInfo)rc;
+ IToolChain tc = foInfo.getToolChain();
+ tc = ManagedBuildManager.getRealToolChain(tc);
+ if(tc == rtc){
+ if(addSkipInfo && tcMap != null){
+ Set set = getPathTreeSet(tcMap, tc);
+ set.add(childFoInfo.getPath());
+ }
+ processFolderInfoChildren(childFoInfo, storage, tc, tcMap, toolMap, addSkipInfo);
+ } else {
+ processFolderInfo(storage, childFoInfo, null, false);
+ }
+ }
+ }
+ }
+
+ public static PerTypeMapStorage createChildObjectsRealToolToPathSet(FolderInfo foInfo, Map toolChainMap, Map toolsMap, boolean addSkipPaths){
+ PerTypeMapStorage storage = new PerTypeMapStorage();
+
+ IToolChain tc = foInfo.getToolChain();
+ IToolChain rTc = ManagedBuildManager.getRealToolChain(tc);
+ ITool[] tools = rTc.getTools();
+ toolsMap.clear();
+ if(toolChainMap != null)
+ toolChainMap.clear();
+
+ for(int i = 0; i < tools.length; i++){
+ toolsMap.put(ManagedBuildManager.getRealTool(tools[i]), null);
+ }
+
+
+ processFolderInfoChildren(foInfo, storage, rTc, toolChainMap, toolsMap, addSkipPaths);
+
+ return storage;
+ }
+
+ public static PerTypeMapStorage createParentObjectsRealToolToPathSet(final FolderInfo foInfo){
+ PerTypeMapStorage storage = new PerTypeMapStorage();
+ IConfiguration cfg = foInfo.getParent();
+ FolderInfo rf = (FolderInfo)cfg.getRootFolderInfo();
+ IPath p = rf.getPath();
+
+ IBuilder realBuilder = ManagedBuildManager.getRealBuilder(cfg.getBuilder());
+ Map map = storage.getMap(IRealBuildObjectAssociation.OBJECT_BUILDER, true);
+ TreeSet pathSet = new TreeSet(PathComparator.INSTANCE);
+ pathSet.add(p);
+ map.put(realBuilder, pathSet);
+
+ IRealBuildObjectAssociation realCfg = ((Configuration)cfg).getRealBuildObject();
+ map = storage.getMap(IRealBuildObjectAssociation.OBJECT_CONFIGURATION, true);
+ pathSet = new TreeSet(PathComparator.INSTANCE);
+ pathSet.add(p);
+ map.put(realCfg, pathSet);
+
+ if(!foInfo.isRoot()){
+ Set allRcInfos = new HashSet(Arrays.asList(cfg.getResourceInfos()));
+ allRcInfos.removeAll(foInfo.getChildResourceInfoList(true));
+ for(Iterator iter = allRcInfos.iterator(); iter.hasNext(); ){
+ Object rc = iter.next();
+ if(rc instanceof ResourceConfiguration){
+ processFileInfo(storage, (ResourceConfiguration)rc, null, false);
+ } else {
+ processFolderInfo(storage, (FolderInfo)rc, null, false);
+ }
+ }
+ }
+
+ return storage;
+ }
+
+
+ public static PerTypeMapStorage createRealToolToPathSet(IConfiguration cfg, PerTypeMapStorage skipMapStorage, boolean addSkipPaths){
+ PerTypeMapStorage storage = new PerTypeMapStorage();
+ FolderInfo rf = (FolderInfo)cfg.getRootFolderInfo();
+ IPath p = rf.getPath();
+
+ Map skipMap = skipMapStorage != null ? skipMapStorage.getMap(IRealBuildObjectAssociation.OBJECT_BUILDER, false) : null;
+ IBuilder realBuilder = ManagedBuildManager.getRealBuilder(cfg.getBuilder());
+ if(skipMap != null && skipMap.containsKey(realBuilder)){
+ if(addSkipPaths){
+ Set set = getPathTreeSet(skipMap, realBuilder);
+ set.add(p);
+ }
+ } else {
+ Map map = storage.getMap(IRealBuildObjectAssociation.OBJECT_BUILDER, true);
+ TreeSet pathSet = new TreeSet(PathComparator.INSTANCE);
+ pathSet.add(p);
+ map.put(realBuilder, pathSet);
+ }
+
+ skipMap = skipMapStorage != null ? skipMapStorage.getMap(IRealBuildObjectAssociation.OBJECT_CONFIGURATION, false) : null;
+ IRealBuildObjectAssociation realCfg = ((Configuration)cfg).getRealBuildObject();
+ if(skipMap != null && skipMap.containsKey(realCfg)){
+ if(addSkipPaths){
+ Set set = getPathTreeSet(skipMap, realCfg);
+ set.add(p);
+ }
+ } else {
+ Map map = storage.getMap(IRealBuildObjectAssociation.OBJECT_CONFIGURATION, true);
+ TreeSet pathSet = new TreeSet(PathComparator.INSTANCE);
+ pathSet.add(p);
+ map.put(realCfg, pathSet);
+ }
+
+ processFolderInfo(storage, rf, skipMapStorage, addSkipPaths);
+ IResourceInfo[] rcInfos = rf.getChildResourceInfos();
+ for(int i = 0; i < rcInfos.length; i++){
+ IResourceInfo rc = rcInfos[i];
+ if(rc instanceof ResourceConfiguration){
+ processFileInfo(storage, (ResourceConfiguration)rc, skipMapStorage, addSkipPaths);
+ } else {
+ processFolderInfo(storage, (FolderInfo)rc, skipMapStorage, addSkipPaths);
+ }
+ }
+
+ return storage;
+ }
+
+ private static void processFolderInfo(PerTypeMapStorage storage, FolderInfo info, PerTypeMapStorage skipMapStorage, boolean addSkipPaths){
+ IPath p = info.getPath();
+ IToolChain rtc = ManagedBuildManager.getRealToolChain(info.getToolChain());
+ Map skipMap = skipMapStorage != null ? skipMapStorage.getMap(IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, false) : null;
+ if(skipMap != null && skipMap.containsKey(rtc)){
+ if(addSkipPaths){
+ TreeSet set = getPathTreeSet(skipMap, rtc);
+ set.add(p);
+ }
+ } else {
+ Map map = storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, true);
+ TreeSet set = getPathTreeSet(map, rtc);
+ set.add(p);
+ }
+
+ ITool[] tools = info.getTools();
+ processTools(storage, p, tools, skipMapStorage, addSkipPaths);
+ }
+
+ public static IRealBuildObjectAssociation[] getRealObjects(IRealBuildObjectAssociation[] objs, Class clazz){
+ LinkedHashSet set = new LinkedHashSet();
+ for(int i = 0; i < objs.length; i++){
+ set.add(objs[i].getRealBuildObject());
+ }
+ Object[] array = (Object[])Array.newInstance(clazz, set.size());
+ return (IRealBuildObjectAssociation[])set.toArray(array);
+ }
+
+ public static Set getRealObjectsSet(IRealBuildObjectAssociation[] objs, Set set){
+ if(set == null)
+ set = new LinkedHashSet();
+ for(int i = 0; i < objs.length; i++){
+ set.add(objs[i].getRealBuildObject());
+ }
+ return set;
+ }
+
+ public static Map getRealToObjectsMap(IRealBuildObjectAssociation[] objs, Map map){
+ if(map == null)
+ map = new LinkedHashMap();
+ for(int i = 0; i < objs.length; i++){
+ map.put(objs[i].getRealBuildObject(), objs[i]);
+ }
+ return map;
+ }
+
+ private static void processFileInfo(PerTypeMapStorage storage, ResourceConfiguration info, PerTypeMapStorage skipMapStorage, boolean addSkipPaths){
+ IPath p = info.getPath();
+ ITool[] tools = info.getTools();
+ processTools(storage, p, tools, skipMapStorage, addSkipPaths);
+ }
+
+ private static void processTools(PerTypeMapStorage storage, IPath path, ITool[] tools, PerTypeMapStorage skipMapStorage, boolean addSkipPaths){
+ Map map = storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOL, true);
+ Map skipMap = skipMapStorage != null ? skipMapStorage.getMap(IRealBuildObjectAssociation.OBJECT_TOOL, false) : null;
+
+ processTools(map, path, tools, skipMap, addSkipPaths);
+ }
+
+ private static void processTools(Map storageMap, IPath path, ITool[] tools, Map skipMap, boolean addSkipPaths){
+ for(int i = 0; i < tools.length; i++){
+ ITool rt = ManagedBuildManager.getRealTool(tools[i]);
+ if(skipMap != null && skipMap.containsKey(rt)){
+ if(addSkipPaths){
+ TreeSet set = getPathTreeSet(skipMap, rt);
+ set.add(path);
+ }
+ } else {
+ TreeSet set = getPathTreeSet(storageMap, rt);
+ set.add(path);
+ }
+ }
+ }
+
+
+ public static TreeSet getPathTreeSet(Map map, Object obj){
+ TreeSet set = (TreeSet)map.get(obj);
+ if(set == null){
+ set = new TreeSet(PathComparator.INSTANCE);
+ map.put(obj, set);
+ }
+ return set;
+ }
+
+ public static ArrayList getArrayList(Map map, Object obj){
+ ArrayList list = (ArrayList)map.get(obj);
+ if(list == null){
+ list = new ArrayList();
+ map.put(obj, list);
+ }
+ return list;
+ }
+
+ public static Object removeBuilderInfo(PerTypeMapStorage starage, IBuilder builder){
+ return starage.getMap(IRealBuildObjectAssociation.OBJECT_BUILDER, true).remove(builder);
+ }
+
+ public static void restoreBuilderInfo(PerTypeMapStorage starage, IBuilder builder, Object obj){
+ starage.getMap(IRealBuildObjectAssociation.OBJECT_BUILDER, true).put(builder, obj);
+ }
+
+// public static boolean removeToolInfo(PerTypeMapStorage starage, IPath path, ITool tool){
+// Map map = starage.getMap(IRealBuildObjectAssociation.OBJECT_TOOL, false);
+// if(map == null)
+// return false;
+// Set set = (Set)map.get(tool);
+// if(set == null)
+// return false;
+// boolean result = set.remove(path);
+// if(set.isEmpty())
+// map.remove(tool);
+// return result;
+// }
+//
+// public static void restoreToolInfo(PerTypeMapStorage starage, IPath path, ITool tool){
+// Map map = starage.getMap(IRealBuildObjectAssociation.OBJECT_TOOL, true);
+// Set set = TcModificationUtil.getPathTreeSet(map, tool);
+// set.add(path);
+// }
+//
+// public static Set removeToolInfoWithChildren(PerTypeMapStorage starage, IPath path, ITool tool){
+// Map map = starage.getMap(IRealBuildObjectAssociation.OBJECT_TOOL, false);
+// if(map == null)
+// return null;
+// SortedSet set = (SortedSet)map.get(tool);
+// if(set == null)
+// return null;
+//
+// Set rmSet = PathComparator.getChildPathSet(set, path, true, true);
+// if(rmSet.size() == 0)
+// return null;
+//
+// set.removeAll(rmSet);
+// return rmSet;
+// }
+//
+// public static void restoreToolInfoWithChildren(PerTypeMapStorage starage, Set restoreSet, ITool tool){
+// Map map = starage.getMap(IRealBuildObjectAssociation.OBJECT_TOOL, true);
+// Set set = TcModificationUtil.getPathTreeSet(map, tool);
+// set.addAll(restoreSet);
+// }
+
+ public static void removePaths(Map map, IRealBuildObjectAssociation obj, Set paths){
+ Set objPaths = (Set)map.get(obj);
+ if(objPaths == null)
+ return;
+
+ objPaths.removeAll(paths);
+ if(objPaths.size() == 0)
+ map.remove(obj);
+ }
+
+ public static void addPaths(Map map, IRealBuildObjectAssociation obj, Set paths){
+ if(paths.size() == 0)
+ return;
+
+ Set objPaths = (Set)map.get(obj);
+ if(objPaths == null){
+ objPaths = new TreeSet(PathComparator.INSTANCE);
+ map.put(obj, objPaths);
+ }
+
+ objPaths.addAll(paths);
+ }
+
+ public static void addPath(Map map, IRealBuildObjectAssociation obj, IPath path){
+ Set objPaths = (Set)map.get(obj);
+ if(objPaths == null){
+ objPaths = new TreeSet(PathComparator.INSTANCE);
+ map.put(obj, objPaths);
+ }
+
+ objPaths.add(path);
+ }
+
+ public static void applyBuilder(PerTypeMapStorage storage, IPath path, IBuilder builder){
+ Map bMap = storage.getMap(IRealBuildObjectAssociation.OBJECT_BUILDER, true);
+ bMap.clear();
+ IBuilder realBuilder = ManagedBuildManager.getRealBuilder(builder);
+ TreeSet set = getPathTreeSet(bMap, realBuilder);
+ set.add(path);
+ }
+
+ public static void applyBuilder(TreeMap pathMap, IPath path, IBuilder builder){
+ IBuilder realBuilder = ManagedBuildManager.getRealBuilder(builder);
+ PerTypeSetStorage storage = (PerTypeSetStorage)pathMap.get(path);
+ Set set = storage.getSet(IRealBuildObjectAssociation.OBJECT_BUILDER, true);
+ set.clear();
+ set.add(realBuilder);
+ }
+
+ public static TreeMap createPathMap(PerTypeMapStorage storage){
+ int[] types = ObjectTypeBasedStorage.getSupportedObjectTypes();
+ TreeMap result = new TreeMap(PathComparator.INSTANCE);
+ for(int i = 0; i < types.length; i++){
+ int type = types[i];
+ Map map = storage.getMap(type, false);
+ if(map == null)
+ continue;
+
+ for(Iterator iter = map.entrySet().iterator(); iter.hasNext(); ){
+ Map.Entry entry = (Map.Entry)iter.next();
+ IRealBuildObjectAssociation obj = (IRealBuildObjectAssociation)entry.getKey();
+ SortedSet pathSet = (SortedSet)entry.getValue();
+
+ for(Iterator pathIter = pathSet.iterator(); pathIter.hasNext(); ){
+ Object path = pathIter.next();
+ PerTypeSetStorage oset = (PerTypeSetStorage)result.get(path);
+ if(oset == null){
+ oset = new PerTypeSetStorage();
+ result.put(path, oset);
+ }
+
+ oset.getSet(obj.getType(), true).add(obj);
+ }
+ }
+ }
+
+ return result;
+ }
+
+ private static boolean pathContainsObjects(PerTypeMapStorage storage, IPath path, int type){
+ Map map = storage.getMap(type, false);
+ if(map == null)
+ return false;
+
+ for(Iterator iter = map.values().iterator(); iter.hasNext(); ){
+ SortedSet set = (SortedSet)iter.next();
+ if(set.contains(path))
+ return true;
+ }
+
+ return false;
+ }
+
+ public static SortedSet getDirectChildUsagePaths(PerTypeMapStorage storage, IPath path, IRealBuildObjectAssociation obj, SortedSet inclusionPaths){
+ Map objMap = storage.getMap(obj.getType(), false);
+
+ SortedSet objPaths = (SortedSet)objMap.get(obj);
+ if(DbgTcmUtil.DEBUG){
+ if(!objPaths.contains(path)){
+ DbgTcmUtil.fail();
+ }
+ }
+
+ SortedSet objChildPaths = PathComparator.getChildPathSet(objPaths, path, false, true);
+ if(inclusionPaths != null) {
+ objChildPaths.retainAll(inclusionPaths);
+ }
+
+ for(Iterator iter = objMap.entrySet().iterator(); iter.hasNext(); ){
+ Map.Entry entry = (Map.Entry)iter.next();
+ Object cur = entry.getKey();
+ if(obj == cur)
+ continue;
+
+ SortedSet curPaths = (SortedSet)entry.getValue();
+
+ curPaths = PathComparator.getChildPathSet(curPaths, path, false, false);
+
+ for(Iterator pathIter = objChildPaths.iterator(); pathIter.hasNext(); ){
+ SortedSet sub = curPaths.tailSet(pathIter.next());
+ if(sub.size() != 0)
+ iter.remove();
+ }
+ }
+
+ objChildPaths.add(path);
+
+ return objChildPaths;
+ }
+
+
+ public static boolean containCommonEntries(Set set, Object[] objs){
+ for(int i = 0; i < objs.length; i++){
+ if(set.contains(objs[i]))
+ return true;
+ }
+ return false;
+ }
+
+ public static IRealBuildObjectAssociation[] getRealObjects(int type){
+ switch (type) {
+ case IRealBuildObjectAssociation.OBJECT_TOOL:
+ return (IRealBuildObjectAssociation[])ManagedBuildManager.getRealTools();
+ case IRealBuildObjectAssociation.OBJECT_TOOLCHAIN:
+ return (IRealBuildObjectAssociation[])ManagedBuildManager.getRealToolChains();
+ case IRealBuildObjectAssociation.OBJECT_BUILDER:
+ return (IRealBuildObjectAssociation[])ManagedBuildManager.getRealBuilders();
+ case IRealBuildObjectAssociation.OBJECT_CONFIGURATION:
+ return (IRealBuildObjectAssociation[])ManagedBuildManager.getExtensionConfigurations();
+ default:
+ throw new IllegalArgumentException();
+ }
+ }
+
+ public static IRealBuildObjectAssociation[] getExtensionObjects(int type){
+ switch (type) {
+ case IRealBuildObjectAssociation.OBJECT_TOOL:
+ return (IRealBuildObjectAssociation[])ManagedBuildManager.getExtensionTools();
+ case IRealBuildObjectAssociation.OBJECT_TOOLCHAIN:
+ return (IRealBuildObjectAssociation[])ManagedBuildManager.getExtensionToolChains();
+ case IRealBuildObjectAssociation.OBJECT_BUILDER:
+ return (IRealBuildObjectAssociation[])ManagedBuildManager.getExtensionBuilders();
+ case IRealBuildObjectAssociation.OBJECT_CONFIGURATION:
+ return (IRealBuildObjectAssociation[])ManagedBuildManager.getExtensionConfigurations();
+ default:
+ throw new IllegalArgumentException();
+ }
+ }
+
+ public static IRealBuildObjectAssociation getObjectById(int type, String id){
+ switch (type) {
+ case IRealBuildObjectAssociation.OBJECT_TOOL:
+ return (IRealBuildObjectAssociation)ManagedBuildManager.getExtensionTool(id);
+ case IRealBuildObjectAssociation.OBJECT_TOOLCHAIN:
+ return (IRealBuildObjectAssociation)ManagedBuildManager.getExtensionToolChain(id);
+ case IRealBuildObjectAssociation.OBJECT_BUILDER:
+ return (IRealBuildObjectAssociation)ManagedBuildManager.getExtensionBuilder(id);
+ case IRealBuildObjectAssociation.OBJECT_CONFIGURATION:
+ return (IRealBuildObjectAssociation)ManagedBuildManager.getExtensionConfiguration(id);
+ default:
+ throw new IllegalArgumentException();
+ }
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ToolChainModificationManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ToolChainModificationManager.java
new file mode 100644
index 00000000000..7064d46fdb4
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ToolChainModificationManager.java
@@ -0,0 +1,241 @@
+/*******************************************************************************
+ * 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.managedbuilder.internal.tcmodification;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.cdt.managedbuilder.core.IFileInfo;
+import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
+import org.eclipse.cdt.managedbuilder.internal.core.FolderInfo;
+import org.eclipse.cdt.managedbuilder.internal.core.IRealBuildObjectAssociation;
+import org.eclipse.cdt.managedbuilder.internal.core.ResourceConfiguration;
+import org.eclipse.cdt.managedbuilder.internal.tcmodification.extension.ObjectSetListBasedDefinition;
+import org.eclipse.cdt.managedbuilder.internal.tcmodification.extension.RulesManager;
+import org.eclipse.cdt.managedbuilder.tcmodification.IFileInfoModification;
+import org.eclipse.cdt.managedbuilder.tcmodification.IFolderInfoModification;
+import org.eclipse.cdt.managedbuilder.tcmodification.IToolChainModificationManager;
+
+public class ToolChainModificationManager implements
+ IToolChainModificationManager {
+ private static ToolChainModificationManager fInstance;
+
+ private ToolChainModificationManager(){
+ }
+
+ public static ToolChainModificationManager getInstance(){
+ if(fInstance == null)
+ fInstance = getInstanceSynch();
+ return fInstance;
+ }
+
+ private static synchronized ToolChainModificationManager getInstanceSynch() {
+ if(fInstance == null)
+ fInstance = new ToolChainModificationManager();
+ return fInstance;
+ }
+
+ public void start(){
+ RulesManager.getInstance().start();
+ }
+
+ public IFileInfoModification getModification(IFileInfo rcInfo) {
+ return new FileInfoModification((ResourceConfiguration)rcInfo);
+ }
+
+ public IFolderInfoModification getModification(IFolderInfo rcInfo) {
+ FolderInfo foInfo = (FolderInfo)rcInfo;
+ if(foInfo.isRoot())
+ return new ConfigurationModification(foInfo);
+ return new FolderInfoModification(foInfo);
+ }
+
+ public static boolean checkFlags(int flags, int value){
+ return (flags & value) == value;
+ }
+
+ public static int addFlags(int flags, int value){
+ return flags |= value;
+ }
+
+ public static int clearFlags(int flags, int value){
+ return flags &= (~value);
+ }
+
+// public static final int SCOPE_MATCH_EXACT = 1;
+// public static final int SCOPE_MATCH_PARTIAL = 1 << 1;
+// public static final int SCOPE_MATCH_SCOPE_COVERS = 1 << 2;
+// public static final int SCOPE_MATCH_SET_SCOPE_COVERS = 1 << 3;
+// public static final int SCOPE_MATCH_NO = 1 << 4;
+// public static final int SCOPE_MATCH_ANY_MATCH =
+// SCOPE_MATCH_EXACT
+// | SCOPE_MATCH_PARTIAL
+// | SCOPE_MATCH_SCOPE_COVERS
+// | SCOPE_MATCH_SET_SCOPE_COVERS;
+//
+//
+// public static boolean matchScope(int scope, int setScope, int matchType){
+// int applicableTypes = 0;
+// if(scope == setScope){
+// applicableTypes |= SCOPE_MATCH_EXACT;
+// } else {
+// int conjunction = scope & setScope;
+// if(conjunction == scope){
+// applicableTypes |= SCOPE_MATCH_SET_SCOPE_COVERS;
+// } else if (conjunction == setScope) {
+// applicableTypes |= SCOPE_MATCH_SCOPE_COVERS;
+// } else if (conjunction == 0){
+// applicableTypes |= SCOPE_MATCH_NO;
+// } else {
+// applicableTypes |= SCOPE_MATCH_PARTIAL;
+// }
+// }
+//
+// return (applicableTypes & matchType) != 0;
+// }
+
+ private boolean getMatchingObjects(int type, IObjectSet[] oSets, Set skipSet, IRealBuildObjectAssociation additionalSkip, Set result){
+ Set tmp = null;
+ boolean added = false;
+ for(int i = 0; i < oSets.length; i++){
+ IObjectSet os = oSets[i];
+ int setType = os.getObjectType();
+ if(setType != type)
+ continue;
+
+ if(tmp == null)
+ tmp = new HashSet();
+ else
+ tmp.clear();
+
+ os.getRealBuildObjects(tmp);
+
+ if(skipSet != null)
+ tmp.removeAll(skipSet);
+
+ if(additionalSkip != null)
+ tmp.remove(additionalSkip);
+
+ if(result.addAll(tmp)){
+ added = true;
+ }
+ }
+ return added;
+ }
+
+ public ConflictMatchSet getConflictInfo(int objType, PerTypeMapStorage parent){
+ //parent should be passed - it is constant no need to recalculate every time
+ //PerTypeMapStorage parent = TcModificationUtil.createParentObjectsRealToolToPathSet(foInfo);
+
+ ConflictMatchSet conflicts = getConflictMatches(objType, parent, null);
+
+ return conflicts;
+ }
+
+ public static class ConflictMatch {
+ final int fMatchType;
+ final Map fRObjToPathMap;
+ final int fConflictType;
+ final Set fConflicts;
+
+ ConflictMatch(int matchType, Map robjToPathMap,
+ int conflictType, Set conflicts){
+ fMatchType = matchType;
+ fRObjToPathMap = Collections.unmodifiableMap(robjToPathMap);
+ fConflictType = conflictType;
+ fConflicts = Collections.unmodifiableSet(conflicts);
+ }
+ }
+
+ public static class ConflictMatchSet {
+ ConflictMatch[] fConflicts;
+ Map fObjToConflictListMap;
+
+ ConflictMatchSet(ConflictMatch[] coflicts, Map objToConflictMap){
+ fConflicts = coflicts;
+ fObjToConflictListMap = objToConflictMap;
+ }
+
+
+ }
+
+ private ConflictMatchSet getConflictMatches(int type, PerTypeMapStorage rtToPath, PerTypeSetStorage skip){
+
+ //conversion:
+ //1.first filter applicable to not-this
+ //2. get variants for applicable ones
+
+ //1.first filter applicable to not-this
+ List conflictList = new ArrayList();
+ Map objToConflictMatchMap = new HashMap();
+
+ ObjectSetListBasedDefinition[] defs = RulesManager.getInstance().getRules(ObjectSetListBasedDefinition.CONFLICT);
+ for(int i = 0; i < defs.length; i++){
+ ObjectSetListBasedDefinition def= defs[i];
+ ObjectSetList sl = def.getObjectSetList();
+ IObjectSet oss[] = sl.getObjectSets();
+ for(int k = 0; k < oss.length; k++){
+ IObjectSet os = oss[k];
+ int objType = os.getObjectType();
+ Map rtToPathMap = rtToPath.getMap(objType, false);
+ if(rtToPathMap == null)
+ continue;
+
+ rtToPathMap = (Map)((HashMap)rtToPathMap).clone();
+ Set skipSet = skip != null ? skip.getSet(objType, false) : null;
+ Set objSet = rtToPathMap.keySet();
+
+ if(skipSet != null)
+ objSet.removeAll(skipSet);
+
+ os.retainMatches(objSet);
+
+ if(objSet.size() != 0){
+ List remainingList = new ArrayList(Arrays.asList(oss));
+ remainingList.remove(os);
+
+ IObjectSet[] remaining = (IObjectSet[])remainingList.toArray(new IObjectSet[remainingList.size()]);
+ //get objects matching remaining
+ skipSet = skip != null ? skip.getSet(type, false) : null;
+ Set matchingObjects = new HashSet();
+ getMatchingObjects(type, remaining, skipSet,
+ null,
+ matchingObjects);
+ if(matchingObjects.size() != 0){
+ ConflictMatch conflict = new ConflictMatch(
+ objType,
+ rtToPathMap,
+ type,
+ matchingObjects);
+
+ for(Iterator iter = matchingObjects.iterator(); iter.hasNext(); ){
+ TcModificationUtil.getArrayList(objToConflictMatchMap, iter.next()).add(conflict);
+ }
+
+ conflictList.add(conflict);
+ }
+// break;
+ }
+ }
+ }
+
+ return new ConflictMatchSet(
+ (ConflictMatch[])conflictList.toArray(new ConflictMatch[conflictList.size()]),
+ objToConflictMatchMap);
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ToolChainModificationMessages.properties b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ToolChainModificationMessages.properties
new file mode 100644
index 00000000000..7878d2285df
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ToolChainModificationMessages.properties
@@ -0,0 +1,7 @@
+FolderInfoModification.0=Toolchain is incompatible with the current cnfiguration
+ConfigurationModification.0=Builder is incompatible with the current cnfiguration
+RulesManager.1=Tool-chain modification rules initialization
+
+ToolListModification.0=Tool is incompatible with the current configuration
+ToolListModification.2=Tool is incompatible with the current cnfiguration
+ToolListModification.4=Tool is incompatible with the current cnfiguration
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ToolListModification.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ToolListModification.java
new file mode 100644
index 00000000000..65e5ad389ed
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/ToolListModification.java
@@ -0,0 +1,624 @@
+/*******************************************************************************
+ * 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.managedbuilder.internal.tcmodification;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.core.IRealBuildObjectAssociation;
+import org.eclipse.cdt.managedbuilder.internal.core.ResourceInfo;
+import org.eclipse.cdt.managedbuilder.internal.core.Tool;
+import org.eclipse.cdt.managedbuilder.internal.core.ToolChainModificationHelper;
+import org.eclipse.cdt.managedbuilder.internal.core.ToolListModificationInfo;
+import org.eclipse.cdt.managedbuilder.internal.tcmodification.ToolChainModificationManager.ConflictMatchSet;
+import org.eclipse.cdt.managedbuilder.tcmodification.CompatibilityStatus;
+import org.eclipse.cdt.managedbuilder.tcmodification.IModificationOperation;
+import org.eclipse.cdt.managedbuilder.tcmodification.IToolListModification;
+import org.eclipse.cdt.managedbuilder.tcmodification.IToolModification;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+
+public abstract class ToolListModification implements
+ IToolListModification {
+// private Tool []fTools;
+ private Set fInputExtsSet = new HashSet();
+ private ResourceInfo fRcInfo;
+ private LinkedHashMap fProjCompInfoMap = new LinkedHashMap();
+ private HashMap fSysCompInfoMap = new HashMap();
+ private Tool[] fAllSysTools;
+ private Set fFilteredOutSysTools;
+// private LinkedHashMap fRealToToolMap = new LinkedHashMap();
+// private boolean fSysInfoMapInited;
+ private PerTypeMapStorage fCompleteObjectStorage;
+ private TreeMap fCompletePathMapStorage;
+ private Set fAddCapableTools;
+ private Map fFilteredOutTools;
+
+ private ToolListModificationInfo fModificationInfo;
+
+ private class ModificationOperation implements IModificationOperation {
+ private ITool fReplacement;
+ private IToolModification fModification;
+
+ ModificationOperation(IToolModification modification, ITool tool){
+ fModification = modification;
+ fReplacement = tool;
+ }
+
+ public ITool getReplacementTool() {
+ return fReplacement;
+ }
+
+ public IToolModification getToolModification() {
+ return fModification;
+ }
+ }
+
+ private class FilteredTool implements IToolModification {
+ private ITool fTool;
+ private boolean fIsProject;
+
+ public FilteredTool(ITool tool, boolean isProject){
+ fTool = tool;
+ fIsProject = isProject;
+ }
+
+ public CompatibilityStatus getCompatibilityStatus() {
+ return fIsProject ? CompatibilityStatus.OK_COMPATIBILITY_STATUS
+ : new CompatibilityStatus(IStatus.ERROR, Messages.getString("ToolListModification.0"), null); //$NON-NLS-1$
+ }
+
+ public IModificationOperation[] getSupportedOperations() {
+ return new IModificationOperation[0];
+ }
+
+ public ITool getTool() {
+ return fTool;
+ }
+
+ public boolean isCompatible() {
+ return fIsProject;
+ }
+
+ public boolean isProjectTool() {
+ return fIsProject;
+ }
+
+ public IResourceInfo getResourceInfo() {
+ return ToolListModification.this.getResourceInfo();
+ }
+
+ }
+
+ public class ProjToolCompatibilityStatusInfo implements IToolModification {
+ private ToolCompatibilityInfoElement fCurrentElement;
+ private Map fCompatibleTools;
+ private Map fInCompatibleTools;
+ private IModificationOperation[] fOperations;
+ private Tool fSelectedTool;
+ private Tool fRealTool;
+ private boolean fInited;
+ private Set fExtConflictTools;
+
+ ProjToolCompatibilityStatusInfo(Tool tool){
+ fSelectedTool = tool;
+ fRealTool = (Tool)ManagedBuildManager.getRealTool(tool);
+ }
+
+ private ToolCompatibilityInfoElement getCurrentElement(){
+ checkInitCompatibleTools();
+ return fCurrentElement;
+ }
+
+ public CompatibilityStatus getCompatibilityStatus() {
+ return getCurrentElement().getCompatibilityStatus();
+ }
+
+ public boolean isCompatible(){
+ return getCurrentElement().isCompatible();
+ }
+
+ public boolean isProjectTool() {
+ return true;
+ }
+
+ public Map getCompatibleTools(){
+ checkInitCompatibleTools();
+ return fCompatibleTools;
+ }
+
+ private void checkInitCompatibleTools(){
+ if(fInited)
+ return;
+
+ if(DbgTcmUtil.DEBUG)
+ DbgTcmUtil.println("calculating compatibility for tool " + fRealTool.getUniqueRealName()); //$NON-NLS-1$
+
+ PerTypeMapStorage storage = getCompleteObjectStore();
+ Tool tool = fRealTool;
+ Set rmSet = getToolApplicabilityPathSet(tool, true);
+ try {
+ if(rmSet != null && rmSet.size() != 0)
+ TcModificationUtil.removePaths(storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOL, false), tool, rmSet);
+
+ if(DbgTcmUtil.DEBUG)
+ DbgTcmUtil.dumpStorage(storage);
+
+ ConflictMatchSet conflicts = ToolChainModificationManager.getInstance().getConflictInfo(IRealBuildObjectAssociation.OBJECT_TOOL, storage);
+
+ fCompatibleTools = new HashMap();
+ fInCompatibleTools = new HashMap();
+ Tool sysTools[] = getTools(false, true);
+ Map conflictMap = conflicts.fObjToConflictListMap;
+ for(int i = 0; i < sysTools.length; i++){
+ Tool t = sysTools[i];
+ List l = (List)conflictMap.get(t);
+ ToolCompatibilityInfoElement el = new ToolCompatibilityInfoElement(this, t, l);
+ if(el.isCompatible()){
+ fCompatibleTools.put(t, el);
+ } else {
+ fInCompatibleTools.put(t, el);
+ }
+ }
+
+ Tool t = fRealTool;
+ List l = (List)conflictMap.get(t);
+ fCurrentElement = new ToolCompatibilityInfoElement(this, t, l);
+ } finally {
+ if(rmSet != null && rmSet.size() != 0)
+ TcModificationUtil.addPaths(storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOL, false), tool, rmSet);
+ }
+ fInited = true;
+ }
+
+ private Set getConflictingTools(){
+ if(fExtConflictTools == null){
+ Tool[] tmp = new Tool[1];
+ tmp[0] = fSelectedTool;
+ tmp = filterTools(tmp);
+ if(tmp.length == 0)
+ fExtConflictTools = Collections.EMPTY_SET;
+ else
+ fExtConflictTools = getExtensionConflictToolSet(fSelectedTool, filterTools(getTools(true, false)));
+ }
+ return fExtConflictTools;
+ }
+
+ public IModificationOperation[] getSupportedOperations() {
+ if(fOperations == null){
+ checkInitCompatibleTools();
+ if(fFilteredOutTools.containsKey(fRealTool)){
+ if(canRemove(fRealTool)){
+ fOperations = new ModificationOperation[]{
+ new ModificationOperation(this, null)
+ };
+ } else {
+ fOperations = new ModificationOperation[0];
+ }
+ } else {
+ List opList = new ArrayList(fCompatibleTools.size() + 1);
+ for(Iterator iter = fCompatibleTools.keySet().iterator(); iter.hasNext(); ){
+ Tool tool = (Tool)iter.next();
+ if(tool == fRealTool)
+ continue;
+
+ if(canReplace(fRealTool, tool))
+ opList.add(new ModificationOperation(this, tool));
+ }
+
+ if(fCompatibleTools.size() == 0 || canRemove(fRealTool)){
+ opList.add(new ModificationOperation(this, null));
+ }
+
+ fOperations = (ModificationOperation[])opList.toArray(new ModificationOperation[opList.size()]);
+ }
+ }
+ return (IModificationOperation[])fOperations.clone();
+ }
+
+ public ITool getTool() {
+ return fSelectedTool;
+ }
+
+ public ITool getRealTool() {
+ return fRealTool;
+ }
+
+ public IResourceInfo getResourceInfo() {
+ return fRcInfo;
+ }
+
+ public void clearCompatibilityInfo(){
+ fInited = false;
+ fCompatibleTools = null;
+ fInCompatibleTools = null;
+ fOperations = null;
+ fCurrentElement = null;
+ fExtConflictTools = null;
+ }
+
+ }
+
+ protected Set getInputExtsSet(){
+ return fInputExtsSet;
+ }
+
+ public class SysToolCompatibilityStatusInfo implements IToolModification {
+ private IModificationOperation[] fOperations;
+ private Tool fSelectedTool;
+ private Tool fRealTool;
+ private CompatibilityStatus fStatus;
+
+ SysToolCompatibilityStatusInfo(Tool tool){
+ fSelectedTool = tool;
+ fRealTool = (Tool)ManagedBuildManager.getRealTool(tool);
+ }
+
+// private ToolCompatibilityInfoElement getCurrentElement(){
+// if(fCurrentElement == null){
+// checkInitCompatibleTools();
+// ToolCompatibilityInfoElement info = (ToolCompatibilityInfoElement)fCompatibleTools.get(fRealTool);
+// if(info == null)
+// info = (ToolCompatibilityInfoElement)fInCompatibleTools.get(fRealTool);
+// fCurrentElement = info;
+// }
+// return fCurrentElement;
+// }
+
+ public CompatibilityStatus getCompatibilityStatus() {
+ if(fStatus == null){
+ int severity;
+ String message;
+ if(!isCompatible()){
+ severity = IStatus.ERROR;
+ message = Messages.getString("ToolListModification.2"); //$NON-NLS-1$
+ } else {
+ severity = IStatus.OK;
+ message = ""; //$NON-NLS-1$
+ }
+ fStatus = new CompatibilityStatus(severity, message, null);
+ }
+ return fStatus;
+ }
+
+ public boolean isCompatible(){
+ return getSupportedOperationsArray().length > 0;
+ }
+
+ public boolean isProjectTool() {
+ return false;
+ }
+
+ public IModificationOperation[] getSupportedOperationsArray() {
+ if(fOperations == null){
+ Set addCompatibleSysToolsSet = getAddCompatibleSysTools();
+ if(addCompatibleSysToolsSet.contains(fRealTool) && canAdd(fRealTool)){
+ fOperations = new ModificationOperation[]{new ModificationOperation(this, null)};
+ } else {
+ Map projMap = getMap(true);
+ List opList = new ArrayList(projMap.size());
+ for(Iterator iter = projMap.values().iterator(); iter.hasNext(); ){
+ ProjToolCompatibilityStatusInfo info = (ProjToolCompatibilityStatusInfo)iter.next();
+ if(info.getCompatibleTools().containsKey(fRealTool)
+ && !fFilteredOutTools.containsKey(info.fRealTool)
+ && canReplace(info.fSelectedTool, this.fSelectedTool)){
+ opList.add(new ModificationOperation(this, info.fSelectedTool));
+ }
+ }
+ fOperations = (ModificationOperation[])opList.toArray(new ModificationOperation[opList.size()]);
+ }
+ }
+ return fOperations;
+
+ }
+
+ public IModificationOperation[] getSupportedOperations() {
+ return (IModificationOperation[])getSupportedOperationsArray().clone();
+ }
+
+ public ITool getTool() {
+ return fSelectedTool;
+ }
+
+ public ITool getRealTool() {
+ return fRealTool;
+ }
+
+ public IResourceInfo getResourceInfo() {
+ return fRcInfo;
+ }
+
+ public void clearCompatibilityInfo(){
+ fOperations = null;
+ fStatus = null;
+ }
+ }
+
+ private Set getAddCompatibleSysTools(){
+ if(fAddCapableTools == null){
+ fAddCapableTools = new HashSet(Arrays.asList(getAllSysTools()));
+ PerTypeMapStorage storage = getCompleteObjectStore();
+ ConflictMatchSet conflicts = ToolChainModificationManager.getInstance().getConflictInfo(IRealBuildObjectAssociation.OBJECT_TOOL, storage);
+ fAddCapableTools.removeAll(conflicts.fObjToConflictListMap.keySet());
+ }
+ return fAddCapableTools;
+ }
+
+ public ToolListModification(ResourceInfo rcInfo, ITool[] tools){
+ fRcInfo = rcInfo;
+ clearToolInfo(tools);
+ }
+
+ public IResourceInfo getResourceInfo(){
+ return fRcInfo;
+ }
+
+ protected abstract boolean canRemove(ITool realTool);
+
+ protected abstract boolean canReplace(Tool fromTool, Tool toTool);
+
+ protected abstract boolean canAdd(Tool tool);
+
+ protected abstract Set getToolApplicabilityPathSet(Tool realTool, boolean isProject);
+
+ protected abstract Set getExtensionConflictToolSet(Tool tool, Tool[] toos);
+
+ protected abstract Tool[] filterTools(Tool[] tools);
+
+ public class ToolCompatibilityInfoElement {
+ private Tool fRealTool;
+ private List fErrComflictMatchList;
+ private CompatibilityStatus fStatus;
+ private ProjToolCompatibilityStatusInfo fStatusInfo;
+
+ ToolCompatibilityInfoElement(ProjToolCompatibilityStatusInfo statusInfo, Tool realTool, List errConflictList){
+ fStatusInfo = statusInfo;
+ fRealTool = realTool;
+ if(errConflictList != null && errConflictList.size() != 0)
+ fErrComflictMatchList = errConflictList;
+ }
+
+ public CompatibilityStatus getCompatibilityStatus(){
+ if(fStatus == null){
+ int severity;
+ String message;
+ ConflictSet conflicts;
+ if(!isCompatible()){
+ severity = IStatus.ERROR;
+ message = Messages.getString("ToolListModification.4");; //$NON-NLS-1$
+ conflicts = new ConflictSet(fRealTool, fErrComflictMatchList, fStatusInfo.getConflictingTools());
+ } else {
+ severity = IStatus.OK;
+ message = ""; //$NON-NLS-1$
+ conflicts = null;
+ }
+ fStatus = new CompatibilityStatus(severity, message, conflicts);
+ }
+ return fStatus;
+ }
+
+ public boolean isCompatible(){
+ return noCompatibilityConflicts() &&
+ (fRealTool != fStatusInfo.getRealTool() || fStatusInfo.getConflictingTools().size() == 0);
+ }
+
+ public boolean noCompatibilityConflicts(){
+ return fErrComflictMatchList == null;
+ }
+ }
+
+ private Tool[] getAllSysTools(){
+ if(fAllSysTools == null){
+ ITool[] allSys = ManagedBuildManager.getRealTools();
+ fAllSysTools = filterTools((Tool[])allSys);
+ Set set = new HashSet(Arrays.asList(allSys));
+ set.removeAll(Arrays.asList(fAllSysTools));
+ fFilteredOutSysTools = set;
+ }
+ return fAllSysTools;
+ }
+
+ public void apply() throws CoreException {
+ ToolListModificationInfo info = getModificationInfo();
+ info.apply();
+ }
+
+ private ToolListModificationInfo getModificationInfo(){
+ if(fModificationInfo == null){
+ fModificationInfo = ToolChainModificationHelper.getModificationInfo(fRcInfo, fRcInfo.getTools(), getTools(true, false));
+ }
+ return fModificationInfo;
+ }
+
+ public IToolModification[] getProjectToolModifications() {
+ Map map = getMap(true);
+ return (ProjToolCompatibilityStatusInfo[])map.values().toArray(new ProjToolCompatibilityStatusInfo[map.size()]);
+ }
+
+ public ITool[] getProjectTools() {
+ return getTools(true, false);
+ }
+
+ public IToolModification[] getSystemToolModifications() {
+ Map map = getMap(false);
+ return (SysToolCompatibilityStatusInfo[])map.values().toArray(new SysToolCompatibilityStatusInfo[map.size()]);
+ }
+
+ public IToolModification getToolModification(ITool tool) {
+ Tool rt = (Tool)ManagedBuildManager.getRealTool(tool);
+ boolean isProj = isProjectTool(rt);
+ Map map = getMap(isProj);
+ IToolModification m = (IToolModification)map.get(rt);
+ if(m == null){
+ ITool realTool = ManagedBuildManager.getRealTool(tool);
+ boolean projFiltered = fFilteredOutTools.keySet().contains(realTool);
+ m = new FilteredTool(tool, projFiltered);
+ }
+ return m;
+ }
+
+ private Map getMap(Tool tool){
+ return getMap(isProjectTool(tool));
+ }
+
+ private Map getMap(boolean proj){
+ return proj ? fProjCompInfoMap : fSysCompInfoMap;
+ }
+
+ private Tool[] getTools(boolean proj, boolean real){
+ if(proj){
+ if(real)
+ return (Tool[])fProjCompInfoMap.keySet().toArray(new Tool[fProjCompInfoMap.size()]);
+
+ Tool[] tools = new Tool[fProjCompInfoMap.size()];
+ int i = 0;
+ for(Iterator iter = fProjCompInfoMap.values().iterator(); iter.hasNext(); ){
+ tools[i++] = ((ProjToolCompatibilityStatusInfo)iter.next()).fSelectedTool;
+ }
+ return tools;
+ }
+
+ return (Tool[])fSysCompInfoMap.keySet().toArray(new Tool[fSysCompInfoMap.size()]);
+ }
+
+ private boolean isProjectTool(Tool tool){
+ return fProjCompInfoMap.containsKey(tool.getRealBuildObject());
+ }
+
+ public void changeProjectTools(ITool removeTool, ITool addTool) {
+ Map map = createRealToToolMap();
+ Tool realAdded = (Tool)ManagedBuildManager.getRealTool(addTool);
+ Tool realRemoved = (Tool)ManagedBuildManager.getRealTool(removeTool);
+ boolean removed = realRemoved != null ? map.remove(realRemoved) != null : false;
+ boolean added = realAdded != null ? map.put(realAdded, addTool) == null : false;
+ if(!added && !removed)
+ return;
+
+ Set rmSet = null;
+ Set addSet = null;
+ if(removed){
+ rmSet = getToolApplicabilityPathSet(realRemoved, true);
+ }
+ if(added){
+ if(rmSet == null)
+ addSet = getToolApplicabilityPathSet(realAdded, false);
+ else
+ addSet = rmSet;
+ }
+
+ List list = new ArrayList();
+ list.addAll(map.values());
+ clearToolInfo((Tool[])map.values().toArray(new Tool[map.size()]));
+
+ PerTypeMapStorage storage = getCompleteObjectStore();
+ Map toolMap = storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOL, true);
+ if(rmSet != null)
+ TcModificationUtil.removePaths(toolMap, realRemoved, rmSet);
+ if(addSet != null)
+ TcModificationUtil.addPaths(toolMap, realAdded, addSet);
+ }
+
+ private HashMap createRealToToolMap(/*boolean includeFilteredOut*/){
+ HashMap map = new HashMap();
+ for(Iterator iter = fProjCompInfoMap.entrySet().iterator(); iter.hasNext(); ){
+ Map.Entry entry = (Map.Entry)iter.next();
+ map.put(entry.getKey(), ((IToolModification)entry.getValue()).getTool());
+ }
+// if(includeFilteredOut){
+// for(Iterator iter = fFilteredOutTools.entrySet().iterator(); iter.hasNext(); ){
+// Map.Entry entry = (Map.Entry)iter.next();
+// map.put(entry.getKey(), entry.getValue());
+// }
+// }
+
+ return map;
+ }
+
+ protected void clearToolCompatibilityInfo(){
+ for(Iterator iter = fProjCompInfoMap.values().iterator(); iter.hasNext(); ){
+ ((ProjToolCompatibilityStatusInfo)iter.next()).clearCompatibilityInfo();
+ }
+
+ for(Iterator iter = fSysCompInfoMap.values().iterator(); iter.hasNext(); ){
+ ((SysToolCompatibilityStatusInfo)iter.next()).clearCompatibilityInfo();
+ }
+ }
+
+
+ protected void clearToolInfo(ITool[] tools){
+ Tool[] filteredTools;
+ Tool[] allTools;
+ if(tools instanceof Tool[]){
+ allTools = (Tool[])tools;
+ } else {
+ allTools = new Tool[tools.length];
+ System.arraycopy(tools, 0, allTools, 0, tools.length);
+ }
+
+ filteredTools = filterTools(allTools);
+ Map filteredMap = TcModificationUtil.getRealToObjectsMap(filteredTools, null);
+ Map allMap = TcModificationUtil.getRealToObjectsMap(allTools, null);
+ allMap.keySet().removeAll(filteredMap.keySet());
+ fFilteredOutTools = allMap;
+// tools = filteredTools;
+
+ fModificationInfo = null;
+ fInputExtsSet.clear();
+ fProjCompInfoMap.clear();
+ for(int i = 0; i < tools.length; i++){
+ ITool tool = tools[i];
+ ITool realTool = ManagedBuildManager.getRealTool(tool);
+ fProjCompInfoMap.put(realTool, new ProjToolCompatibilityStatusInfo((Tool)tool));
+ if(!fFilteredOutTools.containsKey(realTool))
+ fInputExtsSet.addAll(Arrays.asList(tool.getPrimaryInputExtensions()));
+ }
+ fSysCompInfoMap.clear();
+ Tool[] sysTools = getAllSysTools();
+ for(int i = 0; i < sysTools.length; i++){
+ Tool sysTool = sysTools[i];
+ if(!fProjCompInfoMap.containsKey(sysTool)){
+ fSysCompInfoMap.put(sysTool, new SysToolCompatibilityStatusInfo(sysTool));
+ }
+ }
+ fAddCapableTools = null;
+ fCompletePathMapStorage = null;
+ }
+
+ protected PerTypeMapStorage getCompleteObjectStore(){
+ if(fCompleteObjectStorage == null){
+ fCompleteObjectStorage = TcModificationUtil.createRealToolToPathSet(fRcInfo.getParent(), null, false);
+ if(DbgTcmUtil.DEBUG){
+ DbgTcmUtil.println("dumping complete storage"); //$NON-NLS-1$
+ DbgTcmUtil.dumpStorage(fCompleteObjectStorage);
+ }
+ }
+ return fCompleteObjectStorage;
+ }
+
+ protected TreeMap getCompletePathMapStorage(){
+ if(fCompletePathMapStorage == null){
+ fCompletePathMapStorage = TcModificationUtil.createPathMap(getCompleteObjectStore());
+ }
+ return fCompletePathMapStorage;
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/extension/ConflictDefinition.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/extension/ConflictDefinition.java
new file mode 100644
index 00000000000..74f73e7b21e
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/extension/ConflictDefinition.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * 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.managedbuilder.internal.tcmodification.extension;
+
+import org.eclipse.cdt.managedbuilder.internal.tcmodification.ObjectSetList;
+
+public class ConflictDefinition extends ObjectSetListBasedDefinition {
+
+ protected ConflictDefinition(ObjectSetList list) {
+ super(list);
+ }
+
+ public final int getType() {
+ return CONFLICT;
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/extension/ConflictDefinitionElement.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/extension/ConflictDefinitionElement.java
new file mode 100644
index 00000000000..15ff793894c
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/extension/ConflictDefinitionElement.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * 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.managedbuilder.internal.tcmodification.extension;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+
+public class ConflictDefinitionElement extends MatchObjectList {
+ public static final String ELEMENT_NAME = "conflictDefinition"; //$NON-NLS-1$
+
+ public ConflictDefinitionElement(IConfigurationElement element)
+ throws IllegalArgumentException {
+ super(element);
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/extension/MatchObjectElement.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/extension/MatchObjectElement.java
new file mode 100644
index 00000000000..d9c2f734cc6
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/extension/MatchObjectElement.java
@@ -0,0 +1,275 @@
+/*******************************************************************************
+ * 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.managedbuilder.internal.tcmodification.extension;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+import org.eclipse.cdt.managedbuilder.internal.core.IRealBuildObjectAssociation;
+import org.eclipse.cdt.managedbuilder.internal.tcmodification.ObjectTypeBasedStorage;
+import org.eclipse.core.runtime.IConfigurationElement;
+
+public class MatchObjectElement {
+ public static String ELEMENT_NAME = "matchObject"; //$NON-NLS-1$
+ private static String ATTR_OBJECT_TYPE = "objectType"; //$NON-NLS-1$
+ private static String ATTR_OBJECT_IDS = "objectIds"; //$NON-NLS-1$
+ private static String ELEMENT_PATTERN = "pattern"; //$NON-NLS-1$
+ private static String ATTR_PATTERN_TYPE_SEARCH_SCOPE = "searchScope"; //$NON-NLS-1$
+ private static String ATTR_PATTERN_TYPE_ID_TYPE = "objectIdsType"; //$NON-NLS-1$
+
+ private static String DELIMITER = ";"; //$NON-NLS-1$
+
+ private int fObjectType;
+ private PatternElement[] fPatterns;
+ private int fHash;
+
+ public static class TypeToStringAssociation {
+ private int fType;
+ private String fString;
+ private static ObjectTypeBasedStorage fTypeAssociationStorage = new ObjectTypeBasedStorage();
+ private static Map fStringAssociationStorage = new HashMap();
+
+ public static TypeToStringAssociation TOOL = new TypeToStringAssociation(IRealBuildObjectAssociation.OBJECT_TOOL, "tool"); //$NON-NLS-1$
+ public static TypeToStringAssociation TOOLCHAIN = new TypeToStringAssociation(IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, "toolChain"); //$NON-NLS-1$
+ public static TypeToStringAssociation CONFIGURATION = new TypeToStringAssociation(IRealBuildObjectAssociation.OBJECT_CONFIGURATION, "configuration"); //$NON-NLS-1$
+ public static TypeToStringAssociation BUILDER = new TypeToStringAssociation(IRealBuildObjectAssociation.OBJECT_BUILDER, "builder"); //$NON-NLS-1$
+
+ private TypeToStringAssociation(int type, String string){
+ fType = type;
+ fString = string;
+ fTypeAssociationStorage.set(type, this);
+ fStringAssociationStorage.put(fString, this);
+ }
+
+ public int getType(){
+ return fType;
+ }
+
+ public String getString(){
+ return fString;
+ }
+
+ public static TypeToStringAssociation getAssociation(String str){
+ return (TypeToStringAssociation)fStringAssociationStorage.get(str);
+ }
+
+ public static TypeToStringAssociation getAssociation(int type){
+ return (TypeToStringAssociation)fTypeAssociationStorage.get(type);
+ }
+ }
+
+ private static class PatternTypeKey {
+ private int fType;
+
+ PatternTypeKey(PatternElement el){
+ fType = el.getCompleteOredTypeValue();
+ }
+
+ public boolean equals(Object obj) {
+ if(obj == this)
+ return true;
+
+ if(!(obj instanceof PatternTypeKey))
+ return false;
+
+ return fType == ((PatternTypeKey)obj).fType;
+ }
+
+ public int hashCode() {
+ return fType;
+ }
+ }
+
+ public class PatternElement {
+ private HashSet fIds;
+ private int fHash;
+ private int fType;
+
+ private static final int SEARCH_TYPE_MASK = 0xff;
+ private static final int SEARCH_TYPE_OFFSET = 0;
+ public static final int TYPE_SEARCH_EXTENSION_OBJECT = 1 << SEARCH_TYPE_OFFSET;
+ public static final int TYPE_SEARCH_ALL_EXTENSION_SUPERCLASSES = 1 << 1 + SEARCH_TYPE_OFFSET;
+ private static final int DEFAULT_PATTERN_SEARCH_TYPE = TYPE_SEARCH_EXTENSION_OBJECT;
+
+ private static final String EXTENSION_OBJECT = "EXTENSION_OBJECT"; //$NON-NLS-1$
+ private static final String ALL_EXTENSION_SUPERCLASSES = "ALL_EXTENSION_SUPERCLASSES"; //$NON-NLS-1$
+
+ private static final int ID_TYPE_MASK = 0xff00;
+ private static final int ID_TYPE_OFFSET = 8;
+ public static final int TYPE_ID_EXACT_MATCH = 1 << ID_TYPE_OFFSET;
+ public static final int TYPE_ID_REGEXP = 1 << 1 + ID_TYPE_OFFSET;
+ private static final int DEFAULT_PATTERN_ID_TYPE = TYPE_ID_EXACT_MATCH;
+
+ private static final String EXACT_MATCH = "EXACT_MATCH"; //$NON-NLS-1$
+ private static final String REGEGP = "REGEXP"; //$NON-NLS-1$
+
+ PatternElement(IConfigurationElement el, int defaultSearchType, int defaultIdType){
+ String tmp = el.getAttribute(ATTR_OBJECT_IDS);
+ fIds = new HashSet(Arrays.asList(CDataUtil.stringToArray(tmp, DELIMITER)));
+
+ int type = 0;
+ tmp = el.getAttribute(ATTR_PATTERN_TYPE_SEARCH_SCOPE);
+ if(tmp == null) {
+ type = defaultSearchType;
+ } else {
+ if(EXTENSION_OBJECT.equals(tmp)){
+ type = TYPE_SEARCH_EXTENSION_OBJECT;
+ } else if (ALL_EXTENSION_SUPERCLASSES.equals(tmp)){
+ type = TYPE_SEARCH_ALL_EXTENSION_SUPERCLASSES;
+ } else {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ tmp = el.getAttribute(ATTR_PATTERN_TYPE_ID_TYPE);
+ if(tmp == null) {
+ type |= defaultIdType;
+ } else {
+ if(EXACT_MATCH.equals(tmp)){
+ type |= TYPE_ID_EXACT_MATCH;
+ } else if (REGEGP.equals(tmp)){
+ type |= TYPE_ID_REGEXP;
+ } else {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ fType = type;
+ }
+
+ private PatternElement(HashSet ids, int type){
+ fIds = ids;
+ fType = type;
+ }
+
+ public String[] getIds(){
+ return (String[])fIds.toArray(new String[fIds.size()]);
+ }
+
+ public boolean equals(Object obj) {
+ if(obj == this)
+ return true;
+
+ if(!(obj instanceof PatternElement))
+ return false;
+
+ PatternElement other = (PatternElement)obj;
+ if(other.fIds.size() != fIds.size())
+ return false;
+
+ return other.fIds.containsAll(fIds);
+ }
+
+ public int hashCode() {
+ if(fHash == 0){
+ fHash = fIds.hashCode();
+ }
+ return fHash;
+ }
+
+ public PatternElement merge(PatternElement el) throws IllegalArgumentException {
+ if(el.fType != fType)
+ throw new IllegalArgumentException();
+
+ HashSet set = new HashSet();
+ set.addAll(fIds);
+ set.addAll(el.fIds);
+ return new PatternElement(set, fType);
+ }
+
+ public int getSearchType(){
+ return fType & SEARCH_TYPE_MASK;
+ }
+
+ public int getIdType(){
+ return fType & ID_TYPE_MASK;
+ }
+
+ public int getCompleteOredTypeValue(){
+ return fType;
+ }
+ }
+
+ public MatchObjectElement(IConfigurationElement element) throws IllegalArgumentException {
+ TypeToStringAssociation assoc = TypeToStringAssociation.getAssociation(element.getAttribute(ATTR_OBJECT_TYPE));
+ if(assoc == null)
+ throw new IllegalArgumentException();
+
+ fObjectType = assoc.getType();
+
+ Map patternMap = new HashMap();
+ int defaultSearchType = PatternElement.DEFAULT_PATTERN_SEARCH_TYPE;
+ int defaultIdType = PatternElement.DEFAULT_PATTERN_ID_TYPE;
+
+ if(element.getAttribute(ATTR_OBJECT_IDS) != null){
+ PatternElement el = new PatternElement(element, defaultSearchType, defaultIdType);
+ patternMap.put(new PatternTypeKey(el), el);
+ defaultSearchType = el.getSearchType();
+ defaultIdType = el.getIdType();
+ }
+
+ IConfigurationElement patternsChildren[] = element.getChildren(ELEMENT_PATTERN);
+ if(patternsChildren.length != 0){
+ for(int i = 0; i < patternsChildren.length; i++){
+ PatternElement el = new PatternElement(patternsChildren[i], defaultSearchType, defaultIdType);
+ PatternTypeKey key = new PatternTypeKey(el);
+ PatternElement cur = (PatternElement)patternMap.get(key);
+ if(cur != null){
+ patternMap.put(key, cur.merge(el));
+ } else {
+ patternMap.put(key, el);
+ }
+ }
+ }
+
+ if(patternMap.size() == 0) {
+ throw new IllegalArgumentException();
+ }
+
+ fPatterns = (PatternElement[])patternMap.values().toArray(new PatternElement[patternMap.size()]);
+ }
+
+ public int getObjectType(){
+ return fObjectType;
+ }
+
+ public boolean equals(Object obj) {
+ if(obj == this)
+ return true;
+
+ if(!(obj instanceof MatchObjectElement))
+ return false;
+
+ MatchObjectElement other = (MatchObjectElement)obj;
+ if(fObjectType != other.fObjectType)
+ return false;
+
+ return Arrays.equals(other.fPatterns, fPatterns);
+ }
+
+ public int hashCode() {
+ if(fHash == 0){
+ int hash = fObjectType;
+ for(int i = 0; i < fPatterns.length; i++){
+ hash += fPatterns[i].hashCode();
+ }
+ fHash = hash;
+ }
+ return fHash;
+ }
+
+ public PatternElement[] getPatterns(){
+ return (PatternElement[])fPatterns.clone();
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/extension/MatchObjectList.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/extension/MatchObjectList.java
new file mode 100644
index 00000000000..b7ca254935f
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/extension/MatchObjectList.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * 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.managedbuilder.internal.tcmodification.extension;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+
+public class MatchObjectList {
+ private MatchObjectElement[] fObjects;
+
+ public MatchObjectList(IConfigurationElement element) throws IllegalArgumentException {
+ IConfigurationElement[] objectEls = element.getChildren(MatchObjectElement.ELEMENT_NAME);
+ MatchObjectElement[] objects = new MatchObjectElement[objectEls.length];
+ for(int i = 0; i < objectEls.length; i++){
+ objects[i] = new MatchObjectElement(objectEls[i]);
+ }
+ fObjects = objects;
+ }
+
+ public MatchObjectElement[] getMatchObjects(){
+ return (MatchObjectElement[])fObjects.clone();
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/extension/ObjectSetListBasedDefinition.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/extension/ObjectSetListBasedDefinition.java
new file mode 100644
index 00000000000..86940bebd6d
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/extension/ObjectSetListBasedDefinition.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * 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.managedbuilder.internal.tcmodification.extension;
+
+import org.eclipse.cdt.managedbuilder.internal.tcmodification.ObjectSetList;
+
+public abstract class ObjectSetListBasedDefinition {
+ public static final int CONFLICT = 1;
+ private ObjectSetList fList;
+
+ protected ObjectSetListBasedDefinition(ObjectSetList list){
+ fList = list;
+ }
+
+ public ObjectSetList getObjectSetList(){
+ return fList;
+ }
+
+ public abstract int getType();
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/extension/RulesManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/extension/RulesManager.java
new file mode 100644
index 00000000000..ab120a57e64
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/tcmodification/extension/RulesManager.java
@@ -0,0 +1,294 @@
+/*******************************************************************************
+ * 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.managedbuilder.internal.tcmodification.extension;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.cdt.managedbuilder.internal.core.IRealBuildObjectAssociation;
+import org.eclipse.cdt.managedbuilder.internal.tcmodification.IObjectSet;
+import org.eclipse.cdt.managedbuilder.internal.tcmodification.Messages;
+import org.eclipse.cdt.managedbuilder.internal.tcmodification.ObjectSet;
+import org.eclipse.cdt.managedbuilder.internal.tcmodification.ObjectSetList;
+import org.eclipse.cdt.managedbuilder.internal.tcmodification.PerTypeMapStorage;
+import org.eclipse.cdt.managedbuilder.internal.tcmodification.TcModificationUtil;
+import org.eclipse.cdt.managedbuilder.internal.tcmodification.extension.MatchObjectElement.PatternElement;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+
+
+public class RulesManager {
+ private static RulesManager fInstance;
+ private static final String EXTENSION_POINT_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".tcModificationInfo"; //$NON-NLS-1$
+
+ private ConflictDefinition[] fConflictDefinitions;
+
+ private Map fMatchObjectMap = new HashMap();
+ private PerTypeMapStorage fObjToChildSuperClassMap;
+ private StarterJob fStarter;
+ private boolean fIsStartInited;
+
+ private class StarterJob extends Job {
+
+ private StarterJob() {
+ super(Messages.getString("RulesManager.1")); //$NON-NLS-1$
+ setSystem(true);
+ }
+
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ loadExtensions();
+ } finally {
+ fStarter = null;
+ }
+ return Status.OK_STATUS;
+ }
+
+ }
+
+ private RulesManager(){
+ }
+
+ public static RulesManager getInstance(){
+ if(fInstance == null)
+ fInstance = getInstanceSynch();
+ return fInstance;
+ }
+
+ public synchronized static RulesManager getInstanceSynch(){
+ if(fInstance == null)
+ fInstance = new RulesManager();
+ return fInstance;
+ }
+
+ public void start(){
+ if(fIsStartInited)
+ return;
+
+ synchronized (this) {
+ if(fIsStartInited)
+ return;
+
+ fIsStartInited = true;
+ }
+
+ fStarter = new StarterJob();
+ fStarter.schedule();
+ }
+
+ private void loadExtensions(){
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_POINT_ID);
+ if(extensionPoint == null){
+ fConflictDefinitions = new ConflictDefinition[0];
+ } else {
+ IExtension[] extensions = extensionPoint.getExtensions();
+ List conflictDefs = new ArrayList();
+ for (int i = 0; i < extensions.length; ++i) {
+ IExtension extension = extensions[i];
+ IConfigurationElement[] elements = extension.getConfigurationElements();
+ for(int k = 0; k < elements.length; k++){
+ IConfigurationElement el = elements[k];
+ String elName = el.getName();
+ if(ConflictDefinitionElement.ELEMENT_NAME.equals(elName)){
+ try {
+ ConflictDefinitionElement cde = new ConflictDefinitionElement(el);
+ ConflictDefinition cd = resolve(cde);
+ if(cd != null)
+ conflictDefs.add(cd);
+ } catch (IllegalArgumentException e){
+ ManagedBuilderCorePlugin.log(e);
+ }
+ }
+ }
+ }
+
+ fConflictDefinitions = (ConflictDefinition[])conflictDefs.toArray(new ConflictDefinition[conflictDefs.size()]);
+ }
+ }
+
+ private ConflictDefinition resolve(ConflictDefinitionElement el) throws IllegalArgumentException {
+ MatchObjectElement mos[] = el.getMatchObjects();
+ if(mos.length != 2)
+ throw new IllegalArgumentException();
+
+ IObjectSet oss[] = new IObjectSet[mos.length];
+
+ for(int i = 0; i < mos.length; i++){
+ oss[i] = resolve(mos[i]);
+ if(oss[i].getNumObjects() == 0){
+ //no conflicts
+ return null;
+ }
+ }
+
+ return new ConflictDefinition(new ObjectSetList(oss));
+ }
+
+ private IObjectSet resolve(MatchObjectElement el){
+ IObjectSet oSet = (IObjectSet)fMatchObjectMap.get(el);
+ if(oSet == null){
+ int type = el.getObjectType();
+ PatternElement[] patterns = el.getPatterns();
+ HashSet objectsSet = new HashSet();
+ for(int i = 0; i < patterns.length; i++){
+ PatternElement pattern = patterns[i];
+ processPattern(type, pattern, objectsSet);
+ }
+ oSet = new ObjectSet(type, objectsSet);
+ fMatchObjectMap.put(el, oSet);
+ }
+ return oSet;
+ }
+
+ private IRealBuildObjectAssociation[] getObjectsForId(int objType, String id, int idType){
+ if(idType == PatternElement.TYPE_ID_EXACT_MATCH){
+ IRealBuildObjectAssociation obj = TcModificationUtil.getObjectById(objType, id);
+ if(obj != null)
+ return new IRealBuildObjectAssociation[]{obj};
+ return new IRealBuildObjectAssociation[0];
+ }
+
+ IRealBuildObjectAssociation[] allObjs = TcModificationUtil.getExtensionObjects(objType);
+ Pattern pattern = Pattern.compile(id);
+ List list = new ArrayList();
+
+ for(int i = 0; i < allObjs.length; i++){
+ if(pattern.matcher(allObjs[i].getId()).matches())
+ list.add(allObjs[i]);
+ }
+
+ return (IRealBuildObjectAssociation[])list.toArray(new IRealBuildObjectAssociation[list.size()]);
+ }
+
+ private Set processPattern(int objType, PatternElement el, Set set){
+ if(set == null)
+ set = new HashSet();
+
+ String ids[] = el.getIds();
+ if(el.getSearchType() == PatternElement.TYPE_SEARCH_EXTENSION_OBJECT){
+ for(int i = 0; i < ids.length; i++){
+ IRealBuildObjectAssociation objs[] = getObjectsForId(objType, ids[i], el.getIdType());
+ for(int k = 0; k < objs.length; k++){
+ set.add(objs[k].getRealBuildObject());
+ }
+ }
+ } else if (el.getSearchType() == PatternElement.TYPE_SEARCH_ALL_EXTENSION_SUPERCLASSES){
+ IRealBuildObjectAssociation[] allReal = TcModificationUtil.getRealObjects(objType);
+ for(int i = 0; i < ids.length; i++){
+ IRealBuildObjectAssociation []objs = getObjectsForId(objType, ids[i], el.getIdType());
+ for(int k = 0; k < objs.length; k++){
+ IRealBuildObjectAssociation obj = objs[k];
+
+ set.add(obj.getRealBuildObject());
+
+ Set childRealSet = getChildSuperClassRealSet(obj, allReal);
+
+ set.addAll(childRealSet);
+// for(int k = 0; k < allReal.length; k++){
+// IRealBuildObjectAssociation otherReal = allReal[k];
+// if(otherReal == obj || set.contains(otherReal))
+// continue;
+//
+// if("tcm.derive.tc1".equals(otherReal.getId())){
+// int f = 0; f++;
+// }
+// IRealBuildObjectAssociation[] identics = otherReal.getIdenticBuildObjects();
+// for(int j = 0; j < identics.length; j++){
+// IRealBuildObjectAssociation identic = identics[j];
+// for(identic = identic.getSuperClassObject(); identic != null; identic = identic.getSuperClassObject()){
+// if(identic == obj){
+// set.add(identic.getRealBuildObject());
+// }
+// }
+// }
+// }
+ }
+ }
+ }
+
+ return set;
+ }
+
+ private Set getChildSuperClassRealSet(IRealBuildObjectAssociation obj, IRealBuildObjectAssociation[] all){
+ if(fObjToChildSuperClassMap == null)
+ fObjToChildSuperClassMap = new PerTypeMapStorage();
+
+ if(all == null)
+ all = TcModificationUtil.getExtensionObjects(obj.getType());
+
+ Map map = fObjToChildSuperClassMap.getMap(obj.getType(), true);
+ Set set = (Set)map.get(obj);
+ if(set == null){
+ set = createChildSuperClassRealSet(obj, all, null);
+ map.put(obj, set);
+ }
+
+ return set;
+ }
+
+ private static Set createChildSuperClassRealSet(IRealBuildObjectAssociation obj, IRealBuildObjectAssociation[] all, Set set){
+ if(set == null)
+ set = new HashSet();
+
+ if(all == null)
+ all = TcModificationUtil.getExtensionObjects(obj.getType());
+
+ for(int i = 0; i < all.length; i++){
+ IRealBuildObjectAssociation cur = all[i];
+ for(IRealBuildObjectAssociation el = cur.getSuperClassObject(); el != null; el = el.getSuperClassObject()){
+ if(el == obj){
+ IRealBuildObjectAssociation realQuickTest = null;
+ for(IRealBuildObjectAssociation found = cur; found != obj; found = found.getSuperClassObject()){
+ IRealBuildObjectAssociation real = found.getRealBuildObject();
+ if(real != realQuickTest){
+ set.add(real);
+ realQuickTest = real;
+ }
+ }
+ }
+ }
+ }
+
+ return set;
+ }
+
+ public ObjectSetListBasedDefinition[] getRules(int ruleType){
+ checkInitialization();
+ return (ConflictDefinition[])fConflictDefinitions.clone();
+ }
+
+ private void checkInitialization(){
+ if(!fIsStartInited)
+ throw new IllegalStateException();
+
+ StarterJob starter = fStarter;
+
+ if(starter != null){
+ try {
+ starter.join();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/CompatibilityStatus.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/CompatibilityStatus.java
new file mode 100644
index 00000000000..808b0411be2
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/CompatibilityStatus.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * 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.managedbuilder.tcmodification;
+
+import org.eclipse.cdt.managedbuilder.core.IBuildObject;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.cdt.managedbuilder.internal.tcmodification.ConflictSet;
+import org.eclipse.core.runtime.Status;
+
+
+public final class CompatibilityStatus extends Status {
+
+ public static final CompatibilityStatus OK_COMPATIBILITY_STATUS = new CompatibilityStatus(OK, ManagedBuilderCorePlugin.getUniqueIdentifier(), ""); //$NON-NLS-1$
+
+ private ConflictSet fConflictSet;
+
+// private CompatibilityStatus(int severity, String pluginId, int code,
+// String message, Throwable exception) {
+// super(severity, pluginId, code, message, exception);
+// }
+
+// private CompatibilityStatus(int severity, String pluginId, String message,
+// Throwable exception) {
+// super(severity, pluginId, message, exception);
+// }
+
+ private CompatibilityStatus(int severity, String pluginId, String message) {
+ super(severity, pluginId, message);
+ }
+
+ public CompatibilityStatus(int severity, String message, ConflictSet cs) {
+ this(severity, ManagedBuilderCorePlugin.getUniqueIdentifier(), message);
+
+ fConflictSet = cs;
+ }
+
+ public IConflict[] getConflicts(){
+ return fConflictSet != null ? fConflictSet.getConflicts() : ConflictSet.EMPTY_CONFLICT_ARRAY;
+ }
+
+ public IConflict[] getConflictsWith(int objectType){
+ return fConflictSet != null ? fConflictSet.getConflictsWith(objectType) : ConflictSet.EMPTY_CONFLICT_ARRAY;
+ }
+
+ public IBuildObject[] getConflictingObjects(int objectType){
+ return fConflictSet != null ? fConflictSet.getConflictingObjects(objectType) : ConflictSet.EMPTY_BO_ARRAY;
+ }
+
+ public IConflict getConflictWith(IBuildObject bo){
+ return fConflictSet != null ? fConflictSet.getConflictWith(bo) : null;
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IApplicableModification.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IApplicableModification.java
new file mode 100644
index 00000000000..ef621ee2d01
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IApplicableModification.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * 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.managedbuilder.tcmodification;
+
+
+public interface IApplicableModification extends IModification {
+ /**
+ * applies the settings made to the given modification to the underlying
+ * resource info
+ * @throws CoreException
+ */
+ //TODO: not implemented yet
+// void apply() throws CoreException;
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IConfigurationModification.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IConfigurationModification.java
new file mode 100644
index 00000000000..4a2effe1789
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IConfigurationModification.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * 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.managedbuilder.tcmodification;
+
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
+
+public interface IConfigurationModification extends IFolderInfoModification {
+ /**
+ * returns a builder currently assigned to this Configuration Modification
+ * @return
+ */
+ IBuilder getBuilder();
+
+ IBuilder getRealBuilder();
+
+ /**
+ * returns a set of compatible builders
+ * @return
+ */
+ IBuilder[] getCompatibleBuilders();
+
+ /**
+ * returns the compatibility status for the builder
+ *
+ * @return
+ */
+ CompatibilityStatus getBuilderCompatibilityStatus();
+
+ /**
+ * returns the compatibility status for the builder,
+ * i.e. true when the getCompatibilityStatus() returns an non-ERROR status,
+ * and false otherwise
+ *
+ * @return
+ */ boolean isBuilderCompatible();
+
+ /**
+ * sets the builder to this Configuration Modification
+ * Note that this does NOT apply the builder to the underlying configuration
+ * For applying the Modification settings the {@link IApplicableModification#apply()}
+ * method should be called
+ *
+ * @param builder
+ */
+ void setBuilder(IBuilder builder);
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IConflict.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IConflict.java
new file mode 100644
index 00000000000..250e234c158
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IConflict.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * 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.managedbuilder.tcmodification;
+
+import org.eclipse.cdt.managedbuilder.core.IBuildObject;
+import org.eclipse.core.runtime.IPath;
+
+public interface IConflict {
+ int INCOMPATIBLE = 1;
+ int SOURCE_EXT_CONFLICT = 1 << 1;
+
+ int getConflictType();
+
+ int getObjectType();
+
+ IBuildObject getBuildObject();
+
+
+ IPath[] getPaths();
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IFileInfoModification.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IFileInfoModification.java
new file mode 100644
index 00000000000..b03c5bec3c1
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IFileInfoModification.java
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * 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.managedbuilder.tcmodification;
+
+public interface IFileInfoModification extends IToolListModification {
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IFolderInfoModification.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IFolderInfoModification.java
new file mode 100644
index 00000000000..5db8df260c1
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IFolderInfoModification.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * 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.managedbuilder.tcmodification;
+
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+
+public interface IFolderInfoModification extends IToolListModification {
+
+ /**
+ * returns a set of tool-chains compatible with the current one
+ * @return
+ */
+ IToolChain[] getCompatibleToolChains();
+
+ /**
+ * returns compatibility status for the current tool-chain
+ * @return
+ */
+ CompatibilityStatus getToolChainCompatibilityStatus();
+
+ /**
+ * answers whether the current tool-chain is compatible,
+ * i.e. whether the {@link #getToolChainCompatibilityStatus()} returns a
+ * non-ERROR status
+ *
+ * @return
+ */
+ boolean isToolChainCompatible();
+
+ /**
+ * returns the current tool-chain
+ * @return
+ */
+ IToolChain getToolChain();
+
+ /**
+ * sets the current tool-chain
+ * once the tool-chain is changed all child Tool and Builder Modifications
+ * become invalid, i.e. one should re-query the modifications needed
+ *
+ * @param tc
+ */
+ void setToolChain(IToolChain tc);
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IModification.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IModification.java
new file mode 100644
index 00000000000..b2dd0aff021
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IModification.java
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * 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.managedbuilder.tcmodification;
+
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
+
+public interface IModification {
+ IResourceInfo getResourceInfo();
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IModificationOperation.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IModificationOperation.java
new file mode 100644
index 00000000000..4e4f5116910
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IModificationOperation.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * 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.managedbuilder.tcmodification;
+
+import org.eclipse.cdt.managedbuilder.core.ITool;
+
+public interface IModificationOperation {
+ /**
+ * specifies the replacement tool, i.e. tool that is to replace the tools
+ * presented with the IToolModification containing this operation
+ * For project IToolModification the replacement tool is a system tool
+ * that is to replace the project tool
+ * For system IToolModification the replacement tool is a project tool
+ * to be replaced with the system tool
+ *
+ * @return
+ */
+ ITool getReplacementTool();
+
+ /**
+ * returns the containing {@link IToolModification}
+ * @return
+ */
+ IToolModification getToolModification();
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IToolChainModificationManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IToolChainModificationManager.java
new file mode 100644
index 00000000000..490b31072fb
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IToolChainModificationManager.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * 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.managedbuilder.tcmodification;
+
+import org.eclipse.cdt.managedbuilder.core.IFileInfo;
+import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
+import org.eclipse.cdt.managedbuilder.internal.core.IRealBuildObjectAssociation;
+
+public interface IToolChainModificationManager {
+ int OBJECT_CONFIGURATION = IRealBuildObjectAssociation.OBJECT_CONFIGURATION;
+ int OBJECT_TOOLCHAIN = IRealBuildObjectAssociation.OBJECT_TOOLCHAIN;
+ int OBJECT_TOOL = IRealBuildObjectAssociation.OBJECT_TOOL;
+ int OBJECT_BUILDER = IRealBuildObjectAssociation.OBJECT_BUILDER;
+
+ /**
+ * returns the modification info calculator for the given folder info
+ * if the folder info is a root folder info,
+ * returns the {@link IConfigurationModification}
+ *
+ * @param rcInfo
+ * @return
+ */
+ IFolderInfoModification getModification(IFolderInfo rcInfo);
+
+ /**
+ * returns the modification info calculator for the given file info
+ *
+ * @param rcInfo
+ * @return
+ */
+ IFileInfoModification getModification(IFileInfo rcInfo);
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IToolListModification.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IToolListModification.java
new file mode 100644
index 00000000000..15dfcc7d4ef
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IToolListModification.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * 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.managedbuilder.tcmodification;
+
+import org.eclipse.cdt.managedbuilder.core.ITool;
+
+public interface IToolListModification extends IApplicableModification {
+ /**
+ * specifies the set of tools to be validated
+ * once the set of tools is modified,
+ * all previously calculated ToolModifications become invalid,
+ * i.e. one should re-query the ToolModification for each tool needed
+ * Note that this method does NOT apply the tools to the underlying resource info
+ * For applying the settings the {@link IApplicableModification#apply()} method should be called
+ *
+ * @param tools
+ */
+ void changeProjectTools(ITool removeTools, ITool addTool);
+
+ /**
+ * returns the list of tools assigned to the given resource info
+ * on the ToolListModificatrion creation the tool-list is the one
+ * contained by the given resource info
+ * the list can be changed by calling the {@link #setProjectTools(ITool[])} method
+ *
+ * @return
+ */
+ ITool[] getProjectTools();
+
+// ITool[] getSystemTools();
+
+ /**
+ * returns a list of tool modifications for all project tools contained
+ * by this toollist modification
+ */
+ IToolModification[] getProjectToolModifications();
+
+ /**
+ * returns a list of tool modifications for all system tools not contained
+ * by this toollist modification
+ */
+ IToolModification[] getSystemToolModifications();
+
+ /**
+ * returns a tool-list modification for the given tool
+ * if a is one of the project tools contained by this tool-list modification
+ * the returned ToolModification is a project modification for that tool
+ * otherwise the returned ToolModification tool is a system tool modification for the
+ * given system tool
+ *
+ * @param tool
+ * @return
+ */
+ IToolModification getToolModification(ITool tool);
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IToolModification.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IToolModification.java
new file mode 100644
index 00000000000..9e90c1a3195
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/tcmodification/IToolModification.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * 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.managedbuilder.tcmodification;
+
+import org.eclipse.cdt.managedbuilder.core.ITool;
+
+public interface IToolModification extends IModification {
+ /**
+ * returns the detailed compatibility status for this tool
+ * for project tools specifies whether the tool is compatible
+ * with the configuration
+ * for system tools specifies whether the tool can be added to the
+ * configuration
+ *
+ * @return
+ */
+ CompatibilityStatus getCompatibilityStatus();
+
+ /**
+ * returns the compatibility status for this tool,
+ * i.e. true when the getCompatibilityStatus() returns an non-ERROR status,
+ * and false otherwise
+ *
+ * for project tools specifies whether the tool is compatible
+ * with the configuration
+ * for system tools specifies whether the tool can be added to the
+ * configuration
+ *
+ * @return
+ */
+ boolean isCompatible();
+
+ /**
+ * returns the tool of the given Modification
+ * @return
+ */
+ ITool getTool();
+
+ /**
+ * specifies whether the current tools belongs to the resource configuration
+ * @return
+ */
+ boolean isProjectTool();
+
+ /**
+ * returns the list of supported operations
+ * @return
+ */
+ IModificationOperation[] getSupportedOperations();
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildListComparator.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildListComparator.java
index 27721294d31..06c9ec5950b 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildListComparator.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildListComparator.java
@@ -11,7 +11,9 @@
package org.eclipse.cdt.managedbuilder.ui.properties;
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue;
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.ui.newui.CDTListComparator;
/**
@@ -19,7 +21,8 @@ import org.eclipse.cdt.ui.newui.CDTListComparator;
*/
public class BuildListComparator extends CDTListComparator {
private static BuildListComparator comparator = null;
-
+ private static final String EMPTY = ""; //$NON-NLS-1$
+
public static CDTListComparator getInstance() {
if (comparator == null)
comparator = new BuildListComparator();
@@ -32,9 +35,27 @@ public class BuildListComparator extends CDTListComparator {
ITool c1 = (ITool)a;
ITool c2 = (ITool)b;
String s1 = c1.getName();
- if (s1 == null) s1 = ""; //$NON-NLS-1$
+ if (s1 == null) s1 = EMPTY;
String s2 = c2.getName();
- if (s2 == null) s2 = ""; //$NON-NLS-1$
+ if (s2 == null) s2 = EMPTY;
+ return s1.compareToIgnoreCase(s2);
+ }
+ if (a instanceof IToolChain) {
+ IToolChain c1 = (IToolChain)a;
+ IToolChain c2 = (IToolChain)b;
+ String s1 = c1.getUniqueRealName();
+ if (s1 == null) s1 = EMPTY;
+ String s2 = c2.getUniqueRealName();
+ if (s2 == null) s2 = EMPTY;
+ return s1.compareToIgnoreCase(s2);
+ }
+ if (a instanceof IBuilder) {
+ IBuilder c1 = (IBuilder)a;
+ IBuilder c2 = (IBuilder)b;
+ String s1 = c1.getUniqueRealName();
+ if (s1 == null) s1 = EMPTY;
+ String s2 = c2.getUniqueRealName();
+ if (s2 == null) s2 = EMPTY;
return s1.compareToIgnoreCase(s2);
}
if (a instanceof IBuildPropertyValue) {
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolChainEditTab.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolChainEditTab.java
index 85231a8a23a..ac70ae60ba7 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolChainEditTab.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolChainEditTab.java
@@ -12,10 +12,13 @@ package org.eclipse.cdt.managedbuilder.ui.properties;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.managedbuilder.core.BuildException;
+import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IBuilder;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IFileInfo;
@@ -24,24 +27,46 @@ import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.core.IRealBuildObjectAssociation;
import org.eclipse.cdt.managedbuilder.internal.core.ToolChain;
+import org.eclipse.cdt.managedbuilder.tcmodification.CompatibilityStatus;
+import org.eclipse.cdt.managedbuilder.tcmodification.IConfigurationModification;
+import org.eclipse.cdt.managedbuilder.tcmodification.IConflict;
+import org.eclipse.cdt.managedbuilder.tcmodification.IFileInfoModification;
+import org.eclipse.cdt.managedbuilder.tcmodification.IFolderInfoModification;
+import org.eclipse.cdt.managedbuilder.tcmodification.IModificationOperation;
+import org.eclipse.cdt.managedbuilder.tcmodification.IToolChainModificationManager;
+import org.eclipse.cdt.managedbuilder.tcmodification.IToolModification;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
public class ToolChainEditTab extends AbstractCBuildPropertyTab {
+ public static final IToolChainModificationManager tcmm = ManagedBuildManager.getToolChainModificationManager();
private static final String NO_TC = Messages.getString("StdProjectTypeHandler.0"); //$NON-NLS-1$
private static final IToolChain[] r_tcs = ManagedBuildManager.getRealToolChains();
private static final IBuilder[] r_bs = ManagedBuildManager.getRealBuilders();
private static final ITool[] r_tools = ManagedBuildManager.getRealTools();
+ private static final Color red = Display.getDefault().getSystemColor(SWT.COLOR_RED);
+ private static final String SPACE = " "; //$NON-NLS-1$
+
+ static final Image IMG_WARNING = CPluginImages.get(CPluginImages.IMG_OBJS_REFACTORING_WARNING);
+ static final Image IMG_ERROR = CPluginImages.get(CPluginImages.IMG_OBJS_REFACTORING_ERROR);
+ static final Image IMG_INFO = CPluginImages.get(CPluginImages.IMG_OBJS_REFACTORING_INFO);
+ static final Image IMG_ARROW = CPluginImages.get(CPluginImages.IMG_PREFERRED);
private Text text;
private Button b_dispCompatible;
@@ -51,6 +76,10 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
private Button button_edit;
private Group tools_group;
+ private Label st_builder;
+ private Label st_toolchain;
+ private Label st_tool;
+
private IBuilder[] v_bs;
private IToolChain[] v_tcs;
private ITool[] v_tools;
@@ -74,7 +103,10 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
modifyToolchain();
}});
c_toolchain.setEnabled(!page.isForFile());
-
+
+ st_toolchain = setupLabel(usercomp, EMPTY_STR, 2, GridData.FILL_HORIZONTAL);
+ st_toolchain.setForeground(red);
+
setupLabel(usercomp, Messages.getString("ToolChainEditTab.2"), 2, GridData.BEGINNING); //$NON-NLS-1$
c_builder = new Combo(usercomp, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL);
@@ -86,6 +118,9 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
}});
c_builder.setEnabled(page.isForProject());
+ st_builder = setupLabel(usercomp, EMPTY_STR, 2, GridData.FILL_HORIZONTAL);
+ st_builder.setForeground(red);
+
// make table for tools list
if (page.isForFile()) {
Group g = setupGroup(usercomp, Messages.getString("ToolChainEditTab.5"), 2, GridData.FILL_BOTH); //$NON-NLS-1$
@@ -97,6 +132,9 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
public void widgetSelected(SelectionEvent e) {
saveToolSelected();
}});
+
+ st_tool = setupLabel(g, EMPTY_STR, 2, GridData.FILL_HORIZONTAL);
+ st_tool.setForeground(red);
} else { // Folder or Project
tools_group = setupGroup(usercomp, Messages.getString("ToolChainEditTab.3"), 2, GridData.FILL_BOTH); //$NON-NLS-1$
@@ -126,36 +164,68 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
ri = cfg.getResourceInfo(rcfg.getPath(), false);
updateData();
}
- private void updateData() {
- v_tcs = new IToolChain[r_tcs.length];
- v_bs = new IBuilder[r_bs.length];
- v_tools = new ITool[r_tools.length];
-
+
+ private void showErrorMessage() {
+ if (ri instanceof IFolderInfo) {
+ IFolderInfoModification foim = tcmm.getModification((IFolderInfo)ri);
+ if (foim.isToolChainCompatible()) {
+ st_toolchain.setText(EMPTY_STR);
+ } else {
+ String s = foim.getToolChainCompatibilityStatus().getMessage();
+ st_toolchain.setText(s);
+ }
+ st_builder.setText(EMPTY_STR);
+ if (foim instanceof IConfigurationModification) {
+ IConfigurationModification cm = (IConfigurationModification)foim;
+ if (!cm.isBuilderCompatible()) {
+ CompatibilityStatus cs = cm.getBuilderCompatibilityStatus();
+ if (cs != null) {
+ String s = cs.getMessage();
+ st_builder.setText(s);
+ }
+ }
+ }
+ } else { // FileInfo
+ IFileInfoModification fim = tcmm.getModification((IFileInfo)ri);
+ fim.getProjectToolModifications();
+ }
+ }
+
+ private void fillToolChainCombo() {
IToolChain tc = null;
if (ri instanceof IFolderInfo)
tc = ManagedBuildManager.getRealToolChain(((IFolderInfo)ri).getToolChain());
- int cnt = 0;
- int pos = -1;
-
+
c_toolchain.removeAll();
boolean isMng = cfg.getBuilder().isManagedBuildOn();
- for (int i=0; i<r_tcs.length; i++) {
- if (r_tcs[i].isSystemObject() &&
- !(
- ((ToolChain)r_tcs[i]).isPreferenceToolChain() &&
- !isMng)
+ ArrayList list = new ArrayList();
+
+ IToolChain[] tcs = r_tcs;
+ if (b_dispCompatible.getSelection() && (ri instanceof IFolderInfo)) {
+ IFolderInfoModification fim = tcmm.getModification((IFolderInfo)ri);
+ tcs = fim.getCompatibleToolChains();
+ IToolChain[] tcs1 = new IToolChain[tcs.length + 1];
+ System.arraycopy(tcs, 0, tcs1, 0, tcs.length);
+ tcs1[tcs.length] = tc; // add existing toolchain
+ tcs = tcs1;
+ }
+ for (int i=0; i<tcs.length; i++) {
+ if (tcs[i].isSystemObject() &&
+ !( ((ToolChain)tcs[i]).isPreferenceToolChain() &&
+ !isMng)
) // NO TOOLCHAIN
continue;
-
- if (b_dispCompatible.getSelection() &&
- (ri instanceof IFolderInfo) &&
- ! ((IFolderInfo)ri).isToolChainCompatible(r_tcs[i]))
- continue;
- c_toolchain.add(r_tcs[i].getUniqueRealName());
- v_tcs[cnt] = r_tcs[i];
- if (r_tcs[i].equals(tc)) pos = cnt;
- cnt++;
+ list.add(tcs[i]);
+ }
+ Collections.sort(list, BuildListComparator.getInstance());
+
+ int pos = -1;
+ v_tcs = (IToolChain[]) list.toArray(new IToolChain[list.size()]);
+ for (int i=0; i<v_tcs.length; i++) {
+ c_toolchain.add(v_tcs[i].getUniqueRealName());
+ if (v_tcs[i].matches(tc)) pos = i;
}
+
if (pos != -1) {
c_toolchain.select(pos);
c_builder.setEnabled(page.isForProject());
@@ -164,27 +234,103 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
c_toolchain.setText(EMPTY_STR); // unprobable case
c_builder.setEnabled(false);
}
-
+ }
+
+ private void fillBuilderCombo() {
IBuilder b = ManagedBuildManager.getRealBuilder(cfg.getBuilder());
- cnt = 0;
- pos = -1;
+ int pos = -1;
c_builder.removeAll();
- for (int i=0; i<r_bs.length; i++) {
- if (r_bs[i].isSystemObject()) continue;
- if (b_dispCompatible.getSelection() &&
- ! cfg.isBuilderCompatible(r_bs[i]))
- continue; // not compatible builder
- c_builder.add(r_bs[i].getUniqueRealName());
- v_bs[cnt] = r_bs[i];
- if (r_bs[i].equals(b)) pos = cnt;
- cnt++;
+ ArrayList list = new ArrayList();
+
+ IBuilder[] bs = r_bs;
+
+ if (b_dispCompatible.getSelection() && (ri instanceof IFolderInfo)) {
+ IFolderInfoModification fim = tcmm.getModification((IFolderInfo)ri);
+ if (fim instanceof IConfigurationModification) {
+ IBuilder[] bs1 = ((IConfigurationModification)fim).getCompatibleBuilders();
+ bs = new IBuilder[bs1.length + 1];
+ System.arraycopy(bs1, 0, bs, 0, bs1.length);
+ bs[bs1.length] = b;
+ }
+ }
+ for (int i=0; i<bs.length; i++) {
+ if (bs[i].isSystemObject())
+ continue;
+ list.add(bs[i]);
+ }
+ bs = null;
+ Collections.sort(list, BuildListComparator.getInstance());
+ v_bs = (IBuilder[])list.toArray(new IBuilder[list.size()]);
+ for (int i=0; i<v_bs.length; i++) {
+ c_builder.add(v_bs[i].getUniqueRealName());
+ if (v_bs[i].matches(b)) pos = i;
}
if (pos != -1)
c_builder.select(pos);
else
c_builder.setText(EMPTY_STR);
- cnt = 0;
+ }
+
+ private ITool getToolForFile() {
+ ITool[] tools = ri.getTools();
+ if (tools != null && tools.length > 0) {
+ for (int i=0; i<tools.length; i++) {
+ if (tools[i] != null && !tools[i].getCustomBuildStep()) {
+ return tools[i];
+ }
+ }
+ }
+ return null;
+ }
+
+ private void fillToolCombo(boolean add, ITool curr) {
+ c_tool.removeAll();
+ int pos = (curr == null) ? v_tools.length : -1;
+ for (int i=0; i<v_tools.length; i++) {
+ if (pos == -1 && curr.matches(v_tools[i])) {
+ pos = i;
+ c_tool.add(curr.getUniqueRealName());
+ } else {
+ c_tool.add(v_tools[i].getUniqueRealName());
+ }
+ }
+ // Add NO_TOOL
+ if (add) {
+ c_tool.add(Messages.getString("ToolChainEditTab.6")); //$NON-NLS-1$
+ }
+ c_tool.select(pos);
+ }
+
+ private void fillToolsList() {
+ updateAllTools(); // modifies v_tools inside !!!
+
+ ToolChain tc = null;
+ if (ri instanceof IFolderInfo)
+ tc = (ToolChain)ManagedBuildManager.getRealToolChain(((IFolderInfo)ri).getToolChain());
+
+ if (page.isForFile()) { // Edit tool in combo for File
+ ITool curr = getToolForFile();
+ boolean canAddNO_TOOL = true;
+ if (ri instanceof IFileInfo && b_dispCompatible.getSelection())
+ canAddNO_TOOL = updateCompatibleTools(curr); // modifies v_tools inside !!!
+ fillToolCombo(canAddNO_TOOL, curr);
+ showToolStatus(curr);
+ } else if (tc != null && tc.isPreferenceToolChain()){ // display tools list for Folder and Project
+ tools_group.setVisible(false);
+ } else {
+ tools_group.setVisible(true);
+ String s = EMPTY_STR;
+ ITool[] tools = ri.getTools();
+ for (int i = 0; i < tools.length; i++)
+ s = s + tools[i].getUniqueRealName() + "\n"; //$NON-NLS-1$
+ text.setText(s);
+ }
+ }
+
+ private void updateAllTools() {
+ int cnt = 0;
+ v_tools = new ITool[r_tools.length];
for (int i=0; i<r_tools.length; i++) {
if (r_tools[i].isSystemObject()) continue;
if (r_tools[i].isAbstract()) continue;
@@ -194,42 +340,68 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
System.arraycopy(v_tools, 0, tmp, 0, cnt);
Arrays.sort(tmp, BuildListComparator.getInstance());
v_tools = tmp;
+ }
+
+ private void showToolStatus(ITool tool) {
+ st_tool.setText(EMPTY_STR);
+ st_tool.setImage(null);
+ if (tool == null)
+ return;
+ IFileInfoModification fim = tcmm.getModification((IFileInfo)ri);
+ IToolModification tm = fim.getToolModification(tool);
+ if (tm != null && !tm.isCompatible()) {
+ CompatibilityStatus cs = tm.getCompatibilityStatus();
+ if (cs != null) {
+ st_tool.setText(cs.getMessage());
+ st_tool.setImage(getErrorIcon(cs));
+ }
+ }
+ }
+
+ private boolean updateCompatibleTools(ITool real) {
+ boolean result = false;
+ ArrayList list = new ArrayList();
+ IFileInfoModification fim = tcmm.getModification((IFileInfo)ri);
- if (page.isForFile()) { // Edit tool in combo for File
- c_tool.removeAll();
- ITool[] tools = ri.getTools();
- ITool curr = null, real = null;
- if (tools != null && tools.length > 0) {
- for (int i=0; i<tools.length; i++) {
- if (tools[i] != null && !tools[i].getCustomBuildStep()) {
- curr = tools[i];
- real = ManagedBuildManager.getRealTool(curr);
- break;
- }
+ if (real != null) { // Current tool exists
+ real = ManagedBuildManager.getRealTool(real);
+ list.add(real);
+ IToolModification tm = fim.getToolModification(real);
+ IModificationOperation[] mo = tm.getSupportedOperations();
+ for (int i=0; i<mo.length; i++) {
+ ITool t = mo[i].getReplacementTool();
+ if (t == null)
+ result = true;
+ else {
+ if (! t.isSystemObject() && ! t.isAbstract())
+ list.add(t);
}
}
- pos = (curr == null) ? v_tools.length : -1;
-
- for (int i=0; i<v_tools.length; i++) {
- if (pos == -1 && real.matches(v_tools[i])) {
- pos = i;
- c_tool.add(curr.getUniqueRealName()); // tool from v_tools may
- } else {
- c_tool.add(v_tools[i].getUniqueRealName());
+ } else { // Current tool is NO_TOOL
+ result = true;
+ IToolModification[] tm = fim.getSystemToolModifications();
+ for (int i=0; i<tm.length; i++) {
+ IModificationOperation[] mo = tm[i].getSupportedOperations();
+ for (int j=0; j<mo.length; j++) {
+ if (mo[j].getReplacementTool() == null) {
+ ITool t = tm[i].getTool();
+ if (! t.isSystemObject() && ! t.isAbstract())
+ list.add(t);
+ break;
+ }
}
}
- c_tool.add(Messages.getString("ToolChainEditTab.6")); //$NON-NLS-1$
- c_tool.select(pos);
- } else if (((ToolChain)tc).isPreferenceToolChain()){ // display tools list for Folder and Project
- tools_group.setVisible(false);
- } else {
- tools_group.setVisible(true);
- String s = EMPTY_STR;
- ITool[] tools = ri.getTools();
- for (int i = 0; i < tools.length; i++)
- s = s + tools[i].getUniqueRealName() + "\n"; //$NON-NLS-1$
- text.setText(s);
}
+ Collections.sort(list, BuildListComparator.getInstance());
+ v_tools = (ITool[]) list.toArray(new ITool[list.size()]);
+ return result;
+ }
+
+ private void updateData() {
+ showErrorMessage();
+ fillToolChainCombo();
+ fillBuilderCombo();
+ fillToolsList();
}
public void checkPressed(SelectionEvent e) {
@@ -394,7 +566,7 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
}
private void modifyTools() {
- ToolSelectionDialog d = new ToolSelectionDialog(usercomp.getShell());
+ ToolSelectionDialog d = new ToolSelectionDialog(usercomp.getShell(), ri);
d.all = v_tools;
d.fi = (IFolderInfo)ri;
int result = d.open();
@@ -424,10 +596,82 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
}
}
+ public static Image getErrorIcon(IStatus st) {
+ if (st.isOK())
+ return null;
+ int sev = st.getSeverity();
+ if (sev == IStatus.ERROR)
+ return IMG_ERROR;
+ else if (sev == IStatus.WARNING)
+ return IMG_WARNING;
+ else
+ return IMG_INFO;
+ }
+
private void modifyBuilder() {
int x = c_builder.getSelectionIndex();
IBuilder b = v_bs[x];
cfg.changeBuilder(b, ManagedBuildManager.calculateChildId(b.getId(), null), b.getUniqueRealName());
updateData();
}
-}
+
+ /**
+ * Forms a message containing
+ * @param cs
+ * @return
+ */
+ public static String getCompatibilityMessage(CompatibilityStatus cs) {
+ IConflict[] cons = cs.getConflicts();
+ StringBuffer result = new StringBuffer();
+ for (int i=0; i<cons.length; i++) {
+ IBuildObject bo = cons[i].getBuildObject();
+ String n = (bo == null) ?
+ "NULL" : //$NON-NLS-1$
+ (bo instanceof ITool) ?
+ ((ITool)bo).getUniqueRealName() :
+ bo.getName();
+ String t = EMPTY_STR;
+ switch (cons[i].getConflictType()) {
+ case IConflict.INCOMPATIBLE:
+ t = Messages.getString("ToolChainEditTab.7"); //$NON-NLS-1$
+ break;
+ case IConflict.SOURCE_EXT_CONFLICT:
+ t = Messages.getString("ToolChainEditTab.8"); //$NON-NLS-1$
+ break;
+ }
+
+ String o = EMPTY_STR;
+ switch (cons[i].getObjectType()) {
+ case IRealBuildObjectAssociation.OBJECT_TOOLCHAIN:
+ o = Messages.getString("ToolChainEditTab.9"); //$NON-NLS-1$
+ break;
+ case IRealBuildObjectAssociation.OBJECT_BUILDER:
+ o = Messages.getString("ToolChainEditTab.10"); //$NON-NLS-1$
+ break;
+ case IRealBuildObjectAssociation.OBJECT_CONFIGURATION:
+ o = Messages.getString("ToolChainEditTab.11"); //$NON-NLS-1$
+ break;
+ case IRealBuildObjectAssociation.OBJECT_FILE_INFO:
+ o = Messages.getString("ToolChainEditTab.12"); //$NON-NLS-1$
+ break;
+ case IRealBuildObjectAssociation.OBJECT_FOLDER_INFO:
+ o = Messages.getString("ToolChainEditTab.13"); //$NON-NLS-1$
+ break;
+ case IRealBuildObjectAssociation.OBJECT_TOOL:
+ o = Messages.getString("ToolChainEditTab.14"); //$NON-NLS-1$
+ break;
+ }
+
+ result.append(Messages.getString("ToolChainEditTab.15") + //$NON-NLS-1$
+ (i+1) + Messages.getString("ToolChainEditTab.16") + //$NON-NLS-1$
+ SPACE + t + SPACE + o + SPACE + n +
+ Messages.getString("ToolChainEditTab.17")); //$NON-NLS-1$
+ }
+ String s = result.toString();
+ if (s.trim().length() == 0)
+ s = cs.getMessage();
+ if (s == null)
+ s = EMPTY_STR;
+ return s;
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolSelectionDialog.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolSelectionDialog.java
index 083b40a5729..f80ec0438ec 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolSelectionDialog.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolSelectionDialog.java
@@ -16,10 +16,16 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.List;
+import org.eclipse.cdt.managedbuilder.core.IFileInfo;
import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
import org.eclipse.cdt.managedbuilder.core.IModificationStatus;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.tcmodification.CompatibilityStatus;
+import org.eclipse.cdt.managedbuilder.tcmodification.IModificationOperation;
+import org.eclipse.cdt.managedbuilder.tcmodification.IToolListModification;
+import org.eclipse.cdt.managedbuilder.tcmodification.IToolModification;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.resource.JFaceResources;
@@ -27,35 +33,49 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
public class ToolSelectionDialog extends Dialog {
private static final String EMPTY_STR = ""; //$NON-NLS-1$
private static final int COL_WIDTH = 300;
private Table t1, t2;
- private CLabel errorLabel;
+ private Button b_add, b_del, b_rep, b_all;
+ private CLabel errorLabel, l1;
+ private Text txt2;
public ITool[] all, used;
public IFolderInfo fi;
ArrayList added, removed;
private ArrayList left, right;
- Font boldFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);
- Color red;
+ private Font boldFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);
+ private Color red = Display.getDefault().getSystemColor(SWT.COLOR_RED);
+ private Color gray = Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY);
+// private Color white = Display.getDefault().getSystemColor(SWT.COLOR_WHITE);
+ private IToolListModification tmod = null;
- public ToolSelectionDialog(Shell shell ) {
+ public ToolSelectionDialog(Shell shell, IResourceInfo ri) {
super (shell);
setShellStyle(getShellStyle() | SWT.RESIZE);
+
+ if (ri instanceof IFolderInfo)
+ tmod = ManagedBuildManager.getToolChainModificationManager().getModification((IFolderInfo)ri);
+ else
+ tmod = ManagedBuildManager.getToolChainModificationManager().getModification((IFileInfo)ri);
}
/* (non-Javadoc)
@@ -78,60 +98,116 @@ public class ToolSelectionDialog extends Dialog {
removed = new ArrayList();
left = new ArrayList();
right = new ArrayList();
+
+ Composite c1 = new Composite(composite, SWT.NONE);
+ c1.setLayoutData(new GridData(GridData.FILL_BOTH));
+ c1.setLayout(new GridLayout(1, false));
+
+ Composite c2 = new Composite(composite, SWT.BORDER);
+ c2.setLayoutData(new GridData(GridData.FILL_VERTICAL));
+ c2.setLayout(new GridLayout(1, false));
+
+ Composite c3 = new Composite(composite, SWT.NONE);
+ c3.setLayoutData(new GridData(GridData.FILL_BOTH));
+ c3.setLayout(new GridLayout(1, false));
- t1 = new Table(composite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
- t1.setLayoutData(new GridData(GridData.FILL_BOTH));
+ t1 = new Table(c1, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
+ gd = new GridData(GridData.FILL_BOTH);
+ t1.setLayoutData(gd);
t1.setHeaderVisible(true);
t1.setLinesVisible(true);
+ t1.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ handleReplace();
+ }
+ public void widgetSelected(SelectionEvent e) {
+ handleSelection();
+ }});
TableColumn col = new TableColumn(t1, SWT.NONE);
col.setText(Messages.getString("ToolSelectionDialog.1")); //$NON-NLS-1$
col.setWidth(COL_WIDTH);
+
+ l1 = new CLabel(c1, SWT.BORDER);
+ l1.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- Composite c2 = new Composite(composite, SWT.BORDER);
- c2.setLayoutData(new GridData(GridData.FILL_VERTICAL));
- t2 = new Table(composite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
+ t2 = new Table(c3, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
t2.setLayoutData(new GridData(GridData.FILL_BOTH));
t2.setHeaderVisible(true);
t2.setLinesVisible(true);
+ t2.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ handleReplace();
+ }
+ public void widgetSelected(SelectionEvent e) {
+ handleSelection();
+ }});
col = new TableColumn(t2, SWT.NONE);
col.setText(Messages.getString("ToolSelectionDialog.2")); //$NON-NLS-1$
col.setWidth(COL_WIDTH);
- Display display = composite.getDisplay();
- red = display.getSystemColor(SWT.COLOR_RED);
- /*
- Color gray = display.getSystemColor(SWT.COLOR_GRAY);
- ti.setForeground(0, red);
- ti = new TableItem(t3, 0);
- ti.setForeground(0, red);
- */
-
- c2.setLayout(new GridLayout(1, false));
- Button b1 = new Button(c2, SWT.PUSH);
- b1.setText(Messages.getString("ToolSelectionDialog.12")); //$NON-NLS-1$
- b1.addSelectionListener(new SelectionAdapter() {
+ txt2 = new Text(c3, SWT.BORDER | SWT.WRAP | SWT.MULTI |
+ SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL);
+ gd = new GridData(GridData.FILL_BOTH);
+ gd.verticalSpan = 2;
+ gd.minimumHeight = 100;
+ txt2.setLayoutData(gd);
+
+ b_add = new Button(c2, SWT.PUSH);
+ b_add.setText(Messages.getString("ToolSelectionDialog.12")); //$NON-NLS-1$
+ b_add.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
int x = t1.getSelectionIndex();
+ if (x == -1)
+ return;
ITool tool = (ITool)t1.getItem(x).getData();
left.remove(tool);
right.add(tool);
+
+ tmod.changeProjectTools(null, tool);
+
updateData(true);
}});
- b1.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
- Button b2 = new Button(c2, SWT.PUSH);
- b2.setText(Messages.getString("ToolSelectionDialog.13")); //$NON-NLS-1$
- b2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- b2.addSelectionListener(new SelectionAdapter() {
+ b_add.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
+
+ b_rep = new Button(c2, SWT.PUSH);
+ b_rep.setText(Messages.getString("ToolSelectionDialog.14")); //$NON-NLS-1$
+ b_rep.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleReplace();
+ }});
+ b_rep.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
+
+ b_del = new Button(c2, SWT.PUSH);
+ b_del.setText(Messages.getString("ToolSelectionDialog.13")); //$NON-NLS-1$
+ b_del.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ b_del.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
int x = t2.getSelectionIndex();
+ if (x == -1)
+ return;
ITool tool = (ITool)t2.getItem(x).getData();
right.remove(tool);
left.add(ManagedBuildManager.getRealTool(tool));
+
+ tmod.changeProjectTools(tool, null);
+
updateData(true);
}});
- b2.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
+ b_del.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
+
+ // Grabs all place
+ new Label(c2, SWT.NONE).setLayoutData(new GridData(GridData.FILL, SWT.FILL, true, true));
+
+ b_all = new Button(c2, SWT.CHECK | SWT.WRAP);
+ b_all.setText(Messages.getString("ToolSelectionDialog.15")); //$NON-NLS-1$
+ b_all.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ b_all.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleSelection();
+ }});
+ b_all.setLayoutData(new GridData(GridData.FILL, SWT.END, true, false));
errorLabel = new CLabel(composite, SWT.NONE);
gd = new GridData(GridData.FILL_HORIZONTAL);
@@ -154,17 +230,132 @@ public class ToolSelectionDialog extends Dialog {
return composite;
}
+
+ private void handleReplace() {
+ if (! b_rep.isEnabled())
+ return;
+ int x1 = t1.getSelectionIndex();
+ int x2 = t2.getSelectionIndex();
+ if (x1 == -1 || x2 == -1)
+ return;
+ ITool tool1 = (ITool)t1.getItem(x1).getData();
+ ITool tool2 = (ITool)t2.getItem(x2).getData();
+ left.remove(tool1);
+ right.add(tool1);
+ right.remove(tool2);
+ left.add(ManagedBuildManager.getRealTool(tool2));
+
+ tmod.changeProjectTools(tool2, tool1);
+
+ updateData(true);
+ }
+
+ private int removeArrows(Table t) {
+ for (int j=0; j<t.getItemCount(); j++) {
+ TableItem ti = t.getItem(j);
+ if (ToolChainEditTab.IMG_ARROW.equals(ti.getImage()))
+ ti.setImage((Image)null);
+ }
+ return t.getSelectionIndex();
+ }
+
+ private boolean markReplace(int x, Table src, Table dst, Button b) {
+ if (x == -1)
+ return false;
+ ITool tool = (ITool)src.getItem(x).getData();
+ IToolModification tm = tmod.getToolModification(tool);
+ if (tm == null)
+ return false;
+ IModificationOperation[] mo = tm.getSupportedOperations();
+ if (mo == null || mo.length == 0)
+ return false;
+ boolean result = false;
+ int pos = dst.getSelectionIndex();
+ for (int j=0; j<dst.getItemCount(); j++) {
+ TableItem ti = dst.getItem(j);
+ ITool tt = (ITool)ti.getData();
+ for (int i=0; i<mo.length; i++) { // List of modifications
+ ITool t = mo[i].getReplacementTool();
+ if (t == null)
+ b.setEnabled(true); // enable Add or Del
+ else if (t.matches(tt)) {
+ ti.setImage(ToolChainEditTab.IMG_ARROW);
+ if (pos == j) result = true;
+ break; // exit from modif. loop
+ }
+ }
+ }
+ return result;
+ }
+
+ private void handleSelection() {
+ int x1 = removeArrows(t1);
+ int x2 = removeArrows(t2);
+ b_add.setEnabled(b_all.getSelection() && x1 > -1);
+ b_rep.setEnabled(b_all.getSelection() && x1 > -1 && x2 > -1);
+ b_del.setEnabled(b_all.getSelection() && x2 > -1);
+ boolean b1 = markReplace(x1, t1, t2, b_add);
+ boolean b2 = markReplace(x2, t2, t1, b_del);
+ if (b1 && b2) b_rep.setEnabled(true);
+ showErrorMessage(t1, false, x1);
+ showErrorMessage(t2, true, x2);
+ }
+
+ private void showErrorMessage(Table t, boolean isPrj, int x) {
+ if (isPrj)
+ txt2.setText(EMPTY_STR);
+ else {
+ l1.setText(EMPTY_STR);
+ l1.setImage(null);
+ }
+ if (x == -1)
+ return;
+ String message = EMPTY_STR;
+ Image image = null;
+ TableItem ti = t.getItem(x);
+ ITool tool = (ITool)ti.getData();
+ IToolModification tm = tmod.getToolModification(tool);
+ if (tm == null || tm.isCompatible()) {
+ if (ToolChainEditTab.IMG_ARROW.equals(ti.getImage()) && !isPrj) {
+ TableItem[] tis = t2.getSelection();
+ if (tis != null && tis.length > 0) {
+ message = Messages.getString("ToolSelectionDialog.16") + //$NON-NLS-1$
+ ((ITool)tis[0].getData()).getUniqueRealName();
+ }
+ }
+ } else {
+ CompatibilityStatus cs = tm.getCompatibilityStatus();
+ if (isPrj) {
+ message = ToolChainEditTab.getCompatibilityMessage(cs);
+ } /*else {
+ message = cs.getMessage() + cs.getSeverity();
+ image = ToolChainEditTab.getErrorIcon(cs);
+ }*/
+ }
+ if (isPrj) {
+ txt2.setText(message); // tmp
+ } else {
+ l1.setText(message);
+ l1.setImage(image);
+ }
+ }
private void add(ITool tool, Table table, boolean bold) {
+ IToolModification tm = tmod.getToolModification(tool);
TableItem ti = new TableItem(table, 0);
ti.setText(tool.getUniqueRealName());
- if (bold) ti.setFont(boldFont);
+ if (bold)
+ ti.setFont(boldFont);
ti.setData(tool);
+ if (tm != null /*&& table.equals(t2)*/ && !tm.isCompatible())
+ ti.setForeground(table.equals(t2) ? red : gray);
}
private void updateData(boolean check) {
removed.clear();
added.clear();
+ int t1_pos = t1.getSelectionIndex();
+ int t2_pos = t2.getSelectionIndex();
t1.removeAll();
t2.removeAll();
@@ -218,7 +409,7 @@ public class ToolSelectionDialog extends Dialog {
for (int j=0;j<tools[i].length;j++) {
if (t.matches(tools[i][j])) {
conflictTools.add(ti.getText());
- ti.setForeground(red);
+ ti.setBackground(gray);
break loop;
}
}
@@ -258,5 +449,14 @@ public class ToolSelectionDialog extends Dialog {
if(getButton(IDialogConstants.OK_ID) != null)
getButton(IDialogConstants.OK_ID).setEnabled(false);
}
+ if (t1_pos > -1 && t1_pos < t1.getItemCount())
+ t1.select(t1_pos);
+ else if (t1.getItemCount() > 0)
+ t1.select(0);
+ if (t2_pos > -1 && t2_pos < t2.getItemCount())
+ t2.select(t2_pos);
+ else if (t2.getItemCount() > 0)
+ t2.select(0);
+ handleSelection();
}
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/messages.properties b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/messages.properties
index fb65b2c63ec..a8095850ac1 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/messages.properties
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/messages.properties
@@ -60,13 +60,27 @@ ToolSelectionDialog.10=Props not supported \!
ToolSelectionDialog.11=Req. props not supported \!
ToolSelectionDialog.12=Add tool -->
ToolSelectionDialog.13=<-- Remove tool
+ToolSelectionDialog.14=<<- Replace ->>
+ToolSelectionDialog.15=Allow all changes
+ToolSelectionDialog.16=This tool can replace
ToolChainEditTab.0=Display compatible toolchains only
ToolChainEditTab.1=Current toolchain
+ToolChainEditTab.10=builder
+ToolChainEditTab.11=configuration
+ToolChainEditTab.12=file info
+ToolChainEditTab.13=folder info
+ToolChainEditTab.14=tool
+ToolChainEditTab.15=Error \#
+ToolChainEditTab.16=:
+ToolChainEditTab.17=\n
ToolChainEditTab.2=Current builder
ToolChainEditTab.3=Used tools
ToolChainEditTab.4=Select tools
ToolChainEditTab.5=Select tool
ToolChainEditTab.6=-- NO TOOL --
+ToolChainEditTab.7=incompatibility with
+ToolChainEditTab.8=source extension conflict with
+ToolChainEditTab.9=toolchain
NewVarDialog.0=Variable name:
NewVarDialog.1=Apply to all configurations
NewCfgDialog.0=Existing configuration

Back to the top