Exemplo n.º 1
0
  public static Map<String, PsiElement> prepareDefaultNameToDeclaration(
      Project project, KotlinCoreEnvironment environment) {
    Map<String, PsiElement> nameToDeclaration = new HashMap<String, PsiElement>();

    PsiClass java_util_Collections = findClass("java.util.Collections", project, environment);
    nameToDeclaration.put(
        "java::java.util.Collections.emptyList()", findMethod(java_util_Collections, "emptyList"));
    nameToDeclaration.put("java::java.util.Collections", java_util_Collections);
    PsiClass java_util_List = findClass("java.util.ArrayList", project, environment);
    nameToDeclaration.put(
        "java::java.util.List", findClass("java.util.List", project, environment));
    nameToDeclaration.put("java::java.util.ArrayList", java_util_List);
    nameToDeclaration.put(
        "java::java.util.ArrayList.set()", java_util_List.findMethodsByName("set", true)[0]);
    nameToDeclaration.put(
        "java::java.util.ArrayList.get()", java_util_List.findMethodsByName("get", true)[0]);
    nameToDeclaration.put("java::java", findPackage("java", project));
    nameToDeclaration.put("java::java.util", findPackage("java.util", project));
    nameToDeclaration.put("java::java.lang", findPackage("java.lang", project));
    nameToDeclaration.put(
        "java::java.lang.Object", findClass("java.lang.Object", project, environment));
    nameToDeclaration.put(
        "java::java.lang.Comparable", findClass("java.lang.Comparable", project, environment));
    PsiClass java_lang_System = findClass("java.lang.System", project, environment);
    nameToDeclaration.put("java::java.lang.System", java_lang_System);
    PsiMethod[] methods =
        findClass("java.io.PrintStream", project, environment).findMethodsByName("print", true);
    nameToDeclaration.put("java::java.io.PrintStream.print(Object)", methods[8]);
    nameToDeclaration.put("java::java.io.PrintStream.print(Int)", methods[2]);
    nameToDeclaration.put("java::java.io.PrintStream.print(char[])", methods[6]);
    nameToDeclaration.put("java::java.io.PrintStream.print(Double)", methods[5]);
    PsiField outField = java_lang_System.findFieldByName("out", true);
    assertNotNull("'out' property wasn't found", outField);
    nameToDeclaration.put("java::java.lang.System.out", outField);
    PsiClass java_lang_Number = findClass("java.lang.Number", project, environment);
    nameToDeclaration.put("java::java.lang.Number", java_lang_Number);
    nameToDeclaration.put(
        "java::java.lang.Number.intValue()",
        java_lang_Number.findMethodsByName("intValue", true)[0]);

    return nameToDeclaration;
  }
Exemplo n.º 2
0
 @NotNull
 private static PsiMethod findMethod(PsiClass psiClass, String name) {
   PsiMethod[] emptyLists = psiClass.findMethodsByName(name, true);
   return emptyLists[0];
 }