Merge branch 'master' into cdo-integration
Conflicts:
plugins/org.eclipse.mylyn.docs.intent.collab.cdo/src/org/eclipse/mylyn/docs/intent/collab/cdo/repository/CDORepository.java
tests/org.eclipse.mylyn.docs.intent.client.ui.test/META-INF/MANIFEST.MF
tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/unit/compare/IntentMatchEngineTests.java
diff --git a/examples/org.eclipse.mylyn.docs.intent.example.cdo.server/META-INF/MANIFEST.MF b/examples/org.eclipse.mylyn.docs.intent.example.cdo.server/META-INF/MANIFEST.MF
index ffc20b5..39933b9 100644
--- a/examples/org.eclipse.mylyn.docs.intent.example.cdo.server/META-INF/MANIFEST.MF
+++ b/examples/org.eclipse.mylyn.docs.intent.example.cdo.server/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.mylyn.docs.intent.example.cdo.server;singleton:=true
-Bundle-Version: 0.7.0.qualifier
+Bundle-Version: 0.8.0.qualifier
Bundle-Vendor: %providerName
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Require-Bundle: org.eclipse.ui;bundle-version="3.7.100",
diff --git a/examples/org.eclipse.mylyn.docs.intent.example.cdo.server/pom.xml b/examples/org.eclipse.mylyn.docs.intent.example.cdo.server/pom.xml
index ccd95f8..5a4430b 100644
--- a/examples/org.eclipse.mylyn.docs.intent.example.cdo.server/pom.xml
+++ b/examples/org.eclipse.mylyn.docs.intent.example.cdo.server/pom.xml
@@ -13,7 +13,7 @@
<parent>
<groupId>org.eclipse.mylyn.docs.intent-group</groupId>
<artifactId>intent-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
diff --git a/examples/org.eclipse.mylyn.docs.intent.example.documents/META-INF/MANIFEST.MF b/examples/org.eclipse.mylyn.docs.intent.example.documents/META-INF/MANIFEST.MF
index 3f73ab4..863cb2f 100644
--- a/examples/org.eclipse.mylyn.docs.intent.example.documents/META-INF/MANIFEST.MF
+++ b/examples/org.eclipse.mylyn.docs.intent.example.documents/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.mylyn.docs.intent.example.documents;singleton:=true
-Bundle-Version: 0.7.0.qualifier
+Bundle-Version: 0.8.0.qualifier
Bundle-Vendor: %providerName
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ui
diff --git a/examples/org.eclipse.mylyn.docs.intent.example.documents/pom.xml b/examples/org.eclipse.mylyn.docs.intent.example.documents/pom.xml
index 41b4447..346b71b 100644
--- a/examples/org.eclipse.mylyn.docs.intent.example.documents/pom.xml
+++ b/examples/org.eclipse.mylyn.docs.intent.example.documents/pom.xml
@@ -13,7 +13,7 @@
<parent>
<groupId>org.eclipse.mylyn.docs.intent-group</groupId>
<artifactId>intent-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
diff --git a/examples/org.eclipse.mylyn.docs.intent.retro/META-INF/MANIFEST.MF b/examples/org.eclipse.mylyn.docs.intent.retro/META-INF/MANIFEST.MF
index 7c6dcde..4a8e39e 100644
--- a/examples/org.eclipse.mylyn.docs.intent.retro/META-INF/MANIFEST.MF
+++ b/examples/org.eclipse.mylyn.docs.intent.retro/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.mylyn.docs.intent.retro;singleton:=true
-Bundle-Version: 0.7.0.qualifier
+Bundle-Version: 0.8.0.qualifier
Bundle-ClassPath: .
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/examples/org.eclipse.mylyn.docs.intent.retro/pom.xml b/examples/org.eclipse.mylyn.docs.intent.retro/pom.xml
index 3b9e53b..c116b7e 100644
--- a/examples/org.eclipse.mylyn.docs.intent.retro/pom.xml
+++ b/examples/org.eclipse.mylyn.docs.intent.retro/pom.xml
@@ -13,7 +13,7 @@
<parent>
<groupId>org.eclipse.mylyn.docs.intent-group</groupId>
<artifactId>intent-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
diff --git a/features/org.eclipse.mylyn.docs.intent-feature/feature.xml b/features/org.eclipse.mylyn.docs.intent-feature/feature.xml
index 93931cb..12d2167 100644
--- a/features/org.eclipse.mylyn.docs.intent-feature/feature.xml
+++ b/features/org.eclipse.mylyn.docs.intent-feature/feature.xml
@@ -12,7 +12,7 @@
<feature
id="org.eclipse.mylyn.docs.intent.feature"
label="%featureName"
- version="0.7.0.qualifier"
+ version="0.8.0.qualifier"
provider-name="%providerName"
plugin="org.eclipse.mylyn.docs.intent">
@@ -124,4 +124,11 @@
version="0.0.0"
unpack="false"/>
+ <plugin
+ id="org.eclipse.mylyn.docs.intent.client.linkresolver"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
</feature>
diff --git a/features/org.eclipse.mylyn.docs.intent-feature/pom.xml b/features/org.eclipse.mylyn.docs.intent-feature/pom.xml
index 7bf4ce6..d511d9b 100644
--- a/features/org.eclipse.mylyn.docs.intent-feature/pom.xml
+++ b/features/org.eclipse.mylyn.docs.intent-feature/pom.xml
@@ -13,7 +13,7 @@
<parent>
<groupId>org.eclipse.mylyn.docs.intent-group</groupId>
<artifactId>intent-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
diff --git a/features/org.eclipse.mylyn.docs.intent.cdo-feature/feature.xml b/features/org.eclipse.mylyn.docs.intent.cdo-feature/feature.xml
index 906f5bc..ef296df 100644
--- a/features/org.eclipse.mylyn.docs.intent.cdo-feature/feature.xml
+++ b/features/org.eclipse.mylyn.docs.intent.cdo-feature/feature.xml
@@ -12,7 +12,7 @@
<feature
id="org.eclipse.mylyn.docs.intent.cdo.feature"
label="%featureName"
- version="0.7.0.qualifier"
+ version="0.8.0.qualifier"
provider-name="%providerName"
plugin="org.eclipse.mylyn.docs.intent.client.ui.cdo">
diff --git a/features/org.eclipse.mylyn.docs.intent.cdo-feature/pom.xml b/features/org.eclipse.mylyn.docs.intent.cdo-feature/pom.xml
index d7f79f8..56325b7 100644
--- a/features/org.eclipse.mylyn.docs.intent.cdo-feature/pom.xml
+++ b/features/org.eclipse.mylyn.docs.intent.cdo-feature/pom.xml
@@ -13,7 +13,7 @@
<parent>
<groupId>org.eclipse.mylyn.docs.intent-group</groupId>
<artifactId>intent-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
diff --git a/features/org.eclipse.mylyn.docs.intent.exporter-feature/feature.xml b/features/org.eclipse.mylyn.docs.intent.exporter-feature/feature.xml
index 498596c..33255fd 100644
--- a/features/org.eclipse.mylyn.docs.intent.exporter-feature/feature.xml
+++ b/features/org.eclipse.mylyn.docs.intent.exporter-feature/feature.xml
@@ -2,7 +2,7 @@
<feature
id="org.eclipse.mylyn.docs.intent.exporter.feature"
label="%featureName"
- version="0.7.0.qualifier"
+ version="0.8.0.qualifier"
provider-name="%providerName">
<description url="http://www.example.com/description">
diff --git a/features/org.eclipse.mylyn.docs.intent.exporter-feature/pom.xml b/features/org.eclipse.mylyn.docs.intent.exporter-feature/pom.xml
index 5249ae9..ac9d94f 100644
--- a/features/org.eclipse.mylyn.docs.intent.exporter-feature/pom.xml
+++ b/features/org.eclipse.mylyn.docs.intent.exporter-feature/pom.xml
@@ -13,7 +13,7 @@
<parent>
<groupId>org.eclipse.mylyn.docs.intent-group</groupId>
<artifactId>intent-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
diff --git a/features/org.eclipse.mylyn.docs.intent.markup-feature/feature.xml b/features/org.eclipse.mylyn.docs.intent.markup-feature/feature.xml
index 430c61a..92c26e5 100644
--- a/features/org.eclipse.mylyn.docs.intent.markup-feature/feature.xml
+++ b/features/org.eclipse.mylyn.docs.intent.markup-feature/feature.xml
@@ -12,7 +12,7 @@
<feature
id="org.eclipse.mylyn.docs.intent.markup.feature"
label="%featureName"
- version="0.7.0.qualifier"
+ version="0.8.0.qualifier"
provider-name="%providerName">
<description>
diff --git a/features/org.eclipse.mylyn.docs.intent.markup-feature/pom.xml b/features/org.eclipse.mylyn.docs.intent.markup-feature/pom.xml
index f92dc2f..89c9f1d 100644
--- a/features/org.eclipse.mylyn.docs.intent.markup-feature/pom.xml
+++ b/features/org.eclipse.mylyn.docs.intent.markup-feature/pom.xml
@@ -13,7 +13,7 @@
<parent>
<groupId>org.eclipse.mylyn.docs.intent-group</groupId>
<artifactId>intent-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
diff --git a/features/org.eclipse.mylyn.docs.intent.retro-feature/feature.xml b/features/org.eclipse.mylyn.docs.intent.retro-feature/feature.xml
index e4f3e43..b8bcb23 100644
--- a/features/org.eclipse.mylyn.docs.intent.retro-feature/feature.xml
+++ b/features/org.eclipse.mylyn.docs.intent.retro-feature/feature.xml
@@ -2,7 +2,7 @@
<feature
id="org.eclipse.mylyn.docs.intent.retro.feature"
label="%featureName"
- version="0.7.0.qualifier"
+ version="0.8.0.qualifier"
provider-name="%providerName"
plugin="org.eclipse.mylyn.docs.intent.retro">
diff --git a/features/org.eclipse.mylyn.docs.intent.retro-feature/pom.xml b/features/org.eclipse.mylyn.docs.intent.retro-feature/pom.xml
index 282a273..57eb317 100644
--- a/features/org.eclipse.mylyn.docs.intent.retro-feature/pom.xml
+++ b/features/org.eclipse.mylyn.docs.intent.retro-feature/pom.xml
@@ -13,7 +13,7 @@
<parent>
<groupId>org.eclipse.mylyn.docs.intent-group</groupId>
<artifactId>intent-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
diff --git a/features/org.eclipse.mylyn.docs.intent.update/pom.xml b/features/org.eclipse.mylyn.docs.intent.update/pom.xml
index 96ff3f9..7916c52 100644
--- a/features/org.eclipse.mylyn.docs.intent.update/pom.xml
+++ b/features/org.eclipse.mylyn.docs.intent.update/pom.xml
@@ -14,7 +14,7 @@
<parent>
<groupId>org.eclipse.mylyn.docs.intent-group</groupId>
<artifactId>intent-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
@@ -22,7 +22,7 @@
<packaging>eclipse-repository</packaging>
<!-- see http://issues.sonatype.org/browse/TYCHO-313 -->
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<build>
<plugins>
diff --git a/features/org.eclipse.mylyn.docs.intent.workspace-feature/feature.xml b/features/org.eclipse.mylyn.docs.intent.workspace-feature/feature.xml
index 529d09b..6b41076 100644
--- a/features/org.eclipse.mylyn.docs.intent.workspace-feature/feature.xml
+++ b/features/org.eclipse.mylyn.docs.intent.workspace-feature/feature.xml
@@ -12,7 +12,7 @@
<feature
id="org.eclipse.mylyn.docs.intent.workspace.feature"
label="%featureName"
- version="0.7.0.qualifier"
+ version="0.8.0.qualifier"
provider-name="%providerName"
plugin="org.eclipse.emf.cdo.ui.ide">
diff --git a/features/org.eclipse.mylyn.docs.intent.workspace-feature/pom.xml b/features/org.eclipse.mylyn.docs.intent.workspace-feature/pom.xml
index c98253b..a356713 100644
--- a/features/org.eclipse.mylyn.docs.intent.workspace-feature/pom.xml
+++ b/features/org.eclipse.mylyn.docs.intent.workspace-feature/pom.xml
@@ -13,7 +13,7 @@
<parent>
<groupId>org.eclipse.mylyn.docs.intent-group</groupId>
<artifactId>intent-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.compiler/META-INF/MANIFEST.MF b/plugins/org.eclipse.mylyn.docs.intent.client.compiler/META-INF/MANIFEST.MF
index 2a6bbf9..cd3eaf4 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.compiler/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.compiler/META-INF/MANIFEST.MF
@@ -3,15 +3,13 @@
Bundle-Localization: plugin
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.mylyn.docs.intent.client.compiler
-Bundle-Version: 0.7.0.qualifier
+Bundle-Version: 0.8.0.qualifier
Bundle-Vendor: %providerName
Require-Bundle: org.eclipse.emf.common;bundle-version="2.6.0",
org.eclipse.emf.ecore;bundle-version="2.6.0",
org.eclipse.mylyn.docs.intent.core,
org.eclipse.mylyn.docs.intent.collab,
org.eclipse.mylyn.docs.intent.collab.common,
- org.eclipse.emf.compare.match;bundle-version="[1.2.0,2.0.0)",
- org.eclipse.emf.compare;bundle-version="[1.2.0,2.0.0)",
com.google.guava
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Export-Package:
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.compiler/pom.xml b/plugins/org.eclipse.mylyn.docs.intent.client.compiler/pom.xml
index 19eac2a..dbccf28 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.compiler/pom.xml
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.compiler/pom.xml
@@ -13,7 +13,7 @@
<parent>
<groupId>org.eclipse.mylyn.docs.intent-group</groupId>
<artifactId>intent-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.indexer/META-INF/MANIFEST.MF b/plugins/org.eclipse.mylyn.docs.intent.client.indexer/META-INF/MANIFEST.MF
index 8a99728..0630cd4 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.indexer/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.indexer/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@
Bundle-Localization: plugin
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.mylyn.docs.intent.client.indexer
-Bundle-Version: 0.7.0.qualifier
+Bundle-Version: 0.8.0.qualifier
Bundle-Vendor: %providerName
Require-Bundle: org.eclipse.mylyn.docs.intent.core,
org.eclipse.mylyn.docs.intent.collab,
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.indexer/pom.xml b/plugins/org.eclipse.mylyn.docs.intent.client.indexer/pom.xml
index b4e7263..491aade 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.indexer/pom.xml
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.indexer/pom.xml
@@ -13,7 +13,7 @@
<parent>
<groupId>org.eclipse.mylyn.docs.intent-group</groupId>
<artifactId>intent-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.indexer/src/org/eclipse/mylyn/docs/intent/client/indexer/tocmaker/TocMaker.java b/plugins/org.eclipse.mylyn.docs.intent.client.indexer/src/org/eclipse/mylyn/docs/intent/client/indexer/tocmaker/TocMaker.java
index cb54483..1337ca3 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.indexer/src/org/eclipse/mylyn/docs/intent/client/indexer/tocmaker/TocMaker.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.indexer/src/org/eclipse/mylyn/docs/intent/client/indexer/tocmaker/TocMaker.java
@@ -20,7 +20,6 @@
import org.eclipse.mylyn.docs.intent.core.document.IntentDocument;
import org.eclipse.mylyn.docs.intent.core.document.IntentSection;
import org.eclipse.mylyn.docs.intent.core.document.IntentStructuredElement;
-import org.eclipse.mylyn.docs.intent.core.document.IntentSubSectionContainer;
import org.eclipse.mylyn.docs.intent.core.indexer.INDEX_ENTRY_TYPE;
import org.eclipse.mylyn.docs.intent.core.indexer.IntentIndex;
import org.eclipse.mylyn.docs.intent.core.indexer.IntentIndexEntry;
@@ -43,6 +42,7 @@
* the Intent document
*/
public void computeIndex(IntentIndex index, IntentDocument document) {
+
// Purge Index
List<EObject> toRemove = new ArrayList<EObject>();
for (Iterator<EObject> iterator = index.eAllContents(); iterator.hasNext();) {
@@ -77,18 +77,19 @@
documentIndexEntry.setName(title);
documentIndexEntry.setReferencedElement(document);
documentIndexEntry.setType(INDEX_ENTRY_TYPE.INTENT_DOCUMENT);
- int chapterIt = 0;
// Step 4: for each chapter contained in this document
for (IntentChapter chapter : document.getChapters()) {
IntentIndexEntry candidateChapterEntry = null;
// Step 4.1: we use an existing index entry if any
- if (documentIndexEntry.getSubEntries().size() > chapterIt) {
- candidateChapterEntry = documentIndexEntry.getSubEntries().get(chapterIt);
+ for (IntentIndexEntry candidate : documentIndexEntry.getSubEntries()) {
+ if (((IntentStructuredElement)candidate.getReferencedElement()).getCompleteLevel().equals(
+ chapter.getCompleteLevel())) {
+ candidateChapterEntry = candidate;
+ }
}
// Step 4.2: and compute the entry for this chapter
computeEntryForChapter(documentIndexEntry, candidateChapterEntry, chapter);
- chapterIt++;
}
}
@@ -113,33 +114,29 @@
}
// Step 2: compute the title
- String chapterIndex = getIndex(chapter);
String title = StructuredElementHelper.getTitle(chapter);
if ((title == null) || (title.length() < 1)) {
title = "Untitled Chapter";
}
// Step 3: setting index entry informations
- chapterEntry.setName(chapterIndex + " " + title);
+ chapterEntry.setName(chapter.getCompleteLevel() + " " + title);
chapterEntry.setReferencedElement(chapter);
chapterEntry.setType(INDEX_ENTRY_TYPE.INTENT_CHAPTER);
- // Step 4: update the level of this chapter
- if (!chapterIndex.equals(chapter.getCompleteLevel())) {
- chapter.setCompleteLevel(chapterIndex);
- }
-
- // Step 5: for each section contained in this chapter
- int subSectionIt = 0;
+ // Step 4: for each section contained in this chapter
for (IntentSection section : chapter.getSubSections()) {
- // Step 5.1: we use an existing index entry if any
+ // Step 4.1: we use an existing index entry if any
IntentIndexEntry candidateSectionEntry = null;
- if (chapterEntry.getSubEntries().size() > subSectionIt) {
- candidateSectionEntry = chapterEntry.getSubEntries().get(subSectionIt);
+ for (IntentIndexEntry candidate : chapterEntry.getSubEntries()) {
+ if (((IntentStructuredElement)candidate.getReferencedElement()).getCompleteLevel().equals(
+ section.getCompleteLevel())) {
+ candidateSectionEntry = candidate;
+ }
}
- // Step 5.2: and compute the entry for this section
+
+ // Step 4.2: and compute the entry for this section
computeEntryForSection(chapterEntry, candidateSectionEntry, section);
- subSectionIt++;
}
return chapterEntry;
}
@@ -165,60 +162,32 @@
}
// Step 2: compute the title
- String sectionIndex = ((IntentStructuredElement)containerIndexEntry.getReferencedElement())
- .getCompleteLevel() + "." + getIndex(section);
String title = StructuredElementHelper.getTitle(section);
if ((title == null) || (title.length() < 1)) {
title = "Untitled Section";
}
// Step 3: setting index entry informations
- sectionEntry.setName(sectionIndex + " " + title);
+ sectionEntry.setName(section.getCompleteLevel() + " " + title);
sectionEntry.setReferencedElement(section);
sectionEntry.setType(INDEX_ENTRY_TYPE.INTENT_SECTION);
- // Step 4: update the level of this chapter
- if (!sectionIndex.equals(section.getCompleteLevel())) {
- section.setCompleteLevel(sectionIndex);
- }
-
- // Step 5: for each sub-section contained in this section
- int subSectionIt = 0;
+ // Step 4: for each sub-section contained in this section
for (IntentSection subSection : section.getSubSections()) {
- // Step 5.1: we use an existing index entry if any
+ // Step 4.1: we use an existing index entry if any
IntentIndexEntry candidateSubSectionEntry = null;
- if (sectionEntry.getSubEntries().size() > subSectionIt) {
- candidateSubSectionEntry = sectionEntry.getSubEntries().get(subSectionIt);
+
+ for (IntentIndexEntry candidate : sectionEntry.getSubEntries()) {
+ if (((IntentStructuredElement)candidate.getReferencedElement()).getCompleteLevel().equals(
+ subSection.getCompleteLevel())) {
+ candidateSubSectionEntry = candidate;
+ }
}
- // Step 5.2: and compute the entry for this sub-section
+
+ // Step 4.2: and compute the entry for this sub-section
computeEntryForSection(sectionEntry, candidateSubSectionEntry, subSection);
- subSectionIt++;
}
return sectionEntry;
}
- /**
- * Returns the index for this element, using its hierarchical level (for example "2.1.4").
- *
- * @param element
- * a structured element
- * @return the index of this element
- */
- private String getIndex(IntentStructuredElement element) {
- int positionInContainer = 0;
- // If the element is contained in a document
- if (element.eContainer() instanceof IntentDocument) {
- // We get its position in this document
- positionInContainer = element.eContainer().eContents().indexOf(element) + 1;
- } else {
- // If the element is contained in a SubSectionContainer (i.e. Section or Chapter)
- if (element.eContainer() instanceof IntentSubSectionContainer) {
- // we get its position in this container
- positionInContainer = ((IntentSubSectionContainer)element.eContainer()).getSubSections()
- .indexOf(element) + 1;
- }
- }
- return Integer.toString(positionInContainer);
- }
-
}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.linkresolver/META-INF/MANIFEST.MF b/plugins/org.eclipse.mylyn.docs.intent.client.linkresolver/META-INF/MANIFEST.MF
index ec14ad2..131aec8 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.linkresolver/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.linkresolver/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@
Bundle-Localization: plugin
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.mylyn.docs.intent.client.linkresolver
-Bundle-Version: 0.7.0.qualifier
+Bundle-Version: 0.8.0.qualifier
Bundle-Vendor: %providerName
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.mylyn.docs.intent.core;bundle-version="0.7.0",
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.linkresolver/pom.xml b/plugins/org.eclipse.mylyn.docs.intent.client.linkresolver/pom.xml
index d842bf0..deefccd 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.linkresolver/pom.xml
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.linkresolver/pom.xml
@@ -13,7 +13,7 @@
<parent>
<groupId>org.eclipse.mylyn.docs.intent-group</groupId>
<artifactId>intent-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.synchronizer/META-INF/MANIFEST.MF b/plugins/org.eclipse.mylyn.docs.intent.client.synchronizer/META-INF/MANIFEST.MF
index 4f10f0c..21c2c90 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.synchronizer/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.synchronizer/META-INF/MANIFEST.MF
@@ -3,17 +3,17 @@
Bundle-Localization: plugin
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.mylyn.docs.intent.client.synchronizer;singleton:=true
-Bundle-Version: 0.7.0.qualifier
+Bundle-Version: 0.8.0.qualifier
Bundle-Vendor: %providerName
Require-Bundle: org.eclipse.emf.common;bundle-version="2.6.0",
org.eclipse.emf.ecore;bundle-version="2.6.0",
org.eclipse.mylyn.docs.intent.core,
org.eclipse.mylyn.docs.intent.collab,
org.eclipse.mylyn.docs.intent.collab.common,
- org.eclipse.emf.compare.match;bundle-version="[1.2.0,2.0.0)",
org.eclipse.emf.edit.ui;bundle-version="2.6.0",
+ org.eclipse.emf.compare;bundle-version="2.0.0",
com.google.guava,
- org.eclipse.emf.compare.diff.edit;bundle-version="1.3.1"
+ org.eclipse.mylyn.docs.intent.compare;bundle-version="0.7.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.mylyn.docs.intent.client.synchronizer,
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.synchronizer/pom.xml b/plugins/org.eclipse.mylyn.docs.intent.client.synchronizer/pom.xml
index 73f1c5b..9a5fbc2 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.synchronizer/pom.xml
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.synchronizer/pom.xml
@@ -13,7 +13,7 @@
<parent>
<groupId>org.eclipse.mylyn.docs.intent-group</groupId>
<artifactId>intent-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.synchronizer/src/org/eclipse/mylyn/docs/intent/client/synchronizer/factory/SynchronizerMessageProvider.java b/plugins/org.eclipse.mylyn.docs.intent.client.synchronizer/src/org/eclipse/mylyn/docs/intent/client/synchronizer/factory/SynchronizerMessageProvider.java
index b40d58c..01df930 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.synchronizer/src/org/eclipse/mylyn/docs/intent/client/synchronizer/factory/SynchronizerMessageProvider.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.synchronizer/src/org/eclipse/mylyn/docs/intent/client/synchronizer/factory/SynchronizerMessageProvider.java
@@ -10,30 +10,25 @@
*******************************************************************************/
package org.eclipse.mylyn.docs.intent.client.synchronizer.factory;
-import org.eclipse.emf.compare.diff.metamodel.AttributeChange;
-import org.eclipse.emf.compare.diff.metamodel.DiffElement;
-import org.eclipse.emf.compare.diff.metamodel.DiffPackage;
-import org.eclipse.emf.compare.diff.metamodel.ModelElementChangeLeftTarget;
-import org.eclipse.emf.compare.diff.metamodel.ModelElementChangeRightTarget;
-import org.eclipse.emf.compare.diff.metamodel.ReferenceChange;
-import org.eclipse.emf.compare.diff.metamodel.UpdateAttribute;
-import org.eclipse.emf.compare.diff.metamodel.UpdateReference;
-import org.eclipse.emf.compare.diff.metamodel.impl.UpdateAttributeImpl;
-import org.eclipse.emf.compare.diff.metamodel.impl.UpdateReferenceImpl;
-import org.eclipse.emf.ecore.ENamedElement;
-import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.compare.AttributeChange;
+import org.eclipse.emf.compare.Diff;
+import org.eclipse.emf.compare.DifferenceKind;
+import org.eclipse.emf.compare.ReferenceChange;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.mylyn.docs.intent.core.modelingunit.ResourceDeclaration;
/**
- * Provide messages created from a given DiffElement.
+ * Provide messages created from a given Diff.
*
* @author <a href="mailto:alex.lagarde@obeo.fr">Alex Lagarde</a>
+ * @author <a href="mailto:william.piers@obeo.fr">William Piers</a>
*/
public final class SynchronizerMessageProvider {
- /**
- * Represents a whitespace in a status message.
- */
+ private static final String SYNC_MESSAGES_SEPARATOR = " : ";
+
+ private static final String SYNC_MESSAGES_BEGINNING = "The ";
+
private static final String SYNC_MESSAGES_WHITESPACE = " ";
private static final String SYNC_MESSAGES_INTERNAL_MODEL = "<b>Current Document</b>";
@@ -41,206 +36,160 @@
private static final String SYNC_MESSAGES_EXTERNAL_MODEL = "<b>Working Copy</b>";
/**
- * Represents the separation space between to status.
- */
- private static final String SYNC_STATUS_SEPARATOR = "<br/><hr/><br/>";
-
- /**
* SynchronizerMessageProvider constructor.
*/
private SynchronizerMessageProvider() {
-
}
/**
- * Create a message from the given {@link DiffElement}.
+ * Create a message from the given {@link Diff}.
*
- * @param diffElement
- * the {@link DiffElement} used to create the returned message
- * @return a message created from the given {@link DiffElement} element
+ * @param diff
+ * the {@link Diff} used to create the returned message
+ * @return a message created from the given {@link Diff} element
*/
- public static String createMessageFromDiffElement(DiffElement diffElement) {
+ public static String createMessageFromDiff(Diff diff) {
String returnedMessage = null;
- try {
- switch (diffElement.eClass().getClassifierID()) {
- case DiffPackage.ATTRIBUTE_CHANGE:
- returnedMessage = createMessageFromAttributeChange((AttributeChange)diffElement);
- break;
- case DiffPackage.REFERENCE_CHANGE:
- returnedMessage = createMessageFromReferenceChange((ReferenceChange)diffElement);
- break;
-
- case DiffPackage.UPDATE_ATTRIBUTE:
- returnedMessage = createMessageFromUpdateAttribute((UpdateAttribute)diffElement);
- break;
- case DiffPackage.UPDATE_REFERENCE:
- returnedMessage = createMessageFromUpdateReference((UpdateReference)diffElement);
- break;
-
- case DiffPackage.MODEL_ELEMENT_CHANGE_LEFT_TARGET:
- returnedMessage = createMessageFromModelElementChangeLeftTarget((ModelElementChangeLeftTarget)diffElement);
- break;
- case DiffPackage.MODEL_ELEMENT_CHANGE_RIGHT_TARGET:
- returnedMessage = createMessageFromModelElementChangeRightTarget((ModelElementChangeRightTarget)diffElement);
- break;
- case DiffPackage.REFERENCE_CHANGE_LEFT_TARGET:
- break;
- case DiffPackage.REFERENCE_CHANGE_RIGHT_TARGET:
- break;
- case DiffPackage.RESOURCE_DIFF:
- break;
- default:
- break;
-
+ if (diff instanceof ReferenceChange) {
+ ReferenceChange referenceChange = (ReferenceChange)diff;
+ if (referenceChange.getReference().isContainment()) {
+ returnedMessage = createMessageFromContainmentChange(referenceChange);
+ } else {
+ returnedMessage = createMessageFromReferenceChange(referenceChange);
}
- } catch (IllegalArgumentException e) {
- returnedMessage = null;
+ } else if (diff instanceof AttributeChange) {
+ returnedMessage = createMessageFromAttributeChange((AttributeChange)diff);
}
+
if (returnedMessage == null) {
- returnedMessage = SynchonizerEObjectNameGetter.computeObjectName(diffElement);
+ returnedMessage = diff.toString();
}
return returnedMessage;
}
/**
- * Create a message from the given AttributeChange element.
+ * Create a message from the given Difference element.
*
- * @param difference
- * the DiffElement used to create the returned message
- * @return a message created from the given AttributeChange element
- */
- public static String createMessageFromAttributeChange(AttributeChange difference) {
- return difference.toString();
- }
-
- /**
- * Create a message from the given ReferenceChange element.
- *
- * @param difference
- * the DiffElement used to create the returned message
+ * @param diff
+ * the Diff used to create the returned message
* @return a message created from the given ReferenceChange element
*/
- public static String createMessageFromReferenceChange(ReferenceChange difference) {
- return difference.toString();
- }
-
- /**
- * Create a message from the given UpdateAttribute element.
- *
- * @param difference
- * the DiffElement used to create the returned message
- * @return a message created from the given UpdateAttribute element
- */
- public static String createMessageFromUpdateAttribute(UpdateAttribute difference) {
- // We get the attribute
- EStructuralFeature attribute = ((UpdateAttributeImpl)difference).getAttribute();
- // <Attribute's class name> <attributename>
- String returnedMessage = attribute.eClass().getName() + SYNC_MESSAGES_WHITESPACE
- + attribute.getName();
- // If the container of this attribute has a name, 'in' <name of the instance containing this
- // attribute>
- if (difference.getLeftElement() instanceof ENamedElement) {
- String name = ((ENamedElement)difference.getLeftElement()).getName();
- if (name != null) {
- returnedMessage += " in " + name;
- }
+ private static String createMessageFromContainmentChange(ReferenceChange diff) {
+ String returnedMessage = SYNC_MESSAGES_BEGINNING + diff.getValue().eClass().getName()
+ + SYNC_MESSAGES_WHITESPACE + SynchonizerEObjectNameGetter.computeObjectName(diff.getValue());
+ switch (diff.getKind().getValue()) {
+ case DifferenceKind.ADD_VALUE:
+ returnedMessage += " is defined in the " + SYNC_MESSAGES_INTERNAL_MODEL
+ + " model<br/>but not in the " + SYNC_MESSAGES_EXTERNAL_MODEL + " model.";
+ break;
+ case DifferenceKind.DELETE_VALUE:
+ returnedMessage += " is defined in the " + SYNC_MESSAGES_EXTERNAL_MODEL
+ + " model<br/>but not in the " + SYNC_MESSAGES_INTERNAL_MODEL + " model.";
+ break;
+ default:
+ returnedMessage = createMessageFromReferenceChange(diff);
+ break;
}
- // Standard comparison message
- returnedMessage += createCompareValuesMessage(difference.getLeftElement().eGet(attribute), difference
- .getRightElement().eGet(attribute));
return returnedMessage;
}
/**
- * Create a message from the given UpdateAttribute element.
+ * Create a message from the given Difference element.
*
- * @param difference
- * the DiffElement used to create the returned message
- * @return a message created from the given UpdateAttribute element
+ * @param diff
+ * the Diff used to create the returned message
+ * @return a message created from the given ReferenceChange element
*/
- public static String createMessageFromUpdateReference(UpdateReference difference) {
- EStructuralFeature reference = ((UpdateReferenceImpl)difference).getReference();
- String returnedMessage = reference.eClass().getName() + SYNC_MESSAGES_WHITESPACE
- + reference.getName();
+ private static String createMessageFromReferenceChange(ReferenceChange diff) {
+ String valueSignature = diff.getValue().eClass().getName() + SYNC_MESSAGES_WHITESPACE
+ + SynchonizerEObjectNameGetter.computeObjectName(diff.getValue());
- if (difference.getLeftElement() instanceof ENamedElement) {
- String name = ((ENamedElement)difference.getLeftElement()).getName();
- if (name != null) {
- returnedMessage += " in " + name;
- }
+ String returnedMessage = null;
+ String signature = "reference '" + diff.getReference().getName() + "'";
+
+ switch (diff.getKind().getValue()) {
+ case DifferenceKind.ADD_VALUE:
+ returnedMessage = SYNC_MESSAGES_BEGINNING + valueSignature + " has been added to the "
+ + signature;
+ break;
+ case DifferenceKind.DELETE_VALUE:
+ returnedMessage = SYNC_MESSAGES_BEGINNING + valueSignature + " has been removed from the "
+ + signature;
+ break;
+ case DifferenceKind.MOVE_VALUE:
+ returnedMessage = "The order of the values of the " + signature + " has changed";
+ break;
+ case DifferenceKind.CHANGE_VALUE:
+ returnedMessage = SYNC_MESSAGES_BEGINNING + signature;
+ EObject element = diff.getMatch().getRight();
+
+ if (element != null) {
+
+ String elementLabel = SynchonizerEObjectNameGetter.computeObjectName(element);
+ if (elementLabel != null) {
+ returnedMessage += " in " + elementLabel;
+ }
+ returnedMessage += " has changed.<br/>";
+ returnedMessage += SYNC_MESSAGES_INTERNAL_MODEL
+ + SYNC_MESSAGES_SEPARATOR
+ + SynchonizerEObjectNameGetter.computeObjectName(diff.getValue())
+ + "<br/>"
+ + SYNC_MESSAGES_EXTERNAL_MODEL
+ + SYNC_MESSAGES_SEPARATOR
+ + SynchonizerEObjectNameGetter.computeObjectName((EObject)element.eGet(diff
+ .getReference()));
+
+ }
+ break;
+ default:
+ break;
}
- returnedMessage += createCompareValuesMessage(difference.getLeftElement().eGet(reference), difference
- .getRightElement().eGet(reference));
return returnedMessage;
}
/**
- * Create a message from the given ModelElementChangeLeftTarget element.
+ * Create a message from the given Difference element.
*
- * @param difference
- * the DiffElement used to create the returned message
- * @return a message created from the given ModelElementChangeLeftTarget element
+ * @param diff
+ * the Diff used to create the returned message
+ * @return a message created from the given ReferenceChange element
*/
- public static String createMessageFromModelElementChangeLeftTarget(ModelElementChangeLeftTarget difference) {
- String returnedMessage = "The " + difference.getLeftElement().eClass().getName();
- if (difference.getLeftElement() instanceof ENamedElement) {
- String name = ((ENamedElement)difference.getLeftElement()).getName();
- if (name != null) {
- returnedMessage += SYNC_MESSAGES_WHITESPACE + name;
- }
+ private static String createMessageFromAttributeChange(AttributeChange diff) {
+ String returnedMessage = null;
+ String signature = "attribute '" + diff.getAttribute().getName() + "'";
+
+ switch (diff.getKind().getValue()) {
+ case DifferenceKind.ADD_VALUE:
+ returnedMessage = SYNC_MESSAGES_BEGINNING + diff.getValue() + " has been added to "
+ + signature;
+ break;
+ case DifferenceKind.DELETE_VALUE:
+ returnedMessage = SYNC_MESSAGES_BEGINNING + diff.getValue() + " has been removed from "
+ + signature;
+ break;
+ case DifferenceKind.MOVE_VALUE:
+ returnedMessage = "The order of the values of " + signature + " has changed";
+ break;
+ case DifferenceKind.CHANGE_VALUE:
+ returnedMessage = SYNC_MESSAGES_BEGINNING + signature;
+ EObject element = diff.getMatch().getRight();
+ String elementLabel = SynchonizerEObjectNameGetter.computeObjectName(element);
+ if (elementLabel != null) {
+ returnedMessage += " in " + elementLabel;
+ }
+ returnedMessage += " has changed.<br/>";
+ returnedMessage += SYNC_MESSAGES_INTERNAL_MODEL + SYNC_MESSAGES_SEPARATOR + diff.getValue()
+ + "<br/>" + SYNC_MESSAGES_EXTERNAL_MODEL + SYNC_MESSAGES_SEPARATOR
+ + element.eGet(diff.getAttribute());
+ break;
+ default:
+ break;
}
- returnedMessage += " is defined in the " + SYNC_MESSAGES_INTERNAL_MODEL
- + " model<br/>but not in the " + SYNC_MESSAGES_EXTERNAL_MODEL + " model.";
return returnedMessage;
}
/**
- * Create a message from the given ModelElementChangeRightTarget element.
- *
- * @param difference
- * the DiffElement used to create the returned message
- * @return a message created from the given ModelElementChangeRightTarget element
- */
- public static String createMessageFromModelElementChangeRightTarget(
- ModelElementChangeRightTarget difference) {
- String returnedMessage = "The " + difference.getRightElement().eClass().getName();
- if (difference.getRightElement() instanceof ENamedElement) {
- String name = ((ENamedElement)difference.getRightElement()).getName();
- if (name != null) {
- returnedMessage += SYNC_MESSAGES_WHITESPACE + name;
- }
- }
- returnedMessage += " is defined in the " + SYNC_MESSAGES_EXTERNAL_MODEL
- + " model<br/>but not in the " + SYNC_MESSAGES_INTERNAL_MODEL + " model.";
- return returnedMessage;
- }
-
- /**
- * Create a standard comparison message between the given value from the repository and the given local
- * value.
- *
- * @param repositoryValue
- * the repositoryValue
- * @param localValue
- * the localValue
- * @return a standard comparison message between the two given values
- */
- private static String createCompareValuesMessage(Object repositoryValue, Object localValue) {
- return " has changed.<br/>" + SYNC_MESSAGES_INTERNAL_MODEL + " : " + repositoryValue + "<br/>"
- + SYNC_MESSAGES_EXTERNAL_MODEL + " : " + localValue;
- }
-
- /**
- * Returns a String representing the separation space between to status.
- *
- * @return a String representing the separation space between to status
- */
- public static String getStatusSeparator() {
- return SYNC_STATUS_SEPARATOR;
- }
-
- /**
* Creates an error message indicating that the given resourceDeclaration hasn't been found externally.
*
* @param resourceDeclaration
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 fdf7bf2..f333875 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
@@ -15,32 +15,19 @@
import java.util.Map.Entry;
import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.compare.diff.metamodel.AttributeChange;
-import org.eclipse.emf.compare.diff.metamodel.AttributeChangeLeftTarget;
-import org.eclipse.emf.compare.diff.metamodel.AttributeOrderChange;
-import org.eclipse.emf.compare.diff.metamodel.DiffElement;
-import org.eclipse.emf.compare.diff.metamodel.DiffPackage;
-import org.eclipse.emf.compare.diff.metamodel.ModelElementChange;
-import org.eclipse.emf.compare.diff.metamodel.ModelElementChangeLeftTarget;
-import org.eclipse.emf.compare.diff.metamodel.ModelElementChangeRightTarget;
-import org.eclipse.emf.compare.diff.metamodel.ReferenceChange;
-import org.eclipse.emf.compare.diff.metamodel.ReferenceChangeLeftTarget;
-import org.eclipse.emf.compare.diff.metamodel.ReferenceChangeRightTarget;
-import org.eclipse.emf.compare.diff.metamodel.ReferenceOrderChange;
-import org.eclipse.emf.compare.diff.metamodel.ResourceDiff;
-import org.eclipse.emf.compare.diff.metamodel.UpdateReference;
+import org.eclipse.emf.compare.AttributeChange;
+import org.eclipse.emf.compare.Diff;
+import org.eclipse.emf.compare.DifferenceKind;
+import org.eclipse.emf.compare.ReferenceChange;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.mylyn.docs.intent.collab.common.logger.IIntentLogger.LogType;
-import org.eclipse.mylyn.docs.intent.collab.common.logger.IntentLogger;
import org.eclipse.mylyn.docs.intent.core.compiler.AttributeChangeStatus;
import org.eclipse.mylyn.docs.intent.core.compiler.CompilationMessageType;
import org.eclipse.mylyn.docs.intent.core.compiler.CompilationStatus;
import org.eclipse.mylyn.docs.intent.core.compiler.CompilationStatusSeverity;
import org.eclipse.mylyn.docs.intent.core.compiler.CompilerFactory;
import org.eclipse.mylyn.docs.intent.core.compiler.InstructionTraceabilityEntry;
-import org.eclipse.mylyn.docs.intent.core.compiler.ModelElementChangeStatus;
import org.eclipse.mylyn.docs.intent.core.compiler.ReferenceChangeStatus;
import org.eclipse.mylyn.docs.intent.core.compiler.SynchronizerChangeState;
import org.eclipse.mylyn.docs.intent.core.compiler.SynchronizerCompilationStatus;
@@ -54,10 +41,11 @@
import org.eclipse.mylyn.docs.intent.core.modelingunit.ValueForStructuralFeature;
/**
- * This factory is in charge of creating {@link CompilationStatus} from different elements (
- * {@link DiffElement} of a DiffModel, error on a ResourceDeclaration...).
+ * This factory is in charge of creating {@link CompilationStatus} from different elements ( {@link Diff} of a
+ * Comparison, error on a ResourceDeclaration...).
*
* @author <a href="mailto:alex.lagarde@obeo.fr">Alex Lagarde</a>
+ * @author <a href="mailto:william.piers@obeo.fr">William Piers</a>
*/
public final class SynchronizerStatusFactory {
@@ -65,70 +53,42 @@
* SynchronizerStatusFactory constructor.
*/
private SynchronizerStatusFactory() {
-
}
/**
- * Create a list of compilationStatus from the given {@link DiffElement}.
+ * Create a list of compilationStatus from the given {@link Diff}.
*
* @param indexEntry
* the indexEntry currently visited
* @param difference
- * the {@link DiffElement} describing the differences between an element of the internal
- * generated model and the element of an external generated model
- * @return a list of compilationStatus created from the given {@link DiffElement}
+ * the {@link Diff} describing the differences between an element of the internal generated
+ * model and the element of an external generated model
+ * @return a list of compilationStatus created from the given {@link Diff}
*/
- public static List<CompilationStatus> createStatusFromDiffElement(TraceabilityIndexEntry indexEntry,
- DiffElement difference) {
-
+ public static List<CompilationStatus> createStatusFromDiff(TraceabilityIndexEntry indexEntry,
+ Diff difference) {
List<CompilationStatus> statusList = new ArrayList<CompilationStatus>();
- // If we have a unitary diffElement
- if (difference.getSubDiffElements().isEmpty()) {
- SynchronizerCompilationStatus status = null;
-
+ SynchronizerCompilationStatus status = null;
+ if (difference.getMatch().getLeft() != null) { // ignoring diffs related to non existing elements
if (difference instanceof AttributeChange) {
status = createStatusFromAttributeChange(indexEntry, (AttributeChange)difference);
} else if (difference instanceof ReferenceChange) {
status = createStatusFromReferenceChange(indexEntry, (ReferenceChange)difference);
- } else if (difference instanceof ModelElementChange) {
- status = createStatusFromModelElementChange(indexEntry, (ModelElementChange)difference);
- } else if (difference instanceof ResourceDiff) {
- status = CompilerFactory.eINSTANCE.createResourceChangeStatus();
}
if (status != null) {
- // reference order differences are ignored for now
- if (difference instanceof ReferenceOrderChange || difference instanceof AttributeOrderChange) {
+ if (difference.getKind().equals(DifferenceKind.MOVE)) {
status.setSeverity(CompilationStatusSeverity.INFO);
- status.setType(CompilationMessageType.SYNCHRONIZER_INFO);
} else {
status.setSeverity(CompilationStatusSeverity.WARNING);
- status.setType(CompilationMessageType.SYNCHRONIZER_WARNING);
}
-
- status.setMessage(SynchronizerMessageProvider.createMessageFromDiffElement(difference));
+ status.setType(CompilationMessageType.SYNCHRONIZER_WARNING);
+ status.setMessage(SynchronizerMessageProvider.createMessageFromDiff(difference));
status.setWorkingCopyResourceURI(indexEntry.getResourceDeclaration().getUri().toString());
status.setCompiledResourceURI(indexEntry.getGeneratedResourcePath());
- if (status.getTarget() == null) {
- // If no instruction has been found, we associated the status with the currently compiled
- // resource
- IntentLogger.getInstance().log(
- LogType.WARNING,
- "CANNOT FIND ANY INSTRUCTION FOR " + difference.eClass().getName() + ": "
- + difference);
- status.setTarget(indexEntry.getResourceDeclaration());
- }
statusList.add(status);
- } else {
- IntentLogger.getInstance().log(LogType.WARNING,
- "CANNOT HANDLE DIFFERENCE " + difference.eClass().getName() + ": " + difference);
- }
- } else {
- // If the given diffElement contains sub-diffElements
- for (DiffElement subDifference : difference.getSubDiffElements()) {
- statusList.addAll(createStatusFromDiffElement(indexEntry, subDifference));
}
}
return statusList;
@@ -143,101 +103,24 @@
* the difference
* @return the status
*/
- private static ModelElementChangeStatus createStatusFromModelElementChange(
- TraceabilityIndexEntry indexEntry, ModelElementChange difference) {
- ModelElementChangeStatus status = CompilerFactory.eINSTANCE.createModelElementChangeStatus();
-
- switch (difference.eClass().getClassifierID()) {
- case DiffPackage.MODEL_ELEMENT_CHANGE_LEFT_TARGET:
- status.setChangeState(SynchronizerChangeState.COMPILED_TARGET);
- ModelElementChangeLeftTarget letTargetDiff = (ModelElementChangeLeftTarget)difference;
- status.setCompiledElement(letTargetDiff.getLeftElement());
- status.setWorkingCopyParentURIFragment(createURIFragment(letTargetDiff.getRightParent()));
- status.setTarget(getInstructionFromCompiledElement(indexEntry, letTargetDiff.getLeftElement()));
- break;
-
- case DiffPackage.MODEL_ELEMENT_CHANGE_RIGHT_TARGET:
- status.setChangeState(SynchronizerChangeState.WORKING_COPY_TARGET);
- ModelElementChangeRightTarget rightTargetDiff = (ModelElementChangeRightTarget)difference;
- status.setWorkingCopyElementURIFragment(createURIFragment(rightTargetDiff.getRightElement()));
- status.setCompiledParent(rightTargetDiff.getLeftParent());
- status.setTarget(getInstructionFromCompiledElement(indexEntry,
- rightTargetDiff.getLeftParent()));
- break;
-
- case DiffPackage.UPDATE_MODEL_ELEMENT:
- status.setChangeState(SynchronizerChangeState.UPDATE);
- break;
-
- default:
- status = null;
- break;
- }
- return status;
- }
-
- /**
- * Creates the status related to the given difference.
- *
- * @param indexEntry
- * the current index entry
- * @param difference
- * the difference
- * @return the status
- */
private static ReferenceChangeStatus createStatusFromReferenceChange(TraceabilityIndexEntry indexEntry,
ReferenceChange difference) {
- EObject compiledElement = difference.getLeftElement();
+ EObject compiledElement = difference.getMatch().getLeft();
IntentGenericElement target = null;
ReferenceChangeStatus status = CompilerFactory.eINSTANCE.createReferenceChangeStatus();
status.setCompiledElement(compiledElement);
status.setFeatureName(difference.getReference().getName());
- status.setWorkingCopyElementURIFragment(createURIFragment(difference.getRightElement()));
+ status.setWorkingCopyElementURIFragment(createURIFragment(difference.getMatch().getRight()));
+ status.setChangeState(convertDifferenceKindToState(difference.getKind()));
- switch (difference.eClass().getClassifierID()) {
- case DiffPackage.REFERENCE_CHANGE_RIGHT_TARGET:
- status.setChangeState(SynchronizerChangeState.WORKING_COPY_TARGET);
- status.setCompiledTarget(((ReferenceChangeRightTarget)difference).getLeftTarget());
- status.setWorkingCopyTargetURIFragment(createURIFragment(((ReferenceChangeRightTarget)difference)
- .getRightTarget()));
- break;
+ target = getInstructionFromAffectation(indexEntry, compiledElement, difference.getReference(),
+ difference.getValue());
- case DiffPackage.REFERENCE_ORDER_CHANGE:
- status.setChangeState(SynchronizerChangeState.ORDER);
- break;
-
- case DiffPackage.REFERENCE_CHANGE_LEFT_TARGET:
- status.setChangeState(SynchronizerChangeState.COMPILED_TARGET);
- target = getInstructionFromAffectation(indexEntry, compiledElement,
- difference.getReference(), ((ReferenceChangeLeftTarget)difference).getLeftTarget());
- status.setCompiledTarget(((ReferenceChangeLeftTarget)difference).getLeftTarget());
- status.setWorkingCopyTargetURIFragment(createURIFragment(((ReferenceChangeLeftTarget)difference)
- .getRightTarget()));
- break;
-
- case DiffPackage.UPDATE_REFERENCE:
- UpdateReference updateDifference = (UpdateReference)difference;
- status.setChangeState(SynchronizerChangeState.UPDATE);
- target = getInstructionFromAffectation(indexEntry, compiledElement,
- difference.getReference(), difference.getLeftElement()
- .eGet(difference.getReference()));
-
- // Workaround EMF compare 1 issue :
- // Actual targets are in fact merging utilities and may not be relevant.
- EObject leftTarget = (EObject)updateDifference.getLeftElement().eGet(
- updateDifference.getReference());
- EObject rightTarget = (EObject)updateDifference.getRightElement().eGet(
- updateDifference.getReference());
-
- status.setCompiledTarget(leftTarget);
- if (rightTarget != null) {
- status.setWorkingCopyTargetURIFragment(createURIFragment(rightTarget));
- }
- break;
-
- default:
- status = null;
- break;
+ if (target instanceof NewObjectValueForStructuralFeature && !target.eContents().isEmpty()) {
+ EObject content = target.eContents().get(0);
+ if (content instanceof InstanciationInstruction) {
+ target = (InstanciationInstruction)content;
+ }
}
// target setting: if affectation not found (or not available), use the parent compiled element
@@ -249,6 +132,7 @@
}
status.setTarget(target);
}
+
return status;
}
@@ -263,38 +147,16 @@
*/
private static AttributeChangeStatus createStatusFromAttributeChange(TraceabilityIndexEntry indexEntry,
AttributeChange difference) {
- EObject compiledElement = difference.getLeftElement();
+ EObject compiledElement = difference.getMatch().getLeft();
IntentGenericElement target = null;
AttributeChangeStatus status = CompilerFactory.eINSTANCE.createAttributeChangeStatus();
status.setCompiledElement(compiledElement);
status.setFeatureName(difference.getAttribute().getName());
- status.setWorkingCopyElementURIFragment(createURIFragment(difference.getRightElement()));
+ status.setWorkingCopyElementURIFragment(createURIFragment(difference.getMatch().getRight()));
+ status.setChangeState(convertDifferenceKindToState(difference.getKind()));
- switch (difference.eClass().getClassifierID()) {
- case DiffPackage.ATTRIBUTE_CHANGE_RIGHT_TARGET:
- status.setChangeState(SynchronizerChangeState.WORKING_COPY_TARGET);
- break;
-
- case DiffPackage.ATTRIBUTE_ORDER_CHANGE:
- status.setChangeState(SynchronizerChangeState.ORDER);
- break;
-
- case DiffPackage.ATTRIBUTE_CHANGE_LEFT_TARGET:
- status.setChangeState(SynchronizerChangeState.COMPILED_TARGET);
- target = getInstructionFromAffectation(indexEntry, difference.getLeftElement(),
- difference.getAttribute(), ((AttributeChangeLeftTarget)difference).getLeftTarget());
- break;
-
- case DiffPackage.UPDATE_ATTRIBUTE:
- status.setChangeState(SynchronizerChangeState.UPDATE);
- target = getInstructionFromAffectation(indexEntry, compiledElement,
- difference.getAttribute(), compiledElement.eGet(difference.getAttribute()));
- break;
-
- default:
- status = null;
- break;
- }
+ target = getInstructionFromAffectation(indexEntry, compiledElement, difference.getAttribute(),
+ difference.getValue());
// target setting: if affectation not found (or not available), use the parent compiled element
if (status != null) {
@@ -433,6 +295,38 @@
}
/**
+ * Converts a difference kind to a state.
+ *
+ * @param differenceKind
+ * the difference kind
+ * @return the state
+ */
+ private static SynchronizerChangeState convertDifferenceKindToState(DifferenceKind differenceKind) {
+ SynchronizerChangeState state = null;
+ switch (differenceKind.getValue()) {
+ case DifferenceKind.ADD_VALUE:
+ state = SynchronizerChangeState.COMPILED_TARGET;
+ break;
+
+ case DifferenceKind.MOVE_VALUE:
+ state = SynchronizerChangeState.ORDER;
+ break;
+
+ case DifferenceKind.DELETE_VALUE:
+ state = SynchronizerChangeState.WORKING_COPY_TARGET;
+ break;
+
+ case DifferenceKind.CHANGE_VALUE:
+ state = SynchronizerChangeState.UPDATE;
+ break;
+
+ default:
+ break;
+ }
+ return state;
+ }
+
+ /**
* Creates a fragment if possible.
*
* @param eo
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 e431e87..6257ca2 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
@@ -16,7 +16,6 @@
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -26,12 +25,8 @@
import org.eclipse.emf.common.util.Monitor;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.common.util.WrappedException;
-import org.eclipse.emf.compare.diff.metamodel.DiffElement;
-import org.eclipse.emf.compare.diff.metamodel.DiffModel;
-import org.eclipse.emf.compare.diff.service.DiffService;
-import org.eclipse.emf.compare.match.MatchOptions;
-import org.eclipse.emf.compare.match.metamodel.MatchModel;
-import org.eclipse.emf.compare.match.service.MatchService;
+import org.eclipse.emf.compare.Comparison;
+import org.eclipse.emf.compare.Diff;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
@@ -44,6 +39,7 @@
import org.eclipse.mylyn.docs.intent.client.synchronizer.strategy.SynchronizerStrategy;
import org.eclipse.mylyn.docs.intent.collab.handlers.adapters.IntentCommand;
import org.eclipse.mylyn.docs.intent.collab.handlers.adapters.RepositoryAdapter;
+import org.eclipse.mylyn.docs.intent.compare.utils.EMFCompareUtils;
import org.eclipse.mylyn.docs.intent.core.compiler.CompilationMessageType;
import org.eclipse.mylyn.docs.intent.core.compiler.CompilationStatus;
import org.eclipse.mylyn.docs.intent.core.compiler.InstructionTraceabilityEntry;
@@ -323,13 +319,13 @@
Resource rightResource = synchronizerStrategy.getRightResource(internalResource,
externalResource);
- List<DiffElement> differences = null;
+ List<Diff> differences = null;
stopIfCanceled(progressMonitor);
differences = compareResource(leftResource, rightResource);
stopIfCanceled(progressMonitor);
- // Step 5 : creating status from the DiffElement
- statusList = createSynchronizerSatusListFromDiffModel(indexEntry, differences,
+ // Step 5 : creating status from the Diff
+ statusList = createSynchronizerSatusListFromComparison(indexEntry, differences,
progressMonitor);
// Step 6 : unloading the external resource
@@ -395,31 +391,30 @@
}
/**
- * Creates the synchronization statuses corresponding to the given list of {@link DiffElement}.
+ * Creates the synchronization statuses corresponding to the given list of {@link Diff}.
*
* @param indexEntry
* the indexEntry indicating the compared resources
* @param differences
- * the list of {@link DiffElement} between the compared resources
+ * the list of {@link Diff} between the compared resources
* @param progressMonitor
* the progress Monitor indicating if this synchronization operation has been canceled
- * @return a list containing the synchronization statuses corresponding to the given list of
- * {@link DiffElement}
+ * @return a list containing the synchronization statuses corresponding to the given list of {@link Diff}
* @throws InterruptedException
* if the operation has been canceled
*/
- private List<CompilationStatus> createSynchronizerSatusListFromDiffModel(
- TraceabilityIndexEntry indexEntry, List<DiffElement> differences, Monitor progressMonitor)
+ private List<CompilationStatus> createSynchronizerSatusListFromComparison(
+ TraceabilityIndexEntry indexEntry, List<Diff> differences, Monitor progressMonitor)
throws InterruptedException {
Map<IntentGenericElement, Collection<CompilationStatus>> elementToSyncStatus = Maps
.newLinkedHashMap();
List<CompilationStatus> statusList = new ArrayList<CompilationStatus>();
- for (DiffElement difference : differences) {
+ for (Diff difference : differences) {
stopIfCanceled(progressMonitor);
- // For each synchronization status relative to the consider diffElement
- for (CompilationStatus newStatus : SynchronizerStatusFactory.createStatusFromDiffElement(
- indexEntry, difference)) {
+ // For each synchronization status relative to the consider Diff
+ for (CompilationStatus newStatus : SynchronizerStatusFactory.createStatusFromDiff(indexEntry,
+ difference)) {
stopIfCanceled(progressMonitor);
if (elementToSyncStatus.get(newStatus.getTarget()) == null) {
@@ -489,27 +484,21 @@
* the <i>"left"</i> resource of the two resources to get compared.
* @param rightResource
* the <i>"right"</i> resource of the two resources to get compared.
- * @return a list of diffElement corresponding to all the differences between the left resources and the
- * right resource
+ * @return a list of Diff corresponding to all the differences between the left resources and the right
+ * resource
* @throws InterruptedException
* if the comparison is interrupted
*/
- private List<DiffElement> compareResource(Resource leftResource, Resource rightResource)
+ private List<Diff> compareResource(Resource leftResource, Resource rightResource)
throws InterruptedException {
-
try {
- // TODO : treat differently models and meta-models : this match isn't efficient on
- // simple meta-models instances
- final HashMap<String, Object> options = new HashMap<String, Object>();
- options.put(MatchOptions.OPTION_IGNORE_XMI_ID, Boolean.TRUE);
- MatchModel matchModel = MatchService.doResourceMatch(leftResource, rightResource, options);
- DiffModel diff = DiffService.doDiff(matchModel, false);
- return diff.getDifferences();
+ Comparison comparison = EMFCompareUtils.compare(leftResource, rightResource);
+ return comparison.getDifferences();
// CHECKSTYLE:OFF
} catch (Exception e) {
// CHECKSTYLE :ON
// TODO create a Status which has the left resource has target
- return new ArrayList<DiffElement>();
+ return new ArrayList<Diff>();
}
}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.ui.cdo/META-INF/MANIFEST.MF b/plugins/org.eclipse.mylyn.docs.intent.client.ui.cdo/META-INF/MANIFEST.MF
index 9e9b96e..cfc2419 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.ui.cdo/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.ui.cdo/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@
Bundle-Localization: plugin
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.mylyn.docs.intent.client.ui.cdo;singleton:=true
-Bundle-Version: 0.7.0.qualifier
+Bundle-Version: 0.8.0.qualifier
Bundle-Vendor: %providerName
Bundle-Activator: org.eclipse.mylyn.docs.intent.client.ui.cdo.Activator
Require-Bundle: org.eclipse.ui,
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.ui.cdo/pom.xml b/plugins/org.eclipse.mylyn.docs.intent.client.ui.cdo/pom.xml
index e849ce7..2af4847 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.ui.cdo/pom.xml
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.ui.cdo/pom.xml
@@ -13,7 +13,7 @@
<parent>
<groupId>org.eclipse.mylyn.docs.intent-group</groupId>
<artifactId>intent-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.ui.ide/META-INF/MANIFEST.MF b/plugins/org.eclipse.mylyn.docs.intent.client.ui.ide/META-INF/MANIFEST.MF
index 9de96ae..2f6a5ed 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.ui.ide/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.ui.ide/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@
Bundle-Localization: plugin
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.mylyn.docs.intent.client.ui.ide;singleton:=true
-Bundle-Version: 0.7.0.qualifier
+Bundle-Version: 0.8.0.qualifier
Bundle-Vendor: %providerName
Bundle-Activator: org.eclipse.mylyn.docs.intent.client.ui.ide.Activator
Require-Bundle: org.eclipse.ui;visibility:=reexport,
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.ui.ide/pom.xml b/plugins/org.eclipse.mylyn.docs.intent.client.ui.ide/pom.xml
index 52ce930..43ba598 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.ui.ide/pom.xml
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.ui.ide/pom.xml
@@ -13,7 +13,7 @@
<parent>
<groupId>org.eclipse.mylyn.docs.intent-group</groupId>
<artifactId>intent-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.ui.ide/src/org/eclipse/mylyn/docs/intent/client/ui/ide/Activator.java b/plugins/org.eclipse.mylyn.docs.intent.client.ui.ide/src/org/eclipse/mylyn/docs/intent/client/ui/ide/Activator.java
index 5c27097..6e9623e 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.ui.ide/src/org/eclipse/mylyn/docs/intent/client/ui/ide/Activator.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.ui.ide/src/org/eclipse/mylyn/docs/intent/client/ui/ide/Activator.java
@@ -69,6 +69,7 @@
return Status.OK_STATUS;
}
};
+ activateListenerJob.setPriority(Job.DECORATE);
activateListenerJob.schedule();
}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.ui.ide/src/org/eclipse/mylyn/docs/intent/client/ui/ide/navigator/ProjectExplorerRefresher.java b/plugins/org.eclipse.mylyn.docs.intent.client.ui.ide/src/org/eclipse/mylyn/docs/intent/client/ui/ide/navigator/ProjectExplorerRefresher.java
index 9500d4a..9069a15 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.ui.ide/src/org/eclipse/mylyn/docs/intent/client/ui/ide/navigator/ProjectExplorerRefresher.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.ui.ide/src/org/eclipse/mylyn/docs/intent/client/ui/ide/navigator/ProjectExplorerRefresher.java
@@ -112,8 +112,8 @@
@Override
protected Job createNotificationJob(RepositoryChangeNotification notification) {
Job res = null;
- if (notification != null && notification.getRightRoots().isEmpty()) {
- res = new ProjectExplorerRefreshJob(project, notification.getRightRoots().iterator().next());
+ if (notification != null && notification.getImpactedElements().isEmpty()) {
+ res = new ProjectExplorerRefreshJob(project, notification.getImpactedElements().iterator().next());
} else {
res = new ProjectExplorerRefreshJob(project, null);
}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.ui.ide/src/org/eclipse/mylyn/docs/intent/client/ui/ide/projectmanager/IntentProjectManager.java b/plugins/org.eclipse.mylyn.docs.intent.client.ui.ide/src/org/eclipse/mylyn/docs/intent/client/ui/ide/projectmanager/IntentProjectManager.java
index 70c42a2..4543326 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.ui.ide/src/org/eclipse/mylyn/docs/intent/client/ui/ide/projectmanager/IntentProjectManager.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.ui.ide/src/org/eclipse/mylyn/docs/intent/client/ui/ide/projectmanager/IntentProjectManager.java
@@ -98,7 +98,6 @@
IntentLogger.getInstance().log(LogType.LIFECYCLE,
"[IntentProjectManager] Connecting to project " + project.getName());
if (project.isAccessible() && project.getNature(IntentNature.NATURE_ID) != null) {
- repository.getOrCreateSession();
// Clients creation (if needed)
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.mylyn.docs.intent.client.ui/META-INF/MANIFEST.MF
index 15aa97f..a61f2b0 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.ui/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@
Bundle-Localization: plugin
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.mylyn.docs.intent.client.ui;singleton:=true
-Bundle-Version: 0.7.0.qualifier
+Bundle-Version: 0.8.0.qualifier
Bundle-Vendor: %providerName
Bundle-Activator: org.eclipse.mylyn.docs.intent.client.ui.IntentEditorActivator
Require-Bundle: org.eclipse.mylyn.docs.intent.core,
@@ -19,12 +19,12 @@
org.eclipse.ui.views,
org.eclipse.ui.workbench.texteditor,
org.eclipse.jface.text,
- org.eclipse.emf.compare.ui;bundle-version="[1.2.0,2.0.0)",
- org.eclipse.emf.compare.match;bundle-version="[1.2.0,2.0.0)",
org.eclipse.core.expressions;bundle-version="3.4.300",
com.google.guava,
org.eclipse.compare,
- org.eclipse.mylyn.docs.intent.modelingunit.update;bundle-version="0.7.0"
+ org.eclipse.mylyn.docs.intent.modelingunit.update;bundle-version="0.7.0",
+ org.eclipse.emf.compare;bundle-version="2.0.0",
+ org.eclipse.emf.compare.ide.ui;bundle-version="2.0.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Export-Package: org.eclipse.mylyn.docs.intent.client.ui,
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.ui/pom.xml b/plugins/org.eclipse.mylyn.docs.intent.client.ui/pom.xml
index f2cc1b0..1e26d50 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.ui/pom.xml
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.ui/pom.xml
@@ -13,7 +13,7 @@
<parent>
<groupId>org.eclipse.mylyn.docs.intent-group</groupId>
<artifactId>intent-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/editor/IntentDocumentProvider.java b/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/editor/IntentDocumentProvider.java
index 80bdee4..5af2352 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/editor/IntentDocumentProvider.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/editor/IntentDocumentProvider.java
@@ -345,7 +345,12 @@
hasSyntaxErrors = false;
this.removeSyntaxErrors();
- localAST = new IntentParser().parse(document.get());
+ String rootCompleteLevel = null;
+ if (documentRoot instanceof IntentStructuredElement) {
+ rootCompleteLevel = ((IntentStructuredElement)documentRoot).getCompleteLevel();
+ }
+
+ localAST = new IntentParser().parse(document.get(), rootCompleteLevel);
this.associatedEditor.refreshTitle(localAST);
final RepositoryAdapter repositoryAdapter = this.listenedElementsHandler
@@ -463,7 +468,7 @@
}
// For each object modified indicated by this notification
- for (EObject modifiedObject : notification.getRightRoots()) {
+ for (EObject modifiedObject : notification.getImpactedElements()) {
Object modifiedObjectIdentifier = listenedElementsHandler.getRepositoryAdapter()
.getIDFromElement(modifiedObject);
@@ -652,7 +657,7 @@
* @return true if a root has been deleted
*/
private boolean handleRootHasBeenDeleted(RepositoryChangeNotification notification) {
- if (notification.getRightRoots().size() < 1) {
+ if (notification.getImpactedElements().size() < 1) {
Object modifiedObjectIdentifier = listenedElementsHandler.getRepositoryAdapter()
.getIDFromElement(documentRoot);
if (elementsToDocuments.get(modifiedObjectIdentifier) != null) {
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/editor/annotation/IntentAnnotationModelManager.java b/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/editor/annotation/IntentAnnotationModelManager.java
index 178190c..41c76bc 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/editor/annotation/IntentAnnotationModelManager.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/editor/annotation/IntentAnnotationModelManager.java
@@ -62,27 +62,6 @@
public void addAnnotationFromStatus(RepositoryAdapter repositoryAdapter, CompilationStatus status,
Position position) {
if (!(handledCompilationStatus.containsKey(status))) {
- // If the status is a Synchronization Status
- // URI uri = null;
- // if (status instanceof SynchronizerCompilationStatus
- // && ((SynchronizerCompilationStatus)status).getCompiledResourceURI() != null
- // && ((SynchronizerCompilationStatus)status).getCompiledResourceURI().length() > 0) {
- // // We use the repository Adapter to get the Resource containing
- // // the target of the synchronization error
- // String compiledResourceURI = ((SynchronizerCompilationStatus)status).getCompiledResourceURI();
- // Resource resource = null;
- // try {
- // resource = repositoryAdapter.getResource(compiledResourceURI);
- // if (resource != null) {
- // uri = resource.getURI();
- // }
- // // CHECKSTYLE:OFF
- // } catch (Exception e) {
- // // CHECKSTYLE:ON
- // // Silent catch
- // }
- // }
-
// We create an annotation from the status and add it to the annotation model
Annotation annotation = IntentAnnotationFactory.createAnnotationFromCompilationStatus(status);
addAnnotation(annotation, position);
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/editor/quickfix/EMFCompareFix.java b/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/editor/quickfix/EMFCompareFix.java
index 8e36553..4ab0800 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/editor/quickfix/EMFCompareFix.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/editor/quickfix/EMFCompareFix.java
@@ -11,47 +11,32 @@
*******************************************************************************/
package org.eclipse.mylyn.docs.intent.client.ui.editor.quickfix;
-import java.util.Collection;
-import java.util.HashMap;
+import java.lang.reflect.InvocationTargetException;
import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.CompareEditorInput;
import org.eclipse.compare.CompareUI;
-import org.eclipse.compare.internal.Utilities;
-import org.eclipse.core.commands.Command;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.commands.NotEnabledException;
-import org.eclipse.core.commands.NotHandledException;
-import org.eclipse.core.commands.ParameterizedCommand;
-import org.eclipse.core.commands.common.NotDefinedException;
-import org.eclipse.core.expressions.Expression;
-import org.eclipse.core.expressions.IEvaluationContext;
-import org.eclipse.core.runtime.ListenerList;
+import org.eclipse.compare.structuremergeviewer.IDiffElement;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.compare.diff.metamodel.ComparisonResourceSnapshot;
-import org.eclipse.emf.compare.diff.metamodel.ComparisonSnapshot;
-import org.eclipse.emf.compare.diff.metamodel.DiffFactory;
-import org.eclipse.emf.compare.diff.metamodel.DiffModel;
-import org.eclipse.emf.compare.diff.service.DiffService;
-import org.eclipse.emf.compare.match.MatchOptions;
-import org.eclipse.emf.compare.match.metamodel.MatchModel;
-import org.eclipse.emf.compare.match.service.MatchService;
-import org.eclipse.emf.compare.ui.editor.ModelCompareEditorInput;
+import org.eclipse.emf.compare.Comparison;
+import org.eclipse.emf.compare.Match;
+import org.eclipse.emf.compare.ide.ui.internal.EMFCompareConstants;
+import org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.EMFCompareStructureMergeViewer;
+import org.eclipse.emf.compare.ide.ui.internal.util.EMFCompareEditingDomain;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.viewers.Viewer;
import org.eclipse.mylyn.docs.intent.client.ui.editor.IntentEditorDocument;
import org.eclipse.mylyn.docs.intent.collab.handlers.adapters.RepositoryAdapter;
+import org.eclipse.mylyn.docs.intent.compare.utils.EMFCompareUtils;
+import org.eclipse.mylyn.docs.intent.core.compiler.CompilationStatus;
+import org.eclipse.mylyn.docs.intent.core.compiler.StructuralFeatureChangeStatus;
import org.eclipse.mylyn.docs.intent.core.compiler.SynchronizerCompilationStatus;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.ui.ISourceProvider;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.handlers.IHandlerActivation;
-import org.eclipse.ui.handlers.IHandlerService;
-import org.eclipse.ui.services.IServiceLocator;
+import org.eclipse.swt.widgets.Composite;
/**
* Proposal used to fix a Synchronization issue by opening the compare Editor.
@@ -62,6 +47,9 @@
private static final String COMPARE_EDITOR_TITLE = "Comparing Intent Document and Working Copy";
+ private ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory(
+ ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
+
/**
* Default constructor.
*
@@ -80,41 +68,27 @@
*/
@Override
protected void applyFix(RepositoryAdapter repositoryAdapter, IntentEditorDocument document) {
- // Step 1 : getting the resources to compare URI
String workingCopyResourceURI = ((SynchronizerCompilationStatus)syncAnnotation.getCompilationStatus())
.getWorkingCopyResourceURI().replace("\"", "");
String generatedResourceURI = ((SynchronizerCompilationStatus)syncAnnotation.getCompilationStatus())
.getCompiledResourceURI().replace("\"", "");
- // Step 2 : loading the resources
+ // launch comparison
Resource generatedResource = repositoryAdapter.getResource(generatedResourceURI);
ResourceSetImpl rs = new ResourceSetImpl();
Resource workingCopyResource = rs.getResource(URI.createURI(workingCopyResourceURI), true);
+ final Comparison comparison = EMFCompareUtils.compare(generatedResource, workingCopyResource);
- // Step 3 : opening a new Compare Editor on these two resources
- try {
- // Step 3.1 : making match and diff
- final HashMap<String, Object> options = new HashMap<String, Object>();
- options.put(MatchOptions.OPTION_IGNORE_XMI_ID, Boolean.TRUE);
- MatchModel match = MatchService.doResourceMatch(generatedResource, workingCopyResource, options);
- DiffModel diff = DiffService.doDiff(match, false);
-
- // Step 3.2 : creating a comparaison snapshot from this diff
- ComparisonResourceSnapshot snapshot = DiffFactory.eINSTANCE.createComparisonResourceSnapshot();
- snapshot.setDiff(diff);
- snapshot.setMatch(match);
-
- // Step 3.3 : open a compare dialog
- final CompareConfiguration compareConfig = new IntentCompareConfiguration(generatedResource,
- workingCopyResource);
- ModelCompareEditorInput input = new IntentCompareEditorInput(snapshot, compareConfig);
- compareConfig.setContainer(input);
- input.setTitle(COMPARE_EDITOR_TITLE + " (" + workingCopyResourceURI + ")");
- CompareUI.openCompareDialog(input);
-
- } catch (InterruptedException e) {
- // Editor will not be opened
- }
+ // prepare configuration & open dialog
+ final CompareConfiguration compareConfig = new IntentCompareConfiguration(generatedResource,
+ workingCopyResource);
+ compareConfig.setProperty(EMFCompareConstants.COMPARE_RESULT, comparison);
+ compareConfig.setProperty(EMFCompareConstants.EDITING_DOMAIN, new EMFCompareEditingDomain(comparison,
+ generatedResource, workingCopyResource, null));
+ CompareEditorInput input = new IntentCompareEditorInput(compareConfig, comparison);
+ compareConfig.setContainer(input);
+ input.setTitle(COMPARE_EDITOR_TITLE + " (" + workingCopyResourceURI + ")");
+ CompareUI.openCompareDialog(input);
}
/**
@@ -127,319 +101,53 @@
}
/**
- * A custom CompareEditorInput for Intent.
- *
- * @author alagarde
+ * A custom implementation of the editor input.
*/
- private class IntentCompareEditorInput extends ModelCompareEditorInput {
-
- private CompareConfiguration compareConfig;
-
- private ListenerList listenerList = new ListenerList();
-
- private boolean isDirty;
+ class IntentCompareEditorInput extends CompareEditorInput {
+ private Object selection;
/**
- * This constructor takes a {@link ComparisonSnapshot} as input.
+ * Constructor.
*
- * @param snapshot
- * The ComparisonSnapshot loaded from an emfdiff.
- * @param compareConfig
- * the compare config
+ * @param configuration
+ * the compare configuration
+ * @param comparison
+ * the comparison
*/
- public IntentCompareEditorInput(ComparisonSnapshot snapshot, CompareConfiguration compareConfig) {
- super(snapshot);
- this.compareConfig = compareConfig;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.compare.CompareEditorInput#getCompareConfiguration()
- */
- @Override
- public CompareConfiguration getCompareConfiguration() {
- return compareConfig;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.compare.CompareEditorInput#getWorkbenchPart()
- */
- @Override
- public IWorkbenchPart getWorkbenchPart() {
- return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.compare.CompareEditorInput#getServiceLocator()
- */
- @Override
- public IServiceLocator getServiceLocator() {
- return new IServiceLocator() {
-
- public boolean hasService(Class api) {
- if (api.equals(IHandlerService.class)) {
- return true;
- }
- return false;
+ public IntentCompareEditorInput(CompareConfiguration configuration, Comparison comparison) {
+ super(configuration);
+ this.selection = comparison;
+ CompilationStatus status = syncAnnotation.getCompilationStatus();
+ if (status instanceof StructuralFeatureChangeStatus) {
+ EObject element = ((StructuralFeatureChangeStatus)status).getCompiledElement();
+ Match match = comparison.getMatch(element);
+ if (match != null && !match.getDifferences().isEmpty()) {
+ // TODO improve, find a way to accurately rely status original difference with comparison
+ // (use message ?)
+ this.selection = match.getDifferences().get(0);
}
-
- public Object getService(Class api) {
- if (api.equals(IHandlerService.class)) {
- return new IntentCompareHandlerService();
- }
- return null;
- }
- };
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.compare.CompareEditorInput#addPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener)
- */
- @Override
- public void addPropertyChangeListener(IPropertyChangeListener listener) {
- if (listener != null) {
- listenerList.add(listener);
}
- super.addPropertyChangeListener(listener);
}
/**
* {@inheritDoc}
*
- * @see org.eclipse.compare.CompareEditorInput#removePropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener)
+ * @see org.eclipse.compare.CompareEditorInput#prepareInput(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- public void removePropertyChangeListener(IPropertyChangeListener listener) {
- if (listenerList != null) {
- listenerList.remove(listener);
- }
- super.removePropertyChangeListener(listener);
+ protected Object prepareInput(IProgressMonitor monitor) throws InvocationTargetException,
+ InterruptedException {
+ return (IDiffElement)adapterFactory.adapt(this.selection, IDiffElement.class);
}
/**
* {@inheritDoc}
*
- * @see org.eclipse.compare.CompareEditorInput#setDirty(boolean)
+ * @see org.eclipse.compare.CompareEditorInput#createDiffViewer(org.eclipse.swt.widgets.Composite)
*/
@Override
- public void setDirty(boolean dirty) {
- boolean oldDirty = isDirty;
- isDirty = dirty;
- if (oldDirty != isDirty) {
- Utilities.firePropertyChange(listenerList, this, DIRTY_STATE, Boolean.valueOf(oldDirty),
- Boolean.valueOf(isSaveNeeded()));
- }
-
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.compare.CompareEditorInput#isDirty()
- */
- @Override
- public boolean isDirty() {
- return this.isDirty;
- }
-
+ public Viewer createDiffViewer(Composite parent) {
+ return new EMFCompareStructureMergeViewer(parent, getCompareConfiguration());
+ };
}
-
- /**
- * A IHandlerService for Intent.
- *
- * @author alagarde
- */
- private class IntentCompareHandlerService implements IHandlerService {
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.ui.services.IDisposable#dispose()
- */
- public void dispose() {
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.ui.services.IServiceWithSources#removeSourceProvider(org.eclipse.ui.ISourceProvider)
- */
- public void removeSourceProvider(ISourceProvider provider) {
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.ui.services.IServiceWithSources#addSourceProvider(org.eclipse.ui.ISourceProvider)
- */
- public void addSourceProvider(ISourceProvider provider) {
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.ui.handlers.IHandlerService#setHelpContextId(org.eclipse.core.commands.IHandler,
- * java.lang.String)
- */
- public void setHelpContextId(IHandler handler, String helpContextId) {
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.ui.handlers.IHandlerService#readRegistry()
- */
- public void readRegistry() {
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.ui.handlers.IHandlerService#getCurrentState()
- */
- public IEvaluationContext getCurrentState() {
- return null;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.ui.handlers.IHandlerService#executeCommandInContext(org.eclipse.core.commands.ParameterizedCommand,
- * org.eclipse.swt.widgets.Event, org.eclipse.core.expressions.IEvaluationContext)
- */
- // CHECKSTYLE:OFF
- public Object executeCommandInContext(ParameterizedCommand command, Event event,
- IEvaluationContext context) throws ExecutionException, NotDefinedException,
- NotEnabledException, NotHandledException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.ui.handlers.IHandlerService#executeCommand(org.eclipse.core.commands.ParameterizedCommand,
- * org.eclipse.swt.widgets.Event)
- */
- public Object executeCommand(ParameterizedCommand command, Event event) throws ExecutionException,
- NotDefinedException, NotEnabledException, NotHandledException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.ui.handlers.IHandlerService#executeCommand(java.lang.String,
- * org.eclipse.swt.widgets.Event)
- */
- public Object executeCommand(String commandId, Event event) throws ExecutionException,
- NotDefinedException, NotEnabledException, NotHandledException {
- return null;
- }
-
- // CHECKSTYLE:ON
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.ui.handlers.IHandlerService#deactivateHandlers(java.util.Collection)
- */
- public void deactivateHandlers(Collection activations) {
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.ui.handlers.IHandlerService#deactivateHandler(org.eclipse.ui.handlers.IHandlerActivation)
- */
- public void deactivateHandler(IHandlerActivation activation) {
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.ui.handlers.IHandlerService#createExecutionEvent(org.eclipse.core.commands.ParameterizedCommand,
- * org.eclipse.swt.widgets.Event)
- */
- public ExecutionEvent createExecutionEvent(ParameterizedCommand command, Event event) {
- return null;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.ui.handlers.IHandlerService#createExecutionEvent(org.eclipse.core.commands.Command,
- * org.eclipse.swt.widgets.Event)
- */
- public ExecutionEvent createExecutionEvent(Command command, Event event) {
- return null;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.ui.handlers.IHandlerService#createContextSnapshot(boolean)
- */
- public IEvaluationContext createContextSnapshot(boolean includeSelection) {
- return null;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.ui.handlers.IHandlerService#activateHandler(java.lang.String,
- * org.eclipse.core.commands.IHandler, org.eclipse.core.expressions.Expression, int)
- */
- public IHandlerActivation activateHandler(String commandId, IHandler handler, Expression expression,
- int sourcePriorities) {
- return null;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.ui.handlers.IHandlerService#activateHandler(java.lang.String,
- * org.eclipse.core.commands.IHandler, org.eclipse.core.expressions.Expression, boolean)
- */
- public IHandlerActivation activateHandler(String commandId, IHandler handler, Expression expression,
- boolean global) {
- return null;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.ui.handlers.IHandlerService#activateHandler(java.lang.String,
- * org.eclipse.core.commands.IHandler, org.eclipse.core.expressions.Expression)
- */
- public IHandlerActivation activateHandler(String commandId, IHandler handler, Expression expression) {
- return null;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.ui.handlers.IHandlerService#activateHandler(java.lang.String,
- * org.eclipse.core.commands.IHandler)
- */
- public IHandlerActivation activateHandler(String commandId, IHandler handler) {
- return null;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.ui.handlers.IHandlerService#activateHandler(org.eclipse.ui.handlers.IHandlerActivation)
- */
- public IHandlerActivation activateHandler(IHandlerActivation activation) {
- return null;
- }
-
- }
-
}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.collab.cdo/META-INF/MANIFEST.MF b/plugins/org.eclipse.mylyn.docs.intent.collab.cdo/META-INF/MANIFEST.MF
index 319c709..eb7c008 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.collab.cdo/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.mylyn.docs.intent.collab.cdo/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@
Bundle-Localization: plugin
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.mylyn.docs.intent.collab.cdo;singleton:=true
-Bundle-Version: 0.7.0.qualifier
+Bundle-Version: 0.8.0.qualifier
Bundle-Activator: org.eclipse.mylyn.docs.intent.collab.cdo.Activator
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.emf.cdo;bundle-version="3.0.0";visibility:=reexport,
diff --git a/plugins/org.eclipse.mylyn.docs.intent.collab.cdo/pom.xml b/plugins/org.eclipse.mylyn.docs.intent.collab.cdo/pom.xml
index e9fdad5..54fa1fe 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.collab.cdo/pom.xml
+++ b/plugins/org.eclipse.mylyn.docs.intent.collab.cdo/pom.xml
@@ -13,7 +13,7 @@
<parent>
<groupId>org.eclipse.mylyn.docs.intent-group</groupId>
<artifactId>intent-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
diff --git a/plugins/org.eclipse.mylyn.docs.intent.collab.cdo/src/org/eclipse/mylyn/docs/intent/collab/cdo/notification/CDORepositoryChangeNotificationFactory.java b/plugins/org.eclipse.mylyn.docs.intent.collab.cdo/src/org/eclipse/mylyn/docs/intent/collab/cdo/notification/CDORepositoryChangeNotificationFactory.java
index 8002433..f996ca3 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.collab.cdo/src/org/eclipse/mylyn/docs/intent/collab/cdo/notification/CDORepositoryChangeNotificationFactory.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.collab.cdo/src/org/eclipse/mylyn/docs/intent/collab/cdo/notification/CDORepositoryChangeNotificationFactory.java
@@ -67,7 +67,7 @@
// notification.getNewValue();
RepositoryChangeNotification newNotification = new RepositoryChangeNotificationImpl();
- newNotification.getRightRoots().add(target);
+ newNotification.getImpactedElements().add(target);
return newNotification;
}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.collab.cdo/src/org/eclipse/mylyn/docs/intent/collab/cdo/repository/CDORepository.java b/plugins/org.eclipse.mylyn.docs.intent.collab.cdo/src/org/eclipse/mylyn/docs/intent/collab/cdo/repository/CDORepository.java
index ae678b2..73fba0e 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.collab.cdo/src/org/eclipse/mylyn/docs/intent/collab/cdo/repository/CDORepository.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.collab.cdo/src/org/eclipse/mylyn/docs/intent/collab/cdo/repository/CDORepository.java
@@ -14,8 +14,9 @@
import java.util.Set;
import org.eclipse.emf.cdo.net4j.CDONet4jSession;
-import org.eclipse.emf.cdo.net4j.CDONet4jSessionConfiguration;
import org.eclipse.emf.cdo.net4j.CDONet4jUtil;
+import org.eclipse.emf.cdo.net4j.CDOSession;
+import org.eclipse.emf.cdo.net4j.CDOSessionConfiguration;
import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.ecore.EPackage.Registry;
import org.eclipse.mylyn.docs.intent.collab.cdo.adapters.CDOAdapter;
@@ -56,12 +57,12 @@
/**
* SessionConfiguration for the CDO repository (concrete notion).
*/
- private static CDONet4jSessionConfiguration cdoSessionConfiguration;
+ private static CDOSessionConfiguration cdoSessionConfiguration;
/**
* Current session connected to the repository.
*/
- private static CDONet4jSession session;
+ private static CDOSession session;
/**
* List of the active repositories (while not empty, we can't close the session).
@@ -133,7 +134,7 @@
connector = TCPUtil.getConnector(container, repositoryConfiguration.getServerAdress());
// Create configuration
- cdoSessionConfiguration = CDONet4jUtil.createNet4jSessionConfiguration();
+ cdoSessionConfiguration = CDONet4jUtil.createSessionConfiguration();
cdoSessionConfiguration.setConnector(connector);
cdoSessionConfiguration.setRepositoryName(repositoryConfiguration.getRepositoryName());
@@ -143,7 +144,7 @@
if ((session == null) || session.isClosed()) {
// Open session
try {
- session = cdoSessionConfiguration.openNet4jSession();
+ session = cdoSessionConfiguration.openSession();
} catch (TimeoutRuntimeException tre) {
throw new RepositoryConnectionException(tre.getMessage());
} catch (ChannelException ce) {
@@ -201,7 +202,7 @@
* @see org.eclipse.mylyn.docs.intent.collab.repository.Repository#getPackageRegistry()
*/
public Registry getPackageRegistry() throws RepositoryConnectionException {
- return ((CDONet4jSession)getOrCreateSession()).getPackageRegistry();
+ return ((CDOSession)getOrCreateSession()).getPackageRegistry();
}
/**
diff --git a/plugins/org.eclipse.mylyn.docs.intent.collab.common/META-INF/MANIFEST.MF b/plugins/org.eclipse.mylyn.docs.intent.collab.common/META-INF/MANIFEST.MF
index cc5bee0..57295af 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.collab.common/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.mylyn.docs.intent.collab.common/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@
Bundle-Localization: plugin
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.mylyn.docs.intent.collab.common;singleton:=true
-Bundle-Version: 0.7.0.qualifier
+Bundle-Version: 0.8.0.qualifier
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Export-Package: org.eclipse.mylyn.docs.intent.collab.common,
org.eclipse.mylyn.docs.intent.collab.common.location,
diff --git a/plugins/org.eclipse.mylyn.docs.intent.collab.common/pom.xml b/plugins/org.eclipse.mylyn.docs.intent.collab.common/pom.xml
index 9c4498f..5c05632 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.collab.common/pom.xml
+++ b/plugins/org.eclipse.mylyn.docs.intent.collab.common/pom.xml
@@ -13,7 +13,7 @@
<parent>
<groupId>org.eclipse.mylyn.docs.intent-group</groupId>
<artifactId>intent-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
diff --git a/plugins/org.eclipse.mylyn.docs.intent.collab.ide/META-INF/MANIFEST.MF b/plugins/org.eclipse.mylyn.docs.intent.collab.ide/META-INF/MANIFEST.MF
index 57f7bf1..af578f3 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.collab.ide/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.mylyn.docs.intent.collab.ide/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@
Bundle-Localization: plugin
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.mylyn.docs.intent.collab.ide;singleton:=true
-Bundle-Version: 0.7.0.qualifier
+Bundle-Version: 0.8.0.qualifier
Bundle-Activator: org.eclipse.mylyn.docs.intent.collab.ide.Activator
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.mylyn.docs.intent.collab;visibility:=reexport,
diff --git a/plugins/org.eclipse.mylyn.docs.intent.collab.ide/pom.xml b/plugins/org.eclipse.mylyn.docs.intent.collab.ide/pom.xml
index 33eb78d..efdc9ab 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.collab.ide/pom.xml
+++ b/plugins/org.eclipse.mylyn.docs.intent.collab.ide/pom.xml
@@ -13,7 +13,7 @@
<parent>
<groupId>org.eclipse.mylyn.docs.intent-group</groupId>
<artifactId>intent-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
diff --git a/plugins/org.eclipse.mylyn.docs.intent.collab.ide/src/org/eclipse/mylyn/docs/intent/collab/ide/notification/WorkspaceRepositoryChangeNotificationFactory.java b/plugins/org.eclipse.mylyn.docs.intent.collab.ide/src/org/eclipse/mylyn/docs/intent/collab/ide/notification/WorkspaceRepositoryChangeNotificationFactory.java
index dc79abf..8ebfa9f 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.collab.ide/src/org/eclipse/mylyn/docs/intent/collab/ide/notification/WorkspaceRepositoryChangeNotificationFactory.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.collab.ide/src/org/eclipse/mylyn/docs/intent/collab/ide/notification/WorkspaceRepositoryChangeNotificationFactory.java
@@ -58,7 +58,7 @@
// notification.getNewValue();
RepositoryChangeNotification newNotification = new RepositoryChangeNotificationImpl();
- newNotification.getRightRoots().add(target);
+ newNotification.getImpactedElements().add(target);
return newNotification;
}
@@ -71,7 +71,7 @@
*/
private RepositoryChangeNotification createFromChangedResource(Resource changedResource) {
RepositoryChangeNotification newNotification = new RepositoryChangeNotificationImpl();
- newNotification.getRightRoots().addAll(changedResource.getContents());
+ newNotification.getImpactedElements().addAll(changedResource.getContents());
return newNotification;
}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.collab/META-INF/MANIFEST.MF b/plugins/org.eclipse.mylyn.docs.intent.collab/META-INF/MANIFEST.MF
index 0781dc0..2f4d683 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.collab/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.mylyn.docs.intent.collab/META-INF/MANIFEST.MF
@@ -3,12 +3,12 @@
Bundle-Localization: plugin
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.mylyn.docs.intent.collab;singleton:=true
-Bundle-Version: 0.7.0.qualifier
+Bundle-Version: 0.8.0.qualifier
Require-Bundle: org.eclipse.emf.ecore;visibility:=reexport,
org.eclipse.emf.ecore.xmi;visibility:=reexport,
- org.eclipse.emf.compare.diff;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
org.eclipse.core.runtime;visibility:=reexport,
- com.google.guava
+ com.google.guava,
+ org.eclipse.emf.compare;bundle-version="2.0.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Export-Package: org.eclipse.mylyn.docs.intent.collab.handlers,
diff --git a/plugins/org.eclipse.mylyn.docs.intent.collab/pom.xml b/plugins/org.eclipse.mylyn.docs.intent.collab/pom.xml
index e8f5a46..6d10291 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.collab/pom.xml
+++ b/plugins/org.eclipse.mylyn.docs.intent.collab/pom.xml
@@ -13,7 +13,7 @@
<parent>
<groupId>org.eclipse.mylyn.docs.intent-group</groupId>
<artifactId>intent-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
diff --git a/plugins/org.eclipse.mylyn.docs.intent.collab/src/org/eclipse/mylyn/docs/intent/collab/handlers/impl/notification/RepositoryChangeNotificationImpl.java b/plugins/org.eclipse.mylyn.docs.intent.collab/src/org/eclipse/mylyn/docs/intent/collab/handlers/impl/notification/RepositoryChangeNotificationImpl.java
index 61dc572..8948f5d 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.collab/src/org/eclipse/mylyn/docs/intent/collab/handlers/impl/notification/RepositoryChangeNotificationImpl.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.collab/src/org/eclipse/mylyn/docs/intent/collab/handlers/impl/notification/RepositoryChangeNotificationImpl.java
@@ -10,31 +10,37 @@
*******************************************************************************/
package org.eclipse.mylyn.docs.intent.collab.handlers.impl.notification;
-import org.eclipse.emf.compare.diff.metamodel.DiffModel;
-import org.eclipse.emf.compare.diff.metamodel.impl.DiffModelImpl;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.compare.Comparison;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.mylyn.docs.intent.collab.handlers.notification.RepositoryChangeNotification;
/**
- * Representation of a notification (use the EMF Compare DiffModel).
+ * Representation of a notification (use the EMF Compare Comparison).
*
* @author <a href="mailto:alex.lagarde@obeo.fr">Alex Lagarde</a>
*/
-public class RepositoryChangeNotificationImpl extends DiffModelImpl implements RepositoryChangeNotification {
+public class RepositoryChangeNotificationImpl implements RepositoryChangeNotification {
+
+ private List<EObject> impactedElements;
/**
* RepositoryChangeNotificationImpl default constructor.
*/
public RepositoryChangeNotificationImpl() {
super();
+ impactedElements = new ArrayList<EObject>();
}
/**
* RepositoryChangeNotificationImpl constructor.
*
- * @param diffModel
- * the DiffModel to copy.
+ * @param comparison
+ * the Comparison to copy.
*/
- public RepositoryChangeNotificationImpl(DiffModel diffModel) {
+ public RepositoryChangeNotificationImpl(Comparison comparison) {
super();
}
@@ -45,7 +51,16 @@
*/
@Override
public String toString() {
- String toString = getRightRoots().toString();
+ String toString = getImpactedElements().toString();
return toString;
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.mylyn.docs.intent.collab.handlers.notification.RepositoryChangeNotification#getImpactedElements()
+ */
+ public List<EObject> getImpactedElements() {
+ return impactedElements;
+ }
}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.collab/src/org/eclipse/mylyn/docs/intent/collab/handlers/impl/notification/elementList/ElementListAdapter.java b/plugins/org.eclipse.mylyn.docs.intent.collab/src/org/eclipse/mylyn/docs/intent/collab/handlers/impl/notification/elementList/ElementListAdapter.java
index 3cee5cd..5101111 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.collab/src/org/eclipse/mylyn/docs/intent/collab/handlers/impl/notification/elementList/ElementListAdapter.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.collab/src/org/eclipse/mylyn/docs/intent/collab/handlers/impl/notification/elementList/ElementListAdapter.java
@@ -76,7 +76,7 @@
public void notifyChangesOnElement(EObject target) {
RepositoryChangeNotification newNotification = new RepositoryChangeNotificationImpl();
if (target != null) {
- newNotification.getRightRoots().add(target);
+ newNotification.getImpactedElements().add(target);
}
this.notificator.notifyHandlers(newNotification);
}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.collab/src/org/eclipse/mylyn/docs/intent/collab/handlers/notification/RepositoryChangeNotification.java b/plugins/org.eclipse.mylyn.docs.intent.collab/src/org/eclipse/mylyn/docs/intent/collab/handlers/notification/RepositoryChangeNotification.java
index b9f1fc0..7f9e9b2 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.collab/src/org/eclipse/mylyn/docs/intent/collab/handlers/notification/RepositoryChangeNotification.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.collab/src/org/eclipse/mylyn/docs/intent/collab/handlers/notification/RepositoryChangeNotification.java
@@ -10,13 +10,21 @@
*******************************************************************************/
package org.eclipse.mylyn.docs.intent.collab.handlers.notification;
-import org.eclipse.emf.compare.diff.metamodel.DiffModel;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
/**
* Notification sent by the repository to the clients containing the changing objects.
*
* @author <a href="mailto:alex.lagarde@obeo.fr">Alex Lagarde</a>
*/
-public interface RepositoryChangeNotification extends DiffModel {
+public interface RepositoryChangeNotification {
+ /**
+ * Returns the list of the impacted elements.
+ *
+ * @return the list of the impacted elements
+ */
+ List<EObject> getImpactedElements();
}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.compare/.checkstyle b/plugins/org.eclipse.mylyn.docs.intent.compare/.checkstyle
index c8682c8..4017aff 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.compare/.checkstyle
+++ b/plugins/org.eclipse.mylyn.docs.intent.compare/.checkstyle
@@ -1,9 +1,12 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<fileset-config file-format-version="1.2.0" simple-config="true">
- <local-check-config name="Intent" location="/org.eclipse.mylyn.docs.intent/dev/code/checkstyleConfiguration.xml" type="project" description="">
- <additional-data name="protect-config-file" value="false"/>
- </local-check-config>
- <fileset name="tous" enabled="true" check-config-name="Intent" local="true">
- <file-match-pattern match-pattern="." include-pattern="true"/>
- </fileset>
-</fileset-config>
+<?xml version="1.0" encoding="UTF-8"?>
+<fileset-config file-format-version="1.2.0" simple-config="true">
+ <local-check-config name="Intent" location="/org.eclipse.mylyn.docs.intent/dev/code/checkstyleConfiguration.xml" type="project" description="">
+ <additional-data name="protect-config-file" value="false"/>
+ </local-check-config>
+ <fileset name="tous" enabled="true" check-config-name="Intent" local="true">
+ <file-match-pattern match-pattern="." include-pattern="true"/>
+ </fileset>
+ <filter name="FilesFromPackage" enabled="true">
+ <filter-data value="src/org/eclipse/mylyn/docs/intent/compare/debug"/>
+ </filter>
+</fileset-config>
diff --git a/plugins/org.eclipse.mylyn.docs.intent.compare/META-INF/MANIFEST.MF b/plugins/org.eclipse.mylyn.docs.intent.compare/META-INF/MANIFEST.MF
index 0134eac..17f09fc 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.compare/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.mylyn.docs.intent.compare/META-INF/MANIFEST.MF
@@ -3,13 +3,13 @@
Bundle-Localization: plugin
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.mylyn.docs.intent.compare
-Bundle-Version: 0.7.0.qualifier
+Bundle-Version: 0.8.0.qualifier
Require-Bundle: org.eclipse.mylyn.docs.intent.core,
- org.eclipse.emf.compare.match;bundle-version="[1.3.0,2.0.0)",
- org.eclipse.emf.compare;bundle-version="[1.3.0,2.0.0)",
- org.eclipse.emf.compare.diff;bundle-version="[1.3.0,2.0.0)",
- com.google.guava
+ org.eclipse.emf.compare;bundle-version="2.0.0",
+ com.google.guava,
+ org.eclipse.mylyn.docs.intent.parser;bundle-version="0.7.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Export-Package: org.eclipse.mylyn.docs.intent.compare
+Export-Package: org.eclipse.mylyn.docs.intent.compare,
+ org.eclipse.mylyn.docs.intent.compare.utils
Bundle-Vendor: %providerName
diff --git a/plugins/org.eclipse.mylyn.docs.intent.compare/pom.xml b/plugins/org.eclipse.mylyn.docs.intent.compare/pom.xml
index 2562b68..9ee0447 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.compare/pom.xml
+++ b/plugins/org.eclipse.mylyn.docs.intent.compare/pom.xml
@@ -13,7 +13,7 @@
<parent>
<groupId>org.eclipse.mylyn.docs.intent-group</groupId>
<artifactId>intent-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
diff --git a/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/IntentASTMerger.java b/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/IntentASTMerger.java
index 4340f68..656da30 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/IntentASTMerger.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/IntentASTMerger.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 Obeo.
+ * Copyright (c) 2010, 2012 Obeo.
* 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
@@ -10,36 +10,29 @@
*******************************************************************************/
package org.eclipse.mylyn.docs.intent.compare;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.compare.diff.merge.service.MergeService;
-import org.eclipse.emf.compare.diff.metamodel.DiffElement;
-import org.eclipse.emf.compare.diff.metamodel.DiffModel;
-import org.eclipse.emf.compare.diff.service.DiffService;
-import org.eclipse.emf.compare.match.MatchOptions;
-import org.eclipse.emf.compare.match.engine.IMatchScopeProvider;
-import org.eclipse.emf.compare.match.metamodel.MatchModel;
+import org.eclipse.emf.compare.Comparison;
+import org.eclipse.emf.compare.Diff;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.impl.ResourceImpl;
-import org.eclipse.mylyn.docs.intent.compare.match.IntentMatchEngine;
-import org.eclipse.mylyn.docs.intent.compare.match.IntentScopeProvider;
+import org.eclipse.mylyn.docs.intent.compare.utils.EMFCompareUtils;
/**
* Merges local and repository asts using EMF Compare.
*
* @author <a href="mailto:alex.lagarde@obeo.fr">Alex Lagarde</a>
+ * @author <a href="mailto:william.piers@obeo.fr">William Piers</a>
*/
public class IntentASTMerger {
private static final boolean OVERRIDE = false;
/**
+ * Constructor.
+ */
+ public IntentASTMerger() {
+ }
+
+ /**
* Modify the repository elements according to the local elements ; this operation should occur during a
* transaction and be committed to be effective.
*
@@ -48,7 +41,7 @@
* @param repositoryRoot
* the repository element to update
* @throws MergingException
- * if the mergin has encountered a problem.
+ * if the merging has encountered a problem.
*/
public void mergeFromLocalToRepository(EObject localRoot, EObject repositoryRoot) throws MergingException {
if (OVERRIDE) {
@@ -56,49 +49,11 @@
repositoryRoot.eSet(feature, localRoot.eGet(feature));
}
} else {
- List<DiffElement> differences = getDifferences(localRoot, repositoryRoot);
- MergeService.merge(differences, true);
+ Comparison comparison = EMFCompareUtils.compareDocuments(localRoot, repositoryRoot);
+ for (Diff diff : comparison.getDifferences()) {
+ diff.copyLeftToRight();
+ }
}
}
- /**
- * For now on, does nothing.
- */
- public void mergeFromRepositoryToLocal() {
-
- }
-
- /**
- * Returns the differences between a given local object and the corresponding repository element.
- *
- * @param localRoot
- * the local element to commit
- * @param repositoryRoot
- * the repository element to update
- * @return the differences between a given local object and the corresponding repository element
- */
- public static List<DiffElement> getDifferences(EObject localRoot, EObject repositoryRoot) {
- // Step 0 : match preparation
- // Step 0.1 : we create a sample resource and add the localRoot to
- // its content.
- Resource sampleResource = new ResourceImpl(URI.createURI("http://mysampleuri.com"));
- sampleResource.getContents().add(localRoot);
-
- // Step 0.2 Defining a scope provider
- MatchModel match = null;
- IMatchScopeProvider scopeProvider = new IntentScopeProvider(localRoot, repositoryRoot);
- Map<String, Object> optionsMap = new HashMap<String, Object>();
- optionsMap.put(MatchOptions.OPTION_MATCH_SCOPE_PROVIDER, scopeProvider);
-
- // Step 1 : matching the local and the repository root using a custom
- // MatcheEngine.
- match = new IntentMatchEngine(localRoot, repositoryRoot).contentMatch(localRoot, repositoryRoot,
- optionsMap);
-
- DiffModel diff = DiffService.doDiff(match, false);
- // Step 3 : Merges all differences from local to repository
- List<DiffElement> differences = new ArrayList<DiffElement>(diff.getOwnedElements());
-
- return differences;
- }
}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/match/AbstractGenericMatchEngineToCheckerBridge.java b/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/match/AbstractGenericMatchEngineToCheckerBridge.java
deleted file mode 100644
index 7b8ba88..0000000
--- a/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/match/AbstractGenericMatchEngineToCheckerBridge.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Obeo.
-
- * 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:
- * Obeo - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.docs.intent.compare.match;
-
-import org.eclipse.emf.compare.FactoryException;
-import org.eclipse.emf.ecore.EObject;
-
-/**
- * This class is only here to keep the 1.0 behavior in 1.1 and in that case : clients having specialized
- * content/nameSimilarity in their subclass of generic match engine should still be called.
- *
- * @author <a href="mailto:cedric.brun@obeo.fr">Cedric Brun</a>
- */
-
-public abstract class AbstractGenericMatchEngineToCheckerBridge {
- /**
- * This will compute the similarity between two {@link EObject}s' contents.
- *
- * @param obj1
- * First of the two {@link EObject}s.
- * @param obj2
- * Second of the two {@link EObject}s.
- * @return <code>double</code> representing the similarity between the two {@link EObject}s' contents. 0
- * < value < 1.
- * @throws FactoryException
- * Thrown if we cannot compute the {@link EObject}s' contents similarity metrics.
- * @see org.eclipse.emf.compare.match.internal.statistic.NameSimilarity#contentValue(EObject,
- * org.eclipse.emf.compare.match.statistic.MetamodelFilter)
- */
- public abstract double contentSimilarity(EObject obj1, EObject obj2) throws FactoryException;
-
- /**
- * This will compute the similarity between two {@link EObject}s' names.
- *
- * @param obj1
- * First of the two {@link EObject}s.
- * @param obj2
- * Second of the two {@link EObject}s.
- * @return <code>double</code> representing the similarity between the two {@link EObject}s' names. 0 <
- * value < 1.
- * @see org.eclipse.emf.compare.match.internal.statistic.NameSimilarity#nameSimilarityMetric(String,
- * String)
- */
- public abstract double nameSimilarity(EObject obj1, EObject obj2);
-}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/match/EditionDistance.java b/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/match/EditionDistance.java
new file mode 100644
index 0000000..c9ca566
--- /dev/null
+++ b/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/match/EditionDistance.java
@@ -0,0 +1,480 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.mylyn.docs.intent.compare.match;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Iterators;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.compare.CompareFactory;
+import org.eclipse.emf.compare.Comparison;
+import org.eclipse.emf.compare.DifferenceKind;
+import org.eclipse.emf.compare.DifferenceSource;
+import org.eclipse.emf.compare.Match;
+import org.eclipse.emf.compare.diff.DefaultDiffEngine;
+import org.eclipse.emf.compare.diff.FeatureFilter;
+import org.eclipse.emf.compare.diff.IDiffProcessor;
+import org.eclipse.emf.compare.match.eobject.ProximityEObjectMatcher.DistanceFunction;
+import org.eclipse.emf.compare.match.eobject.URIDistance;
+import org.eclipse.emf.compare.utils.DiffUtil;
+import org.eclipse.emf.compare.utils.EqualityHelper;
+import org.eclipse.emf.compare.utils.ReferenceUtil;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+/**
+ * This distance function implementation will actually compare the given EObject.
+ *
+ * @author <a href="mailto:cedric.brun@obeo.fr">Cedric Brun</a>
+ */
+public class EditionDistance implements DistanceFunction {
+ /**
+ * Weight coefficient of a change on a reference.
+ */
+ private int referenceChangeCoef = 10;
+
+ /**
+ * Weight coefficient of a change on an attribute.
+ */
+ private int attributeChangeCoef = 10 + 10;
+
+ /**
+ * Weight coefficient of a change of location (uri).
+ */
+ private int locationChangeCoef = 4;
+
+ /**
+ * Weight coefficient of a change of order within a reference.
+ */
+ private int orderChangeCoef = 5;
+
+ /**
+ * The list of specific weight to apply on specific Features.
+ */
+ private Map<EStructuralFeature, Integer> weights;
+
+ /**
+ * The list of features to ignore during the distance computation.
+ */
+ private Set<EStructuralFeature> toBeIgnored;
+
+ /**
+ * The equality helper used to retrieve the URIs through its cache and to instanciate a specific diff
+ * engine.
+ */
+ private EqualityHelper helper;
+
+ /**
+ * The left root.
+ */
+ // FORK
+ private Notifier leftRoot;
+
+ /**
+ * The right root.
+ */
+ // FORK
+ private Notifier rightRoot;
+
+ /**
+ * Instanciate a new Edition Distance using the given equality helper.
+ *
+ * @param equalityHelper
+ * the equality helper to use.
+ * @param leftRoot
+ * the left root of the comparison
+ * @param rightRoot
+ * the right root of the comparison
+ */
+ // FORK
+ public EditionDistance(EqualityHelper equalityHelper, Notifier leftRoot, Notifier rightRoot) {
+ weights = Maps.newHashMap();
+ this.helper = equalityHelper;
+ this.toBeIgnored = Sets.newLinkedHashSet();
+ this.leftRoot = leftRoot;
+ this.rightRoot = rightRoot;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ // FORK
+ public int distance(EObject a, EObject b, int maxDistance) {
+ int distance = maxDistance;
+ if (a.equals(leftRoot) && b.equals(rightRoot) || b.equals(leftRoot) && a.equals(rightRoot)) {
+ distance = 0;
+ } else {
+ distance = new IntentCountingDiffEngine(this, maxDistance).measureDifferences(a, b);
+ }
+ return distance;
+ }
+
+ /**
+ * Create a new builder to instanciate and configure an EditionDistance.
+ *
+ * @param helper
+ * the equality helper (required to instanciate an EditionDistance).
+ * @param leftRoot
+ * the left root of the comparison
+ * @param rightRoot
+ * the right root of the comparison
+ * @return a configuration builder.
+ */
+ public static Builder builder(EqualityHelper helper, Notifier leftRoot, Notifier rightRoot) {
+ return new Builder(helper, leftRoot, rightRoot);
+ }
+
+ /**
+ * Builder class to configure an EditionDistance instance.
+ */
+ public static class Builder {
+ /**
+ * The EditionDistance built by the builder.
+ */
+ private EditionDistance toBeBuilt;
+
+ /**
+ * Create the builder.
+ *
+ * @param toBe
+ * the equality helper (required to instanciate an EditionDistance).
+ * @param leftRoot
+ * the left root of the comparison
+ * @param rightRoot
+ * the right root of the comparison
+ */
+ // FORK
+ public Builder(EqualityHelper toBe, Notifier leftRoot, Notifier rightRoot) {
+ this.toBeBuilt = new EditionDistance(toBe, leftRoot, rightRoot);
+ }
+
+ /**
+ * Specify a weight for a given feature.
+ *
+ * @param feat
+ * the feature to customize.
+ * @param weight
+ * the weight, it will be multiplied by the type of change coefficient.
+ * @return the current builder instance.
+ */
+ public Builder weight(EStructuralFeature feat, Integer weight) {
+ this.toBeBuilt.weights.put(feat, weight);
+ return this;
+ }
+
+ /**
+ * Specify a feature to ignore during the measure.
+ *
+ * @param featToIgnore
+ * the feature to ignore.
+ * @return the current builder instance.
+ */
+ public Builder ignore(EStructuralFeature featToIgnore) {
+ this.toBeBuilt.toBeIgnored.add(featToIgnore);
+ return this;
+ }
+
+ /**
+ * Specify the weight of any change of uri between two instances.
+ *
+ * @param weight
+ * the new weight.
+ * @return the current builder instance.
+ */
+ public Builder uri(int weight) {
+ this.toBeBuilt.locationChangeCoef = weight;
+ return this;
+ }
+
+ /**
+ * Specify the weight of any change of reference order between two instances.
+ *
+ * @param weight
+ * the new weight.
+ * @return the current builder instance.
+ */
+
+ public Builder order(int weight) {
+ this.toBeBuilt.orderChangeCoef = weight;
+ return this;
+ }
+
+ /**
+ * Specify the weight of any change of attribute value between two instances.
+ *
+ * @param weight
+ * the new weight.
+ * @return the current builder instance.
+ */
+
+ public Builder attribute(int weight) {
+ this.toBeBuilt.attributeChangeCoef = weight;
+ return this;
+ }
+
+ /**
+ * Specify the weight of any change of reference between two instances.
+ *
+ * @param weight
+ * the new weight.
+ * @return the current builder instance.
+ */
+
+ public Builder reference(int weight) {
+ this.toBeBuilt.referenceChangeCoef = weight;
+ return this;
+ }
+
+ /**
+ * return the configured instance.
+ *
+ * @return the configured instance.
+ */
+ public EditionDistance build() {
+ return toBeBuilt;
+ }
+ }
+
+ /**
+ * This class is an implementation of a {@link IDiffProcessor} which counts the number of differences to
+ * given an overall distance between two objects.
+ */
+ class CountingDiffProcessor implements IDiffProcessor {
+ /**
+ * The current distance.
+ */
+ private int distance;
+
+ /**
+ * {@inheritDoc}
+ */
+ public void referenceChange(Match match, EReference reference, EObject value, DifferenceKind kind,
+ DifferenceSource source) {
+ distance += getWeight(reference) * referenceChangeCoef;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void attributeChange(Match match, EAttribute attribute, Object value, DifferenceKind kind,
+ DifferenceSource source) {
+ Object aValue = ReferenceUtil.safeEGet(match.getLeft(), attribute);
+ Object bValue = ReferenceUtil.safeEGet(match.getRight(), attribute);
+ switch (kind) {
+ case MOVE:
+ distance += getWeight(attribute) * orderChangeCoef;
+ break;
+ case ADD:
+ case DELETE:
+ case CHANGE:
+ if (aValue instanceof String && bValue instanceof String) {
+ distance += getWeight(attribute)
+ * (1 - DiffUtil.diceCoefficient((String)aValue, (String)bValue))
+ * attributeChangeCoef;
+ } else {
+ distance += getWeight(attribute) * attributeChangeCoef;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.diff.IDiffProcessor#resourceAttachmentChange(org.eclipse.emf.compare.Match,
+ * java.lang.String, org.eclipse.emf.compare.DifferenceKind,
+ * org.eclipse.emf.compare.DifferenceSource)
+ */
+ public void resourceAttachmentChange(Match match, String uri, DifferenceKind kind,
+ DifferenceSource source) {
+ // Not important for the distance computation
+ }
+
+ /**
+ * return the computed distance.
+ *
+ * @return the computed distance.
+ */
+ public int getComputedDistance() {
+ return distance;
+ }
+
+ }
+
+ /**
+ * Return the weight for the given feature.
+ *
+ * @param attribute
+ * any {@link EStructuralFeature}.
+ * @return the weight for the given feature.
+ */
+ private int getWeight(EStructuralFeature attribute) {
+ Integer found = weights.get(attribute);
+ if (found == null) {
+ if ("name".equals(attribute.getName())) { //$NON-NLS-1$
+ found = Integer.valueOf(3);
+ } else {
+ found = Integer.valueOf(1);
+ }
+ }
+ return found.intValue();
+ }
+
+ /**
+ * An implementation of a diff engine which count and measure the detected changes.
+ */
+ class CountingDiffEngine extends DefaultDiffEngine {
+ /** A fake comparison object required so that the diff engine does his job correctly. */
+ private Comparison fakeComparison;
+
+ /**
+ * The maximum distance until which we just have to stop.
+ */
+ private int maxDistance;
+
+ /**
+ * Create the diff engine.
+ *
+ * @param maxDistance
+ * the maximum distance we might reach.
+ */
+ public CountingDiffEngine(int maxDistance) {
+ super(new CountingDiffProcessor());
+ this.maxDistance = maxDistance;
+ this.fakeComparison = CompareFactory.eINSTANCE.createComparison();
+ this.helper = EditionDistance.this.helper;
+
+ }
+
+ @Override
+ protected void computeDifferences(Match match, EAttribute attribute, boolean checkOrdering) {
+ if (getCounter().getComputedDistance() <= maxDistance) {
+ super.computeDifferences(match, attribute, checkOrdering);
+ }
+ }
+
+ @Override
+ protected void computeDifferences(Match match, EReference reference, boolean checkOrdering) {
+ if (getCounter().getComputedDistance() <= maxDistance) {
+ super.computeDifferences(match, reference, checkOrdering);
+ }
+ }
+
+ /**
+ * Measure the difference between two objects and return a distance value.
+ *
+ * @param a
+ * first object.
+ * @param b
+ * second object.
+ * @return the distance between them computed using the number of changes required to change a to b.
+ */
+ public int measureDifferences(EObject a, EObject b) {
+ Match fakeMatch = CompareFactory.eINSTANCE.createMatch();
+ fakeMatch.setLeft(a);
+ fakeMatch.setRight(b);
+ URI aLocation = helper.getURI(a);
+ URI bLocation = helper.getURI(b);
+ int changes = 0;
+ if (!aLocation.fragment().equals(bLocation.fragment())) {
+ int dist = new URIDistance().proximity(aLocation.fragment(), bLocation.fragment());
+ changes += dist * locationChangeCoef;
+ }
+ if (changes <= maxDistance) {
+ checkForDifferences(fakeMatch);
+ changes += getCounter().getComputedDistance();
+ }
+ // System.err.println(changes + ":max=>" + maxDistance + ":" + a + ":" + b);
+ return changes;
+
+ }
+
+ protected CountingDiffProcessor getCounter() {
+ return (CountingDiffProcessor)getDiffProcessor();
+ }
+
+ @Override
+ protected Comparison getComparison() {
+ return fakeComparison;
+ }
+
+ @Override
+ protected FeatureFilter createFeatureFilter() {
+ return new FeatureFilter() {
+
+ @Override
+ public Iterator<EReference> getReferencesToCheck(Match match) {
+ return Iterators.filter(super.getReferencesToCheck(match), new Predicate<EReference>() {
+
+ public boolean apply(EReference input) {
+ return toBeIgnored.contains(input) && !input.isContainment();
+ }
+ });
+ }
+
+ @Override
+ public Iterator<EAttribute> getAttributesToCheck(Match match) {
+ return Iterators.filter(super.getAttributesToCheck(match), new Predicate<EAttribute>() {
+
+ public boolean apply(EAttribute input) {
+ return !toBeIgnored.contains(input);
+ }
+ });
+ }
+
+ };
+ }
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getMaxDistance(EObject eObj) {
+
+ Predicate<EStructuralFeature> featureFilter = new Predicate<EStructuralFeature>() {
+
+ public boolean apply(EStructuralFeature feat) {
+ return !feat.isDerived() && !feat.isTransient() && !toBeIgnored.contains(feat);
+ }
+ };
+ // When can you safely says these are not the same EObjects *at all* ?
+ // lets consider every feature which is set, and add this in the max distance.
+ // and then tweak the max value adding half a location change
+ // thats very empirical... and might be wrong in the end, but it gives pretty good results with
+ // Ecore so I'll try to gather as much as test data I can and add the corresponding test to be able to
+ // assess the quality of further changes.
+ int max = 0;
+ for (EReference feat : Iterables.filter(eObj.eClass().getEAllReferences(), featureFilter)) {
+ if (!feat.isContainer() && eObj.eIsSet(feat)) {
+ max += getWeight(feat) * referenceChangeCoef;
+ }
+ }
+ for (EAttribute feat : Iterables.filter(eObj.eClass().getEAllAttributes(), featureFilter)) {
+ max += getWeight(feat) * attributeChangeCoef;
+ }
+ max = max + locationChangeCoef * 5 - 1;
+ // System.out.println(eObj.eClass().getName() + ":" + eObj + ":" + max);
+ return max;
+ }
+}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/match/IntentCountingDiffEngine.java b/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/match/IntentCountingDiffEngine.java
new file mode 100644
index 0000000..7b2c8ea
--- /dev/null
+++ b/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/match/IntentCountingDiffEngine.java
@@ -0,0 +1,194 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.mylyn.docs.intent.compare.match;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.mylyn.docs.intent.compare.match.EditionDistance.CountingDiffEngine;
+import org.eclipse.mylyn.docs.intent.core.descriptionunit.DescriptionBloc;
+import org.eclipse.mylyn.docs.intent.core.descriptionunit.DescriptionUnit;
+import org.eclipse.mylyn.docs.intent.core.document.IntentDocument;
+import org.eclipse.mylyn.docs.intent.core.document.IntentStructuredElement;
+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.StructuralFeatureAffectation;
+import org.eclipse.mylyn.docs.intent.markup.markup.BlockContent;
+import org.eclipse.mylyn.docs.intent.markup.markup.MarkupPackage;
+import org.eclipse.mylyn.docs.intent.markup.markup.Text;
+import org.eclipse.mylyn.docs.intent.markup.serializer.WikiTextSerializer;
+import org.eclipse.mylyn.docs.intent.serializer.IntentSerializer;
+
+/**
+ * An implementation of a diff engine which count and measure the detected changes into Intent documents.
+ *
+ * @author <a href="mailto:william.piers@obeo.fr">William Piers</a>
+ */
+public class IntentCountingDiffEngine extends CountingDiffEngine {
+
+ private static final double LOCALIZATION_DISTANCE_WEIGHT = 0.2;
+
+ private static final double IDENTIFIER_DISTANCE_WEIGHT = 0.8;
+
+ /**
+ * Constructor.
+ *
+ * @param editionDistance
+ * for instanciation
+ * @param maxDistance
+ * the max distance
+ */
+ public IntentCountingDiffEngine(
+ org.eclipse.mylyn.docs.intent.compare.match.EditionDistance editionDistance, int maxDistance) {
+ editionDistance.super(maxDistance);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.mylyn.docs.intent.compare.match.EditionDistance.CountingDiffEngine#measureDifferences(org.eclipse.emf.ecore.EObject,
+ * org.eclipse.emf.ecore.EObject)
+ */
+ @Override
+ public int measureDifferences(EObject a, EObject b) {
+ if (a instanceof IntentDocument && b instanceof IntentDocument) {
+ return 0; // root element
+ }
+
+ Integer distance = null;
+
+ // the default localization distance
+ Integer uriDistance = getURIDistance(a, b);
+
+ // the semantic distance: in the best case, a title or feature id. If not available, the
+ // element serialization
+ Integer identifierDistance = getIdentifierDistance(a, b);
+ if (identifierDistance == null) {
+ identifierDistance = getSerializationDistance(a, b);
+ }
+
+ if (identifierDistance != null) {
+ distance = (int)(identifierDistance * IDENTIFIER_DISTANCE_WEIGHT + uriDistance
+ * LOCALIZATION_DISTANCE_WEIGHT);
+ } else {
+ distance = uriDistance;
+ }
+ return distance;
+ }
+
+ /**
+ * Returns the distance between document elements by comparing their uris.
+ *
+ * @param a
+ * the first element
+ * @param b
+ * the second element
+ * @return the distance between two strings
+ */
+ private Integer getURIDistance(EObject a, EObject b) {
+ Integer distance = null;
+ String fragmentA = helper.getURI(a).fragment();
+ String fragmentB = helper.getURI(b).fragment();
+ if (fragmentA != null && fragmentB != null) {
+ distance = StringDistanceUtils.getStringDistance(fragmentA, fragmentB);
+ }
+ return distance;
+ }
+
+ /**
+ * Returns the distance between document elements by comparing their identifiers.
+ *
+ * @param a
+ * the first element
+ * @param b
+ * the second element
+ * @return the distance between two strings
+ */
+ private Integer getIdentifierDistance(EObject a, EObject b) {
+ Integer distance = null;
+ String identifierA = null;
+ String identifierB = null;
+ if (a instanceof IntentStructuredElement && b instanceof IntentStructuredElement) {
+ identifierA = getTitle((IntentStructuredElement)a);
+ identifierB = getTitle((IntentStructuredElement)b);
+ } else if (a instanceof StructuralFeatureAffectation && b instanceof StructuralFeatureAffectation) {
+ identifierA = ((StructuralFeatureAffectation)a).getName();
+ identifierB = ((StructuralFeatureAffectation)b).getName();
+ } else if (a instanceof InstanciationInstruction && b instanceof InstanciationInstruction) {
+ identifierA = ((InstanciationInstruction)a).getName();
+ identifierB = ((InstanciationInstruction)b).getName();
+ } else if (a instanceof ContributionInstruction && b instanceof ContributionInstruction) {
+ identifierA = ((ContributionInstruction)a).getContributionReference().getIntentHref();
+ identifierB = ((ContributionInstruction)b).getContributionReference().getIntentHref();
+ }
+ if (identifierA != null && identifierB != null) {
+ distance = StringDistanceUtils.getStringDistance(identifierA, identifierB);
+ }
+ return distance;
+ }
+
+ /**
+ * Returns the distance between document elements by comparing their serialization.
+ *
+ * @param a
+ * the first element
+ * @param b
+ * the second element
+ * @return the distance between two strings
+ */
+ private Integer getSerializationDistance(EObject a, EObject b) {
+ Integer distance = null;
+ String serializedA = serialize(a);
+ String serializedB = serialize(b);
+ if (serializedA != null && serializedB != null) {
+ distance = StringDistanceUtils.getStringDistance(serializedA, serializedB);
+ }
+ return distance;
+ }
+
+ /**
+ * Serializes the given element.
+ *
+ * @param root
+ * the element to serialize
+ * @return the serialized version
+ */
+ private static String serialize(EObject root) {
+ String res = null;
+ if (root.eClass().getEPackage().equals(MarkupPackage.eINSTANCE)) {
+ res = new WikiTextSerializer().serialize(root);
+ } else if (root instanceof ModelingUnit || root instanceof DescriptionUnit
+ || root instanceof IntentStructuredElement) {
+ res = new IntentSerializer().serialize(root);
+ } else if (root instanceof DescriptionBloc) {
+ DescriptionBloc bloc = (DescriptionBloc)root;
+ res = serialize(bloc.getDescriptionBloc());
+ }
+ return res;
+ }
+
+ /**
+ * Returns the formatted title of the given element.
+ *
+ * @param element
+ * the formatted title
+ * @return the formatted title of the given element
+ */
+ private static String getTitle(IntentStructuredElement element) {
+ String title = null;
+ if (element.getTitle() != null && !element.getTitle().getContent().isEmpty()) {
+ BlockContent content = element.getTitle().getContent().get(0);
+ if (content instanceof Text) {
+ title = ((Text)content).getData();
+ }
+ }
+ return title;
+ }
+}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/match/IntentElementFilter.java b/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/match/IntentElementFilter.java
deleted file mode 100644
index 25e1c2f..0000000
--- a/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/match/IntentElementFilter.java
+++ /dev/null
@@ -1,264 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Obeo.
- * 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:
- * Obeo - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.docs.intent.compare.match;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.emf.compare.match.statistic.MetamodelFilter;
-import org.eclipse.emf.compare.util.EMFCompareMap;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-/**
- * This class determines the unused features in an Intent metamodel.
- *
- * @author <a href="mailto:alex.lagarde@obeo.fr">Alex Lagarde</a>
- */
-public class IntentElementFilter extends MetamodelFilter {
-
- /** Keeps track of all the informations of the features. */
- protected final Map<EStructuralFeature, FeatureInformation> featuresToInformation = new EMFCompareMap<EStructuralFeature, FeatureInformation>();
-
- /** List of the unused features' informations. */
- protected List<EStructuralFeature> unusedFeatures;
-
- /**
- * This map will keep track of all the used {@link EStructuralFeature features} for a given {@link EClass
- * class}.
- */
- private final Map<EClass, List<EStructuralFeature>> eClassToFilteredFeaturesList = new EMFCompareMap<EClass, List<EStructuralFeature>>();
-
- /**
- * Contains the list of Intent Features to ignore.
- */
- private List<EStructuralFeature> featuresToIgnore;
-
- /**
- * Sets the feature that will be ignored during content match.
- *
- * @param featuresToIgnoreList
- * the list of features to ignore
- */
- public void defineFeaturesToIgnore(List<EStructuralFeature> featuresToIgnoreList) {
- this.featuresToIgnore = featuresToIgnoreList;
- }
-
- /**
- * Analyzes a model and changes the stats using this model.
- *
- * @param root
- * Model to analyze.
- */
- public void analyseModel(EObject root) {
- processEObject(root);
- final Iterator<EObject> it = root.eAllContents();
- while (it.hasNext()) {
- final EObject eObj = it.next();
- processEObject(eObj);
- }
- unusedFeatures = null;
- eClassToFilteredFeaturesList.clear();
- }
-
- /**
- * Clears all recorded information.
- */
- public void clear() {
- featuresToInformation.clear();
- unusedFeatures = null;
- eClassToFilteredFeaturesList.clear();
- }
-
- /**
- * Returns a list of the pertinent features for this {@link EObject}.
- *
- * @param eObj
- * {@link EObject} from which we seek the features.
- * @return A list of the pertinent features for this {@link EObject}.
- */
- public List<EStructuralFeature> getFilteredFeatures(EObject eObj) {
- // cache the filtered features for a type
- if (eClassToFilteredFeaturesList.containsKey(eObj.eClass())) {
- return eClassToFilteredFeaturesList.get(eObj.eClass());
- }
- // end of memorize cache
-
- final List<EStructuralFeature> result = new ArrayList<EStructuralFeature>();
- final Collection<EStructuralFeature> unused = getUnusedFeatures();
- final Iterator<EStructuralFeature> it = eObj.eClass().getEAllStructuralFeatures().iterator();
- while (it.hasNext()) {
- final EStructuralFeature feat = it.next();
- if (!unused.contains(feat)) {
- result.add(feat);
- }
- }
- eClassToFilteredFeaturesList.put(eObj.eClass(), result);
- return result;
- }
-
- /**
- * This will iterate through all the features stored via {@link #processEObject(EObject)} and populates
- * the {@link #unusedFeatures unused features list}.
- */
- private void buildUnusedFeatures() {
- unusedFeatures = new ArrayList<EStructuralFeature>();
-
- // We add to the standard unused Features the ignored features
- unusedFeatures.addAll(this.featuresToIgnore);
- final Iterator<EStructuralFeature> it = featuresToInformation.keySet().iterator();
- while (it.hasNext()) {
- final EStructuralFeature feat = it.next();
-
- if (featuresToInformation.get(feat).hasUniqueValue()) {
- unusedFeatures.add(featuresToInformation.get(feat).getFeature());
- }
- }
- }
-
- /**
- * Returns all the unused features of the {@link EObject} that's been parsed through
- * {@link #processEObject(EObject)}.
- *
- * @return All the unused features of the {@link EObject} that's been parsed through
- * {@link #processEObject(EObject)}.
- */
- private Collection<EStructuralFeature> getUnusedFeatures() {
- if (unusedFeatures == null) {
- buildUnusedFeatures();
- }
- return unusedFeatures;
- }
-
- /**
- * Iterates through all the {@link EStructuralFeature features} of a given {@link EObject} and populates
- * the {@link #featuresToInformation known features list} for later use.
- *
- * @param eObj
- * {@link EObject} we need to parse for feature information.
- */
- private void processEObject(EObject eObj) {
- final Iterator<EStructuralFeature> featIt = eObj.eClass().getEAllStructuralFeatures().iterator();
- while (featIt.hasNext()) {
- final EStructuralFeature feat = featIt.next();
- if (!feat.isDerived()) {
- FeatureInformation featureInformation = featuresToInformation.get(feat);
- if (featureInformation == null) {
- featureInformation = new FeatureInformation(feat);
- featuresToInformation.put(feat, featureInformation);
- }
- final Object value = eObj.eGet(feat);
- treatFeatureAccordingToType(feat, featureInformation, value);
- }
- }
- }
-
- /**
- * Complete the featureInformations about to the given structural feature according to its type and value.
- *
- * @param feat
- * the feature to analyse
- * @param featureInformation
- * the calculated featureInformations that need to be completed
- * @param value
- * the value of this feature
- */
- private void treatFeatureAccordingToType(final EStructuralFeature feat,
- FeatureInformation featureInformation, final Object value) {
- if (feat instanceof EReference) {
- if (feat.isMany()) {
- @SuppressWarnings({"unchecked", "rawtypes"
- })
- final Collection<EObject> values = (Collection)value;
- if (values.size() == 0) {
- featureInformation.processValue("0"); //$NON-NLS-1$
- }
- } else {
- if (value == null) {
- featureInformation.processValue("0"); //$NON-NLS-1$
- }
- }
- } else {
- if (value != null) {
- featureInformation.processValue(value.toString());
- } else {
- featureInformation.processValue("null"); //$NON-NLS-1$
- }
- }
- }
-}
-
-/**
- * Describes a feature.
- *
- * @author <a href="mailto:cedric.brun@obeo.fr">Cedric Brun</a>
- */
-class FeatureInformation {
- /** Structure which information is computed here. */
- private final EStructuralFeature feature;
-
- /** Checks wether this feature's value is always the same. */
- private boolean hasUniqueValue = true;
-
- /** Counts the number of times this feature's information is accessed. */
- private int timesUsed;
-
- /** Value of this feature if it is never altered. */
- private String uniqueValue;
-
- /**
- * Creates a {@link org.eclipse.mylyn.docs.intent.compare.match.FeatureInformation} from a feature.
- *
- * @param feat
- * The {@link EStructuralFeature feature} we want described.
- */
- public FeatureInformation(EStructuralFeature feat) {
- feature = feat;
- }
-
- /**
- * Returns the feature described by this {@link FeatureInformation}.
- *
- * @return The feature described by this {@link FeatureInformation}.
- */
- public EStructuralFeature getFeature() {
- return feature;
- }
-
- /**
- * Indicates that this features always has the same value.
- *
- * @return <code>True</code> if this feature always has the same value, <code>False</code> otherwise.
- */
- public boolean hasUniqueValue() {
- return hasUniqueValue;
- }
-
- /**
- * Adds this value in the calculus model.
- *
- * @param value
- * The value to add.
- */
- public void processValue(String value) {
- timesUsed += 1;
- if (uniqueValue != null && !uniqueValue.equals(value)) {
- hasUniqueValue = false;
- } else if (uniqueValue == null) {
- uniqueValue = value;
- }
- }
-}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/match/IntentMatchEngine.java b/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/match/IntentMatchEngine.java
deleted file mode 100644
index 1358f7b..0000000
--- a/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/match/IntentMatchEngine.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Obeo.
- * 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:
- * Obeo - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.docs.intent.compare.match;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.compare.FactoryException;
-import org.eclipse.emf.compare.match.engine.AbstractSimilarityChecker;
-import org.eclipse.emf.compare.match.engine.GenericMatchEngine;
-import org.eclipse.emf.compare.match.internal.statistic.NameSimilarity;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.mylyn.docs.intent.core.document.IntentDocumentPackage;
-import org.eclipse.mylyn.docs.intent.core.document.IntentStructuredElement;
-import org.eclipse.mylyn.docs.intent.core.genericunit.GenericUnitPackage;
-import org.eclipse.mylyn.docs.intent.core.modelingunit.ModelingUnitPackage;
-
-/**
- * Match Engine for Intent element.
- *
- * @author <a href="mailto:alex.lagarde@obeo.fr">Alex Lagarde</a>
- */
-@SuppressWarnings("restriction")
-public class IntentMatchEngine extends GenericMatchEngine {
-
- /**
- * The root of the local AST of a Intent Element.
- */
- private final EObject localRoot;
-
- /**
- * The root of the repository AST for a Intent Element.
- */
- private final EObject repositoryRoot;
-
- /**
- * IntentMatchEngineconstructor.
- *
- * @param localRoot
- * the root of the local AST of a Intent Element.
- * @param repositoryRoot
- * the root of the repository AST for a Intent Element
- */
- public IntentMatchEngine(EObject localRoot, EObject repositoryRoot) {
- this.localRoot = localRoot;
- this.repositoryRoot = repositoryRoot;
-
- // We use or own metamodel filer
- this.filter = new IntentElementFilter();
-
- // We define the list of features to ignore : basically all the resolved References.
- List<EStructuralFeature> featuresToIgnoreList = new ArrayList<EStructuralFeature>();
- featuresToIgnoreList.add(GenericUnitPackage.eINSTANCE.getIntentReference_ReferencedElement());
- featuresToIgnoreList.add(ModelingUnitPackage.eINSTANCE
- .getContributionInstruction_ContributionReference());
- featuresToIgnoreList.add(ModelingUnitPackage.eINSTANCE
- .getModelingUnitInstructionReference_ReferencedInstruction());
- featuresToIgnoreList.add(ModelingUnitPackage.eINSTANCE.getResourceReference_Declaration());
- featuresToIgnoreList.add(IntentDocumentPackage.eINSTANCE.getIntentGenericElement_CompilationStatus());
- featuresToIgnoreList.add(IntentDocumentPackage.eINSTANCE.getIntentStructuredElement_CompleteLevel());
-
- ((IntentElementFilter)filter).defineFeaturesToIgnore(featuresToIgnoreList);
-
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.emf.compare.match.engine.GenericMatchEngine#prepareChecker()
- */
- @Override
- protected AbstractSimilarityChecker prepareChecker() {
- final IntentMatchEngine engine = this;
- AbstractGenericMatchEngineToCheckerBridge bridge = new AbstractGenericMatchEngineToCheckerBridge() {
-
- @Override
- public double nameSimilarity(EObject obj1, EObject obj2) {
- if (obj1 instanceof IntentStructuredElement && obj2 instanceof IntentStructuredElement) {
- return 0.2d;
- } else {
- return engine.nameSimilarity(obj1, obj2);
- }
- }
-
- @Override
- public double contentSimilarity(EObject obj1, EObject obj2) throws FactoryException {
- return engine.contentSimilarity(obj1, obj2);
- }
- };
- return new IntentSimilarityChecker(filter, bridge, localRoot, repositoryRoot);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- @Deprecated
- protected double nameSimilarity(EObject obj1, EObject obj2) {
- double similarity = 0d;
-
- try {
-
- similarity = NameSimilarity.nameSimilarityMetric(NameSimilarity.findName(obj1),
- NameSimilarity.findName(obj2));
- } catch (final FactoryException e) {
- // fails silently, will return a similarity of 0d
- }
-
- return similarity;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- @Deprecated
- protected double contentSimilarity(EObject obj1, EObject obj2) throws FactoryException {
- double similarity = 0d;
- similarity = NameSimilarity.nameSimilarityMetric(NameSimilarity.contentValue(obj1, filter),
- NameSimilarity.contentValue(obj2, filter));
- return similarity;
- }
-
-}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/match/IntentScope.java b/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/match/IntentScope.java
deleted file mode 100644
index 0b4df1f..0000000
--- a/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/match/IntentScope.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Obeo.
- * 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:
- * Obeo - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.docs.intent.compare.match;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.compare.match.engine.IMatchScope;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.mylyn.docs.intent.core.compiler.CompilerPackage;
-
-/**
- * Provide a scope for any ReStructurde Models element, providing objects and features to ignore during the
- * match process (like resolved links for example).
- *
- * @author <a href="mailto:alex.lagarde@obeo.fr">Alex Lagarde</a>
- */
-public class IntentScope implements IMatchScope {
-
- /** the list of objects to be included in the scope. */
- private final List<EObject> eObjectsInScope = new ArrayList<EObject>();
-
- /**
- * The list of elements to ignore.
- */
- private ArrayList<EClass> elementToIgnoreList;
-
- /**
- * IntentScope constructor.
- *
- * @param element
- * the Intent element on which create this scope.
- */
- public IntentScope(EObject element) {
- initializeIgnoredFeaturesList();
- eObjectsInScope.add(element);
- addContainedElementsInScope(element);
- }
-
- /**
- * Adds all element contained by the given element in the list of objects in scope.
- *
- * @param element
- * the element to consider
- */
- private void addContainedElementsInScope(EObject element) {
- final Iterator<EObject> iterator = element.eAllContents();
- while (iterator.hasNext()) {
- final EObject next = iterator.next();
-
- if (!isIgnoredObject(next)) {
- eObjectsInScope.add(next);
- }
- }
- }
-
- /**
- * Initialize the list of features to ignore.
- */
- private void initializeIgnoredFeaturesList() {
- elementToIgnoreList = new ArrayList<EClass>();
- // elementToIgnoreList.add(ModelingUnitPackage.eINSTANCE.getTypeReference());
- elementToIgnoreList.add(CompilerPackage.eINSTANCE.getCompilationStatus());
- elementToIgnoreList.add(CompilerPackage.eINSTANCE.getSynchronizerCompilationStatus());
- }
-
- /**
- * Indicates if the given object must be ignored during the match process (for example any resolved link
- * should be ignored).
- *
- * @param eObject
- * the object to consider
- * @return true if the given object must be ignored during the match process (for example any resolved
- * link should be ignored), false otherwise.
- */
- private boolean isIgnoredObject(EObject eObject) {
- return elementToIgnoreList.contains(eObject.eClass());
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.emf.compare.match.engine.IMatchScope#isInScope(org.eclipse.emf.ecore.EObject)
- */
- public boolean isInScope(EObject eObject) {
- return this.eObjectsInScope.contains(eObject);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.emf.compare.match.engine.IMatchScope#isInScope(org.eclipse.emf.ecore.resource.Resource)
- */
- public boolean isInScope(Resource resource) {
- return false;
- }
-
-}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/match/IntentScopeProvider.java b/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/match/IntentScopeProvider.java
deleted file mode 100644
index f48cf3b..0000000
--- a/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/match/IntentScopeProvider.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Obeo.
- * 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:
- * Obeo - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.docs.intent.compare.match;
-
-import org.eclipse.emf.compare.match.engine.IMatchScope;
-import org.eclipse.emf.compare.match.engine.IMatchScopeProvider;
-import org.eclipse.emf.compare.match.filter.IResourceFilter;
-import org.eclipse.emf.ecore.EObject;
-
-/**
- * Scope Provider for Intent elements.
- *
- * @author <a href="mailto:alex.lagarde@obeo.fr">Alex Lagarde</a>
- */
-public class IntentScopeProvider implements IMatchScopeProvider {
-
- private IntentScope leftScope;
-
- private IntentScope rightScope;
-
- /**
- * IntentScopeProvider constructor.
- *
- * @param leftObject
- * the object from which we will create the left scope
- * @param rightObject
- * the object from which we will create the right scope
- */
- public IntentScopeProvider(EObject leftObject, EObject rightObject) {
- this.leftScope = new IntentScope(leftObject);
- this.rightScope = new IntentScope(rightObject);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.emf.compare.match.engine.IMatchScopeProvider#getLeftScope()
- */
- public IMatchScope getLeftScope() {
- return this.leftScope;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.emf.compare.match.engine.IMatchScopeProvider#getRightScope()
- */
- public IMatchScope getRightScope() {
- return this.rightScope;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.emf.compare.match.engine.IMatchScopeProvider#getAncestorScope()
- */
- public IMatchScope getAncestorScope() {
- return null;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.emf.compare.match.engine.IMatchScopeProvider#applyResourceFilter(org.eclipse.emf.compare.match.filter.IResourceFilter)
- */
- public void applyResourceFilter(IResourceFilter filter) {
-
- }
-}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/match/IntentSimilarityChecker.java b/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/match/IntentSimilarityChecker.java
deleted file mode 100644
index a2d7f0f..0000000
--- a/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/match/IntentSimilarityChecker.java
+++ /dev/null
@@ -1,340 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Obeo.
- * 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:
- * Obeo - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.docs.intent.compare.match;
-
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-
-import org.eclipse.emf.compare.FactoryException;
-import org.eclipse.emf.compare.match.statistic.MetamodelFilter;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.mylyn.docs.intent.core.descriptionunit.DescriptionBloc;
-import org.eclipse.mylyn.docs.intent.core.document.IntentStructuredElement;
-import org.eclipse.mylyn.docs.intent.core.document.IntentSubSectionContainer;
-import org.eclipse.mylyn.docs.intent.markup.markup.Block;
-import org.eclipse.mylyn.docs.intent.markup.markup.Paragraph;
-import org.eclipse.mylyn.docs.intent.markup.markup.Text;
-
-/**
- * Similarity checker using the Intent semantics to compare two Intent elements.
- *
- * @author <a href="mailto:alex.lagarde@obeo.fr">Alex Lagarde</a>
- */
-public class IntentSimilarityChecker extends StatisticBasedSimilarityChecker {
-
- /**
- * Value taht represents a very strong similarity.
- */
- private static final double MAX_SIMILARITY = 0.9999;
-
- private EObject localRoot;
-
- private EObject repositoryRoot;
-
- /**
- * IntentSimilarityChecker constructor.
- *
- * @param localRoot
- * the root of the local AST of a Intent Element.
- * @param repositoryRoot
- * the root of the repository AST for a Intent Element
- * @param metamodelFilter
- * a metamodel filter the checker can use to know whether a feature alwaas has the same value
- * or not in the models.
- * @param bridge
- * utility class to keep API compatibility.
- */
- public IntentSimilarityChecker(MetamodelFilter metamodelFilter,
- AbstractGenericMatchEngineToCheckerBridge bridge, EObject localRoot, EObject repositoryRoot) {
- super(metamodelFilter, bridge);
- this.localRoot = localRoot;
- this.repositoryRoot = repositoryRoot;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.mylyn.docs.intent.compare.match.StatisticBasedSimilarityChecker#isSimilar(org.eclipse.emf.ecore.EObject,
- * org.eclipse.emf.ecore.EObject)
- */
- @Override
- public boolean isSimilar(EObject obj1, EObject obj2) throws FactoryException {
- boolean isSimilar = isSimilar(obj1, obj2, false);
- return isSimilar;
- }
-
- /**
- * Should determine whether an element is similar to the other one or not.
- *
- * @param obj1
- * an element
- * @param obj2
- * another element
- * @param useGenericMatcher
- * indicates wheteher generic matcher should be directly called
- * @return true if those elements have the same identity.
- * @throws FactoryException
- * on error accessing features.
- */
- public boolean isSimilar(EObject obj1, EObject obj2, boolean useGenericMatcher) throws FactoryException {
- boolean isSimilar = false;
- boolean haveSpecificMatcher = false;
-
- // Step 1 : if we should use specific matcher directly, we call super
- if (useGenericMatcher) {
- return super.isSimilar(obj1, obj2);
- }
- // Step 2 : If the two objects are the roots, we consider that they are similar in any circumstance
- if (areRoots(obj1, obj2)) {
- isSimilar = true;
- haveSpecificMatcher = true;
- } else {
- if (obj1 instanceof DescriptionBloc && obj2 instanceof DescriptionBloc) {
- isSimilar = areSimilarDescriptionBlocs((DescriptionBloc)obj1, (DescriptionBloc)obj2);
- haveSpecificMatcher = true;
- } else {
- if (obj1 instanceof IntentStructuredElement && obj2 instanceof IntentStructuredElement) {
- isSimilar = areSimilarStructuredElements((IntentStructuredElement)obj1,
- (IntentStructuredElement)obj2);
- haveSpecificMatcher = true;
- } else {
- if (obj1 instanceof Paragraph && obj2 instanceof Paragraph) {
- isSimilar = areSimilarParagraphs((Paragraph)obj1, (Paragraph)obj2);
- haveSpecificMatcher = true;
- }
- }
- }
- }
- if (!haveSpecificMatcher) {
- isSimilar = super.isSimilar(obj1, obj2);
- }
- return isSimilar;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.emf.compare.match.engine.AbstractSimilarityChecker#fastLookup(org.eclipse.emf.ecore.EObject)
- */
- @Override
- public EObject fastLookup(EObject obj1) {
- if (obj1 == localRoot) {
- return repositoryRoot;
- }
- return super.fastLookup(obj1);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.mylyn.docs.intent.compare.match.StatisticBasedSimilarityChecker#absoluteMetric(org.eclipse.emf.ecore.EObject,
- * org.eclipse.emf.ecore.EObject)
- */
- @Override
- public double absoluteMetric(EObject obj1, EObject obj2) throws FactoryException {
- // If the two objects are the roots, we consider that they are similar in any circumstance
- if (areRoots(obj1, obj2)) {
- return MAX_SIMILARITY;
- } else {
- if (obj1 instanceof IntentStructuredElement && obj2 instanceof IntentStructuredElement) {
- if (areSimilarStructuredElements((IntentStructuredElement)obj1, (IntentStructuredElement)obj2)) {
- return 1.0;
- } else {
- return 0;
- }
- }
- }
- return super.absoluteMetric(obj1, obj2);
- }
-
- /**
- * Indicates if the two given objects represent the roots of the compared element.
- *
- * @param obj1
- * the first element to determine if it's a root
- * @param obj2
- * the second element to determine if it's a root
- * @return true if the two given objects represent the roots of the compared element, false otherwise
- */
- private boolean areRoots(EObject obj1, EObject obj2) {
- return (obj1 == localRoot) && (obj2 == repositoryRoot);
- }
-
- /**
- * Indicates if the first session matches the second one.
- *
- * @param element1
- * the element to match
- * @param element2
- * the candidate element
- * @return true if the first session matches the second one, false otherwise
- * @throws FactoryException
- * - on error accessing features.
- */
- protected boolean areSimilarStructuredElements(IntentStructuredElement element1,
- IntentStructuredElement element2) throws FactoryException {
- boolean areSimilarStructuredElements = false;
-
- // 2 structured element are equal if :
- // they have the same title
- Block title1 = element1.getTitle();
- Block title2 = element2.getTitle();
-
- if (title1 != null && title2 != null) {
- return isSimilar(title1, title2);
- } else {
- // if both title are null, we make a content match
- if (title1 == null && title2 == null) {
- areSimilarStructuredElements = isSimilar(element1, element2, true);
- }
- }
- return areSimilarStructuredElements;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.mylyn.docs.intent.compare.match.StatisticBasedSimilarityChecker#contentSimilarity(org.eclipse.emf.ecore.EObject,
- * org.eclipse.emf.ecore.EObject)
- */
- @Override
- protected double contentSimilarity(EObject obj1, EObject obj2) throws FactoryException {
- if (obj1 instanceof IntentSubSectionContainer && obj2 instanceof IntentSubSectionContainer) {
- return 0.97;
- }
- return super.contentSimilarity(obj1, obj2);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.mylyn.docs.intent.compare.match.StatisticBasedSimilarityChecker#relationsSimilarity(org.eclipse.emf.ecore.EObject,
- * org.eclipse.emf.ecore.EObject)
- */
- @Override
- protected double relationsSimilarity(EObject obj1, EObject obj2) throws FactoryException {
- if (obj1 instanceof IntentSubSectionContainer && obj2 instanceof IntentSubSectionContainer) {
- final Double value = getSimilarityFromCache(obj1, obj2, 'r');
- double similarity = 0d;
- if (value != null) {
- similarity = value;
- } else {
- similarity = getIntentStructuredElementsSimilarity((IntentSubSectionContainer)obj1,
- (IntentSubSectionContainer)obj2);
- setSimilarityInCache(obj1, obj2, 'r', similarity);
- }
- return similarity;
- }
- return super.relationsSimilarity(obj1, obj2);
- }
-
- /**
- * Returns the similarity between intent structured elements.
- *
- * @param obj1
- * the first element
- * @param obj2
- * the second element
- * @return the similarity value
- * @throws FactoryException
- * if an error occurs accessing elements
- */
- private double getIntentStructuredElementsSimilarity(IntentSubSectionContainer obj1,
- IntentSubSectionContainer obj2) throws FactoryException {
- double numberOfTotalElements = obj1.getIntentContent().size();
- double numberOfCommonElements = 0;
- Collection<EObject> obj1Elements = Lists.newArrayList(obj1.getIntentContent());
-
- Collection<EObject> obj2Elements = Lists.newArrayList(obj2.getIntentContent());
-
- for (EObject obj2Element : obj2Elements) {
-
- Iterator<EObject> obj1ElementsIterator = obj1Elements.iterator();
- while (obj1ElementsIterator.hasNext()) {
- EObject obj1Element = obj1ElementsIterator.next();
-
- if (isSimilar(obj1Element, obj2Element)) {
- numberOfCommonElements++;
- obj1ElementsIterator.remove();
- break;
- }
- }
- }
- if (obj2.getIntentContent().size() > obj1.getIntentContent().size()) {
- numberOfTotalElements += obj2.getIntentContent().size() - obj1.getIntentContent().size();
- }
-
- if (numberOfTotalElements > 0) {
- double similarity = numberOfCommonElements / numberOfTotalElements;
- if (similarity >= 0.5 && numberOfTotalElements <= 4) {
- similarity = Math.max(similarity, 0.99);
- } else {
- if (similarity >= 0.5) {
- similarity = 0.5 + (numberOfCommonElements / (numberOfTotalElements * 2));
- }
- }
- return similarity;
- }
- return 1.0;
- }
-
- /**
- * Indicates if the first description bloc matches the second one.
- *
- * @param obj1
- * the description bloc to match
- * @param obj2
- * the candidate description bloc
- * @return true if the first description bloc matches the second one, false otherwise
- */
- private boolean areSimilarDescriptionBlocs(DescriptionBloc obj1, DescriptionBloc obj2) {
- // FIXME : first verify that both description blocs are part of the same DU
-
- // Two description blocs are equals if they have the same position in their container
- int positionInContainer1 = obj1.eContainer().eContents().indexOf(obj1);
- int positionInContainer2 = obj2.eContainer().eContents().indexOf(obj2);
-
- boolean haveSamePositionInContainer = positionInContainer1 == positionInContainer2;
- return haveSamePositionInContainer;
- }
-
- /**
- * Indicates if 2 paragraphs are equals.
- *
- * @param obj1
- * the paragraph to match
- * @param obj2
- * the candidate paragraph
- * @return true if the first pargraph matches the second one, false otherwise
- */
- private boolean areSimilarParagraphs(Paragraph obj1, Paragraph obj2) {
- LinkedHashSet<Text> obj1Texts = Sets
- .newLinkedHashSet(Iterables.filter(obj1.getContent(), Text.class));
- LinkedHashSet<Text> obj2Texts = Sets
- .newLinkedHashSet(Iterables.filter(obj2.getContent(), Text.class));
-
- String obj1AsString = "";
- for (Text t : obj1Texts) {
- obj1AsString += t.getData();
- }
-
- String obj2AsString = "";
- for (Text t : obj2Texts) {
- obj2AsString += t.getData();
- }
- return obj1AsString.equals(obj2AsString);
- }
-}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/match/SimilarityCheckerFromHead b/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/match/SimilarityCheckerFromHead
deleted file mode 100644
index ef5ed9b..0000000
--- a/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/match/SimilarityCheckerFromHead
+++ /dev/null
@@ -1,554 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Obeo 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:
- * Obeo - initial API and implementation
- * Victor Roldan Betancort - bug 352727, bug 360939
- *******************************************************************************/
-package org.eclipse.emf.compare.match.engine.internal;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.WeakHashMap;
-
-import org.eclipse.emf.compare.FactoryException;
-import org.eclipse.emf.compare.match.engine.AbstractSimilarityChecker;
-import org.eclipse.emf.compare.match.internal.statistic.NameSimilarity;
-import org.eclipse.emf.compare.match.internal.statistic.StructureSimilarity;
-import org.eclipse.emf.compare.match.statistic.MetamodelFilter;
-import org.eclipse.emf.ecore.EGenericType;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.resource.Resource;
-
-/**
- * A similarity checker using heuristics.
- *
- * @author <a href="mailto:cedric.brun@obeo.fr">Cedric Brun</a>
- */
-public class StatisticBasedSimilarityChecker extends AbstractSimilarityChecker {
- /** Used while computing similarity, this defines the general threshold. */
- private static final double GENERAL_THRESHOLD = 0.96d;
-
- /**
- * Minimal number of attributes an element must have for content comparison.
- */
- private static final int MIN_ATTRIBUTES_COUNT = 5;
-
- /**
- * This map is used to cache the name similarity. <code>Pair(Element1, Element2) => nameSimilarity</code>.
- *
- * @since 1.3
- */
- protected Map<String, Double> nameSimilarityCache;
-
- /**
- * This map is used to cache the value similarity.
- * <code>Pair(Element1, Element2) => valueSimilarity</code>.
- *
- * @since 1.3
- */
- protected Map<String, Double> valueSimilarityCache;
-
- /**
- * This map is used to cache the relation similarity.
- * <code>Pair(Element1, Element2) => relationSimilarity</code>.
- *
- * @since 1.3
- */
- protected Map<String, Double> relationSimilarityCache;
-
- /**
- * This map is used to cache the type similarity. <code>Pair(Element1, Element2) => typeSimilarity</code>.
- *
- * @since 1.3
- */
- protected Map<String, Double> typeSimilarityCache;
-
- /**
- * This map will allow us to cache the number of non-null features a given instance of EObject has.
- */
- private final Map<EObject, Integer> nonNullFeatureCounts = new HashMap<EObject, Integer>(20);
-
- /** We'll use this map to cache the uri fragments computed for each objects. */
- private final Map<EObject, String> uriFragmentCache = new WeakHashMap<EObject, String>(20);
-
- /**
- * This field is needed to keep the same behavior for clients having subclassed the generic match engine.
- */
- @Deprecated
- private GenericMatchEngineToCheckerBridge matchToCheckerBridge;
-
- /**
- * Create a new checker.
- *
- * @param mmFilter
- * a metamodel filter the checker can use to know whether a feature alwaas has the same value
- * or not in the models.
- * @param bridge
- * utility class to keep API compatibility.
- */
- public StatisticBasedSimilarityChecker(MetamodelFilter mmFilter, GenericMatchEngineToCheckerBridge bridge) {
- super(mmFilter);
- this.matchToCheckerBridge = bridge;
- initMetricsCaches();
- }
-
- /**
- * Initializes the different metrics caches.
- *
- * @since 1.3
- */
- protected void initMetricsCaches() {
- final int initialCapacity = 256;
- nameSimilarityCache = new HashMap<String, Double>(initialCapacity);
- valueSimilarityCache = new HashMap<String, Double>(initialCapacity);
- relationSimilarityCache = new HashMap<String, Double>(initialCapacity);
- typeSimilarityCache = new HashMap<String, Double>(initialCapacity);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isSimilar(EObject obj1, EObject obj2) throws FactoryException {
- boolean similar = false;
- final double almostEquals = 0.999999d;
-
- // Defines threshold constants to assume objects' similarity
- final double nameOnlyMetricThreshold = 0.7d;
- final double fewerAttributesNameThreshold = 0.8d;
- final double relationsThreshold = 0.9d;
- final double nameThreshold = 0.2d;
- final double contentThreshold = 0.9d;
- final double triWayThreshold = 0.9d;
- final double generalThreshold = GENERAL_THRESHOLD;
-
- // Computes some of the required metrics
- final double nameSimilarity = nameSimilarity(obj1, obj2);
- final boolean hasSameUri = hasSameUri(obj1, obj2);
- final int obj1NonNullFeatures = nonNullFeaturesCount(obj1);
- final int obj2NonNullFeatures = nonNullFeaturesCount(obj2);
-
- if (obj1 instanceof EGenericType || obj2 instanceof EGenericType) {
- similar = isSimilar(obj1.eContainer(), obj2.eContainer());
- } else if (nameSimilarity > almostEquals && hasSameUri) {
- similar = true;
- // softer tests if we don't have enough attributes to compare the
- // objects
- } else if (obj1NonNullFeatures == 1 && obj2NonNullFeatures == 1) {
- similar = nameSimilarity > nameOnlyMetricThreshold;
- } else if (nameSimilarity > fewerAttributesNameThreshold
- && obj1NonNullFeatures <= MIN_ATTRIBUTES_COUNT && obj2NonNullFeatures <= MIN_ATTRIBUTES_COUNT
- && typeSimilarity(obj1, obj2) > generalThreshold) {
- similar = true;
- } else {
- final double contentSimilarity = contentSimilarity(obj1, obj2);
- final double relationsSimilarity = relationsSimilarity(obj1, obj2);
-
- if (relationsSimilarity > almostEquals && hasSameUri && nameSimilarity > nameThreshold) {
- similar = true;
- } else if (contentSimilarity > almostEquals && relationsSimilarity > almostEquals) {
- similar = true;
- } else if (contentSimilarity > generalThreshold && relationsSimilarity > relationsThreshold
- && nameSimilarity > nameThreshold) {
- similar = true;
- } else if (relationsSimilarity > generalThreshold && contentSimilarity > contentThreshold) {
- similar = true;
- } else if (contentSimilarity > triWayThreshold && nameSimilarity > triWayThreshold
- && relationsSimilarity > triWayThreshold) {
- similar = true;
- } else if (contentSimilarity > generalThreshold && nameSimilarity > generalThreshold
- && typeSimilarity(obj1, obj2) > generalThreshold) {
- similar = true;
- }
- }
- return similar;
- }
-
- /**
- * This will compute the similarity between two {@link EObject}s' names.
- *
- * @param obj1
- * First of the two {@link EObject}s.
- * @param obj2
- * Second of the two {@link EObject}s.
- * @return <code>double</code> representing the similarity between the two {@link EObject}s' names. 0 <
- * value < 1.
- * @see NameSimilarity#nameSimilarityMetric(String, String)
- */
- protected double nameSimilarity(EObject obj1, EObject obj2) {
- double similarity = 0d;
- final Double value = getSimilarityFromCache(obj1, obj2, SimilarityKind.NAME);
- if (value != null) {
- similarity = value;
- } else {
- similarity = matchToCheckerBridge.nameSimilarity(obj1, obj2);
- setSimilarityInCache(obj1, obj2, SimilarityKind.NAME, similarity);
- }
- // fails silently, will return a similarity of 0d
- return similarity;
- }
-
- /**
- * Returns an absolute comparison metric between the two given {@link EObject}s.
- *
- * @param obj1
- * The first {@link EObject} to compare.
- * @param obj2
- * Second of the {@link EObject}s to compare.
- * @return An absolute comparison metric. 0 < value < 1.
- * @throws FactoryException
- * Thrown if we cannot compute the content similarity.
- */
- @Override
- public double absoluteMetric(EObject obj1, EObject obj2) throws FactoryException {
- final double nameSimilarity = nameSimilarity(obj1, obj2);
- final double relationsSimilarity = relationsSimilarity(obj1, obj2);
- double sameUri = 0d;
- if (hasSameUri(obj1, obj2)) {
- sameUri = 1d;
- }
- final double positionSimilarity = relationsSimilarity / 2d + sameUri / 2d;
-
- final double contentWeight = 0.5d;
-
- if (nonNullFeaturesCount(obj1) > MIN_ATTRIBUTES_COUNT
- && nonNullFeaturesCount(obj2) > MIN_ATTRIBUTES_COUNT) {
- final double nameWeight = 0.4d;
- final double positionWeight = 0.4d;
- final double contentSimilarity = contentSimilarity(obj1, obj2);
- // Computing type similarity really is time expensive
- // double typeSimilarity = typeSimilarity(obj1, obj2);
- return (contentSimilarity * contentWeight + nameSimilarity * nameWeight + positionSimilarity
- * positionWeight)
- / (contentWeight + nameWeight + positionWeight);
- }
- // we didn't have enough features to compute an accurate metric
- final double nameWeight = 0.8d;
- final double positionWeight = 0.2d;
-
- return (nameSimilarity * nameWeight + positionSimilarity * positionWeight)
- / (nameWeight + positionWeight);
- }
-
- /**
- * This will compute the similarity between two {@link EObject}s' types.
- *
- * @param obj1
- * First of the two {@link EObject}s.
- * @param obj2
- * Second of the two {@link EObject}s.
- * @return <code>double</code> representing the similarity between the two {@link EObject}s' types. 0 <
- * value < 1.
- * @throws FactoryException
- * Thrown if we cannot compute the type similarity metrics.
- * @see StructureSimilarity#typeSimilarityMetric(EObject, EObject)
- */
- private double typeSimilarity(EObject obj1, EObject obj2) throws FactoryException {
- double similarity = 0d;
- final Double value = getSimilarityFromCache(obj1, obj2, SimilarityKind.TYPE);
- if (value != null) {
- similarity = value;
- } else {
- similarity = StructureSimilarity.typeSimilarityMetric(obj1, obj2);
- setSimilarityInCache(obj1, obj2, SimilarityKind.TYPE, similarity);
- }
- return similarity;
- }
-
- /**
- * This will compute the similarity between two {@link EObject}s' contents.
- *
- * @param obj1
- * First of the two {@link EObject}s.
- * @param obj2
- * Second of the two {@link EObject}s.
- * @return <code>double</code> representing the similarity between the two {@link EObject}s' contents. 0
- * < value < 1.
- * @throws FactoryException
- * Thrown if we cannot compute the {@link EObject}s' contents similarity metrics.
- */
- protected double contentSimilarity(EObject obj1, EObject obj2) throws FactoryException {
- double similarity = 0d;
- Double value = getSimilarityFromCache(obj1, obj2, SimilarityKind.VALUE);
- // This might be the counter check, invert the two
- if (value == null) {
- value = getSimilarityFromCache(obj2, obj1, SimilarityKind.VALUE);
- }
- if (value != null) {
- similarity = value;
- } else if (filter.getFilteredFeatures(obj1).size() < MIN_ATTRIBUTES_COUNT
- || filter.getFilteredFeatures(obj2).size() < MIN_ATTRIBUTES_COUNT) {
- similarity = matchToCheckerBridge.contentSimilarity(obj1, obj2);
- setSimilarityInCache(obj1, obj2, SimilarityKind.VALUE, similarity);
- } else {
- similarity = NameSimilarity.nameSimilarityMetric(NameSimilarity.contentValue(obj1, filter),
- NameSimilarity.contentValue(obj2, filter));
- setSimilarityInCache(obj1, obj2, SimilarityKind.VALUE, similarity);
- }
- return similarity;
- }
-
- /**
- * Counts all the {@link EStructuralFeature features} of the given {@link EObject} that are
- * <code>null</code> or initialized to the empty {@link String} "".
- *
- * @param eobj
- * {@link EObject} we need to count the empty features of.
- * @return The number of features not initialized to <code>null</code> or the empty String.
- */
- private int nonNullFeaturesCount(EObject eobj) {
- Integer nonNullFeatures = nonNullFeatureCounts.get(eobj);
- if (nonNullFeatures == null) {
- final int count = countNonNullFeatures(eobj);
- nonNullFeatures = Integer.valueOf(count);
- nonNullFeatureCounts.put(eobj, nonNullFeatures);
- }
- return nonNullFeatures.intValue();
- }
-
- /**
- * Count non null features in an EObject.
- *
- * @param eobj
- * the EObject.
- * @return the number of filtered non null features.
- */
- private int countNonNullFeatures(EObject eobj) {
- int count = 0;
- final Iterator<EStructuralFeature> features = filter.getFilteredFeatures(eobj).iterator();
- while (features.hasNext()) {
- final EStructuralFeature feature = features.next();
- if (!feature.isDerived()) {
- final Object value = eobj.eGet(feature);
- if (feature.isMany()) {
- if (((Collection<?>)value).size() > 0) {
- count++;
- }
- } else {
- if (value != null && !"".equals(value.toString())) { //$NON-NLS-1$
- count++;
- }
- }
- }
- }
- return count;
- }
-
- /**
- * Computes an unique key between to {@link EObject}s to store their similarity in cache.
- * <p>
- * <code>similarityKind</code> must be one of
- * <ul>
- * <li>{@link #NAME_SIMILARITY}</li>
- * <li>{@link #TYPE_SIMILARITY}</li>
- * <li>{@link #VALUE_SIMILARITY}</li>
- * <li>{@link #RELATION_SIMILARITY}</li>
- * </ul>
- * </p>
- *
- * @param obj1
- * First of the two {@link EObject}s.
- * @param obj2
- * Second of the two {@link EObject}s.
- * @param similarityKind
- * Kind of similarity this key will represent in cache.
- * @return Unique key for the similarity cache.
- * @since 1.3
- */
- protected static String pairHashCode(EObject obj1, EObject obj2) {
- final StringBuilder hash = new StringBuilder();
-
- final int obj1Hash = obj1.hashCode();
- final int obj2Hash = obj2.hashCode();
- if (obj1Hash < obj2Hash) {
- hash.append(String.valueOf(obj1Hash)).append(String.valueOf(obj2Hash));
- } else {
- hash.append(String.valueOf(obj2Hash)).append(String.valueOf(obj1Hash));
- }
-
- return hash.toString();
- }
-
- /**
- * Returns the given similarity between the two given {@link EObject}s as it is stored in cache.<br/>
- * <p>
- * <code>similarityKind</code> must be one of
- * <ul>
- * <li>{@link #NAME_SIMILARITY}</li>
- * <li>{@link #TYPE_SIMILARITY}</li>
- * <li>{@link #VALUE_SIMILARITY}</li>
- * <li>{@link #RELATION_SIMILARITY}</li>
- * </ul>
- * </p>
- *
- * @param obj1
- * First of the two {@link EObject}s we seek the similarity for.
- * @param obj2
- * Second of the two {@link EObject}s we seek the similarity for.
- * @param similarityKind
- * Kind of similarity to get.
- * @return The similarity as described by <code>similarityKind</code> as it is stored in cache for the two
- * given {@link EObject}s.
- * @since 1.3
- */
- protected Double getSimilarityFromCache(EObject obj1, EObject obj2, SimilarityKind similarityKind) {
- final Map<String, Double> cache = getCache(similarityKind);
-
- return cache.get(pairHashCode(obj1, obj2));
- }
-
- /**
- * Returns the cache for the given similarity kind.
- *
- * @param kind
- * The kind of similarity for which we need the cache.
- * @return The cache for the given similarity kind.
- * @since 1.3
- */
- protected Map<String, Double> getCache(SimilarityKind kind) {
- final Map<String, Double> cache;
- switch (kind) {
- case NAME:
- cache = nameSimilarityCache;
- break;
- case RELATION:
- cache = relationSimilarityCache;
- break;
- case TYPE:
- cache = typeSimilarityCache;
- break;
- case VALUE:
- cache = valueSimilarityCache;
- break;
- default:
- // Should never happen
- cache = valueSimilarityCache;
- }
- return cache;
- }
-
- /**
- * Checks whether the two given {@link EObject} have the same URI.
- *
- * @param obj1
- * First of the two {@link EObject} we're comparing.
- * @param obj2
- * Second {@link EObject} we're comparing.
- * @return <code>True</code> if the {@link EObject}s have the same URI, <code>False</code> otherwise.
- */
- protected boolean hasSameUri(EObject obj1, EObject obj2) {
- if (obj1.eResource() != null && obj2.eResource() != null) {
- String obj1URIFragment = uriFragmentCache.get(obj1);
- if (obj1URIFragment == null) {
- obj1URIFragment = obj1.eResource().getURIFragment(obj1);
- uriFragmentCache.put(obj1, obj1URIFragment);
- }
- String obj2URIFragment = uriFragmentCache.get(obj2);
- if (obj2URIFragment == null) {
- obj2URIFragment = obj2.eResource().getURIFragment(obj2);
- uriFragmentCache.put(obj2, obj2URIFragment);
- }
- return obj1URIFragment.equals(obj2URIFragment);
- }
- return false;
- }
-
- /**
- * This will compute the similarity between two {@link EObject}s' relations.
- *
- * @param obj1
- * First of the two {@link EObject}s.
- * @param obj2
- * Second of the two {@link EObject}s.
- * @return <code>double</code> representing the similarity between the two {@link EObject}s' relations. 0
- * < value < 1.
- * @throws FactoryException
- * Thrown if we cannot compute the relations' similarity metrics.
- * @see StructureSimilarity#relationsSimilarityMetric(EObject, EObject, MetamodelFilter)
- */
- private double relationsSimilarity(EObject obj1, EObject obj2) throws FactoryException {
- double similarity = 0d;
- final Double value = getSimilarityFromCache(obj1, obj2, SimilarityKind.RELATION);
- if (value != null) {
- similarity = value;
- } else {
- similarity = StructureSimilarity.relationsSimilarityMetric(obj1, obj2, filter);
- setSimilarityInCache(obj1, obj2, SimilarityKind.RELATION, similarity);
- }
- return similarity;
- }
-
- /**
- * Stores in cache the given similarity between the two given {@link EObject}s.<br/>
- * <p>
- * <code>similarityKind</code> must be one of
- * <ul>
- * <li>{@link #NAME_SIMILARITY}</li>
- * <li>{@link #TYPE_SIMILARITY}</li>
- * <li>{@link #VALUE_SIMILARITY}</li>
- * <li>{@link #RELATION_SIMILARITY}</li>
- * </ul>
- * </p>
- *
- * @param obj1
- * First of the two {@link EObject}s we're setting the similarity for.
- * @param obj2
- * Second of the two {@link EObject}s we're setting the similarity for.
- * @param similarityKind
- * Kind of similarity to set.
- * @param similarity
- * Value of the similarity between the two {@link EObject}s.
- * @since 1.3
- */
- protected void setSimilarityInCache(EObject obj1, EObject obj2, SimilarityKind similarityKind,
- double similarity) {
- final Map<String, Double> cache = getCache(similarityKind);
-
- cache.put(pairHashCode(obj1, obj2), Double.valueOf(similarity));
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void init(EObject leftObject, EObject rightObject) throws FactoryException {
- // this similarity checker needs no initialization.
-
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void init(Resource leftResource, Resource rightResource) throws FactoryException {
- // this similarity checker needs no initialization.
- }
-
- /**
- * Converts the legacy strings into a regular enumeration.
- *
- * @author Victor Roldan Betancort
- * @since 1.3
- */
- protected static enum SimilarityKind {
- /** This constant is used as key for the buffering of type similarity. */
- TYPE,
-
- /** This constant is used as key for the buffering of name similarity. */
- NAME,
-
- /** This constant is used as key for the buffering of relations similarity. */
- RELATION,
-
- /** This constant is used as key for the buffering of value similarity. */
- VALUE
- }
-}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/match/StatisticBasedSimilarityChecker.java b/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/match/StatisticBasedSimilarityChecker.java
deleted file mode 100644
index 27dd9aa..0000000
--- a/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/match/StatisticBasedSimilarityChecker.java
+++ /dev/null
@@ -1,473 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Obeo.
- * 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:
- * Obeo - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.docs.intent.compare.match;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.WeakHashMap;
-
-import org.eclipse.emf.compare.FactoryException;
-import org.eclipse.emf.compare.match.EMFCompareMatchMessages;
-import org.eclipse.emf.compare.match.engine.AbstractSimilarityChecker;
-import org.eclipse.emf.compare.match.internal.statistic.NameSimilarity;
-import org.eclipse.emf.compare.match.internal.statistic.StructureSimilarity;
-import org.eclipse.emf.compare.match.statistic.MetamodelFilter;
-import org.eclipse.emf.compare.util.EMFCompareMap;
-import org.eclipse.emf.ecore.EGenericType;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.resource.Resource;
-
-/**
- * A similarity checker using heuristics.
- *
- * @author <a href="mailto:cedric.brun@obeo.fr">Cedric Brun</a>
- */
-public class StatisticBasedSimilarityChecker extends AbstractSimilarityChecker {
-
- /** Used while computing similarity, this defines the general threshold. */
- private static final double GENERAL_THRESHOLD = 0.96d;
-
- /** This constant is used as key for the buffering of type similarity. */
- private static final char TYPE_SIMILARITY = 't';
-
- /**
- * Minimal number of attributes an element must have for content comparison.
- */
- private static final int MIN_ATTRIBUTES_COUNT = 1;
-
- /** This constant is used as key for the buffering of name similarity. */
- private static final char NAME_SIMILARITY = 'n';
-
- /** This constant is used as key for the buffering of relations similarity. */
- private static final char RELATION_SIMILARITY = 'r';
-
- /** This constant is used as key for the buffering of value similarity. */
- private static final char VALUE_SIMILARITY = 'v';
-
- /**
- * This map is used to cache the comparison results Pair(Element1, Element2) => [nameSimilarity,
- * valueSimilarity, relationSimilarity, TypeSimilarity].
- */
- private final Map<String, Double> metricsCache = new EMFCompareMap<String, Double>();
-
- /**
- * This map will allow us to cache the number of non-null features a given instance of EObject has.
- */
- private final Map<EObject, Integer> nonNullFeatureCounts = new HashMap<EObject, Integer>(20);
-
- /** We'll use this map to cache the uri fragments computed for each objects. */
- private final Map<EObject, String> uriFragmentCache = new WeakHashMap<EObject, String>(20);
-
- /**
- * This field is needed to keep the same behavior for clients having subclassed the generic match engine.
- */
- @Deprecated
- private AbstractGenericMatchEngineToCheckerBridge bridge;
-
- /**
- * Create a new checker.
- *
- * @param filter
- * a metamodel filter the checker can use to know whether a feature alwaas has the same value
- * or not in the models.
- * @param bridge
- * utility class to keep API compatibility.
- */
- public StatisticBasedSimilarityChecker(MetamodelFilter filter,
- AbstractGenericMatchEngineToCheckerBridge bridge) {
- super(filter);
- this.bridge = bridge;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isSimilar(EObject obj1, EObject obj2) throws FactoryException {
- boolean similar = false;
- final double almostEquals = 0.999999d;
-
- // Defines threshold constants to assume objects' similarity
-
- final double relationsThreshold = 0.9d;
- final double generalThreshold = GENERAL_THRESHOLD;
- final double contentThreshold = 0.9d;
-
- // Modified constants for Intent :
- final double nameOnlyMetricThreshold = 0.1d; // previously 0.7d
- final double triWayThreshold = 0.5d; // previously 0.9d
- final double fewerAttributesNameThreshold = 0.2d; // previously 0.8d
- final double nameThreshold = 0.1d; // previously 0.2d
-
- // Computes some of the required metrics
- final double nameSimilarity = nameSimilarity(obj1, obj2);
- // final boolean hasSameUri = hasSameUri(obj1, obj2);
- final int obj1NonNullFeatures = nonNullFeaturesCount(obj1);
- final int obj2NonNullFeatures = nonNullFeaturesCount(obj2);
-
- if (obj1 instanceof EGenericType || obj2 instanceof EGenericType) {
- similar = isSimilar(obj1.eContainer(), obj2.eContainer());
- } else if (obj1NonNullFeatures == 1 && obj2NonNullFeatures == 1) {
- similar = nameSimilarity > nameOnlyMetricThreshold;
- } else if (nameSimilarity > fewerAttributesNameThreshold
- && obj1NonNullFeatures <= MIN_ATTRIBUTES_COUNT && obj2NonNullFeatures <= MIN_ATTRIBUTES_COUNT
- && typeSimilarity(obj1, obj2) > generalThreshold) {
- similar = true;
- } else {
- final double contentSimilarity = contentSimilarity(obj1, obj2);
- final double relationsSimilarity = relationsSimilarity(obj1, obj2);
-
- if (relationsSimilarity > almostEquals && nameSimilarity > nameThreshold) {
- similar = true;
- } else if (contentSimilarity > almostEquals && relationsSimilarity > almostEquals) {
- similar = true;
- } else if (contentSimilarity > generalThreshold && relationsSimilarity > relationsThreshold
- && nameSimilarity > nameThreshold) {
- similar = true;
- } else if (relationsSimilarity > generalThreshold && contentSimilarity > contentThreshold) {
- similar = true;
- } else if (contentSimilarity > triWayThreshold && nameSimilarity > triWayThreshold
- && relationsSimilarity > triWayThreshold) {
- similar = true;
- } else if (contentSimilarity > generalThreshold && nameSimilarity > generalThreshold
- && typeSimilarity(obj1, obj2) > generalThreshold) {
- similar = true;
- }
- }
- return similar;
- }
-
- /**
- * This will compute the similarity between two {@link EObject}s' names.
- *
- * @param obj1
- * First of the two {@link EObject}s.
- * @param obj2
- * Second of the two {@link EObject}s.
- * @return <code>double</code> representing the similarity between the two {@link EObject}s' names. 0 <
- * value < 1.
- * @see NameSimilarity#nameSimilarityMetric(String, String)
- */
- protected double nameSimilarity(EObject obj1, EObject obj2) {
- double similarity = 0d;
- final Double value = getSimilarityFromCache(obj1, obj2, NAME_SIMILARITY);
- if (value != null) {
- similarity = value;
- } else {
- similarity = bridge.nameSimilarity(obj1, obj2);
- setSimilarityInCache(obj1, obj2, NAME_SIMILARITY, similarity);
- }
- // fails silently, will return a similarity of 0d
- return similarity;
- }
-
- /**
- * Returns an absolute comparison metric between the two given {@link EObject}s.
- *
- * @param obj1
- * The first {@link EObject} to compare.
- * @param obj2
- * Second of the {@link EObject}s to compare.
- * @return An absolute comparison metric. 0 < value < 1.
- * @throws FactoryException
- * Thrown if we cannot compute the content similarity.
- */
- @Override
- public double absoluteMetric(EObject obj1, EObject obj2) throws FactoryException {
- final double nameSimilarity = nameSimilarity(obj1, obj2);
- final double relationsSimilarity = relationsSimilarity(obj1, obj2);
- double sameUri = 0d;
- if (hasSameUri(obj1, obj2)) {
- sameUri = 1d;
- }
- final double positionSimilarity = relationsSimilarity / 2d + sameUri / 2d;
-
- final double contentWeight = 0.5d;
-
- if (nonNullFeaturesCount(obj1) > MIN_ATTRIBUTES_COUNT
- && nonNullFeaturesCount(obj2) > MIN_ATTRIBUTES_COUNT) {
- final double nameWeight = 0.4d;
- final double positionWeight = 0.4d;
- final double contentSimilarity = contentSimilarity(obj1, obj2);
-
- // Computing type similarity really is time expensive
- // double typeSimilarity = typeSimilarity(obj1, obj2);
- return (contentSimilarity * contentWeight + nameSimilarity * nameWeight + positionSimilarity
- * positionWeight)
- / (contentWeight + nameWeight + positionWeight);
- }
- // we didn't have enough features to compute an accurate metric
- final double nameWeight = 0.8d;
- final double positionWeight = 0.2d;
- return (nameSimilarity * nameWeight + positionSimilarity * positionWeight)
- / (nameWeight + positionWeight);
- }
-
- /**
- * This will compute the similarity between two {@link EObject}s' types.
- *
- * @param obj1
- * First of the two {@link EObject}s.
- * @param obj2
- * Second of the two {@link EObject}s.
- * @return <code>double</code> representing the similarity between the two {@link EObject}s' types. 0 <
- * value < 1.
- * @throws FactoryException
- * Thrown if we cannot compute the type similarity metrics.
- * @see StructureSimilarity#typeSimilarityMetric(EObject, EObject)
- */
- private double typeSimilarity(EObject obj1, EObject obj2) throws FactoryException {
- double similarity = 0d;
- final Double value = getSimilarityFromCache(obj1, obj2, TYPE_SIMILARITY);
- if (value != null) {
- similarity = value;
- } else {
- similarity = StructureSimilarity.typeSimilarityMetric(obj1, obj2);
- setSimilarityInCache(obj1, obj2, TYPE_SIMILARITY, similarity);
- }
- return similarity;
- }
-
- /**
- * This will compute the similarity between two {@link EObject}s' contents.
- *
- * @param obj1
- * First of the two {@link EObject}s.
- * @param obj2
- * Second of the two {@link EObject}s.
- * @return <code>double</code> representing the similarity between the two {@link EObject}s' contents. 0
- * < value < 1.
- * @throws FactoryException
- * Thrown if we cannot compute the {@link EObject}s' contents similarity metrics.
- */
- protected double contentSimilarity(EObject obj1, EObject obj2) throws FactoryException {
- double similarity = 0d;
- Double value = getSimilarityFromCache(obj1, obj2, VALUE_SIMILARITY);
- // This might be the counter check, invert the two
- if (value == null) {
- value = getSimilarityFromCache(obj2, obj1, VALUE_SIMILARITY);
- }
- if (value != null) {
- similarity = value;
- } else if (filter.getFilteredFeatures(obj1).size() < MIN_ATTRIBUTES_COUNT
- || filter.getFilteredFeatures(obj2).size() < MIN_ATTRIBUTES_COUNT) {
-
- similarity = bridge.contentSimilarity(obj1, obj2);
- setSimilarityInCache(obj1, obj2, VALUE_SIMILARITY, similarity);
- } else {
-
- similarity = NameSimilarity.nameSimilarityMetric(NameSimilarity.contentValue(obj1, filter),
- NameSimilarity.contentValue(obj2, filter));
- setSimilarityInCache(obj1, obj2, VALUE_SIMILARITY, similarity);
- }
- return similarity;
- }
-
- /**
- * Counts all the {@link EStructuralFeature features} of the given {@link EObject} that are
- * <code>null</code> or initialized to the empty {@link String} "".
- *
- * @param eobj
- * {@link EObject} we need to count the empty features of.
- * @return The number of features not initialized to <code>null</code> or the empty String.
- */
- private int nonNullFeaturesCount(EObject eobj) {
- Integer nonNullFeatures = nonNullFeatureCounts.get(eobj);
- if (nonNullFeatures == null) {
- final int count = countNonNullFeatures(eobj);
- nonNullFeatures = Integer.valueOf(count);
- nonNullFeatureCounts.put(eobj, nonNullFeatures);
- }
- return nonNullFeatures.intValue();
- }
-
- /**
- * Count non null features in an EObject.
- *
- * @param eobj
- * the EObject.
- * @return the number of filtered non null features.
- */
- private int countNonNullFeatures(EObject eobj) {
-
- int count = 0;
- final Iterator<EStructuralFeature> features = filter.getFilteredFeatures(eobj).iterator();
- while (features.hasNext()) {
- final EStructuralFeature feature = features.next();
- if (!feature.isDerived()) {
- final Object value = eobj.eGet(feature);
- if (feature.isMany()) {
- if (((Collection<?>)value).size() > 0) {
- count++;
- }
- } else {
- if (value != null && !"".equals(value.toString())) { //$NON-NLS-1$
- count++;
- }
- }
- }
- }
- return count;
- }
-
- /**
- * Computes an unique key between to {@link EObject}s to store their similarity in cache.
- * <p>
- * <code>similarityKind</code> must be one of
- * <ul>
- * <li>{@link #NAME_SIMILARITY}</li>
- * <li>{@link #TYPE_SIMILARITY}</li>
- * <li>{@link #VALUE_SIMILARITY}</li>
- * <li>{@link #RELATION_SIMILARITY}</li>
- * </ul>
- * </p>
- *
- * @param obj1
- * First of the two {@link EObject}s.
- * @param obj2
- * Second of the two {@link EObject}s.
- * @param similarityKind
- * Kind of similarity this key will represent in cache.
- * @return Unique key for the similarity cache.
- */
- private String pairHashCode(EObject obj1, EObject obj2, char similarityKind) {
- if (similarityKind == NAME_SIMILARITY || similarityKind == TYPE_SIMILARITY
- || similarityKind == VALUE_SIMILARITY || similarityKind == RELATION_SIMILARITY) {
- final StringBuilder hash = new StringBuilder();
- hash.append(similarityKind).append(obj1.hashCode()).append(obj2.hashCode());
- return hash.toString();
- }
- throw new IllegalArgumentException(EMFCompareMatchMessages.getString(
- "DifferencesServices.illegalSimilarityKind", similarityKind)); //$NON-NLS-1$
- }
-
- /**
- * Returns the given similarity between the two given {@link EObject}s as it is stored in cache.<br/>
- * <p>
- * <code>similarityKind</code> must be one of
- * <ul>
- * <li>{@link #NAME_SIMILARITY}</li>
- * <li>{@link #TYPE_SIMILARITY}</li>
- * <li>{@link #VALUE_SIMILARITY}</li>
- * <li>{@link #RELATION_SIMILARITY}</li>
- * </ul>
- * </p>
- *
- * @param obj1
- * First of the two {@link EObject}s we seek the similarity for.
- * @param obj2
- * Second of the two {@link EObject}s we seek the similarity for.
- * @param similarityKind
- * Kind of similarity to get.
- * @return The similarity as described by <code>similarityKind</code> as it is stored in cache for the two
- * given {@link EObject}s.
- */
- protected Double getSimilarityFromCache(EObject obj1, EObject obj2, char similarityKind) {
- return metricsCache.get(pairHashCode(obj1, obj2, similarityKind));
- }
-
- /**
- * Checks wether the two given {@link EObject} have the same URI.
- *
- * @param obj1
- * First of the two {@link EObject} we're comparing.
- * @param obj2
- * Second {@link EObject} we're comparing.
- * @return <code>True</code> if the {@link EObject}s have the same URI, <code>False</code> otherwise.
- */
- private boolean hasSameUri(EObject obj1, EObject obj2) {
- if (obj1.eResource() != null && obj2.eResource() != null) {
- String obj1URIFragment = uriFragmentCache.get(obj1);
- if (obj1URIFragment == null) {
- obj1URIFragment = obj1.eResource().getURIFragment(obj1);
- uriFragmentCache.put(obj1, obj1URIFragment);
- }
- String obj2URIFragment = uriFragmentCache.get(obj2);
- if (obj2URIFragment == null) {
- obj2URIFragment = obj2.eResource().getURIFragment(obj2);
- uriFragmentCache.put(obj2, obj2URIFragment);
- }
- return obj1URIFragment.equals(obj2URIFragment);
- }
- return false;
- }
-
- /**
- * This will compute the similarity between two {@link EObject}s' relations.
- *
- * @param obj1
- * First of the two {@link EObject}s.
- * @param obj2
- * Second of the two {@link EObject}s.
- * @return <code>double</code> representing the similarity between the two {@link EObject}s' relations. 0
- * < value < 1.
- * @throws FactoryException
- * Thrown if we cannot compute the relations' similarity metrics.
- * @see StructureSimilarity#relationsSimilarityMetric(EObject, EObject, MetamodelFilter)
- */
- protected double relationsSimilarity(EObject obj1, EObject obj2) throws FactoryException {
- double similarity = 0d;
- final Double value = getSimilarityFromCache(obj1, obj2, RELATION_SIMILARITY);
- if (value != null) {
- similarity = value;
- } else {
- similarity = StructureSimilarity.relationsSimilarityMetric(obj1, obj2, filter);
- setSimilarityInCache(obj1, obj2, RELATION_SIMILARITY, similarity);
- }
- return similarity;
- }
-
- /**
- * Stores in cache the given similarity between the two given {@link EObject}s.<br/>
- * <p>
- * <code>similarityKind</code> must be one of
- * <ul>
- * <li>{@link #NAME_SIMILARITY}</li>
- * <li>{@link #TYPE_SIMILARITY}</li>
- * <li>{@link #VALUE_SIMILARITY}</li>
- * <li>{@link #RELATION_SIMILARITY}</li>
- * </ul>
- * </p>
- *
- * @param obj1
- * First of the two {@link EObject}s we're setting the similarity for.
- * @param obj2
- * Second of the two {@link EObject}s we're setting the similarity for.
- * @param similarityKind
- * Kind of similarity to set.
- * @param similarity
- * Value of the similarity between the two {@link EObject}s.
- */
- protected void setSimilarityInCache(EObject obj1, EObject obj2, char similarityKind, double similarity) {
- metricsCache.put(pairHashCode(obj1, obj2, similarityKind), new Double(similarity));
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void init(EObject leftObject, EObject rightObject) throws FactoryException {
- // this similarity checker needs no initialization.
-
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void init(Resource leftResource, Resource rightResource) throws FactoryException {
- // this similarity checker needs no initialization.
- }
-
-}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/match/StringDistanceUtils.java b/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/match/StringDistanceUtils.java
new file mode 100644
index 0000000..9772783
--- /dev/null
+++ b/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/match/StringDistanceUtils.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.mylyn.docs.intent.compare.match;
+
+import org.eclipse.emf.compare.utils.DiffUtil;
+
+/**
+ * String distance computation utilities.
+ *
+ * @author <a href="mailto:william.piers@obeo.fr">William Piers</a>
+ */
+public final class StringDistanceUtils {
+
+ private static final int DEFAULT_MAX_STRING_DISTANCE = 500;
+
+ private static final double DEFAULT_STRING_SIZE_DISTANCE_IMPACT = 0.7;
+
+ private static final double DEFAULT_STRING_DICE_DISTANCE_IMPACT = 0.3;
+
+ /**
+ * Prevents instantiation.
+ */
+ private StringDistanceUtils() {
+ }
+
+ /**
+ * Returns the distance between two strings.
+ *
+ * @param a
+ * the first string
+ * @param b
+ * the second string
+ * @return the distance between two strings
+ */
+ public static int getStringDistance(String a, String b) {
+ return getStringDistance(a, b, DEFAULT_STRING_DICE_DISTANCE_IMPACT,
+ DEFAULT_STRING_SIZE_DISTANCE_IMPACT);
+ }
+
+ /**
+ * Returns the distance between two strings. Note: diceDistanceImpact + sizeDistanceImpact = 1
+ *
+ * @param a
+ * the first string
+ * @param b
+ * the second string
+ * @param diceDistanceImpact
+ * the impact of the diceCoefficient
+ * @param sizeDistanceImpact
+ * the impact of the size distance
+ * @return the distance between two strings
+ */
+ public static int getStringDistance(String a, String b, double diceDistanceImpact,
+ double sizeDistanceImpact) {
+ if (diceDistanceImpact + sizeDistanceImpact != 1) {
+ throw new AssertionError("dice and size impacts sum must be equal to 1, currently "
+ + diceDistanceImpact + sizeDistanceImpact);
+ }
+ int res = DEFAULT_MAX_STRING_DISTANCE;
+ if (a != null && b != null) {
+ double sizeCoeff = 1 - (2d * Math.abs(a.length() - b.length())) / (a.length() + b.length());
+ double diceCoefficient = DiffUtil.diceCoefficient(a, b);
+ double average = diceCoefficient * diceDistanceImpact + sizeCoeff * sizeDistanceImpact;
+ res = (int)((1 - average) * DEFAULT_MAX_STRING_DISTANCE);
+ } else if (a == null && b == null) {
+ res = 0;
+ }
+ return res;
+ }
+}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/merge/IntentMerger.java b/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/merge/IntentMerger.java
deleted file mode 100644
index 1298f2d..0000000
--- a/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/merge/IntentMerger.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Obeo.
- * 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:
- * Obeo - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.docs.intent.compare.merge;
-
-import org.eclipse.emf.compare.diff.merge.DefaultMerger;
-
-/**
- * Merger for Intent elements.
- *
- * @author <a href="mailto:alex.lagarde@obeo.fr">Alex Lagarde</a>
- */
-public class IntentMerger extends DefaultMerger {
-
- /**
- * IntentMerger constructor.
- */
- public IntentMerger() {
-
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.emf.compare.diff.merge.DefaultMerger#canUndoInTarget()
- */
- @Override
- public boolean canUndoInTarget() {
- return true;
- }
-}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/scope/IntentComparisonScope.java b/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/scope/IntentComparisonScope.java
new file mode 100644
index 0000000..a6920db
--- /dev/null
+++ b/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/scope/IntentComparisonScope.java
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.mylyn.docs.intent.compare.scope;
+
+import com.google.common.collect.ForwardingIterator;
+import com.google.common.collect.Iterators;
+
+import java.util.Iterator;
+
+import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.compare.scope.DefaultComparisonScope;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+/**
+ * The comparison scope for intent documents. Derived from FilterComparisonScope: resolve content proxies.
+ *
+ * @see org.eclipse.emf.compare.scope.FilterComparisonScope
+ * @author <a href="mailto:william.piers@obeo.fr">William Piers</a>
+ */
+public class IntentComparisonScope extends DefaultComparisonScope {
+
+ /**
+ * Creates the scope from the given parameters.
+ *
+ * @param left
+ * the left object
+ * @param right
+ * the right object
+ */
+ public IntentComparisonScope(Notifier left, Notifier right) {
+ super(left, right, null);
+ }
+
+ /**
+ * {@inheritDoc}
+ * <p>
+ * This default implementation will return all direct and indirect content of the given {@link EObject},
+ * filtering out those {@link EObject}s that do not match {@link #eObjectContentFilter}.
+ * </p>
+ *
+ * @see org.eclipse.emf.compare.scope.IComparisonScope#getChildren(org.eclipse.emf.ecore.EObject)
+ */
+ public Iterator<? extends EObject> getChildren(EObject eObject) {
+ if (eObject == null) {
+ return Iterators.emptyIterator();
+ }
+ // original instruction (@see
+ // org.eclipse.emf.compare.scope.FilterComparisonScope.getCoveredResources(ResourceSet))
+ // final Iterator<EObject> properContent = EcoreUtil.getAllProperContents(eObject, false);
+
+ // <modified>
+ final Iterator<EObject> properContent = EcoreUtil.getAllContents(eObject, false);
+ // </modified>
+
+ final Iterator<EObject> filter = Iterators.filter(properContent, eObjectContentFilter);
+ final Iterator<EObject> uriInitializingIt = new URIInitializingIterator<EObject>(eObject, filter);
+ return Iterators.unmodifiableIterator(uriInitializingIt);
+ }
+
+ /**
+ * This iterator enables to add in the iteration the initialization of the namespace and resource uris
+ * set.
+ *
+ * @author <a href="mailto:cedric.notot@obeo.fr">Cedric Notot</a>
+ * @param <T>
+ * The kind of object to iterate on.
+ */
+ private class URIInitializingIterator<T> extends ForwardingIterator<T> {
+
+ /** The origin iterator. */
+ private Iterator<T> delegate;
+
+ /**
+ * Constructor.
+ *
+ * @param delegate
+ * The origin iterator.
+ */
+ public URIInitializingIterator(Iterator<T> delegate) {
+ this.delegate = delegate;
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param resource
+ * The resource containing the elements to iterate on.
+ * @param delegate
+ * The origin iterator.
+ */
+ public URIInitializingIterator(Resource resource, Iterator<T> delegate) {
+ this.delegate = delegate;
+ addUri(resource);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param eObject
+ * The EObject containing the elements to iterate on.
+ * @param delegate
+ * The origin iterator.
+ */
+ public URIInitializingIterator(EObject eObject, Iterator<T> delegate) {
+ this.delegate = delegate;
+ addUri(eObject);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see com.google.common.collect.ForwardingIterator#delegate()
+ */
+ @Override
+ protected Iterator<T> delegate() {
+ return delegate;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see com.google.common.collect.ForwardingIterator#next()
+ */
+ @Override
+ public T next() {
+ T obj = super.next();
+ if (obj instanceof EObject) {
+ addUri((EObject)obj);
+ } else if (obj instanceof Resource) {
+ addUri((Resource)obj);
+ }
+ return obj;
+ }
+
+ /**
+ * It registers the namespace and resource URI from the given <code>eObject</code>.
+ *
+ * @param eObject
+ * The given <code>eObject</code>.
+ */
+ private void addUri(EObject eObject) {
+ if (eObject.eResource() != null) {
+ getResourceURIs().add(eObject.eResource().getURI().toString());
+ }
+ getNsURIs().add(eObject.eClass().getEPackage().getNsURI());
+ }
+
+ /**
+ * It registers the resource URI from the given <code>resource</code>.
+ *
+ * @param resource
+ * The given <code>resource</code>.
+ */
+ private void addUri(Resource resource) {
+ getResourceURIs().add(resource.getURI().toString());
+ }
+ }
+}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/utils/EMFCompareUtils.java b/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/utils/EMFCompareUtils.java
new file mode 100644
index 0000000..ec7d6a8
--- /dev/null
+++ b/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/utils/EMFCompareUtils.java
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.mylyn.docs.intent.compare.utils;
+
+import com.google.common.base.Predicate;
+
+import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.compare.Comparison;
+import org.eclipse.emf.compare.EMFCompare;
+import org.eclipse.emf.compare.match.eobject.IEObjectMatcher;
+import org.eclipse.emf.compare.match.eobject.ProximityEObjectMatcher;
+import org.eclipse.emf.compare.utils.EqualityHelper;
+import org.eclipse.emf.compare.utils.UseIdentifiers;
+import org.eclipse.mylyn.docs.intent.compare.scope.IntentComparisonScope;
+import org.eclipse.mylyn.docs.intent.core.compiler.CompilationStatus;
+import org.eclipse.mylyn.docs.intent.core.compiler.SynchronizerCompilationStatus;
+
+import static com.google.common.base.Predicates.instanceOf;
+import static com.google.common.base.Predicates.not;
+import static com.google.common.base.Predicates.or;
+
+/**
+ * Utilities for EMF Compare use.
+ *
+ * @author <a href="mailto:william.piers@obeo.fr">William Piers</a>
+ */
+public final class EMFCompareUtils {
+
+ /**
+ * Prevents instantiation.
+ */
+ private EMFCompareUtils() {
+ }
+
+ /**
+ * Returns the differences between the left element and the right element. Comparison customization:
+ * <ul>
+ * <li>Ignore XMI Ids</li>
+ * <li>Resolve proxies</li>
+ * </ul>
+ *
+ * @param left
+ * the left element
+ * @param right
+ * the right element
+ * @return the differences between the left element and the right element
+ */
+ public static Comparison compare(Notifier left, Notifier right) {
+ IntentComparisonScope scope = new IntentComparisonScope(left, right);
+ EqualityHelper helper = new IntentEqualityHelper();
+
+ Predicate<Object> filter = not(or(instanceOf(CompilationStatus.class),
+ instanceOf(SynchronizerCompilationStatus.class)));
+ scope.setEObjectContentFilter(filter);
+
+ EMFCompare compare = EMFCompare.newComparator(scope);
+ compare.matchByID(UseIdentifiers.NEVER);
+ compare.setEqualityHelper(helper);
+ return compare.compare();
+ }
+
+ /**
+ * Returns the differences between the left element and the right element. Comparison customization:
+ * <ul>
+ * <li>Ignore XMI Ids</li>
+ * <li>Resolve proxies</li>
+ * <li>Intent specific match engine</li>
+ * </ul>
+ *
+ * @param left
+ * the left element
+ * @param right
+ * the right element
+ * @return the differences between the left element and the right element
+ */
+ public static Comparison compareDocuments(Notifier left, Notifier right) {
+ IntentComparisonScope scope = new IntentComparisonScope(left, right);
+ EqualityHelper helper = new IntentEqualityHelper();
+
+ Predicate<Object> filter = not(or(instanceOf(CompilationStatus.class),
+ instanceOf(SynchronizerCompilationStatus.class)));
+ scope.setEObjectContentFilter(filter);
+
+ IEObjectMatcher matcher = ProximityEObjectMatcher.builder(
+ org.eclipse.mylyn.docs.intent.compare.match.EditionDistance.builder(helper, left, right)
+ .build()).build();
+
+ EMFCompare compare = EMFCompare.newComparator(scope);
+ compare.setEObjectMatcher(matcher);
+ compare.matchByID(UseIdentifiers.NEVER);
+ compare.setEqualityHelper(helper);
+ return compare.compare();
+ }
+}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/utils/IntentEqualityHelper.java b/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/utils/IntentEqualityHelper.java
new file mode 100644
index 0000000..0b9571d
--- /dev/null
+++ b/plugins/org.eclipse.mylyn.docs.intent.compare/src/org/eclipse/mylyn/docs/intent/compare/utils/IntentEqualityHelper.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.mylyn.docs.intent.compare.utils;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.compare.utils.EqualityHelper;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.mylyn.docs.intent.core.document.IntentStructuredElement;
+
+/**
+ * An {@link EqualityHelper} redefinition used to define accurate URIs.
+ *
+ * @author <a href="mailto:william.piers@obeo.fr">William Piers</a>
+ */
+public class IntentEqualityHelper extends EqualityHelper {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.utils.EqualityHelper#getURI(org.eclipse.emf.ecore.EObject)
+ */
+ @Override
+ public URI getURI(EObject object) {
+ URI uri = super.getURI(object);
+ String level = computeLevel(object);
+ if (level != null) {
+ uri = uri.trimFragment().appendFragment(level);
+ }
+ return uri;
+ }
+
+ /**
+ * Returns the level of the given object inside of the model tree.
+ *
+ * @param object
+ * the object
+ * @return the level of the given object inside of the model tree
+ */
+ private static String computeLevel(EObject object) {
+ String level = null;
+ if (object instanceof IntentStructuredElement) {
+ level = ((IntentStructuredElement)object).getCompleteLevel();
+ } else {
+ EObject container = object.eContainer();
+ if (container != null) {
+ int index = container.eContents().indexOf(object);
+ String containerLevel = computeLevel(container);
+ if (containerLevel != null) {
+ level = containerLevel + ".";
+ } else {
+ level = "";
+ }
+ level += index;
+ }
+ }
+ return level;
+ }
+
+}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.mylyn.docs.intent.core/META-INF/MANIFEST.MF
index 3b81d1a..3e72b4a 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.core/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.mylyn.docs.intent.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.mylyn.docs.intent.core;singleton:=true
-Bundle-Version: 0.7.0.qualifier
+Bundle-Version: 0.8.0.qualifier
Bundle-ClassPath: .
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/plugins/org.eclipse.mylyn.docs.intent.core/pom.xml b/plugins/org.eclipse.mylyn.docs.intent.core/pom.xml
index 7c02b88..76ae3ef 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.core/pom.xml
+++ b/plugins/org.eclipse.mylyn.docs.intent.core/pom.xml
@@ -13,7 +13,7 @@
<parent>
<groupId>org.eclipse.mylyn.docs.intent-group</groupId>
<artifactId>intent-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
diff --git a/plugins/org.eclipse.mylyn.docs.intent.exporter.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.mylyn.docs.intent.exporter.ui/META-INF/MANIFEST.MF
index 6e8f847..1a1ed95 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.exporter.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.mylyn.docs.intent.exporter.ui/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@
Bundle-Localization: plugin
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.mylyn.docs.intent.exporter.ui;singleton:=true
-Bundle-Version: 0.7.0.qualifier
+Bundle-Version: 0.8.0.qualifier
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.mylyn.docs.intent.exporter,
diff --git a/plugins/org.eclipse.mylyn.docs.intent.exporter.ui/pom.xml b/plugins/org.eclipse.mylyn.docs.intent.exporter.ui/pom.xml
index 7d9aee1..33211c9 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.exporter.ui/pom.xml
+++ b/plugins/org.eclipse.mylyn.docs.intent.exporter.ui/pom.xml
@@ -13,7 +13,7 @@
<parent>
<groupId>org.eclipse.mylyn.docs.intent-group</groupId>
<artifactId>intent-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
diff --git a/plugins/org.eclipse.mylyn.docs.intent.exporter/META-INF/MANIFEST.MF b/plugins/org.eclipse.mylyn.docs.intent.exporter/META-INF/MANIFEST.MF
index 0d3ae19..62dfdfb 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.exporter/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.mylyn.docs.intent.exporter/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: Intent Documentation Exporter
Bundle-SymbolicName: org.eclipse.mylyn.docs.intent.exporter
-Bundle-Version: 0.7.0.qualifier
+Bundle-Version: 0.8.0.qualifier
Bundle-Activator: org.eclipse.mylyn.docs.intent.exporter.Activator
Bundle-Vendor: Eclipse Mylyn
Require-Bundle: org.eclipse.core.runtime,
diff --git a/plugins/org.eclipse.mylyn.docs.intent.exporter/build.acceleo b/plugins/org.eclipse.mylyn.docs.intent.exporter/build.acceleo
index bf5d71d..e950c1a 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.exporter/build.acceleo
+++ b/plugins/org.eclipse.mylyn.docs.intent.exporter/build.acceleo
@@ -18,7 +18,7 @@
<acceleoCompiler
sourceFolder="${target.folder}"
outputFolder="${target.folder}"
- dependencies="${target.folder}/../../org.eclipse.mylyn.docs.intent.core;${target.folder}/../../org.eclipse.mylyn.docs.intent.markup;${target.folder}/../../org.eclipse.mylyn.docs.intent.markup.gen;${target.folder}/../../org.eclipse.mylyn.docs.intent.collab.common;${target.folder}/../../org.eclipse.mylyn.docs.intent.collab;${target.folder}/../../org.eclipse.mylyn.docs.intent.parser;${target.folder}/../../org.eclipse.mylyn.docs.intent.client.ui;${target.folder}/../../org.eclipse.mylyn.docs.intent.compare;${target.folder}/../../org.eclipse.mylyn.docs.intent.modelingunit.update;"
+ dependencies="${target.folder}/../../org.eclipse.mylyn.docs.intent.core;${target.folder}/../../org.eclipse.mylyn.docs.intent.markup;${target.folder}/../../org.eclipse.mylyn.docs.intent.markup.gen;${target.folder}/../../org.eclipse.mylyn.docs.intent.collab.common;${target.folder}/../../org.eclipse.mylyn.docs.intent.collab;${target.folder}/../../org.eclipse.emf.compare;${target.folder}/../../org.eclipse.mylyn.docs.intent.parser;${target.folder}/../../org.eclipse.mylyn.docs.intent.client.ui;${target.folder}/../../org.eclipse.mylyn.docs.intent.compare;${target.folder}/../../org.eclipse.mylyn.docs.intent.modelingunit.update;${target.folder}/../../org.eclipse.emf.compare.ide.ui;${target.folder}/../../org.eclipse.emf.compare.edit;${target.folder}/../../org.eclipse.emf.compare.ide;${target.folder}/../../org.eclipse.emf.compare.rcp.ui;"
binaryResource="false"
packagesToRegister="">
</acceleoCompiler>
diff --git a/plugins/org.eclipse.mylyn.docs.intent.exporter/pom.xml b/plugins/org.eclipse.mylyn.docs.intent.exporter/pom.xml
index ee3b5e9..1e768ae 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.exporter/pom.xml
+++ b/plugins/org.eclipse.mylyn.docs.intent.exporter/pom.xml
@@ -13,7 +13,7 @@
<parent>
<groupId>org.eclipse.mylyn.docs.intent-group</groupId>
<artifactId>intent-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
diff --git a/plugins/org.eclipse.mylyn.docs.intent.exporter/tasks/HTMLBootstrapGenDocument.xml b/plugins/org.eclipse.mylyn.docs.intent.exporter/tasks/HTMLBootstrapGenDocument.xml
index 0c836ba..3b4cca5 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.exporter/tasks/HTMLBootstrapGenDocument.xml
+++ b/plugins/org.eclipse.mylyn.docs.intent.exporter/tasks/HTMLBootstrapGenDocument.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project default="HTMLBootstrapGenDocument" name="org.eclipse.mylyn.docs.intent.exporter">
- <property name="ECLIPSE_HOME" value="../../../../../../programs/intent/eclipse"/>
- <property name="ECLIPSE_WORKSPACE" value="../../../../../../programs/intent/eclipse/workspace"/>
+ <property name="ECLIPSE_HOME" value="../../../../../../programs/intent/eclipse-SDK-4.2-win32-x86_64/eclipse"/>
+ <property name="ECLIPSE_WORKSPACE" value="../../../../../../programs/intent/eclipse-SDK-4.2-win32-x86_64/eclipse/workspace"/>
<!-- The classpath with only the dependencies used by the project -->
<path id="org.eclipse.mylyn.docs.intent.exporter.libraryclasspath">
@@ -45,7 +45,6 @@
<pathelement location="${ECLIPSE_WORKSPACE}//.metadata/.plugins/org.eclipse.pde.core/.bundle_pool/plugins/org.eclipse.swt.win32.win32.x86_64_3.100.0.v4233d.jar"/>
<pathelement location="${ECLIPSE_WORKSPACE}//.metadata/.plugins/org.eclipse.pde.core/.bundle_pool/plugins/org.eclipse.jface_3.8.0.v20120521-2329.jar"/>
<pathelement location="${ECLIPSE_WORKSPACE}//.metadata/.plugins/org.eclipse.pde.core/.bundle_pool/plugins/org.eclipse.core.commands_3.6.1.v20120521-2329.jar"/>
- <pathelement location="${ECLIPSE_WORKSPACE}//.metadata/.plugins/org.eclipse.pde.core/.bundle_pool/plugins/org.eclipse.emf.compare.diff_1.3.1.v20120605-0748.jar"/>
<pathelement location="${ECLIPSE_WORKSPACE}//.metadata/.plugins/org.eclipse.pde.core/.bundle_pool/plugins/org.eclipse.core.resources_3.8.0.v20120522-2034.jar"/>
<pathelement location="${ECLIPSE_WORKSPACE}//.metadata/.plugins/org.eclipse.pde.core/.bundle_pool/plugins/org.eclipse.ui.editors_3.8.0.v20120523-1540.jar"/>
<pathelement location="${ECLIPSE_WORKSPACE}//.metadata/.plugins/org.eclipse.pde.core/.bundle_pool/plugins/org.eclipse.core.filebuffers_3.5.200.v20120523-1310.jar"/>
diff --git a/plugins/org.eclipse.mylyn.docs.intent.markup.gen/META-INF/MANIFEST.MF b/plugins/org.eclipse.mylyn.docs.intent.markup.gen/META-INF/MANIFEST.MF
index 57d9aaa..6b385b4 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.markup.gen/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.mylyn.docs.intent.markup.gen/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.mylyn.docs.intent.markup.gen;singleton:=true
-Bundle-Version: 0.7.0.qualifier
+Bundle-Version: 0.8.0.qualifier
Bundle-ClassPath: .
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/plugins/org.eclipse.mylyn.docs.intent.markup.gen/pom.xml b/plugins/org.eclipse.mylyn.docs.intent.markup.gen/pom.xml
index d354bba..36e07f5 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.markup.gen/pom.xml
+++ b/plugins/org.eclipse.mylyn.docs.intent.markup.gen/pom.xml
@@ -11,13 +11,13 @@
<parent>
<groupId>org.eclipse.mylyn.docs.intent-group</groupId>
<artifactId>intent-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
<groupId>acceleo</groupId>
<artifactId>org.eclipse.mylyn.docs.intent.markup.gen</artifactId>
- <version>0.7.0.qualifier</version> <!-- This version should match the version of your project in the MANIFEST.MF-->
+ <version>0.8.0-SNAPSHOT</version> <!-- This version should match the version of your project in the MANIFEST.MF-->
<packaging>eclipse-plugin</packaging>
<build>
diff --git a/plugins/org.eclipse.mylyn.docs.intent.markup.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.mylyn.docs.intent.markup.ui/META-INF/MANIFEST.MF
index a0a1726..4ab55de 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.markup.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.mylyn.docs.intent.markup.ui/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@
Bundle-Localization: plugin
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.mylyn.docs.intent.markup.ui; singleton:=true
-Bundle-Version: 0.7.0.qualifier
+Bundle-Version: 0.8.0.qualifier
Bundle-Activator: org.eclipse.mylyn.docs.intent.markup.ui.Activator
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
diff --git a/plugins/org.eclipse.mylyn.docs.intent.markup.ui/pom.xml b/plugins/org.eclipse.mylyn.docs.intent.markup.ui/pom.xml
index ec9d964..913f94d 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.markup.ui/pom.xml
+++ b/plugins/org.eclipse.mylyn.docs.intent.markup.ui/pom.xml
@@ -8,7 +8,7 @@
<parent>
<groupId>org.eclipse.mylyn.docs.intent-group</groupId>
<artifactId>intent-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
diff --git a/plugins/org.eclipse.mylyn.docs.intent.markup/META-INF/MANIFEST.MF b/plugins/org.eclipse.mylyn.docs.intent.markup/META-INF/MANIFEST.MF
index bfe05f5..eb69951 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.markup/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.mylyn.docs.intent.markup/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.mylyn.docs.intent.markup;singleton:=true
-Bundle-Version: 0.7.0.qualifier
+Bundle-Version: 0.8.0.qualifier
Bundle-ClassPath: .
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/plugins/org.eclipse.mylyn.docs.intent.markup/pom.xml b/plugins/org.eclipse.mylyn.docs.intent.markup/pom.xml
index ecbf691..4df00b8 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.markup/pom.xml
+++ b/plugins/org.eclipse.mylyn.docs.intent.markup/pom.xml
@@ -13,7 +13,7 @@
<parent>
<groupId>org.eclipse.mylyn.docs.intent-group</groupId>
<artifactId>intent-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
diff --git a/plugins/org.eclipse.mylyn.docs.intent.markup/src/org/eclipse/mylyn/docs/intent/markup/resource/WikimediaResource.java b/plugins/org.eclipse.mylyn.docs.intent.markup/src/org/eclipse/mylyn/docs/intent/markup/resource/WikimediaResource.java
index 97942e7..76647b3 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.markup/src/org/eclipse/mylyn/docs/intent/markup/resource/WikimediaResource.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.markup/src/org/eclipse/mylyn/docs/intent/markup/resource/WikimediaResource.java
@@ -13,8 +13,6 @@
*******************************************************************************/
package org.eclipse.mylyn.docs.intent.markup.resource;
-import com.google.common.collect.Iterators;
-
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -49,6 +47,8 @@
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
+import com.google.common.collect.Iterators;
+
/**
* A resource implementation for web-based pages on wikimedia.
*
@@ -82,7 +82,8 @@
Map<?, ?> response = null;
if (options != null) {
response = (Map<?, ?>)options.get(URIConverter.OPTION_RESPONSE);
- } else {
+ }
+ if (response == null) {
response = new HashMap<Object, Object>();
}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.modelingunit.update/META-INF/MANIFEST.MF b/plugins/org.eclipse.mylyn.docs.intent.modelingunit.update/META-INF/MANIFEST.MF
index e0fc647..43ff4f9 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.modelingunit.update/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.mylyn.docs.intent.modelingunit.update/META-INF/MANIFEST.MF
@@ -3,12 +3,13 @@
Bundle-Localization: plugin
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.mylyn.docs.intent.modelingunit.update
-Bundle-Version: 0.7.0.qualifier
+Bundle-Version: 0.8.0.qualifier
Bundle-Vendor: %providerName
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy
Require-Bundle: org.eclipse.mylyn.docs.intent.core;bundle-version="0.7.0",
org.eclipse.mylyn.docs.intent.collab;bundle-version="0.7.0",
org.eclipse.mylyn.docs.intent.collab.common;bundle-version="0.7.0",
- org.eclipse.emf.compare.match;bundle-version="1.3.1"
+ org.eclipse.emf.compare;bundle-version="2.0.0",
+ org.eclipse.mylyn.docs.intent.compare;bundle-version="0.7.0"
Export-Package: org.eclipse.mylyn.docs.intent.modelingunit.update
diff --git a/plugins/org.eclipse.mylyn.docs.intent.modelingunit.update/pom.xml b/plugins/org.eclipse.mylyn.docs.intent.modelingunit.update/pom.xml
index efe1584..84b6d52 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.modelingunit.update/pom.xml
+++ b/plugins/org.eclipse.mylyn.docs.intent.modelingunit.update/pom.xml
@@ -13,7 +13,7 @@
<parent>
<groupId>org.eclipse.mylyn.docs.intent-group</groupId>
<artifactId>intent-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
diff --git a/plugins/org.eclipse.mylyn.docs.intent.modelingunit.update/src/org/eclipse/mylyn/docs/intent/modelingunit/gen/AbstractModelingUnitGenerator.java b/plugins/org.eclipse.mylyn.docs.intent.modelingunit.update/src/org/eclipse/mylyn/docs/intent/modelingunit/gen/AbstractModelingUnitGenerator.java
index 56870fe..b06071a 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.modelingunit.update/src/org/eclipse/mylyn/docs/intent/modelingunit/gen/AbstractModelingUnitGenerator.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.modelingunit.update/src/org/eclipse/mylyn/docs/intent/modelingunit/gen/AbstractModelingUnitGenerator.java
@@ -11,6 +11,7 @@
*******************************************************************************/
package org.eclipse.mylyn.docs.intent.modelingunit.gen;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -117,20 +118,8 @@
for (EStructuralFeature feature : root.eClass().getEAllStructuralFeatures()) {
if (!filter(feature)) {
- Object value = root.eGet(feature);
- if (value instanceof Collection<?>) {
- for (Object singleValue : (Collection<?>)value) {
- StructuralFeatureAffectation affectation = generateAffectation(feature, singleValue);
- if (affectation != null) {
- instanciation.getStructuralFeatures().add(affectation);
- }
- }
- } else {
- StructuralFeatureAffectation affectation = generateAffectation(feature, value);
- if (affectation != null) {
- instanciation.getStructuralFeatures().add(affectation);
- }
- }
+ instanciation.getStructuralFeatures().addAll(
+ generateAffectations(feature, root.eGet(feature)));
}
}
return instanciation;
@@ -142,10 +131,38 @@
* @param feature
* the feature to set
* @param workingCopyValue
- * the value to set
+ * the value to set, can be a collection
* @return the affectation instruction
*/
- public StructuralFeatureAffectation generateAffectation(EStructuralFeature feature,
+ public List<StructuralFeatureAffectation> generateAffectations(EStructuralFeature feature,
+ Object workingCopyValue) {
+ List<StructuralFeatureAffectation> affectations = new ArrayList<StructuralFeatureAffectation>();
+ if (workingCopyValue instanceof Collection<?>) {
+ for (Object singleValue : (Collection<?>)workingCopyValue) {
+ StructuralFeatureAffectation affectation = generateSingleAffectation(feature, singleValue);
+ if (affectation != null) {
+ affectations.add(affectation);
+ }
+ }
+ } else {
+ StructuralFeatureAffectation affectation = generateSingleAffectation(feature, workingCopyValue);
+ if (affectation != null) {
+ affectations.add(affectation);
+ }
+ }
+ return affectations;
+ }
+
+ /**
+ * Generates the {@link StructuralFeatureAffectation} which build the affectation.
+ *
+ * @param feature
+ * the feature to set
+ * @param workingCopyValue
+ * the single value to set
+ * @return the affectation instruction
+ */
+ public StructuralFeatureAffectation generateSingleAffectation(EStructuralFeature feature,
Object workingCopyValue) {
StructuralFeatureAffectation affectation = null;
if (workingCopyValue != null
@@ -169,33 +186,6 @@
}
/**
- * Generates the {@link ValueForStructuralFeature} which build the value.
- *
- * @param feature
- * the feature to set
- * @param value
- * the value
- * @return the value instruction
- */
- public ValueForStructuralFeature generateValue(EStructuralFeature feature, Object value) {
- ValueForStructuralFeature res = null;
- if (feature instanceof EAttribute) {
- res = ModelingUnitFactory.eINSTANCE.createNativeValueForStructuralFeature();
- } else if (feature instanceof EReference) {
- if (((EReference)feature).isContainment()) {
- res = ModelingUnitFactory.eINSTANCE.createNewObjectValueForStructuralFeature();
- } else {
- res = ModelingUnitFactory.eINSTANCE.createReferenceValueForStructuralFeature();
- }
- }
- if (setValue(res, value)) {
- return res;
- } else {
- return null;
- }
- }
-
- /**
* Sets the correct value in the given value instruction.
*
* @param valueInstruction
@@ -227,7 +217,7 @@
} else {
InstanciationInstructionReference reference = ModelingUnitFactory.eINSTANCE
.createInstanciationInstructionReference();
-
+
InstanciationInstruction instanciation = getExistingInstanciationFor((EObject)newValue);
if (instanciation != null) {
if (instanciation.getName() == null) {
@@ -253,6 +243,33 @@
}
/**
+ * Generates the {@link ValueForStructuralFeature} which build the value.
+ *
+ * @param feature
+ * the feature to set
+ * @param value
+ * the value
+ * @return the value instruction
+ */
+ private ValueForStructuralFeature generateValue(EStructuralFeature feature, Object value) {
+ ValueForStructuralFeature res = null;
+ if (feature instanceof EAttribute) {
+ res = ModelingUnitFactory.eINSTANCE.createNativeValueForStructuralFeature();
+ } else if (feature instanceof EReference) {
+ if (((EReference)feature).isContainment()) {
+ res = ModelingUnitFactory.eINSTANCE.createNewObjectValueForStructuralFeature();
+ } else {
+ res = ModelingUnitFactory.eINSTANCE.createReferenceValueForStructuralFeature();
+ }
+ }
+ if (setValue(res, value)) {
+ return res;
+ } else {
+ return null;
+ }
+ }
+
+ /**
* Filters the feature to generate as affectations.
*
* @param feature
diff --git a/plugins/org.eclipse.mylyn.docs.intent.modelingunit.update/src/org/eclipse/mylyn/docs/intent/modelingunit/update/AbstractModelingUnitUpdater.java b/plugins/org.eclipse.mylyn.docs.intent.modelingunit.update/src/org/eclipse/mylyn/docs/intent/modelingunit/update/AbstractModelingUnitUpdater.java
index e4d4233..f946a3f 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.modelingunit.update/src/org/eclipse/mylyn/docs/intent/modelingunit/update/AbstractModelingUnitUpdater.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.modelingunit.update/src/org/eclipse/mylyn/docs/intent/modelingunit/update/AbstractModelingUnitUpdater.java
@@ -17,16 +17,13 @@
import java.util.Map;
import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.compare.match.MatchOptions;
-import org.eclipse.emf.compare.match.metamodel.Match2Elements;
-import org.eclipse.emf.compare.match.metamodel.MatchElement;
-import org.eclipse.emf.compare.match.metamodel.MatchModel;
-import org.eclipse.emf.compare.match.service.MatchService;
+import org.eclipse.emf.compare.Match;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.mylyn.docs.intent.collab.common.query.TraceabilityInformationsQuery;
import org.eclipse.mylyn.docs.intent.collab.handlers.adapters.RepositoryAdapter;
+import org.eclipse.mylyn.docs.intent.compare.utils.EMFCompareUtils;
import org.eclipse.mylyn.docs.intent.core.document.IntentGenericElement;
import org.eclipse.mylyn.docs.intent.core.modelingunit.InstanciationInstruction;
import org.eclipse.mylyn.docs.intent.modelingunit.gen.AbstractModelingUnitGenerator;
@@ -73,11 +70,8 @@
*/
protected void includeMatch(Resource compiledResource, Resource workingCopyResource) {
try {
- final HashMap<String, Object> options = new HashMap<String, Object>();
- options.put(MatchOptions.OPTION_IGNORE_XMI_ID, Boolean.TRUE);
- MatchModel matchModel = MatchService.doResourceMatch(compiledResource, workingCopyResource,
- options);
- for (MatchElement matchElement : matchModel.getMatchedElements()) {
+ for (Match matchElement : EMFCompareUtils.compare(compiledResource, workingCopyResource)
+ .getMatches()) {
collectAllMatches(matchElement);
}
// CHECKSTYLE:OFF we ignore comparison errors
@@ -93,15 +87,14 @@
* @param matchElement
* the match element
*/
- private void collectAllMatches(MatchElement matchElement) {
- if (matchElement instanceof Match2Elements) {
- Match2Elements match2Elements = (Match2Elements)matchElement;
- EObject workingCopyObject = match2Elements.getRightElement();
- EObject compiledObject = match2Elements.getLeftElement();
- match.put(workingCopyObject, compiledObject);
- }
- for (MatchElement subMatchElement : matchElement.getSubMatchElements()) {
- collectAllMatches(subMatchElement);
+ private void collectAllMatches(Match matchElement) {
+ EObject workingCopyObject = matchElement.getRight();
+ EObject compiledObject = matchElement.getLeft();
+ match.put(workingCopyObject, compiledObject);
+ for (Match subMatchElement : matchElement.getAllSubmatches()) {
+ EObject subWorkingCopyObject = subMatchElement.getRight();
+ EObject subCompiledObject = subMatchElement.getLeft();
+ match.put(subWorkingCopyObject, subCompiledObject);
}
}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.modelingunit.update/src/org/eclipse/mylyn/docs/intent/modelingunit/update/MergeUpdater.java b/plugins/org.eclipse.mylyn.docs.intent.modelingunit.update/src/org/eclipse/mylyn/docs/intent/modelingunit/update/MergeUpdater.java
index 0fc32c7..1503e55 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.modelingunit.update/src/org/eclipse/mylyn/docs/intent/modelingunit/update/MergeUpdater.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.modelingunit.update/src/org/eclipse/mylyn/docs/intent/modelingunit/update/MergeUpdater.java
@@ -27,7 +27,7 @@
import org.eclipse.mylyn.docs.intent.collab.handlers.adapters.RepositoryAdapter;
import org.eclipse.mylyn.docs.intent.collab.handlers.adapters.SaveException;
import org.eclipse.mylyn.docs.intent.core.compiler.CompilationStatus;
-import org.eclipse.mylyn.docs.intent.core.compiler.ModelElementChangeStatus;
+import org.eclipse.mylyn.docs.intent.core.compiler.StructuralFeatureChangeStatus;
import org.eclipse.mylyn.docs.intent.core.document.IntentSection;
import org.eclipse.mylyn.docs.intent.core.modelingunit.ContributionInstruction;
import org.eclipse.mylyn.docs.intent.core.modelingunit.InstanciationInstruction;
@@ -119,31 +119,27 @@
setNewObjects(getAllNewObjects(elements));
newInstanciations = new HashMap<EObject, InstanciationInstruction>();
for (EObject workingCopyObject : elements) {
- ModelElementChangeStatus status = findStatus(workingCopyObject);
- if (status != null) {
- Resource compiledResource = repositoryAdapter.getResource(status.getCompiledResourceURI());
- includeMatch(compiledResource, workingCopyObject.eResource());
- if (getExistingInstanciationFor(workingCopyObject) == null) {
- InstanciationInstruction containerInstanciation = getExistingInstanciationFor(workingCopyObject
- .eContainer());
- if (containerInstanciation == null) {
- // lookup in new instanciations
- containerInstanciation = newInstanciations.get(workingCopyObject.eContainer());
- }
- if (containerInstanciation != null) {
- ContributionInstruction contribution = generateContribution(containerInstanciation);
- StructuralFeatureAffectation containment = generateAffectation(
- workingCopyObject.eContainingFeature(), workingCopyObject);
- contribution.getContributions().add(containment);
- modelingUnit.getInstructions().add(contribution);
- newInstanciations.put(workingCopyObject,
- ((NewObjectValueForStructuralFeature)containment.getValues().get(0))
- .getValue());
- } else {
- InstanciationInstruction instanciation = generateInstanciation(workingCopyObject);
- modelingUnit.getInstructions().add(instanciation);
- newInstanciations.put(workingCopyObject, instanciation);
- }
+ Resource compiledResource = getMatchingCompiledResource(workingCopyObject);
+ includeMatch(compiledResource, workingCopyObject.eResource());
+ if (getExistingInstanciationFor(workingCopyObject) == null) {
+ InstanciationInstruction containerInstanciation = getExistingInstanciationFor(workingCopyObject
+ .eContainer());
+ if (containerInstanciation == null) {
+ // lookup in new instanciations
+ containerInstanciation = newInstanciations.get(workingCopyObject.eContainer());
+ }
+ if (containerInstanciation != null) {
+ ContributionInstruction contribution = generateContribution(containerInstanciation);
+ StructuralFeatureAffectation containment = generateSingleAffectation(
+ workingCopyObject.eContainingFeature(), workingCopyObject);
+ contribution.getContributions().add(containment);
+ modelingUnit.getInstructions().add(contribution);
+ newInstanciations.put(workingCopyObject, ((NewObjectValueForStructuralFeature)containment
+ .getValues().get(0)).getValue());
+ } else {
+ InstanciationInstruction instanciation = generateInstanciation(workingCopyObject);
+ modelingUnit.getInstructions().add(instanciation);
+ newInstanciations.put(workingCopyObject, instanciation);
}
}
}
@@ -172,15 +168,15 @@
* the object
* @return a status associated to the given object
*/
- private ModelElementChangeStatus findStatus(EObject eObject) {
+ private Resource getMatchingCompiledResource(EObject eObject) {
String uriFragment = EcoreUtil.getURI(eObject).toString();
CompilationStatusQuery query = new CompilationStatusQuery(repositoryAdapter);
for (CompilationStatus compilationStatus : query.getOrCreateCompilationStatusManager()
.getCompilationStatusList()) {
- if (compilationStatus instanceof ModelElementChangeStatus) {
- ModelElementChangeStatus status = (ModelElementChangeStatus)compilationStatus;
+ if (compilationStatus instanceof StructuralFeatureChangeStatus) {
+ StructuralFeatureChangeStatus status = (StructuralFeatureChangeStatus)compilationStatus;
if (uriFragment.equals(status.getWorkingCopyElementURIFragment())) {
- return status;
+ return repositoryAdapter.getResource(status.getCompiledResourceURI());
}
}
}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.modelingunit.update/src/org/eclipse/mylyn/docs/intent/modelingunit/update/SyncStatusUpdater.java b/plugins/org.eclipse.mylyn.docs.intent.modelingunit.update/src/org/eclipse/mylyn/docs/intent/modelingunit/update/SyncStatusUpdater.java
index 605b5c1..c66e05b 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.modelingunit.update/src/org/eclipse/mylyn/docs/intent/modelingunit/update/SyncStatusUpdater.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.modelingunit.update/src/org/eclipse/mylyn/docs/intent/modelingunit/update/SyncStatusUpdater.java
@@ -133,7 +133,7 @@
}
setNewObjects(newObjects);
- StructuralFeatureAffectation affectation = generateAffectation(
+ StructuralFeatureAffectation affectation = generateSingleAffectation(
workingCopyObject.eContainingFeature(), workingCopyObject);
if (affectation != null) {
instanciation.getStructuralFeatures().add(affectation);
@@ -201,10 +201,7 @@
setValue((ValueForStructuralFeature)status.getTarget(), newValue);
}
} else if (status.getTarget() instanceof InstanciationInstruction) {
- StructuralFeatureAffectation newAffectation = generateAffectation(feature, newValue);
- if (newAffectation != null) {
- addAffectation(status.getTarget(), newAffectation);
- }
+ addAffectations(status.getTarget(), generateAffectations(feature, newValue));
}
break;
@@ -217,11 +214,10 @@
break;
case SynchronizerChangeState.WORKING_COPY_TARGET_VALUE:
- StructuralFeatureAffectation newAffectation = generateAffectation(feature, newValue);
IntentGenericElement container = getContainer(status.getTarget(),
ModelingUnitPackage.CONTRIBUTION_INSTRUCTION,
ModelingUnitPackage.INSTANCIATION_INSTRUCTION);
- addAffectation(container, newAffectation);
+ addAffectations(container, generateAffectations(feature, newValue));
break;
default:
@@ -236,16 +232,17 @@
*
* @param container
* the container
- * @param affectation
+ * @param affectations
* the affectation
*/
- private void addAffectation(IntentGenericElement container, StructuralFeatureAffectation affectation) {
+ private void addAffectations(IntentGenericElement container,
+ List<StructuralFeatureAffectation> affectations) {
if (container instanceof ContributionInstruction) {
ContributionInstruction contribution = (ContributionInstruction)container;
- contribution.getContributions().add(affectation);
+ contribution.getContributions().addAll(affectations);
} else if (container instanceof InstanciationInstruction) {
InstanciationInstruction instanciation = (InstanciationInstruction)container;
- instanciation.getStructuralFeatures().add(affectation);
+ instanciation.getStructuralFeatures().addAll(affectations);
}
}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.parser/META-INF/MANIFEST.MF b/plugins/org.eclipse.mylyn.docs.intent.parser/META-INF/MANIFEST.MF
index 2acaf97..21cab7d 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.parser/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.mylyn.docs.intent.parser/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@
Bundle-Localization: plugin
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
-Bundle-Version: 0.7.0.qualifier
+Bundle-Version: 0.8.0.qualifier
Bundle-SymbolicName: org.eclipse.mylyn.docs.intent.parser; singleton:=true
Bundle-ActivationPolicy: lazy
Require-Bundle: org.eclipse.emf.common,
diff --git a/plugins/org.eclipse.mylyn.docs.intent.parser/pom.xml b/plugins/org.eclipse.mylyn.docs.intent.parser/pom.xml
index fdbf18c..3819102 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.parser/pom.xml
+++ b/plugins/org.eclipse.mylyn.docs.intent.parser/pom.xml
@@ -13,7 +13,7 @@
<parent>
<groupId>org.eclipse.mylyn.docs.intent-group</groupId>
<artifactId>intent-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
diff --git a/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/parser/IntentParser.java b/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/parser/IntentParser.java
index 3b8ffa4..3b3381b 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/parser/IntentParser.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/parser/IntentParser.java
@@ -41,6 +41,22 @@
* if the given content contain error or doesn't describe an Intent entity
*/
public EObject parse(String contentToParse) throws ParseException {
+ return parse(contentToParse, null);
+ }
+
+ /**
+ * Parse the given content and return the described element.
+ *
+ * @param contentToParse
+ * textual form of an Intent entity (can be a IntentDocument, a Section, a Chapter, a Modeling
+ * Unit or a Description Unit).
+ * @param rootCompleteLevel
+ * the root complete level
+ * @return the given content and return the described element
+ * @throws ParseException
+ * if the given content contain error or doesn't describe an Intent entity
+ */
+ public EObject parse(String contentToParse, String rootCompleteLevel) throws ParseException {
IntentDocumentParser documentParser = new IntentDocumentParser();
ModelingUnitParserImpl modelingUnitParser = new ModelingUnitParserImpl();
DescriptionUnitParser descriptionUnitParser = new DescriptionUnitParser();
@@ -56,7 +72,7 @@
} else {
// If it starts with a IntentDocument's Keyword (like "Section, Document, Chapter..."
if (documentParser.isParserFor(contentToParse)) {
- generatedObject = documentParser.parse(contentToParse);
+ generatedObject = documentParser.parse(contentToParse, rootCompleteLevel);
positionManager.addIntentPositionManagerInformations(documentParser.getPositionManager());
} else {
// In the other cases, we consider that the given contentToParse is a DescriptionUnit
diff --git a/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/parser/internal/IntentBuilder.java b/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/parser/internal/IntentBuilder.java
index bf152e1..dbf83e2 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/parser/internal/IntentBuilder.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/parser/internal/IntentBuilder.java
@@ -63,14 +63,22 @@
private int currentImbricationLevel;
/**
+ * The root complete level.
+ */
+ private String rootCompleteLevel;
+
+ /**
* IntentBuilder constructor.
*
* @param positionManager
* the positionManager where to register positions
+ * @param rootCompleteLevel
+ * the root complete level
*/
- public IntentBuilder(IntentPositionManager positionManager) {
+ public IntentBuilder(IntentPositionManager positionManager, String rootCompleteLevel) {
roots = new ArrayList<EObject>();
this.positionManager = positionManager;
+ this.rootCompleteLevel = rootCompleteLevel;
}
/**
@@ -153,7 +161,7 @@
currentRoot = IntentDocumentFactory.eINSTANCE.createIntentChapter();
roots.add(currentRoot);
currentState = new SChapter(offset, declarationLength, null, (IntentChapter)currentRoot,
- positionManager, title);
+ positionManager, title, rootCompleteLevel);
} else {
currentState = currentState.beginChapter(offset, declarationLength, title);
@@ -178,7 +186,7 @@
currentRoot = IntentDocumentFactory.eINSTANCE.createIntentSection();
roots.add(currentRoot);
currentState = new SSection(offset, declarationLength, null, (IntentSection)currentRoot,
- positionManager, title);
+ positionManager, title, rootCompleteLevel);
} else {
currentState = currentState.beginSection(offset, declarationLength, title);
}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/parser/internal/IntentDocumentParser.java b/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/parser/internal/IntentDocumentParser.java
index 06f094e..d5b5b5a 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/parser/internal/IntentDocumentParser.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/parser/internal/IntentDocumentParser.java
@@ -72,13 +72,15 @@
*
* @param contentToParse
* the contentToParse
+ * @param rootCompleteLevel
+ * the root complete level
* @return the IntentStructuredElement described by the given content to parse
* @throws ParseException
* if the given content to parse contains errors
*/
- public EObject parse(String contentToParse) throws ParseException {
+ public EObject parse(String contentToParse, String rootCompleteLevel) throws ParseException {
// Step 1 : creating the builder which will generate the elements
- builder = new IntentBuilder(positionManager);
+ builder = new IntentBuilder(positionManager, rootCompleteLevel);
String remainingContentToParse = contentToParse;
String currentlyParsedSentence = null;
int cursor = 0;
diff --git a/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/parser/internal/state/IntentSubSectionContainerState.java b/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/parser/internal/state/IntentSubSectionContainerState.java
index a2faa30..13f90bf 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/parser/internal/state/IntentSubSectionContainerState.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/parser/internal/state/IntentSubSectionContainerState.java
@@ -16,8 +16,10 @@
import org.eclipse.emf.ecore.EObject;
import org.eclipse.mylyn.docs.intent.core.descriptionunit.DescriptionBloc;
import org.eclipse.mylyn.docs.intent.core.descriptionunit.DescriptionUnit;
+import org.eclipse.mylyn.docs.intent.core.document.IntentDocument;
import org.eclipse.mylyn.docs.intent.core.document.IntentDocumentFactory;
import org.eclipse.mylyn.docs.intent.core.document.IntentSection;
+import org.eclipse.mylyn.docs.intent.core.document.IntentStructuredElement;
import org.eclipse.mylyn.docs.intent.core.document.IntentSubSectionContainer;
import org.eclipse.mylyn.docs.intent.core.genericunit.UnitInstruction;
import org.eclipse.mylyn.docs.intent.markup.markup.Block;
@@ -54,14 +56,17 @@
* the positionManager where to register positions
* @param title
* the element title
+ * @param completeLevel
+ * the container complete level
* @throws ParseException
* it the title cannot be parsed
*/
public IntentSubSectionContainerState(int offset, int declarationLength, IntentGenericState previous,
- EObject currentElement, IntentPositionManager positionManager, String title)
+ EObject currentElement, IntentPositionManager positionManager, String title, String completeLevel)
throws ParseException {
super(offset, declarationLength, previous, currentElement, positionManager);
setTitle(title);
+ ((IntentStructuredElement)this.currentElement).setCompleteLevel(completeLevel);
}
/**
@@ -103,7 +108,32 @@
throws ParseException {
IntentSection subSection = IntentDocumentFactory.eINSTANCE.createIntentSection();
((IntentSubSectionContainer)currentElement).getIntentContent().add(subSection);
- return new SSection(offset, declarationLength, this, subSection, positionManager, title);
+ return new SSection(offset, declarationLength, this, subSection, positionManager, title,
+ ((IntentStructuredElement)currentElement).getCompleteLevel() + "." + getIndex(subSection));
+ }
+
+ /**
+ * Returns the index for this element, using its hierarchical level (for example "2.1.4").
+ *
+ * @param element
+ * a structured element
+ * @return the index of this element
+ */
+ private String getIndex(IntentStructuredElement element) {
+ int positionInContainer = 0;
+ // If the element is contained in a document
+ if (element.eContainer() instanceof IntentDocument) {
+ // We get its position in this document
+ positionInContainer = element.eContainer().eContents().indexOf(element) + 1;
+ } else {
+ // If the element is contained in a SubSectionContainer (i.e. Section or Chapter)
+ if (element.eContainer() instanceof IntentSubSectionContainer) {
+ // we get its position in this container
+ positionInContainer = ((IntentSubSectionContainer)element.eContainer()).getSubSections()
+ .indexOf(element) + 1;
+ }
+ }
+ return Integer.toString(positionInContainer);
}
/**
diff --git a/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/parser/internal/state/SChapter.java b/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/parser/internal/state/SChapter.java
index 6757b22..959154e 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/parser/internal/state/SChapter.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/parser/internal/state/SChapter.java
@@ -21,6 +21,7 @@
* @author <a href="mailto:william.piers@obeo.fr">William Piers</a>
*/
public class SChapter extends IntentSubSectionContainerState {
+
/**
* SChapter constructor.
*
@@ -36,12 +37,14 @@
* the positionManager where to register positions
* @param title
* the section title
+ * @param containerLevel
+ * the resolved container level
* @throws ParseException
* if the title cannot be parsed
*/
public SChapter(int offset, int declarationLength, IntentGenericState previous, IntentChapter chapter,
- IntentPositionManager positionManager, String title) throws ParseException {
- super(offset, declarationLength, previous, chapter, positionManager, title);
+ IntentPositionManager positionManager, String title, String containerLevel) throws ParseException {
+ super(offset, declarationLength, previous, chapter, positionManager, title, containerLevel);
}
}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/parser/internal/state/SDocument.java b/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/parser/internal/state/SDocument.java
index 44c4ce8..a54a38d 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/parser/internal/state/SDocument.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/parser/internal/state/SDocument.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.mylyn.docs.intent.parser.internal.state;
+import org.eclipse.emf.common.util.EList;
import org.eclipse.mylyn.docs.intent.core.document.IntentChapter;
import org.eclipse.mylyn.docs.intent.core.document.IntentDocument;
import org.eclipse.mylyn.docs.intent.core.document.IntentDocumentFactory;
@@ -53,8 +54,10 @@
public IntentGenericState beginChapter(int offset, int declarationLength, String title)
throws ParseException {
IntentChapter chapter = IntentDocumentFactory.eINSTANCE.createIntentChapter();
- ((IntentDocument)currentElement).getChapters().add(chapter);
- return new SChapter(offset, declarationLength, this, chapter, positionManager, title);
+ EList<IntentChapter> chapters = ((IntentDocument)currentElement).getChapters();
+ chapters.add(chapter);
+ return new SChapter(offset, declarationLength, this, chapter, positionManager, title,
+ String.valueOf(chapters.size()));
}
/**
diff --git a/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/parser/internal/state/SSection.java b/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/parser/internal/state/SSection.java
index 2962659..07c0e1a 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/parser/internal/state/SSection.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/parser/internal/state/SSection.java
@@ -46,12 +46,14 @@
* the positionManager where to register positions
* @param title
* the section title
+ * @param containerLevel
+ * the resolved container level
* @throws ParseException
* if the title cannot be parsed
*/
public SSection(int offset, int declarationLength, IntentGenericState previous, IntentSection section,
- IntentPositionManager positionManager, String title) throws ParseException {
- super(offset, declarationLength, previous, section, positionManager, title);
+ IntentPositionManager positionManager, String title, String containerLevel) throws ParseException {
+ super(offset, declarationLength, previous, section, positionManager, title, containerLevel);
}
/**
diff --git a/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/parser/modelingunit/serializer/internal/NewObjectValueForStructuralFeatureSerializer.java b/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/parser/modelingunit/serializer/internal/NewObjectValueForStructuralFeatureSerializer.java
index 9e41749..395e292 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/parser/modelingunit/serializer/internal/NewObjectValueForStructuralFeatureSerializer.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/parser/modelingunit/serializer/internal/NewObjectValueForStructuralFeatureSerializer.java
@@ -46,8 +46,8 @@
renderedForm += ModelingUnitSerializer.LINE_BREAK;
}
- // dispatcher.setPositionForInstruction(newObjectValueForStructuralFeature, initialOffset,
- // renderedForm.length());
+ dispatcher.getPositionManager().setPositionForInstruction(newObjectValueForStructuralFeature,
+ initialOffset, renderedForm.length());
dispatcher.setCurrentOffset(initialOffset + renderedForm.length());
return renderedForm;
}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/serializer/ParsedElementPosition.java b/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/serializer/ParsedElementPosition.java
index b008f85..82ef615 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/serializer/ParsedElementPosition.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.parser/src/org/eclipse/mylyn/docs/intent/serializer/ParsedElementPosition.java
@@ -105,4 +105,15 @@
return res;
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return this.getClass().getSimpleName() + "[offset: " + offset + ", declaration length: "
+ + declarationLength + ", length: " + length + "]";
+ }
+
}
diff --git a/plugins/org.eclipse.mylyn.docs.intent/META-INF/MANIFEST.MF b/plugins/org.eclipse.mylyn.docs.intent/META-INF/MANIFEST.MF
index a715ec0..e43e8c5 100644
--- a/plugins/org.eclipse.mylyn.docs.intent/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.mylyn.docs.intent/META-INF/MANIFEST.MF
@@ -3,5 +3,5 @@
Bundle-Localization: plugin
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.mylyn.docs.intent
-Bundle-Version: 0.7.0.qualifier
+Bundle-Version: 0.8.0.qualifier
Bundle-Vendor: %providerName
diff --git a/plugins/org.eclipse.mylyn.docs.intent/dev/launchconfigs/tests/Compare-All-TestSuite.launch b/plugins/org.eclipse.mylyn.docs.intent/dev/launchconfigs/tests/Compare-All-TestSuite.launch
new file mode 100644
index 0000000..27dddb4
--- /dev/null
+++ b/plugins/org.eclipse.mylyn.docs.intent/dev/launchconfigs/tests/Compare-All-TestSuite.launch
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/org.eclipse.mylyn.docs.intent.compare.test/src/org/eclipse/mylyn/docs/intent/compare/test/unit/MergingIssues.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
+<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.mylyn.docs.intent.compare.test.unit.MergingIssues"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.mylyn.docs.intent.compare.test"/>
+</launchConfiguration>
diff --git a/plugins/org.eclipse.mylyn.docs.intent/dev/target platform/juno-sdk-4.2.target b/plugins/org.eclipse.mylyn.docs.intent/dev/target platform/juno-sdk-4.2.target
index fa48d06..17ad721 100644
--- a/plugins/org.eclipse.mylyn.docs.intent/dev/target platform/juno-sdk-4.2.target
+++ b/plugins/org.eclipse.mylyn.docs.intent/dev/target platform/juno-sdk-4.2.target
@@ -8,7 +8,6 @@
<unit id="org.eclipse.acceleo.sdk.feature.group" version="3.3.0.v20120529-1042"/>
<unit id="org.eclipse.emf.cdo.sdk.feature.group" version="4.1.0.v20120612-1844"/>
<unit id="org.eclipse.emf.sdk.feature.group" version="2.8.0.v20120608-0554"/>
-<unit id="org.eclipse.emf.compare.sdk.feature.group" version="1.3.1.v20120605-0748"/>
<unit id="org.eclipse.emf.transaction.sdk.feature.group" version="1.6.0.v20120328-0001-777Z-9A_WsZmcPluNecyPkvrPKlH"/>
<unit id="org.eclipse.emf.validation.sdk.feature.group" version="1.6.0.v20120328-0001-67T-96SGR75UNqZNTdeQnghI6uFA"/>
<repository location="http://download.eclipse.org/releases/juno"/>
diff --git a/plugins/org.eclipse.mylyn.docs.intent/pom.xml b/plugins/org.eclipse.mylyn.docs.intent/pom.xml
index 40a627c..c03327c 100644
--- a/plugins/org.eclipse.mylyn.docs.intent/pom.xml
+++ b/plugins/org.eclipse.mylyn.docs.intent/pom.xml
@@ -13,7 +13,7 @@
<parent>
<groupId>org.eclipse.mylyn.docs.intent-group</groupId>
<artifactId>intent-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
diff --git a/pom.xml b/pom.xml
index 37d4127..4ffd714 100644
--- a/pom.xml
+++ b/pom.xml
@@ -19,7 +19,7 @@
<groupId>org.eclipse.mylyn.docs.intent-group</groupId>
<artifactId>intent-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<packaging>pom</packaging>
<licenses>
@@ -91,6 +91,7 @@
<!-- Intent tests -->
<module>tests/org.eclipse.mylyn.docs.intent.parser.test</module>
+ <module>tests/org.eclipse.mylyn.docs.intent.compare.test</module>
<module>tests/org.eclipse.mylyn.docs.intent.collab.test</module>
<module>tests/org.eclipse.mylyn.docs.intent.client.ui.test</module>
<module>tests/org.eclipse.mylyn.docs.intent.client.compiler.test</module>
@@ -327,7 +328,9 @@
<repository><id>orbit</id><layout>p2</layout>
<url>http://download.eclipse.org/tools/orbit/downloads/drops/updateSite</url>
</repository>
-
+ <repository><id>emfcompare2</id><layout>p2</layout>
+ <url>https://hudson.eclipse.org/hudson/view/Modeling/job/emf-compare-master/lastSuccessfulBuild/artifact/packaging/org.eclipse.emf.compare.update/target/repository/</url>
+ </repository>
</repositories>
</profile>
</profiles>
diff --git a/tests/org.eclipse.mylyn.docs.intent.client.compiler.test/META-INF/MANIFEST.MF b/tests/org.eclipse.mylyn.docs.intent.client.compiler.test/META-INF/MANIFEST.MF
index 81b95c8..cd862df 100644
--- a/tests/org.eclipse.mylyn.docs.intent.client.compiler.test/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.mylyn.docs.intent.client.compiler.test/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@
Bundle-Localization: plugin
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.mylyn.docs.intent.client.compiler.test
-Bundle-Version: 0.7.0.qualifier
+Bundle-Version: 0.8.0.qualifier
Bundle-Vendor: %providerName
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Require-Bundle: org.junit;bundle-version="4.0.0",
@@ -11,7 +11,7 @@
org.eclipse.mylyn.docs.intent.client.compiler;bundle-version="0.7.0",
org.eclipse.mylyn.docs.intent.parser;bundle-version="0.7.0",
org.eclipse.mylyn.docs.intent.core;bundle-version="0.7.0",
- org.eclipse.emf.compare.diff;bundle-version="1.3.1",
- org.eclipse.emf.compare.match;bundle-version="1.3.1",
+ org.eclipse.emf.compare;bundle-version="2.0.0",
org.eclipse.emf.codegen.ecore;bundle-version="2.8.0",
+ org.eclipse.mylyn.docs.intent.compare;bundle-version="0.7.0",
org.eclipse.mylyn.docs.intent.parser.test;bundle-version="0.7.0"
diff --git a/tests/org.eclipse.mylyn.docs.intent.client.compiler.test/expectedResults/resources/enumerations.intent.TestGenModel.xmi b/tests/org.eclipse.mylyn.docs.intent.client.compiler.test/expectedResults/resources/enumerations.intent.TestGenModel.xmi
index a94dc95..b861f29 100644
--- a/tests/org.eclipse.mylyn.docs.intent.client.compiler.test/expectedResults/resources/enumerations.intent.TestGenModel.xmi
+++ b/tests/org.eclipse.mylyn.docs.intent.client.compiler.test/expectedResults/resources/enumerations.intent.TestGenModel.xmi
@@ -1,2 +1,2 @@
<?xml version="1.0" encoding="ASCII"?>
-<ecore:EObject xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"/>
+<genmodel:GenModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" featureDelegation="Virtual"/>
diff --git a/tests/org.eclipse.mylyn.docs.intent.client.compiler.test/pom.xml b/tests/org.eclipse.mylyn.docs.intent.client.compiler.test/pom.xml
index e2dd881..170f863 100644
--- a/tests/org.eclipse.mylyn.docs.intent.client.compiler.test/pom.xml
+++ b/tests/org.eclipse.mylyn.docs.intent.client.compiler.test/pom.xml
@@ -13,7 +13,7 @@
<parent>
<groupId>org.eclipse.mylyn.docs.intent-group</groupId>
<artifactId>intent-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
diff --git a/tests/org.eclipse.mylyn.docs.intent.client.compiler.test/src/org/eclipse/mylyn/docs/intent/client/compiler/test/util/AbstractIntentCompilerTest.java b/tests/org.eclipse.mylyn.docs.intent.client.compiler.test/src/org/eclipse/mylyn/docs/intent/client/compiler/test/util/AbstractIntentCompilerTest.java
index fe44b00..7261515 100644
--- a/tests/org.eclipse.mylyn.docs.intent.client.compiler.test/src/org/eclipse/mylyn/docs/intent/client/compiler/test/util/AbstractIntentCompilerTest.java
+++ b/tests/org.eclipse.mylyn.docs.intent.client.compiler.test/src/org/eclipse/mylyn/docs/intent/client/compiler/test/util/AbstractIntentCompilerTest.java
@@ -14,7 +14,6 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
import junit.framework.Assert;
@@ -26,11 +25,7 @@
import org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage;
import org.eclipse.emf.common.util.BasicMonitor;
import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.compare.diff.metamodel.DiffModel;
-import org.eclipse.emf.compare.diff.service.DiffService;
-import org.eclipse.emf.compare.match.MatchOptions;
-import org.eclipse.emf.compare.match.metamodel.MatchModel;
-import org.eclipse.emf.compare.match.service.MatchService;
+import org.eclipse.emf.compare.Comparison;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.resource.Resource;
@@ -40,6 +35,7 @@
import org.eclipse.mylyn.docs.intent.client.compiler.ModelingUnitCompiler;
import org.eclipse.mylyn.docs.intent.client.compiler.generator.modellinking.ModelingUnitLinkResolver;
import org.eclipse.mylyn.docs.intent.client.compiler.utils.IntentCompilerInformationHolder;
+import org.eclipse.mylyn.docs.intent.compare.utils.EMFCompareUtils;
import org.eclipse.mylyn.docs.intent.core.compiler.CompilationStatus;
import org.eclipse.mylyn.docs.intent.core.compiler.CompilationStatusSeverity;
import org.eclipse.mylyn.docs.intent.core.document.IntentDocumentPackage;
@@ -178,17 +174,9 @@
}
} else {
Resource expected = resourceSet.getResource(expectedURI, true);
- try {
- final HashMap<String, Object> options = new HashMap<String, Object>();
- options.put(MatchOptions.OPTION_IGNORE_XMI_ID, Boolean.TRUE);
- MatchModel matchModel = MatchService
- .doResourceMatch(expected, generatedResource, options);
- DiffModel diff = DiffService.doDiff(matchModel, false);
- Assert.assertTrue("There are differences between expected and actual", diff
- .getDifferences().isEmpty());
- } catch (InterruptedException e) {
- throw new AssertionFailedError(e.getMessage());
- }
+ Comparison comparison = EMFCompareUtils.compare(expected, generatedResource);
+ Assert.assertTrue("There are differences between expected and actual", comparison
+ .getDifferences().isEmpty());
}
}
diff --git a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/META-INF/MANIFEST.MF b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/META-INF/MANIFEST.MF
index 266fd11..96695da 100644
--- a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.mylyn.docs.intent.client.ui.test
-Bundle-Version: 0.7.0.qualifier
+Bundle-Version: 0.8.0.qualifier
Bundle-ClassPath: .
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -20,8 +20,8 @@
org.eclipse.jface.text;bundle-version="3.7.0",
org.eclipse.mylyn.docs.intent.collab.ide;bundle-version="0.7.0",
com.google.guava,
- org.eclipse.emf.compare.match;bundle-version="[1.2.0,2.0.0)",
org.eclipse.mylyn.docs.intent.retro;bundle-version="0.7.0",
org.eclipse.mylyn.docs.intent.compare;bundle-version="0.7.0",
org.eclipse.mylyn.docs.intent.modelingunit.update;bundle-version="0.7.0",
- org.eclipse.mylyn.docs.intent.test.server
+ org.eclipse.mylyn.docs.intent.test.server,
+ org.eclipse.emf.compare;bundle-version="2.0.0"
diff --git a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/data/unit/documents/synchronizer/synchronizer.intent b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/data/unit/documents/synchronizer/synchronizer.intent
new file mode 100644
index 0000000..7140b2c
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/data/unit/documents/synchronizer/synchronizer.intent
@@ -0,0 +1,80 @@
+Document {
+ Chapter Synchronizer {
+ Tests the synchronization status.
+
+ Section MAIN {
+ @M
+ Resource testResource {
+ URI = "platform:/resource/synchronizer/test.ecore";
+ content += testPackage;
+ }
+ new EPackage testPackage {
+ name = "testPackage";
+ nsURI = "testPackageURI";
+ nsPrefix = "testPackagePrefix";
+ eClassifiers += new EClass A {};
+ eClassifiers += new EClass B {};
+ eClassifiers += new EClass C {};
+ }
+ M@
+
+ }
+
+ Section Containement {
+ @M
+ testPackage {
+ eSubpackages += new EPackage OnlyInCurrentDocument {
+ name = "OnlyInCurrentDocument";
+ nsURI = "OnlyInCurrentDocument";
+ nsPrefix = "OnlyInCurrentDocument";
+ };
+ }
+ M@
+
+ }
+
+ Section References {
+ Section Added {
+ @M
+ testPackage {
+ eClassifiers += new EClass AddedReference {
+ eSuperTypes += A;
+ };
+ }
+ M@
+
+ }
+
+ Section Deleted {
+ @M
+ testPackage {
+ eClassifiers += new EClass DeletedReference {};
+ }
+ M@
+
+ }
+
+ Section Changed {
+ @M
+ testPackage {
+ eClassifiers += new EClass ChangedReference {
+ eSuperTypes += B;
+ };
+ }
+ M@
+
+ }
+ }
+
+ Section Attributes {
+ @M
+ testPackage {
+ eClassifiers += new EClass Attributes {
+ abstract = "true";
+ };
+ }
+ M@
+
+ }
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/data/unit/documents/synchronizer/synchronizer.zip b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/data/unit/documents/synchronizer/synchronizer.zip
new file mode 100644
index 0000000..e81b531
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/data/unit/documents/synchronizer/synchronizer.zip
Binary files differ
diff --git a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/pom.xml b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/pom.xml
index bfbcd6c..ea5cceb 100644
--- a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/pom.xml
+++ b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/pom.xml
@@ -13,7 +13,7 @@
<parent>
<groupId>org.eclipse.mylyn.docs.intent-group</groupId>
<artifactId>intent-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
diff --git a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/suite/UITestSuite.java b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/suite/UITestSuite.java
index 1a4c6ab..95ce414 100644
--- a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/suite/UITestSuite.java
+++ b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/suite/UITestSuite.java
@@ -17,7 +17,6 @@
import org.eclipse.mylyn.docs.intent.client.ui.test.unit.cdo.CDOIntegrationTest;
import org.eclipse.mylyn.docs.intent.client.ui.test.unit.compare.ChangeEditorUpdateTest;
-import org.eclipse.mylyn.docs.intent.client.ui.test.unit.compare.IntentMatchEngineTests;
import org.eclipse.mylyn.docs.intent.client.ui.test.unit.compare.SimpleOrderTests;
import org.eclipse.mylyn.docs.intent.client.ui.test.unit.demo.compilation.CompileTest;
import org.eclipse.mylyn.docs.intent.client.ui.test.unit.demo.opening.OpenEditorTest;
@@ -30,8 +29,7 @@
import org.eclipse.mylyn.docs.intent.client.ui.test.unit.scenario.IntentAbstractResourceTest;
import org.eclipse.mylyn.docs.intent.client.ui.test.unit.scenario.IntentDocumentationUpdateDoesNotCauseResolvingIssuesTest;
import org.eclipse.mylyn.docs.intent.client.ui.test.unit.scenario.IntentProjectReopeningTest;
-import org.eclipse.mylyn.docs.intent.client.ui.test.unit.update.DragAndDropTest;
-import org.eclipse.mylyn.docs.intent.client.ui.test.unit.update.QuickFixTest;
+import org.eclipse.mylyn.docs.intent.client.ui.test.unit.synchronizer.SynchronizerTest;
/**
* This suite will launch all the tests relative to the UI behavior.
@@ -65,10 +63,11 @@
final TestSuite clientSuite = new TestSuite("Intent Client tests");
suite.addTest(clientSuite);
- // Match & merge tests
- final TestSuite compareSuite = new TestSuite("Intent match and merge tests");
- compareSuite.addTestSuite(IntentMatchEngineTests.class);
- clientSuite.addTest(compareSuite);
+ // TODO reactivate tests when comparison match stable
+ // // Match & merge tests
+ // final TestSuite compareSuite = new TestSuite("Intent match and merge tests");
+ // compareSuite.addTestSuite(IntentMatchEngineTests.class);
+ // clientSuite.addTest(compareSuite);
/*
* Intent UI Tests
@@ -84,6 +83,7 @@
basicTestSuite.addTestSuite(RefresherTest.class);
basicTestSuite.addTestSuite(ChangeEditorUpdateTest.class);
basicTestSuite.addTestSuite(SimpleOrderTests.class);
+ basicTestSuite.addTestSuite(SynchronizerTest.class);
uiTestSuite.addTest(basicTestSuite);
// Scenario tests
@@ -104,11 +104,12 @@
demoSuite.addTestSuite(JavaTest.class);
// uiTestSuite.addTest(demoSuite);
- // Updates tests
- final TestSuite updatesSuite = new TestSuite("Modeling Unit update tests");
- updatesSuite.addTestSuite(QuickFixTest.class);
- updatesSuite.addTestSuite(DragAndDropTest.class);
- uiTestSuite.addTest(updatesSuite);
+ // TODO reactivate tests when comparison match stable
+ // // Updates tests
+ // final TestSuite updatesSuite = new TestSuite("Modeling Unit update tests");
+ // updatesSuite.addTestSuite(QuickFixTest.class);
+ // updatesSuite.addTestSuite(DragAndDropTest.class);
+ // uiTestSuite.addTest(updatesSuite);
/*
* CDO related test Suite
diff --git a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/unit/compare/IntentMatchEngineTests.java b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/unit/compare/IntentMatchEngineTests.java
index e09121d..195c76c 100644
--- a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/unit/compare/IntentMatchEngineTests.java
+++ b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/unit/compare/IntentMatchEngineTests.java
@@ -10,20 +10,16 @@
*******************************************************************************/
package org.eclipse.mylyn.docs.intent.client.ui.test.unit.compare;
-import com.google.common.collect.Sets;
-
import java.util.Collection;
import java.util.List;
import junit.framework.AssertionFailedError;
-import org.eclipse.emf.compare.diff.metamodel.DiffElement;
-import org.eclipse.emf.compare.diff.metamodel.DifferenceKind;
-import org.eclipse.emf.compare.diff.metamodel.ModelElementChangeLeftTarget;
-import org.eclipse.emf.compare.diff.metamodel.ModelElementChangeRightTarget;
+import org.eclipse.emf.compare.Diff;
+import org.eclipse.emf.compare.DifferenceKind;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.mylyn.docs.intent.client.ui.test.util.AbstractIntentUITest;
-import org.eclipse.mylyn.docs.intent.compare.IntentASTMerger;
+import org.eclipse.mylyn.docs.intent.compare.utils.EMFCompareUtils;
import org.eclipse.mylyn.docs.intent.core.document.IntentChapter;
import org.eclipse.mylyn.docs.intent.core.document.IntentDocument;
import org.eclipse.mylyn.docs.intent.core.document.IntentSection;
@@ -32,11 +28,16 @@
import org.eclipse.mylyn.docs.intent.parser.IntentParser;
import org.eclipse.mylyn.docs.intent.parser.modelingunit.ParseException;
+<<<<<<< HEAD
/**
* Test ensuring that the Intent match engine works as expected.
*
* @author <a href="mailto:alex.lagarde@obeo.fr">Alex Lagarde</a>
*/
+=======
+import com.google.common.collect.Sets;
+
+>>>>>>> master
public class IntentMatchEngineTests extends AbstractIntentUITest {
private static final String INTENT_DOCUMENT_FOLDER = "data/unit/documents/editorupdates/";
@@ -101,10 +102,10 @@
IntentStructuredElement copy = EcoreUtil.copy(getIntentDocument());
// Check that copy is equal to original
- List<DiffElement> differences = IntentASTMerger.getDifferences(copy, getIntentDocument());
+ List<Diff> differences = EMFCompareUtils.compareDocuments(copy, getIntentDocument()).getDifferences();
String message = "No difference should be detected between an Intent document and its copy";
try {
- assertDiffElementIsAsExpected(message, differences, 0);
+ assertDiffIsAsExpected(message, differences, 0);
} catch (AssertionFailedError e) {
errors.add(e);
}
@@ -124,16 +125,18 @@
// according to where the chapter is added, we should have the following results :
for (int position = 0; position <= getIntentDocument().getChapters().size(); position++) {
copy.getChapters().add(position, newChapter);
- List<DiffElement> differences = IntentASTMerger.getDifferences(copy, getIntentDocument());
+ List<Diff> differences = EMFCompareUtils.compareDocuments(copy, getIntentDocument())
+ .getDifferences();
String message = "One new chapter should be detected at position " + position;
try {
- DiffElement diff = assertDiffElementIsAsExpected(message, differences, 2);
- assertEquals(message + LINEBREAK + getDiffAsString(differences), DifferenceKind.ADDITION,
+ Diff diff = assertDiffIsAsExpected(message, differences, 2);
+ assertEquals(message + '\n' + getDiffAsString(differences), DifferenceKind.ADD,
diff.getKind());
- assertEquals(message + getDiffAsString(differences), newChapter,
- ((ModelElementChangeLeftTarget)diff).getLeftElement());
- assertEquals(message + getDiffAsString(differences), getIntentDocument(),
- ((ModelElementChangeLeftTarget)diff).getRightParent());
+ // TODO migrate to emf compare2
+ // assertEquals(message + getDiffAsString(differences), newChapter,
+ // ((ModelElementChangeLeftTarget)diff).getLeftElement());
+ // assertEquals(message + getDiffAsString(differences), getIntentDocument(),
+ // ((ModelElementChangeLeftTarget)diff).getRightParent());
} catch (AssertionFailedError e) {
errors.add(e);
}
@@ -158,14 +161,16 @@
copy.getChapters().remove(chapterToRemoveinCopy);
String message = "A Chapter deletion should be detected at " + position;
try {
- List<DiffElement> differences = IntentASTMerger.getDifferences(copy, getIntentDocument());
- DiffElement diff = assertDiffElementIsAsExpected(message, differences, 2);
- assertEquals(message + LINEBREAK + getDiffAsString(differences), DifferenceKind.DELETION,
+ List<Diff> differences = EMFCompareUtils.compareDocuments(copy, getIntentDocument())
+ .getDifferences();
+ Diff diff = assertDiffIsAsExpected(message, differences, 2);
+ assertEquals(message + '\n' + getDiffAsString(differences), DifferenceKind.DELETE,
diff.getKind());
- assertEquals(message + LINEBREAK + getDiffAsString(differences), chapterToRemoveInOriginal,
- ((ModelElementChangeRightTarget)diff).getRightElement());
- assertEquals(message + LINEBREAK + getDiffAsString(differences), copy,
- ((ModelElementChangeRightTarget)diff).getLeftParent());
+ // TODO migrate to emf compare2
+ // assertEquals(message + '\n' + getDiffAsString(differences), chapterToRemoveInOriginal,
+ // ((ModelElementChangeRightTarget)diff).getRightElement());
+ // assertEquals(message + '\n' + getDiffAsString(differences), copy,
+ // ((ModelElementChangeRightTarget)diff).getLeftParent());
} catch (AssertionFailedError e) {
errors.add(e);
}
@@ -201,17 +206,19 @@
// according to where the section is added, we should have the following results :
for (int sectionID = 0; sectionID <= container.getSubSections().size(); sectionID++) {
containerCopy.getIntentContent().add(sectionID, newSection);
- List<DiffElement> differences = IntentASTMerger.getDifferences(copy, getIntentDocument());
+ List<Diff> differences = EMFCompareUtils.compareDocuments(copy, getIntentDocument())
+ .getDifferences();
String message = "One new section should be detected at position " + containerLevel + "."
+ sectionID;
try {
- DiffElement diff = assertDiffElementIsAsExpected(message, differences, containerLevel);
- assertEquals(message + LINEBREAK + getDiffAsString(differences), DifferenceKind.ADDITION,
+ Diff diff = assertDiffIsAsExpected(message, differences, containerLevel);
+ assertEquals(message + '\n' + getDiffAsString(differences), DifferenceKind.ADD,
diff.getKind());
- assertEquals(message + LINEBREAK + getDiffAsString(differences), newSection,
- ((ModelElementChangeLeftTarget)diff).getLeftElement());
- assertEquals(message + LINEBREAK + getDiffAsString(differences), container,
- ((ModelElementChangeLeftTarget)diff).getRightParent());
+ // TODO migrate to emf compare2
+ // assertEquals(message + '\n' + getDiffAsString(differences), newSection,
+ // ((ModelElementChangeLeftTarget)diff).getLeftElement());
+ // assertEquals(message + '\n' + getDiffAsString(differences), container,
+ // ((ModelElementChangeLeftTarget)diff).getRightParent());
} catch (AssertionFailedError e) {
errors.add(e);
}
@@ -256,18 +263,21 @@
IntentSection removedSection = (IntentSection)containerCopy.getSubSections().get(sectionID);
int trueIndex = containerCopy.getIntentContent().indexOf(removedSection);
containerCopy.getIntentContent().remove(removedSection);
- List<DiffElement> differences = IntentASTMerger.getDifferences(copy, getIntentDocument());
+ List<Diff> differences = EMFCompareUtils.compareDocuments(copy, getIntentDocument())
+ .getDifferences();
String message = "A Section deletion should be detected at position" + containerLevel + "."
+ sectionID;
try {
- DiffElement diff = assertDiffElementIsAsExpected(message, differences, containerLevel);
- assertEquals(message + LINEBREAK + getDiffAsString(differences), DifferenceKind.DELETION,
+ Diff diff = assertDiffIsAsExpected(message, differences, containerLevel);
+ assertEquals(message + '\n' + getDiffAsString(differences), DifferenceKind.DELETE,
diff.getKind());
- assertEquals(message + LINEBREAK + getDiffAsString(differences), container.getIntentContent()
- .get(trueIndex), ((ModelElementChangeRightTarget)diff).getRightElement());
- assertEquals(message + LINEBREAK + getDiffAsString(differences), containerCopy,
- ((ModelElementChangeRightTarget)diff).getLeftParent());
+ // TODO migrate to emf compare2
+ // assertEquals(message + '\n' + getDiffAsString(differences),
+ // container.getIntentContent().get(trueIndex),
+ // ((ModelElementChangeRightTarget)diff).getRightElement());
+ // assertEquals(message + '\n' + getDiffAsString(differences), containerCopy,
+ // ((ModelElementChangeRightTarget)diff).getLeftParent());
} catch (AssertionFailedError e) {
errors.add(e);
}
@@ -294,32 +304,32 @@
* the expected level for the diff (2 for chapter, 3 for root section, 4 for subsection...).
* @return the expected diff element if correct
*/
- protected DiffElement assertDiffElementIsAsExpected(String message, Collection<DiffElement> differences,
- int expectedLevel) {
+ protected Diff assertDiffIsAsExpected(String message, Collection<Diff> differences, int expectedLevel) {
compareCasesNumber++;
- assertEquals(message + LINEBREAK + getDiffAsString(differences), 1, differences.size());
+ assertEquals(message + '\n' + getDiffAsString(differences), 1, differences.size());
// We want to have exactly one difference at the expected level
- DiffElement childDiff = differences.iterator().next();
+ Diff childDiff = differences.iterator().next();
int currentLevel = 0;
while (childDiff != null && currentLevel < expectedLevel) {
- assertEquals(message + LINEBREAK + getDiffAsString(differences), 1, childDiff
- .getSubDiffElements().size());
+ // assertEquals(message + '\n' + getDiffAsString(differences), 1, childDiff.getSubDiffs().size());
+ // TODO migrate to emf compare2
currentLevel++;
- childDiff = childDiff.getSubDiffElements().iterator().next();
+ // childDiff = childDiff.getSubDiffs().iterator().next();
+ // TODO migrate to emf compare2
}
// This difference should not have any sub difference elements
- assertEquals(message + LINEBREAK + getDiffAsString(differences), 0, childDiff.getSubDiffElements()
- .size());
+ // assertEquals(message + '\n' + getDiffAsString(differences), 0, childDiff.getSubDiffs().size()); //
+ // TODO migrate to emf compare2
return childDiff;
}
- protected String getDiffAsString(Collection<DiffElement> differences) {
+ protected String getDiffAsString(Collection<Diff> differences) {
String diff = "";
- for (DiffElement element : differences) {
- diff += element.toString() + LINEBREAK;
- diff += getDiffAsString(element.getSubDiffElements());
+ for (Diff element : differences) {
+ diff += element.toString() + '\n';
+ // diff += getDiffAsString(element.getSubDiffs()); // TODO migrate to emf compare2
}
return diff;
}
diff --git a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/unit/refresher/RefresherTest.java b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/unit/refresher/RefresherTest.java
index e9e70da..cd865ed 100644
--- a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/unit/refresher/RefresherTest.java
+++ b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/unit/refresher/RefresherTest.java
@@ -62,7 +62,12 @@
waitForCompiler(false);
}
- private List<String> getProblems() {
+ /**
+ * Returns the current problem messages.
+ *
+ * @return the current problem messages
+ */
+ protected List<String> getProblems() {
List<String> res = new ArrayList<String>();
try {
IMarker[] markers = intentProject.findMarkers("org.eclipse.core.resources.problemmarker", true,
diff --git a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/unit/synchronizer/SynchronizerTest.java b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/unit/synchronizer/SynchronizerTest.java
new file mode 100644
index 0000000..44627f4
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/unit/synchronizer/SynchronizerTest.java
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.mylyn.docs.intent.client.ui.test.unit.synchronizer;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.mylyn.docs.intent.client.ui.editor.IntentEditor;
+import org.eclipse.mylyn.docs.intent.client.ui.editor.IntentEditorDocument;
+import org.eclipse.mylyn.docs.intent.client.ui.test.util.AbstractZipBasedTest;
+import org.eclipse.mylyn.docs.intent.core.compiler.SynchronizerCompilationStatus;
+import org.eclipse.mylyn.docs.intent.serializer.ParsedElementPosition;
+
+/**
+ * Ensures that the Intent project synchronizer is correctly notified.
+ *
+ * @author <a href="mailto:william.piers@obeo.fr">William Piers</a>
+ */
+public class SynchronizerTest extends AbstractZipBasedTest {
+
+ protected IntentEditor editor;
+
+ protected IntentEditorDocument document;
+
+ private IMarker[] markers;
+
+ /**
+ * Constructor.
+ */
+ public SynchronizerTest() {
+ super("data/unit/documents/synchronizer/synchronizer.zip", "synchronizer");
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.mylyn.docs.intent.client.ui.test.util.AbstractZipBasedTest#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ editor = openIntentEditor();
+ document = (IntentEditorDocument)(editor.getDocumentProvider().getDocument(editor.getEditorInput()));
+ }
+
+ /**
+ * Tests the synchronization status.
+ *
+ * @throws Exception
+ */
+ public void testSynchronizationStatus() throws Exception {
+ markers = intentProject.findMarkers("org.eclipse.core.resources.problemmarker", true,
+ IResource.DEPTH_INFINITE);
+
+ assertMessageExists(
+ "[Sync] The EPackage OnlyInCurrentDocument is defined in the <b>Current Document</b> model<br/>but not in the <b>Working Copy</b> model.",
+ 552, 35);
+ assertMessageExists(
+ "[Sync] The EClass OnlyInWorkingCopy is defined in the <b>Working Copy</b> model<br/>but not in the <b>Current Document</b> model.",
+ 222, 25);
+ assertMessageExists("[Sync] The EClass A has been removed from the reference 'eSuperTypes'", 991, 28);
+ assertMessageExists("[Sync] The EClass A has been removed from the reference 'eSuperTypes'", 1121, 28);
+ assertMessageExists("[Sync] The EClass A has been removed from the reference 'eSuperTypes'", 991, 28);
+ assertMessageExists("[Sync] The EClass A has been removed from the reference 'eSuperTypes'", 1121, 28);
+ assertMessageExists("[Sync] The EClass B has been added to the reference 'eSuperTypes'", 1173, 1);
+ assertMessageExists("[Sync] The EClass A has been removed from the reference 'eSuperTypes'", 991, 28);
+ assertMessageExists("[Sync] The EClass A has been removed from the reference 'eSuperTypes'", 1121, 28);
+ assertMessageExists("[Sync] The EClass A has been removed from the reference 'eSuperTypes'", 991, 28);
+ assertMessageExists("[Sync] The EClass A has been removed from the reference 'eSuperTypes'", 1121, 28);
+ assertMessageExists("[Sync] The EClass A has been added to the reference 'eSuperTypes'", 881, 1);
+ assertMessageExists(
+ "[Sync] The attribute 'abstract' in Attributes has changed.<br/><b>Current Document</b> : true<br/><b>Working Copy</b> : false",
+ 1326, 6);
+ }
+
+ /**
+ * Checks that the given message exists at the given position.
+ *
+ * @param message
+ * the message
+ * @param offset
+ * the sync warning offset in the document
+ * @param length
+ * the sync warning length in the document
+ * @throws CoreException
+ */
+ private void assertMessageExists(String message, int offset, int length) throws CoreException {
+ boolean found = false;
+ for (IMarker marker : markers) {
+ SynchronizerCompilationStatus status = (SynchronizerCompilationStatus)editor.getIntentContent()
+ .eResource().getResourceSet()
+ .getEObject(URI.createURI((String)marker.getAttribute(IMarker.LOCATION)), false);
+ ParsedElementPosition position = document.getIntentPosition(status.getTarget());
+ String markerMessage = ((String)marker.getAttribute(IMarker.MESSAGE)).trim();
+ if (position.getOffset() == offset && position.getDeclarationLength() == length) {
+ assertEquals(message, markerMessage);
+ found = true;
+ }
+ }
+ assertTrue("No message found at offset " + offset, found);
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/util/AnnotationUtils.java b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/util/AnnotationUtils.java
index c1151be..886f84d 100644
--- a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/util/AnnotationUtils.java
+++ b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/util/AnnotationUtils.java
@@ -12,18 +12,11 @@
import java.io.IOException;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.compare.diff.merge.service.MergeService;
-import org.eclipse.emf.compare.diff.metamodel.DiffElement;
-import org.eclipse.emf.compare.diff.metamodel.DiffModel;
-import org.eclipse.emf.compare.diff.service.DiffService;
-import org.eclipse.emf.compare.match.MatchOptions;
-import org.eclipse.emf.compare.match.metamodel.MatchModel;
-import org.eclipse.emf.compare.match.service.MatchService;
+import org.eclipse.emf.compare.Diff;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
@@ -34,6 +27,7 @@
import org.eclipse.mylyn.docs.intent.client.ui.editor.annotation.IntentAnnotation;
import org.eclipse.mylyn.docs.intent.client.ui.editor.annotation.IntentAnnotationMessageType;
import org.eclipse.mylyn.docs.intent.collab.handlers.adapters.RepositoryAdapter;
+import org.eclipse.mylyn.docs.intent.compare.utils.EMFCompareUtils;
import org.eclipse.mylyn.docs.intent.core.compiler.SynchronizerCompilationStatus;
import org.eclipse.mylyn.docs.intent.core.modelingunit.ModelingUnit;
import org.eclipse.mylyn.docs.intent.modelingunit.update.SyncStatusUpdater;
@@ -91,7 +85,7 @@
*/
public static IntentAnnotation getIntentAnnotation(IntentEditor intentEditor,
IntentAnnotationMessageType messageType, String expectedMessage, boolean exactMessage) {
- Iterator annotationIterator = ((IntentDocumentProvider)intentEditor.getDocumentProvider())
+ Iterator<?> annotationIterator = ((IntentDocumentProvider)intentEditor.getDocumentProvider())
.getAnnotationModel(null).getAnnotationIterator();
while (annotationIterator.hasNext()) {
Object annotation = annotationIterator.next();
@@ -160,14 +154,9 @@
Resource workingCopyResource = rs.getResource(URI.createURI(workingCopyResourceURI), true);
// Step 3.1 : making match and diff
- final HashMap<String, Object> options = new HashMap<String, Object>();
- options.put(MatchOptions.OPTION_IGNORE_XMI_ID, Boolean.TRUE);
- MatchModel match = MatchService.doResourceMatch(generatedResource, workingCopyResource, options);
- DiffModel diff = DiffService.doDiff(match, false);
-
- // Step 3.2 : Merges all differences from local to repository
- List<DiffElement> differences = new ArrayList<DiffElement>(diff.getOwnedElements());
- MergeService.merge(differences, true);
+ for (Diff diff : EMFCompareUtils.compare(workingCopyResource, generatedResource).getDifferences()) {
+ diff.copyLeftToRight();
+ }
// Step 3.3 : Save model
workingCopyResource.save(null);
@@ -218,7 +207,7 @@
*/
public static void displayAnnotations(IntentEditor intentEditor) {
System.err.println("Annotations in \"" + intentEditor.getPartName() + "\":");
- Iterator annotationIterator = ((IntentDocumentProvider)intentEditor.getDocumentProvider())
+ Iterator<?> annotationIterator = ((IntentDocumentProvider)intentEditor.getDocumentProvider())
.getAnnotationModel(null).getAnnotationIterator();
while (annotationIterator.hasNext()) {
Object o = annotationIterator.next();
diff --git a/tests/org.eclipse.mylyn.docs.intent.collab.test/META-INF/MANIFEST.MF b/tests/org.eclipse.mylyn.docs.intent.collab.test/META-INF/MANIFEST.MF
index d1c168e..b08ce0e 100644
--- a/tests/org.eclipse.mylyn.docs.intent.collab.test/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.mylyn.docs.intent.collab.test/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.mylyn.docs.intent.collab.test;singleton:=true
-Bundle-Version: 0.7.0.qualifier
+Bundle-Version: 0.8.0.qualifier
Bundle-ClassPath: .
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/tests/org.eclipse.mylyn.docs.intent.collab.test/pom.xml b/tests/org.eclipse.mylyn.docs.intent.collab.test/pom.xml
index 78918fe..26f56ee 100644
--- a/tests/org.eclipse.mylyn.docs.intent.collab.test/pom.xml
+++ b/tests/org.eclipse.mylyn.docs.intent.collab.test/pom.xml
@@ -13,7 +13,7 @@
<parent>
<groupId>org.eclipse.mylyn.docs.intent-group</groupId>
<artifactId>intent-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
diff --git a/tests/org.eclipse.mylyn.docs.intent.collab.test/src/org/eclipse/mylyn/docs/intent/collab/test/assertioncontainer/NotificationAssertionContainer.java b/tests/org.eclipse.mylyn.docs.intent.collab.test/src/org/eclipse/mylyn/docs/intent/collab/test/assertioncontainer/NotificationAssertionContainer.java
index b304134..a24c5ca 100644
--- a/tests/org.eclipse.mylyn.docs.intent.collab.test/src/org/eclipse/mylyn/docs/intent/collab/test/assertioncontainer/NotificationAssertionContainer.java
+++ b/tests/org.eclipse.mylyn.docs.intent.collab.test/src/org/eclipse/mylyn/docs/intent/collab/test/assertioncontainer/NotificationAssertionContainer.java
@@ -67,9 +67,9 @@
if ((notification != null) && expectedNotification) {
// Then we check that the notification is relative to the expected target
isNotificationConformToExpected = isNotificationConformToExpected
- && (EcoreUtil.equals(notification.getRightRoots().get(0), expectedTarget));
+ && (EcoreUtil.equals(notification.getImpactedElements().get(0), expectedTarget));
if (!isNotificationConformToExpected) {
- System.err.println(" got :" + notification.getRightRoots());
+ System.err.println(" got :" + notification.getImpactedElements());
System.err.println("expected :" + expectedTarget.eResource());
}
}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/.checkstyle b/tests/org.eclipse.mylyn.docs.intent.compare.test/.checkstyle
new file mode 100644
index 0000000..4017aff
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/.checkstyle
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<fileset-config file-format-version="1.2.0" simple-config="true">
+ <local-check-config name="Intent" location="/org.eclipse.mylyn.docs.intent/dev/code/checkstyleConfiguration.xml" type="project" description="">
+ <additional-data name="protect-config-file" value="false"/>
+ </local-check-config>
+ <fileset name="tous" enabled="true" check-config-name="Intent" local="true">
+ <file-match-pattern match-pattern="." include-pattern="true"/>
+ </fileset>
+ <filter name="FilesFromPackage" enabled="true">
+ <filter-data value="src/org/eclipse/mylyn/docs/intent/compare/debug"/>
+ </filter>
+</fileset-config>
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/.classpath b/tests/org.eclipse.mylyn.docs.intent.compare.test/.classpath
new file mode 100644
index 0000000..0f50db1
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/.project b/tests/org.eclipse.mylyn.docs.intent.compare.test/.project
new file mode 100644
index 0000000..a489dab
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/.project
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.mylyn.docs.intent.compare.test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
+ <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>
+ </natures>
+</projectDescription>
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/.settings/org.eclipse.jdt.core.prefs b/tests/org.eclipse.mylyn.docs.intent.compare.test/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..c82c880
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,288 @@
+#Fri Sep 23 21:59:11 CEST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_assignment=0
+org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
+org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
+org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
+org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
+org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
+org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
+org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=0
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=0
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
+org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_after_package=1
+org.eclipse.jdt.core.formatter.blank_lines_before_field=1
+org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
+org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
+org.eclipse.jdt.core.formatter.blank_lines_before_method=1
+org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
+org.eclipse.jdt.core.formatter.blank_lines_before_package=0
+org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
+org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
+org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=true
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=true
+org.eclipse.jdt.core.formatter.comment.format_block_comments=true
+org.eclipse.jdt.core.formatter.comment.format_header=false
+org.eclipse.jdt.core.formatter.comment.format_html=true
+org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
+org.eclipse.jdt.core.formatter.comment.format_line_comments=true
+org.eclipse.jdt.core.formatter.comment.format_source_code=true
+org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
+org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
+org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
+org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
+org.eclipse.jdt.core.formatter.comment.line_length=110
+org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
+org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
+org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false
+org.eclipse.jdt.core.formatter.compact_else_if=true
+org.eclipse.jdt.core.formatter.continuation_indentation=2
+org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
+org.eclipse.jdt.core.formatter.disabling_tag=
+org.eclipse.jdt.core.formatter.enabling_tag=
+org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
+org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
+org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_empty_lines=false
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true
+org.eclipse.jdt.core.formatter.indentation.size=8
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert
+org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
+org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.join_lines_in_comments=true
+org.eclipse.jdt.core.formatter.join_wrapped_lines=true
+org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.lineSplit=110
+org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
+org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
+org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
+org.eclipse.jdt.core.formatter.tabulation.char=tab
+org.eclipse.jdt.core.formatter.tabulation.size=4
+org.eclipse.jdt.core.formatter.use_on_off_tags=false
+org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
+org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
+org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/.settings/org.eclipse.jdt.ui.prefs b/tests/org.eclipse.mylyn.docs.intent.compare.test/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 0000000..377e9ee
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,57 @@
+#Fri Sep 23 21:59:11 CEST 2011
+eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+formatter_profile=_Intent
+formatter_settings_version=12
+sp_cleanup.add_default_serial_version_id=true
+sp_cleanup.add_generated_serial_version_id=false
+sp_cleanup.add_missing_annotations=true
+sp_cleanup.add_missing_deprecated_annotations=true
+sp_cleanup.add_missing_methods=false
+sp_cleanup.add_missing_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_missing_override_annotations_interface_methods=true
+sp_cleanup.add_serial_version_id=false
+sp_cleanup.always_use_blocks=true
+sp_cleanup.always_use_parentheses_in_expressions=false
+sp_cleanup.always_use_this_for_non_static_field_access=false
+sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_to_enhanced_for_loop=false
+sp_cleanup.correct_indentation=false
+sp_cleanup.format_source_code=true
+sp_cleanup.format_source_code_changes_only=false
+sp_cleanup.make_local_variable_final=false
+sp_cleanup.make_parameters_final=false
+sp_cleanup.make_private_fields_final=true
+sp_cleanup.make_type_abstract_if_missing_method=false
+sp_cleanup.make_variable_declarations_final=true
+sp_cleanup.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.on_save_use_additional_actions=false
+sp_cleanup.organize_imports=true
+sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.remove_private_constructors=true
+sp_cleanup.remove_trailing_whitespaces=false
+sp_cleanup.remove_trailing_whitespaces_all=true
+sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_casts=true
+sp_cleanup.remove_unnecessary_nls_tags=false
+sp_cleanup.remove_unused_imports=false
+sp_cleanup.remove_unused_local_variables=false
+sp_cleanup.remove_unused_private_fields=true
+sp_cleanup.remove_unused_private_members=false
+sp_cleanup.remove_unused_private_methods=true
+sp_cleanup.remove_unused_private_types=true
+sp_cleanup.sort_members=false
+sp_cleanup.sort_members_all=false
+sp_cleanup.use_blocks=false
+sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_parentheses_in_expressions=false
+sp_cleanup.use_this_for_non_static_field_access=false
+sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+sp_cleanup.use_this_for_non_static_method_access=false
+sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/META-INF/MANIFEST.MF b/tests/org.eclipse.mylyn.docs.intent.compare.test/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..a001323
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/META-INF/MANIFEST.MF
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Localization: plugin
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.mylyn.docs.intent.compare.test
+Bundle-Version: 0.8.0.qualifier
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.junit;bundle-version="4.8.1",
+ org.eclipse.mylyn.docs.intent.core;bundle-version="0.7.0",
+ org.eclipse.mylyn.docs.intent.parser;bundle-version="0.7.0",
+ org.eclipse.emf.compare;bundle-version="2.0.0",
+ com.google.guava;bundle-version="10.0.1",
+ org.eclipse.mylyn.docs.intent.compare;bundle-version="0.7.0"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-Vendor: %providerName
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/about.html b/tests/org.eclipse.mylyn.docs.intent.compare.test/about.html
new file mode 100644
index 0000000..34ab520
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/about.html
@@ -0,0 +1,106 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+<title>Eclipse Foundation Software User Agreement</title>
+</head>
+
+<body lang="EN-US">
+<h2>Eclipse Foundation Software User Agreement</h2>
+<p>April 14, 2010</p>
+
+<h3>Usage Of Content</h3>
+
+<p>THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS
+ (COLLECTIVELY "CONTENT"). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND
+ CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE
+ OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR
+ NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND
+ CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.</p>
+
+<h3>Applicable Licenses</h3>
+
+<p>Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0
+ ("EPL"). A copy of the EPL is provided with this Content and is also available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+ For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse Foundation source code
+ repository ("Repository") in software modules ("Modules") and made available as downloadable archives ("Downloads").</p>
+
+<ul>
+ <li>Content may be structured and packaged into modules to facilitate delivering, extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"), plug-in fragments ("Fragments"), and features ("Features").</li>
+ <li>Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java™ ARchive) in a directory named "plugins".</li>
+ <li>A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material. Each Feature may be packaged as a sub-directory in a directory named "features". Within a Feature, files named "feature.xml" may contain a list of the names and version numbers of the Plug-ins
+ and/or Fragments associated with that Feature.</li>
+ <li>Features may also include other Features ("Included Features"). Within a Feature, files named "feature.xml" may contain a list of the names and version numbers of Included Features.</li>
+</ul>
+
+<p>The terms and conditions governing Plug-ins and Fragments should be contained in files named "about.html" ("Abouts"). The terms and conditions governing Features and
+Included Features should be contained in files named "license.html" ("Feature Licenses"). Abouts and Feature Licenses may be located in any directory of a Download or Module
+including, but not limited to the following locations:</p>
+
+<ul>
+ <li>The top-level (root) directory</li>
+ <li>Plug-in and Fragment directories</li>
+ <li>Inside Plug-ins and Fragments packaged as JARs</li>
+ <li>Sub-directories of the directory named "src" of certain Plug-ins</li>
+ <li>Feature directories</li>
+</ul>
+
+<p>Note: if a Feature made available by the Eclipse Foundation is installed using the Provisioning Technology (as defined below), you must agree to a license ("Feature Update License") during the
+installation process. If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or
+inform you where you can locate them. Feature Update Licenses may be found in the "license" property of files named "feature.properties" found within a Feature.
+Such Abouts, Feature Licenses, and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in
+that directory.</p>
+
+<p>THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE
+OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):</p>
+
+<ul>
+ <li>Common Public License Version 1.0 (available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>)</li>
+ <li>Apache Software License 1.1 (available at <a href="http://www.apache.org/licenses/LICENSE">http://www.apache.org/licenses/LICENSE</a>)</li>
+ <li>Apache Software License 2.0 (available at <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>)</li>
+ <li>Metro Link Public License 1.00 (available at <a href="http://www.opengroup.org/openmotif/supporters/metrolink/license.html">http://www.opengroup.org/openmotif/supporters/metrolink/license.html</a>)</li>
+ <li>Mozilla Public License Version 1.1 (available at <a href="http://www.mozilla.org/MPL/MPL-1.1.html">http://www.mozilla.org/MPL/MPL-1.1.html</a>)</li>
+</ul>
+
+<p>IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License is provided, please
+contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.</p>
+
+
+<h3>Use of Provisioning Technology</h3>
+
+<p>The Eclipse Foundation makes available provisioning software, examples of which include, but are not limited to, p2 and the Eclipse
+ Update Manager ("Provisioning Technology") for the purpose of allowing users to install software, documentation, information and/or
+ other materials (collectively "Installable Software"). This capability is provided with the intent of allowing such users to
+ install, extend and update Eclipse-based products. Information about packaging Installable Software is available at <a
+ href="http://eclipse.org/equinox/p2/repository_packaging.html">http://eclipse.org/equinox/p2/repository_packaging.html</a>
+ ("Specification").</p>
+
+<p>You may use Provisioning Technology to allow other parties to install Installable Software. You shall be responsible for enabling the
+ applicable license agreements relating to the Installable Software to be presented to, and accepted by, the users of the Provisioning Technology
+ in accordance with the Specification. By using Provisioning Technology in such a manner and making it available in accordance with the
+ Specification, you further acknowledge your agreement to, and the acquisition of all necessary rights to permit the following:</p>
+
+<ol>
+ <li>A series of actions may occur ("Provisioning Process") in which a user may execute the Provisioning Technology
+ on a machine ("Target Machine") with the intent of installing, extending or updating the functionality of an Eclipse-based
+ product.</li>
+ <li>During the Provisioning Process, the Provisioning Technology may cause third party Installable Software or a portion thereof to be
+ accessed and copied to the Target Machine.</li>
+ <li>Pursuant to the Specification, you will provide to the user the terms and conditions that govern the use of the Installable
+ Software ("Installable Software Agreement") and such Installable Software Agreement shall be accessed from the Target
+ Machine in accordance with the Specification. Such Installable Software Agreement must inform the user of the terms and conditions that govern
+ the Installable Software and must solicit acceptance by the end user in the manner prescribed in such Installable Software Agreement. Upon such
+ indication of agreement by the user, the provisioning Technology will complete installation of the Installable Software.</li>
+</ol>
+
+<h3>Cryptography</h3>
+
+<p>Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to
+ another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import,
+ possession, or use, and re-export of encryption software, to see if this is permitted.</p>
+
+<p><small>Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.</small></p>
+</body>
+</html>
\ No newline at end of file
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/build.properties b/tests/org.eclipse.mylyn.docs.intent.compare.test/build.properties
new file mode 100644
index 0000000..33a3ca4
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/build.properties
@@ -0,0 +1,17 @@
+################################################################################
+# Copyright (c) 2010, 2012 Obeo.
+# 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:
+# Obeo - initial API and implementation
+################################################################################
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ about.html,\
+ plugin.properties
+src.includes = about.html
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/doubleSectionInsertion/IntentDocument.text b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/doubleSectionInsertion/IntentDocument.text
new file mode 100644
index 0000000..4a49924
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/doubleSectionInsertion/IntentDocument.text
@@ -0,0 +1,37 @@
+Document {
+ Chapter {
+ The first chapter is the best.
+
+ Section Differencing the left model from right model when comparaison fails {
+ During the Match process, deleted or added elements are considered as unmatched.
+
+ @M SidedataTypeDefinition
+ match {
+ eClassifiers += new EEnum Side {
+ eLiterals += new EEnumLiteral {
+ name = "Left";
+ literal = "Left";
+ value = "0";
+ };
+ eLiterals += new EEnumLiteral {
+ name = "Right";
+ literal = "Right";
+ value = "1";
+ };
+ };
+ }
+ M@
+
+ Otherwise, it is a deleted element.
+ }
+ }
+ Chapter {
+ Section {
+ @M myModelingUnit
+ Side {
+ serializable = "true";
+ }
+ M@
+ }
+ }
+}
\ No newline at end of file
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/doubleSectionInsertion/IntentDocument.text.modifications b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/doubleSectionInsertion/IntentDocument.text.modifications
new file mode 100644
index 0000000..202997b
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/doubleSectionInsertion/IntentDocument.text.modifications
@@ -0,0 +1,47 @@
+Document {
+ Chapter {
+ The first chapter is the best.
+
+ Section Differencing the left model from right model when comparaison fails {
+ During the Match process, deleted or added elements are considered as unmatched.
+
+ Section {
+ SubSection1
+
+ MySubSection
+ }
+ @M SidedataTypeDefinition
+ match {
+ eClassifiers += new EEnum Side {
+ eLiterals += new EEnumLiteral {
+ name = "Left";
+ literal = "Left";
+ value = "0";
+ };
+ eLiterals += new EEnumLiteral {
+ name = "Right";
+ literal = "Right";
+ value = "1";
+ };
+ };
+ }
+ M@
+
+ Otherwise, it is a deleted element.
+
+ Section {
+ SubSection2
+
+ MySubSection
+ }
+ }
+ }
+ Chapter {
+ Section { @M myModelingUnit
+ Side {
+ serializable = "true";
+ }
+ M@
+ }
+ }
+}
\ No newline at end of file
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/doubleTopTextAddition/IntentDocument.text b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/doubleTopTextAddition/IntentDocument.text
new file mode 100644
index 0000000..5a1b1c7
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/doubleTopTextAddition/IntentDocument.text
@@ -0,0 +1,30 @@
+Document {
+ Chapter {
+ The first chapter is the best.
+ }
+ Chapter {
+ Section Section 2.1 {
+ The 2.1 Section.
+ }
+
+ Section Section 2.2 {
+ The 2.2 Section.
+ }
+ }
+ Chapter {
+ Section {
+ Section Section 3.1.1 {
+ Such a good section.
+ }
+ @M myModelingUnit
+ Side {
+ serializable = "true";
+ }
+ M@
+
+ Section Section 3.2.1 {
+ The last Section.
+ }
+ }
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/doubleTopTextAddition/IntentDocument.text.modifications b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/doubleTopTextAddition/IntentDocument.text.modifications
new file mode 100644
index 0000000..944e91d
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/doubleTopTextAddition/IntentDocument.text.modifications
@@ -0,0 +1,34 @@
+Document {
+ Chapter {
+ The first chapter is the best.
+ }
+ Chapter {
+ A new description Unit
+
+ Section Section 2.1 {
+ The 2.1 Section.
+ }
+
+ Section Section 2.2 {
+ The 2.2 Section.
+ }
+ }
+ Chapter {
+ A new description Unit
+
+ Section {
+ Section Section 3.1.1 {
+ Such a good section.
+ }
+ @M myModelingUnit
+ Side {
+ serializable = "true";
+ }
+ M@
+
+ Section Section 3.2.1 {
+ The last Section.
+ }
+ }
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/endTextAddition/IntentDocument.text b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/endTextAddition/IntentDocument.text
new file mode 100644
index 0000000..5129942
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/endTextAddition/IntentDocument.text
@@ -0,0 +1,11 @@
+Document {
+ Chapter {
+ Section Section 2.1 {
+ The 2.1 Section.
+ }
+
+ Section Section 2.2 {
+ The 2.2 Section.
+ }
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/endTextAddition/IntentDocument.text.modifications b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/endTextAddition/IntentDocument.text.modifications
new file mode 100644
index 0000000..7101d7c
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/endTextAddition/IntentDocument.text.modifications
@@ -0,0 +1,13 @@
+Document {
+ Chapter {
+ Section Section 2.1 {
+ The 2.1 Section.
+ }
+
+ Section Section 2.2 {
+ The 2.2 Section.
+ }
+
+ A new description Unit
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/fillEmptyDoc/IntentDocument.text b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/fillEmptyDoc/IntentDocument.text
new file mode 100644
index 0000000..67b601f
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/fillEmptyDoc/IntentDocument.text
@@ -0,0 +1,2 @@
+Document {
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/fillEmptyDoc/IntentDocument.text.modifications b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/fillEmptyDoc/IntentDocument.text.modifications
new file mode 100644
index 0000000..7f82e7e
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/fillEmptyDoc/IntentDocument.text.modifications
@@ -0,0 +1,7 @@
+Document {
+ Chapter c {
+ Section s {
+ Text
+ }
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/inversionIssue/IntentDocument.text b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/inversionIssue/IntentDocument.text
new file mode 100644
index 0000000..4b7c62a
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/inversionIssue/IntentDocument.text
@@ -0,0 +1,9 @@
+Document {
+ Chapter {
+ MiddleText
+
+ Section {
+ BottomText
+ }
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/inversionIssue/IntentDocument.text.modifications b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/inversionIssue/IntentDocument.text.modifications
new file mode 100644
index 0000000..4499e10
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/inversionIssue/IntentDocument.text.modifications
@@ -0,0 +1,13 @@
+Document {
+ Chapter {
+ Section {
+ TopText
+ }
+
+ MiddleText
+
+ Section {
+ BottomText
+ }
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/modelingUnitDeletion/IntentDocument.text b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/modelingUnitDeletion/IntentDocument.text
new file mode 100644
index 0000000..8e0e9cd
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/modelingUnitDeletion/IntentDocument.text
@@ -0,0 +1,6 @@
+Section {
+ @see "TheUnmatchElementConcept"
+ @M
+ M@
+ some text
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/modelingUnitDeletion/IntentDocument.text.modifications b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/modelingUnitDeletion/IntentDocument.text.modifications
new file mode 100644
index 0000000..1f5fddd
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/modelingUnitDeletion/IntentDocument.text.modifications
@@ -0,0 +1,4 @@
+Section {
+ @see "TheUnmatchElementConcept"
+ some text
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/muAddition/IntentDocument.text b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/muAddition/IntentDocument.text
new file mode 100644
index 0000000..fb57204
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/muAddition/IntentDocument.text
@@ -0,0 +1,8 @@
+Document {
+Chapter TITLE {
+Section {
+ text
+
+}
+}
+}
\ No newline at end of file
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/muAddition/IntentDocument.text.modifications b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/muAddition/IntentDocument.text.modifications
new file mode 100644
index 0000000..147e107
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/muAddition/IntentDocument.text.modifications
@@ -0,0 +1,12 @@
+Document {
+ Chapter TITLE {
+ Section {
+ text
+ @M
+ Side {
+ serializable = "false";
+ }
+ M@
+ }
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/newChapter/IntentDocument.text b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/newChapter/IntentDocument.text
new file mode 100644
index 0000000..20316f5
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/newChapter/IntentDocument.text
@@ -0,0 +1,11 @@
+Document {
+ Chapter Chapter 1 {
+ Chapter 1.
+
+ Section { }
+
+ }
+ Chapter Chapter 2 {
+ Chapter 2.
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/newChapter/IntentDocument.text.modifications b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/newChapter/IntentDocument.text.modifications
new file mode 100644
index 0000000..e9f4055
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/newChapter/IntentDocument.text.modifications
@@ -0,0 +1,13 @@
+Document {
+ Chapter New Chapter {
+ New Chapter.
+ }
+ Chapter Chapter 1 {
+ Chapter 1.
+
+ Section { }
+ }
+ Chapter Chapter 2 {
+ Chapter 2.
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/newChapterWorking/IntentDocument.text b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/newChapterWorking/IntentDocument.text
new file mode 100644
index 0000000..ad41c4d
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/newChapterWorking/IntentDocument.text
@@ -0,0 +1,11 @@
+Document {
+ Chapter Chapt 1 {
+ Chapt 1.
+
+ Section { }
+
+ }
+ Chapter Chapt 2 {
+ Chapt 2.
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/newChapterWorking/IntentDocument.text.modifications b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/newChapterWorking/IntentDocument.text.modifications
new file mode 100644
index 0000000..2d8cc71
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/newChapterWorking/IntentDocument.text.modifications
@@ -0,0 +1,13 @@
+Document {
+ Chapter New Chapt {
+ New Chapt.
+ }
+ Chapter Chapt 1 {
+ Chapt 1.
+
+ Section { }
+ }
+ Chapter Chapt 2 {
+ Chapt 2.
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/newInstruction/IntentDocument.text b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/newInstruction/IntentDocument.text
new file mode 100644
index 0000000..bfe206d
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/newInstruction/IntentDocument.text
@@ -0,0 +1,19 @@
+Document {
+ Chapter {
+ Section Abstract Resources Test {
+ These resources are used to define models having no relations with any concrete artifact.
+ @M
+ Resource abstractResource {
+ content += myAbstractRoot;
+ }
+ M@
+
+ Hence this resource will not be synchronized :
+ @M
+ new EPackage myAbstractRoot {
+ eClassifiers += new EClass myEClass {};
+ }
+ M@
+ }
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/newInstruction/IntentDocument.text.modifications b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/newInstruction/IntentDocument.text.modifications
new file mode 100644
index 0000000..6918721
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/newInstruction/IntentDocument.text.modifications
@@ -0,0 +1,20 @@
+Document {
+ Chapter {
+ Section Abstract Resources Test {
+ These resources are used to define models having no relations with any concrete artifact.
+ @M
+ Resource abstractResource {
+ URI = "platform:/resource/intentProject/Model.ecore";
+ content += myAbstractRoot;
+ }
+ M@
+
+ Hence this resource will not be synchronized :
+ @M
+ new EPackage myAbstractRoot {
+ eClassifiers += new EClass myEClass {};
+ }
+ M@
+ }
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/newSection/IntentDocument.text b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/newSection/IntentDocument.text
new file mode 100644
index 0000000..91e28d6
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/newSection/IntentDocument.text
@@ -0,0 +1,2 @@
+Document {
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/newSection/IntentDocument.text.modifications b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/newSection/IntentDocument.text.modifications
new file mode 100644
index 0000000..834726f
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/newSection/IntentDocument.text.modifications
@@ -0,0 +1,7 @@
+Document {
+ Chapter c {
+ Section s {
+ Text
+ }
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/newSectionUpdate1/IntentDocument.text b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/newSectionUpdate1/IntentDocument.text
new file mode 100644
index 0000000..834726f
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/newSectionUpdate1/IntentDocument.text
@@ -0,0 +1,7 @@
+Document {
+ Chapter c {
+ Section s {
+ Text
+ }
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/newSectionUpdate1/IntentDocument.text.modifications b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/newSectionUpdate1/IntentDocument.text.modifications
new file mode 100644
index 0000000..1c6c75b
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/newSectionUpdate1/IntentDocument.text.modifications
@@ -0,0 +1,9 @@
+Document {
+ Chapter c {
+ Text
+
+ Section s {
+ Text
+ }
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/newSectionUpdate2/IntentDocument.text b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/newSectionUpdate2/IntentDocument.text
new file mode 100644
index 0000000..3bb434b
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/newSectionUpdate2/IntentDocument.text
@@ -0,0 +1,9 @@
+Document {
+ Chapter c {
+ Text
+
+ Section s {
+ Text
+ }
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/newSectionUpdate2/IntentDocument.text.modifications b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/newSectionUpdate2/IntentDocument.text.modifications
new file mode 100644
index 0000000..90ce995
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/newSectionUpdate2/IntentDocument.text.modifications
@@ -0,0 +1,13 @@
+Document {
+ Chapter c {
+ Section new {
+ Text
+ }
+
+ Text
+
+ Section s {
+ Text
+ }
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/rename/IntentDocument.text b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/rename/IntentDocument.text
new file mode 100644
index 0000000..af6eafc
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/rename/IntentDocument.text
@@ -0,0 +1,8 @@
+Document {
+ Chapter Title {
+ Text
+
+ Section Title {
+ }
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/rename/IntentDocument.text.modifications b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/rename/IntentDocument.text.modifications
new file mode 100644
index 0000000..9827056
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/rename/IntentDocument.text.modifications
@@ -0,0 +1,7 @@
+Document {
+ Chapter A {
+ Text
+
+ Section A { }
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/renameAll/IntentDocument.text b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/renameAll/IntentDocument.text
new file mode 100644
index 0000000..553d434
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/renameAll/IntentDocument.text
@@ -0,0 +1,29 @@
+Document {
+ Chapter Title {
+ Text
+
+ Section Title {
+ Text
+
+ Section Title {
+ Text
+
+ Section Title {
+ Text
+
+ Section Title {
+ Text
+
+ Section Title {
+ Text
+
+ Section Title {
+ Text
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/renameAll/IntentDocument.text.modifications b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/renameAll/IntentDocument.text.modifications
new file mode 100644
index 0000000..2334693
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/renameAll/IntentDocument.text.modifications
@@ -0,0 +1,29 @@
+Document {
+ Chapter A {
+ Text
+
+ Section A {
+ Text
+
+ Section A {
+ Text
+
+ Section A {
+ Text
+
+ Section A {
+ Text
+
+ Section A {
+ Text
+
+ Section A {
+ Text
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/reverseRename/IntentDocument.text b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/reverseRename/IntentDocument.text
new file mode 100644
index 0000000..9819744
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/reverseRename/IntentDocument.text
@@ -0,0 +1,8 @@
+Document {
+ Chapter A {
+ Text
+
+ Section A {
+ }
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/reverseRename/IntentDocument.text.modifications b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/reverseRename/IntentDocument.text.modifications
new file mode 100644
index 0000000..27f6ebf
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/reverseRename/IntentDocument.text.modifications
@@ -0,0 +1,7 @@
+Document {
+ Chapter Title {
+ Text
+
+ Section Title { }
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/sectionInsertion/IntentDocument.text b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/sectionInsertion/IntentDocument.text
new file mode 100644
index 0000000..2f78f9c
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/sectionInsertion/IntentDocument.text
@@ -0,0 +1,10 @@
+Document {
+ Chapter {
+ Section Differencing the left model from right model when comparaison fails {
+ During the Match process, deleted or added elements are considered as unmatched.
+ If the feature of an UnmatchElement is, then it must be considered as an added element.
+ Otherwise, it is a deleted element.
+ The MatchModel store suchs an element using
+ }
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/sectionInsertion/IntentDocument.text.modifications b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/sectionInsertion/IntentDocument.text.modifications
new file mode 100644
index 0000000..e34b06f
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/sectionInsertion/IntentDocument.text.modifications
@@ -0,0 +1,17 @@
+Document {
+ Chapter {
+ Section Differencing the left model from right model when comparaison fails {
+ During the Match process, deleted or added elements are considered as unmatched.
+
+ Section {
+ SubSection1
+
+ MySubSection
+ }
+
+ If the feature of an UnmatchElement is, then it must be considered as an added element.
+ Otherwise, it is a deleted element.
+ The MatchModel store suchs an element using
+ }
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/sectionsAdditions/IntentDocument.text b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/sectionsAdditions/IntentDocument.text
new file mode 100644
index 0000000..3e12a60
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/sectionsAdditions/IntentDocument.text
@@ -0,0 +1,34 @@
+Section Differencing the left model from right model when comparaison fails {
+ During the Match process, deleted or added elements are considered as unmatched.
+
+ Two different situations can occur :
+
+ * an element defined in the left model is not matching any element in the right model (deleted element)
+ * an element defined in the right model is not matching any element in the left model (added element)
+
+
+
+ @M SidedataTypeDefinition
+ match {
+ eClassifiers += new EEnum Side {
+ eLiterals += new EEnumLiteral {
+ name = "Left";
+ literal = "Left";
+ value = "0";
+ };
+ eLiterals += new EEnumLiteral {
+ name = "Right";
+ literal = "Right";
+ value = "1";
+ };
+ };
+ }
+ M@
+
+ If the feature @side@ of an UnmatchElement is _Right_, then it must be considered as an added element.
+ Otherwise, it is a deleted element.
+
+ The MatchModel store suchs an element using @UnmatchElement@s (
+ @see "TheUnmatchElementConcept" ). To differenciate
+ added element from deleted element, we define the @EEnum@ *Side* :
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/sectionsAdditions/IntentDocument.text.modifications b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/sectionsAdditions/IntentDocument.text.modifications
new file mode 100644
index 0000000..764e3a6
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/sectionsAdditions/IntentDocument.text.modifications
@@ -0,0 +1,46 @@
+Section Differencing the left model from right model when comparaison fails {
+ During the Match process, deleted or added elements are considered as unmatched.
+
+ Two different situations can occur :
+
+ * an element defined in the left model is not matching any element in the right model (deleted element)
+ * an element defined in the right model is not matching any element in the left model (added element)
+
+
+
+
+ Section {
+ SubSection1
+
+ MySubSection
+ }
+ @M SidedataTypeDefinition
+ match {
+ eClassifiers += new EEnum Side {
+ eLiterals += new EEnumLiteral {
+ name = "Left";
+ literal = "Left";
+ value = "0";
+ };
+ eLiterals += new EEnumLiteral {
+ name = "Right";
+ literal = "Right";
+ value = "1";
+ };
+ };
+ }
+ M@
+
+ If the feature @side@ of an UnmatchElement is _Right_, then it must be considered as an added element.
+ Otherwise, it is a deleted element.
+
+ Section {
+ SubSection2
+
+ MySubSection
+ }
+
+ The MatchModel store suchs an element using @UnmatchElement@s (
+ @see "TheUnmatchElementConcept" ). To differenciate
+ added element from deleted element, we define the @EEnum@ *Side* :
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/textDeletion/IntentDocument.text b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/textDeletion/IntentDocument.text
new file mode 100644
index 0000000..2b870fb
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/textDeletion/IntentDocument.text
@@ -0,0 +1,9 @@
+Document {
+ Chapter aaaa {
+ Text
+
+ Section bbbb {
+ Text
+ }
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/textDeletion/IntentDocument.text.modifications b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/textDeletion/IntentDocument.text.modifications
new file mode 100644
index 0000000..3bb33ca
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/textDeletion/IntentDocument.text.modifications
@@ -0,0 +1,7 @@
+Document {
+ Chapter aaaa {
+ Section bbbb {
+ Text
+ }
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/textInsertion/IntentDocument.text b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/textInsertion/IntentDocument.text
new file mode 100644
index 0000000..dd3dc8e
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/textInsertion/IntentDocument.text
@@ -0,0 +1,7 @@
+Document {
+ Chapter a {
+ Section b { }
+
+ Section c { }
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/textInsertion/IntentDocument.text.modifications b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/textInsertion/IntentDocument.text.modifications
new file mode 100644
index 0000000..eb4b158
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/textInsertion/IntentDocument.text.modifications
@@ -0,0 +1,9 @@
+Document {
+ Chapter a {
+ Section b { }
+
+ toto
+
+ Section c { }
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/topChapterAddition/IntentDocument.text b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/topChapterAddition/IntentDocument.text
new file mode 100644
index 0000000..4e8c61b
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/topChapterAddition/IntentDocument.text
@@ -0,0 +1,5 @@
+Document {
+ Chapter The first chapter is the best {
+ The first chapter is the best.
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/topChapterAddition/IntentDocument.text.modifications b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/topChapterAddition/IntentDocument.text.modifications
new file mode 100644
index 0000000..77692e0
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/topChapterAddition/IntentDocument.text.modifications
@@ -0,0 +1,10 @@
+Document {
+ Chapter New Chapter {
+ New chapter.
+
+ Section { }
+ }
+ Chapter The first chapter is the best {
+ The first chapter is the best.
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/topTextAddition/IntentDocument.text b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/topTextAddition/IntentDocument.text
new file mode 100644
index 0000000..f5cd9ef
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/topTextAddition/IntentDocument.text
@@ -0,0 +1,11 @@
+Document {
+ Chapter {
+ Section Section 2.1 {
+ The 2.1 Section.
+ }
+
+ Section Section 2.2 {
+ The 2.2 Section.
+ }
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/data/topTextAddition/IntentDocument.text.modifications b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/topTextAddition/IntentDocument.text.modifications
new file mode 100644
index 0000000..a497d6e
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/data/topTextAddition/IntentDocument.text.modifications
@@ -0,0 +1,13 @@
+Document {
+ Chapter {
+ A new description Unit
+
+ Section Section 2.1 {
+ The 2.1 Section.
+ }
+
+ Section Section 2.2 {
+ The 2.2 Section.
+ }
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/plugin.properties b/tests/org.eclipse.mylyn.docs.intent.compare.test/plugin.properties
new file mode 100644
index 0000000..4d72632
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/plugin.properties
@@ -0,0 +1,12 @@
+#################################################################################
+# Copyright (c) 2012 Obeo.
+# 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:
+# Obeo - initial API and implementation
+#################################################################################
+pluginName = Intent EMF Compare Test
+providerName = Eclipse Mylyn
\ No newline at end of file
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/pom.xml b/tests/org.eclipse.mylyn.docs.intent.compare.test/pom.xml
new file mode 100644
index 0000000..68f2296
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/pom.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (C) 2011, 2012 Obeo
+
+ Cedric Brun <cedric.brun@obeo.fr>
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.eclipse.mylyn.docs.intent-group</groupId>
+ <artifactId>intent-parent</artifactId>
+ <version>0.8.0-SNAPSHOT</version>
+ <relativePath>../..</relativePath>
+ </parent>
+
+ <artifactId>org.eclipse.mylyn.docs.intent.compare.test</artifactId>
+ <packaging>eclipse-test-plugin</packaging>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-source-plugin</artifactId>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>${tycho-version}</version>
+ <configuration>
+ <includes>
+ <include>org/eclipse/mylyn/docs/intent/compare/test/suite/TestCompareSuite.class</include>
+ </includes>
+ <testIgnoreFailure>true</testIgnoreFailure>
+ <testFailureIgnore>true</testFailureIgnore>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+
+
+</project>
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/src/org/eclipse/mylyn/docs/intent/compare/test/suite/TestCompareSuite.java b/tests/org.eclipse.mylyn.docs.intent.compare.test/src/org/eclipse/mylyn/docs/intent/compare/test/suite/TestCompareSuite.java
new file mode 100644
index 0000000..a175849
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/src/org/eclipse/mylyn/docs/intent/compare/test/suite/TestCompareSuite.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.mylyn.docs.intent.compare.test.suite;
+
+import org.eclipse.mylyn.docs.intent.compare.test.unit.MergingIssues;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * Launch all the test files related to emf compare tests.
+ *
+ * @author <a href="mailto:william.piers@obeo.fr">William Piers</a>
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({MergingIssues.class,
+
+})
+public class TestCompareSuite {
+
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/src/org/eclipse/mylyn/docs/intent/compare/test/unit/MergingIssues.java b/tests/org.eclipse.mylyn.docs.intent.compare.test/src/org/eclipse/mylyn/docs/intent/compare/test/unit/MergingIssues.java
new file mode 100644
index 0000000..c24b7ca
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/src/org/eclipse/mylyn/docs/intent/compare/test/unit/MergingIssues.java
@@ -0,0 +1,158 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.mylyn.docs.intent.compare.test.unit;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.eclipse.emf.compare.Comparison;
+import org.eclipse.emf.compare.Diff;
+import org.eclipse.mylyn.docs.intent.compare.test.utils.AbstractEMFCompareTest;
+import org.eclipse.mylyn.docs.intent.compare.test.utils.IntentPrettyPrinter;
+import org.eclipse.mylyn.docs.intent.compare.utils.EMFCompareUtils;
+import org.eclipse.mylyn.docs.intent.core.document.IntentStructuredElement;
+import org.eclipse.mylyn.docs.intent.parser.modelingunit.ParseException;
+import org.eclipse.mylyn.docs.intent.serializer.IntentSerializer;
+
+/**
+ * Tests the potential merging issues.
+ *
+ * @author <a href="mailto:william.piers@obeo.fr">William Piers</a>
+ */
+public class MergingIssues extends AbstractEMFCompareTest {
+ private static final boolean USE_DEFAULT_COMPARE = false;
+
+ private static final boolean DEBUG = false;
+
+ public void testFillEmptyDoc() throws IOException, ParseException {
+ compareAndMerge("fillEmptyDoc");
+ }
+
+ public void testModelingUnitDeletion() throws IOException, ParseException {
+ compareAndMerge("modelingUnitDeletion");
+ }
+
+ public void testSectionsAdditions() throws IOException, ParseException {
+ compareAndMerge("sectionsAdditions");
+ }
+
+ public void testNewChapter() throws IOException, ParseException {
+ compareAndMerge("newChapter");
+ }
+
+ public void testNewChapterWorking() throws IOException, ParseException {
+ compareAndMerge("newChapterWorking");
+ }
+
+ public void testDoubleSectionInsertion() throws IOException, ParseException {
+ compareAndMerge("doubleSectionInsertion");
+ }
+
+ public void testDoubleTopTextAddition() throws IOException, ParseException {
+ compareAndMerge("doubleTopTextAddition");
+ }
+
+ public void testEndTextAddition() throws IOException, ParseException {
+ compareAndMerge("endTextAddition");
+ }
+
+ public void testMuAddition() throws IOException, ParseException {
+ compareAndMerge("muAddition");
+ }
+
+ public void testNewInstruction() throws IOException, ParseException {
+ compareAndMerge("newInstruction");
+ }
+
+ public void testNewSection() throws IOException, ParseException {
+ compareAndMerge("newSection");
+ }
+
+ public void testNewSectionUpdate1() throws IOException, ParseException {
+ compareAndMerge("newSectionUpdate1");
+ }
+
+ public void testNewSectionUpdate2() throws IOException, ParseException {
+ compareAndMerge("newSectionUpdate2");
+ }
+
+ public void testInversionIssue() throws IOException, ParseException {
+ compareAndMerge("inversionIssue");
+ }
+
+ public void testRenameAll() throws IOException, ParseException {
+ compareAndMerge("renameAll");
+ }
+
+ public void testSectionInsertion() throws IOException, ParseException {
+ compareAndMerge("sectionInsertion");
+ }
+
+ public void testTextDeletion() throws IOException, ParseException {
+ compareAndMerge("textDeletion");
+ }
+
+ public void testTextInsertion() throws IOException, ParseException {
+ compareAndMerge("textInsertion");
+ }
+
+ public void testTopChapterAddition() throws IOException, ParseException {
+ compareAndMerge("topChapterAddition");
+ }
+
+ public void testTopTextAddition() throws IOException, ParseException {
+ compareAndMerge("topTextAddition");
+ }
+
+ public void testRename() throws IOException, ParseException {
+ compareAndMerge("rename");
+ }
+
+ public void testReverseRename() throws IOException, ParseException {
+ compareAndMerge("reverseRename");
+ }
+
+ private void compareAndMerge(String testName) throws IOException, ParseException {
+
+ String repository = getFileAsString(new File("data/" + testName + "/IntentDocument.text"));
+ String modified = getFileAsString(new File("data/" + testName + "/IntentDocument.text.modifications"));
+ IntentStructuredElement left = parseIntentDocument(modified);
+ IntentStructuredElement right = parseIntentDocument(repository);
+
+ Comparison comparison = null;
+
+ if (USE_DEFAULT_COMPARE) {
+ comparison = EMFCompareUtils.compare(left, right);
+ } else {
+ comparison = EMFCompareUtils.compareDocuments(left, right);
+ }
+
+ if (DEBUG) {
+ System.out.println("TESTING: " + testName);
+ System.out.println("Was:");
+ IntentPrettyPrinter.displayModel(right);
+ System.out.println();
+ System.out.println("Now:");
+ IntentPrettyPrinter.displayModel(left);
+ System.out.println();
+ IntentPrettyPrinter.printMatch(comparison, System.out);
+ IntentPrettyPrinter.printDifferences(comparison, System.out);
+ System.out.println("=========================================================");
+ }
+
+ for (Diff diff : comparison.getDifferences()) {
+ diff.copyLeftToRight();
+ }
+
+ assertEquals(modified, new IntentSerializer().serialize(right));
+ }
+
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/src/org/eclipse/mylyn/docs/intent/compare/test/utils/AbstractEMFCompareTest.java b/tests/org.eclipse.mylyn.docs.intent.compare.test/src/org/eclipse/mylyn/docs/intent/compare/test/utils/AbstractEMFCompareTest.java
new file mode 100644
index 0000000..e678784
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/src/org/eclipse/mylyn/docs/intent/compare/test/utils/AbstractEMFCompareTest.java
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.mylyn.docs.intent.compare.test.utils;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import junit.framework.TestCase;
+
+import org.eclipse.mylyn.docs.intent.compare.IntentASTMerger;
+import org.eclipse.mylyn.docs.intent.compare.MergingException;
+import org.eclipse.mylyn.docs.intent.core.document.IntentStructuredElement;
+import org.eclipse.mylyn.docs.intent.parser.IntentParser;
+import org.eclipse.mylyn.docs.intent.parser.modelingunit.ParseException;
+
+/**
+ * Abstract definition of a comparison test.
+ *
+ * @author <a href="mailto:william.piers@obeo.fr">William Piers</a>
+ */
+public class AbstractEMFCompareTest extends TestCase {
+
+ /**
+ * Compares the two elements.
+ *
+ * @param left
+ * the left element
+ * @param right
+ * the right element
+ */
+ protected void compareAndMergeDiffs(IntentStructuredElement left, IntentStructuredElement right) {
+ try {
+ new IntentASTMerger().mergeFromLocalToRepository(left, right);
+ } catch (MergingException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ /**
+ * Parses the given document.
+ *
+ * @param content
+ * the document as string
+ * @return the parser result
+ * @throws ParseException
+ */
+ protected IntentStructuredElement parseIntentDocument(String content) throws ParseException {
+ return (IntentStructuredElement)new IntentParser().parse(content);
+ }
+
+ /**
+ * Returns the content of the given file as a String.
+ *
+ * @param file
+ * file containing the information to extract.
+ * @return the content of the given file as a String
+ * @throws IOException
+ * if the file doesn't exists
+ */
+ protected static String getFileAsString(File file) throws IOException {
+ String result = "";
+ FileInputStream fis = null;
+ BufferedInputStream bis = null;
+ BufferedReader dis = null;
+ StringBuffer sb = new StringBuffer();
+
+ fis = new FileInputStream(file);
+ bis = new BufferedInputStream(fis);
+ dis = new BufferedReader(new InputStreamReader(bis));
+
+ while (dis.ready()) {
+ sb.append(dis.readLine() + "\n");
+ }
+
+ fis.close();
+ bis.close();
+ dis.close();
+
+ result = sb.toString();
+ return result;
+
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.compare.test/src/org/eclipse/mylyn/docs/intent/compare/test/utils/IntentPrettyPrinter.java b/tests/org.eclipse.mylyn.docs.intent.compare.test/src/org/eclipse/mylyn/docs/intent/compare/test/utils/IntentPrettyPrinter.java
new file mode 100644
index 0000000..1f2248d
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.compare.test/src/org/eclipse/mylyn/docs/intent/compare/test/utils/IntentPrettyPrinter.java
@@ -0,0 +1,473 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.mylyn.docs.intent.compare.test.utils;
+
+import java.io.PrintStream;
+import java.util.Arrays;
+
+import org.eclipse.emf.compare.AttributeChange;
+import org.eclipse.emf.compare.Comparison;
+import org.eclipse.emf.compare.Conflict;
+import org.eclipse.emf.compare.Diff;
+import org.eclipse.emf.compare.DifferenceKind;
+import org.eclipse.emf.compare.DifferenceSource;
+import org.eclipse.emf.compare.Match;
+import org.eclipse.emf.compare.MatchResource;
+import org.eclipse.emf.compare.ReferenceChange;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.mylyn.docs.intent.compare.utils.IntentEqualityHelper;
+import org.eclipse.mylyn.docs.intent.core.document.IntentDocument;
+import org.eclipse.mylyn.docs.intent.core.modelingunit.StructuralFeatureAffectation;
+import org.eclipse.mylyn.docs.intent.markup.markup.Annotations;
+import org.eclipse.mylyn.docs.intent.markup.markup.Text;
+
+import com.google.common.collect.Iterables;
+
+/**
+ * This class exposes methods to serialize a "human-readable" form of the comparison model onto a given
+ * stream.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
+ */
+@SuppressWarnings("nls")
+public final class IntentPrettyPrinter {
+
+ private static final String SEP = " |";
+
+ /** This is the max length of the columns we display for the Match. */
+ private static final int COLUMN_LENGTH = 40;
+
+ /**
+ * Hides default constructor.
+ */
+ private IntentPrettyPrinter() {
+ // No need to construct an instance of this.
+ }
+
+ /**
+ * Prints the whole comparison on the given stream (might be {@code stream} ).
+ *
+ * @param comparison
+ * The comparison we are to print on {@code stream}.
+ * @param stream
+ * The {@link PrintStream} on which we should print this comparison model.
+ */
+ public static void printComparison(Comparison comparison, PrintStream stream) {
+ for (MatchResource res : comparison.getMatchedResources()) {
+ stream.println("Matched resources :");
+ stream.println("Left = " + res.getLeftURI());
+ stream.println("Right = " + res.getRightURI());
+ stream.println("origin = " + res.getOriginURI());
+ }
+ stream.println();
+
+ printMatch(comparison, stream);
+
+ stream.println();
+
+ printDifferences(comparison, stream);
+ }
+
+ /**
+ * Prints all the Match elements contained by the given {@code comparison}. Each Match will be displayed
+ * on its own line.
+ * <p>
+ * For example, if the left model has two packages "package1" and "package2", but the right has "package1"
+ * and "package3", what we will display here depends on the Match : if "left.package1" is matched with
+ * "right.package1", but "package2" and "package3" did not match, this will print <code><pre>
+ * | package1 | package1 |
+ * | package2 | |
+ * | | package3 |
+ * </pre></code> On the contrary, if "package2" and "package3" did match, we will display <code><pre>
+ * | package1 | package1 |
+ * | package2 | package3 |
+ * </pre></code>
+ * </p>
+ *
+ * @param comparison
+ * The comparison which Matched elements we are to print on {@code stream}.
+ * @param stream
+ * The {@link PrintStream} on which we should print the matched elements of this comparison.
+ */
+ public static void printMatch(Comparison comparison, PrintStream stream) {
+ final String separator = "+----------------------------------------+----------------------------------------+----------------------------------------+"; //$NON-NLS-1$
+ final String leftLabel = "Left";
+ final String rightLabel = "Right";
+ final String originLabel = "Origin";
+ stream.println(separator);
+ stream.println('|' + formatHeader(leftLabel) + '|' + formatHeader(rightLabel) + '|'
+ + formatHeader(originLabel) + '|');
+ stream.println(separator);
+ for (Match match : comparison.getMatches()) {
+ printMatch(match, stream);
+ }
+ stream.println(separator);
+ }
+
+ /**
+ * Prints all differences detected for the given {@code comparison} on the given {@code stream}.
+ *
+ * @param comparison
+ * The comparison which differences we are to print on {@code stream}.
+ * @param stream
+ * The {@link PrintStream} on which we should print these differences.
+ */
+ public static void printDifferences(Comparison comparison, PrintStream stream) {
+ final Iterable<ReferenceChange> refChanges = Iterables.filter(comparison.getDifferences(),
+ ReferenceChange.class);
+
+ stream.println("REFERENCE CHANGES");
+ for (Diff diff : refChanges) {
+ printDiff(diff, stream);
+ }
+ stream.println();
+
+ stream.println("ATTRIBUTE CHANGES");
+ final Iterable<AttributeChange> attChanges = Iterables.filter(comparison.getDifferences(),
+ AttributeChange.class);
+ for (Diff diff : attChanges) {
+ printDiff(diff, stream);
+ }
+ stream.println();
+
+ stream.println("CONFLICTS");
+ for (Conflict conflict : comparison.getConflicts()) {
+ printConflict(conflict, stream);
+ }
+ }
+
+ /**
+ * Prints the given {@link Conflict} on the given {@code stream}.
+ *
+ * @param conflict
+ * The conflict we need to print on {@code stream}.
+ * @param stream
+ * The {@link PrintStream} on which we should print this conflict.
+ */
+ private static void printConflict(Conflict conflict, PrintStream stream) {
+ stream.println(conflict.getKind() + " conflict:");
+ final Iterable<ReferenceChange> refChanges = Iterables.filter(conflict.getDifferences(),
+ ReferenceChange.class);
+ for (Diff diff : refChanges) {
+ stream.print("\t");
+ printDiff(diff, stream);
+ }
+ final Iterable<AttributeChange> attChanges = Iterables.filter(conflict.getDifferences(),
+ AttributeChange.class);
+ for (Diff diff : attChanges) {
+ stream.print("\t");
+ printDiff(diff, stream);
+ }
+
+ }
+
+ /**
+ * Prints the given {@link Diff difference} on the given {@code stream}.
+ *
+ * @param diff
+ * The difference we are to print on {@code stream}.
+ * @param stream
+ * The {@link PrintStream} on which we should print this difference.
+ */
+ private static void printDiff(Diff diff, PrintStream stream) {
+ if (diff instanceof ReferenceChange) {
+ final ReferenceChange refChange = (ReferenceChange)diff;
+ final String valueName;
+ if (refChange.getValue() != null) {
+ valueName = elementToReadableString(refChange.getValue());
+ } else {
+ valueName = refChange.getValue().toString();
+ }
+ String change = "";
+ if (diff.getSource() == DifferenceSource.RIGHT) {
+ change = "remotely ";
+ }
+ if (diff.getKind() == DifferenceKind.ADD) {
+ change += "added to";
+ } else if (diff.getKind() == DifferenceKind.DELETE) {
+ change += "deleted from";
+ } else if (diff.getKind() == DifferenceKind.CHANGE) {
+ change += "changed from";
+ } else {
+ change += "moved from";
+ }
+ final String objectName;
+ if (refChange.getMatch().getLeft() != null) {
+ objectName = elementToReadableString(refChange.getMatch().getLeft());
+ } else if (refChange.getMatch().getRight() != null) {
+ objectName = elementToReadableString(refChange.getMatch().getRight());
+ } else if (refChange.getMatch().getOrigin() != null) {
+ objectName = elementToReadableString(refChange.getMatch().getOrigin());
+ } else {
+ objectName = "";
+ }
+ if (valueName != null) {
+ stream.println("[" + diff.getKind() + "] " + "value " + valueName + " has been " + change
+ + " reference " + refChange.getReference().getName() + " of object " + objectName);
+ }
+ } else if (diff instanceof AttributeChange) {
+ final AttributeChange attChange = (AttributeChange)diff;
+ String valueName = "null";
+ if (attChange.getValue() != null) {
+ valueName = attChange.getValue().toString();
+ }
+ String change = "";
+ if (diff.getSource() == DifferenceSource.RIGHT) {
+ change = "remotely ";
+ }
+ if (diff.getKind() == DifferenceKind.ADD) {
+ change += "added to";
+ } else if (diff.getKind() == DifferenceKind.DELETE) {
+ change += "deleted from";
+ } else if (diff.getKind() == DifferenceKind.CHANGE) {
+ change += "changed from";
+ } else {
+ change += "moved from";
+ }
+ final String objectName;
+ if (attChange.getMatch().getLeft() != null) {
+ objectName = elementToReadableString(attChange.getMatch().getLeft());
+ } else if (attChange.getMatch().getRight() != null) {
+ objectName = elementToReadableString(attChange.getMatch().getRight());
+ } else if (attChange.getMatch().getOrigin() != null) {
+ objectName = elementToReadableString(attChange.getMatch().getOrigin());
+ } else {
+ objectName = "";
+ }
+ stream.println("value " + valueName + " has been " + change + " attribute "
+ + attChange.getAttribute().getName() + " of object " + objectName);
+ }
+ }
+
+ /**
+ * Prints the given {@link Match} on the given {@code stream}.
+ *
+ * @param match
+ * The match we are to print on {@code stream}.
+ * @param stream
+ * The {@link PrintStream} on which we should print this difference.
+ * @see #printMatch(Comparison, PrintStream) A description on how we format the match.
+ */
+ private static void printMatch(Match match, PrintStream stream) {
+ String leftName = null;
+ String rightName = null;
+
+ final EObject left = match.getLeft();
+ final EObject right = match.getRight();
+
+ if (left != null) {
+ leftName = formatName(left);
+ } else {
+ int level = 0;
+ EObject currentMatch = match;
+ while (currentMatch instanceof Match && ((Match)currentMatch).getLeft() == null) {
+ currentMatch = currentMatch.eContainer();
+ }
+ while (currentMatch instanceof Match && ((Match)currentMatch).getLeft() != null) {
+ level++;
+ currentMatch = currentMatch.eContainer();
+ }
+ leftName = getEmptyLine(level);
+ }
+
+ if (right != null) {
+ rightName = formatName(right);
+ } else {
+ int level = 0;
+ EObject currentMatch = match;
+ while (currentMatch instanceof Match && ((Match)currentMatch).getRight() == null) {
+ currentMatch = currentMatch.eContainer();
+ }
+ while (currentMatch instanceof Match && ((Match)currentMatch).getRight() != null) {
+ level++;
+ currentMatch = currentMatch.eContainer();
+ }
+ rightName = getEmptyLine(level);
+ }
+ if (leftName != null && rightName != null) {
+ stream.println('|' + leftName + '|' + rightName + '|');
+ }
+
+ for (Match submatch : match.getSubmatches()) {
+ printMatch(submatch, stream);
+ }
+ }
+
+ /**
+ * Formats the given header so that it spans {@value #COLUMN_LENGTH} characters, centered between white
+ * spaces.
+ *
+ * @param header
+ * The header we are to format.
+ * @return The formatted header.
+ */
+ private static String formatHeader(String header) {
+ int padding = (COLUMN_LENGTH - header.length()) / 2;
+ char[] charsBefore = new char[padding];
+ for (int i = 0; i < charsBefore.length; i++) {
+ charsBefore[i] = ' ';
+ }
+ if ((header.length() & 1) == 1) {
+ padding++;
+ }
+ final char[] charsAfter = new char[padding];
+ for (int i = 0; i < charsAfter.length; i++) {
+ charsAfter[i] = ' ';
+ }
+ return String.valueOf(charsBefore) + header + String.valueOf(charsAfter);
+ }
+
+ /**
+ * Formats the named of the given element by adding spaces before and after it so that it spans
+ * {@value #COLUMN_LENGTH} characters at most.
+ *
+ * @param element
+ * The element which name should be formatted.
+ * @return the formatted element's name.
+ */
+ private static String formatName(EObject element) {
+ String name = elementToReadableString(element);
+ if (name != null) {
+ int level = 0;
+ EObject current = element;
+ while (current.eContainer() != null) {
+ level++;
+ current = current.eContainer();
+ }
+
+ char[] charsBefore = new char[1 + (level * 2)];
+ charsBefore[0] = ' ';
+ if (level > 0) {
+ for (int i = 1; i < charsBefore.length - 2; i = i + 2) {
+ charsBefore[i] = '|';
+ charsBefore[i + 1] = ' ';
+ }
+ charsBefore[charsBefore.length - 2] = '|';
+ charsBefore[charsBefore.length - 1] = '-';
+ }
+
+ int missingChars = COLUMN_LENGTH - name.length() - charsBefore.length;
+ final char[] spacesAfter = new char[Math.max(0, missingChars)];
+ Arrays.fill(spacesAfter, ' ');
+
+ return String.valueOf(charsBefore) + name + String.valueOf(spacesAfter);
+ }
+ return null;
+ }
+
+ /**
+ * Returns an "empty line" which will only show pipes for previous levels.
+ *
+ * @param level
+ * The level of nesting that we should make visible through pipes on this line.
+ * @return A line that displays only pipes for a tree's {@code level}, and only that.
+ */
+ private static String getEmptyLine(int level) {
+ char[] charsBefore = new char[1 + (level * 2)];
+ charsBefore[0] = ' ';
+ for (int i = 1; i < charsBefore.length; i = i + 2) {
+ charsBefore[i] = '|';
+ charsBefore[i + 1] = ' ';
+ }
+
+ int missingChars = COLUMN_LENGTH - charsBefore.length;
+ final char[] spacesAfter = new char[Math.max(0, missingChars)];
+ Arrays.fill(spacesAfter, ' ');
+
+ return String.valueOf(charsBefore) + String.valueOf(spacesAfter);
+ }
+
+ public static void displayModel(EObject root) {
+ displayModel(root, "");
+ }
+
+ public static void displayModel(EObject root, String tab) {
+ String s = elementToReadableString(root);
+ if (s != null) {
+ System.out.println(tab + "-" + s);
+ }
+ for (EObject content : root.eContents()) {
+ if (root instanceof IntentDocument) {
+ displayModel(content, tab);
+ } else {
+ displayModel(content, tab + SEP);
+ }
+ }
+ }
+
+ public static void displayMatchModel(Comparison comparison) {
+ for (Match root : comparison.getMatches()) {
+ displayMatchModel(root, "");
+ }
+ }
+
+ private static void displayMatchModel(Match root, String tab) {
+ String matchString = matchToReadableString(root);
+ if (matchString != null) {
+ System.out.println(tab + "-" + matchString);
+ }
+ for (Match match : root.getSubmatches()) {
+ if (root.getLeft() instanceof IntentDocument) {
+ displayMatchModel(match, tab);
+ } else {
+ displayMatchModel(match, tab + SEP);
+ }
+ }
+ }
+
+ public static String diffToReadableString(Diff diff) {
+ String res = diff.getKind() + " ";
+ if (diff instanceof AttributeChange) {
+ AttributeChange change = (AttributeChange)diff;
+ res += change.getAttribute().getEContainingClass().getName() + "."
+ + change.getAttribute().getName() + " ";
+ } else if (diff instanceof ReferenceChange) {
+ ReferenceChange change = (ReferenceChange)diff;
+ res += change.getReference().getEContainingClass().getName() + "."
+ + change.getReference().getName() + " ";
+ }
+ res += "\n" + diff + "\n";
+ res += "based on " + matchToReadableString(diff.getMatch());
+ return res;
+ }
+
+ private static String matchToReadableString(Match match) {
+ String res = null;
+ String left = elementToReadableString(match.getLeft());
+ String right = elementToReadableString(match.getRight());
+ if (left != null && right != null) {
+ res = left + " == " + right;
+ }
+ return res;
+ }
+
+ public static String elementToReadableString(EObject element) {
+ String res = null;
+ if (element == null) {
+ res = "?";
+ } else {
+ res = element.eClass().getName();
+ String fragment = new IntentEqualityHelper().getURI(element).fragment();
+ if (fragment != null) {
+ res += "[" + fragment + "]";
+ }
+ }
+ if (element instanceof Text) {
+ res = "\"" + ((Text)element).getData() + "\"";
+ } else if (element instanceof IntentDocument || element instanceof Annotations) {
+ res = null;
+ } else if (element instanceof StructuralFeatureAffectation) {
+ StructuralFeatureAffectation aff = (StructuralFeatureAffectation)element;
+ res += element.eClass().getName() + " \"" + aff.getName() + "\"";
+ }
+ return res;
+ }
+}
diff --git a/tests/org.eclipse.mylyn.docs.intent.parser.test/META-INF/MANIFEST.MF b/tests/org.eclipse.mylyn.docs.intent.parser.test/META-INF/MANIFEST.MF
index 013a4dc..d91d0c3 100644
--- a/tests/org.eclipse.mylyn.docs.intent.parser.test/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.mylyn.docs.intent.parser.test/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@
Bundle-Localization: plugin
Bundle-Name: org.eclipse.mylyn.docs.intent.modelingunit.parser.test
Bundle-SymbolicName: org.eclipse.mylyn.docs.intent.parser.test
-Bundle-Version: 0.7.0.qualifier
+Bundle-Version: 0.8.0.qualifier
Export-Package: org.eclipse.mylyn.docs.intent.parser.modelingunit.test.utils,
org.eclipse.mylyn.docs.intent.parser.test,
org.eclipse.mylyn.docs.intent.parser.test.utils
diff --git a/tests/org.eclipse.mylyn.docs.intent.parser.test/expectedResults/intentDocuments/intentDocument.xmi b/tests/org.eclipse.mylyn.docs.intent.parser.test/expectedResults/intentDocuments/intentDocument.xmi
index bb2a1c5..e4d19cd 100644
--- a/tests/org.eclipse.mylyn.docs.intent.parser.test/expectedResults/intentDocuments/intentDocument.xmi
+++ b/tests/org.eclipse.mylyn.docs.intent.parser.test/expectedResults/intentDocuments/intentDocument.xmi
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="ASCII"?>
<intentDocument:IntentDocument xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:intentDU="http://www.eclipse.org/intent/descriptionunit/0.7" xmlns:intentDocument="http://www.eclipse.org/intent/intentdocument/0.7" xmlns:intentGU="http://www.eclipse.org/intent/genericunit/0.7" xmlns:intentMU="http://www.eclipse.org/intent/modelingunit/0.7" xmlns:markup="http://www.eclipse.org/intent/markup/0.7" xsi:schemaLocation="http://www.eclipse.org/intent/descriptionunit/0.7 expectedResults/packagesModels/descriptionUnit.ecore http://www.eclipse.org/intent/intentdocument/0.7 expectedResults/packagesModels/org.eclipse.mylyn.docs.intent.core.document.ecore http://www.eclipse.org/intent/genericunit/0.7 expectedResults/packagesModels/genericUnit.ecore http://www.eclipse.org/intent/modelingunit/0.7 expectedResults/packagesModels/org.eclipse.mylyn.docs.intent.core.modelingunit.ecore http://www.eclipse.org/intent/markup/0.7 expectedResults/packagesModels/markup.ecore">
- <chapters>
+ <chapters completeLevel="1">
<title xmi:type="markup:Paragraph">
<attributes/>
<content xmi:type="markup:Text" data="Overview : the "/>
@@ -40,7 +40,7 @@
</descriptionBloc>
</instructions>
</intentContent>
- <intentContent xmi:type="intentDocument:IntentSection">
+ <intentContent xmi:type="intentDocument:IntentSection" completeLevel="1.1">
<title xmi:type="markup:Paragraph">
<attributes/>
<content xmi:type="markup:Text" data="Motivation for define Extended Library"/>
@@ -75,7 +75,7 @@
</instructions>
</intentContent>
</intentContent>
- <intentContent xmi:type="intentDocument:IntentSection">
+ <intentContent xmi:type="intentDocument:IntentSection" completeLevel="1.2">
<title xmi:type="markup:Paragraph">
<attributes/>
<content xmi:type="markup:Text" data="Extended Library storage : Resources definitions"/>
@@ -109,7 +109,7 @@
</instructions>
</intentContent>
</intentContent>
- <intentContent xmi:type="intentDocument:IntentSection">
+ <intentContent xmi:type="intentDocument:IntentSection" completeLevel="1.3">
<title xmi:type="markup:Paragraph">
<attributes/>
<content xmi:type="markup:Text" data="Extended Library Package : package hierarchy"/>
@@ -156,7 +156,7 @@
</intentContent>
</intentContent>
</chapters>
- <chapters>
+ <chapters completeLevel="2">
<title xmi:type="markup:Paragraph">
<attributes/>
<content xmi:type="markup:Text" data="The main entities of the Extended Library"/>
@@ -173,7 +173,7 @@
</descriptionBloc>
</instructions>
</intentContent>
- <intentContent xmi:type="intentDocument:IntentSection">
+ <intentContent xmi:type="intentDocument:IntentSection" completeLevel="2.1">
<title xmi:type="markup:Paragraph">
<attributes/>
<content xmi:type="markup:Text" data="Specification of a Book"/>
@@ -296,7 +296,7 @@
</intentContent>
</intentContent>
</chapters>
- <chapters>
+ <chapters completeLevel="3">
<title xmi:type="markup:Paragraph">
<attributes/>
<content xmi:type="markup:Text" data="The Items hierarchy"/>
@@ -312,7 +312,7 @@
</descriptionBloc>
</instructions>
</intentContent>
- <intentContent xmi:type="intentDocument:IntentSection">
+ <intentContent xmi:type="intentDocument:IntentSection" completeLevel="3.1">
<title xmi:type="markup:Paragraph">
<attributes/>
<content xmi:type="markup:Text" data="BookCategory : allow us to classify Books"/>
@@ -393,7 +393,7 @@
</instructions>
</intentContent>
</intentContent>
- <intentContent xmi:type="intentDocument:IntentSection">
+ <intentContent xmi:type="intentDocument:IntentSection" completeLevel="3.2">
<title xmi:type="markup:Paragraph">
<attributes/>
<content xmi:type="markup:Text" data="Presentation of the Book class."/>
@@ -476,7 +476,7 @@
</instructions>
</intentContent>
</intentContent>
- <intentContent xmi:type="intentDocument:IntentSection">
+ <intentContent xmi:type="intentDocument:IntentSection" completeLevel="3.3">
<title xmi:type="markup:Paragraph">
<attributes/>
<content xmi:type="markup:Text" data="Presentation of the Library class."/>
@@ -856,7 +856,7 @@
</instructions>
</intentContent>
</intentContent>
- <intentContent xmi:type="intentDocument:IntentSection">
+ <intentContent xmi:type="intentDocument:IntentSection" completeLevel="3.4">
<title xmi:type="markup:Paragraph">
<attributes/>
<content xmi:type="markup:Text" data="Presentation of the Writer class."/>
@@ -978,7 +978,7 @@
</instructions>
</intentContent>
</intentContent>
- <intentContent xmi:type="intentDocument:IntentSection">
+ <intentContent xmi:type="intentDocument:IntentSection" completeLevel="3.5">
<title xmi:type="markup:Paragraph">
<attributes/>
<content xmi:type="markup:Text" data="Presentation of the Item class."/>
@@ -1063,7 +1063,7 @@
</instructions>
</intentContent>
</intentContent>
- <intentContent xmi:type="intentDocument:IntentSection">
+ <intentContent xmi:type="intentDocument:IntentSection" completeLevel="3.6">
<title xmi:type="markup:Paragraph">
<attributes/>
<content xmi:type="markup:Text" data="Presentation of the Lendable class."/>
@@ -1183,7 +1183,7 @@
</instructions>
</intentContent>
</intentContent>
- <intentContent xmi:type="intentDocument:IntentSection">
+ <intentContent xmi:type="intentDocument:IntentSection" completeLevel="3.7">
<title xmi:type="markup:Paragraph">
<attributes/>
<content xmi:type="markup:Text" data="Presentation of the CirculatingItem class."/>
@@ -1255,7 +1255,7 @@
</instructions>
</intentContent>
</intentContent>
- <intentContent xmi:type="intentDocument:IntentSection">
+ <intentContent xmi:type="intentDocument:IntentSection" completeLevel="3.8">
<title xmi:type="markup:Paragraph">
<attributes/>
<content xmi:type="markup:Text" data="Presentation of the Periodical class."/>
@@ -1369,7 +1369,7 @@
</instructions>
</intentContent>
</intentContent>
- <intentContent xmi:type="intentDocument:IntentSection">
+ <intentContent xmi:type="intentDocument:IntentSection" completeLevel="3.9">
<title xmi:type="markup:Paragraph">
<attributes/>
<content xmi:type="markup:Text" data="Presentation of the AudioVisualItem class."/>
@@ -1504,7 +1504,7 @@
</instructions>
</intentContent>
</intentContent>
- <intentContent xmi:type="intentDocument:IntentSection">
+ <intentContent xmi:type="intentDocument:IntentSection" completeLevel="3.10">
<title xmi:type="markup:Paragraph">
<attributes/>
<content xmi:type="markup:Text" data="Presentation of the BookOnTape class."/>
@@ -1612,7 +1612,7 @@
</instructions>
</intentContent>
</intentContent>
- <intentContent xmi:type="intentDocument:IntentSection">
+ <intentContent xmi:type="intentDocument:IntentSection" completeLevel="3.11">
<title xmi:type="markup:Paragraph">
<attributes/>
<content xmi:type="markup:Text" data="Presentation of the VideoCassette class."/>
@@ -1702,7 +1702,7 @@
</instructions>
</intentContent>
</intentContent>
- <intentContent xmi:type="intentDocument:IntentSection">
+ <intentContent xmi:type="intentDocument:IntentSection" completeLevel="3.12">
<title xmi:type="markup:Paragraph">
<attributes/>
<content xmi:type="markup:Text" data="Presentation of the Borrower class."/>
@@ -1798,7 +1798,7 @@
</intentContent>
</intentContent>
</chapters>
- <chapters>
+ <chapters completeLevel="4">
<title xmi:type="markup:Paragraph">
<attributes/>
<content xmi:type="markup:Text" data="Specification of the actor of an Extended Library : Employees and Borrowers"/>
@@ -1813,7 +1813,7 @@
</descriptionBloc>
</instructions>
</intentContent>
- <intentContent xmi:type="intentDocument:IntentSection">
+ <intentContent xmi:type="intentDocument:IntentSection" completeLevel="4.1">
<title xmi:type="markup:Paragraph">
<attributes/>
<content xmi:type="markup:Text" data="Presentation of the Person class."/>
@@ -1927,7 +1927,7 @@
</instructions>
</intentContent>
</intentContent>
- <intentContent xmi:type="intentDocument:IntentSection">
+ <intentContent xmi:type="intentDocument:IntentSection" completeLevel="4.2">
<title xmi:type="markup:Paragraph">
<attributes/>
<content xmi:type="markup:Text" data="Presentation of the Employee class."/>
@@ -2014,7 +2014,7 @@
</instructions>
</intentContent>
</intentContent>
- <intentContent xmi:type="intentDocument:IntentSection">
+ <intentContent xmi:type="intentDocument:IntentSection" completeLevel="4.3">
<title xmi:type="markup:Paragraph">
<attributes/>
<content xmi:type="markup:Text" data="Presentation of the Addressable class."/>
diff --git a/tests/org.eclipse.mylyn.docs.intent.parser.test/pom.xml b/tests/org.eclipse.mylyn.docs.intent.parser.test/pom.xml
index 013e7c1..78a232f 100644
--- a/tests/org.eclipse.mylyn.docs.intent.parser.test/pom.xml
+++ b/tests/org.eclipse.mylyn.docs.intent.parser.test/pom.xml
@@ -13,7 +13,7 @@
<parent>
<groupId>org.eclipse.mylyn.docs.intent-group</groupId>
<artifactId>intent-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>