Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v3
- name: Install scip cli
run: |
bash -c 'curl -L "https://github.com/sourcegraph/scip/releases/download/v0.2.3/scip-linux-amd64.tar.gz"' | tar xzf - scip
bash -c 'curl -L "https://github.com/sourcegraph/scip/releases/download/v0.3.0/scip-linux-amd64.tar.gz"' | tar xzf - scip
./scip --version

- uses: dart-lang/setup-dart@v1
Expand All @@ -24,15 +24,22 @@ jobs:
- name: pub get scip-dart package
run: dart pub get

- name: pub get snapshots directory
- name: pub get basic-project directory
run: dart pub get
working-directory: ./snapshots/input/basic-project

- name: pub get relationships-project directory
run: dart pub get
working-directory: ./snapshots/input/relationships-project

- name: Snapshots Diff Check
run: |
dart run scip_dart ./snapshots/input/basic-project
./scip snapshot --to ./snapshots/output/basic-project

dart run scip_dart --index-relationships ./snapshots/input/relationships-project
./scip snapshot --to ./snapshots/output/relationships-project

if [[ -z "$(git status --porcelain ./snapshots/output)" ]];
then
echo "No changes to snapshot files"
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
regen-snapshots:
dart run scip_dart ./snapshots/input/basic-project --verbose
dart run scip_dart ./snapshots/input/basic-project
scip snapshot --to ./snapshots/output/basic-project

dart run scip_dart --index-relationships ./snapshots/input/relationships-project
scip snapshot --to ./snapshots/output/relationships-project

run:
dart run scip_dart ./snapshots/input/staging-project --verbose

Expand Down
14 changes: 12 additions & 2 deletions bin/scip_dart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ import 'package:scip_dart/src/version.dart';

