blob: 4d5fa5fbe640e8e42035b37209b511f4c655accb [file] [log] [blame]
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/analysis/session.dart';
import 'package:analyzer/src/dart/analysis/session_helper.dart';
/// The context in which a refactoring was requested.
class RefactoringContext {
/// The result of resolving the compilation unit in which a refactoring was
/// requested.
final ResolvedUnitResult resolvedResult;
/// The offset to the beginning of the selection range.
final int selectionOffset;
/// The number of selected characters.
final int selectionLength;
/// The helper used to efficiently access resolved units.
late final AnalysisSessionHelper sessionHelper =
AnalysisSessionHelper(session);
/// Initialize a newly created context based on the [resolvedResult].
RefactoringContext({
required this.resolvedResult,
required this.selectionOffset,
required this.selectionLength,
});
/// Return the analysis session in which additional resolution can occur.
AnalysisSession get session => resolvedResult.session;
}