Skip to content

Commit 71e70f5

Browse files
resolved confliucts
2 parents 0ef2de7 + 981f8c0 commit 71e70f5

File tree

9 files changed

+379
-34
lines changed

9 files changed

+379
-34
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
.DS_Store
33
index.scip
44
snapshots/input/staging-project/lib/**
5-
snapshots/output/staging-project/lib/**
5+
snapshots/output/staging-project/lib/**

README.md

+3-13
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,11 @@ dart pub global activate scip_dart
1414

1515
The following command will output a `index.scip` file
1616
```sh
17-
dart pub global run scip_dart ./path/to/project/root
17+
cd ./path/to/project/root
18+
dart pub get
19+
dart pub global run scip_dart ./
1820
```
1921

20-
> Note: by default, only `./lib` is indexed. This can be extended to include other paths using `--path/-p`
21-
>
22-
> ```bash
23-
> dart pub global run scip_dart \
24-
> -p ./lib \ # path relative to project root
25-
> -p ./test \
26-
> ./path/to/project/root
27-
>```
28-
>
29-
> Indexing test directories will impact performance of the indexer
30-
31-
3222
This file can be analyzed / displayed using the [scip cli](https://github.com/sourcegraph/scip)
3323

3424
```sh

bin/scip_dart.dart

+26-3
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,36 @@ import 'package:scip_dart/src/flags.dart';
99

1010
Future<void> main(List<String> args) async {
1111
final result = (ArgParser()
12-
..addFlag('performance', aliases: ['perf'], defaultsTo: false)
13-
..addFlag('verbose', abbr: 'v', defaultsTo: false)
14-
..addMultiOption('path', abbr: 'p', defaultsTo: ['./lib']))
12+
..addFlag(
13+
'performance',
14+
aliases: ['perf'],
15+
defaultsTo: false,
16+
help: 'Whether or not to output performance metrics during indexing',
17+
)
18+
..addFlag(
19+
'verbose',
20+
abbr: 'v',
21+
defaultsTo: false,
22+
help: 'Whether or not to display debugging text during indexing',
23+
)
24+
..addMultiOption(
25+
'path',
26+
abbr: 'p',
27+
help: 'DEPRECATED, has no effect on executed code',
28+
))
1529
.parse(args);
1630

31+
1732
Flags.instance.init(result);
1833

34+
if ((result['path'] as List<String>?)?.isNotEmpty == true) {
35+
print(
36+
'The --path/-p flag is deprecated and no longer used. '
37+
'All dart files in the provided directory are indexed by '
38+
'default.',
39+
);
40+
}
41+
1942
final packageRoot =
2043
result.rest.length > 0 ? result.rest.first : Directory.current.path;
2144

lib/src/flags.dart

-4
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,9 @@ class Flags {
77
bool get performance => _performance;
88
bool _performance = false;
99

10-
List<String> get paths => _paths;
11-
List<String> _paths = [];
12-
1310
void init(ArgResults results) {
1411
_verbose = results['verbose'] ?? false;
1512
_performance = results['performance'] ?? false;
16-
_paths = (results['path'] as Iterable<String>?)?.toList() ?? [];
1713
}
1814

1915
static Flags get instance => _instance;

lib/src/indexer.dart

+6-12
Original file line numberDiff line numberDiff line change
@@ -28,28 +28,22 @@ Future<Index> indexPackage(
2828
.map((package) => p.normalize(package.packageUriRoot.toFilePath()))
2929
.toList();
3030

31-
final indexedPaths = Flags.instance.paths.map(
32-
(relPath) => p.normalize(p.join(dirPath, relPath)),
33-
);
3431

3532
final collection = AnalysisContextCollection(
3633
includedPaths: [
3734
...allPackageRoots,
38-
...indexedPaths,
35+
dirPath,
3936
],
4037
);
4138

4239
if (Flags.instance.performance) print('Analyzing Source');
4340
final st = Stopwatch()..start();
4441

45-
final resolvedUnitFutures = indexedPaths.map((path) {
46-
final context = collection.contextFor(path);
47-
final files = context.contextRoot
48-
.analyzedFiles()
49-
.where((file) => p.extension(file) == '.dart');
50-
51-
return files.map(context.currentSession.getResolvedUnit);
52-
}).expand((resUnits) => resUnits);
42+
final context = collection.contextFor(dirPath);
43+
final resolvedUnitFutures = context.contextRoot
44+
.analyzedFiles()
45+
.where((file) => p.extension(file) == '.dart')
46+
.map(context.currentSession.getResolvedUnit);
5347

5448
final resolvedUnits = await Future.wait(resolvedUnitFutures);
5549

0 commit comments

Comments
 (0)