Future<void> main(List<String> args) async {
final result = (ArgParser()
..addFlag(
'index-relationships',
defaultsTo: false,
help: 'Whether or not to index symbol relationships. '
'This functionality is currently in alpha, and should not be '
'considered stable and accurate.',
)
..addFlag(
'performance',
aliases: ['perf'],
Expand All @@ -22,8 +29,11 @@ Future<void> main(List<String> args) async {
defaultsTo: false,
help: 'Whether or not to display debugging text during indexing',
)
..addFlag('version',
defaultsTo: false, help: 'Display the current version of scip-dart')
..addFlag(
'version',
defaultsTo: false,
help: 'Display the current version of scip-dart',
)
..addMultiOption(
'path',
abbr: 'p',
Expand Down
4 changes: 4 additions & 0 deletions lib/src/flags.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ class Flags {
bool get performance => _performance;
bool _performance = false;

bool get indexRelationships => _indexRelationships;
bool _indexRelationships = false;

void init(ArgResults results) {
_verbose = results['verbose'] as bool? ?? false;
_performance = results['performance'] as bool? ?? false;
_indexRelationships = results['index-relationships'] as bool? ?? false;
}

static Flags get instance => _instance;
Expand Down
9 changes: 8 additions & 1 deletion lib/src/scip_visitor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/source/line_info.dart';
import 'package:package_config/package_config.dart';
import 'package:pubspec_parse/pubspec_parse.dart';
import 'package:scip_dart/src/flags.dart';
import 'package:scip_dart/src/metadata.dart';
import 'package:scip_dart/src/gen/scip.pb.dart';
import 'package:scip_dart/src/relationship_generator.dart';
Expand Down Expand Up @@ -62,9 +63,15 @@ class ScipVisitor extends GeneralizingAstVisitor {
if (node.declaredElement == null) return;

final element = node.declaredElement!;

List<Relationship>? relationships;
if (Flags.instance.indexRelationships) {
relationships = relationshipsFor(node, element, _symbolGenerator);
}

_registerAsDefinition(
element,
relationships: relationshipsFor(node, element, _symbolGenerator),
relationships: relationships,
);
}

Expand Down
4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ packages:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.2"
version: "2.4.1"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

downgrade?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, thats strange

I did run a pubclean + pubget, I wonder if for whatever reason the pubspec.lock got upgraded past what a clean install results in?

async:
dependency: transitive
description:
Expand Down Expand Up @@ -175,7 +175,7 @@ packages:
name: glob
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.2"
version: "2.1.1"
graphs:
dependency: transitive
description:
Expand Down
5 changes: 5 additions & 0 deletions snapshots/input/relationships-project/pubspec.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages: {}
sdks:
dart: ">=2.18.0 <3.0.0"
5 changes: 5 additions & 0 deletions snapshots/input/relationships-project/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: dart_test
version: 1.0.0

environment:
sdk: ">=2.18.0 <3.0.0"
2 changes: 0 additions & 2 deletions snapshots/output/basic-project/lib/more.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
class Animal with SleepMixin {
// ^^^^^^ definition scip-dart pub dart_test 1.0.0 lib/more.dart/Animal#
// documentation ```dart
// relationship scip-dart pub dart_test 1.0.0 lib/more.dart/SleepMixin# implementation
// ^^^^^^^^^^ reference scip-dart pub dart_test 1.0.0 lib/more.dart/SleepMixin#
String name;
// ^^^^^^ reference scip-dart pub dart:core 2.18.0 dart:core/string.dart/String#
Expand Down Expand Up @@ -103,7 +102,6 @@
// ^^^^^^ reference scip-dart pub dart:core 2.18.0 dart:core/string.dart/String#
// ^^^^^^^^ definition scip-dart pub dart_test 1.0.0 lib/more.dart/Animal#toString().
// documentation ```dart
// relationship scip-dart pub dart:core 2.18.0 dart:core/object.dart/Object#toString(). implementation reference
return '$name the $type';
// ^^^^ reference scip-dart pub dart_test 1.0.0 lib/more.dart/Animal#name.
// ^^^^ reference scip-dart pub dart_test 1.0.0 lib/more.dart/Animal#type.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
abstract class Mammal {
// definition scip-dart pub dart_test 1.0.0 lib/relationships.dart/
// ^^^^^^ definition scip-dart pub dart_test 1.0.0 lib/relationships.dart/Mammal#
// definition scip-dart pub dart_test 1.0.0 lib/main.dart/
// ^^^^^^ definition scip-dart pub dart_test 1.0.0 lib/main.dart/Mammal#
// documentation ```dart
String get hierarchy;
// ^^^^^^ reference scip-dart pub dart:core 2.18.0 dart:core/string.dart/String#
// ^^^^^^^^^ definition scip-dart pub dart_test 1.0.0 lib/relationships.dart/Mammal#hierarchy.
// ^^^^^^^^^ definition scip-dart pub dart_test 1.0.0 lib/main.dart/Mammal#hierarchy.
// documentation ```dart
}

abstract class Animal extends Mammal {
// ^^^^^^ definition scip-dart pub dart_test 1.0.0 lib/relationships.dart/Animal#
// ^^^^^^ definition scip-dart pub dart_test 1.0.0 lib/main.dart/Animal#
// documentation ```dart
// relationship scip-dart pub dart_test 1.0.0 lib/relationships.dart/Mammal# implementation
// ^^^^^^ reference scip-dart pub dart_test 1.0.0 lib/relationships.dart/Mammal#
// relationship scip-dart pub dart_test 1.0.0 lib/main.dart/Mammal# implementation
// ^^^^^^ reference scip-dart pub dart_test 1.0.0 lib/main.dart/Mammal#
String sound() => 'NOISE!';
// ^^^^^^ reference scip-dart pub dart:core 2.18.0 dart:core/string.dart/String#
// ^^^^^ definition scip-dart pub dart_test 1.0.0 lib/relationships.dart/Animal#sound().
// ^^^^^ definition scip-dart pub dart_test 1.0.0 lib/main.dart/Animal#sound().
// documentation ```dart
}

mixin SwimAction {
// ^^^^^^^^^^ definition scip-dart pub dart_test 1.0.0 lib/relationships.dart/SwimAction#
// ^^^^^^^^^^ definition scip-dart pub dart_test 1.0.0 lib/main.dart/SwimAction#
// documentation ```dart
void execute() => print('swimming...');
// ^^^^^^^ definition scip-dart pub dart_test 1.0.0 lib/relationships.dart/SwimAction#execute().
// ^^^^^^^ definition scip-dart pub dart_test 1.0.0 lib/main.dart/SwimAction#execute().
// documentation ```dart
// ^^^^^ reference scip-dart pub dart:core 2.18.0 dart:core/print.dart/print().
}

class Dog extends Animal with SwimAction {
// ^^^ definition scip-dart pub dart_test 1.0.0 lib/relationships.dart/Dog#
// ^^^ definition scip-dart pub dart_test 1.0.0 lib/main.dart/Dog#
// documentation ```dart
// relationship scip-dart pub dart_test 1.0.0 lib/relationships.dart/Animal# implementation
// relationship scip-dart pub dart_test 1.0.0 lib/relationships.dart/Mammal# implementation
// relationship scip-dart pub dart_test 1.0.0 lib/relationships.dart/SwimAction# implementation
// ^^^^^^ reference scip-dart pub dart_test 1.0.0 lib/relationships.dart/Animal#
// ^^^^^^^^^^ reference scip-dart pub dart_test 1.0.0 lib/relationships.dart/SwimAction#
// relationship scip-dart pub dart_test 1.0.0 lib/main.dart/Animal# implementation
// relationship scip-dart pub dart_test 1.0.0 lib/main.dart/Mammal# implementation
// relationship scip-dart pub dart_test 1.0.0 lib/main.dart/SwimAction# implementation
// ^^^^^^ reference scip-dart pub dart_test 1.0.0 lib/main.dart/Animal#
// ^^^^^^^^^^ reference scip-dart pub dart_test 1.0.0 lib/main.dart/SwimAction#
@override
// ^^^^^^^^ reference scip-dart pub dart:core 2.18.0 dart:core/annotations.dart/override.
String sound() => 'woof';
// ^^^^^^ reference scip-dart pub dart:core 2.18.0 dart:core/string.dart/String#
// ^^^^^ definition scip-dart pub dart_test 1.0.0 lib/relationships.dart/Dog#sound().
// ^^^^^ definition scip-dart pub dart_test 1.0.0 lib/main.dart/Dog#sound().
// documentation ```dart
// relationship scip-dart pub dart_test 1.0.0 lib/relationships.dart/Animal#sound(). implementation reference
// relationship scip-dart pub dart_test 1.0.0 lib/main.dart/Animal#sound(). implementation reference

@override
// ^^^^^^^^ reference scip-dart pub dart:core 2.18.0 dart:core/annotations.dart/override.
String get hierarchy => 'dog.animal.mammal';
// ^^^^^^ reference scip-dart pub dart:core 2.18.0 dart:core/string.dart/String#
// ^^^^^^^^^ definition scip-dart pub dart_test 1.0.0 lib/relationships.dart/Dog#hierarchy.
// ^^^^^^^^^ definition scip-dart pub dart_test 1.0.0 lib/main.dart/Dog#hierarchy.
// documentation ```dart
// relationship scip-dart pub dart_test 1.0.0 lib/relationships.dart/Mammal#hierarchy. implementation reference
// relationship scip-dart pub dart_test 1.0.0 lib/main.dart/Mammal#hierarchy. implementation reference
}