Skip to content

Commit

Permalink
more work on symbol generation
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewnitschke-wk committed Feb 7, 2024
1 parent 1bd955d commit f42284a
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 29 deletions.
34 changes: 5 additions & 29 deletions lib/src/symbol_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class SymbolGenerator {
_getDescriptor(element),
].join(' ');
}

String symbolForFile(String path) {
return [
'scip-dart',
Expand All @@ -75,12 +75,14 @@ class SymbolGenerator {
}

if (uri.toString().startsWith('dart')) {
final packageVersion =
element.library!.languageVersion.package.toString();
return [
'scip-dart',
'pub $uri $packageVersion',
_getPackage(element),
_escapeNamespacePath(_pathForSdkElement(element)) + '/'
].join(' ');
} else {

}

if (uri.toString().startsWith('package')) {
Expand Down Expand Up @@ -246,32 +248,6 @@ class SymbolGenerator {
return '${_getDescriptor(encEle)}${element.name}.';
}

if (
element is LibraryImportElement ||
element is LibraryExportElement ||
element is PartElement
) {
DirectiveUriWithSource directiveUri;
if (element is LibraryImportElement) {
directiveUri = element.uri as DirectiveUriWithSource;
} else if (element is LibraryExportElement) {
directiveUri = element.uri as DirectiveUriWithSource;
} else if (element is PartElement) {
directiveUri = element.uri as DirectiveUriWithSource;
} else {
return null;
}

final config = _packageConfig.packageOf(Uri.file(sourcePath));
if (config == null) {
throw Exception('Could not find package for $sourcePath. Have you run pub get?');
}

return _escapeNamespacePath(
sourcePath.substring(config.root.toFilePath().length),
);
}

display(
'\n'
'Received unknown type (${element.runtimeType})\n'
Expand Down
7 changes: 7 additions & 0 deletions snapshots/input/basic-project/lib/nested/directives.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import 'dart:math' as math;
import 'dart:collection';
import 'package:dart_test/main.dart';
import 'package:test/fake.dart';
import '../other.dart';
export '../relationships.dart';
part 'directives_part.dart';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
part of 'directives.dart';
1 change: 1 addition & 0 deletions snapshots/output/basic-project/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:dart_test/other.dart';
// definition scip-dart pub dart_test 1.0.0 lib/`main.dart`/
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference scip-dart pub dart_test 1.0.0 lib/`other.dart`/

/// This is a fib function
///
Expand Down
1 change: 1 addition & 0 deletions snapshots/output/basic-project/lib/more.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:math' as math;
// definition scip-dart pub dart_test 1.0.0 lib/`more.dart`/
// ^^^^^^^^^^^ reference scip-dart pub dart:math 2.18.0 pub dart_test 1.0.0 package:dart_test/`more.dart`/
// ^^^^ definition scip-dart pub dart_test 1.0.0 lib/`more.dart`/math.

enum AnimalType {
Expand Down
16 changes: 16 additions & 0 deletions snapshots/output/basic-project/lib/nested/directives.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'dart:math' as math;
// definition scip-dart pub dart_test 1.0.0 lib/nested/`directives.dart`/
// ^^^^^^^^^^^ reference scip-dart pub dart:math 2.18.0 pub dart_test 1.0.0 package:dart_test/nested/`directives.dart`/
// ^^^^ definition scip-dart pub dart_test 1.0.0 lib/nested/`directives.dart`/math.
import 'dart:collection';
// ^^^^^^^^^^^^^^^^^ reference scip-dart pub dart:collection 2.18.0 pub dart_test 1.0.0 package:dart_test/nested/`directives.dart`/
import 'package:dart_test/main.dart';
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference scip-dart pub dart_test 1.0.0 lib/`main.dart`/
import 'package:test/fake.dart';
// ^^^^^^^^^^^^^^^^^^^^^^^^ reference scip-dart pub test 1.24.3 lib/`fake.dart`/
import '../other.dart';
// ^^^^^^^^^^^^^^^ reference scip-dart pub dart_test 1.0.0 lib/`other.dart`/
export '../relationships.dart';
// ^^^^^^^^^^^^^^^^^^^^^^^ reference scip-dart pub dart_test 1.0.0 lib/`relationships.dart`/
part 'directives_part.dart';
// ^^^^^^^^^^^^^^^^^^^^^^ reference scip-dart pub dart_test 1.0.0 lib/nested/`directives_part.dart`/
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
part of 'directives.dart';
// definition scip-dart pub dart_test 1.0.0 lib/nested/`directives_part.dart`/
// ^^^^^^^^^^^^^^^^^ reference scip-dart pub dart_test 1.0.0 lib/nested/`directives.dart`/
1 change: 1 addition & 0 deletions snapshots/output/basic-project/lib/other.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'more.dart' deferred as more;
// definition scip-dart pub dart_test 1.0.0 lib/`other.dart`/
// ^^^^^^^^^^^ reference scip-dart pub dart_test 1.0.0 lib/`more.dart`/
// ^^^^ definition scip-dart pub dart_test 1.0.0 lib/`other.dart`/more.

class Foo {
Expand Down
1 change: 1 addition & 0 deletions snapshots/output/basic-project/test/basic_test.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:test/test.dart';
// definition scip-dart pub dart_test 1.0.0 test/`basic_test.dart`/
// ^^^^^^^^^^^^^^^^^^^^^^^^ reference scip-dart pub test 1.24.3 lib/`test.dart`/

void main() {
// ^^^^ definition scip-dart pub dart_test 1.0.0 test/`basic_test.dart`/main().
Expand Down

0 comments on commit f42284a

Please sign in to comment.