[bugzilla 372463] Modifiy the compiler to also store traceability informations for Contributions and modifying doc export to use these informations
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.compiler/src/org/eclipse/mylyn/docs/intent/client/compiler/ModelingUnitCompiler.java b/plugins/org.eclipse.mylyn.docs.intent.client.compiler/src/org/eclipse/mylyn/docs/intent/client/compiler/ModelingUnitCompiler.java
index 3ccaaa0..6a3062e 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.compiler/src/org/eclipse/mylyn/docs/intent/client/compiler/ModelingUnitCompiler.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.compiler/src/org/eclipse/mylyn/docs/intent/client/compiler/ModelingUnitCompiler.java
@@ -352,7 +352,7 @@
 	protected void validateGeneratedElement() {

 		for (EObject generatedElement : informationHolder.getCurrentCreatedElements()) {

 			GeneratedElementValidator validator = new GeneratedElementValidator(

-					informationHolder.getInstructionByCreatedElement(generatedElement), generatedElement);

+					informationHolder.getInstanciationInstructionByCreatedElement(generatedElement), generatedElement);

 			Diagnostic diagnostic;

 			try {

 				diagnostic = validator.validate();

diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.compiler/src/org/eclipse/mylyn/docs/intent/client/compiler/generator/modellinking/ModelingUnitLinkResolver.java b/plugins/org.eclipse.mylyn.docs.intent.client.compiler/src/org/eclipse/mylyn/docs/intent/client/compiler/generator/modellinking/ModelingUnitLinkResolver.java
index 6f4f131..6442076 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.compiler/src/org/eclipse/mylyn/docs/intent/client/compiler/generator/modellinking/ModelingUnitLinkResolver.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.compiler/src/org/eclipse/mylyn/docs/intent/client/compiler/generator/modellinking/ModelingUnitLinkResolver.java
@@ -251,7 +251,7 @@
 		}

 

 		UnitInstruction instanciationInstruction = informationHolder

-				.getInstructionByCreatedElement(foundReference);

+				.getInstanciationInstructionByCreatedElement(foundReference);

 		if (instanciationInstruction instanceof ModelingUnitInstruction

 				&& instruction instanceof ContributionInstruction) {

 			((ContributionInstruction)instruction).getReferencedElement().setReferencedElement(

diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.compiler/src/org/eclipse/mylyn/docs/intent/client/compiler/saver/CompilerInformationsSaver.java b/plugins/org.eclipse.mylyn.docs.intent.client.compiler/src/org/eclipse/mylyn/docs/intent/client/compiler/saver/CompilerInformationsSaver.java
index 747f03e..d30e25b 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.compiler/src/org/eclipse/mylyn/docs/intent/client/compiler/saver/CompilerInformationsSaver.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.compiler/src/org/eclipse/mylyn/docs/intent/client/compiler/saver/CompilerInformationsSaver.java
@@ -10,6 +10,7 @@
  *******************************************************************************/
 package org.eclipse.mylyn.docs.intent.client.compiler.saver;
 
+import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 import com.google.common.collect.Sets.SetView;
 
@@ -55,7 +56,7 @@
  */
 public class CompilerInformationsSaver {
 
-	private Map<ResourceDeclaration, Map<EObject, IntentGenericElement>> resourceToTraceabilityElementIndexEntry;
+	private Map<ResourceDeclaration, Map<EObject, Collection<IntentGenericElement>>> resourceToTraceabilityElementIndexEntry;
 
 	/**
 	 * Progress monitor allowing to cancel a save operation if another notification has been received by the
@@ -84,7 +85,7 @@
 	 */
 	public void saveOnRepository(IntentCompilerInformationHolder informationHolder,
 			RepositoryObjectHandler handler) {
-		resourceToTraceabilityElementIndexEntry = new HashMap<ResourceDeclaration, Map<EObject, IntentGenericElement>>();
+		resourceToTraceabilityElementIndexEntry = Maps.newLinkedHashMap();
 		try {
 
 			// We first save the generated elements
@@ -166,16 +167,23 @@
 		// For each element contained in the resource
 		for (EObject element : elementsToConsider) {
 			if (!progressMonitor.isCanceled()) {
-				// We get the instruction that defined this element
-				UnitInstruction instruction = informationHolder.getInstructionByCreatedElement(element);
+				// We add an entry to the traceability map
+				if (resourceToTraceabilityElementIndexEntry.get(resource) == null) {
+					resourceToTraceabilityElementIndexEntry.put(resource,
+							Maps.<EObject, Collection<IntentGenericElement>> newLinkedHashMap());
+				}
 
-				if (instruction != null) {
-					// We add an entry to the traceability map
-					if (resourceToTraceabilityElementIndexEntry.get(resource) == null) {
-						resourceToTraceabilityElementIndexEntry.put(resource,
-								new HashMap<EObject, IntentGenericElement>());
+				// We get the instructions that defined or contributed to this element
+				Collection<UnitInstruction> instructions = informationHolder
+						.getAllInstructionsByCreatedElement(element);
+
+				if (instructions != null && !instructions.isEmpty()) {
+
+					if (resourceToTraceabilityElementIndexEntry.get(resource).get(element) == null) {
+						resourceToTraceabilityElementIndexEntry.get(resource).put(element,
+								Sets.<IntentGenericElement> newLinkedHashSet());
 					}
-					resourceToTraceabilityElementIndexEntry.get(resource).put(element, instruction);
+					resourceToTraceabilityElementIndexEntry.get(resource).get(element).addAll(instructions);
 
 					// We do the same for each contained element
 					updateTraceabilityFromResourceContent(resource, informationHolder, element.eContents());
@@ -248,10 +256,14 @@
 
 			// For each entry, we define a mapping between contained elements and instructions
 			if (resourceToTraceabilityElementIndexEntry.get(resourceDeclaration) != null) {
-				entry.getContainedElementToInstructions().putAll(
-						resourceToTraceabilityElementIndexEntry.get(resourceDeclaration));
-				handledInstructions.addAll(resourceToTraceabilityElementIndexEntry.get(resourceDeclaration)
-						.values());
+				for (Entry<EObject, Collection<IntentGenericElement>> traceabilityEntry : resourceToTraceabilityElementIndexEntry
+						.get(resourceDeclaration).entrySet()) {
+					entry.getContainedElementToInstructions().put(traceabilityEntry.getKey(),
+							new BasicEList<IntentGenericElement>());
+					entry.getContainedElementToInstructions().get(traceabilityEntry.getKey())
+							.addAll(traceabilityEntry.getValue());
+					handledInstructions.addAll(traceabilityEntry.getValue());
+				}
 			}
 			newTraceabilityEntries.add(entry);
 		}
@@ -265,7 +277,9 @@
 			entry.setCompilationTime(BigInteger.valueOf(System.currentTimeMillis()));
 
 			for (UnitInstruction instruction : instanciationsInstructionNotContainedInResource) {
-				entry.getContainedElementToInstructions().put(instruction, instruction);
+				entry.getContainedElementToInstructions().put(instruction,
+						new BasicEList<IntentGenericElement>());
+				entry.getContainedElementToInstructions().get(instruction).add(instruction);
 			}
 			newTraceabilityEntries.add(entry);
 		}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.compiler/src/org/eclipse/mylyn/docs/intent/client/compiler/utils/IntentCompilerInformationHolder.java b/plugins/org.eclipse.mylyn.docs.intent.client.compiler/src/org/eclipse/mylyn/docs/intent/client/compiler/utils/IntentCompilerInformationHolder.java
index 0d7ff4b..e3f441a 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.compiler/src/org/eclipse/mylyn/docs/intent/client/compiler/utils/IntentCompilerInformationHolder.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.compiler/src/org/eclipse/mylyn/docs/intent/client/compiler/utils/IntentCompilerInformationHolder.java
@@ -14,7 +14,10 @@
 import com.google.common.collect.Iterables;

 import com.google.common.collect.Sets;

 

+import java.util.Collection;

+import java.util.Iterator;

 import java.util.List;

+import java.util.Map.Entry;

 import java.util.Set;

 

 import org.eclipse.emf.common.util.BasicEList;

@@ -37,6 +40,7 @@
 import org.eclipse.mylyn.docs.intent.core.modelingunit.ContributionInstruction;

 import org.eclipse.mylyn.docs.intent.core.modelingunit.InstanciationInstruction;

 import org.eclipse.mylyn.docs.intent.core.modelingunit.ModelingUnit;

+import org.eclipse.mylyn.docs.intent.core.modelingunit.ModelingUnitInstruction;

 import org.eclipse.mylyn.docs.intent.core.modelingunit.ResourceDeclaration;

 

 /**

@@ -111,7 +115,28 @@
 	private void addCreatedElementsToCurrentList(UnitInstruction instruction, EObject createdElement) {

 		if (createdElement != null) {

 			this.getCurrentCreatedElements().add(createdElement);

-			this.informationHolder.getCreatedElementsToInstructions().put(createdElement, instruction);

+			BasicEList<UnitInstruction> unitInstructions = new BasicEList<UnitInstruction>();

+			unitInstructions.add(instruction);

+			this.informationHolder.getCreatedElementsToInstructions().put(createdElement, unitInstructions);

+		}

+	}

+

+	private void referenceContributionInstruction(String name, ContributionInstruction contributionInstruction) {

+		if (contributionInstruction.getReferencedElement() != null

+				&& contributionInstruction.getReferencedElement().getReferencedElement() != null) {

+

+			Iterator<Entry<EObject, EList<UnitInstruction>>> entryIterator = this.informationHolder

+					.getCreatedElementsToInstructions().entrySet().iterator();

+			ModelingUnitInstruction targetInstanciationInstruction = contributionInstruction

+					.getReferencedElement().getReferencedElement();

+			boolean instanciationInstructionFound = false;

+			while (entryIterator.hasNext() && !instanciationInstructionFound) {

+				Entry<EObject, EList<UnitInstruction>> entry = entryIterator.next();

+				if (entry.getValue().contains(targetInstanciationInstruction)) {

+					entry.getValue().add(contributionInstruction);

+					instanciationInstructionFound = true;

+				}

+			}

 		}

 	}

 

@@ -122,7 +147,12 @@
 	 *            the element to inspect

 	 * @return the instruction that declared the given element

 	 */

-	public UnitInstruction getInstructionByCreatedElement(EObject createdElement) {

+	public UnitInstruction getInstanciationInstructionByCreatedElement(EObject createdElement) {

+		return this.informationHolder.getCreatedElementsToInstructions().get(createdElement).iterator()

+				.next();

+	}

+

+	public Collection<UnitInstruction> getAllInstructionsByCreatedElement(EObject createdElement) {

 		return this.informationHolder.getCreatedElementsToInstructions().get(createdElement);

 	}

 

@@ -132,14 +162,15 @@
 	 * @return all the instanciation instructions that have a non-null name (e.g new EClass e1 {})

 	 */

 	public Set<UnitInstruction> getAllInstanciationsInstructions() {

-		return Sets.newLinkedHashSet(Iterables.filter(this.informationHolder

-				.getCreatedElementsToInstructions().values(), new Predicate<UnitInstruction>() {

+		return Sets.newLinkedHashSet(Iterables.filter(

+				Iterables.concat(this.informationHolder.getCreatedElementsToInstructions().values()),

+				new Predicate<UnitInstruction>() {

 

-			public boolean apply(UnitInstruction instruction) {

-				return instruction instanceof InstanciationInstruction

-						&& ((InstanciationInstruction)instruction).getName() != null;

-			}

-		}));

+					public boolean apply(UnitInstruction instruction) {

+						return instruction instanceof InstanciationInstruction

+								&& ((InstanciationInstruction)instruction).getName() != null;

+					}

+				}));

 	}

 

 	/**

@@ -420,7 +451,7 @@
 			newStatus.setSeverity(CompilationStatusConverter

 					.createStatusSeverityFromDiagnosticSeverity(subDiagnostic));

 			newStatus.setType(CompilationMessageType.VALIDATION_ERROR);

-			newStatus.setTarget(this.getInstructionByCreatedElement(generatedElement));

+			newStatus.setTarget(this.getInstanciationInstructionByCreatedElement(generatedElement));

 

 			// and add this status to the diagnostic list.

 			compilationStatusList.add(newStatus);

@@ -428,7 +459,7 @@
 

 		// Step 2 : we register the new Diagnostics in the informationHolder

 		addStatusListToInformationHolder(

-				getModelingUnitForInstruction(getInstructionByCreatedElement(generatedElement)),

+				getModelingUnitForInstruction(getInstanciationInstructionByCreatedElement(generatedElement)),

 				compilationStatusList);

 

 	}

@@ -535,5 +566,8 @@
 				holder.setResolved(true);

 			}

 		}

+		referenceContributionInstruction(((InstanciationInstruction)contributionInstruction

+				.getReferencedElement().getReferencedElement()).getName(), contributionInstruction);

 	}

+

 }

diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.synchronizer/src/org/eclipse/mylyn/docs/intent/client/synchronizer/factory/SynchronizerStatusFactory.java b/plugins/org.eclipse.mylyn.docs.intent.client.synchronizer/src/org/eclipse/mylyn/docs/intent/client/synchronizer/factory/SynchronizerStatusFactory.java
index 7b751b3..89bd191 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.synchronizer/src/org/eclipse/mylyn/docs/intent/client/synchronizer/factory/SynchronizerStatusFactory.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.synchronizer/src/org/eclipse/mylyn/docs/intent/client/synchronizer/factory/SynchronizerStatusFactory.java
@@ -201,7 +201,7 @@
 	 */
 	private static IntentGenericElement getInstructionFromCompiledElement(TraceabilityIndexEntry indexEntry,
 			EObject compiledElement) {
-		return indexEntry.getContainedElementToInstructions().get(compiledElement);
+		return indexEntry.getContainedElementToInstructions().get(compiledElement).iterator().next();
 	}
 
 }
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.synchronizer/src/org/eclipse/mylyn/docs/intent/client/synchronizer/synchronizer/IntentSynchronizer.java b/plugins/org.eclipse.mylyn.docs.intent.client.synchronizer/src/org/eclipse/mylyn/docs/intent/client/synchronizer/synchronizer/IntentSynchronizer.java
index c82691f..0ccb200 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.synchronizer/src/org/eclipse/mylyn/docs/intent/client/synchronizer/synchronizer/IntentSynchronizer.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.synchronizer/src/org/eclipse/mylyn/docs/intent/client/synchronizer/synchronizer/IntentSynchronizer.java
@@ -173,8 +173,8 @@
 

 			// We must remove the synchronization statuses from the instruction that generated this

 			// element

-			IntentGenericElement instruction = indexEntry.getContainedElementToInstructions().get(

-					containedElement);

+			IntentGenericElement instruction = indexEntry.getContainedElementToInstructions()

+					.get(containedElement).iterator().next();

 			if (instruction != null) {

 				Iterator<CompilationStatus> iterator = instruction.getCompilationStatus().iterator();

 				while (iterator.hasNext()) {

diff --git a/plugins/org.eclipse.mylyn.docs.intent.core/model/compilerInformations.ecore b/plugins/org.eclipse.mylyn.docs.intent.core/model/compilerInformations.ecore
index 3d31019..e3441d2 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.core/model/compilerInformations.ecore
+++ b/plugins/org.eclipse.mylyn.docs.intent.core/model/compilerInformations.ecore
@@ -38,7 +38,8 @@
   <eClassifiers xsi:type="ecore:EClass" name="CreatedElementToInstructionMapEntry"

       instanceClassName="java.util.Map$Entry">

     <eStructuralFeatures xsi:type="ecore:EReference" name="key" eType="ecore:EClass http://www.eclipse.org/emf/2002/Ecore#//EObject"/>

-    <eStructuralFeatures xsi:type="ecore:EReference" name="value" eType="ecore:EClass genericUnit.ecore#//UnitInstruction"/>

+    <eStructuralFeatures xsi:type="ecore:EReference" name="value" upperBound="-1"

+        eType="ecore:EClass genericUnit.ecore#//UnitInstruction"/>

   </eClassifiers>

   <eClassifiers xsi:type="ecore:EClass" name="UnresolvedReferenceHolder">

     <eStructuralFeatures xsi:type="ecore:EAttribute" name="textualReference" lowerBound="1"

@@ -121,7 +122,8 @@
   </eClassifiers>

   <eClassifiers xsi:type="ecore:EClass" name="CompiledElementToInstructionEntry" instanceClassName="java.util.Map$Entry">

     <eStructuralFeatures xsi:type="ecore:EReference" name="key" lowerBound="1" eType="ecore:EClass http://www.eclipse.org/emf/2002/Ecore#//EObject"/>

-    <eStructuralFeatures xsi:type="ecore:EReference" name="value" lowerBound="1" eType="ecore:EClass document.ecore#//IntentGenericElement"/>

+    <eStructuralFeatures xsi:type="ecore:EReference" name="value" lowerBound="1" upperBound="-1"

+        eType="ecore:EClass document.ecore#//IntentGenericElement"/>

   </eClassifiers>

   <eClassifiers xsi:type="ecore:EClass" name="SynchronizerCompilationStatus" eSuperTypes="#//CompilationStatus">

     <eStructuralFeatures xsi:type="ecore:EAttribute" name="workingCopyResourceURI"

diff --git a/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/CompilationInformationHolder.java b/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/CompilationInformationHolder.java
index fc951e8..1b5cf9d 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/CompilationInformationHolder.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/CompilationInformationHolder.java
@@ -94,7 +94,7 @@
 	/**
 	 * Returns the value of the '<em><b>Created Elements To Instructions</b></em>' map.
 	 * The key is of type {@link org.eclipse.emf.ecore.EObject},
-	 * and the value is of type {@link org.eclipse.mylyn.docs.intent.core.genericunit.UnitInstruction},
+	 * and the value is of type list of {@link org.eclipse.mylyn.docs.intent.core.genericunit.UnitInstruction},
 	 * <!-- begin-user-doc -->
 	 * <p>
 	 * If the meaning of the '<em>Created Elements To Instructions</em>' map isn't clear, there really should
@@ -106,7 +106,7 @@
 	 * @model mapType="org.eclipse.mylyn.docs.intent.core.compiler.CreatedElementToInstructionMapEntry<org.eclipse.emf.ecore.EObject, org.eclipse.mylyn.docs.intent.core.genericunit.UnitInstruction>"
 	 * @generated
 	 */
-	EMap<EObject, UnitInstruction> getCreatedElementsToInstructions();
+	EMap<EObject, EList<UnitInstruction>> getCreatedElementsToInstructions();
 
 	/**
 	 * Returns the value of the '<em><b>Current Generated Element List</b></em>' reference list.
diff --git a/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/CompilerPackage.java b/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/CompilerPackage.java
index 9841fbf..35aa4ef 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/CompilerPackage.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/CompilerPackage.java
@@ -317,7 +317,7 @@
 	int CREATED_ELEMENT_TO_INSTRUCTION_MAP_ENTRY__KEY = 0;
 
 	/**
-	 * The feature id for the '<em><b>Value</b></em>' reference.
+	 * The feature id for the '<em><b>Value</b></em>' reference list.
 	 * <!-- begin-user-doc --> <!-- end-user-doc -->
 	 * @generated
 	 * @ordered
@@ -704,7 +704,7 @@
 	int COMPILED_ELEMENT_TO_INSTRUCTION_ENTRY__KEY = 0;
 
 	/**
-	 * The feature id for the '<em><b>Value</b></em>' reference.
+	 * The feature id for the '<em><b>Value</b></em>' reference list.
 	 * <!-- begin-user-doc -->
 	 * <!-- end-user-doc -->
 	 * @generated
@@ -1079,7 +1079,7 @@
 	 * @return the meta object for class '<em>Created Element To Instruction Map Entry</em>'.
 	 * @see java.util.Map.Entry
 	 * @model keyType="org.eclipse.emf.ecore.EObject"
-	 *        valueType="org.eclipse.mylyn.docs.intent.core.genericunit.UnitInstruction"
+	 *        valueType="org.eclipse.mylyn.docs.intent.core.genericunit.UnitInstruction" valueMany="true"
 	 * @generated
 	 */
 	EClass getCreatedElementToInstructionMapEntry();
@@ -1438,7 +1438,7 @@
 	 * @return the meta object for class '<em>Compiled Element To Instruction Entry</em>'.
 	 * @see java.util.Map.Entry
 	 * @model keyType="org.eclipse.emf.ecore.EObject" keyRequired="true"
-	 *        valueType="org.eclipse.mylyn.docs.intent.core.document.IntentGenericElement" valueRequired="true"
+	 *        valueType="org.eclipse.mylyn.docs.intent.core.document.IntentGenericElement" valueRequired="true" valueMany="true"
 	 * @generated
 	 */
 	EClass getCompiledElementToInstructionEntry();
@@ -1455,10 +1455,10 @@
 	EReference getCompiledElementToInstructionEntry_Key();
 
 	/**
-	 * Returns the meta object for the reference '{@link java.util.Map.Entry <em>Value</em>}'.
+	 * Returns the meta object for the reference list '{@link java.util.Map.Entry <em>Value</em>}'.
 	 * <!-- begin-user-doc -->
 	 * <!-- end-user-doc -->
-	 * @return the meta object for the reference '<em>Value</em>'.
+	 * @return the meta object for the reference list '<em>Value</em>'.
 	 * @see java.util.Map.Entry
 	 * @see #getCompiledElementToInstructionEntry()
 	 * @generated
@@ -1787,7 +1787,7 @@
 				.getCreatedElementToInstructionMapEntry_Key();
 
 		/**
-		 * The meta object literal for the '<em><b>Value</b></em>' reference feature.
+		 * The meta object literal for the '<em><b>Value</b></em>' reference list feature.
 		 * <!-- begin-user-doc -->
 		 * <!-- end-user-doc -->
 		 * @generated
@@ -2095,7 +2095,7 @@
 				.getCompiledElementToInstructionEntry_Key();
 
 		/**
-		 * The meta object literal for the '<em><b>Value</b></em>' reference feature.
+		 * The meta object literal for the '<em><b>Value</b></em>' reference list feature.
 		 * <!-- begin-user-doc -->
 		 * <!-- end-user-doc -->
 		 * @generated
diff --git a/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/TraceabilityIndexEntry.java b/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/TraceabilityIndexEntry.java
index 01f01ed..378a9c4 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/TraceabilityIndexEntry.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/TraceabilityIndexEntry.java
@@ -13,6 +13,7 @@
 import java.math.BigInteger;
 
 import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.common.util.EList;
 import org.eclipse.emf.common.util.EMap;
 import org.eclipse.emf.ecore.EObject;
 import org.eclipse.mylyn.docs.intent.core.document.IntentGenericElement;
@@ -120,7 +121,7 @@
 	/**
 	 * Returns the value of the '<em><b>Contained Element To Instructions</b></em>' map.
 	 * The key is of type {@link org.eclipse.emf.ecore.EObject},
-	 * and the value is of type {@link org.eclipse.mylyn.docs.intent.core.document.IntentGenericElement},
+	 * and the value is of type list of {@link org.eclipse.mylyn.docs.intent.core.document.IntentGenericElement},
 	 * <!-- begin-user-doc -->
 	 * <p>
 	 * If the meaning of the '<em>Contained Element To Instructions</em>' map isn't clear,
@@ -132,6 +133,6 @@
 	 * @model mapType="org.eclipse.mylyn.docs.intent.core.compiler.CompiledElementToInstructionEntry<org.eclipse.emf.ecore.EObject, org.eclipse.mylyn.docs.intent.core.document.IntentGenericElement>"
 	 * @generated
 	 */
-	EMap<EObject, IntentGenericElement> getContainedElementToInstructions();
+	EMap<EObject, EList<IntentGenericElement>> getContainedElementToInstructions();
 
 } // TraceabilityIndexEntry
diff --git a/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/impl/CompilationInformationHolderImpl.java b/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/impl/CompilationInformationHolderImpl.java
index c802ad8..0245bb4 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/impl/CompilationInformationHolderImpl.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/impl/CompilationInformationHolderImpl.java
@@ -105,8 +105,8 @@
 	 * @generated
 	 */
 	@SuppressWarnings("unchecked")
-	public EMap<EObject, UnitInstruction> getCreatedElementsToInstructions() {
-		return (EMap<EObject, UnitInstruction>)eGet(
+	public EMap<EObject, EList<UnitInstruction>> getCreatedElementsToInstructions() {
+		return (EMap<EObject, EList<UnitInstruction>>)eGet(
 				CompilerPackage.Literals.COMPILATION_INFORMATION_HOLDER__CREATED_ELEMENTS_TO_INSTRUCTIONS,
 				true);
 	}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/impl/CompiledElementToInstructionEntryImpl.java b/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/impl/CompiledElementToInstructionEntryImpl.java
index 583c7e8..fc3c3b9 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/impl/CompiledElementToInstructionEntryImpl.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/impl/CompiledElementToInstructionEntryImpl.java
@@ -11,6 +11,7 @@
 package org.eclipse.mylyn.docs.intent.core.compiler.impl;
 
 import org.eclipse.emf.common.util.BasicEMap;
+import org.eclipse.emf.common.util.EList;
 import org.eclipse.emf.common.util.EMap;
 import org.eclipse.emf.ecore.EClass;
 import org.eclipse.emf.ecore.EObject;
@@ -32,7 +33,7 @@
  *
  * @generated
  */
-public class CompiledElementToInstructionEntryImpl extends CDOObjectImpl implements BasicEMap.Entry<EObject, IntentGenericElement> {
+public class CompiledElementToInstructionEntryImpl extends CDOObjectImpl implements BasicEMap.Entry<EObject, EList<IntentGenericElement>> {
 	/**
 	 * <!-- begin-user-doc -->
 	 * <!-- end-user-doc -->
@@ -85,8 +86,9 @@
 	 * <!-- end-user-doc -->
 	 * @generated
 	 */
-	public IntentGenericElement getTypedValue() {
-		return (IntentGenericElement)eGet(
+	@SuppressWarnings("unchecked")
+	public EList<IntentGenericElement> getTypedValue() {
+		return (EList<IntentGenericElement>)eGet(
 				CompilerPackage.Literals.COMPILED_ELEMENT_TO_INSTRUCTION_ENTRY__VALUE, true);
 	}
 
@@ -95,15 +97,6 @@
 	 * <!-- end-user-doc -->
 	 * @generated
 	 */
-	public void setTypedValue(IntentGenericElement newValue) {
-		eSet(CompilerPackage.Literals.COMPILED_ELEMENT_TO_INSTRUCTION_ENTRY__VALUE, newValue);
-	}
-
-	/**
-	 * <!-- begin-user-doc -->
-	 * <!-- end-user-doc -->
-	 * @generated
-	 */
 	protected int hash = -1;
 
 	/**
@@ -151,7 +144,7 @@
 	 * <!-- end-user-doc -->
 	 * @generated
 	 */
-	public IntentGenericElement getValue() {
+	public EList<IntentGenericElement> getValue() {
 		return getTypedValue();
 	}
 
@@ -160,9 +153,10 @@
 	 * <!-- end-user-doc -->
 	 * @generated
 	 */
-	public IntentGenericElement setValue(IntentGenericElement value) {
-		IntentGenericElement oldValue = getValue();
-		setTypedValue(value);
+	public EList<IntentGenericElement> setValue(EList<IntentGenericElement> value) {
+		EList<IntentGenericElement> oldValue = getValue();
+		getTypedValue().clear();
+		getTypedValue().addAll(value);
 		return oldValue;
 	}
 
@@ -172,9 +166,9 @@
 	 * @generated
 	 */
 	@SuppressWarnings("unchecked")
-	public EMap<EObject, IntentGenericElement> getEMap() {
+	public EMap<EObject, EList<IntentGenericElement>> getEMap() {
 		EObject container = eContainer();
-		return container == null ? null : (EMap<EObject, IntentGenericElement>)container
+		return container == null ? null : (EMap<EObject, EList<IntentGenericElement>>)container
 				.eGet(eContainmentFeature());
 	}
 
diff --git a/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/impl/CompilerFactoryImpl.java b/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/impl/CompilerFactoryImpl.java
index 07ac7d0..49c9557 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/impl/CompilerFactoryImpl.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/impl/CompilerFactoryImpl.java
@@ -224,7 +224,7 @@
 	 * <!-- begin-user-doc --> <!-- end-user-doc -->
 	 * @generated
 	 */
-	public Map.Entry<EObject, UnitInstruction> createCreatedElementToInstructionMapEntry() {
+	public Map.Entry<EObject, EList<UnitInstruction>> createCreatedElementToInstructionMapEntry() {
 		CreatedElementToInstructionMapEntryImpl createdElementToInstructionMapEntry = new CreatedElementToInstructionMapEntryImpl();
 		return createdElementToInstructionMapEntry;
 	}
@@ -299,7 +299,7 @@
 	 * <!-- end-user-doc -->
 	 * @generated
 	 */
-	public Map.Entry<EObject, IntentGenericElement> createCompiledElementToInstructionEntry() {
+	public Map.Entry<EObject, EList<IntentGenericElement>> createCompiledElementToInstructionEntry() {
 		CompiledElementToInstructionEntryImpl compiledElementToInstructionEntry = new CompiledElementToInstructionEntryImpl();
 		return compiledElementToInstructionEntry;
 	}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/impl/CompilerPackageImpl.java b/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/impl/CompilerPackageImpl.java
index d2e86c9..f61e2d7 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/impl/CompilerPackageImpl.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/impl/CompilerPackageImpl.java
@@ -1059,7 +1059,7 @@
 				null, 0, 1, Map.Entry.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE,
 				IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
 		initEReference(getCreatedElementToInstructionMapEntry_Value(),
-				theGenericUnitPackage.getUnitInstruction(), null, "value", null, 0, 1, Map.Entry.class,
+				theGenericUnitPackage.getUnitInstruction(), null, "value", null, 0, -1, Map.Entry.class,
 				!IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES,
 				!IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
 
@@ -1181,7 +1181,7 @@
 				null, 1, 1, Map.Entry.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE,
 				IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
 		initEReference(getCompiledElementToInstructionEntry_Value(),
-				theIntentDocumentPackage.getIntentGenericElement(), null, "value", null, 1, 1,
+				theIntentDocumentPackage.getIntentGenericElement(), null, "value", null, 1, -1,
 				Map.Entry.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE,
 				IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
 
diff --git a/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/impl/CreatedElementToInstructionMapEntryImpl.java b/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/impl/CreatedElementToInstructionMapEntryImpl.java
index 80c1916..317273d 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/impl/CreatedElementToInstructionMapEntryImpl.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/impl/CreatedElementToInstructionMapEntryImpl.java
@@ -11,6 +11,7 @@
 package org.eclipse.mylyn.docs.intent.core.compiler.impl;
 
 import org.eclipse.emf.common.util.BasicEMap;
+import org.eclipse.emf.common.util.EList;
 import org.eclipse.emf.common.util.EMap;
 import org.eclipse.emf.ecore.EClass;
 import org.eclipse.emf.ecore.EObject;
@@ -31,7 +32,7 @@
  *
  * @generated
  */
-public class CreatedElementToInstructionMapEntryImpl extends CDOObjectImpl implements BasicEMap.Entry<EObject, UnitInstruction> {
+public class CreatedElementToInstructionMapEntryImpl extends CDOObjectImpl implements BasicEMap.Entry<EObject, EList<UnitInstruction>> {
 	/**
 	 * <!-- begin-user-doc --> <!-- end-user-doc -->
 	 * @generated
@@ -78,8 +79,9 @@
 	 * <!-- begin-user-doc --> <!-- end-user-doc -->
 	 * @generated
 	 */
-	public UnitInstruction getTypedValue() {
-		return (UnitInstruction)eGet(
+	@SuppressWarnings("unchecked")
+	public EList<UnitInstruction> getTypedValue() {
+		return (EList<UnitInstruction>)eGet(
 				CompilerPackage.Literals.CREATED_ELEMENT_TO_INSTRUCTION_MAP_ENTRY__VALUE, true);
 	}
 
@@ -87,14 +89,6 @@
 	 * <!-- begin-user-doc --> <!-- end-user-doc -->
 	 * @generated
 	 */
-	public void setTypedValue(UnitInstruction newValue) {
-		eSet(CompilerPackage.Literals.CREATED_ELEMENT_TO_INSTRUCTION_MAP_ENTRY__VALUE, newValue);
-	}
-
-	/**
-	 * <!-- begin-user-doc --> <!-- end-user-doc -->
-	 * @generated
-	 */
 	protected int hash = -1;
 
 	/**
@@ -137,17 +131,19 @@
 	 * <!-- begin-user-doc --> <!-- end-user-doc -->
 	 * @generated
 	 */
-	public UnitInstruction getValue() {
+	public EList<UnitInstruction> getValue() {
 		return getTypedValue();
 	}
 
 	/**
-	 * <!-- begin-user-doc --> <!-- end-user-doc -->
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
 	 * @generated
 	 */
-	public UnitInstruction setValue(UnitInstruction value) {
-		UnitInstruction oldValue = getValue();
-		setTypedValue(value);
+	public EList<UnitInstruction> setValue(EList<UnitInstruction> value) {
+		EList<UnitInstruction> oldValue = getValue();
+		getTypedValue().clear();
+		getTypedValue().addAll(value);
 		return oldValue;
 	}
 
@@ -156,9 +152,9 @@
 	 * @generated
 	 */
 	@SuppressWarnings("unchecked")
-	public EMap<EObject, UnitInstruction> getEMap() {
+	public EMap<EObject, EList<UnitInstruction>> getEMap() {
 		EObject container = eContainer();
-		return container == null ? null : (EMap<EObject, UnitInstruction>)container
+		return container == null ? null : (EMap<EObject, EList<UnitInstruction>>)container
 				.eGet(eContainmentFeature());
 	}
 
diff --git a/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/impl/TraceabilityIndexEntryImpl.java b/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/impl/TraceabilityIndexEntryImpl.java
index 0e4e8e3..fde4640 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/impl/TraceabilityIndexEntryImpl.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/impl/TraceabilityIndexEntryImpl.java
@@ -12,6 +12,7 @@
 
 import java.math.BigInteger;
 
+import org.eclipse.emf.common.util.EList;
 import org.eclipse.emf.common.util.EMap;
 import org.eclipse.emf.ecore.EClass;
 import org.eclipse.emf.ecore.EObject;
@@ -129,8 +130,8 @@
 	 * @generated
 	 */
 	@SuppressWarnings("unchecked")
-	public EMap<EObject, IntentGenericElement> getContainedElementToInstructions() {
-		return (EMap<EObject, IntentGenericElement>)eGet(
+	public EMap<EObject, EList<IntentGenericElement>> getContainedElementToInstructions() {
+		return (EMap<EObject, EList<IntentGenericElement>>)eGet(
 				CompilerPackage.Literals.TRACEABILITY_INDEX_ENTRY__CONTAINED_ELEMENT_TO_INSTRUCTIONS, true);
 	}
 
diff --git a/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/util/CompilerAdapterFactory.java b/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/util/CompilerAdapterFactory.java
index 0d7db4f..6b86fca 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/util/CompilerAdapterFactory.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/util/CompilerAdapterFactory.java
@@ -124,7 +124,8 @@
 		}
 
 		@Override
-		public Adapter caseCreatedElementToInstructionMapEntry(Map.Entry<EObject, UnitInstruction> object) {
+		public Adapter caseCreatedElementToInstructionMapEntry(
+				Map.Entry<EObject, EList<UnitInstruction>> object) {
 			return createCreatedElementToInstructionMapEntryAdapter();
 		}
 
@@ -164,7 +165,8 @@
 		}
 
 		@Override
-		public Adapter caseCompiledElementToInstructionEntry(Map.Entry<EObject, IntentGenericElement> object) {
+		public Adapter caseCompiledElementToInstructionEntry(
+				Map.Entry<EObject, EList<IntentGenericElement>> object) {
 			return createCompiledElementToInstructionEntryAdapter();
 		}
 
diff --git a/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/util/CompilerSwitch.java b/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/util/CompilerSwitch.java
index 40cf3bb..5f49eb1 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/util/CompilerSwitch.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.core/src-gen/org/eclipse/mylyn/docs/intent/core/compiler/util/CompilerSwitch.java
@@ -139,7 +139,7 @@
 			}
 			case CompilerPackage.CREATED_ELEMENT_TO_INSTRUCTION_MAP_ENTRY: {
 				@SuppressWarnings("unchecked")
-				Map.Entry<EObject, UnitInstruction> createdElementToInstructionMapEntry = (Map.Entry<EObject, UnitInstruction>)theEObject;
+				Map.Entry<EObject, EList<UnitInstruction>> createdElementToInstructionMapEntry = (Map.Entry<EObject, EList<UnitInstruction>>)theEObject;
 				T result = caseCreatedElementToInstructionMapEntry(createdElementToInstructionMapEntry);
 				if (result == null)
 					result = defaultCase(theEObject);
@@ -196,7 +196,7 @@
 			}
 			case CompilerPackage.COMPILED_ELEMENT_TO_INSTRUCTION_ENTRY: {
 				@SuppressWarnings("unchecked")
-				Map.Entry<EObject, IntentGenericElement> compiledElementToInstructionEntry = (Map.Entry<EObject, IntentGenericElement>)theEObject;
+				Map.Entry<EObject, EList<IntentGenericElement>> compiledElementToInstructionEntry = (Map.Entry<EObject, EList<IntentGenericElement>>)theEObject;
 				T result = caseCompiledElementToInstructionEntry(compiledElementToInstructionEntry);
 				if (result == null)
 					result = defaultCase(theEObject);
@@ -320,7 +320,7 @@
 	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
 	 * @generated
 	 */
-	public T caseCreatedElementToInstructionMapEntry(Map.Entry<EObject, UnitInstruction> object) {
+	public T caseCreatedElementToInstructionMapEntry(Map.Entry<EObject, EList<UnitInstruction>> object) {
 		return null;
 	}
 
@@ -432,7 +432,7 @@
 	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
 	 * @generated
 	 */
-	public T caseCompiledElementToInstructionEntry(Map.Entry<EObject, IntentGenericElement> object) {
+	public T caseCompiledElementToInstructionEntry(Map.Entry<EObject, EList<IntentGenericElement>> object) {
 		return null;
 	}
 
diff --git a/plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/main/HTMLBootstrapGenDocument.mtl b/plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/main/HTMLBootstrapGenDocument.mtl
index c871469..1e5afe0 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/main/HTMLBootstrapGenDocument.mtl
+++ b/plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/main/HTMLBootstrapGenDocument.mtl
@@ -13,132 +13,129 @@
 /]
 
 [template public HTMLBootstrapGenDocumentDocument(element : IntentDocument, intentDocumentName : String )]
-	
-	[comment @main /]
-	
-	[file (fileName(intentDocumentName), false, 'UTF-8')]
-		[comment Step 1: create top navigation bar/]
-		[generateNavigationBar(element, intentDocumentName)/]
+[comment @main /]
+[file (fileName(intentDocumentName), false, 'UTF-8')]
+[comment Step 1: create top navigation bar/]
+[generateNavigationBar(element, intentDocumentName)/]
 
-		[comment Step 2: generate TOC/]
-		[generateTOC(element)/]
+[comment Step 2: generate TOC/]
+[generateTOC(element)/]
 
-		[comment Step 3: generate documentation content/]
-		[generateHTMLContent(element)/]
+[comment Step 3: generate documentation content/]
+[generateHTMLContent(element)/]
 
-		[comment Step 4: generate footer/]
-		[generateFooter(element)/]
-	[/file]
-	
+[comment Step 4: generate footer/]
+[generateFooter(element)/]
+[/file]
 [/template]
 
 
 
 [template public generateNavigationBar (intentDocument : IntentDocument, intentDocumentName : String) ]
-	<!doctype html>  
-	<html> 
-		<head> 
-			<title>[intentDocumentName/]</title>
-			<link href="./css/bootstrap.css" rel="stylesheet">
-			<link href="./css/bootstrap-responsive.css" rel="stylesheet">
-			<link href="./css/toc.css" rel="stylesheet">			
-			<link href="./css/tree.css" rel="stylesheet">		
-			<style>
-			   body {
-			       padding-top: 60px;
-			   }
-		    </style>
-		  	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
-	    </head>
-	    <body>
+<!doctype html>  
+<html> 
+	<head> 
+		<title>[intentDocumentName/]</title>
+	<link href="./css/bootstrap.css" rel="stylesheet">
+	<link href="./css/bootstrap-responsive.css" rel="stylesheet">
+	<link href="./css/toc.css" rel="stylesheet">			
+	<link href="./css/tree.css" rel="stylesheet">		
+	<style>
+	   body {
+	       padding-top: 60px;
+	   }
+    </style>
+  	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+</head>
+<body>
 
-		 	<div id="topbar" class="navbar navbar-fixed-top" data-dropdown="dropdown">
-	      		<div class="navbar-inner">
-		       		<div class="container" style="width: auto;">
-			         	 <h3> <a class="brand" href="#"> [intentDocumentName/] </a></h3>
-						 <ul class="nav">
-							<li><a href="#">Text documentation</a></li>
-							<li><a href="#">Models</a></li>
-						 </ul>
-						 <form class="navbar-search pull-left" action="">
-								<input type="text" placeholder="Search" />
-						</form>
-						
-						<ul class="nav pull-right">
-							<li class="dropdown">
-								<a href="#" class="dropdown-toggle" data-toggle="dropdown">Options <b class="caret"></b></a>
-								<ul class="dropdown-menu">
-									<li id="hidden_table_of_content">
-										<a href="#" onClick="hideToc()">Hide Table Of Contents</a>
-									</li>
-								</ul>
+ 	<div id="topbar" class="navbar navbar-fixed-top" data-dropdown="dropdown">
+  		<div class="navbar-inner">
+       		<div class="container" style="width: auto;">
+	         	 <h3> <a class="brand" href="#"> [intentDocumentName/] </a></h3>
+				 <ul class="nav">
+					<li><a href="#">Text documentation</a></li>
+					<li><a href="#">Models</a></li>
+				 </ul>
+				 <form class="navbar-search pull-left" action="">
+						<input type="text" placeholder="Search" />
+				</form>
+				
+				<ul class="nav pull-right">
+					<li class="dropdown">
+						<a href="#" class="dropdown-toggle" data-toggle="dropdown">Options <b class="caret"></b></a>
+						<ul class="dropdown-menu">
+							<li id="hidden_table_of_content">
+								<a href="#" onClick="hideToc()">Hide Table Of Contents</a>
 							</li>
 						</ul>
-		        	</div>
-	      		</div>
-	   		</div>
+					</li>
+				</ul>
+        	</div>
+  		</div>
+	</div>
 [/template]
 
 [template public generateFooter (aIntentDocument : IntentDocument) ]
-	<script type="text/javascript" src="./scripts/jquery.js"></script>
-	<script type="text/javascript" src="./scripts/jquery.jstree.js" ></script>	
-	<script type="text/javascript" src="./scripts/bootstrap-twipsy.js"></script>
-	<script type="text/javascript" src="./scripts/bootstrap-tooltip.js"></script>
-	<script type="text/javascript" src="./scripts/bootstrap-popover.js"></script>
-	<script type="text/javascript" src="./scripts/bootstrap-modal.js"></script>
-	<script type="text/javascript" src="./scripts/bootstrap-tabs.js"></script>
-	<script type="text/javascript" src="./scripts/bootstrap-dropdown.js" ></script>	
-	<script type="text/javascript" src="./scripts/prettify.js"></script>
-	<script type="text/javascript" src="./scripts/bootstrap-transition.js"></script>
-	<script type="text/javascript" src="./scripts/bootstrap-scrollspy.js"></script>
-	<script type="text/javascript">
-		$(function () {
-			$("#toc").jstree({ "plugins" : ['['/]"themes","html_data","ui"]})
-		});
-	</script>
-	<script language="javascript"> 
-			var toc = document.getElementById("table_of_content");							
-			var hiddenToc = document.getElementById("hidden_table_of_content");
-			var content = document.getElementById("content");
-			
-			function hideToc() {								
-				toc.style.display = "none";
-				content.style.padding = "0px 0px 0px 50px";
-				hiddenToc.innerHTML = '<a href="#" onClick="revealToc()"><i class="icon-list-alt"/>Show Table Of Contents</a>';
-			}
-			function revealToc() {								
-				toc.style.display = "block";
-				content.style.padding = "0px 0px 0px 350px";								
-				hiddenToc.innerHTML = '<a href="#" onClick="hideToc()"><i class="icon-remove"/>Hide Table Of Contents</a>';
-			}
-			function bindToc(id){
-				var parentId = "#toc_";
-				for (i =5; i<id.length-1; i = i+2){
-					if (i==5) {
-						parentId += id['['/]i];
-					} else {
-					parentId += "." + id['['/]i];
-					}
-					alert(parentId);
-					$.jstree._reference(parentId).open_node(parentId);
+<script type="text/javascript" src="./scripts/jquery.js"></script>
+<script type="text/javascript" src="./scripts/jquery.jstree.js" ></script>	
+<script type="text/javascript" src="./scripts/bootstrap-twipsy.js"></script>
+<script type="text/javascript" src="./scripts/bootstrap-tooltip.js"></script>
+<script type="text/javascript" src="./scripts/bootstrap-popover.js"></script>
+<script type="text/javascript" src="./scripts/bootstrap-modal.js"></script>
+<script type="text/javascript" src="./scripts/bootstrap-tabs.js"></script>
+<script type="text/javascript" src="./scripts/bootstrap-dropdown.js" ></script>	
+<script type="text/javascript" src="./scripts/prettify.js"></script>
+<script type="text/javascript" src="./scripts/bootstrap-transition.js"></script>
+<script type="text/javascript" src="./scripts/bootstrap-scrollspy.js"></script>
+<script type="text/javascript">
+	$(function () {
+		$("#toc").jstree({ "plugins" : ['['/]"themes","html_data","ui"]})
+	});
+</script>
+<script language="javascript"> 
+		var toc = document.getElementById("table_of_content");							
+		var hiddenToc = document.getElementById("hidden_table_of_content");
+		var content = document.getElementById("content");
+		
+		function hideToc() {								
+			toc.style.display = "none";
+			content.style.padding = "0px 0px 0px 50px";
+			hiddenToc.innerHTML = '<a href="#" onClick="revealToc()"><i class="icon-list-alt"/>Show Table Of Contents</a>';
+		}
+		function revealToc() {								
+			toc.style.display = "block";
+			content.style.padding = "0px 0px 0px 350px";								
+			hiddenToc.innerHTML = '<a href="#" onClick="hideToc()"><i class="icon-remove"/>Hide Table Of Contents</a>';
+		}
+		function bindToc(id){
+			var parentId = "#toc_";
+			for (i =5; i<id.length-1; i = i+2){
+				if (i==5) {
+					parentId += id['['/]i];
+				} else {
+				parentId += "." + id['['/]i];
 				}
-				$("#toc").jstree("set_focus");
-				$.jstree._focused().select_node(id);
+				alert(parentId);
+				$.jstree._reference(parentId).open_node(parentId);
 			}
-		$(function () {
-			$("a['['/]rel=popover]")
-			.popover({
-				animation:true,
-				offset: 10,
-				html:true,
-				trigger:"hover",
-				delay: { show: 0, hide: 100000 }
-				})
-			.click(function(e) {
-			  e.preventDefault()
+			$("#toc").jstree("set_focus");
+			$.jstree._focused().select_node(id);
+		}
+	$(function () {
+		$("a['['/]rel=popover]")
+		.popover({
+			animation:true,
+			offset: 10,
+			html:true,
+			trigger:"hover",
+			delay: { show: 0, hide: 100000 }
 			})
+		.click(function(e) {
+		  e.preventDefault()
 		})
-	</script>
+	})
+</script>
 </body>	
 </html>
 [/template]
diff --git a/plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/main/generateHTMLContent.mtl b/plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/main/generateHTMLContent.mtl
index 8a53e61..0dc77f0 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/main/generateHTMLContent.mtl
+++ b/plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/main/generateHTMLContent.mtl
@@ -8,47 +8,45 @@
 
 
 [template public generateHTMLContent(intentDocument : IntentDocument)]
-	<div id="content" >
-		[for (chapter : IntentChapter | intentDocument.chapters)]
-			[generateHTMLContent(chapter, chapter.indexInContainer().toString())/]
-		[/for]
-	</div>
+<div id="content" >
+	[for (chapter : IntentChapter | intentDocument.chapters)]
+		[generateHTMLContent(chapter, chapter.indexInContainer().toString())/]
+	[/for]
+</div>
 [/template]
 
 
 [template public generateHTMLContent(subSectionContainer : IntentSubSectionContainer, index : String) ]
-		<section id="[index/]">
-		[if subSectionContainer.oclIsTypeOf(IntentChapter)]
-			<div class="page-header">
-				<h1>
-					[subSectionContainer.generateSubSectionTitle(false)/]
-				</h1>		
-			</div>
-		[else]			
-			<h[getHeaderSize(index)/]>[subSectionContainer.generateSubSectionTitle(false)/]</h[getHeaderSize(index)/]>
-		[/if]
-		</section>
+<section id="[index/]">
+[if subSectionContainer.oclIsTypeOf(IntentChapter)]
+	<div class="page-header">
+		<h1>
+			[subSectionContainer.generateSubSectionTitle(false)/]
+		</h1>		
+	</div>
+[else]			
+	<h[getHeaderSize(index)/]>[subSectionContainer.generateSubSectionTitle(false)/]</h[getHeaderSize(index)/]>
+[/if]
+</section>
 
-		[for (child : EObject | subSectionContainer.intentContent)]
-		
-			[if child.oclIsTypeOf(IntentSection)]
-				[child.oclAsType(IntentSection).generateHTMLContent(index + '_' + child.oclAsType(IntentSection).indexInContainer())/]
-			[else]
-				[if child.oclIsTypeOf(ModelingUnit)]
-					[child.oclAsType(ModelingUnit).generateHTMLContent(index + '_' + child.oclAsType(ModelingUnit).indexInContainer())/]
-				[else ]
-					[child.generateHTMLContent()/]
-				[/if]
-			[/if]
-		[/for]
+[for (child : EObject | subSectionContainer.intentContent)]
+
+	[if child.oclIsTypeOf(IntentSection)]
+		[child.oclAsType(IntentSection).generateHTMLContent(index + '_' + child.oclAsType(IntentSection).indexInContainer())/]
+	[else]
+		[if child.oclIsTypeOf(ModelingUnit)]
+			[child.oclAsType(ModelingUnit).generateHTMLContent(index + '_' + child.oclAsType(ModelingUnit).indexInContainer())/]
+		[else ]
+			[child.generateHTMLContent()/]
+		[/if]
+	[/if]
+[/for]
 [/template]
 
 [template public generateHTMLContent(descriptionUnit :DescriptionUnit )]
-	<p>
-	[for (bloc : EObject | descriptionUnit.instructions)]
-		[bloc.generateHTMLContent()/]	
-	[/for]
-	</p>
+<p>
+	[descriptionUnit.instructions.generateHTMLContent()/]
+</p>
 [/template]
 
 [template public generateHTMLContent(descriptionBloc : DescriptionBloc)]
@@ -71,142 +69,131 @@
 
 
 [template public generateHTMLContent(modelingUnit :ModelingUnit, index : String )]
-	<div  class="mu" id="index">
-		<ul>
-			[for (instruction : UnitInstruction | modelingUnit.instructions)]
-				[generateHTMLContent(instruction)/]
-			[/for]
-		</ul>
-	</div>
+<div  class="mu" id="index">
+	<ul>
+		[modelingUnit.instructions.generateHTMLContent()->sep(lineSeparator())/]
+	</ul>
+</div>
 [/template]
 
 [template public generateHTMLContent(instancation : InstanciationInstruction)]
-	<li class="jstree-open">
-		[instancation.getImageForValue()/]
+<li class="jstree-open">
+	[instancation.getImageForValue()/]		
+	<a href="#"	rel="popover" title=""
+	[instancation.generatePopoverLinks()/]>
+[if instancation.name->isEmpty()._not()]
+	[instancation.name/] - 
+[/if]
+ 		new [instancation.metaType.IntentHref/] [definitionInformation()/]
+	</a>
 
-		<a href="#"												
-			rel="popover" title=""
-			[instancation.generatePopoverLinks()/]
-		>
-		[if instancation.name->isEmpty()._not()]
-			[instancation.name/] - 
-		[/if]
-		 new [instancation.metaType.IntentHref/] [definitionInformation()/]
-
-		</a>
-		[if instancation.structuralFeatures->size() > 0]
-			<ul>
-			[for (structuralFeature : StructuralFeatureAffectation | instancation.structuralFeatures)]
-				[generateHTMLContent(structuralFeature)/]
-			[/for]
-			</ul>
-		[/if]
-	</li>
+[if instancation.structuralFeatures->size() > 0]
+	<ul>
+		[instancation.structuralFeatures.generateHTMLContent()->sep(lineSeparator())/]
+	</ul>
+[/if]
+</li>
 [/template]
 
 [template public generateHTMLContent(contribution : ContributionInstruction)]
-	<li class="jstree-open">
-		[contribution.getImageForValue()/]
+<li class="jstree-open">
+[contribution.getImageForValue()/]
 
-		<a href="#"												
-			rel="popover" title="Contribution to [contribution.referencedElement.IntentHref/] [if contribution.referencedElement.referencedElement.oclIsInvalid()._not()](of type [contribution.referencedElement.referencedElement.oclAsType(InstanciationInstruction).metaType.IntentHref/])[/if]"
-			[contribution.referencedElement.referencedElement.oclAsType(InstanciationInstruction).generatePopoverLinks()/]
-			"
-		>
-		[contribution.referencedElement.IntentHref/] [contributionInformation()/]
-		</a>
-		[if contribution.contributions->size() > 0]
-			<ul>
-			[for (structuralFeature : UnitInstruction | contribution.contributions)]
-				[generateHTMLContent(structuralFeature)/]
-			[/for]
-			</ul>
-		[/if]
-	</li>
+	<a href="#"												
+		rel="popover" title="Contribution to [contribution.referencedElement.IntentHref/] [if contribution.referencedElement.referencedElement.oclIsInvalid()._not()](of type [contribution.referencedElement.referencedElement.oclAsType(InstanciationInstruction).metaType.IntentHref/])[/if]"
+	[contribution.referencedElement.referencedElement.oclAsType(InstanciationInstruction).generatePopoverLinks()/]
+		">
+	[contribution.referencedElement.IntentHref/] [contributionInformation()/]
+</a>
+[if contribution.contributions->size() > 0]
+	<ul>
+	[contribution.contributions.generateHTMLContent()->sep(lineSeparator())/]
+	</ul>
+[/if]
+</li>
 [/template]
 
 [template public generateHTMLContent(resourceDeclaration : ResourceDeclaration)]
-	<li class="jstree-open">
-		<img src="./icons/modelingunit_resource.gif"/>
+<li class="jstree-open">
+	<img src="./icons/modelingunit_resource.gif"/>
 
-		<a href="#"												
-			rel="popover" title="Resource [resourceDeclaration.name/]"
-			data-content="Some infos"
-		>
-		Resource [resourceDeclaration.name/]
-		</a>
-			[if resourceDeclaration.uri->isEmpty()._not()]
-				(URI :<code style="color:blue; border:0px solid black;">[resourceDeclaration.uri.toString()/])</code>
-			[/if]
-			[if resourceDeclaration.content->size() > 0]
-				<ul>
-				[for (reference : ModelingUnitInstructionReference | resourceDeclaration.content)]
-					<a href="#"												
-				rel="popover" title="Reference to [reference.IntentHref/] [if reference.referencedElement.oclAsType(InstanciationInstruction).metaType.oclIsInvalid()._not()](of type [reference.referencedElement.oclAsType(InstanciationInstruction).metaType.IntentHref/])[/if]"
-				[reference.referencedElement.oclAsType(InstanciationInstructionReference).referencedElement.generatePopoverLinks()/]
-				>[reference.IntentHref/]</a>
-				[/for]
-				</ul>
-			[/if]
-	</li>
+	<a href="#"												
+		rel="popover" title="Resource [resourceDeclaration.name/]"
+		data-content="Some infos"
+	>
+	Resource [resourceDeclaration.name/]
+	</a>
+		[if resourceDeclaration.uri->isEmpty()._not()]
+			(URI :<code style="color:blue; border:0px solid black;">[resourceDeclaration.uri.toString()/])</code>
+		[/if]
+		[if resourceDeclaration.content->size() > 0]
+			<ul>
+			[for (reference : ModelingUnitInstructionReference | resourceDeclaration.content)]
+				<a href="#"												
+			rel="popover" title="Reference to [reference.IntentHref/] [if reference.referencedElement.oclAsType(InstanciationInstruction).metaType.oclIsInvalid()._not()](of type [reference.referencedElement.oclAsType(InstanciationInstruction).metaType.IntentHref/])[/if]"
+			[reference.referencedElement.oclAsType(InstanciationInstructionReference).referencedElement.generatePopoverLinks()/]
+			>[reference.IntentHref/]</a>
+			[/for]
+			</ul>
+		[/if]
+</li>
 [/template]
 
 [template public generateHTMLContent(structuralFeature : StructuralFeatureAffectation)]
-	
-	<li class="jstree-open">
-		[comment icon/]
-		[if structuralFeature.values->size() >0]
-			[structuralFeature.values->first().getImageForValue()/]
-		[/if]
+<li class="jstree-open">
+	[comment icon/]
+	[if structuralFeature.values->size() >0]
+		[structuralFeature.values->first().getImageForValue()/]
+	[/if]
 
-		[comment left-hand link/]
-		<a href="#" style="color:black"									
-			rel="popover" title="Feature [structuralFeature.name/] [if structuralFeature.metaType.IntentHref.oclIsInvalid()._not()](of type [structuralFeature.metaType.IntentHref/])[/if]"
-			data-content="Informations on [structuralFeature.name/]"
-		>
-		[structuralFeature.name/]
-		</a>
-		
-		[comment single-valued/]		
-		[if structuralFeature.values->size() = 1]
-			[if (structuralFeature.values->first().oclIsKindOf(NativeValueForStructuralFeature))]:
-			[else]
-				&larr;
-			[/if]
-			[structuralFeature.values->first().generateHTMLContent()/]
+	[comment left-hand link/]
+	<a href="#" style="color:black"									
+		rel="popover" title="Feature [structuralFeature.name/] [if structuralFeature.metaType.IntentHref.oclIsInvalid()._not()](of type [structuralFeature.metaType.IntentHref/])[/if]"
+		data-content="Informations on [structuralFeature.name/]"
+	>
+	[structuralFeature.name/]
+	</a>
+	
+	[comment single-valued/]		
+	[if structuralFeature.values->size() = 1]
+		[if (structuralFeature.values->first().oclIsKindOf(NativeValueForStructuralFeature))]:
 		[else]
-			[comment multi-valued/]
-			&larr; <ul>
-			[for (value : ValueForStructuralFeature | structuralFeature.values)]				
-				<li>[value.getImageForValue()/] [value.generateHTMLContent()/]</li>
-				[/for] 
-			</ul>
+			&larr;
 		[/if]
+		[structuralFeature.values->first().generateHTMLContent()/]
+	[else]
+		[comment multi-valued/]
+		&larr; <ul>
+		[for (value : ValueForStructuralFeature | structuralFeature.values)]				
+			<li>[value.getImageForValue()/] [value.generateHTMLContent()/]</li>
+			[/for] 
+		</ul>
+	[/if]
 [/template]
 
 
 
 [template public generateHTMLContent(newValueInstruction : NewObjectValueForStructuralFeature)]
 <a href="#"												
-			rel="popover" title=""
-			[newValueInstruction.value.generatePopoverLinks()/]
-		>
-		[if newValueInstruction.value.name->isEmpty()._not()]
-			[newValueInstruction.value.name/] - 
-		[/if]
-		 new [newValueInstruction.value.metaType.IntentHref/] [definitionInformation()/]
+	rel="popover" title=""
+	[newValueInstruction.value.generatePopoverLinks()/]
+>
+[if newValueInstruction.value.name->isEmpty()._not()]
+	[newValueInstruction.value.name/] - 
+[/if]
+ new [newValueInstruction.value.metaType.IntentHref/] [definitionInformation()/]
 
-		</a>
-		[if newValueInstruction.value.structuralFeatures->size() > 0]
-			<ul>
-				[for (structuralFeature : StructuralFeatureAffectation | newValueInstruction.value.structuralFeatures->select(feature | feature.values->select(value | value.oclIsKindOf(NativeValueForStructuralFeature))->size() = feature.values->size()))]
-					[generateHTMLContent(structuralFeature)/]
-				[/for]
-				[for (structuralFeature : StructuralFeatureAffectation | newValueInstruction.value.structuralFeatures->select(feature | feature.values->select(value | value.oclIsKindOf(NativeValueForStructuralFeature))->size() <> feature.values->size()))]
-					[generateHTMLContent(structuralFeature)/]
-				[/for]
-			</ul>
-		[/if]
+</a>
+[if newValueInstruction.value.structuralFeatures->size() > 0]
+<ul>
+	[for (structuralFeature : StructuralFeatureAffectation | newValueInstruction.value.structuralFeatures->select(feature | feature.values->select(value | value.oclIsKindOf(NativeValueForStructuralFeature))->size() = feature.values->size()))]
+		[generateHTMLContent(structuralFeature)/]
+	[/for]
+	[for (structuralFeature : StructuralFeatureAffectation | newValueInstruction.value.structuralFeatures->select(feature | feature.values->select(value | value.oclIsKindOf(NativeValueForStructuralFeature))->size() <> feature.values->size()))]
+		[generateHTMLContent(structuralFeature)/]
+	[/for]
+</ul>
+[/if]
 [/template]
 
 [template public generateHTMLContent(valueInstruction : NativeValueForStructuralFeature)]
@@ -285,12 +272,25 @@
 
 [template public generatePopoverLinks(instruction : InstanciationInstruction)]
 data-content="<h4> Definition </h4>
-			[let containingSection : IntentSection = instruction.getContainingSection()]
-				<ul><li><a href='#[containingSection.getContainingSectionID()/]' >[containingSection.generateSubSectionTitle(true)/]</a></li></ul>
-			[/let]
-				<h4> Other contributions </h4>
-				
-			"
+[let containingSection : IntentSection = instruction.getContainingSection()]
+	<ul><li><a href='#[containingSection.getContainingSectionID()/]' >[containingSection.generateSubSectionTitle(true)/]</a></li></ul>
+[/let]
+
+[let  contributions : OrderedSet(ContributionInstruction) = instruction.getAllContributions()]
+[if contributions->size()>0]
+	<h4> Other contributions </h4>
+	<ul>
+[/if]
+[for (contribution : ContributionInstruction | contributions)]
+[let containingSection : IntentSection = contribution.getContainingSection()]
+		<li><a href='#[containingSection.getContainingSectionID()/]' >[containingSection.generateSubSectionTitle(true)/]</a></li>
+[/let]
+[/for]
+[if contributions->size()>0]	
+	</ul>
+[/if]
+[/let]
+"
 [/template]
 
 [template public contributionInformation()]
diff --git a/plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/main/generateToc.mtl b/plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/main/generateToc.mtl
index 03407d4..d01046c 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/main/generateToc.mtl
+++ b/plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/main/generateToc.mtl
@@ -2,33 +2,34 @@
 [module generateToc('http://www.eclipse.org/intent/intentdocument/0.7','http://www.eclipse.org/intent/markup/0.7', 'http://www.eclipse.org/intent/modelingunit/0.7','http://www.eclipse.org/intent/markup/generator/0.7')]
 [import org::eclipse::mylyn::docs::intent::markup::gen::files::html/]
 [import org::eclipse::mylyn::docs::intent::markup::gen::files::htmlGenDocument/]
+[import org::eclipse::mylyn::docs::intent::exporter::queries::documentQueries /]
 
 [template public generateTOC(intentDocument : IntentDocument)]
-	<div id="table_of_content" class="sidebar-nav toc">
-			<div class="summary">				
-						<h3 class="summaryTitle">Table Of Contents</h3>
-						<div id="toc" class="demo" style="height:100px;">					
-							<ul id="menu" >
-							[for (chapter : IntentChapter | intentDocument.chapters)]
-								[chapter.generateToc(indexInContainer(chapter))/]
-							[/for]							
-							</ul>
-						</div>
-			</div>
-	</div>
+<div id="table_of_content" class="sidebar-nav toc">
+		<div class="summary">				
+					<h3 class="summaryTitle">Table Of Contents</h3>
+					<div id="toc" class="demo" style="height:100px;">					
+						<ul id="menu" >
+						[for (chapter : IntentChapter | intentDocument.chapters)]
+							[chapter.generateToc(indexInContainer(chapter))/]
+						[/for]							
+						</ul>
+					</div>
+		</div>
+</div>
 [/template]
 
 [template public generateToc (subSectionContainer : IntentSubSectionContainer, index : String) ]
-	<li id="toc_[index/]">
-		<a href="#" onClick="javascript:window.location = '#[index/]';">
-			[generateSubSectionTitle(subSectionContainer, true)/]
-		</a>
-		<ul>
-			[for (subSection : IntentSection | subSectionContainer.intentContent->filter(IntentSection))]
-				[subSection.generateToc(index + '_' + indexInContainer(subSection.oclAsType(IntentSection)))/]
-			[/for]
-		</ul>
-	</li>
+<li id="toc_[index/]">
+	<a href="#" onClick="javascript:window.location = '#[index/]';">
+		[generateSubSectionTitle(subSectionContainer, true)/]
+	</a>
+	<ul>
+		[for (subSection : IntentSection | subSectionContainer.intentContent->filter(IntentSection))]
+			[subSection.generateToc(index + '_' + indexInContainer(subSection.oclAsType(IntentSection)))/]
+		[/for]
+	</ul>
+</li>
 [/template]
 
 [template public generateSubSectionTitle(subSectionContainer : IntentSubSectionContainer, showUntitled : Boolean)]
@@ -40,12 +41,4 @@
 	[else]
 	[/if]
 [/if]
-[/template]
-
-[query public indexInContainer(subSectionContainer : IntentSubSectionContainer) : String = 
-subSectionContainer.eContainer().eContents()->filter(IntentSubSectionContainer)->asSequence()->indexOf(subSectionContainer).toString()
-/]
-
-[query public indexInContainer(modelingUnit : ModelingUnit) : String = 
-modelingUnit.eContainer().eContents()->filter(ModelingUnit)->asSequence()->indexOf(modelingUnit).toString()
-/]
\ No newline at end of file
+[/template]
\ No newline at end of file
diff --git a/plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/queries/documentQueries.mtl b/plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/queries/documentQueries.mtl
index ea1b899..fd3e6ee 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/queries/documentQueries.mtl
+++ b/plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/queries/documentQueries.mtl
@@ -17,3 +17,15 @@
 [query public getContainingSectionID(classifer : EObject) : String = 
 invoke('org.eclipse.mylyn.docs.intent.exporter.services.IntentAcceleoServices', 'getContainingSectionID(org.eclipse.emf.ecore.EObject)', Sequence{classifer})
 /]
+
+[query public indexInContainer(subSectionContainer : IntentSubSectionContainer) : String = 
+subSectionContainer.eContainer().eContents()->filter(IntentSubSectionContainer)->asSequence()->indexOf(subSectionContainer).toString()
+/]
+
+[query public indexInContainer(modelingUnit : ModelingUnit) : String = 
+modelingUnit.eContainer().eContents()->filter(ModelingUnit)->asSequence()->indexOf(modelingUnit).toString()
+/]
+
+[query public getAllContributions(instanciationOrContributionInstruction : UnitInstruction) : OrderedSet(ContributionInstruction) =
+invoke('org.eclipse.mylyn.docs.intent.exporter.services.IntentAcceleoServices', 'getAllContributions(org.eclipse.mylyn.docs.intent.core.genericunit.UnitInstruction)', Sequence{instanciationOrContributionInstruction})
+ /]
diff --git a/plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/services/IntentAcceleoServices.java b/plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/services/IntentAcceleoServices.java
index fe2da3c..49fc79e 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/services/IntentAcceleoServices.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/services/IntentAcceleoServices.java
@@ -10,14 +10,26 @@
  *******************************************************************************/
 package org.eclipse.mylyn.docs.intent.exporter.services;
 
-import java.io.File;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Sets;
 
+import java.io.File;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map.Entry;
+
+import org.eclipse.emf.common.util.EList;
 import org.eclipse.emf.ecore.EObject;
+import org.eclipse.mylyn.docs.intent.collab.common.location.IntentLocations;
 import org.eclipse.mylyn.docs.intent.collab.handlers.adapters.RepositoryAdapter;
+import org.eclipse.mylyn.docs.intent.core.compiler.TraceabilityIndex;
+import org.eclipse.mylyn.docs.intent.core.compiler.TraceabilityIndexEntry;
 import org.eclipse.mylyn.docs.intent.core.document.IntentDocument;
+import org.eclipse.mylyn.docs.intent.core.document.IntentGenericElement;
 import org.eclipse.mylyn.docs.intent.core.document.IntentSection;
 import org.eclipse.mylyn.docs.intent.core.document.IntentSubSectionContainer;
 import org.eclipse.mylyn.docs.intent.core.genericunit.UnitInstruction;
+import org.eclipse.mylyn.docs.intent.core.modelingunit.ContributionInstruction;
 
 /**
  * Regroups all services use during doc export.
@@ -101,6 +113,38 @@
 		return null;
 	}
 
+	/**
+	 * Returns all the {@link ContributionInstruction}s related to the given {@link UnitInstruction}.
+	 * 
+	 * @param instruction
+	 *            the instruction to consider
+	 * @return all the {@link ContributionInstruction}s related to the given {@link UnitInstruction}
+	 */
+	public static Collection<ContributionInstruction> getAllContributions(UnitInstruction instruction) {
+		Collection<ContributionInstruction> contributionInstructions = Sets.newLinkedHashSet();
+		TraceabilityIndex index = (TraceabilityIndex)repositoryAdapter
+				.getResource(IntentLocations.TRACEABILITY_INFOS_INDEX_PATH).getContents().get(0);
+
+		boolean foundContributions = false;
+		for (Iterator<TraceabilityIndexEntry> iterator = index.getEntries().iterator(); iterator.hasNext()
+				&& !foundContributions;) {
+			TraceabilityIndexEntry entry = (TraceabilityIndexEntry)iterator.next();
+			for (Iterator<Entry<EObject, EList<IntentGenericElement>>> elements = entry
+					.getContainedElementToInstructions().iterator(); elements.hasNext()
+					&& !foundContributions;) {
+
+				Entry<EObject, EList<IntentGenericElement>> elementToInstruction = elements.next();
+				if (elementToInstruction.getValue().contains(instruction)) {
+					contributionInstructions.addAll(Sets.newLinkedHashSet(Iterables.filter(
+							elementToInstruction.getValue(), ContributionInstruction.class)));
+					foundContributions = true;
+				}
+			}
+		}
+		contributionInstructions.remove(instruction);
+		return contributionInstructions;
+	}
+
 	public static void initialize(String documentTitle, File generationOutputFolder, RepositoryAdapter adapter) {
 		intentDocumentTitle = documentTitle;
 		outputFolder = generationOutputFolder;