diff options
author | Arnaud Cuccuru | 2013-09-17 09:09:46 +0000 |
---|---|---|
committer | Arnaud Cuccuru | 2013-09-17 09:27:05 +0000 |
commit | 3d4e598102b6ce95ec64d26b349271358f419f89 (patch) | |
tree | 01a8ed9f2a44228bee38dbfc7fc4ca74128372db /plugins/uml/xtext | |
parent | 4181e7c5d2222cee821e00f45970c4570a94bb4b (diff) | |
download | org.eclipse.papyrus-3d4e598102b6ce95ec64d26b349271358f419f89.tar.gz org.eclipse.papyrus-3d4e598102b6ce95ec64d26b349271358f419f89.tar.xz org.eclipse.papyrus-3d4e598102b6ce95ec64d26b349271358f419f89.zip |
Bug 315231 - Improvement of xtext integration.
Applied patches from ITEMIS. Changes the validation constraint to check
for comments instead of ecore annotation. Creates a comment when a
linking error occured.
Diffstat (limited to 'plugins/uml/xtext')
3 files changed, 16 insertions, 16 deletions
diff --git a/plugins/uml/xtext/org.eclipse.papyrus.uml.xtext.integration.ui/src/org/eclipse/papyrus/uml/xtext/integration/DefaultXtextDirectEditorConfiguration.java b/plugins/uml/xtext/org.eclipse.papyrus.uml.xtext.integration.ui/src/org/eclipse/papyrus/uml/xtext/integration/DefaultXtextDirectEditorConfiguration.java index 97c6ed814d9..45a60d77a93 100644 --- a/plugins/uml/xtext/org.eclipse.papyrus.uml.xtext.integration.ui/src/org/eclipse/papyrus/uml/xtext/integration/DefaultXtextDirectEditorConfiguration.java +++ b/plugins/uml/xtext/org.eclipse.papyrus.uml.xtext.integration.ui/src/org/eclipse/papyrus/uml/xtext/integration/DefaultXtextDirectEditorConfiguration.java @@ -44,6 +44,8 @@ import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.uml2.uml.Comment; import org.eclipse.uml2.uml.Element; +import org.eclipse.xtext.EcoreUtil2; +import org.eclipse.xtext.util.CancelIndicator; import org.eclipse.xtext.util.StringInputStream; import com.google.inject.Injector; @@ -133,8 +135,11 @@ public abstract class DefaultXtextDirectEditorConfiguration extends } catch (IOException e) { e.printStackTrace(); } + EcoreUtil2.resolveLazyCrossReferences( + context.getFakeResource(), CancelIndicator.NullImpl); if (!context.getFakeResource().getParseResult() - .hasSyntaxErrors()) { + .hasSyntaxErrors() + && context.getFakeResource().getErrors().size() == 0) { EObject xtextObject = context.getFakeResource() .getParseResult().getRootASTElement(); return DefaultXtextDirectEditorConfiguration.this diff --git a/plugins/uml/xtext/org.eclipse.papyrus.uml.xtext.integration.validation/META-INF/MANIFEST.MF b/plugins/uml/xtext/org.eclipse.papyrus.uml.xtext.integration.validation/META-INF/MANIFEST.MF index 304ac99e72d..7283ccff891 100644 --- a/plugins/uml/xtext/org.eclipse.papyrus.uml.xtext.integration.validation/META-INF/MANIFEST.MF +++ b/plugins/uml/xtext/org.eclipse.papyrus.uml.xtext.integration.validation/META-INF/MANIFEST.MF @@ -9,5 +9,6 @@ Bundle-Vendor: Eclipse Modeling Project Require-Bundle: org.eclipse.core.runtime;bundle-version="3.9.0", org.eclipse.emf.ecore;bundle-version="2.9.0", org.eclipse.emf.validation;bundle-version="1.7.0", - org.eclipse.uml2.uml;bundle-version="4.1.0" + org.eclipse.uml2.uml;bundle-version="4.1.0", + org.eclipse.papyrus.uml.xtext.integration.ui;bundle-version="0.10.1" Export-Package: org.eclipse.papyrus.uml.xtext.integration.validation diff --git a/plugins/uml/xtext/org.eclipse.papyrus.uml.xtext.integration.validation/src/org/eclipse/papyrus/uml/xtext/integration/validation/ExistsAnnotationConstraint.java b/plugins/uml/xtext/org.eclipse.papyrus.uml.xtext.integration.validation/src/org/eclipse/papyrus/uml/xtext/integration/validation/ExistsAnnotationConstraint.java index 8800a38f8d0..008439089cb 100644 --- a/plugins/uml/xtext/org.eclipse.papyrus.uml.xtext.integration.validation/src/org/eclipse/papyrus/uml/xtext/integration/validation/ExistsAnnotationConstraint.java +++ b/plugins/uml/xtext/org.eclipse.papyrus.uml.xtext.integration.validation/src/org/eclipse/papyrus/uml/xtext/integration/validation/ExistsAnnotationConstraint.java @@ -1,42 +1,36 @@ package org.eclipse.papyrus.uml.xtext.integration.validation;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EModelElement;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.validation.AbstractModelConstraint;
import org.eclipse.emf.validation.EMFEventType;
import org.eclipse.emf.validation.IValidationContext;
+import org.eclipse.papyrus.uml.xtext.integration.InvalidStringUtil;
+import org.eclipse.uml2.uml.Element;
/**
* Creates an error if a model element has an annotation. If an annotation exist
* the xtext string couldn't be parsed and is out of sync with the UML model.
*
*
- * @author Markus Mühlbrandt
+ * @author Markus Mühlbrandt
*
*/
public class ExistsAnnotationConstraint extends AbstractModelConstraint {
- public static final String ANNOTATION_SOURCE = "expression_source";
-
- public static final String ANNOTATION_DETAIL = "expression";
-
@Override
public IStatus validate(IValidationContext ctx) {
EObject eObj = ctx.getTarget();
EMFEventType eType = ctx.getEventType();
String text = null;
// In the case of batch mode.
- if(eType == EMFEventType.NULL) {
- if(eObj instanceof EModelElement) {
- EAnnotation eAnnotation = ((EModelElement)eObj).getEAnnotation(ANNOTATION_SOURCE);
- if(eAnnotation != null) {
- text = eAnnotation.getDetails().get(ANNOTATION_DETAIL);
- }
+ if (eType == EMFEventType.NULL) {
+ if (eObj instanceof Element) {
+ Element element = (Element) eObj;
+ text = InvalidStringUtil.getTextualRepresentation(element);
}
- if(text != null && !"".equals(text)) {
+ if (text != null && !"".equals(text)) {
return ctx.createFailureStatus(eObj.eClass().getName());
}
}
|