Remove return type from addSource().

Change-Id: Iab4ecce3cdd6f4b4034cb293f56f0c943d069b08
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169403
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov
2020-10-28 18:40:50 +00:00
committed by commit-bot@chromium.org
parent 7588ed86de
commit f8fdb4be05
8 changed files with 18 additions and 37 deletions
@@ -16,7 +16,6 @@ import 'package:analyzer/src/dart/analysis/driver.dart';
import 'package:analyzer/src/dart/analysis/driver_based_analysis_context.dart';
import 'package:analyzer/src/dart/analysis/experiments.dart';
import 'package:analyzer/src/generated/engine.dart' show AnalysisEngine;
import 'package:analyzer/src/generated/source_io.dart';
import 'package:analyzer/src/test_utilities/mock_sdk.dart';
import 'package:analyzer/src/test_utilities/package_config_file_builder.dart';
import 'package:analyzer/src/test_utilities/resource_provider_mixin.dart';
@@ -79,9 +78,8 @@ class AbstractContextTest with ResourceProviderMixin {
String get workspaceRootPath => '/home';
Source addSource(String path, String content, [Uri uri]) {
var file = newFile(path, content: content);
return file.createSource(uri);
void addSource(String path, String content) {
newFile(path, content: content);
}
Future<void> analyzeTestPackageFiles() async {
@@ -12,7 +12,6 @@ import 'package:analyzer/src/dart/ast/element_locator.dart';
import 'package:analyzer/src/dart/ast/utilities.dart';
import 'package:analyzer/src/dart/error/hint_codes.dart';
import 'package:analyzer/src/generated/java_engine.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/test_utilities/find_node.dart';
import 'package:analyzer/src/test_utilities/platform.dart';
import 'package:test/test.dart';
@@ -27,7 +26,6 @@ class AbstractSingleUnitTest extends AbstractContextTest {
String testCode;
String testFile;
Source testSource;
ResolvedUnitResult testAnalysisResult;
CompilationUnit testUnit;
CompilationUnitElement testUnitElement;
@@ -35,19 +33,19 @@ class AbstractSingleUnitTest extends AbstractContextTest {
FindNode findNode;
@override
Source addSource(String path, String content, [Uri uri]) {
void addSource(String path, String content) {
if (useLineEndingsForPlatform) {
content = normalizeNewlinesForPlatform(content);
}
return super.addSource(path, content, uri);
super.addSource(path, content);
}
void addTestSource(String code, [Uri uri]) {
void addTestSource(String code) {
if (useLineEndingsForPlatform) {
code = normalizeNewlinesForPlatform(code);
}
testCode = code;
testSource = addSource(testFile, code, uri);
addSource(testFile, code);
}
Element findElement(String name, [ElementKind kind]) {
@@ -581,7 +581,7 @@ import 'package:b/a.dart';''');
Future<void> _computeUnitAndErrors(String code) async {
addTestSource(code);
var result = await session.getResolvedUnit(testSource.fullName);
var result = await session.getResolvedUnit(testFile);
testUnit = result.unit;
testErrors = result.errors;
}
@@ -924,7 +924,7 @@ int c;
Future<void> _parseTestUnit(String code) async {
addTestSource(code);
var result = session.getParsedUnit(testSource.fullName);
var result = session.getParsedUnit(testFile);
testUnit = result.unit;
}
}
@@ -468,7 +468,7 @@ part of 'a.dart';
RefactoringWorkspace([driverFor(testFile)], searchEngine);
// Allow passing an oldName for when we don't want to rename testSource,
// but otherwise fall back to testSource.fullname
oldFile = convertPath(oldFile ?? testSource.fullName);
oldFile = convertPath(oldFile ?? testFile);
refactoring = MoveFileRefactoring(
resourceProvider, refactoringWorkspace, testAnalysisResult, oldFile);
refactoring.newFile = convertPath(newFile);
@@ -35,7 +35,7 @@ abstract class AssistProcessorTest extends AbstractSingleUnitTest {
}
@override
void addTestSource(String code, [Uri uri]) {
void addTestSource(String code) {
if (useLineEndingsForPlatform) {
code = normalizeNewlinesForPlatform(code);
}
@@ -61,7 +61,7 @@ abstract class AssistProcessorTest extends AbstractSingleUnitTest {
_length = 0;
}
}
super.addTestSource(code, uri);
super.addTestSource(code);
}
void assertExitPosition({String before, String after}) {
@@ -31,8 +31,10 @@ class TransformSetManagerTest extends AbstractContextTest {
);
addSource('/home/test/pubspec.yaml', '');
var testSource = addSource('/home/test/lib/test.dart', '');
var result = await session.getResolvedLibrary(testSource.fullName);
var testFile = convertPath('/home/test/lib/test.dart');
addSource(testFile, '');
var result = await session.getResolvedLibrary(testFile);
var sets = manager.forLibrary(result.element);
expect(sets, hasLength(2));
}
@@ -41,8 +43,9 @@ class TransformSetManagerTest extends AbstractContextTest {
// addTestPackageDependency('p1', '/.pub-cache/p1');
// addTestPackageDependency('p2', '/.pub-cache/p2');
addSource('/home/test/pubspec.yaml', '');
var testSource = addSource('/home/test/lib/test.dart', '');
var result = await session.getResolvedLibrary(testSource.fullName);
var testFile = convertPath('/home/test/lib/test.dart');
addSource(testFile, '');
var result = await session.getResolvedLibrary(testFile);
var sets = manager.forLibrary(result.element);
expect(sets, hasLength(0));
}
@@ -29,9 +29,6 @@ export 'package:analyzer/src/test_utilities/package_config_file_builder.dart';
/// A base class defining support for writing fix processor tests that are
/// specific to fixes associated with lints that use the FixKind.
abstract class FixProcessorLintTest extends FixProcessorTest {
/// The offset of the lint marker in the code being analyzed.
int lintOffset = -1;
/// Return the lint code being tested.
String get lintCode;
@@ -45,21 +42,6 @@ abstract class FixProcessorLintTest extends FixProcessorTest {
void _createAnalysisOptionsFile() {
createAnalysisOptionsFile(experiments: experiments, lints: [lintCode]);
}
/// Find the error that is to be fixed by computing the errors in the file,
/// using the [errorFilter] to filter out errors that should be ignored, and
/// expecting that there is a single remaining error. The error filter should
/// return `true` if the error should not be ignored.
@override
Future<AnalysisError> _findErrorToFix(
bool Function(AnalysisError) errorFilter,
{int length}) async {
if (lintOffset < 0) {
return super._findErrorToFix(errorFilter, length: 0);
}
return AnalysisError(
testSource, lintOffset, length ?? 0, LintCode(lintCode, '<ignored>'));
}
}
/// A base class defining support for writing fix processor tests.