OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library services.src.refactoring.rename_constructor; | 5 library services.src.refactoring.rename_constructor; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:analysis_server/src/protocol_server.dart' hide Element; | 9 import 'package:analysis_server/src/protocol_server.dart' hide Element; |
10 import 'package:analysis_server/src/services/correction/source_range.dart'; | 10 import 'package:analysis_server/src/services/correction/source_range.dart'; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 } | 65 } |
66 } | 66 } |
67 } | 67 } |
68 | 68 |
69 void _analyzePossibleConflicts(RefactoringStatus result) { | 69 void _analyzePossibleConflicts(RefactoringStatus result) { |
70 // check if there are members with "newName" in the same ClassElement | 70 // check if there are members with "newName" in the same ClassElement |
71 ClassElement parentClass = element.enclosingElement; | 71 ClassElement parentClass = element.enclosingElement; |
72 for (Element newNameMember in getChildren(parentClass, newName)) { | 72 for (Element newNameMember in getChildren(parentClass, newName)) { |
73 String message = format( | 73 String message = format( |
74 "Class '{0}' already declares {1} with name '{2}'.", | 74 "Class '{0}' already declares {1} with name '{2}'.", |
75 parentClass.displayName, getElementKindName(newNameMember), newName); | 75 parentClass.displayName, |
| 76 getElementKindName(newNameMember), |
| 77 newName); |
76 result.addError(message, newLocation_fromElement(newNameMember)); | 78 result.addError(message, newLocation_fromElement(newNameMember)); |
77 } | 79 } |
78 } | 80 } |
79 | 81 |
80 SourceReference _createDeclarationReference() { | 82 SourceReference _createDeclarationReference() { |
81 SourceRange sourceRange; | 83 SourceRange sourceRange; |
82 if (element.periodOffset != null) { | 84 if (element.periodOffset != null) { |
83 sourceRange = rangeStartEnd(element.periodOffset, element.nameEnd); | 85 sourceRange = rangeStartEnd(element.periodOffset, element.nameEnd); |
84 } else { | 86 } else { |
85 sourceRange = rangeStartLength(element.nameEnd, 0); | 87 sourceRange = rangeStartLength(element.nameEnd, 0); |
86 } | 88 } |
87 String file = element.source.fullName; | 89 String file = element.source.fullName; |
88 return new SourceReference(file, sourceRange, element, true, true); | 90 return new SourceReference(file, sourceRange, element, true, true); |
89 } | 91 } |
90 } | 92 } |
OLD | NEW |