use of org.eclipse.emf.ecore.util.InternalEList in project xtext-eclipse by eclipse.
the class JdtBasedTypeFactory method setParameterNamesAndAnnotations.
private void setParameterNamesAndAnnotations(IMethodBinding method, ITypeBinding[] parameterTypes, String[] parameterNames, JvmExecutable result) {
InternalEList<JvmFormalParameter> parameters = (InternalEList<JvmFormalParameter>) result.getParameters();
for (int i = 0; i < parameterTypes.length; i++) {
IAnnotationBinding[] parameterAnnotations;
try {
parameterAnnotations = method.getParameterAnnotations(i);
} catch (AbortCompilation aborted) {
parameterAnnotations = null;
}
ITypeBinding parameterType = parameterTypes[i];
String parameterName = parameterNames == null ? null : /* lazy */
i < parameterNames.length ? parameterNames[i] : "arg" + i;
JvmFormalParameter formalParameter = createFormalParameter(parameterType, parameterName, parameterAnnotations);
parameters.addUnique(formalParameter);
}
}
use of org.eclipse.emf.ecore.util.InternalEList in project xtext-eclipse by eclipse.
the class JdtBasedTypeFactory method createTypeArgument.
protected JvmTypeReference createTypeArgument(ITypeBinding argument) {
if (argument.isWildcardType()) {
JvmWildcardTypeReference result = TypesFactory.eINSTANCE.createJvmWildcardTypeReference();
InternalEList<JvmTypeConstraint> constraints = (InternalEList<JvmTypeConstraint>) result.getConstraints();
JvmUpperBound upperBound = TypesFactory.eINSTANCE.createJvmUpperBound();
ITypeBinding bound = argument.getBound();
if (argument.isUpperbound()) {
JvmTypeReference reference = createTypeReference(bound);
upperBound.setTypeReference(reference);
constraints.addUnique(upperBound);
} else {
JvmTypeReference objectReference = createObjectClassReference();
upperBound.setTypeReference(objectReference);
constraints.addUnique(upperBound);
if (bound != null) {
JvmLowerBound lowerBound = TypesFactory.eINSTANCE.createJvmLowerBound();
JvmTypeReference reference = createTypeReference(bound);
lowerBound.setTypeReference(reference);
constraints.addUnique(lowerBound);
}
}
return result;
} else {
return createTypeReference(argument);
}
}
use of org.eclipse.emf.ecore.util.InternalEList in project xtext-eclipse by eclipse.
the class JdtBasedTypeFactory method createFields.
/**
* @since 2.4
*/
protected void createFields(ITypeBinding typeBinding, StringBuilder qualifiedName, JvmDeclaredType result) {
resolveMembers.start();
IVariableBinding[] declaredFields = typeBinding.getDeclaredFields();
if (declaredFields.length > 0) {
int length = qualifiedName.length();
InternalEList<JvmMember> members = (InternalEList<JvmMember>) result.getMembers();
for (IVariableBinding field : declaredFields) {
if (!field.isSynthetic()) {
members.addUnique(createField(qualifiedName, field));
qualifiedName.setLength(length);
}
}
}
resolveMembers.stop();
}
use of org.eclipse.emf.ecore.util.InternalEList in project xtext-eclipse by eclipse.
the class JdtBasedTypeFactory method createMethods.
/**
* @since 2.4
*/
protected void createMethods(ITypeBinding typeBinding, String handleIdentifier, List<String> path, StringBuilder qualifiedName, JvmDeclaredType result) {
resolveMembers.start();
IMethodBinding[] declaredMethods = typeBinding.getDeclaredMethods();
if (declaredMethods.length > 0) {
int length = qualifiedName.length();
InternalEList<JvmMember> members = (InternalEList<JvmMember>) result.getMembers();
String[] subpath = subpath(path);
boolean intf = typeBinding.isInterface() && !typeBinding.isAnnotation();
for (IMethodBinding method : declaredMethods) {
if (!method.isSynthetic() && !"<clinit>".equals(method.getName())) {
if (method.isConstructor()) {
members.addUnique(createConstructor(qualifiedName, handleIdentifier, subpath, method));
} else {
JvmOperation operation = createOperation(qualifiedName, handleIdentifier, subpath, method);
if (typeBinding.isAnnotation()) {
setDefaultValue(operation, method);
} else if (intf && !operation.isAbstract() && !operation.isStatic()) {
operation.setDefault(true);
}
members.addUnique(operation);
}
qualifiedName.setLength(length);
}
}
}
resolveMembers.stop();
}
use of org.eclipse.emf.ecore.util.InternalEList in project xtext-eclipse by eclipse.
the class JdtBasedTypeFactory method createAnnotationReference.
/**
* @since 2.4
*/
protected JvmAnnotationReference createAnnotationReference(/* @NonNull */
IAnnotationBinding annotation) {
JvmAnnotationReference annotationReference = TypesFactory.eINSTANCE.createJvmAnnotationReference();
ITypeBinding annotationType = annotation.getAnnotationType();
annotationReference.setAnnotation(createAnnotationProxy(annotationType));
InternalEList<JvmAnnotationValue> values = (InternalEList<JvmAnnotationValue>) annotationReference.getExplicitValues();
IMemberValuePairBinding[] allMemberValuePairs = annotation.getDeclaredMemberValuePairs();
for (IMemberValuePairBinding memberValuePair : allMemberValuePairs) {
IMethodBinding methodBinding = memberValuePair.getMethodBinding();
if (methodBinding != null) {
try {
values.addUnique(createAnnotationValue(annotationType, memberValuePair.getValue(), methodBinding));
} catch (NullPointerException npe) {
// memberValuePair#getValue may throw an NPE if the methodBinding has no return type
if (methodBinding.getReturnType() != null) {
throw npe;
} else {
if (log.isDebugEnabled()) {
log.debug(npe.getMessage(), npe);
}
}
}
}
}
return annotationReference;
}
Aggregations