use of org.eclipse.xtend.core.xtend.XtendTypeDeclaration in project xtext-xtend by eclipse.
the class OverrideHelperTest method checkFindOverriddenOperation_01.
@Test
public void checkFindOverriddenOperation_01() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package foo");
_builder.newLine();
_builder.newLine();
_builder.append("import java.util.List");
_builder.newLine();
_builder.append("import java.util.Map");
_builder.newLine();
_builder.append("import java.util.Set");
_builder.newLine();
_builder.newLine();
_builder.append("class Foo extends Bar {");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("override bar(List<Object> list, ");
_builder.newLine();
_builder.append("\t\t");
_builder.append("Map<Object, Object> map,");
_builder.newLine();
_builder.append("\t\t");
_builder.append("var List<Object> blabla = null");
_builder.newLine();
_builder.append("\t\t");
_builder.append("Set<Object> set");
_builder.newLine();
_builder.append("\t");
_builder.append(") {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("super.bar(list, map, set)");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("class Bar {");
_builder.newLine();
_builder.append("\t");
_builder.append("def void bar(List<Object> list, ");
_builder.newLine();
_builder.append("\t\t");
_builder.append("Map<Object, Object> map, ");
_builder.newLine();
_builder.append("\t\t");
_builder.append("Set<Object> set");
_builder.newLine();
_builder.append("\t");
_builder.append(") {");
_builder.newLine();
_builder.append("\t\t");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile xtendFile = this.fileWithErrors(_builder.toString());
EObject _primaryJvmElement = this._iJvmModelAssociations.getPrimaryJvmElement(IterableExtensions.<XtendFunction>head(Iterables.<XtendFunction>filter(IterableExtensions.<XtendTypeDeclaration>head(xtendFile.getXtendTypes()).getMembers(), XtendFunction.class)));
final JvmOperation operation = ((JvmOperation) _primaryJvmElement);
Assert.assertNull(this.overrideHelper.findOverriddenOperation(operation));
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendTypeDeclaration in project xtext-xtend by eclipse.
the class OverrideHelperTest method checkFindOverriddenOperation_04.
@Test
public void checkFindOverriddenOperation_04() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package foo");
_builder.newLine();
_builder.newLine();
_builder.append("class Foo implements Bar {");
_builder.newLine();
_builder.newLine();
_builder.append("\t");
_builder.append("override bar(T<?> map) {");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("interface Bar {");
_builder.newLine();
_builder.append("\t");
_builder.append("def void bar(T<?> map)");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("class T<E extends CharSequence> {}");
_builder.newLine();
final XtendFile xtendFile = this.file(_builder.toString());
EObject _primaryJvmElement = this._iJvmModelAssociations.getPrimaryJvmElement(IterableExtensions.<XtendFunction>head(Iterables.<XtendFunction>filter(IterableExtensions.<XtendTypeDeclaration>head(xtendFile.getXtendTypes()).getMembers(), XtendFunction.class)));
final JvmOperation operation = ((JvmOperation) _primaryJvmElement);
Assert.assertNotNull(this.overrideHelper.findOverriddenOperation(operation));
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendTypeDeclaration in project xtext-xtend by eclipse.
the class OverrideHelperTest method checkFindOverriddenOperation_05.
@Test
public void checkFindOverriddenOperation_05() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package foo");
_builder.newLine();
_builder.append("class Foo implements int {");
_builder.newLine();
_builder.append("\t");
_builder.append("override bar(Map<?, ?> map) {}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile xtendFile = this.file(_builder.toString());
EObject _primaryJvmElement = this._iJvmModelAssociations.getPrimaryJvmElement(IterableExtensions.<XtendFunction>head(Iterables.<XtendFunction>filter(IterableExtensions.<XtendTypeDeclaration>head(xtendFile.getXtendTypes()).getMembers(), XtendFunction.class)));
final JvmOperation operation = ((JvmOperation) _primaryJvmElement);
Assert.assertNull(this.overrideHelper.findOverriddenOperation(operation));
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendTypeDeclaration in project xtext-xtend by eclipse.
the class OverrideHelperTest method checkFindOverriddenOperation_02.
@Test
public void checkFindOverriddenOperation_02() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package foo");
_builder.newLine();
_builder.newLine();
_builder.append("import java.util.List");
_builder.newLine();
_builder.append("import java.util.Map");
_builder.newLine();
_builder.append("import java.util.Set");
_builder.newLine();
_builder.newLine();
_builder.append("class Foo extends Bar {");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("override bar(List<Object> list, ");
_builder.newLine();
_builder.append("\t\t");
_builder.append("Map<Object, Object> map,");
_builder.newLine();
_builder.append("\t\t");
_builder.append("Set<Object> set");
_builder.newLine();
_builder.append("\t");
_builder.append(") {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("super.bar(list, map, set)");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("class Bar {");
_builder.newLine();
_builder.append("\t");
_builder.append("def void bar(List<Object> list, ");
_builder.newLine();
_builder.append("\t\t");
_builder.append("Map<Object, Object> map, ");
_builder.newLine();
_builder.append("\t\t");
_builder.append("Set<Object> set");
_builder.newLine();
_builder.append("\t");
_builder.append(") {");
_builder.newLine();
_builder.append("\t\t");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile xtendFile = this.file(_builder.toString());
EObject _primaryJvmElement = this._iJvmModelAssociations.getPrimaryJvmElement(IterableExtensions.<XtendFunction>head(Iterables.<XtendFunction>filter(IterableExtensions.<XtendTypeDeclaration>head(xtendFile.getXtendTypes()).getMembers(), XtendFunction.class)));
final JvmOperation operation = ((JvmOperation) _primaryJvmElement);
Assert.assertNotNull(this.overrideHelper.findOverriddenOperation(operation));
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendTypeDeclaration in project xtext-xtend by eclipse.
the class SuspiciousOverloadValidationTest method assertSuspicious.
protected void assertSuspicious(final CharSequence contents, final String... messageParts) {
final XtendFile file = this.getParsedXtendFile(contents);
final EList<Resource.Diagnostic> errors = file.eResource().getErrors();
Assert.assertEquals(errors.toString(), 1, errors.size());
Resource.Diagnostic _head = IterableExtensions.<Resource.Diagnostic>head(errors);
final AbstractDiagnostic singleError = ((AbstractDiagnostic) _head);
Assert.assertEquals(singleError.getMessage(), IssueCodes.SUSPICIOUSLY_OVERLOADED_FEATURE, singleError.getCode());
final Function1<String, String> _function = (String it) -> {
return Strings.toUnixLineSeparator(it);
};
final Consumer<String> _function_1 = (String it) -> {
final String message = singleError.getMessage();
boolean _contains = message.contains(it);
boolean _not = (!_contains);
if (_not) {
Assert.assertEquals(it, message);
}
};
ListExtensions.<String, String>map(((List<String>) Conversions.doWrapArray(messageParts)), _function).forEach(_function_1);
final XtendTypeDeclaration firstType = IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes());
XtendMember _head_1 = IterableExtensions.<XtendMember>head(firstType.getMembers());
final XtendFunction firstMember = ((XtendFunction) _head_1);
XExpression _expression = firstMember.getExpression();
final XBlockExpression block = ((XBlockExpression) _expression);
final Function1<XAbstractFeatureCall, Boolean> _function_2 = (XAbstractFeatureCall it) -> {
return Boolean.valueOf(((!Objects.equal(it.eContainingFeature(), XbasePackage.Literals.XABSTRACT_FEATURE_CALL__IMPLICIT_RECEIVER)) && (it.getFeature() instanceof JvmOperation)));
};
final XAbstractFeatureCall featureCall = IteratorExtensions.<XAbstractFeatureCall>findLast(Iterators.<XAbstractFeatureCall>filter(block.eAllContents(), XAbstractFeatureCall.class), _function_2);
final IFeatureLinkingCandidate linkingCandidate = this._iBatchTypeResolver.resolveTypes(file).getLinkingCandidate(featureCall);
Assert.assertTrue((linkingCandidate instanceof ISuspiciouslyOverloadedCandidate));
}
Aggregations