String (PyElement node) { // are we a method? List<? extends PsiElement> place = PyUtil.searchForWrappingMethod(node, true); if (place == null || place.size() < 2) return null; PyFunction method = (PyFunction)place.get(place.size()-2); //PyClass owner = (PyClass)place.get(place.size()-1); // what is our first param? PyParameter[] params = method.getParameterList().getParameters(); if (params.length < 1) return null; // no params PyNamedParameter first_parm = params[0].getAsNamed(); if (first_parm == null) return null; if (first_parm.isKeywordContainer() || first_parm.isPositionalContainer()) return null; // legal but crazy cases; back off final String first_param_name = first_parm.getName(); if (first_param_name == null || first_param_name.length() < 1) return null; // ignore cases of incorrect code // is it a static method? PyFunction.Modifier modifier = method.getModifier(); if (modifier == PyFunction.Modifier.STATICMETHOD) return null; // these may do whatever they please return first_param_name; }