Skip to content

Commit 540efbb

Browse files
srawlinsCommit Queue
authored andcommitted
analyzer: Extract some public API from WorkspacePackage
Fixes #60725 Change-Id: I63e79075d6538810ddc518e96b5bb7430e55496b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428564 Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]>
1 parent 55c5feb commit 540efbb

21 files changed

+70
-46
lines changed

pkg/analysis_server/lib/src/context_manager.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ class ContextManagerImpl implements ContextManager {
386386
/// options file at the given [path].
387387
void _analyzeAnalysisOptionsYaml(
388388
AnalysisDriver driver,
389-
WorkspacePackage? package,
389+
WorkspacePackageImpl? package,
390390
String path,
391391
) {
392392
var convertedErrors = const <protocol.AnalysisError>[];

pkg/analysis_server/lib/src/status/diagnostics.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,7 @@ class ContextsPage extends DiagnosticPageWithNav {
10951095
buf.writeln(writeOption('Workspace root', escape(workspace?.root)));
10961096
var workspaceFolder = folder.provider.getFolder(workspace!.root);
10971097

1098-
void writePackage(WorkspacePackage package) {
1098+
void writePackage(WorkspacePackageImpl package) {
10991099
buf.writeln(writeOption('Package root', escape(package.root.path)));
11001100
if (package is PubPackage) {
11011101
buf.writeln(

pkg/analyzer/api.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4860,6 +4860,13 @@ package:analyzer/utilities/package_config_file_builder.dart:
48604860
add (method: void Function({String? languageVersion, required String name, String packageUri, required String rootPath}))
48614861
copy (method: PackageConfigFileBuilder Function())
48624862
toContent (method: String Function({required String Function(String) toUriStr}))
4863+
package:analyzer/workspace/workspace.dart:
4864+
WorkspacePackage (class extends Object):
4865+
new (constructor: WorkspacePackage Function())
4866+
canHavePublicApi (getter: bool)
4867+
root (getter: Folder)
4868+
contains (method: bool Function(Source))
4869+
isInTestDirectory (method: bool Function(File))
48634870
dart:async:
48644871
Future (referenced)
48654872
Stream (referenced)

pkg/analyzer/lib/src/dart/analysis/file_state.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -485,10 +485,10 @@ class FileState {
485485
/// The [FileSource] of the file with the [uri].
486486
final FileSource source;
487487

488-
/// The [WorkspacePackage] that contains this file.
488+
/// The [WorkspacePackageImpl] that contains this file.
489489
///
490490
/// It might be `null` if the file is outside of the workspace.
491-
final WorkspacePackage? workspacePackage;
491+
final WorkspacePackageImpl? workspacePackage;
492492

493493
/// The [FeatureSet] for this file.
494494
///
@@ -1553,7 +1553,7 @@ class FileSystemState {
15531553
FeatureSet _getFeatureSet(
15541554
String path,
15551555
Uri uri,
1556-
WorkspacePackage? workspacePackage,
1556+
WorkspacePackageImpl? workspacePackage,
15571557
AnalysisOptionsImpl analysisOptions,
15581558
) {
15591559
var workspacePackageExperiments = workspacePackage?.enabledExperiments;
@@ -1574,7 +1574,7 @@ class FileSystemState {
15741574
Version _getLanguageVersion(
15751575
String path,
15761576
Uri uri,
1577-
WorkspacePackage? workspacePackage,
1577+
WorkspacePackageImpl? workspacePackage,
15781578
AnalysisOptionsImpl analysisOptions,
15791579
) {
15801580
var workspaceLanguageVersion = workspacePackage?.languageVersion;
@@ -1596,7 +1596,7 @@ class FileSystemState {
15961596
OperationPerformanceImpl? performance,
15971597
}) {
15981598
FileSource uriSource = FileSource(resource, uri);
1599-
WorkspacePackage? workspacePackage = _workspace?.findPackageFor(path);
1599+
WorkspacePackageImpl? workspacePackage = _workspace?.findPackageFor(path);
16001600
AnalysisOptionsImpl analysisOptions = _getAnalysisOptions(resource);
16011601
FeatureSet featureSet = _getFeatureSet(
16021602
path,

pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ class LibraryAnalyzer {
384384
var definingUnit = _libraryElement.definingCompilationUnit;
385385
var analysesToContextUnits = <FileAnalysis, LintRuleUnitContext>{};
386386
LintRuleUnitContext? definingContextUnit;
387-
WorkspacePackage? workspacePackage;
387+
WorkspacePackageImpl? workspacePackage;
388388
for (var fileAnalysis in _libraryFiles.values) {
389389
var linterContextUnit = LintRuleUnitContext(
390390
file: fileAnalysis.file.resource,

pkg/analyzer/lib/src/error/annotation_verifier.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ class AnnotationVerifier {
2121
/// The current library.
2222
final LibraryElement _currentLibrary;
2323

24-
/// The [WorkspacePackage] in which [_currentLibrary] is declared.
25-
final WorkspacePackage? _workspacePackage;
24+
/// The [WorkspacePackageImpl] in which [_currentLibrary] is declared.
25+
final WorkspacePackageImpl? _workspacePackage;
2626

2727
/// Whether [_currentLibrary] is part of its containing package's public API.
2828
late final bool _inPackagePublicApi =

pkg/analyzer/lib/src/error/best_practices_verifier.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
8080

8181
final WidgetPreviewVerifier _widgetPreviewVerifier;
8282

83-
/// The [WorkspacePackage] in which [_currentLibrary] is declared.
84-
final WorkspacePackage? _workspacePackage;
83+
/// The [WorkspacePackageImpl] in which [_currentLibrary] is declared.
84+
final WorkspacePackageImpl? _workspacePackage;
8585

8686
/// True if inference failures should be reported, otherwise false.
8787
final bool _strictInference;
@@ -98,7 +98,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
9898
CompilationUnit unit, {
9999
required TypeSystemImpl typeSystem,
100100
required AnalysisOptions analysisOptions,
101-
required WorkspacePackage? workspacePackage,
101+
required WorkspacePackageImpl? workspacePackage,
102102
}) : _nullType = typeProvider.nullType,
103103
_typeSystem = typeSystem,
104104
_strictInference = analysisOptions.strictInference,
@@ -1618,7 +1618,7 @@ class _InvalidAccessVerifier {
16181618

16191619
final ErrorReporter _errorReporter;
16201620
final LibraryElement _library;
1621-
final WorkspacePackage? _workspacePackage;
1621+
final WorkspacePackageImpl? _workspacePackage;
16221622

16231623
final bool _inTemplateSource;
16241624
final bool _inTestDirectory;

pkg/analyzer/lib/src/error/deprecated_member_use_verifier.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ abstract class BaseDeprecatedMemberUseVerifier {
354354
}
355355

356356
class DeprecatedMemberUseVerifier extends BaseDeprecatedMemberUseVerifier {
357-
final WorkspacePackage? _workspacePackage;
357+
final WorkspacePackageImpl? _workspacePackage;
358358
final ErrorReporter _errorReporter;
359359

360360
DeprecatedMemberUseVerifier(

pkg/analyzer/lib/src/lint/linter.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import 'package:analyzer/file_system/file_system.dart';
1616
import 'package:analyzer/src/lint/linter_visitor.dart' show NodeLintRegistry;
1717
import 'package:analyzer/src/lint/pub.dart';
1818
import 'package:analyzer/src/lint/state.dart';
19-
import 'package:analyzer/src/workspace/workspace.dart';
19+
import 'package:analyzer/workspace/workspace.dart';
2020
import 'package:meta/meta.dart';
2121

2222
export 'package:analyzer/src/lint/linter_visitor.dart' show NodeLintRegistry;

pkg/analyzer/lib/src/workspace/basic.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class BasicWorkspace extends SimpleWorkspace {
2323
}
2424

2525
@override
26-
WorkspacePackage? findPackageFor(String filePath) {
26+
WorkspacePackageImpl? findPackageFor(String filePath) {
2727
Folder folder = provider.getFolder(filePath);
2828
if (provider.pathContext.isWithin(root, folder.path)) {
2929
return theOnlyPackage;
@@ -55,7 +55,7 @@ class BasicWorkspace extends SimpleWorkspace {
5555
/// Separate from [Packages] or package maps, this class is designed to simply
5656
/// understand whether arbitrary file paths represent libraries declared within
5757
/// a given package in a [BasicWorkspace].
58-
class BasicWorkspacePackage extends WorkspacePackage {
58+
class BasicWorkspacePackage extends WorkspacePackageImpl {
5959
@override
6060
final Folder root;
6161

0 commit comments

Comments
 (0)