Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Merks2012-01-15 13:54:12 +0000
committerEd Merks2012-01-15 13:54:12 +0000
commitcddfae8e6dd4058e14a47a0c34a39790b1968703 (patch)
tree335ff7bb96266e60f5a0128981a62abab4dc2f3e /tests/org.eclipse.emf.test.ecore.xcore/src
parenta12920a0935ff60cadf65e3f3dc3d393ad75de6e (diff)
downloadorg.eclipse.emf-cddfae8e6dd4058e14a47a0c34a39790b1968703.tar.gz
org.eclipse.emf-cddfae8e6dd4058e14a47a0c34a39790b1968703.tar.xz
org.eclipse.emf-cddfae8e6dd4058e14a47a0c34a39790b1968703.zip
[368320] Format using EMF formatting rules
Diffstat (limited to 'tests/org.eclipse.emf.test.ecore.xcore/src')
-rw-r--r--tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/EObjectFormatter.java302
-rw-r--r--tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/GenModelFormatter.java146
-rw-r--r--tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/ecore/XcoreEcoreTest.java42
-rw-r--r--tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/genmodel/XcoreGenModelTest.java44
-rw-r--r--tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/interpreter/XcoreInterpreterXbaseIntegrationTest.java78
-rw-r--r--tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/scoping/LazyCreationProxyUriConverterTest.java166
-rw-r--r--tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/scoping/LazyGenModelInferenceTest.java215
-rw-r--r--tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/scoping/ResourceDescriptionManagerTest.java55
-rw-r--r--tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/scoping/XcoreScopingTest.java54
-rw-r--r--tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/validation/XcoreValidationTest.java60
10 files changed, 602 insertions, 560 deletions
diff --git a/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/EObjectFormatter.java b/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/EObjectFormatter.java
index 4953d1064..500f98e6a 100644
--- a/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/EObjectFormatter.java
+++ b/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/EObjectFormatter.java
@@ -7,6 +7,7 @@
*/
package org.eclipse.emf.test.ecore.xcore;
+
import java.util.List;
import org.eclipse.emf.common.util.URI;
@@ -22,6 +23,7 @@ import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.collect.Iterables;
+
/**
* @author Moritz Eysholdt - Initial contribution and API
*
@@ -30,154 +32,156 @@ import com.google.common.collect.Iterables;
public class EObjectFormatter implements Function<EObject, String>
{
- protected boolean resolveCrossReferences = false;
-
- protected boolean showIndex = false;
-
- public String apply(EObject from)
- {
- return format(from);
- }
-
- protected String assignmentOperator(EObject object, EStructuralFeature feature)
- {
- if (feature instanceof EReference && !((EReference) feature).isContainment())
- return "->";
- else
- return "=";
- }
-
- public String format(EObject object)
- {
- if (object == null)
- return "null";
- StringBuilder result = new StringBuilder();
- result.append(object.eClass().getName());
- result.append(" {");
- for (EStructuralFeature feature : object.eClass().getEAllStructuralFeatures())
- if (shouldFormat(object, feature))
- result.append(indent("\n" + format(object, feature)));
- result.append("\n}");
- return result.toString();
- }
-
- protected String format(EObject object, EStructuralFeature feature)
- {
- StringBuilder result = new StringBuilder();
- result.append(feature.getName());
- result.append(" ");
- result.append(assignmentOperator(object, feature));
- result.append(" ");
- Object val = object.eGet(feature, resolveCrossReferences);
- if (feature.isMany())
- {
- result.append("[");
- List<?> vals = (List<?>) val;
- List<?> sortedVals = sort(object, feature, vals);
- if (vals == sortedVals)
- {
- for (int i = 0; i < vals.size(); i++)
- if (shouldFormat(object, feature, i, vals.get(i)))
- result.append(indent("\n" + format(object, feature, i, vals.get(i))));
- } else
- {
- for (int i = 0; i < sortedVals.size(); i++)
- if (shouldFormat(object, feature, sortedVals.get(i)))
- result.append(indent("\n" + format(object, feature, sortedVals.get(i))));
- }
- result.append("\n]");
- } else
- result.append(indent(format(object, feature, val)));
- return result.toString();
- }
-
- protected String format(EObject object, EStructuralFeature feature, int index, Object value)
- {
- if (showIndex)
- return index + ": " + format(object, feature, value);
- return format(object, feature, value);
- }
-
- protected String format(EObject object, EStructuralFeature feature, Object value)
- {
- if (feature instanceof EAttribute)
- return formatAttributeValue(object, (EAttribute) feature, value);
- else if (feature instanceof EReference)
- {
- EReference ref = (EReference) feature;
- if (ref.isContainment())
- return format((EObject) value);
- return formatCrossRefValue(object, ref, (EObject) value);
- }
- return "";
- }
-
- public String format(Iterable<? extends EObject> object)
- {
- return Joiner.on('\n').join(Iterables.transform(object, this));
- }
-
- protected String formatAttributeValue(EObject object, EAttribute feature, Object value)
- {
- if (value == null)
- return "null";
- EFactory factory = feature.getEAttributeType().getEPackage().getEFactoryInstance();
- String stringVal = factory.convertToString(feature.getEAttributeType(), value);
- return "'" + stringVal + "'";
- }
-
- protected String formatCrossRefValue(EObject object, EReference feature, EObject value)
- {
- if (value == null)
- return "null";
- if (value.eIsProxy())
- return "proxy (URI: " + ((InternalEObject) value).eProxyURI() + ")";
- if (value.eResource() == object.eResource())
- return value.eClass().getName() + " " + object.eResource().getURIFragment(value);
- URI uri = EcoreUtil.getURI(value);
- uri = uri.deresolve(object.eResource().getURI());
- return value.eClass().getName() + " " + uri.toString();
- }
-
- protected String indent(String string)
- {
- return string.replaceAll("\\n", "\n\t");
- }
-
- public EObjectFormatter resolveCrossReferences()
- {
- this.resolveCrossReferences = true;
- return this;
- }
-
- protected boolean shouldFormat(EObject object, EStructuralFeature feature)
- {
- if (feature.isDerived())
- return false;
- if (feature instanceof EReference && ((EReference) feature).isContainer())
- return false;
- return object.eIsSet(feature);
- }
-
- protected boolean shouldFormat(EObject object, EStructuralFeature feature, int index, Object value)
- {
- return true;
- }
-
- protected boolean shouldFormat(EObject object, EStructuralFeature feature, Object value)
- {
- return true;
- }
-
- public EObjectFormatter showIndex()
- {
- this.showIndex = true;
- return this;
- }
-
- protected List<?> sort(EObject obj, EStructuralFeature feature, List<?> values)
- {
- return values;
- }
+ protected boolean resolveCrossReferences = false;
+
+ protected boolean showIndex = false;
+
+ public String apply(EObject from)
+ {
+ return format(from);
+ }
+
+ protected String assignmentOperator(EObject object, EStructuralFeature feature)
+ {
+ if (feature instanceof EReference && !((EReference)feature).isContainment())
+ return "->";
+ else
+ return "=";
+ }
+
+ public String format(EObject object)
+ {
+ if (object == null)
+ return "null";
+ StringBuilder result = new StringBuilder();
+ result.append(object.eClass().getName());
+ result.append(" {");
+ for (EStructuralFeature feature : object.eClass().getEAllStructuralFeatures())
+ if (shouldFormat(object, feature))
+ result.append(indent("\n" + format(object, feature)));
+ result.append("\n}");
+ return result.toString();
+ }
+
+ protected String format(EObject object, EStructuralFeature feature)
+ {
+ StringBuilder result = new StringBuilder();
+ result.append(feature.getName());
+ result.append(" ");
+ result.append(assignmentOperator(object, feature));
+ result.append(" ");
+ Object val = object.eGet(feature, resolveCrossReferences);
+ if (feature.isMany())
+ {
+ result.append("[");
+ List<?> vals = (List<?>)val;
+ List<?> sortedVals = sort(object, feature, vals);
+ if (vals == sortedVals)
+ {
+ for (int i = 0; i < vals.size(); i++)
+ if (shouldFormat(object, feature, i, vals.get(i)))
+ result.append(indent("\n" + format(object, feature, i, vals.get(i))));
+ }
+ else
+ {
+ for (int i = 0; i < sortedVals.size(); i++)
+ if (shouldFormat(object, feature, sortedVals.get(i)))
+ result.append(indent("\n" + format(object, feature, sortedVals.get(i))));
+ }
+ result.append("\n]");
+ }
+ else
+ result.append(indent(format(object, feature, val)));
+ return result.toString();
+ }
+
+ protected String format(EObject object, EStructuralFeature feature, int index, Object value)
+ {
+ if (showIndex)
+ return index + ": " + format(object, feature, value);
+ return format(object, feature, value);
+ }
+
+ protected String format(EObject object, EStructuralFeature feature, Object value)
+ {
+ if (feature instanceof EAttribute)
+ return formatAttributeValue(object, (EAttribute)feature, value);
+ else if (feature instanceof EReference)
+ {
+ EReference ref = (EReference)feature;
+ if (ref.isContainment())
+ return format((EObject)value);
+ return formatCrossRefValue(object, ref, (EObject)value);
+ }
+ return "";
+ }
+
+ public String format(Iterable<? extends EObject> object)
+ {
+ return Joiner.on('\n').join(Iterables.transform(object, this));
+ }
+
+ protected String formatAttributeValue(EObject object, EAttribute feature, Object value)
+ {
+ if (value == null)
+ return "null";
+ EFactory factory = feature.getEAttributeType().getEPackage().getEFactoryInstance();
+ String stringVal = factory.convertToString(feature.getEAttributeType(), value);
+ return "'" + stringVal + "'";
+ }
+
+ protected String formatCrossRefValue(EObject object, EReference feature, EObject value)
+ {
+ if (value == null)
+ return "null";
+ if (value.eIsProxy())
+ return "proxy (URI: " + ((InternalEObject)value).eProxyURI() + ")";
+ if (value.eResource() == object.eResource())
+ return value.eClass().getName() + " " + object.eResource().getURIFragment(value);
+ URI uri = EcoreUtil.getURI(value);
+ uri = uri.deresolve(object.eResource().getURI());
+ return value.eClass().getName() + " " + uri.toString();
+ }
+
+ protected String indent(String string)
+ {
+ return string.replaceAll("\\n", "\n\t");
+ }
+
+ public EObjectFormatter resolveCrossReferences()
+ {
+ this.resolveCrossReferences = true;
+ return this;
+ }
+
+ protected boolean shouldFormat(EObject object, EStructuralFeature feature)
+ {
+ if (feature.isDerived())
+ return false;
+ if (feature instanceof EReference && ((EReference)feature).isContainer())
+ return false;
+ return object.eIsSet(feature);
+ }
+
+ protected boolean shouldFormat(EObject object, EStructuralFeature feature, int index, Object value)
+ {
+ return true;
+ }
+
+ protected boolean shouldFormat(EObject object, EStructuralFeature feature, Object value)
+ {
+ return true;
+ }
+
+ public EObjectFormatter showIndex()
+ {
+ this.showIndex = true;
+ return this;
+ }
+
+ protected List<?> sort(EObject obj, EStructuralFeature feature, List<?> values)
+ {
+ return values;
+ }
}
diff --git a/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/GenModelFormatter.java b/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/GenModelFormatter.java
index d830a1fec..2c63386bc 100644
--- a/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/GenModelFormatter.java
+++ b/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/GenModelFormatter.java
@@ -7,6 +7,7 @@
*/
package org.eclipse.emf.test.ecore.xcore;
+
import org.eclipse.emf.codegen.ecore.genmodel.GenClass;
import org.eclipse.emf.codegen.ecore.genmodel.GenDataType;
import org.eclipse.emf.codegen.ecore.genmodel.GenFeature;
@@ -23,87 +24,88 @@ import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.ecore.util.EcoreSwitch;
import org.eclipse.xtext.EcoreUtil2;
+
public class GenModelFormatter extends EObjectFormatter
{
- private static class EcoreTitleSwitch extends EcoreSwitch<String>
- {
- @Override
- public String caseENamedElement(ENamedElement object)
- {
- EPackage pkg = EcoreUtil2.getContainerOfType(object, EPackage.class);
- StringBuilder result = new StringBuilder();
- if (pkg != object)
- {
- result.append(pkg.getName());
- result.append("::");
- }
- result.append(object.getName());
- return result.toString();
- }
+ private static class EcoreTitleSwitch extends EcoreSwitch<String>
+ {
+ @Override
+ public String caseENamedElement(ENamedElement object)
+ {
+ EPackage pkg = EcoreUtil2.getContainerOfType(object, EPackage.class);
+ StringBuilder result = new StringBuilder();
+ if (pkg != object)
+ {
+ result.append(pkg.getName());
+ result.append("::");
+ }
+ result.append(object.getName());
+ return result.toString();
+ }
- @Override
- public String caseEStructuralFeature(EStructuralFeature object)
- {
- StringBuilder result = new StringBuilder();
- result.append(doSwitch(object.getEContainingClass()));
- result.append("::");
- result.append(object.getName());
- return result.toString();
- }
- }
+ @Override
+ public String caseEStructuralFeature(EStructuralFeature object)
+ {
+ StringBuilder result = new StringBuilder();
+ result.append(doSwitch(object.getEContainingClass()));
+ result.append("::");
+ result.append(object.getName());
+ return result.toString();
+ }
+ }
- private static class GenModelTitleSwitch extends GenModelSwitch<String>
- {
- @Override
- public String caseGenClass(GenClass object)
- {
- return object.getQualifiedInterfaceName();
- }
+ private static class GenModelTitleSwitch extends GenModelSwitch<String>
+ {
+ @Override
+ public String caseGenClass(GenClass object)
+ {
+ return object.getQualifiedInterfaceName();
+ }
- @Override
- public String caseGenDataType(GenDataType object)
- {
- return object.getQualifiedInstanceClassName();
- }
+ @Override
+ public String caseGenDataType(GenDataType object)
+ {
+ return object.getQualifiedInstanceClassName();
+ }
- @Override
- public String caseGenFeature(GenFeature object)
- {
- StringBuilder result = new StringBuilder();
- result.append(doSwitch(object.getGenClass()));
- result.append(".");
- result.append(object.getName());
- return result.toString();
- }
+ @Override
+ public String caseGenFeature(GenFeature object)
+ {
+ StringBuilder result = new StringBuilder();
+ result.append(doSwitch(object.getGenClass()));
+ result.append(".");
+ result.append(object.getName());
+ return result.toString();
+ }
- @Override
- public String caseGenModel(GenModel object)
- {
- return object.getModelName();
- }
+ @Override
+ public String caseGenModel(GenModel object)
+ {
+ return object.getModelName();
+ }
- @Override
- public String caseGenPackage(GenPackage object)
- {
- return object.getQualifiedPackageInterfaceName();
- }
+ @Override
+ public String caseGenPackage(GenPackage object)
+ {
+ return object.getQualifiedPackageInterfaceName();
+ }
- }
+ }
- @Override
- protected String formatCrossRefValue(EObject object, EReference feature, EObject value)
- {
- if (value != null && !value.eIsProxy())
- {
- String title = null;
- if (value.eClass().getEPackage() == EcorePackage.eINSTANCE)
- title = new EcoreTitleSwitch().doSwitch(value);
- else if (value.eClass().getEPackage() == GenModelPackage.eINSTANCE)
- title = new GenModelTitleSwitch().doSwitch(value);
- if (title != null)
- return value.eClass().getName() + " " + title;
- }
- return super.formatCrossRefValue(object, feature, value);
- }
+ @Override
+ protected String formatCrossRefValue(EObject object, EReference feature, EObject value)
+ {
+ if (value != null && !value.eIsProxy())
+ {
+ String title = null;
+ if (value.eClass().getEPackage() == EcorePackage.eINSTANCE)
+ title = new EcoreTitleSwitch().doSwitch(value);
+ else if (value.eClass().getEPackage() == GenModelPackage.eINSTANCE)
+ title = new GenModelTitleSwitch().doSwitch(value);
+ if (title != null)
+ return value.eClass().getName() + " " + title;
+ }
+ return super.formatCrossRefValue(object, feature, value);
+ }
}
diff --git a/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/ecore/XcoreEcoreTest.java b/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/ecore/XcoreEcoreTest.java
index 6eae729d9..4f101db65 100644
--- a/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/ecore/XcoreEcoreTest.java
+++ b/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/ecore/XcoreEcoreTest.java
@@ -7,6 +7,7 @@
*/
package org.eclipse.emf.test.ecore.xcore.ecore;
+
import org.eclipse.emf.ecore.ENamedElement;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.xcore.XNamedElement;
@@ -26,6 +27,7 @@ import org.junit.runner.RunWith;
import com.google.inject.Inject;
+
@SuppressWarnings("restriction")
@InjectWith(XcoreInjectorProvider.class)
@RunWith(ParameterizedXtextRunner.class)
@@ -33,30 +35,30 @@ import com.google.inject.Inject;
public class XcoreEcoreTest
{
- @Inject
- private XcoreMapper mapper;
+ @Inject
+ private XcoreMapper mapper;
- @InjectParameter
- private Offset offset;
+ @InjectParameter
+ private Offset offset;
- @InjectParameter
- private XtextResource resource;
+ @InjectParameter
+ private XtextResource resource;
- @Inject
- private ValidationTestHelper validationHelper;
+ @Inject
+ private ValidationTestHelper validationHelper;
- @Test
- public void noValidationIssues()
- {
- validationHelper.assertNoIssues(resource.getContents().get(0));
- }
+ @Test
+ public void noValidationIssues()
+ {
+ validationHelper.assertNoIssues(resource.getContents().get(0));
+ }
- @XpectString
- public String eNamedElement()
- {
- EcoreUtil.resolveAll(resource);
- ENamedElement gen = mapper.getEcore((XNamedElement) offset.getEObject());
- return new GenModelFormatter().resolveCrossReferences().format(gen);
- }
+ @XpectString
+ public String eNamedElement()
+ {
+ EcoreUtil.resolveAll(resource);
+ ENamedElement gen = mapper.getEcore((XNamedElement)offset.getEObject());
+ return new GenModelFormatter().resolveCrossReferences().format(gen);
+ }
}
diff --git a/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/genmodel/XcoreGenModelTest.java b/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/genmodel/XcoreGenModelTest.java
index 66708ef9e..50ffff9d6 100644
--- a/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/genmodel/XcoreGenModelTest.java
+++ b/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/genmodel/XcoreGenModelTest.java
@@ -7,6 +7,7 @@
*/
package org.eclipse.emf.test.ecore.xcore.genmodel;
+
import org.eclipse.emf.codegen.ecore.genmodel.GenBase;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.xcore.XNamedElement;
@@ -27,6 +28,7 @@ import org.junit.runner.RunWith;
import com.google.inject.Inject;
+
@SuppressWarnings("restriction")
@InjectWith(XcoreInjectorProvider.class)
@RunWith(ParameterizedXtextRunner.class)
@@ -34,31 +36,31 @@ import com.google.inject.Inject;
public class XcoreGenModelTest
{
- @Inject
- private XcoreMapper mapper;
+ @Inject
+ private XcoreMapper mapper;
- @InjectParameter
- private Offset offset;
+ @InjectParameter
+ private Offset offset;
- @InjectParameter
- private XtextResource resource;
+ @InjectParameter
+ private XtextResource resource;
- @Inject
- private ValidationTestHelper validationHelper;
+ @Inject
+ private ValidationTestHelper validationHelper;
- @Test
- public void noValidationIssues()
- {
- validationHelper.assertNoIssues(resource.getContents().get(0));
- }
+ @Test
+ public void noValidationIssues()
+ {
+ validationHelper.assertNoIssues(resource.getContents().get(0));
+ }
- @XpectString
- @ParameterSyntax("'at' offset=OFFSET")
- public String genBase()
- {
- EcoreUtil.resolveAll(resource);
- GenBase gen = mapper.getGen((XNamedElement) offset.getEObject());
- return new GenModelFormatter().resolveCrossReferences().format(gen);
- }
+ @XpectString
+ @ParameterSyntax("'at' offset=OFFSET")
+ public String genBase()
+ {
+ EcoreUtil.resolveAll(resource);
+ GenBase gen = mapper.getGen((XNamedElement)offset.getEObject());
+ return new GenModelFormatter().resolveCrossReferences().format(gen);
+ }
}
diff --git a/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/interpreter/XcoreInterpreterXbaseIntegrationTest.java b/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/interpreter/XcoreInterpreterXbaseIntegrationTest.java
index 8d8d18099..e3a2be088 100644
--- a/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/interpreter/XcoreInterpreterXbaseIntegrationTest.java
+++ b/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/interpreter/XcoreInterpreterXbaseIntegrationTest.java
@@ -7,6 +7,7 @@
*/
package org.eclipse.emf.test.ecore.xcore.interpreter;
+
import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
@@ -22,45 +23,50 @@ import org.junit.runner.RunWith;
import com.google.inject.Inject;
+
@RunWith(XtextRunner.class)
@InjectWith(XcoreInjectorProvider.class)
public class XcoreInterpreterXbaseIntegrationTest extends AbstractXbaseEvaluationTest
{
-
- @Inject
- private ParseHelper<XPackage> parser;
-
- @Inject
- private ValidationTestHelper validator;
- @Override
- protected Object invokeXbaseExpression(String expression) throws Exception {
- XPackage pack = parser.parse("package foo class Bar { op Object foo() { "+expression+" } }");
- validator.assertNoErrors(pack);
- EPackage ePack = (EPackage) pack.eResource().getContents().get(2);
- EClass barClass = (EClass) ePack.getEClassifier("Bar");
- EObject eObject = ePack.getEFactoryInstance().create(barClass);
- return eObject.eInvoke(barClass.getEOperations().get(0), new BasicEList<Object>());
- }
-
- @Override
- public void testShortCircuitBooleanExpression_03() throws Exception
- {
- // Ignore
- }
- @Override
- public void testShortCircuitBooleanExpression_04() throws Exception
- {
- // Ignore
- }
- @Override
- public void testFunctionConversion_00() throws Exception
- {
- // Ignore
- }
- @Override
- public void testMapConstruction_01() throws Exception
- {
- // Ignore
- }
+ @Inject
+ private ParseHelper<XPackage> parser;
+
+ @Inject
+ private ValidationTestHelper validator;
+
+ @Override
+ protected Object invokeXbaseExpression(String expression) throws Exception
+ {
+ XPackage pack = parser.parse("package foo class Bar { op Object foo() { " + expression + " } }");
+ validator.assertNoErrors(pack);
+ EPackage ePack = (EPackage)pack.eResource().getContents().get(2);
+ EClass barClass = (EClass)ePack.getEClassifier("Bar");
+ EObject eObject = ePack.getEFactoryInstance().create(barClass);
+ return eObject.eInvoke(barClass.getEOperations().get(0), new BasicEList<Object>());
+ }
+
+ @Override
+ public void testShortCircuitBooleanExpression_03() throws Exception
+ {
+ // Ignore
+ }
+
+ @Override
+ public void testShortCircuitBooleanExpression_04() throws Exception
+ {
+ // Ignore
+ }
+
+ @Override
+ public void testFunctionConversion_00() throws Exception
+ {
+ // Ignore
+ }
+
+ @Override
+ public void testMapConstruction_01() throws Exception
+ {
+ // Ignore
+ }
}
diff --git a/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/scoping/LazyCreationProxyUriConverterTest.java b/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/scoping/LazyCreationProxyUriConverterTest.java
index 0f31e221d..2975d68e4 100644
--- a/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/scoping/LazyCreationProxyUriConverterTest.java
+++ b/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/scoping/LazyCreationProxyUriConverterTest.java
@@ -7,6 +7,7 @@
*/
package org.eclipse.emf.test.ecore.xcore.scoping;
+
import org.eclipse.emf.codegen.ecore.genmodel.GenClass;
import org.eclipse.emf.codegen.ecore.genmodel.GenModelFactory;
import org.eclipse.emf.common.util.URI;
@@ -28,88 +29,93 @@ import com.google.inject.Inject;
import static junit.framework.Assert.*;
+
@RunWith(XtextRunner.class)
@InjectWith(XcoreInjectorProvider.class)
public class LazyCreationProxyUriConverterTest
{
- @Inject LazyCreationProxyURIConverter converter;
-
- @Test
- public void testUriConversion_1() throws Exception
- {
- LazyCreationProxyURIConverter converter = getProxyUriConverter();
-
- GenClass genClass = GenModelFactory.eINSTANCE.createGenClass();
- final QualifiedName name = QualifiedName.create("foo.bar", "Baz");
- converter.installProxyURI(URI.createFileURI("foo.test"), genClass, name);
-
- Pair<EClass, QualifiedName> proxyInfo = converter.decodeProxy(genClass);
- assertSame(genClass.eClass(), proxyInfo.getFirst());
- assertEquals(name.toString(), proxyInfo.getSecond().toString());
- }
-
- protected LazyCreationProxyURIConverter getProxyUriConverter() {
- return converter;
- }
-
- @Test
- public void testUriConversion_2() throws Exception
- {
- LazyCreationProxyURIConverter converter = getProxyUriConverter();
-
- EClass eClass = EcoreFactory.eINSTANCE.createEClass();
- final QualifiedName name = QualifiedName.create("foo.bar", "Baz");
- converter.installProxyURI(URI.createFileURI("foo.test"), eClass, name);
-
- Pair<EClass, QualifiedName> proxyInfo = converter.decodeProxy(eClass);
- assertSame(eClass.eClass(), proxyInfo.getFirst());
- assertEquals(name.toString(), proxyInfo.getSecond().toString());
- }
-
- @Test
- public void testUriConversion_3() throws Exception
- {
- LazyCreationProxyURIConverter converter = getProxyUriConverter();
-
- JvmGenericType genericType = TypesFactory.eINSTANCE.createJvmGenericType();
- final QualifiedName name = QualifiedName.create("foo.bar", "Baz");
- converter.installProxyURI(URI.createFileURI("foo.test"), genericType, name);
-
- Pair<EClass, QualifiedName> proxyInfo = converter.decodeProxy(genericType);
- assertSame(genericType.eClass(), proxyInfo.getFirst());
- assertEquals(name.toString(), proxyInfo.getSecond().toString());
- }
-
- @Test
- public void testUriConversion_4() throws Exception
- {
- LazyCreationProxyURIConverter converter = getProxyUriConverter();
-
- EOperation op = EcoreFactory.eINSTANCE.createEOperation();
- final QualifiedName name = QualifiedName.create("foo.bar", "Baz");
- try
- {
- converter.installProxyURI(URI.createFileURI("foo.test"), op, name);
- fail();
- } catch (IllegalArgumentException e)
- {
- // Ignore
- }
- }
-
- @Test
- public void testUriConversion_5() throws Exception
- {
- LazyCreationProxyURIConverter converter = getProxyUriConverter();
-
- JvmGenericType genericType = TypesFactory.eINSTANCE.createJvmGenericType();
- try
- {
- converter.decodeProxy(genericType);
- fail();
- } catch (IllegalArgumentException e)
- {
- // Ignore
- }
- }
+ @Inject
+ LazyCreationProxyURIConverter converter;
+
+ @Test
+ public void testUriConversion_1() throws Exception
+ {
+ LazyCreationProxyURIConverter converter = getProxyUriConverter();
+
+ GenClass genClass = GenModelFactory.eINSTANCE.createGenClass();
+ final QualifiedName name = QualifiedName.create("foo.bar", "Baz");
+ converter.installProxyURI(URI.createFileURI("foo.test"), genClass, name);
+
+ Pair<EClass, QualifiedName> proxyInfo = converter.decodeProxy(genClass);
+ assertSame(genClass.eClass(), proxyInfo.getFirst());
+ assertEquals(name.toString(), proxyInfo.getSecond().toString());
+ }
+
+ protected LazyCreationProxyURIConverter getProxyUriConverter()
+ {
+ return converter;
+ }
+
+ @Test
+ public void testUriConversion_2() throws Exception
+ {
+ LazyCreationProxyURIConverter converter = getProxyUriConverter();
+
+ EClass eClass = EcoreFactory.eINSTANCE.createEClass();
+ final QualifiedName name = QualifiedName.create("foo.bar", "Baz");
+ converter.installProxyURI(URI.createFileURI("foo.test"), eClass, name);
+
+ Pair<EClass, QualifiedName> proxyInfo = converter.decodeProxy(eClass);
+ assertSame(eClass.eClass(), proxyInfo.getFirst());
+ assertEquals(name.toString(), proxyInfo.getSecond().toString());
+ }
+
+ @Test
+ public void testUriConversion_3() throws Exception
+ {
+ LazyCreationProxyURIConverter converter = getProxyUriConverter();
+
+ JvmGenericType genericType = TypesFactory.eINSTANCE.createJvmGenericType();
+ final QualifiedName name = QualifiedName.create("foo.bar", "Baz");
+ converter.installProxyURI(URI.createFileURI("foo.test"), genericType, name);
+
+ Pair<EClass, QualifiedName> proxyInfo = converter.decodeProxy(genericType);
+ assertSame(genericType.eClass(), proxyInfo.getFirst());
+ assertEquals(name.toString(), proxyInfo.getSecond().toString());
+ }
+
+ @Test
+ public void testUriConversion_4() throws Exception
+ {
+ LazyCreationProxyURIConverter converter = getProxyUriConverter();
+
+ EOperation op = EcoreFactory.eINSTANCE.createEOperation();
+ final QualifiedName name = QualifiedName.create("foo.bar", "Baz");
+ try
+ {
+ converter.installProxyURI(URI.createFileURI("foo.test"), op, name);
+ fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ // Ignore
+ }
+ }
+
+ @Test
+ public void testUriConversion_5() throws Exception
+ {
+ LazyCreationProxyURIConverter converter = getProxyUriConverter();
+
+ JvmGenericType genericType = TypesFactory.eINSTANCE.createJvmGenericType();
+ try
+ {
+ converter.decodeProxy(genericType);
+ fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ // Ignore
+ }
+ }
}
diff --git a/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/scoping/LazyGenModelInferenceTest.java b/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/scoping/LazyGenModelInferenceTest.java
index 55b801eeb..8197a4d9b 100644
--- a/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/scoping/LazyGenModelInferenceTest.java
+++ b/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/scoping/LazyGenModelInferenceTest.java
@@ -7,6 +7,7 @@
*/
package org.eclipse.emf.test.ecore.xcore.scoping;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
@@ -41,106 +42,122 @@ import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Provider;
+
@RunWith(XtextRunner.class)
@InjectWith(LazyGenModelInferenceTest.MyXcoreInjectorProvider.class)
-public class LazyGenModelInferenceTest {
-
- @Inject
- private Provider<XtextResourceSet> resourceSetProvider;
-
- public static class MyXcoreInjectorProvider extends XcoreInjectorProvider {
-
- private Injector injector;
-
- @Override
- public Injector getInjector() {
- if (injector == null) {
- this.injector = new XcoreStandaloneSetup() {
- @Override
- public Injector createInjector() {
- return Guice.createInjector(new org.eclipse.emf.ecore.xcore.XcoreRuntimeModule() {
- @Override
- public Class<? extends XtextResource> bindXtextResource() {
- return InspectableXcoreResource.class;
- }
- });
- }
- }.createInjectorAndDoEMFRegistration();
- }
- return injector;
- }
-
- @Override
- public void setupRegistry() {
- super.setupRegistry();
- if (injector != null) {
- new XcoreStandaloneSetup().register(injector);
- }
- }
- }
-
- public static class InspectableXcoreResource extends XcoreResource {
-
- public EList<EObject> getContentsUnsafe() {
- return contents;
- }
-
- public boolean isFullyInitialized() {
- return fullyInitialized;
- }
-
- }
-
- @Test
- public void testSetup() {
- XtextResourceSet resourceSet = resourceSetProvider.get();
- Resource resource = resourceSet.createResource(URI.createURI("foo.xcore"));
- assertTrue(resource.toString(), resource instanceof InspectableXcoreResource);
- assertNull(((InspectableXcoreResource) resource).getContentsUnsafe());
- assertFalse(((InspectableXcoreResource) resource).isFullyInitialized());
- }
-
- @Test
- public void testContentsWithoutDerived() throws IOException {
- XtextResourceSet resourceSet = resourceSetProvider.get();
- Resource resource = resourceSet.createResource(URI.createURI("foo.xcore"));
- resource.load(new StringInputStream("package foo.bar class Baz {}"), null);
- assertEquals(1, ((InspectableXcoreResource) resource).getContentsUnsafe().size());
- assertFalse(((InspectableXcoreResource) resource).isFullyInitialized());
- }
-
- @Test
- public void testContentsWithDerived() throws IOException {
- XtextResourceSet resourceSet = resourceSetProvider.get();
- Resource resource = resourceSet.createResource(URI.createURI("foo.xcore"));
- resource.load(new StringInputStream("package foo.bar class Baz {}"), null);
- assertTrue(1 < resource.getContents().size());
- assertTrue(((InspectableXcoreResource) resource).isFullyInitialized());
- }
-
- public void testResourceDescriptionManagerDoesNotResolve() throws IOException {
- XtextResourceSet resourceSet = resourceSetProvider.get();
- InspectableXcoreResource resource = (InspectableXcoreResource) resourceSet.createResource(URI.createURI("foo.xcore"));
- resource.load(new StringInputStream("package foo.bar class Baz {}"), null);
- Manager manager = resource.getResourceServiceProvider().getResourceDescriptionManager();
- IResourceDescription resourceDescription = manager.getResourceDescription(resource);
-
- Iterator<IEObjectDescription> eclass = resourceDescription.getExportedObjectsByType(EcorePackage.Literals.ECLASS).iterator();
- Iterator<IEObjectDescription> genclass = resourceDescription.getExportedObjectsByType(GenModelPackage.Literals.GEN_CLASS)
- .iterator();
- Iterator<IEObjectDescription> jvmTypes = resourceDescription.getExportedObjectsByType(TypesPackage.Literals.JVM_GENERIC_TYPE)
- .iterator();
- final String expected = "foo.bar.Baz";
- assertEquals(expected, eclass.next().getName().toString());
- assertFalse(eclass.hasNext());
- assertEquals(expected, genclass.next().getName().toString());
- assertFalse(genclass.hasNext());
- assertEquals(expected, jvmTypes.next().getName().toString());
- assertEquals(expected + "Impl", jvmTypes.next().getName().toString());
- assertFalse(genclass.hasNext());
-
- assertEquals(1, resource.getContentsUnsafe().size());
- assertFalse(resource.isFullyInitialized());
- }
+public class LazyGenModelInferenceTest
+{
+
+ @Inject
+ private Provider<XtextResourceSet> resourceSetProvider;
+
+ public static class MyXcoreInjectorProvider extends XcoreInjectorProvider
+ {
+
+ private Injector injector;
+
+ @Override
+ public Injector getInjector()
+ {
+ if (injector == null)
+ {
+ this.injector = new XcoreStandaloneSetup()
+ {
+ @Override
+ public Injector createInjector()
+ {
+ return Guice.createInjector(new org.eclipse.emf.ecore.xcore.XcoreRuntimeModule()
+ {
+ @Override
+ public Class<? extends XtextResource> bindXtextResource()
+ {
+ return InspectableXcoreResource.class;
+ }
+ });
+ }
+ }.createInjectorAndDoEMFRegistration();
+ }
+ return injector;
+ }
+
+ @Override
+ public void setupRegistry()
+ {
+ super.setupRegistry();
+ if (injector != null)
+ {
+ new XcoreStandaloneSetup().register(injector);
+ }
+ }
+ }
+
+ public static class InspectableXcoreResource extends XcoreResource
+ {
+
+ public EList<EObject> getContentsUnsafe()
+ {
+ return contents;
+ }
+
+ public boolean isFullyInitialized()
+ {
+ return fullyInitialized;
+ }
+
+ }
+
+ @Test
+ public void testSetup()
+ {
+ XtextResourceSet resourceSet = resourceSetProvider.get();
+ Resource resource = resourceSet.createResource(URI.createURI("foo.xcore"));
+ assertTrue(resource.toString(), resource instanceof InspectableXcoreResource);
+ assertNull(((InspectableXcoreResource)resource).getContentsUnsafe());
+ assertFalse(((InspectableXcoreResource)resource).isFullyInitialized());
+ }
+
+ @Test
+ public void testContentsWithoutDerived() throws IOException
+ {
+ XtextResourceSet resourceSet = resourceSetProvider.get();
+ Resource resource = resourceSet.createResource(URI.createURI("foo.xcore"));
+ resource.load(new StringInputStream("package foo.bar class Baz {}"), null);
+ assertEquals(1, ((InspectableXcoreResource)resource).getContentsUnsafe().size());
+ assertFalse(((InspectableXcoreResource)resource).isFullyInitialized());
+ }
+
+ @Test
+ public void testContentsWithDerived() throws IOException
+ {
+ XtextResourceSet resourceSet = resourceSetProvider.get();
+ Resource resource = resourceSet.createResource(URI.createURI("foo.xcore"));
+ resource.load(new StringInputStream("package foo.bar class Baz {}"), null);
+ assertTrue(1 < resource.getContents().size());
+ assertTrue(((InspectableXcoreResource)resource).isFullyInitialized());
+ }
+
+ public void testResourceDescriptionManagerDoesNotResolve() throws IOException
+ {
+ XtextResourceSet resourceSet = resourceSetProvider.get();
+ InspectableXcoreResource resource = (InspectableXcoreResource)resourceSet.createResource(URI.createURI("foo.xcore"));
+ resource.load(new StringInputStream("package foo.bar class Baz {}"), null);
+ Manager manager = resource.getResourceServiceProvider().getResourceDescriptionManager();
+ IResourceDescription resourceDescription = manager.getResourceDescription(resource);
+
+ Iterator<IEObjectDescription> eclass = resourceDescription.getExportedObjectsByType(EcorePackage.Literals.ECLASS).iterator();
+ Iterator<IEObjectDescription> genclass = resourceDescription.getExportedObjectsByType(GenModelPackage.Literals.GEN_CLASS).iterator();
+ Iterator<IEObjectDescription> jvmTypes = resourceDescription.getExportedObjectsByType(TypesPackage.Literals.JVM_GENERIC_TYPE).iterator();
+ final String expected = "foo.bar.Baz";
+ assertEquals(expected, eclass.next().getName().toString());
+ assertFalse(eclass.hasNext());
+ assertEquals(expected, genclass.next().getName().toString());
+ assertFalse(genclass.hasNext());
+ assertEquals(expected, jvmTypes.next().getName().toString());
+ assertEquals(expected + "Impl", jvmTypes.next().getName().toString());
+ assertFalse(genclass.hasNext());
+
+ assertEquals(1, resource.getContentsUnsafe().size());
+ assertFalse(resource.isFullyInitialized());
+ }
}
diff --git a/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/scoping/ResourceDescriptionManagerTest.java b/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/scoping/ResourceDescriptionManagerTest.java
index 24157db9b..027cc5e9e 100644
--- a/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/scoping/ResourceDescriptionManagerTest.java
+++ b/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/scoping/ResourceDescriptionManagerTest.java
@@ -7,6 +7,7 @@
*/
package org.eclipse.emf.test.ecore.xcore.scoping;
+
import java.util.Iterator;
import org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage;
@@ -26,37 +27,35 @@ import com.google.inject.Inject;
import static org.junit.Assert.*;
+
@RunWith(XtextRunner.class)
@InjectWith(XcoreInjectorProvider.class)
public class ResourceDescriptionManagerTest
{
- @Inject
- private ParseHelper<XPackage> parser;
-
- @Inject
- private IResourceDescription.Manager descriptionManager;
-
- @Test
- public void testCreateResourceDescription() throws Exception
- {
- XPackage xcorePackage = parser.parse("package foo.bar class Baz {}");
- IResourceDescription resourceDescription = descriptionManager.getResourceDescription(xcorePackage.eResource());
-
- Iterator<IEObjectDescription> eclass = resourceDescription.getExportedObjectsByType(EcorePackage.Literals.ECLASS)
- .iterator();
- Iterator<IEObjectDescription> genclass = resourceDescription.getExportedObjectsByType(
- GenModelPackage.Literals.GEN_CLASS).iterator();
- Iterator<IEObjectDescription> jvmTypes = resourceDescription.getExportedObjectsByType(
- TypesPackage.Literals.JVM_GENERIC_TYPE).iterator();
- final String expected = "foo.bar.Baz";
- assertEquals(expected, eclass.next().getName().toString());
- assertFalse(eclass.hasNext());
- assertEquals(expected, genclass.next().getName().toString());
- assertFalse(genclass.hasNext());
- assertEquals(expected, jvmTypes.next().getName().toString());
- assertEquals(expected + "Impl", jvmTypes.next().getName().toString());
- assertFalse(genclass.hasNext());
- }
-
+ @Inject
+ private ParseHelper<XPackage> parser;
+
+ @Inject
+ private IResourceDescription.Manager descriptionManager;
+
+ @Test
+ public void testCreateResourceDescription() throws Exception
+ {
+ XPackage xcorePackage = parser.parse("package foo.bar class Baz {}");
+ IResourceDescription resourceDescription = descriptionManager.getResourceDescription(xcorePackage.eResource());
+
+ Iterator<IEObjectDescription> eclass = resourceDescription.getExportedObjectsByType(EcorePackage.Literals.ECLASS).iterator();
+ Iterator<IEObjectDescription> genclass = resourceDescription.getExportedObjectsByType(GenModelPackage.Literals.GEN_CLASS).iterator();
+ Iterator<IEObjectDescription> jvmTypes = resourceDescription.getExportedObjectsByType(TypesPackage.Literals.JVM_GENERIC_TYPE).iterator();
+ final String expected = "foo.bar.Baz";
+ assertEquals(expected, eclass.next().getName().toString());
+ assertFalse(eclass.hasNext());
+ assertEquals(expected, genclass.next().getName().toString());
+ assertFalse(genclass.hasNext());
+ assertEquals(expected, jvmTypes.next().getName().toString());
+ assertEquals(expected + "Impl", jvmTypes.next().getName().toString());
+ assertFalse(genclass.hasNext());
+ }
+
}
diff --git a/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/scoping/XcoreScopingTest.java b/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/scoping/XcoreScopingTest.java
index 91ad93f48..739f03f72 100644
--- a/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/scoping/XcoreScopingTest.java
+++ b/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/scoping/XcoreScopingTest.java
@@ -7,6 +7,7 @@
*/
package org.eclipse.emf.test.ecore.xcore.scoping;
+
import java.util.List;
import org.eclipse.emf.ecore.EObject;
@@ -33,6 +34,7 @@ import org.junit.runner.RunWith;
import com.google.common.collect.Lists;
import com.google.inject.Inject;
+
@SuppressWarnings("restriction")
@InjectWith(XcoreInjectorProvider.class)
@RunWith(ParameterizedXtextRunner.class)
@@ -40,36 +42,36 @@ import com.google.inject.Inject;
public class XcoreScopingTest
{
- @InjectParameter
- private XtextResource resource;
+ @InjectParameter
+ private XtextResource resource;
- @InjectParameter
- private Offset offset;
+ @InjectParameter
+ private Offset offset;
- @Inject
- private ValidationTestHelper validationHelper;
+ @Inject
+ private ValidationTestHelper validationHelper;
- @Inject
- private IScopeProvider scopeProvider;
+ @Inject
+ private IScopeProvider scopeProvider;
- @Test
- public void noValidationIssues()
- {
- validationHelper.assertNoIssues(resource.getContents().get(0));
- }
+ @Test
+ public void noValidationIssues()
+ {
+ validationHelper.assertNoIssues(resource.getContents().get(0));
+ }
- @XpectCommaSeparatedValues()
- @ParameterSyntax("'at' offset=OFFSET")
- public List<String> scopeAllElements()
- {
- Pair<EObject, EStructuralFeature> objAndFeature = offset.getEStructuralFeatureByParent();
- Assert.assertTrue(objAndFeature.getSecond() instanceof EReference);
- Assert.assertFalse(((EReference) objAndFeature.getSecond()).isContainment());
- IScope scope = scopeProvider.getScope(objAndFeature.getFirst(), (EReference) objAndFeature.getSecond());
- List<String> result = Lists.newArrayList();
- for (IEObjectDescription desc : scope.getAllElements())
- result.add(desc.getName().toString());
- return result;
- }
+ @XpectCommaSeparatedValues()
+ @ParameterSyntax("'at' offset=OFFSET")
+ public List<String> scopeAllElements()
+ {
+ Pair<EObject, EStructuralFeature> objAndFeature = offset.getEStructuralFeatureByParent();
+ Assert.assertTrue(objAndFeature.getSecond() instanceof EReference);
+ Assert.assertFalse(((EReference)objAndFeature.getSecond()).isContainment());
+ IScope scope = scopeProvider.getScope(objAndFeature.getFirst(), (EReference)objAndFeature.getSecond());
+ List<String> result = Lists.newArrayList();
+ for (IEObjectDescription desc : scope.getAllElements())
+ result.add(desc.getName().toString());
+ return result;
+ }
}
diff --git a/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/validation/XcoreValidationTest.java b/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/validation/XcoreValidationTest.java
index 0d11842fd..ab5fa7a7a 100644
--- a/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/validation/XcoreValidationTest.java
+++ b/tests/org.eclipse.emf.test.ecore.xcore/src/org/eclipse/emf/test/ecore/xcore/validation/XcoreValidationTest.java
@@ -7,6 +7,7 @@
*/
package org.eclipse.emf.test.ecore.xcore.validation;
+
import java.util.List;
import org.eclipse.emf.ecore.util.EcoreValidator;
@@ -26,6 +27,7 @@ import org.junit.runner.RunWith;
import com.google.common.collect.Lists;
import com.google.inject.Inject;
+
/**
* There are cases not covered because the grammar doesn't allow it, i.e.,
* {@link EcoreValidator#CONSISTENT_BOUNDS_NOT_ALLOWED},
@@ -59,36 +61,36 @@ import com.google.inject.Inject;
public class XcoreValidationTest
{
- @InjectParameter
- private XtextResource resource;
+ @InjectParameter
+ private XtextResource resource;
- @Inject
- private IResourceValidator validator;
+ @Inject
+ private IResourceValidator validator;
- protected String formatIssue(Issue issue)
- {
- StringBuilder result = new StringBuilder();
- result.append(issue.getSeverity().name().toLowerCase());
- if (issue.getOffset() != null && issue.getLength() != null)
- {
- result.append(" at '");
- result.append(resource.getParseResult().getRootNode().getText()
- .substring(issue.getOffset(), issue.getOffset() + issue.getLength()));
- result.append("' ");
- } else
- result.append(" ");
- result.append("message '");
- result.append(issue.getMessage());
- result.append("'");
- return result.toString();
- }
+ protected String formatIssue(Issue issue)
+ {
+ StringBuilder result = new StringBuilder();
+ result.append(issue.getSeverity().name().toLowerCase());
+ if (issue.getOffset() != null && issue.getLength() != null)
+ {
+ result.append(" at '");
+ result.append(resource.getParseResult().getRootNode().getText().substring(issue.getOffset(), issue.getOffset() + issue.getLength()));
+ result.append("' ");
+ }
+ else
+ result.append(" ");
+ result.append("message '");
+ result.append(issue.getMessage());
+ result.append("'");
+ return result.toString();
+ }
- @XpectLines()
- public List<String> validationIssues()
- {
- List<String> result = Lists.newArrayList();
- for (Issue issue : validator.validate(resource, CheckMode.ALL, CancelIndicator.NullImpl))
- result.add(formatIssue(issue));
- return result;
- }
+ @XpectLines()
+ public List<String> validationIssues()
+ {
+ List<String> result = Lists.newArrayList();
+ for (Issue issue : validator.validate(resource, CheckMode.ALL, CancelIndicator.NullImpl))
+ result.add(formatIssue(issue));
+ return result;
+ }
}

Back to the top