File tree 9 files changed +379
-34
lines changed
output/basic-project/test
9 files changed +379
-34
lines changed Original file line number Diff line number Diff line change 2
2
.DS_Store
3
3
index.scip
4
4
snapshots /input /staging-project /lib /**
5
- snapshots /output /staging-project /lib /**
5
+ snapshots /output /staging-project /lib /**
Original file line number Diff line number Diff line change @@ -14,21 +14,11 @@ dart pub global activate scip_dart
14
14
15
15
The following command will output a ` index.scip ` file
16
16
``` 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 ./
18
20
```
19
21
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
-
32
22
This file can be analyzed / displayed using the [ scip cli] ( https://github.com/sourcegraph/scip )
33
23
34
24
``` sh
Original file line number Diff line number Diff line change @@ -9,13 +9,36 @@ import 'package:scip_dart/src/flags.dart';
9
9
10
10
Future <void > main (List <String > args) async {
11
11
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
+ ))
15
29
.parse (args);
16
30
31
+
17
32
Flags .instance.init (result);
18
33
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
+
19
42
final packageRoot =
20
43
result.rest.length > 0 ? result.rest.first : Directory .current.path;
21
44
Original file line number Diff line number Diff line change @@ -7,13 +7,9 @@ class Flags {
7
7
bool get performance => _performance;
8
8
bool _performance = false ;
9
9
10
- List <String > get paths => _paths;
11
- List <String > _paths = [];
12
-
13
10
void init (ArgResults results) {
14
11
_verbose = results['verbose' ] ?? false ;
15
12
_performance = results['performance' ] ?? false ;
16
- _paths = (results['path' ] as Iterable <String >? )? .toList () ?? [];
17
13
}
18
14
19
15
static Flags get instance => _instance;
Original file line number Diff line number Diff line change @@ -28,28 +28,22 @@ Future<Index> indexPackage(
28
28
.map ((package) => p.normalize (package.packageUriRoot.toFilePath ()))
29
29
.toList ();
30
30
31
- final indexedPaths = Flags .instance.paths.map (
32
- (relPath) => p.normalize (p.join (dirPath, relPath)),
33
- );
34
31
35
32
final collection = AnalysisContextCollection (
36
33
includedPaths: [
37
34
...allPackageRoots,
38
- ...indexedPaths ,
35
+ dirPath ,
39
36
],
40
37
);
41
38
42
39
if (Flags .instance.performance) print ('Analyzing Source' );
43
40
final st = Stopwatch ()..start ();
44
41
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);
53
47
54
48
final resolvedUnits = await Future .wait (resolvedUnitFutures);
55
49
You can’t perform that action at this time.
0 commit comments