use of org.eclipse.xtend.core.xtend.XtendTypeDeclaration in project xtext-xtend by eclipse.
the class AccessRestrictionInWorkspaceTest method testReexported.
@Test
public void testReexported() {
try {
final XtendFile xtendFile = this.parse(IResourcesSetupUtil.createFile("thirdProject/src/Dummy.xtend", "class D { allowed.C c }"));
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 testDiscouragedReferenceInOtherProject.
@Test
public void testDiscouragedReferenceInOtherProject() {
try {
final XtendFile xtendFile = this.parse(IResourcesSetupUtil.createFile("secondProject/src/Dummy.xtend", "class D { discouraged.B b }"));
XtendTypeDeclaration _head = IterableExtensions.<XtendTypeDeclaration>head(xtendFile.getXtendTypes());
final XtendClass c = ((XtendClass) _head);
this._validationTestHelper.assertWarning(c, TypesPackage.Literals.JVM_TYPE_REFERENCE, IssueCodes.DISCOURAGED_REFERENCE, "Discouraged access: The type B 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 XtendValidator method checkModifiers.
@Check
protected void checkModifiers(XtendConstructor constructor) {
if (!(constructor.getDeclaringType() instanceof XtendClass)) {
error("Contructors are only permitted within classes", null, CONSTRUCTOR_NOT_PERMITTED);
} else {
String typeName = ((XtendTypeDeclaration) constructor.eContainer()).getName();
constructorModifierValidator.checkModifiers(constructor, "type " + typeName);
}
}
use of org.eclipse.xtend.core.xtend.XtendTypeDeclaration in project xtext-xtend by eclipse.
the class XtendValidator method getOutermostType.
/**
* Replies the outer-most type of the given member.
* @return the container of {@code XtendTypeDeclaration} type if it exists, or the direct container.
*/
protected final EObject getOutermostType(XtendMember member) {
XtendTypeDeclaration result = EcoreUtil2.getContainerOfType(member, XtendTypeDeclaration.class);
if (result == null) {
return member.eContainer();
}
while (!(result.eContainer() instanceof XtendFile)) {
XtendTypeDeclaration next = EcoreUtil2.getContainerOfType(result.eContainer(), XtendTypeDeclaration.class);
if (next == null) {
return result;
}
result = next;
}
return result;
}
use of org.eclipse.xtend.core.xtend.XtendTypeDeclaration in project xtext-xtend by eclipse.
the class XtendFormatter method _format.
protected void _format(final XtendFile xtendFile, @Extension final IFormattableDocument format) {
final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
format.<XtendFile>prepend(xtendFile, _function);
final ISemanticRegion pkg = this.textRegionExtensions.regionFor(xtendFile).feature(XtendPackage.Literals.XTEND_FILE__PACKAGE);
if ((pkg != null)) {
final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
format.prepend(pkg, _function_1);
final ISemanticRegion pkgSemicolon = pkg.immediatelyFollowing().keyword(";");
if ((pkgSemicolon != null)) {
final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
format.append(pkg, _function_2);
format.append(pkgSemicolon, XtendFormatterPreferenceKeys.blankLinesAfterPackageDecl);
} else {
format.append(pkg, XtendFormatterPreferenceKeys.blankLinesAfterPackageDecl);
}
}
XImportSection _importSection = xtendFile.getImportSection();
if (_importSection != null) {
format.<XImportSection>format(_importSection);
}
EList<XtendTypeDeclaration> _xtendTypes = xtendFile.getXtendTypes();
for (final XtendTypeDeclaration clazz : _xtendTypes) {
{
format.<XtendTypeDeclaration>format(clazz);
XtendTypeDeclaration _last = IterableExtensions.<XtendTypeDeclaration>last(xtendFile.getXtendTypes());
boolean _notEquals = (!Objects.equal(clazz, _last));
if (_notEquals) {
format.<XtendTypeDeclaration>append(clazz, XtendFormatterPreferenceKeys.blankLinesBetweenClasses);
}
}
}
final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
it.newLine();
};
format.<XtendFile>append(xtendFile, _function_3);
}
Aggregations