PsiClass and operation too complex- sorry

Directly putting the return value of some PsiClass getter methods (in my case, getAllMethods, which returns an array of type PsiMethod) into a Collection, then trying to perform Collection operations on them ( Collection.remove(int) ) will throw this error.

It appears to be because the getter methods return an array of THE instances of the PsiMethod instead of copies. I put the return value into an Collection, and when I tried to manipulate the Collection, I got this error.

It would not let me remove a PsiMethod because I guess that amounts to a refactoring (a delete method) and all that implies. I just wanted to remove it from my local copy of the collection, but it threw.

Proof that getAllFields returns an array with the exact same reference :

List allFields = Arrays.asList(psiClass.getAllFields()); List]]> allFields2 = Arrays.asList(psiClass.getAllFields());
boolean sameObject = false;

for (int i= 0; i<allFields.size(); i++)
sameObject =allFields.get(i) == allFields2.get(i);
System.out.println("sameObject ? = " + sameObject);

returns "true" for all fields.

Message was edited by:

Please sign in to leave a comment.