use of org.eclipse.titanium.refactoring.function.ReturnVisitor.ReturnCertainty in project titan.EclipsePlug-ins by eclipse.
the class ExtractToFunctionRefactoring method createFunction.
public WorkspaceJob createFunction() {
final WorkspaceJob job = new WorkspaceJob("ExtractToFunction: creating new function text") {
@Override
public IStatus runInWorkspace(final IProgressMonitor monitor) throws CoreException {
final StatementList selectedStatements = selectionFinder.getSelectedStatements();
final Module selectedModule = getSelectedModule();
final IFile selectedFile = getSelectedFile();
final Reference runsOnRef = selectionFinder.getRunsOnRef();
final Type returnType = selectionFinder.getReturnType();
final ReturnCertainty retCertainty = selectionFinder.getReturnCertainty();
parentFunc = selectionFinder.getParentFunc();
if (parentFunc == null) {
ErrorReporter.logError("ExtractToFunctionRefactoring.createFunction(): Could not find the enclosing function of the selection! ");
return Status.CANCEL_STATUS;
}
if (selectionFinder.getInsertLoc() < 0) {
ErrorReporter.logError("ExtractToFunctionRefactoring.createFunction(): Could not calculate the insert location! ");
return Status.CANCEL_STATUS;
}
if (selectedStatements == null || selectedStatements.isEmpty() || selectedModule == null) {
ErrorReporter.logError("ExtractToFunctionRefactoring.createFunction(): No or invalid selection! ");
return Status.CANCEL_STATUS;
}
// collect params and find runs on clause
paramCollector = new ParamCollector(project, selectedStatements, selectedModule);
paramCollector.perform();
List<Param> params = paramCollector.getParams();
//
if (params == null) {
ErrorReporter.logError("ExtractToFunctionRefactoring.createFunction(): Unable to collect params! ");
return Status.CANCEL_STATUS;
}
// create new function text
functionCreator = new FunctionCreator(selectedStatements, selectedFile, newFuncName, params, runsOnRef, returnType, retCertainty);
functionCreator.perform();
functionText = functionCreator.getFunctionText();
if (functionText == null) {
ErrorReporter.logError("ExtractToFunctionRefactoring.createFunction(): Unable to create function text! ");
return Status.CANCEL_STATUS;
}
functionCallText = functionCreator.getFunctionCallText();
if (functionCallText == null) {
ErrorReporter.logError("ExtractToFunctionRefactoring.createFunction(): Unable to create function call text! ");
return Status.CANCEL_STATUS;
}
return Status.OK_STATUS;
}
};
job.setUser(true);
job.schedule();
return job;
}
Aggregations