Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEA-3236: Latest scip cli and diagnostic snapshot generation #112

Merged
merged 5 commits into from
Jan 28, 2024
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
44 changes: 5 additions & 39 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.3.0/scip-linux-amd64.tar.gz"' | tar xzf - scip
bash -c 'curl -L "https://github.com/sourcegraph/scip/releases/download/v0.3.3/scip-linux-amd64.tar.gz"' | tar xzf - scip
./scip --version

- uses: dart-lang/setup-dart@v1
Expand All @@ -28,50 +28,17 @@ jobs:
run: dart pub get
working-directory: ./snapshots/input/basic-project

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

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

if [[ -z "$(git status --porcelain ./snapshots/output)" ]];
then
echo "No changes to snapshot files"
else
echo
echo "Snapshot diff detected differences, run 'make gen-snaps' to re-generate snapshots"
git status --short ./snapshots/output
echo
exit 1
fi

snapshots-diagnostics:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install scip cli
run: |
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
with:
sdk: 2.18.7
- name: pub get scip-dart package
run: dart pub get

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

- name: Install jq
uses: dcarbone/[email protected]

- name: Snapshots Diff Check
run: |
make gen-snap_diagnostics
dart run scip_dart ./snapshots/input/diagnostics
./scip snapshot --to ./snapshots/output/diagnostics

if [[ -z "$(git status --porcelain ./snapshots/output)" ]];
then
Expand All @@ -86,7 +53,6 @@ jobs:

consumer:
runs-on: ubuntu-latest

