Skip to content

Commit

Permalink
DAS: Fix comment references in refactoring/
Browse files Browse the repository at this point in the history
Change-Id: Iaf710c67029cc75e2e61c4c5761c790938a9113d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403560
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
  • Loading branch information
srawlins authored and Commit Queue committed Jan 9, 2025
1 parent 66624da commit 1790fb7
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ class ExtractLocalRefactoringImpl extends RefactoringImpl
);
}

/// Return an unique identifier for the given [Element], or `null` if
/// Return an unique identifier for the given [Element2], or `null` if
/// [element] is `null`.
int? _encodeElement(Element2? element) {
if (element == null) {
Expand All @@ -405,8 +405,9 @@ class ExtractLocalRefactoringImpl extends RefactoringImpl
return id;
}

/// Returns an [Element]-sensitive encoding of [tokens].
/// Each [Token] with a [LocalVariableElement] has a suffix of the element id.
/// Returns an [Element2]-sensitive encoding of [tokens].
/// Each [Token] with a [LocalVariableElement2] has a suffix of the element
/// ID.
///
/// So, we can distinguish different local variables with the same name, if
/// there are multiple variables with the same name are declared in the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import 'package:meta/meta.dart';
const String _tokenSeparator = '\uFFFF';

/// Adds edits to the given [change] that ensure that all the [libraries] are
/// imported into the given [targetLibrary].
/// imported into the given [targetLibrary2].
@visibleForTesting
Future<void> addLibraryImports(
AnalysisSession session,
Expand Down Expand Up @@ -667,8 +667,8 @@ final class ExtractMethodRefactoringImpl extends RefactoringImpl
return result;
}

/// Checks if [selectionRange] selects [Expression] which can be extracted,
/// and location of this [DartExpression] in AST allows extracting.
/// Checks if [_selectionRange] selects [Expression] which can be extracted,
/// and location of this [Expression] in AST allows extracting.
RefactoringStatus _checkSelection() {
if (_selectionOffset <= 0) {
return RefactoringStatus.fatal(
Expand Down Expand Up @@ -784,7 +784,7 @@ final class ExtractMethodRefactoringImpl extends RefactoringImpl
return true;
}

/// If the [selectionRange] is associated with a [FunctionExpression], return
/// If the [_selectionRange] is associated with a [FunctionExpression], return
/// this [FunctionExpression].
FunctionExpression? _findFunctionExpression() {
if (_selectionRange.length != 0) {
Expand Down Expand Up @@ -1050,7 +1050,7 @@ final class ExtractMethodRefactoringImpl extends RefactoringImpl
}
}

/// Checks if the given [element] is declared in [selectionRange].
/// Checks if the given [element] is declared in [_selectionRange].
bool _isDeclaredInSelection(Element element) {
return _selectionRange.contains(element.nameOffset);
}
Expand Down Expand Up @@ -1096,7 +1096,7 @@ final class ExtractMethodRefactoringImpl extends RefactoringImpl
return false;
}

/// Checks if [element] is referenced after [selectionRange].
/// Checks if [element] is referenced after [_selectionRange].
bool _isUsedAfterSelection(Element element) {
var visitor = _IsUsedAfterSelectionVisitor(this, element);
_parentMember!.accept(visitor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ class _ParameterOccurrence {
});
}

/// Processor for single [SearchMatch] reference to [methodElement].
/// Processor for single [SearchMatch] reference to an [Element2].
class _ReferenceProcessor {
final InlineMethodRefactoringImpl ref;
final SearchMatch reference;
Expand Down Expand Up @@ -915,7 +915,7 @@ class _SourcePart {

/// A visitor that fills [_SourcePart] with fields, parameters and variables.
class _VariablesVisitor extends GeneralizingAstVisitor<void> {
/// The [ExecutableElement] being inlined.
/// The [ExecutableElement2] being inlined.
final ExecutableElement2 methodElement;

/// The [SourceRange] of the element body.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ abstract class ExtractLocalRefactoring implements Refactoring {

/// The lengths of the expressions that would be replaced by a reference to
/// the variable. The lengths correspond to the offsets. In other words, for a
/// given expression, if the offset of that expression is offsets[i], then the
/// length of that expression is lengths[i].
/// given expression, if the offset of that expression is `offsets[i]`, then
/// the length of that expression is `lengths[i]`.
List<int> get lengths;

/// The name that the local variable should be given.
Expand Down Expand Up @@ -175,8 +175,8 @@ abstract class ExtractMethodRefactoring implements Refactoring {
/// The lengths of the expressions or statements that would be replaced by an
/// invocation of the method. The lengths correspond to the offsets.
/// In other words, for a given expression (or block of statements), if the
/// offset of that expression is offsets[i], then the length of that
/// expression is lengths[i].
/// offset of that expression is `offsets[i]`, then the length of that
/// expression is `lengths[i]`.
List<int> get lengths;

/// The name that the method should be given.
Expand Down Expand Up @@ -386,7 +386,7 @@ abstract class Refactoring {
/// This check should be quick because it is used often as arguments change.
Future<RefactoringStatus> checkInitialConditions();

/// Returns the [Change] to apply to perform this refactoring.
/// Returns the [SourceChange] to apply to perform this refactoring.
Future<SourceChange> createChange();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ class _RenameClassMemberValidator extends _BaseClassMemberValidator {
return null;
}

/// Fills [elements] with [Element]s to rename.
/// Fills [elements] with [Element2]s to rename.
Future<void> _prepareElements() async {
var element = this.element;
if (element is FieldElement2 || element is MethodElement2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import 'package:analyzer/source/source_range.dart';
import 'package:analyzer/src/generated/java_core.dart';
import 'package:analyzer_plugin/utilities/range_factory.dart';

/// A [Refactoring] for renaming [ConstructorElement]s.
/// A [Refactoring] for renaming [ConstructorElement2]s.
class RenameConstructorRefactoringImpl extends RenameRefactoringImpl {
RenameConstructorRefactoringImpl(
super.workspace,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import 'package:analyzer/source/source_range.dart';
import 'package:analyzer/src/dart/analysis/session_helper.dart';
import 'package:analyzer/src/generated/java_core.dart';

/// A [Refactoring] for renaming extension member [Element]s.
/// A [Refactoring] for renaming extension member [Element2]s.
class RenameExtensionMemberRefactoringImpl extends RenameRefactoringImpl {
final ExtensionElement2 extensionElement;

Expand Down Expand Up @@ -92,7 +92,7 @@ class RenameExtensionMemberRefactoringImpl extends RenameRefactoringImpl {
}
}

/// Helper to check if the created or renamed [Element] will cause any
/// Helper to check if the created or renamed [Element2] will cause any
/// conflicts.
class _ExtensionMemberValidator {
final SearchEngine searchEngine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:analysis_server/src/services/refactoring/legacy/refactoring.dart
import 'package:analysis_server/src/services/refactoring/legacy/rename.dart';
import 'package:analyzer/dart/element/element2.dart';

/// A [Refactoring] for renaming [LabelElement]s.
/// A [Refactoring] for renaming [LabelElement2]s.
class RenameLabelRefactoringImpl extends RenameRefactoringImpl {
RenameLabelRefactoringImpl(
super.workspace,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:analysis_server/src/services/refactoring/legacy/refactoring.dart
import 'package:analysis_server/src/services/refactoring/legacy/rename.dart';
import 'package:analyzer/dart/element/element2.dart';

/// A [Refactoring] for renaming [LibraryElement]s.
/// A [Refactoring] for renaming [LibraryElement2]s.
class RenameLibraryRefactoringImpl extends RenameRefactoringImpl {
RenameLibraryRefactoringImpl(
super.workspace,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ class ConflictValidatorVisitor extends RecursiveAstVisitor<void> {
}
}

/// A [Refactoring] for renaming [LocalElement]s (excluding [ParameterElement]).
/// A [Refactoring] for renaming [LocalElement2]s (excluding
/// [FormalParameterElement]s).
class RenameLocalRefactoringImpl extends RenameRefactoringImpl {
RenameLocalRefactoringImpl(
super.workspace,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import 'package:analysis_server/src/services/search/hierarchy.dart';
import 'package:analyzer/dart/element/element2.dart';
import 'package:analyzer/src/generated/java_core.dart';

/// A [Refactoring] for renaming [ParameterElement]s.
/// A [Refactoring] for renaming [FormalParameterElement]s.
class RenameParameterRefactoringImpl extends RenameRefactoringImpl {
List<FormalParameterElement> elements = [];

Expand Down Expand Up @@ -101,7 +101,7 @@ class RenameParameterRefactoringImpl extends RenameRefactoringImpl {
}
}

/// Fills [elements] with [Element]s to rename.
/// Fills [elements] with [Element2]s to rename.
Future<void> _prepareElements() async {
var element = element2;
if (element.isNamed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Future<RefactoringStatus> validateRenameTopLevel(
return _RenameUnitMemberValidator(searchEngine, element, name).validate();
}

/// A [Refactoring] for renaming compilation unit member [Element]s.
/// A [Refactoring] for renaming compilation unit member [Element2]s.
class RenameUnitMemberRefactoringImpl extends RenameRefactoringImpl {
final ResolvedUnitResult resolvedUnit;

Expand Down Expand Up @@ -228,7 +228,7 @@ class _BaseUnitMemberValidator {
}

/// Validates if an element with the [name] will conflict with another
/// top-level [Element] in the same library.
/// top-level [Element2] in the same library.
void _validateWillConflict() {
for (var element in library.children2) {
if (hasDisplayName(element, name)) {
Expand All @@ -242,7 +242,7 @@ class _BaseUnitMemberValidator {
}
}

/// Validates if renamed [element] will shadow any [Element] named [name].
/// Validates if renamed [element] will shadow any [Element2] named [name].
Future<void> _validateWillShadow(Element2? element) async {
var declarations = await searchEngine.searchMemberDeclarations(name);
for (var declaration in declarations) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,7 @@ class _MembersToMove {
/// The members to be moved, in groups of contiguous members.
final List<_MemberGroup> groups;

/// Initialize a newly created instance representing the [member] with the
/// given [name].
/// Initialize a newly created instance representing [groups].
_MembersToMove(this.containingFile, this.groups);

/// Return the name that should be used for the file to which the members will
Expand Down Expand Up @@ -545,7 +544,7 @@ class _SealedSubclassIndex {
}

extension on CompilationUnitMember {
/// Gets all sealed [ClassElement]s that are superclasses of this member.
/// Gets all sealed [ClassElement2]s that are superclasses of this member.
Iterable<ClassElement2> get sealedSuperclassElements {
return superclasses
.map((type) => type?.element2)
Expand Down

0 comments on commit 1790fb7

Please sign in to comment.