| 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 edit.domain; | 5 library edit.domain; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/analysis_server.dart'; | 9 import 'package:analysis_server/src/analysis_server.dart'; |
| 10 import 'package:analysis_server/src/collections.dart'; | 10 import 'package:analysis_server/src/collections.dart'; |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 searchEngine, | 365 searchEngine, |
| 366 context, | 366 context, |
| 367 source); | 367 source); |
| 368 } | 368 } |
| 369 if (kind == RefactoringKind.RENAME) { | 369 if (kind == RefactoringKind.RENAME) { |
| 370 List<AstNode> nodes = server.getNodesAtOffset(file, offset); | 370 List<AstNode> nodes = server.getNodesAtOffset(file, offset); |
| 371 List<Element> elements = server.getElementsOfNodes(nodes, offset); | 371 List<Element> elements = server.getElementsOfNodes(nodes, offset); |
| 372 if (nodes.isNotEmpty && elements.isNotEmpty) { | 372 if (nodes.isNotEmpty && elements.isNotEmpty) { |
| 373 AstNode node = nodes[0]; | 373 AstNode node = nodes[0]; |
| 374 Element element = elements[0]; | 374 Element element = elements[0]; |
| 375 if (element is FieldFormalParameterElement) { |
| 376 element = (element as FieldFormalParameterElement).field; |
| 377 } |
| 375 // climb from "Class" in "new Class()" to "new Class()" | 378 // climb from "Class" in "new Class()" to "new Class()" |
| 376 if (node.parent is TypeName && | 379 if (node.parent is TypeName && |
| 377 node.parent.parent is ConstructorName && | 380 node.parent.parent is ConstructorName && |
| 378 node.parent.parent.parent is InstanceCreationExpression) { | 381 node.parent.parent.parent is InstanceCreationExpression) { |
| 379 InstanceCreationExpression creation = node.parent.parent.parent; | 382 InstanceCreationExpression creation = node.parent.parent.parent; |
| 380 node = creation; | 383 node = creation; |
| 381 element = creation.staticElement; | 384 element = creation.staticElement; |
| 382 } | 385 } |
| 383 // do create the refactoring | 386 // do create the refactoring |
| 384 refactoring = new RenameRefactoring(searchEngine, element); | 387 refactoring = new RenameRefactoring(searchEngine, element); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 } | 502 } |
| 500 if (refactoring is RenameRefactoring) { | 503 if (refactoring is RenameRefactoring) { |
| 501 RenameRefactoring renameRefactoring = refactoring; | 504 RenameRefactoring renameRefactoring = refactoring; |
| 502 RenameOptions renameOptions = params.options; | 505 RenameOptions renameOptions = params.options; |
| 503 renameRefactoring.newName = renameOptions.newName; | 506 renameRefactoring.newName = renameOptions.newName; |
| 504 return renameRefactoring.checkNewName(); | 507 return renameRefactoring.checkNewName(); |
| 505 } | 508 } |
| 506 return new RefactoringStatus(); | 509 return new RefactoringStatus(); |
| 507 } | 510 } |
| 508 } | 511 } |
| OLD | NEW |