コード例 #1
0
 private static boolean usesDefaultClone(PsiClass aClass) {
   final Project project = aClass.getProject();
   final PsiManager manager = aClass.getManager();
   final GlobalSearchScope scope = GlobalSearchScope.allScope(project);
   final PsiClass cloneable =
       JavaPsiFacade.getInstance(manager.getProject()).findClass("java.lang.Cloneable", scope);
   if (!InheritanceUtil.isInheritorOrSelf(aClass, cloneable, true)) {
     return false;
   }
   final PsiMethod[] methods = aClass.findMethodsByName("clone", false);
   for (PsiMethod method : methods) {
     final PsiParameterList parameterList = method.getParameterList();
     final PsiParameter[] parameters = parameterList.getParameters();
     if (parameters.length == 0) {
       return false;
     }
   }
   return true;
 }
コード例 #2
0
 private static boolean usesDefaultSerialization(PsiClass aClass) {
   final Project project = aClass.getProject();
   final PsiManager manager = aClass.getManager();
   final GlobalSearchScope scope = GlobalSearchScope.allScope(project);
   final PsiClass serializable =
       JavaPsiFacade.getInstance(manager.getProject()).findClass("java.io.Serializable", scope);
   if (!InheritanceUtil.isInheritorOrSelf(aClass, serializable, true)) {
     return false;
   }
   final PsiMethod[] methods = aClass.findMethodsByName("writeObject", false);
   for (PsiMethod method : methods) {
     final PsiParameterList parameterList = method.getParameterList();
     final PsiParameter[] parameters = parameterList.getParameters();
     if (parameters.length == 1) {
       final PsiType type = parameters[0].getType();
       final String text = type.getCanonicalText();
       if ("java.io.DataOutputStream".equals(text)) {
         return false;
       }
     }
   }
   return true;
 }