use of org.eclipse.xtext.common.types.JvmIdentifiableElement 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.common.types.JvmIdentifiableElement in project xtext-xtend by eclipse.
the class TypeProviderErrorTest method testNoException_04.
@Test
public void testNoException_04() throws Exception {
XtendFile file = file("class NoException { dispatch");
Iterator<Object> contents = EcoreUtil.getAllContents(file.eResource(), true);
while (contents.hasNext()) {
EObject object = (EObject) contents.next();
if (object instanceof JvmIdentifiableElement) {
JvmIdentifiableElement element = (JvmIdentifiableElement) object;
getType(element);
}
}
}
use of org.eclipse.xtext.common.types.JvmIdentifiableElement in project xtext-xtend by eclipse.
the class TypeProviderTest method testResolvedMultiType_02.
@Test
public void testResolvedMultiType_02() throws Exception {
XtendFile file = file("package testPackage\n" + "import java.util.ArrayList\n" + "import java.util.LinkedList\n" + "class C {\n" + " def m() {\n" + " #[ if (true) new ArrayList<String> else new LinkedList<String> ]\n" + " }\n" + "}\n");
XtendClass c = (XtendClass) file.getXtendTypes().get(0);
XtendFunction function = (XtendFunction) c.getMembers().get(0);
Set<EObject> jvmElements = jvmModelAssociations.getJvmElements(function);
JvmIdentifiableElement operation = (JvmIdentifiableElement) jvmElements.iterator().next();
assertEquals("List<AbstractList<String>>", getType(operation).getSimpleName());
}
use of org.eclipse.xtext.common.types.JvmIdentifiableElement in project xtext-xtend by eclipse.
the class AbstractMultiModeOutlineTreeProvider method computeDecoratedText.
protected Object computeDecoratedText(final Object modelElement, final int inheritanceDepth) {
Object supertext = super.getText(modelElement);
if (!(supertext instanceof StyledString)) {
return supertext;
}
StyledString styledText = (StyledString) supertext;
if (inheritanceDepth > 0) {
styledText = applyStylerToFirstSegment(styledText, ColoringLabelProvider.INHERITED_STYLER);
}
if (modelElement instanceof JvmIdentifiableElement) {
JvmIdentifiableElement jvmElement = (JvmIdentifiableElement) modelElement;
if (!getAssociations().getSourceElements(jvmElement).isEmpty() && !getAssociations().isPrimaryJvmElement(jvmElement)) {
styledText = applyStylerToFirstSegment(styledText, StyledString.QUALIFIER_STYLER);
}
}
if (isShowInherited()) {
if (modelElement instanceof IResolvedFeature) {
String qualifier = createQualifier((IResolvedFeature) modelElement);
appendQualifier(styledText, qualifier);
} else if (modelElement instanceof JvmMember) {
String qualifier = createQualifier((JvmMember) modelElement);
appendQualifier(styledText, qualifier);
} else if (modelElement instanceof XtendMember) {
XtendMember xtendMember = (XtendMember) modelElement;
if (xtendMember.eContainer() instanceof XtendTypeDeclaration) {
String qualifiedName = createQualifier((XtendTypeDeclaration) xtendMember.eContainer(), '.');
appendQualifier(styledText, qualifiedName);
} else if (xtendMember instanceof XtendTypeDeclaration) {
XtendFile xtendFile = EcoreUtil2.getContainerOfType(xtendMember, XtendFile.class);
String qualifiedName = xtendFile.getPackage() == null ? "(default package)" : xtendFile.getPackage();
appendQualifier(styledText, qualifiedName);
}
}
}
return styledText;
}
use of org.eclipse.xtext.common.types.JvmIdentifiableElement in project xtext-xtend by eclipse.
the class AbstractMultiModeOutlineTreeProvider method createNodeForFeature.
protected XtendFeatureNode createNodeForFeature(IOutlineNode parentNode, final JvmDeclaredType inferredType, EObject featureElement, int inheritanceDepth) {
boolean synthetic = false;
if (featureElement instanceof JvmFeature) {
synthetic = typeExtensions.isSynthetic((JvmIdentifiableElement) featureElement);
}
Object text = computeDecoratedText(featureElement, inheritanceDepth);
ImageDescriptor image = getImageDescriptor(featureElement);
if (isShowInherited()) {
return getOutlineNodeFactory().createXtendFeatureNode(parentNode, featureElement, image, text, true, synthetic, inheritanceDepth);
}
return getOutlineNodeFactory().createXtendFeatureNode(parentNode, featureElement, image, text, true, synthetic, inheritanceDepth);
}
Aggregations