public static ICallback<Boolean, Exception> onGetTddPropsError;
private boolean checkMethodCreationAtClass(PyEdit edit, IPyRefactoring pyRefactoring, String callWithoutParens,
PySelection callPs, List<ICompletionProposal> ret, String lineContents, TddPossibleMatches possibleMatch,
File f, IPythonNature nature) throws MisconfigurationException, Exception {
RefactoringRequest request;
ItemPointer[] pointers;
//Ok, no definition found for the full string, so, check if we have a dot there and check
//if it could be a method in a local variable.
String[] headAndTail = FullRepIterable.headAndTail(callWithoutParens);
if (headAndTail[0].length() > 0) {
String methodToCreate = headAndTail[1];
if (headAndTail[0].equals("self")) {
//creating something in the current class -- note that if it was self.bar here, we'd treat it as regular
//(i.e.: no special support for self), so, we wouldn't enter here!
int firstCharPosition = PySelection.getFirstCharPosition(lineContents);
LineStartingScope scopeStart = callPs.getPreviousLineThatStartsScope(PySelection.CLASS_TOKEN, false,
firstCharPosition);
String classNameInLine = null;
if (scopeStart != null) {
for (Boolean isCall : new Boolean[] { true, false }) {
PyCreateMethodOrField pyCreateMethod = new PyCreateMethodOrField();
List<String> parametersAfterCall = null;
parametersAfterCall = configCreateAsAndReturnParametersAfterCall(callPs, isCall,
pyCreateMethod, parametersAfterCall, methodToCreate);
String startingScopeLineContents = callPs.getLine(scopeStart.iLineStartingScope);
classNameInLine = PySelection.getClassNameInLine(startingScopeLineContents);
if (classNameInLine != null && classNameInLine.length() > 0) {
pyCreateMethod.setCreateInClass(classNameInLine);
addCreateMethodOption(callPs, edit, ret, methodToCreate, parametersAfterCall,
pyCreateMethod, classNameInLine);
}
}
}
return true;
}
int absoluteCursorOffset = callPs.getAbsoluteCursorOffset();
absoluteCursorOffset = absoluteCursorOffset - (1 + methodToCreate.length()); //+1 for the dot removed too.
PySelection newSelection = new PySelection(callPs.getDoc(), absoluteCursorOffset);
request = new RefactoringRequest(f, newSelection, null, nature, edit);
//Don't look in additional info.
request.setAdditionalInfo(AstEntryRefactorerRequestConstants.FIND_DEFINITION_IN_ADDITIONAL_INFO, false);
pointers = pyRefactoring.findDefinition(request);
if (pointers.length == 1) {
if (checkCreationBasedOnFoundPointers(edit, callPs, ret, possibleMatch, pointers, methodToCreate,
newSelection, nature)) {
return true;