use of org.eclipse.xtext.common.types.JvmConstructor in project xtext-xtend by eclipse.
the class XtendHoverSignatureProvider method _signature.
protected String _signature(XtendConstructor constructor, boolean typeAtEnd) {
JvmConstructor inferredConstructor = associations.getInferredConstructor(constructor);
XtendClass xtendClazz = EcoreUtil2.getContainerOfType(constructor, XtendClass.class);
return xtendClazz.getName() + hoverUiStrings.parameters(inferredConstructor) + getThrowsDeclaration(inferredConstructor);
}
use of org.eclipse.xtext.common.types.JvmConstructor in project xtext-xtend by eclipse.
the class XtendHoverSignatureProvider method getSimpleSignature.
@Override
protected String getSimpleSignature(EObject container) {
if (container instanceof XtendFunction) {
XtendFunction function = (XtendFunction) container;
JvmOperation inferredOperation = associations.getDirectlyInferredOperation(function);
if (inferredOperation != null) {
return function.getName() + uiStrings.parameters(inferredOperation);
}
} else if (container instanceof XtendConstructor) {
XtendConstructor constructor = (XtendConstructor) container;
XtendClass xtendClazz = EcoreUtil2.getContainerOfType(constructor, XtendClass.class);
JvmConstructor inferredConstructor = associations.getInferredConstructor(constructor);
return xtendClazz.getName() + " " + uiStrings.parameters(inferredConstructor);
}
return super.getSimpleSignature(container);
}
use of org.eclipse.xtext.common.types.JvmConstructor in project xtext-xtend by eclipse.
the class DependentElementsCalculatorTests method testPolymorphicDispatch.
@Test
public void testPolymorphicDispatch() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class Foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("def dispatch foo(Number it) {");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("def dispatch foo(String it) {");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile fooFile = this.testHelper.xtendFile("Foo", _builder.toString());
IResourcesSetupUtil.waitForBuild();
XtendTypeDeclaration _get = fooFile.getXtendTypes().get(0);
final XtendClass fooClass = ((XtendClass) _get);
final XtendMember fooMethod1 = fooClass.getMembers().get(1);
NullProgressMonitor _nullProgressMonitor = new NullProgressMonitor();
final Iterable<URI> dependentElementURIs = this.dependentElementsCalculator.getDependentElementURIs(fooMethod1, _nullProgressMonitor);
Assert.assertEquals(5, IterableExtensions.size(dependentElementURIs));
EList<XtendMember> _members = fooClass.getMembers();
EList<JvmMember> _members_1 = this.associations.getInferredType(fooClass).getMembers();
final Function1<EObject, Boolean> _function = (EObject it) -> {
return Boolean.valueOf((!(it instanceof JvmConstructor)));
};
final Consumer<EObject> _function_1 = (EObject it) -> {
final Function1<URI, Boolean> _function_2 = (URI element) -> {
URI _uRI = EcoreUtil.getURI(it);
return Boolean.valueOf(Objects.equal(element, _uRI));
};
Assert.assertTrue(it.toString(), IterableExtensions.<URI>exists(dependentElementURIs, _function_2));
};
IterableExtensions.<EObject>toList(IterableExtensions.<EObject>filter(Iterables.<EObject>concat(_members, _members_1), _function)).forEach(_function_1);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.common.types.JvmConstructor in project xtext-xtend by eclipse.
the class XtendEObjectAtOffsetHelper method resolveCrossReferencedElement.
@Override
protected EObject resolveCrossReferencedElement(INode node) {
EObject referencedElement = super.resolveCrossReferencedElement(node);
EObject referenceOwner = NodeModelUtils.findActualSemanticObjectFor(node);
if (referenceOwner instanceof XConstructorCall) {
if (referenceOwner.eContainer() instanceof AnonymousClass) {
AnonymousClass anon = (AnonymousClass) referenceOwner.eContainer();
JvmGenericType superType = anonymousClassUtil.getSuperType(anon);
if (superType != null) {
if (referencedElement instanceof JvmGenericType)
return superType;
else if (referencedElement instanceof JvmConstructor) {
if (superType.isInterface())
return superType;
JvmConstructor superConstructor = anonymousClassUtil.getSuperTypeConstructor(anon);
if (superConstructor != null)
return superConstructor;
}
}
}
}
return referencedElement;
}
use of org.eclipse.xtext.common.types.JvmConstructor in project xtext-xtend by eclipse.
the class XtendReentrantTypeResolver method doPrepareLocalTypes.
protected void doPrepareLocalTypes(final ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, JvmFeature container, Map<JvmIdentifiableElement, ResolvedTypes> resolvedTypesByContext) {
List<JvmGenericType> localClasses = container.getLocalClasses();
for (final JvmGenericType localClass : localClasses) {
JvmTypeReference superType = localClass.getSuperTypes().get(0);
final IFeatureScopeSession nestedSession = featureScopeSession;
if (InferredTypeIndicator.isInferred(superType)) {
final XComputedTypeReference casted = (XComputedTypeReference) superType;
InferredTypeIndicator typeProvider = (InferredTypeIndicator) casted.getTypeProvider();
final AnonymousClass anonymousClass = (AnonymousClass) typeProvider.getExpression();
XConstructorCall constructorCall = anonymousClass.getConstructorCall();
IScope typeScope = featureScopeSession.getScope(constructorCall, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, resolvedTypes);
final JvmDeclaredType type = anonymousClassUtil.getSuperTypeNonResolving(anonymousClass, typeScope);
if (type == null) {
JvmUnknownTypeReference superTypeReference = TypesFactory.eINSTANCE.createJvmUnknownTypeReference();
requestCapturedLocalVariables(superTypeReference, localClass, resolvedTypes, resolvedTypesByContext, new IAcceptor<JvmTypeReference>() {
@Override
public void accept(JvmTypeReference capturingTypeReference) {
casted.setEquivalent(capturingTypeReference);
inferAnonymousClassConstructor(anonymousClass, localClass);
}
});
} else {
final JvmParameterizedTypeReference superTypeReference = createSuperTypeReference(type, constructorCall);
requestCapturedLocalVariables(superTypeReference, localClass, resolvedTypes, resolvedTypesByContext, new IAcceptor<JvmTypeReference>() {
@Override
@SuppressWarnings("deprecation")
public void accept(JvmTypeReference capturingTypeReference) {
casted.setEquivalent(capturingTypeReference);
IFeatureScopeSession mySession = addThisAndSuper(nestedSession, resolvedTypes.getReferenceOwner(), localClass, superTypeReference, false);
if (type.eClass() == TypesPackage.Literals.JVM_GENERIC_TYPE && ((JvmGenericType) type).isInterface()) {
localClass.getSuperTypes().add(0, typesBuilder.newTypeRef(localClass, Object.class));
inferAnonymousClassConstructor(anonymousClass, localClass);
} else {
for (JvmMember superMember : type.getMembers()) {
if (superMember instanceof JvmConstructor) {
JvmConstructor superTypeConstructor = (JvmConstructor) superMember;
boolean visible = mySession.isVisible(superTypeConstructor);
inferAnonymousClassConstructor(anonymousClass, localClass, superTypeConstructor, visible);
}
}
}
}
});
}
}
}
}
Aggregations