use of org.eclipse.xtend.core.xtend.XtendTypeDeclaration in project xtext-xtend by eclipse.
the class AccessRestrictionInWorkspaceTest method testDiscouragedReferenceInSameProject.
@Test
public void testDiscouragedReferenceInSameProject() {
try {
final XtendFile xtendFile = this.parse(IResourcesSetupUtil.createFile("firstProject/src/Dummy.xtend", "class D { discouraged.B b }"));
XtendTypeDeclaration _head = IterableExtensions.<XtendTypeDeclaration>head(xtendFile.getXtendTypes());
final XtendClass c = ((XtendClass) _head);
this._validationTestHelper.assertNoError(c, IssueCodes.DISCOURAGED_REFERENCE);
this._validationTestHelper.assertNoError(c, IssueCodes.FORBIDDEN_REFERENCE);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendTypeDeclaration in project xtext-xtend by eclipse.
the class AccessRestrictionInWorkspaceTest method testForbiddenReferenceInReexportedProject.
@Test
public void testForbiddenReferenceInReexportedProject() {
try {
final XtendFile xtendFile = this.parse(IResourcesSetupUtil.createFile("thirdProject/src/Dummy.xtend", "class D { restricted.A a }"));
XtendTypeDeclaration _head = IterableExtensions.<XtendTypeDeclaration>head(xtendFile.getXtendTypes());
final XtendClass c = ((XtendClass) _head);
this._validationTestHelper.assertError(c, TypesPackage.Literals.JVM_TYPE_REFERENCE, IssueCodes.FORBIDDEN_REFERENCE, "Access restriction: The type A is not accessible", "on required project firstProject");
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendTypeDeclaration in project xtext-xtend by eclipse.
the class DependentElementsCalculatorTests method testPolymorphicDispatch.
@Test
public void testPolymorphicDispatch() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class Foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("def dispatch foo(Number it) {");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("def dispatch foo(String it) {");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile fooFile = this.testHelper.xtendFile("Foo", _builder.toString());
IResourcesSetupUtil.waitForBuild();
XtendTypeDeclaration _get = fooFile.getXtendTypes().get(0);
final XtendClass fooClass = ((XtendClass) _get);
final XtendMember fooMethod1 = fooClass.getMembers().get(1);
NullProgressMonitor _nullProgressMonitor = new NullProgressMonitor();
final Iterable<URI> dependentElementURIs = this.dependentElementsCalculator.getDependentElementURIs(fooMethod1, _nullProgressMonitor);
Assert.assertEquals(5, IterableExtensions.size(dependentElementURIs));
EList<XtendMember> _members = fooClass.getMembers();
EList<JvmMember> _members_1 = this.associations.getInferredType(fooClass).getMembers();
final Function1<EObject, Boolean> _function = (EObject it) -> {
return Boolean.valueOf((!(it instanceof JvmConstructor)));
};
final Consumer<EObject> _function_1 = (EObject it) -> {
final Function1<URI, Boolean> _function_2 = (URI element) -> {
URI _uRI = EcoreUtil.getURI(it);
return Boolean.valueOf(Objects.equal(element, _uRI));
};
Assert.assertTrue(it.toString(), IterableExtensions.<URI>exists(dependentElementURIs, _function_2));
};
IterableExtensions.<EObject>toList(IterableExtensions.<EObject>filter(Iterables.<EObject>concat(_members, _members_1), _function)).forEach(_function_1);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendTypeDeclaration in project xtext-xtend by eclipse.
the class AccessRestrictionInWorkspaceTest method testForbiddenReferenceInImplicitLambdaParameter.
@Test
public void testForbiddenReferenceInImplicitLambdaParameter() {
try {
final XtendFile xtendFile = this.parse(IResourcesSetupUtil.createFile("secondProject/src/Dummy.xtend", "class D { new () { new discouraged.B().accept[] } }"));
XtendTypeDeclaration _head = IterableExtensions.<XtendTypeDeclaration>head(xtendFile.getXtendTypes());
final XtendClass c = ((XtendClass) _head);
this._validationTestHelper.assertError(c, TypesPackage.Literals.JVM_TYPE_REFERENCE, IssueCodes.FORBIDDEN_REFERENCE, "Access restriction: The type A is not accessible", "on required project firstProject");
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendTypeDeclaration in project xtext-xtend by eclipse.
the class AccessRestrictionInWorkspaceTest method testForbiddenReferenceInOtherProject.
@Test
public void testForbiddenReferenceInOtherProject() {
try {
final XtendFile xtendFile = this.parse(IResourcesSetupUtil.createFile("secondProject/src/Dummy.xtend", "class D { restricted.A a }"));
XtendTypeDeclaration _head = IterableExtensions.<XtendTypeDeclaration>head(xtendFile.getXtendTypes());
final XtendClass c = ((XtendClass) _head);
this._validationTestHelper.assertError(c, TypesPackage.Literals.JVM_TYPE_REFERENCE, IssueCodes.FORBIDDEN_REFERENCE, "Access restriction: The type A is not accessible", "on required project firstProject");
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
Aggregations