Skip to content

Commit dbcae85

Browse files
committed
More test cleanup, removed unused dependency
1 parent e6df15d commit dbcae85

File tree

4 files changed

+5
-169
lines changed

4 files changed

+5
-169
lines changed

json_serializable/pubspec.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ dependencies:
99
analyzer: '>=0.29.10 <0.32.0'
1010
build: '>=0.9.0 <0.13.0'
1111
build_config: ^0.2.6
12-
cli_util: ^0.1.0
1312

1413
# Use a tight version constraint to ensure that a constraint on
1514
# `json_annotation`. Properly constrains all features it provides.

json_serializable/test/analysis_utils.dart

Lines changed: 4 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,20 @@
55
import 'dart:async';
66
import 'dart:io';
77

8-
import 'package:analyzer/dart/element/element.dart';
98
import 'package:analyzer/file_system/file_system.dart' hide File;
109
import 'package:analyzer/file_system/physical_file_system.dart';
1110
import 'package:analyzer/source/package_map_resolver.dart';
1211
import 'package:analyzer/source/pub_package_map_provider.dart';
1312
import 'package:analyzer/src/dart/sdk/sdk.dart' show FolderBasedDartSdk;
1413
import 'package:analyzer/src/generated/engine.dart';
15-
import 'package:analyzer/src/generated/java_io.dart';
1614
import 'package:analyzer/src/generated/source.dart';
1715
import 'package:analyzer/src/generated/source_io.dart';
18-
import 'package:cli_util/cli_util.dart' as cli;
1916
import 'package:path/path.dart' as p;
2017

21-
/// [foundFiles] is the list of files to consider for the context.
2218
Future<AnalysisContext> getAnalysisContextForProjectPath(
23-
String projectPath, List<String> foundFiles) async {
19+
String projectPath) async {
2420
// TODO: fail more clearly if this...fails
25-
var sdkPath = cli.getSdkPath();
21+
var sdkPath = _getSdkPath();
2622

2723
var resourceProvider = PhysicalResourceProvider.INSTANCE;
2824
var sdk = new FolderBasedDartSdk(
@@ -44,9 +40,6 @@ Future<AnalysisContext> getAnalysisContextForProjectPath(
4440
..analysisOptions = options
4541
..sourceFactory = new SourceFactory(resolvers);
4642

47-
// ensures all libraries defined by the set of files are resolved
48-
_getLibraryElements(foundFiles, context).toList();
49-
5043
return context;
5144
}
5245

@@ -71,43 +64,5 @@ UriResolver _getPackageResolver(String projectPath, FolderBasedDartSdk sdk) {
7164
PhysicalResourceProvider.INSTANCE, packageMap);
7265
}
7366

74-
LibraryElement getLibraryElementForSourceFile(
75-
AnalysisContext context, String sourcePath) {
76-
Source source = new FileBasedSource(new JavaFile(sourcePath));
77-
78-
var libs = context.getLibrariesContaining(source);
79-
80-
if (libs.length > 1) {
81-
throw new Exception("We don't support multiple libraries for a source.");
82-
}
83-
84-
if (libs.isEmpty) {
85-
return null;
86-
}
87-
88-
var libSource = libs.single;
89-
90-
// using `getLibraryElement` because the library should already be computed
91-
// If not, it's a bug in usage
92-
return context.getLibraryElement(libSource);
93-
}
94-
95-
// may return `null` if [path] doesn't refer to a library.
96-
/// [dartFiles] is a [Stream] of paths to [.dart] files.
97-
Iterable<LibraryElement> _getLibraryElements(
98-
List<String> dartFiles, AnalysisContext context) =>
99-
dartFiles
100-
.map((path) => _getLibraryElement(path, context))
101-
.where((lib) => lib != null);
102-
103-
LibraryElement _getLibraryElement(String path, AnalysisContext context) {
104-
Source source = new FileBasedSource(new JavaFile(path));
105-
if (context.computeKindOf(source) == SourceKind.LIBRARY) {
106-
return context.computeLibraryElement(source);
107-
}
108-
return null;
109-
}
110-
111-
String getFileBasedSourcePath(FileBasedSource source) {
112-
return p.fromUri(source.uri);
113-
}
67+
/// Return the path to the current Dart SDK.
68+
String _getSdkPath() => p.dirname(p.dirname(Platform.resolvedExecutable));

json_serializable/test/json_serializable_test.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import 'package:source_gen/source_gen.dart';
2020
import 'package:test/test.dart';
2121

2222
import 'analysis_utils.dart';
23-
import 'src/io.dart';
2423
import 'test_utils.dart';
2524

2625
void main() {
@@ -419,10 +418,7 @@ Future<CompilationUnit> _getCompilationUnitForString(String projectPath) async {
419418
var source =
420419
new StringSource(new File(filePath).readAsStringSync(), 'test content');
421420

422-
var foundFiles = await getDartFiles(projectPath,
423-
searchList: [p.join(getPackagePath(), 'test', 'test_files')]);
424-
425-
var context = await getAnalysisContextForProjectPath(projectPath, foundFiles);
421+
var context = await getAnalysisContextForProjectPath(projectPath);
426422

427423
var libElement = context.computeLibraryElement(source);
428424
return context.resolveCompilationUnit(source, libElement);

json_serializable/test/src/io.dart

Lines changed: 0 additions & 114 deletions
This file was deleted.

0 commit comments

Comments
 (0)