use of org.eclipse.xtend.core.xtend.XtendParameter in project xtext-xtend by eclipse.
the class LinkingTest method testBug342848_02.
@Test
public void testBug342848_02() throws Exception {
String fileAsText = "import org.eclipse.xtext.xbase.lib.Functions\n" + "class Clazz { def void method(Functions.Function0<Integer> f) { f.apply } }";
XtendFile file = file(fileAsText, true);
XtendFunction function = (XtendFunction) ((XtendClass) file.getXtendTypes().get(0)).getMembers().get(0);
XtendParameter parameter = function.getParameters().get(0);
String identifier = parameter.getParameterType().getIdentifier();
assertEquals(Functions.Function0.class.getName() + "<java.lang.Integer>", identifier);
}
use of org.eclipse.xtend.core.xtend.XtendParameter in project xtext-xtend by eclipse.
the class XtendCopyQualifiedNameService method toQualifiedName.
protected String toQualifiedName(final XtendConstructor it) {
StringConcatenation _builder = new StringConcatenation();
String _fullyQualifiedName = this.toFullyQualifiedName(it);
_builder.append(_fullyQualifiedName);
_builder.append("(");
final Function1<XtendParameter, String> _function = (XtendParameter it_1) -> {
return it_1.getParameterType().getSimpleName();
};
CharSequence _qualifiedNames = this.<XtendParameter>toQualifiedNames(it.getParameters(), _function);
_builder.append(_qualifiedNames);
_builder.append(")");
return _builder.toString();
}
use of org.eclipse.xtend.core.xtend.XtendParameter in project xtext-xtend by eclipse.
the class XtendUIValidationTests method testParameterizedTypeReference.
@Test
public void testParameterizedTypeReference() {
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<org.eclipse.xtend.core.tests.internal.InternalClass> 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);
final XtendParameter parameter = function.getParameters().get(0);
JvmTypeReference _parameterType = parameter.getParameterType();
final JvmParameterizedTypeReference type = ((JvmParameterizedTypeReference) _parameterType);
final JvmTypeReference typeParameter = type.getArguments().get(0);
this.helper.assertError(type, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE, org.eclipse.xtext.xbase.validation.IssueCodes.FORBIDDEN_REFERENCE);
this.helper.assertWarning(typeParameter, TypesPackage.Literals.JVM_TYPE_REFERENCE, org.eclipse.xtext.xbase.validation.IssueCodes.DISCOURAGED_REFERENCE);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendParameter in project xtext-xtend by eclipse.
the class XtendProposalProvider method completeParameter_Name.
@Override
public void completeParameter_Name(final EObject model, Assignment assignment, final ContentAssistContext context, final ICompletionProposalAcceptor acceptor) {
if (model instanceof XtendParameter) {
final List<XtendParameter> siblings = EcoreUtil2.getSiblingsOfType(model, XtendParameter.class);
Set<String> alreadyTaken = Sets.newHashSet();
for (XtendParameter sibling : siblings) {
alreadyTaken.add(sibling.getName());
}
alreadyTaken.addAll(getAllKeywords());
completions.getVariableProposals(model, XtendPackage.Literals.XTEND_PARAMETER__PARAMETER_TYPE, VariableType.PARAMETER, alreadyTaken, new JdtVariableCompletions.CompletionDataAcceptor() {
@Override
public void accept(String replaceText, StyledString label, Image img) {
acceptor.accept(createCompletionProposal(replaceText, label, img, context));
}
});
} else {
super.completeParameter_Name(model, assignment, context, acceptor);
}
}
use of org.eclipse.xtend.core.xtend.XtendParameter in project xtext-xtend by eclipse.
the class XtendHoverSignatureProviderTest method testEnumReference.
@Test
public void testEnumReference() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package testPackage");
_builder.newLine();
_builder.append("class Bar {");
_builder.newLine();
_builder.append("\t");
_builder.append("def baz(Foo f){}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.append("enum Foo { BAR, BAZ }");
_builder.newLine();
final XtendFile xtendFile = this.parseHelper.parse(_builder, this.getResourceSet());
XtendMember _head = IterableExtensions.<XtendMember>head(IterableExtensions.<XtendTypeDeclaration>head(xtendFile.getXtendTypes()).getMembers());
final JvmType en = IterableExtensions.<XtendParameter>head(((XtendFunction) _head).getParameters()).getParameterType().getType();
Assert.assertEquals("Foo", this.signatureProvider.getSignature(en));
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
Aggregations