コード例 #1
0
 private PsiMethod getSyntheticMethod(String text) {
   PsiElementFactory factory = JavaPsiFacade.getInstance(myClass.getProject()).getElementFactory();
   PsiMethod method = factory.createMethodFromText(text, myClass);
   return new LightMethod(myClass.getManager(), method, myClass) {
     @Override
     public int getTextOffset() {
       return myClass.getTextOffset();
     }
   };
 }
コード例 #2
0
 @Nullable
 public PsiMethod getValuesMethod() {
   return !myClass.isEnum() || myClass.getName() == null
       ? null
       : CachedValuesManager.getCachedValue(
           myClass,
           new CachedValueProvider<PsiMethod>() {
             @Nullable
             @Override
             public Result<PsiMethod> compute() {
               String text = "public static " + myClass.getName() + "[] values() { }";
               return new Result<PsiMethod>(
                   getSyntheticMethod(text), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTracker);
             }
           });
 }
コード例 #3
0
 @Nullable
 public PsiMethod getValueOfMethod() {
   return !myClass.isEnum() || myClass.getName() == null
       ? null
       : CachedValuesManager.getCachedValue(
           myClass,
           new CachedValueProvider<PsiMethod>() {
             @Nullable
             @Override
             public Result<PsiMethod> compute() {
               String text =
                   "public static "
                       + myClass.getName()
                       + " valueOf(java.lang.String name) throws java.lang.IllegalArgumentException { }";
               return new Result<PsiMethod>(
                   getSyntheticMethod(text), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTracker);
             }
           });
 }
コード例 #4
0
 @NotNull
 private PsiClass[] getAllInnerClasses() {
   List<PsiClass> own = myClass.getOwnInnerClasses();
   List<PsiClass> ext = PsiAugmentProvider.collectAugments(myClass, PsiClass.class);
   return ArrayUtil.mergeCollections(own, ext, PsiClass.ARRAY_FACTORY);
 }
コード例 #5
0
 @NotNull
 private PsiMethod[] getAllMethods() {
   List<PsiMethod> own = myClass.getOwnMethods();
   List<PsiMethod> ext = PsiAugmentProvider.collectAugments(myClass, PsiMethod.class);
   return ArrayUtil.mergeCollections(own, ext, PsiMethod.ARRAY_FACTORY);
 }