Skip to content
Snippets Groups Projects
Commit 5a57acb7 authored by iweigelt's avatar iweigelt
Browse files

Fixed bug #3305107 (Renaming Machine creates NPE when trying to open in Camille)

git-svn-id: svn://svn.code.sf.net/p/rodin-b-sharp/svn/trunk/Camille@11694 1434b563-b632-4741-aa49-43a3a8374d2e
parent bdc34a0b
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<feature <feature
id="org.eventb.texteditor.feature" id="org.eventb.texteditor.feature"
label="Camille TextEditor" label="Camille TextEditor"
version="2.1.2" version="2.1.3"
provider-name="Heinrich-Heine University Dusseldorf" provider-name="Heinrich-Heine University Dusseldorf"
plugin="org.eventb.texteditor.ui"> plugin="org.eventb.texteditor.ui">
...@@ -10,7 +10,9 @@ ...@@ -10,7 +10,9 @@
A text editor for the Rodin platform to edit Event-B models A text editor for the Rodin platform to edit Event-B models
----------------------------------------------------------- -----------------------------------------------------------
Release History: Release History:
2.1.0.beta - Rodin 2.1.1 release compatible with EventB-EMF Framework 3.3.0 2.1.3 - Bigfix release for Bug #3305107 (NPE after renaming a machine)
2.1.0.beta - Rodin 2.1.1 release compatible with EventB-EMF Framework
3.3.0
(emf-compare 1.1.2) (emf-compare 1.1.2)
2.0.1 - Rodin 2.0 release 2.0.1 - Rodin 2.0 release
2.0.0 - Rodin 1.3.1 release compatible with 2.0.0 - Rodin 1.3.1 release compatible with
......
...@@ -2,7 +2,7 @@ Manifest-Version: 1.0 ...@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2 Bundle-ManifestVersion: 2
Bundle-Name: Event-B EMF Texttools Bundle-Name: Event-B EMF Texttools
Bundle-SymbolicName: org.eventb.texttools;singleton:=true Bundle-SymbolicName: org.eventb.texttools;singleton:=true
Bundle-Version: 2.1.2 Bundle-Version: 2.1.3
Bundle-Activator: org.eventb.texttools.TextToolsPlugin Bundle-Activator: org.eventb.texttools.TextToolsPlugin
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,3.7.0)", Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,3.7.0)",
org.eclipse.jface.text;bundle-version="[3.5.0,3.7.0)", org.eclipse.jface.text;bundle-version="[3.5.0,3.7.0)",
......
...@@ -29,6 +29,13 @@ import org.eventb.emf.core.EventBNamedCommentedComponentElement; ...@@ -29,6 +29,13 @@ import org.eventb.emf.core.EventBNamedCommentedComponentElement;
import org.eventb.texttools.merge.ModelMerge; import org.eventb.texttools.merge.ModelMerge;
import org.eventb.texttools.prettyprint.PrettyPrinter; import org.eventb.texttools.prettyprint.PrettyPrinter;
import de.be4.eventb.core.parser.BException;
import de.be4.eventb.core.parser.EventBParser;
import de.be4.eventb.core.parser.node.AContextParseUnit;
import de.be4.eventb.core.parser.node.AMachineParseUnit;
import de.be4.eventb.core.parser.node.PParseUnit;
import de.be4.eventb.core.parser.node.Start;
public class PersistenceHelper { public class PersistenceHelper {
public static final Boolean DEBUG = false; public static final Boolean DEBUG = false;
...@@ -168,7 +175,42 @@ public class PersistenceHelper { ...@@ -168,7 +175,42 @@ public class PersistenceHelper {
// we should find a text representation in the EMF // we should find a text representation in the EMF
final String text = getTextAnnotation(resource); final String text = getTextAnnotation(resource);
if (text != null) {
/* workaround for Bug #3305107
*
* When a machine- or contextfile is renamed the lastmodified date does not change.
* Since isTextUptodate() compares timestamps only, it returns true for renamed files.
* */
boolean namesMatch = true;
final EventBNamedCommentedComponentElement rootElement = getComponent(resource);
if (rootElement != null) {
final EventBParser parser = new EventBParser();
try {
Start start = parser.parse(text, false);
System.out.println(start);
PParseUnit pParseUnit = start.getPParseUnit();
String parsedName = null;
if (pParseUnit instanceof AMachineParseUnit){
parsedName = ((AMachineParseUnit)start.getPParseUnit()).getName().getText();
}
if (pParseUnit instanceof AContextParseUnit){
parsedName = ((AContextParseUnit)start.getPParseUnit()).getName().getText();
}
if (parsedName != null){
if (!parsedName.equals(rootElement.getName())){
namesMatch = false;
System.err.println("Conflicting names of ParseUnit! Expected name: '" + rootElement.getName() + "' actual name: '" + parsedName + "'! Prettyprinting unit...");
}
}
} catch (BException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/* End of woraround */
if (text != null && namesMatch) {
return text; return text;
} }
} }
...@@ -270,6 +312,10 @@ public class PersistenceHelper { ...@@ -270,6 +312,10 @@ public class PersistenceHelper {
private static boolean isTextUptodate(final Resource resource) { private static boolean isTextUptodate(final Resource resource) {
final long textTimestamp = getTextTimestamp(resource); final long textTimestamp = getTextTimestamp(resource);
if (true){
//return false;
}
try { try {
final IResource file = getIResource(resource); final IResource file = getIResource(resource);
// refresh to get latest timestamp // refresh to get latest timestamp
......
...@@ -125,7 +125,7 @@ public class EventBReferencesCheck extends ReferencesCheck { ...@@ -125,7 +125,7 @@ public class EventBReferencesCheck extends ReferencesCheck {
public List<UnmatchElement> filterUnmatchedElements(List<UnmatchElement> unmatched) { public List<UnmatchElement> filterUnmatchedElements(List<UnmatchElement> unmatched) {
final List<UnmatchElement> filteredUnmatched = new ArrayList<UnmatchElement>(unmatched.size()); final List<UnmatchElement> filteredUnmatched = new ArrayList<UnmatchElement>(unmatched.size());
for (UnmatchElement element : unmatched) { for (UnmatchElement element : unmatched) {
if (!shouldBeIgnoredAllowContainment(element.getElement().eContainmentFeature())) { if (element.getElement().eContainmentFeature() == null || !shouldBeIgnoredAllowContainment(element.getElement().eContainmentFeature())) {
filteredUnmatched.add(element); filteredUnmatched.add(element);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment