Skip to content

Commit e34daa8

Browse files
zandersoCommit Queue
authored and
Commit Queue
committed
Revert "[analysis_server] Analyze fix data in fix_data folder"
This reverts commit bbacf39. Reason for revert: Causing flutter/engine to fail to roll into flutter/flutter. See flutter/flutter#125363. Original change's description: > [analysis_server] Analyze fix data in fix_data folder > > Fixes part of #52126. > > Change-Id: Ib4bd7830a2f644eacedccd375c7c8dc60f040d33 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296801 > Commit-Queue: Brian Wilkerson <[email protected]> > Reviewed-by: Brian Wilkerson <[email protected]> Change-Id: I109a4b2c596ad22d73eaf0ac3e25f53a35ba5e28 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297320 Bot-Commit: Rubber Stamper <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Zach Anderson <[email protected]>
1 parent 7575e2c commit e34daa8

File tree

4 files changed

+12
-112
lines changed

4 files changed

+12
-112
lines changed

pkg/analysis_server/lib/src/context_manager.dart

Lines changed: 8 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -344,28 +344,14 @@ class ContextManagerImpl implements ContextManager {
344344
callbacks.recordAnalysisErrors(path, convertedErrors);
345345
}
346346

347-
/// Use the given analysis [driver] to analyze the content of yaml files
348-
/// inside [folder].
349-
void _analyzeFixDataFolder(
350-
AnalysisDriver driver, Folder folder, String packageName) {
351-
for (var resource in folder.getChildren()) {
352-
if (resource is File) {
353-
if (resource.shortName.endsWith('.yaml')) {
354-
_analyzeFixDataYaml(driver, resource, packageName);
355-
}
356-
} else if (resource is Folder) {
357-
_analyzeFixDataFolder(driver, resource, packageName);
358-
}
359-
}
360-
}
361-
362347
/// Use the given analysis [driver] to analyze the content of the
363-
/// given [File].
364-
void _analyzeFixDataYaml(
365-
AnalysisDriver driver, File file, String packageName) {
348+
/// data file at the given [path].
349+
void _analyzeFixDataYaml(AnalysisDriver driver, String path) {
366350
var convertedErrors = const <protocol.AnalysisError>[];
367351
try {
368-
var content = file.readAsStringSync();
352+
var file = resourceProvider.getFile(path);
353+
var packageName = file.parent.parent.shortName;
354+
var content = _readFile(path);
369355
var errorListener = RecordingErrorListener();
370356
var errorReporter = ErrorReporter(
371357
errorListener,
@@ -382,7 +368,7 @@ class ContextManagerImpl implements ContextManager {
382368
// If the file cannot be analyzed, fall through to clear any previous
383369
// errors.
384370
}
385-
callbacks.recordAnalysisErrors(file.path, convertedErrors);
371+
callbacks.recordAnalysisErrors(path, convertedErrors);
386372
}
387373

388374
/// Use the given analysis [driver] to analyze the content of the pubspec file
@@ -450,31 +436,10 @@ class ContextManagerImpl implements ContextManager {
450436
}
451437

452438
void _checkForFixDataYamlUpdate(String path) {
453-
String? extractPackageNameFromPath(String path) {
454-
String? packageName;
455-
var pathSegments = pathContext.split(path);
456-
if (pathContext.basename(path) == file_paths.fixDataYaml &&
457-
pathSegments.length >= 3) {
458-
// packageName/lib/fix_data.yaml
459-
packageName = pathSegments[pathSegments.length - 3];
460-
} else {
461-
var fixDataIndex = pathSegments.indexOf('fix_data');
462-
if (fixDataIndex >= 2) {
463-
// packageName/lib/fix_data/foo/bar/fix.yaml
464-
packageName = pathSegments[fixDataIndex - 2];
465-
}
466-
}
467-
return packageName;
468-
}
469-
470439
if (file_paths.isFixDataYaml(pathContext, path)) {
471440
var driver = getDriverFor(path);
472441
if (driver != null) {
473-
String? packageName = extractPackageNameFromPath(path);
474-
if (packageName != null) {
475-
var file = resourceProvider.getFile(path);
476-
_analyzeFixDataYaml(driver, file, packageName);
477-
}
442+
_analyzeFixDataYaml(driver, path);
478443
}
479444
}
480445
}
@@ -564,19 +529,11 @@ class ContextManagerImpl implements ContextManager {
564529
_analyzeAnalysisOptionsYaml(driver, optionsFile.path);
565530
}
566531

567-
var packageName = rootFolder.shortName;
568532
var fixDataYamlFile = rootFolder
569533
.getChildAssumingFolder('lib')
570534
.getChildAssumingFile(file_paths.fixDataYaml);
571535
if (fixDataYamlFile.exists) {
572-
_analyzeFixDataYaml(driver, fixDataYamlFile, packageName);
573-
}
574-
575-
var fixDataFolder = rootFolder
576-
.getChildAssumingFolder('lib')
577-
.getChildAssumingFolder('fix_data');
578-
if (fixDataFolder.exists) {
579-
_analyzeFixDataFolder(driver, fixDataFolder, packageName);
536+
_analyzeFixDataYaml(driver, fixDataYamlFile.path);
580537
}
581538

582539
var pubspecFile =

pkg/analysis_server/lib/src/lsp/server_capabilities_computer.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,7 @@ class ServerCapabilitiesComputer {
164164
final analysisOptionsFile = TextDocumentFilterWithScheme(
165165
language: 'yaml', scheme: 'file', pattern: '**/analysis_options.yaml');
166166
final fixDataFile = TextDocumentFilterWithScheme(
167-
language: 'yaml',
168-
scheme: 'file',
169-
pattern: '**/lib/{fix_data.yaml,fix_data/**.yaml}');
167+
language: 'yaml', scheme: 'file', pattern: '**/lib/fix_data.yaml');
170168

171169
ServerCapabilitiesComputer(this._server);
172170
ServerCapabilities computeServerCapabilities(

pkg/analysis_server/test/domain_analysis_test.dart

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -238,28 +238,6 @@ class A {}
238238
assertNoErrors(b_path);
239239
}
240240

241-
Future<void> test_fileSystem_addFile_fixDataFolderYaml() async {
242-
var path = '$testPackageLibPath/fix_data/foo.yaml';
243-
244-
newFile('$testPackageLibPath/a.dart', '');
245-
246-
await setRoots(included: [workspaceRootPath], excluded: []);
247-
248-
// No `fix_data.yaml` to analyze yet.
249-
assertNoErrorsNotification(path);
250-
251-
// Create it, will be analyzed.
252-
newFile(path, '0: 1');
253-
await pumpEventQueue();
254-
await server.onAnalysisComplete;
255-
256-
// And it has errors.
257-
assertHasErrors(path);
258-
259-
// We don't recreate analysis contexts.
260-
_assertFlushedResults([]);
261-
}
262-
263241
Future<void> test_fileSystem_addFile_fixDataYaml() async {
264242
var path = '$testPackageLibPath/fix_data.yaml';
265243

@@ -553,34 +531,6 @@ class A {}
553531
assertNoErrors(b_path);
554532
}
555533

556-
Future<void> test_fileSystem_changeFile_fixDataFolderYaml() async {
557-
var path = '$testPackageLibPath/fix_data/foo.yaml';
558-
559-
newFile('$testPackageLibPath/a.dart', '');
560-
561-
// This file has an error.
562-
newFile(path, '0: 1');
563-
564-
await setRoots(included: [workspaceRootPath], excluded: []);
565-
566-
// The file was analyzed.
567-
assertHasErrors(path);
568-
569-
// Replace with the content that does not have errors.
570-
newFile(path, r'''
571-
version: 1
572-
transforms: []
573-
''');
574-
await pumpEventQueue();
575-
await server.onAnalysisComplete;
576-
577-
// And it has errors.
578-
assertNoErrors(path);
579-
580-
// We don't recreate analysis contexts.
581-
_assertFlushedResults([]);
582-
}
583-
584534
Future<void> test_fileSystem_changeFile_fixDataYaml() async {
585535
var path = '$testPackageLibPath/fix_data.yaml';
586536

@@ -594,7 +544,7 @@ transforms: []
594544
// The file was analyzed.
595545
assertHasErrors(path);
596546

597-
// Replace with the content that does not have errors.
547+
// Replace with the context that does not have errors.
598548
newFile(path, r'''
599549
version: 1
600550
transforms: []

pkg/analyzer/lib/src/util/file_paths.dart

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ const String dotDartTool = '.dart_tool';
3131
/// The name of the data file used to specify data-driven fixes.
3232
const String fixDataYaml = 'fix_data.yaml';
3333

34-
/// The name of the data folder used to specify data-driven fixes.
35-
const String fixDataYamlFolder = 'fix_data';
36-
3734
/// The name of the package config files.
3835
const String packageConfigJson = 'package_config.json';
3936

@@ -68,12 +65,10 @@ bool isDart(p.Context pathContext, String path) {
6865
return pathContext.extension(path) == '.dart';
6966
}
7067

71-
/// Return `true` if the [path] is a `fix_data.yaml` or `fix_data/**.yaml` file.
68+
/// Return `true` if the [path] is a `fix_data.yaml` file.
7269
/// Such files specify data-driven fixes.
7370
bool isFixDataYaml(p.Context pathContext, String path) {
74-
return pathContext.basename(path) == fixDataYaml ||
75-
(pathContext.split(path).contains('fix_data') &&
76-
pathContext.extension(path) == '.yaml');
71+
return pathContext.basename(path) == fixDataYaml;
7772
}
7873

7974
/// Return `true` if the given [path] refers to a file that is assumed to be

0 commit comments

Comments
 (0)