refactoringStatistics.recordLocalTypeDeclarationNotAdded();
}
continue;
}
LocalDefn localDefn = visitor.getLocalDefn(identifier);
if (sourceRange != null){
final SourceRange functionSourceRange = localDefn.getSourceRange();
if (functionSourceRange != null){
if (!sourceRange.overlaps(functionSourceRange)){
continue;
}
}
}
Set<ModuleName> importsThatProduceConflicts = new HashSet<ModuleName>();
boolean noConflicts = updateWithUnimportedModules(unimportedModules, importsThatProduceConflicts, moduleTypeInfo, typeExpr);
if (noConflicts) {
TypeSignature typeSignature = typeExpr.toSourceModel(null, namingPolicy);
LocalDefn.Function.TypeDeclaration typeDecl = LocalDefn.Function.TypeDeclaration.make(identifier.getLocalFunctionName(), typeSignature);
boolean noLeadingNewline = visitor.doesTypeDeclNeedLeadingNewline(identifier);
final SourcePosition insertionPosition;
if (localDefn instanceof LocalDefn.Function.Definition) {
insertionPosition = ((LocalDefn.Function.Definition)localDefn).getSourceRangeExcludingCaldoc().getStartSourcePosition();
} else {
// in this case the localDefn should be a LocalDefn.PatternMatch
insertionPosition = localDefn.getSourceRange().getStartSourcePosition();
}
String insertionText = makeIndentedSourceElementText(typeDecl, insertionPosition, sourceText, noLeadingNewline);
sourceModifier.addSourceModification(new SourceModification.InsertText(insertionText, insertionPosition));
if(refactoringStatistics != null) {