/// <summary> /// Add completion data and search through the Java library for more related data /// </summary> private static void AddCompletionData(string data) { AddCompletion_Data(data); java.lang.Class c = java.lang.Class.forName(data); if (c == null) { return; } AddCompletion_Data(c.getSimpleName()); Parallel.ForEach(c.getDeclaredFields(), field => { lock (CompletionList) { if (Modifier.isPublic(field.getModifiers())) { AddCompletion_Data(c.getSimpleName() + "." + field.getName()); } } }); Parallel.ForEach(c.getDeclaredMethods(), method => { lock (CompletionList) { if (Modifier.isPublic(method.getModifiers())) { AddCompletion_Data(c.getSimpleName() + "." + method.getName() + "("); } } }); }
public static java.lang.reflect.Method[] getMethodsAnnotatedWith(java.lang.Class clazz, string annotation) { LinkedList <java.lang.reflect.Method> retval = new LinkedList <java.lang.reflect.Method>(); // @todo: fix this hack up. We should be matching the name of the annotation, not the // .toString() artifact foreach (java.lang.reflect.Method method in clazz.getDeclaredMethods()) { foreach (java.lang.annotation.Annotation ann in method.getDeclaredAnnotations()) { if (ann.toString().Equals('@' + annotation + "()")) { retval.AddFirst(method); } } } return(retval.ToArray <java.lang.reflect.Method>()); }
private void AddMembers(String p, Symbol s, java.lang.Class ci, List <object> exceptFor, int maxDepth) { Package pkg = CurrentPackage(); String ns = ci.getName(); if (!useClassname(ns)) { return; } WriteLine("; importing " + p + " as " + ns); java.lang.reflect.Field[] fi = ci.getFields(); for (int i = 0; i < fi.Length; i++) { java.lang.reflect.Field f = fi[i]; f.setAccessible(true); String fname = ("" + p + "." + f.getName()).ToUpper(); Symbol old = pkg.findAccessibleSymbol(fname); if (old != null) { // fname = ("" + p + "%" + f.getName()).ToUpper() + ""; // old = pkg.findAccessibleSymbol(fname); } bool needsClear = false; if (old == null) { old = pkg.intern(new SimpleString(fname)); needsClear = true; // WriteLine(";;; skip field " + fname + " for " + f); // continue; } WriteLine(";;; field " + fname + " for " + f); Symbol sfm = Intern(fname, null, exceptFor, f.getType(), maxDepth - 1);// IkvmSite.fieldToInstanceSymbol(fname, pkg, s, f); if (needsClear) { sfm.setSymbolValue(null); } if (maxDepth > 0) { exceptFor.Add(f); AddMembers(fname, sfm, f.getType(), exceptFor, maxDepth - 1); } else { if (false && !exceptFor.Contains(f)) { exceptFor.Add(f); AddMembers(fname, sfm, ikvm.runtime.Util.getInstanceTypeFromClass(f.getType()), exceptFor, maxDepth - 1); } } } java.lang.reflect.Method[] mi = ci.getDeclaredMethods(); if (false) { for (int i = 0; i < mi.Length; i++) { java.lang.reflect.Method m = mi[i]; String fname = ("" + p + "." + m.getName()).ToUpper() + ""; Symbol old = pkg.findAccessibleSymbol(fname); if (old != null) { fname = ("" + p + "/" + m.getName()).ToUpper() + ""; old = pkg.findAccessibleSymbol(fname); } if (old != null) { fname = ("" + p + "//" + m.getName()).ToUpper() + ""; old = pkg.findAccessibleSymbol(fname); } if (old != null) { WriteLine(";;; skip method " + fname + " for " + m); continue; } WriteLine(";;; method " + p + " as " + fname + " to " + m); //LispObject sfm = IkvmSite.methodToInstanceSymbol(fname, pkg, s, m); } } }