strategy:
matrix:
repo: [
Expand Down
10 changes: 2 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
gen-snaps:
make gen-snap_basic-project
make gen-snap_relationships-project
make gen-snap_diagnostics

gen-snap_basic-project:
regen-snapshots:
dart run scip_dart ./snapshots/input/basic-project
scip snapshot --to ./snapshots/output/basic-project

gen-snap_diagnostics:
dart run scip_dart ./snapshots/input/diagnostics
scip print --json ./index.scip | jq '.documents[].occurrences[] | select(.diagnostics)' | jq -s . > ./snapshots/output/diagnostics/output.json
scip snapshot --to ./snapshots/output/diagnostics

run:
dart run scip_dart ./snapshots/input/staging-project --verbose
Expand Down
140 changes: 96 additions & 44 deletions snapshots/output/basic-project/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,107 +1,159 @@
import 'package:dart_test/other.dart';
// definition scip-dart pub dart_test 1.0.0 lib/main.dart/
// definition scip-dart pub dart_test 1.0.0 lib/`main.dart`/

/// This is a fib function
///
/// Takes a number
/// Returns a number
int fib(int n) {
//^^^ reference scip-dart pub dart:core 2.19.0 dart:core/int.dart/int#
// ^^^ definition scip-dart pub dart_test 1.0.0 lib/main.dart/fib().
// documentation ```dart
// documentation This is a fib function
// ^^^ reference scip-dart pub dart:core 2.19.0 dart:core/int.dart/int#
//^^^ reference scip-dart pub dart:core 2.19.0 dart:core/`int.dart`/int#
// ^^^ definition scip-dart pub dart_test 1.0.0 lib/`main.dart`/fib().
// documentation
// > ```dart
// > int fib(int n)
// > ```
// documentation
// > This is a fib function
// > Takes a number
// > Returns a number
// ^^^ reference scip-dart pub dart:core 2.19.0 dart:core/`int.dart`/int#
// ^ definition local 0
// documentation ```dart
// documentation
// > ```dart
// > int n
// > ```
if (n <= 1) return 0;
// ^ reference local 0
return fib(n - 1) + fib(n - 2);
// ^^^ reference scip-dart pub dart_test 1.0.0 lib/main.dart/fib().
// ^^^ reference scip-dart pub dart_test 1.0.0 lib/`main.dart`/fib().
// ^ reference local 0
// ^^^ reference scip-dart pub dart_test 1.0.0 lib/main.dart/fib().
// ^^^ reference scip-dart pub dart_test 1.0.0 lib/`main.dart`/fib().
// ^ reference local 0
}

void print_fib(int a) {
// ^^^^^^^^^ definition scip-dart pub dart_test 1.0.0 lib/main.dart/print_fib().
// documentation ```dart
// ^^^ reference scip-dart pub dart:core 2.19.0 dart:core/int.dart/int#
// ^^^^^^^^^ definition scip-dart pub dart_test 1.0.0 lib/`main.dart`/print_fib().
// documentation
// > ```dart
// > void print_fib(int a)
// > ```
// ^^^ reference scip-dart pub dart:core 2.19.0 dart:core/`int.dart`/int#
// ^ definition local 1
// documentation ```dart
// documentation
// > ```dart
// > int a
// > ```
print(fib(a));
// ^^^^^ reference scip-dart pub dart:core 2.19.0 dart:core/print.dart/print().
// ^^^ reference scip-dart pub dart_test 1.0.0 lib/main.dart/fib().
// ^^^^^ reference scip-dart pub dart:core 2.19.0 dart:core/`print.dart`/print().
// ^^^ reference scip-dart pub dart_test 1.0.0 lib/`main.dart`/fib().
// ^ reference local 1
}

final y = 'Hello';
// ^ definition scip-dart pub dart_test 1.0.0 lib/main.dart/y.
// documentation ```dart
// ^ definition scip-dart pub dart_test 1.0.0 lib/`main.dart`/y.
// documentation
// > ```dart
// > String y
// > ```
String capture() {
//^^^^^^ reference scip-dart pub dart:core 2.19.0 dart:core/string.dart/String#
// ^^^^^^^ definition scip-dart pub dart_test 1.0.0 lib/main.dart/capture().
// documentation ```dart
//^^^^^^ reference scip-dart pub dart:core 2.19.0 dart:core/`string.dart`/String#
// ^^^^^^^ definition scip-dart pub dart_test 1.0.0 lib/`main.dart`/capture().
// documentation
// > ```dart
// > String capture()
// > ```
return y;
// ^ reference scip-dart pub dart_test 1.0.0 lib/main.dart/y.
// ^ reference scip-dart pub dart_test 1.0.0 lib/`main.dart`/y.
}

final capture_lambda = () => y;
// ^^^^^^^^^^^^^^ definition scip-dart pub dart_test 1.0.0 lib/main.dart/capture_lambda.
// documentation ```dart
// ^ reference scip-dart pub dart_test 1.0.0 lib/main.dart/y.
// ^^^^^^^^^^^^^^ definition scip-dart pub dart_test 1.0.0 lib/`main.dart`/capture_lambda.
// documentation
// > ```dart
// > String Function() capture_lambda
// > ```
// ^ reference scip-dart pub dart_test 1.0.0 lib/`main.dart`/y.

void main() {
// ^^^^ definition scip-dart pub dart_test 1.0.0 lib/main.dart/main().
// documentation ```dart
// ^^^^ definition scip-dart pub dart_test 1.0.0 lib/`main.dart`/main().
// documentation
// > ```dart
// > void main()
// > ```
for (var i = 0; i <= 10; i++) {}
// ^ definition local 2
// documentation ```dart
// documentation
// > ```dart
// > int i
// > ```
// ^ reference local 2
// ^ reference local 2

for (var i in [1, 2, 3]) {
// ^ definition local 3
// documentation ```dart
// documentation
// > ```dart
// > int i
// > ```
print(i);
// ^^^^^ reference scip-dart pub dart:core 2.19.0 dart:core/print.dart/print().
// ^^^^^ reference scip-dart pub dart:core 2.19.0 dart:core/`print.dart`/print().
// ^ reference local 3
}

var a = 0;
// ^ definition local 4
// documentation ```dart
// documentation
// > ```dart
// > int a
// > ```
a = 1;
// ^ reference local 4
print_fib(a);
// ^^^^^^^^^ reference scip-dart pub dart_test 1.0.0 lib/main.dart/print_fib().
// ^^^^^^^^^ reference scip-dart pub dart_test 1.0.0 lib/`main.dart`/print_fib().
// ^ reference local 4
}

void forever() {
// ^^^^^^^ definition scip-dart pub dart_test 1.0.0 lib/main.dart/forever().
// documentation ```dart
// ^^^^^^^ definition scip-dart pub dart_test 1.0.0 lib/`main.dart`/forever().
// documentation
// > ```dart
// > void forever()
// > ```
return forever();
// ^^^^^^^ reference scip-dart pub dart_test 1.0.0 lib/main.dart/forever().
// ^^^^^^^ reference scip-dart pub dart_test 1.0.0 lib/`main.dart`/forever().
}

class SomeLocalClass {}
// ^^^^^^^^^^^^^^ definition scip-dart pub dart_test 1.0.0 lib/main.dart/SomeLocalClass#
// documentation ```dart
// ^^^^^^^^^^^^^^ definition scip-dart pub dart_test 1.0.0 lib/`main.dart`/SomeLocalClass#
// documentation
// > ```dart
// > class SomeLocalClass
// > ```

/// Reference parameter: [value]
// ^^^^^ reference local 5
/// Reference class: [SomeLocalClass]
// ^^^^^^^^^^^^^^ reference scip-dart pub dart_test 1.0.0 lib/main.dart/SomeLocalClass#
// ^^^^^^^^^^^^^^ reference scip-dart pub dart_test 1.0.0 lib/`main.dart`/SomeLocalClass#
/// Reference external class: [Foo]
// ^^^ reference scip-dart pub dart_test 1.0.0 lib/other.dart/Foo#
// ^^^ reference scip-dart pub dart_test 1.0.0 lib/`other.dart`/Foo#
/// Missing Reference: [IDontExist]
void someFunction(int value) {
// ^^^^^^^^^^^^ definition scip-dart pub dart_test 1.0.0 lib/main.dart/someFunction().
// documentation ```dart
// documentation Reference parameter: [value]
// ^^^ reference scip-dart pub dart:core 2.19.0 dart:core/int.dart/int#
// ^^^^^^^^^^^^ definition scip-dart pub dart_test 1.0.0 lib/`main.dart`/someFunction().
// documentation
// > ```dart
// > void someFunction(int value)
// > ```
// documentation
// > Reference parameter: [value]
// > Reference class: [SomeLocalClass]
// > Reference external class: [Foo]
// > Missing Reference: [IDontExist]
// ^^^ reference scip-dart pub dart:core 2.19.0 dart:core/`int.dart`/int#
// ^^^^^ definition local 5
// documentation ```dart
// documentation
// > ```dart
// > int value
// > ```
Foo(1);
// ^^^ reference scip-dart pub dart_test 1.0.0 lib/other.dart/Foo#
// ^^^ reference scip-dart pub dart_test 1.0.0 lib/`other.dart`/Foo#
}
Loading
Loading