use of org.eclipse.xtend.core.xtend.XtendMember in project xtext-xtend by eclipse.
the class XtendUIValidationTests method testJavaDocRefs_Delegation.
@Test
public void testJavaDocRefs_Delegation() throws Exception {
final IJavaProject javaProject = JavaModelManager.getJavaModelManager().getJavaModel().getJavaProject(this.testHelper.getProject());
final String javaSeverity = javaProject.getOption(JavaCore.COMPILER_PB_INVALID_JAVADOC, true);
try {
boolean _notEquals = (!Objects.equal(javaSeverity, "ignore"));
if (_notEquals) {
Assert.fail((("Wrong expectation Java compiler option \'" + JavaCore.COMPILER_PB_INVALID_JAVADOC) + "\' should be \'ignore\' by default"));
}
String otherSeverity = "warning";
StringConcatenation _builder = new StringConcatenation();
_builder.append("class ValidationClazz {");
_builder.newLine();
_builder.append("\t");
_builder.append("/**");
_builder.newLine();
_builder.append("\t");
_builder.append("* {@link List}");
_builder.newLine();
_builder.append("\t");
_builder.append("*/");
_builder.newLine();
_builder.append("\t");
_builder.append("def doStuff(){}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile xtendFile = this.testHelper.xtendFile("ValidationClazz.xtend", _builder.toString());
XtendTypeDeclaration _head = IterableExtensions.<XtendTypeDeclaration>head(xtendFile.getXtendTypes());
final XtendClass clazz = ((XtendClass) _head);
final XtendMember member = IterableExtensions.<XtendMember>head(clazz.getMembers());
this.helper.assertNoIssues(member);
this.cache.clear(xtendFile.eResource());
javaProject.setOption(JavaCore.COMPILER_PB_INVALID_JAVADOC, otherSeverity);
this.helper.assertWarning(member, XtendPackage.Literals.XTEND_FUNCTION, IssueCodes.JAVA_DOC_LINKING_DIAGNOSTIC, "javaDoc", "List", "cannot be resolved to a type");
} finally {
javaProject.setOption(JavaCore.COMPILER_PB_INVALID_JAVADOC, javaSeverity);
}
}
use of org.eclipse.xtend.core.xtend.XtendMember in project xtext-xtend by eclipse.
the class XtendUIValidationTests method testConfigurableIssueCode.
@Test
public void testConfigurableIssueCode() {
try {
final IPersistentPreferenceStore xtendPrefStore = this.getXtendPreferencesStore();
try {
xtendPrefStore.setValue(IssueCodes.UNUSED_PRIVATE_MEMBER, "warning");
StringConcatenation _builder = new StringConcatenation();
_builder.append("class TestConfigurableIssueCode {");
_builder.newLine();
_builder.append("\t");
_builder.append("private String unusedField = \"unusedField\"");
_builder.newLine();
_builder.append("}");
_builder.newLine();
XtendFile _xtendFile = this.testHelper.xtendFile("TestConfigurableIssueCode.xtend", _builder.toString());
final Procedure1<XtendFile> _function = (XtendFile it) -> {
final XtendMember unusedField = IterableExtensions.<XtendMember>head(IterableExtensions.<XtendClass>head(Iterables.<XtendClass>filter(it.getXtendTypes(), XtendClass.class)).getMembers());
this.helper.assertWarning(unusedField, XtendPackage.Literals.XTEND_FIELD, IssueCodes.UNUSED_PRIVATE_MEMBER);
};
ObjectExtensions.<XtendFile>operator_doubleArrow(_xtendFile, _function);
xtendPrefStore.setValue(IssueCodes.UNUSED_PRIVATE_MEMBER, "error");
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("class TestConfigurableIssueCode {");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("private String unusedField = \"unusedField\"");
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
XtendFile _xtendFile_1 = this.testHelper.xtendFile("TestConfigurableIssueCode.xtend", _builder_1.toString());
final Procedure1<XtendFile> _function_1 = (XtendFile it) -> {
final XtendMember unusedField = IterableExtensions.<XtendMember>head(IterableExtensions.<XtendClass>head(Iterables.<XtendClass>filter(it.getXtendTypes(), XtendClass.class)).getMembers());
this.helper.assertError(unusedField, XtendPackage.Literals.XTEND_FIELD, IssueCodes.UNUSED_PRIVATE_MEMBER);
};
ObjectExtensions.<XtendFile>operator_doubleArrow(_xtendFile_1, _function_1);
} finally {
xtendPrefStore.setToDefault(IssueCodes.UNUSED_PRIVATE_MEMBER);
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendMember in project xtext-xtend by eclipse.
the class XtendUIValidationTests method testForbiddenArrayTypeUsage.
@Test
public void testForbiddenArrayTypeUsage() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class Foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("def bar(org.eclipse.xtend.core.tests.restricted.RestrictedClass[] x) {}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile xtendFile = this.testHelper.xtendFile("Clazz.xtend", _builder.toString());
XtendMember _head = IterableExtensions.<XtendMember>head(IterableExtensions.<XtendClass>head(Iterables.<XtendClass>filter(xtendFile.getXtendTypes(), XtendClass.class)).getMembers());
final XtendFunction function = ((XtendFunction) _head);
this.helper.assertError(function.getParameters().get(0), TypesPackage.Literals.JVM_TYPE_REFERENCE, org.eclipse.xtext.xbase.validation.IssueCodes.FORBIDDEN_REFERENCE);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendMember 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.XtendMember 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);
}
}
Aggregations