use of org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference in project xtext-xtend by eclipse.
the class Bug409780Test method testMissingTypeArgumentInference.
@Test
public void testMissingTypeArgumentInference() throws Exception {
XtendFile file = file("class C {\n" + " def private <T extends Appendable> Iterable<T> a(Iterable<CharSequence> it) {\n" + " map[ b ]\n" + " }\n" + " def private <T extends Appendable> T b(CharSequence c) {}\n" + "}");
XtendClass c = (XtendClass) file.getXtendTypes().get(0);
XtendFunction m = (XtendFunction) c.getMembers().get(0);
XBlockExpression body = (XBlockExpression) m.getExpression();
XFeatureCall featureCall = (XFeatureCall) body.getExpressions().get(0);
JvmIdentifiableElement method = featureCall.getFeature();
assertEquals("org.eclipse.xtext.xbase.lib.IterableExtensions.map(java.lang.Iterable,org.eclipse.xtext.xbase.lib.Functions$Function1)", method.getIdentifier());
assertTrue(featureCall.isStatic());
assertTrue(featureCall.isExtension());
assertFalse(featureCall.isTypeLiteral());
LightweightTypeReference type = getType(featureCall);
assertEquals("java.lang.Iterable<T>", type.getIdentifier());
LightweightTypeReference expectedType = getExpectedType(featureCall);
assertEquals("java.lang.Iterable<T>", expectedType.getIdentifier());
}
use of org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference in project xtext-xtend by eclipse.
the class ConstructorBuilderTest method testJavaException.
@Test
public void testJavaException() {
AbstractConstructorBuilder _createConstructorBuilder = this._codeBuilderFactory.createConstructorBuilder(this.getJavaClass());
final Procedure1<AbstractConstructorBuilder> _function = (AbstractConstructorBuilder it) -> {
it.setContext(this.getJavaClass());
LightweightTypeReference _createTypeRef = this.createTypeRef(Exception.class, this.getJavaClass());
LightweightTypeReference _createTypeRef_1 = this.createTypeRef(RuntimeException.class, this.getJavaClass());
it.setExceptions(Collections.<LightweightTypeReference>unmodifiableList(CollectionLiterals.<LightweightTypeReference>newArrayList(_createTypeRef, _createTypeRef_1)));
};
AbstractConstructorBuilder _doubleArrow = ObjectExtensions.<AbstractConstructorBuilder>operator_doubleArrow(_createConstructorBuilder, _function);
StringConcatenation _builder = new StringConcatenation();
_builder.append("Bar() throws Exception, RuntimeException {");
_builder.newLine();
_builder.append(" ");
_builder.append(AbstractBuilderTest.DEFAULT_BODY, " ");
_builder.append(";");
_builder.newLineIfNotEmpty();
_builder.append("}");
this.assertBuilds(_doubleArrow, _builder.toString());
}
use of org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference in project xtext-xtend by eclipse.
the class MethodBuilderTest method testJavaException.
@Test
public void testJavaException() {
AbstractMethodBuilder _createMethodBuilder = this._codeBuilderFactory.createMethodBuilder(this.getJavaClass());
final Procedure1<AbstractMethodBuilder> _function = (AbstractMethodBuilder it) -> {
it.setContext(this.getJavaClass());
it.setMethodName("foo");
LightweightTypeReference _createTypeRef = this.createTypeRef(Exception.class, this.getJavaClass());
LightweightTypeReference _createTypeRef_1 = this.createTypeRef(RuntimeException.class, this.getJavaClass());
it.setExceptions(Collections.<LightweightTypeReference>unmodifiableList(CollectionLiterals.<LightweightTypeReference>newArrayList(_createTypeRef, _createTypeRef_1)));
};
AbstractMethodBuilder _doubleArrow = ObjectExtensions.<AbstractMethodBuilder>operator_doubleArrow(_createMethodBuilder, _function);
StringConcatenation _builder = new StringConcatenation();
_builder.append("void foo() throws Exception, RuntimeException {");
_builder.newLine();
_builder.append(" ");
_builder.append(AbstractBuilderTest.DEFAULT_BODY, " ");
_builder.append(";");
_builder.newLineIfNotEmpty();
_builder.append("}");
this.assertBuilds(_doubleArrow, _builder.toString());
}
use of org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference in project xtext-xtend by eclipse.
the class MethodBuilderTest method testXtendExceptions.
@Test
public void testXtendExceptions() {
AbstractMethodBuilder _createMethodBuilder = this._codeBuilderFactory.createMethodBuilder(this.getXtendClass());
final Procedure1<AbstractMethodBuilder> _function = (AbstractMethodBuilder it) -> {
it.setContext(this.getXtendClass());
it.setMethodName("foo");
LightweightTypeReference _createTypeRef = this.createTypeRef(Exception.class, this.getXtendClass());
LightweightTypeReference _createTypeRef_1 = this.createTypeRef(RuntimeException.class, this.getXtendClass());
it.setExceptions(Collections.<LightweightTypeReference>unmodifiableList(CollectionLiterals.<LightweightTypeReference>newArrayList(_createTypeRef, _createTypeRef_1)));
};
AbstractMethodBuilder _doubleArrow = ObjectExtensions.<AbstractMethodBuilder>operator_doubleArrow(_createMethodBuilder, _function);
StringConcatenation _builder = new StringConcatenation();
_builder.append("def foo() throws Exception, RuntimeException {");
_builder.newLine();
_builder.append(" ");
_builder.append(AbstractBuilderTest.DEFAULT_BODY, " ");
_builder.newLineIfNotEmpty();
_builder.append("}");
this.assertBuilds(_doubleArrow, _builder.toString());
}
use of org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference in project xtext-xtend by eclipse.
the class CreateMemberQuickfixes method newMethodQuickfixes.
protected void newMethodQuickfixes(String newMemberName, XAbstractFeatureCall call, final Issue issue, final IssueResolutionAcceptor issueResolutionAcceptor) {
JvmDeclaredType callersType = getCallersType(call);
LightweightTypeReference receiverType = getReceiverType(call);
LightweightTypeReference returnType = getNewMemberType(call);
if (callersType == null || receiverType == null)
return;
List<LightweightTypeReference> argumentTypes = getResolvedArgumentTypes(call, logicalContainerProvider.getNearestLogicalContainer(call), call.getActualArguments());
newMethodQuickfixes(receiverType, newMemberName, returnType, argumentTypes, call, callersType, issue, issueResolutionAcceptor);
}
Aggregations