use of org.eclipse.ceylon.compiler.java.metadata.Ignore in project ceylon by eclipse.
the class Array method $set$.
@Ignore
@Override
public void $set$(ReachableReference reference, java.lang.Object instance) {
if (reference instanceof Member && getArraySize().equals(((Member) reference).getAttribute())) {
int size = toSize(((ceylon.language.Integer) instance).value);
try {
Lookup lookup = MethodHandles.lookup();
Util.setter(lookup, "size").invokeExact(this, size);
java.lang.Object array = createArrayWithElement($reifiedElement, size, null);
Util.setter(lookup, "array").invokeExact(this, array);
if (elementType.fieldName != null) {
MethodHandle fieldSetter = Util.setter(lookup, elementType.fieldName);
switch(elementType) {
case CeylonInteger:
fieldSetter.invokeExact(this, (long[]) array);
break;
case CeylonFloat:
fieldSetter.invokeExact(this, (double[]) array);
break;
case CeylonCharacter:
fieldSetter.invokeExact(this, (int[]) array);
break;
case CeylonByte:
fieldSetter.invokeExact(this, (byte[]) array);
break;
case CeylonBoolean:
fieldSetter.invokeExact(this, (boolean[]) array);
break;
case CeylonString:
fieldSetter.invokeExact(this, (java.lang.String[]) array);
break;
case Other:
fieldSetter.invokeExact(this, (java.lang.Object[]) array);
break;
default:
fieldSetter.invoke(this, array);
break;
}
}
} catch (java.lang.Throwable t) {
rethrow_.rethrow(t);
}
} else {
ceylon.language.serialization.Element index = (ceylon.language.serialization.Element) reference;
set(index.getIndex(), (Element) instance);
}
}
use of org.eclipse.ceylon.compiler.java.metadata.Ignore in project ceylon by eclipse.
the class ValueDeclarationImpl method $getJavaAnnotations$.
@Override
@Ignore
public java.lang.annotation.Annotation[] $getJavaAnnotations$() {
Class<?> javaClass = Metamodel.getJavaClass(declaration);
ArrayList<java.lang.annotation.Annotation> result = new ArrayList<>();
HashSet<Class<? extends java.lang.annotation.Annotation>> cls = new HashSet<>();
if (javaClass != null) {
// FIXME: pretty sure this doesn't work with interop and fields
Method declaredGetter = Reflection.getDeclaredGetter(javaClass, NamingBase.getGetterName(declaration));
if (declaredGetter != null) {
addToList(result, cls, declaredGetter.getAnnotations());
}
if (!((Value) declaration).isTransient()) {
// TODO only include those which are java annotations
Field field = Reflection.getDeclaredField(javaClass, declaration.getName());
if (field != null) {
Annotation[] fieldAnnos = field.getAnnotations();
addToList(result, cls, fieldAnnos);
}
Method setter = Reflection.getDeclaredSetter(javaClass, NamingBase.getSetterName(declaration.getName()));
if (setter != null) {
Annotation[] setterAnnos = setter.getAnnotations();
addToList(result, cls, setterAnnos);
}
}
}
// one last chance
if (parameter != null && !parameter.getModel().isShared()) {
// get the annotations from the parameter itself
Annotation[][] parameterAnnotations;
Scope container = parameter.getModel().getContainer();
if (container instanceof org.eclipse.ceylon.model.typechecker.model.Function) {
parameterAnnotations = Metamodel.getJavaMethod((org.eclipse.ceylon.model.typechecker.model.Function) container).getParameterAnnotations();
} else if (container instanceof org.eclipse.ceylon.model.typechecker.model.ClassAlias) {
parameterAnnotations = Reflection.findClassAliasInstantiator(Metamodel.getJavaClass((org.eclipse.ceylon.model.typechecker.model.Class) container), (org.eclipse.ceylon.model.typechecker.model.ClassAlias) container).getParameterAnnotations();
} else if (container instanceof org.eclipse.ceylon.model.typechecker.model.Class) {
// FIXME: pretty sure that's wrong because of synthetic params. See ReflectionMethod.getParameters
parameterAnnotations = Reflection.findConstructor(Metamodel.getJavaClass((org.eclipse.ceylon.model.typechecker.model.Class) container)).getParameterAnnotations();
} else {
throw Metamodel.newModelError("Unsupported parameter container");
}
// now find the right parameter
List<Parameter> parameters = ((org.eclipse.ceylon.model.typechecker.model.Functional) container).getFirstParameterList().getParameters();
int index = parameters.indexOf(parameter);
if (index == -1)
throw Metamodel.newModelError("Parameter " + parameter + " not found in container " + parameter.getModel().getContainer());
if (index >= parameterAnnotations.length)
throw Metamodel.newModelError("Parameter " + parameter + " index is greater than JVM parameters for " + parameter.getModel().getContainer());
addToList(result, cls, parameterAnnotations[index]);
}
// nope
return result.toArray(new java.lang.annotation.Annotation[result.size()]);
}
use of org.eclipse.ceylon.compiler.java.metadata.Ignore in project ceylon by eclipse.
the class SetterDeclarationImpl method $isAnnotated$.
@Override
@Ignore
public boolean $isAnnotated$(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType) {
checkInit();
final AnnotatedElement element = declaredSetter;
return element != null ? element.isAnnotationPresent(annotationType) : false;
}
use of org.eclipse.ceylon.compiler.java.metadata.Ignore in project ceylon by eclipse.
the class Tuple method $references$.
@Ignore
@Override
public java.util.Collection<ReachableReference> $references$() {
// could put the elements with int indexes and the rest as a String!
ArrayList<ReachableReference> s = new ArrayList<ReachableReference>(2);
ClassDeclaration cd = (ClassDeclaration) Metamodel.getOrCreateMetamodel(Tuple.class);
s.add(new MemberImpl(Util.assertExists(cd.<ValueDeclaration>getMemberDeclaration(ValueDeclaration.$TypeDescriptor$, "first"))));
s.add(new MemberImpl(Util.assertExists(cd.<ValueDeclaration>getMemberDeclaration(ValueDeclaration.$TypeDescriptor$, "rest"))));
return s;
}
use of org.eclipse.ceylon.compiler.java.metadata.Ignore in project ceylon by eclipse.
the class ValueTypeTests method validateVTMethod.
// Check if the given method should have a static companion method
// and if so check that it exists and adheres to all the rules
private void validateVTMethod(Class<?> clazz, Method classMethod) {
if (classMethod.getAnnotation(Ignore.class) != null || (classMethod.getModifiers() & Modifier.STATIC) != 0 || (classMethod.getModifiers() & Modifier.VOLATILE) != 0 || classMethod.getDeclaringClass() == Object.class) {
// And finally we skip all methods defined on Object
return;
}
validateVTMethodUnchecked(clazz, classMethod, classMethod);
// See if it has any overloads that need checking
Method[] overloads = findVTMethodOverloads(clazz, classMethod);
for (Method m : overloads) {
if (m.getAnnotation(Ignore.class) == null || (m.getModifiers() & Modifier.STATIC) != 0 || (m.getModifiers() & Modifier.VOLATILE) != 0) {
// and those NOT marked with @Ignore
continue;
}
validateVTMethodUnchecked(clazz, m, classMethod);
}
}
Aggregations