diff --git a/Dockerfile b/Dockerfile index b2595a1..449fd74 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1 +1 @@ -FROM drydock-prod.workiva.net/workiva/dart_build_image:3 as build \ No newline at end of file +FROM scratch \ No newline at end of file diff --git a/lib/src/scip_visitor.dart b/lib/src/scip_visitor.dart index 97df531..003ecf4 100644 --- a/lib/src/scip_visitor.dart +++ b/lib/src/scip_visitor.dart @@ -84,6 +84,15 @@ class ScipVisitor extends GeneralizingAstVisitor { void _visitSimpleIdentifier(SimpleIdentifier node) { var element = node.staticElement; + // Both `.loadLibrary()`, and `.call()` are synthetic functions that + // have no definition. These should therefore should not be indexed. + if (element is FunctionElement && element.isSynthetic) { + if ([ + FunctionElement.LOAD_LIBRARY_NAME, + FunctionElement.CALL_METHOD_NAME, + ].contains(element.name)) return; + } + // [element] for assignment fields is null. If the parent node // is a `CompoundAssignmentExpression`, we know this node is referring // to an assignment line. In that case, use the read/write element attached diff --git a/snapshots/input/basic-project/lib/other.dart b/snapshots/input/basic-project/lib/other.dart index d7acee0..fb31e52 100644 --- a/snapshots/input/basic-project/lib/other.dart +++ b/snapshots/input/basic-project/lib/other.dart @@ -1,3 +1,5 @@ +import 'more.dart' deferred as more; + class Foo { int _far; Foo(this._far); @@ -11,4 +13,10 @@ class Bar { _someValue = 'asdf'; print(_someValue); } +} + +void main() { + more.loadLibrary().then((_) => { + Bar('a').someMethod.call() + }); } \ No newline at end of file diff --git a/snapshots/output/basic-project/lib/other.dart b/snapshots/output/basic-project/lib/other.dart index 08522d3..d8eadfe 100755 --- a/snapshots/output/basic-project/lib/other.dart +++ b/snapshots/output/basic-project/lib/other.dart @@ -1,5 +1,9 @@ - class Foo { + import 'more.dart' deferred as more; // definition scip-dart pub dart_test 1.0.0 lib/other.dart/ +// ^^^^ definition scip-dart pub dart_test 1.0.0 lib/other.dart/more. +// documentation ```dart + + class Foo { // ^^^ definition scip-dart pub dart_test 1.0.0 lib/other.dart/Foo# // documentation ```dart int _far; @@ -40,3 +44,17 @@ // ^^^^^^^^^^ reference local 2 } } + + void main() { +// ^^^^ definition scip-dart pub dart_test 1.0.0 lib/other.dart/main(). +// documentation ```dart + more.loadLibrary().then((_) => { +// ^^^^ reference scip-dart pub dart_test 1.0.0 lib/other.dart/more. +// ^^^^ reference scip-dart pub dart:async 2.18.0 dart:async/future.dart/Future#then(). +// ^ definition local 4 +// documentation ```dart + Bar('a').someMethod.call() +// ^^^ reference scip-dart pub dart_test 1.0.0 lib/other.dart/Bar# +// ^^^^^^^^^^ reference scip-dart pub dart_test 1.0.0 lib/other.dart/Bar#someMethod(). + }); + }