use of org.eclipse.xtend.core.xtend.XtendField in project xtext-xtend by eclipse.
the class XtendUIValidationTests method testDiscouragedConstructorCallInnernClass.
@Test
public void testDiscouragedConstructorCallInnernClass() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("import org.eclipse.xtend.core.tests.internal.InternalClass$InnerInternalClass");
_builder.newLine();
_builder.append("class Foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("InnerInternalClass x = new InnerInternalClass");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile xtendFile = this.testHelper.xtendFile("Clazz.xtend", _builder.toString());
this.helper.assertWarning(xtendFile.getImportSection().getImportDeclarations().get(0), XtypePackage.Literals.XIMPORT_DECLARATION, org.eclipse.xtext.xbase.validation.IssueCodes.DISCOURAGED_REFERENCE);
XtendMember _head = IterableExtensions.<XtendMember>head(IterableExtensions.<XtendClass>head(Iterables.<XtendClass>filter(xtendFile.getXtendTypes(), XtendClass.class)).getMembers());
final XtendField field = ((XtendField) _head);
this.helper.assertWarning(field.getType(), TypesPackage.Literals.JVM_TYPE_REFERENCE, org.eclipse.xtext.xbase.validation.IssueCodes.DISCOURAGED_REFERENCE);
this.helper.assertWarning(field.getInitialValue(), XbasePackage.Literals.XCONSTRUCTOR_CALL, org.eclipse.xtext.xbase.validation.IssueCodes.DISCOURAGED_REFERENCE);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendField in project xtext-xtend by eclipse.
the class XtendUIValidationTests method testForbiddenConstructorCall.
@Test
public void testForbiddenConstructorCall() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("import org.eclipse.xtend.core.tests.restricted.RestrictedClass");
_builder.newLine();
_builder.append("class Foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("RestrictedClass x = new RestrictedClass");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile xtendFile = this.testHelper.xtendFile("Clazz.xtend", _builder.toString());
this.helper.assertError(xtendFile.getImportSection().getImportDeclarations().get(0), XtypePackage.Literals.XIMPORT_DECLARATION, org.eclipse.xtext.xbase.validation.IssueCodes.FORBIDDEN_REFERENCE);
XtendMember _head = IterableExtensions.<XtendMember>head(IterableExtensions.<XtendClass>head(Iterables.<XtendClass>filter(xtendFile.getXtendTypes(), XtendClass.class)).getMembers());
final XtendField field = ((XtendField) _head);
this.helper.assertError(field.getType(), TypesPackage.Literals.JVM_TYPE_REFERENCE, org.eclipse.xtext.xbase.validation.IssueCodes.FORBIDDEN_REFERENCE);
this.helper.assertError(field.getInitialValue(), XbasePackage.Literals.XCONSTRUCTOR_CALL, org.eclipse.xtext.xbase.validation.IssueCodes.FORBIDDEN_REFERENCE);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendField in project xtext-xtend by eclipse.
the class XtendHoverSignatureProviderTest method testSignatureForXtendFieldWithoutNameOrType.
@Test
public void testSignatureForXtendFieldWithoutNameOrType() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package testPackage");
_builder.newLine();
_builder.append("import java.util.Collections");
_builder.newLine();
_builder.append("import com.google.inject.Inject");
_builder.newLine();
_builder.newLine();
_builder.append("class Foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("val = \"\"");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile xtendFile = this.parseHelper.parse(_builder, this.getResourceSet());
final XtendClass clazz = IterableExtensions.<XtendClass>head(Iterables.<XtendClass>filter(xtendFile.getXtendTypes(), XtendClass.class));
XtendMember _get = clazz.getMembers().get(0);
final XtendField xtendField = ((XtendField) _get);
final String signature = this.signatureProvider.getSignature(xtendField);
Assert.assertEquals("", signature);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendField in project xtext-xtend by eclipse.
the class XtendHoverSignatureProviderTest method testSignatureForExtensionFieldWithoutName.
@Test
public void testSignatureForExtensionFieldWithoutName() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package testPackage");
_builder.newLine();
_builder.append("import java.util.Collections");
_builder.newLine();
_builder.append("import com.google.inject.Inject");
_builder.newLine();
_builder.newLine();
_builder.append("class Foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("extension String");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile xtendFile = this.parseHelper.parse(_builder, this.getResourceSet());
final XtendClass clazz = IterableExtensions.<XtendClass>head(Iterables.<XtendClass>filter(xtendFile.getXtendTypes(), XtendClass.class));
XtendMember _get = clazz.getMembers().get(0);
final XtendField xtendField = ((XtendField) _get);
final String signature = this.signatureProvider.getSignature(xtendField);
Assert.assertEquals("String", signature);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendField in project xtext-xtend by eclipse.
the class XtendHoverSignatureProviderTest method testSignatureForXtendField.
@Test
public void testSignatureForXtendField() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package testPackage");
_builder.newLine();
_builder.append("import java.util.Collections");
_builder.newLine();
_builder.append("import com.google.inject.Inject");
_builder.newLine();
_builder.newLine();
_builder.append("class Foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("@Inject");
_builder.newLine();
_builder.append("\t");
_builder.append("Collections collections");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("def bar(String a) throws NullPointerException");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile xtendFile = this.parseHelper.parse(_builder, this.getResourceSet());
final XtendClass clazz = IterableExtensions.<XtendClass>head(Iterables.<XtendClass>filter(xtendFile.getXtendTypes(), XtendClass.class));
XtendMember _get = clazz.getMembers().get(0);
final XtendField xtendField = ((XtendField) _get);
final String signature = this.signatureProvider.getSignature(xtendField);
Assert.assertEquals("Collections collections", signature);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
Aggregations