Skip to content

Commit

Permalink
fixed functions as parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewnitschke-wk committed Aug 29, 2023
1 parent 2178b99 commit 1120f49
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "scip-dart",
"request": "launch",
"program": "bin/scip_dart.dart",
"type": "dart",
"args": ["./snapshots/input/staging-project"]
}
]
}
7 changes: 7 additions & 0 deletions lib/src/scip_visitor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ class ScipVisitor extends GeneralizingAstVisitor {
final element = node.declaredElement;
if (element == null) return;

// if this parameter is a child of another parameter (usually a function
// parameter), don't register it as a declaration, it's references will be
// registered in [_visitSimpleIdentifier]
final parentParameter = node.parent?.thisOrAncestorOfType<NormalFormalParameter>();
if (parentParameter != null) return;

if (node is FieldFormalParameter) {
final fieldElement = (element as FieldFormalParameterElement).field;
_registerAsReference(
Expand Down Expand Up @@ -146,6 +152,7 @@ class ScipVisitor extends GeneralizingAstVisitor {
required int offset,
required int length,
}) {

final symbol = _symbolGenerator.symbolFor(element);
if (symbol != null) {
occurrences.add(Occurrence(
Expand Down
8 changes: 4 additions & 4 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ packages:
name: _fe_analyzer_shared
url: "https://pub.dartlang.org"
source: hosted
version: "61.0.0"
version: "54.0.0"
analyzer:
dependency: "direct main"
description:
name: analyzer
url: "https://pub.dartlang.org"
source: hosted
version: "5.13.0"
version: "5.6.0"
args:
dependency: "direct main"
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.2"
version: "2.4.1"
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

0 comments on commit 1120f49

Please sign in to comment.