fix: Dart extractor cleanup#1360
Open
Overman775 wants to merge 1 commit into
Open
Conversation
Contributor
Author
|
@safishamsi Hi! Please take a look at the PR ) |
4999f61 to
4addb00
Compare
4addb00 to
c6e5bc5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
This PR makes Dart extraction stricter about parser noise. It keeps the current regex-based approach, but avoids creating graph nodes from syntax fragments that are not project entities.
The patch covers a few cases that showed up in real Flutter code:
part of 'package:...'files now resolve throughpubspec.yamlto the parent file underlib/_and_$Foono longer become graph nodesString get,bool get,static const,static finalare filtered outFutureOr,Never,MapEntry,Iterator,Comparable,StackTrace,Exceptionare filtered from noisy type referencesextension on String/List/Map/Set/Iterable/Future/Streamand SDK typedef targets are filtered as noiseIterable<T>from an extension typeimplementsclause is filtered as noise_with MyMixinstill emitsmixes_inThis is not a Dart analyzer rewrite. It only removes false positives that showed up in real projects.
The SDK filter is intentionally conservative. It covers common
dart:coreanddart:asyncnoise, but does not try to mirror the full Dart SDK. Graphify filters by short name here, so a very broad SDK list could hide project classes with the same names.Why
The old extractor sometimes treated syntax fragments as project entities. On a real Flutter monorepo I saw nodes like:
Those nodes are not useful graph facts. They make traversal noisier because they look like real classes, methods, or types.
Real project check
I also ran the extractor against a Flutter monorepo with
1552Dart files. Extraction errors stayed at0.Noise comparison:
_labelsString getlabelsbool getlabelsstatic const/finallabelsMocknodeString/List/Map/Iterable/FuturelabelsMost structural relations stayed stable:
The two drops are intentional.
extendsdrops because SDK targets from ordinary Dart extensions are now filtered; project extension targets still remain.implementsdrops because one SDKIterable<T>edge from an extension type is now filtered.Migration note
If you already have a graph for a Dart or Flutter project, run a forced rebuild once after updating:
graphify . --forceOlder
graphify-out/graph.jsonfiles may already contain the parser-noise nodes removed here. A forced rebuild removes those stale nodes instead of carrying them through an incremental update.Notes
The new tests focus on regression cases, not every Dart grammar rule. They cover the bugs above plus Dart 3 syntax that previously had a good chance of creating fake graph nodes.