Skip to content
Draft
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
26 changes: 26 additions & 0 deletions .github/actions/setup-scip-cli/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Setup SCIP CLI
description: Sets up the SCIP cli

inputs:
version:
description: The version of the scip cli to setup
default: 0.6.0

runs:
using: composite
steps:
# scip is very small, doesn't make sense to try and cache it
- name: Install SCIP CLI
shell: bash
run: |
bash -c 'curl -L "https://github.com/sourcegraph/scip/releases/download/v${{ inputs.version }}/scip-linux-amd64.tar.gz"' | tar xzf - scip

./scip --version

RUNNER_TOOL_CACHE="/opt/hostedtoolcache"
mkdir -p "$RUNNER_TOOL_CACHE/scip/${{ inputs.version }}/x64"
mv ./scip "$RUNNER_TOOL_CACHE/scip/${{ inputs.version }}/x64"

- name: Add scip to PATH
shell: bash
run: echo "/opt/hostedtoolcache/scip/${{ inputs.version }}/x64" >> $GITHUB_PATH
24 changes: 18 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@ jobs:
build:
uses: Workiva/gha-dart-oss/.github/workflows/[email protected]

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: dart-lang/setup-dart@v1
with:
sdk: 2.19.6
- run: dart pub get

- uses: ./.github/actions/setup-scip-cli

- working-directory: test
run: |
dart ../bin/scip_dart.dart ./
scip test ./

snapshots:
runs-on: ubuntu-latest
strategy:
Expand All @@ -30,10 +46,7 @@ jobs:
sdk: 3.7.2
steps:
- uses: actions/checkout@v5
- name: Install scip cli
run: |
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: ./.github/actions/setup-scip-cli

- uses: dart-lang/setup-dart@v1
with:
Expand All @@ -48,7 +61,7 @@ jobs:
- name: Snapshots Diff Check
run: |
dart run scip_dart ./snapshots/input/${{ matrix.dir.path }} --index-pubspec
./scip snapshot --to ./snapshots/output/${{ matrix.dir.path }}
scip snapshot --to ./snapshots/output/${{ matrix.dir.path }}

if [[ -z "$(git status --porcelain ./snapshots/output/${{ matrix.dir.path }})" ]];
then
Expand All @@ -61,7 +74,6 @@ jobs:
exit 1
fi


consumer:
runs-on: ubuntu-latest
strategy:
Expand Down
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,12 @@ gen-proto:
print:
scip print ./index.scip

gen-test:
dart ./bin/scip_dart.dart ./test

.PHONY: test
test:
scip test ./test

print-ast:
dart run ./tool/ast_printer.dart ./snapshots/input/staging-project
dart run ./tool/ast_printer.dart ./snapshots/input/staging-project
20 changes: 20 additions & 0 deletions test/lib/classes.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class AClass {}
class BClass {}
class CClass {}

mixin AMixin on AClass {}
// ^^^^^^ definition scip-dart pub scip_dart_test . lib/`classes.dart`/AMixin#
// ^^^^^^ reference scip-dart pub scip_dart_test . lib/`classes.dart`/AClass#

class ComplexClass
// ^^^^^^^^^^^^ definition scip-dart pub scip_dart_test . lib/`classes.dart`/ComplexClass#
extends AClass
// ^^^^^^ reference scip-dart pub scip_dart_test . lib/`classes.dart`/AClass#
with AMixin
// ^^^^^^ reference scip-dart pub scip_dart_test . lib/`classes.dart`/AMixin#
implements CClass, BClass {}
// ^^^^^^ reference scip-dart pub scip_dart_test . lib/`classes.dart`/CClass#
// ^^^^^^ reference scip-dart pub scip_dart_test . lib/`classes.dart`/BClass#

void fn(ComplexClass c) {}
// ^^^^^^^^^^^^ reference scip-dart pub scip_dart_test . lib/`classes.dart`/ComplexClass#
48 changes: 48 additions & 0 deletions test/lib/functions.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

void main() {
withReturn();
// <- reference scip-dart pub scip_dart_test . lib/`functions.dart`/withReturn().
}

void basicFunction() {}
// ^^^^^^^^^^^^^ definition scip-dart pub scip_dart_test . lib/`functions.dart`/basicFunction().

String withReturn() => 'asdf';
// <- reference scip-dart pub dart:core . dart:core/`string.dart`/String#

void withParameters(
String pos,
//^^^^^^ reference scip-dart pub dart:core . dart:core/`string.dart`/String#
// ^^^ definition local 0
int pos2,
//^^^ reference scip-dart pub dart:core . dart:core/`int.dart`/int#
// ^^^^ definition local 1
) {}

void withNamedParameters(
String base, {
//^^^^^^ reference scip-dart pub dart:core . dart:core/`string.dart`/String#
// ^^^^ definition local .

String? name,
//^^^^^^ reference scip-dart pub dart:core . dart:core/`string.dart`/String#
// ^^^^ definition scip-dart pub scip_dart_test 1.0.0 lib/`functions.dart`/withNamedParameters().(name)

int? name2,
//^^^ reference scip-dart pub dart:core . dart:core/`int.dart`/int#
// ^^^^^ definition scip-dart pub scip_dart_test 1.0.0 lib/`functions.dart`/withNamedParameters().(name2)
}) {}

void withPositionalParameters(
String base, [
//^^^^^^ reference scip-dart pub dart:core . dart:core/`string.dart`/String#
// ^^^^ definition local .

String? pos,
//^^^^^^ reference scip-dart pub dart:core . dart:core/`string.dart`/String#
// ^^^ definition local .

int? pos2
//^^^ reference scip-dart pub dart:core . dart:core/`int.dart`/int#
// ^^^^ definition local .
]) {}
22 changes: 22 additions & 0 deletions test/lib/variables.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const foo = 'asdf';
// ^^^ definition scip-dart pub scip_dart_test . lib/`variables.dart`/foo.

final String bar = 'asdf';
// ^^^^^^ reference scip-dart pub dart:core . dart:core/`string.dart`/String#
// ^^^ definition scip-dart pub scip_dart_test . lib/`variables.dart`/bar.

var zar = 1;
// ^^^ definition scip-dart pub scip_dart_test . lib/`variables.dart`/zar.

void main() {
final variable = 'some local variable';
// ^^^^^^^^ definition local 0

print(variable);
// ^^^^^^^^ reference local 0

print(foo + bar + zar.toString());
// ^^^ reference scip-dart pub scip_dart_test . lib/`variables.dart`/foo.
// ^^^ reference scip-dart pub scip_dart_test . lib/`variables.dart`/bar.
// ^^^ reference scip-dart pub scip_dart_test . lib/`variables.dart`/zar.
}
Loading
Loading