Create from usage: Extracted method from getNextAvailableName.
This commit is contained in:
@@ -1128,14 +1128,18 @@ public class CreateFunctionFromUsageFix extends CreateFromUsageFixBase {
|
||||
*/
|
||||
@NotNull
|
||||
private static String getNextAvailableName(@NotNull String name, @NotNull Collection<String> existingNames, @Nullable JetScope scope) {
|
||||
if (existingNames.contains(name) || (scope != null && scope.getClassifier(Name.identifier(name)) != null)) {
|
||||
if (isConflictingName(name, existingNames, scope)) {
|
||||
int j = 1;
|
||||
while (existingNames.contains(name + j) || (scope != null && scope.getClassifier(Name.identifier(name + j)) != null)) j++;
|
||||
while (isConflictingName(name + j, existingNames, scope)) j++;
|
||||
name += j;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
private static boolean isConflictingName(@NotNull String name, @NotNull Collection<String> existingNames, @Nullable JetScope scope) {
|
||||
return existingNames.contains(name) || (scope != null && scope.getClassifier(Name.identifier(name)) != null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static JetType[] guessTypesForExpression(@NotNull JetExpression expr, @NotNull BindingContext context) {
|
||||
JetType type = context.get(BindingContext.EXPRESSION_TYPE, expr);
|
||||
|
||||
Reference in New Issue
Block a user