glesica / dcdg.dart

Dart Class Diagram Generator
https://pub.dartlang.org/packages/dcdg
Apache License 2.0
156 stars 30 forks source link

Problem with large package and limiting scope #52

Open mingsai opened 2 years ago

mingsai commented 2 years ago

I have successfully been able to create UML diagrams for many of the packages found at.

https://github.com/julienlebren/flutter_packages

I use dcdg | pbcopy to copy the plantuml output to my clipboard on the Mac. Then I use the PlantUML integration plugin viewer on Android Studio to preview the picture.

With that plugin I am able to copy the SVG code into (.svg) files to achieve a good solution for adding the diagrams to SketchApp for layout. One could also use these on HMTL or other places.

I fail when I attempt to render the signin package as noted below. I did some basic research from other closed issues but I'd appreciate suggestions about how to get this fairly complex package to render.

Thanks for your phenomenal work on this package.

Unhandled exception:
Bad state: Unable to find the context to /Volumes/VPL/Development/flutter-workspace/flutter_packages/packages/sign_in/lib/sign_in.freezed.dart
#0      AnalysisContextCollectionImpl.contextFor (package:analyzer/src/dart/analysis/analysis_context_collection.dart:106:5)
#1      findClassElements (package:dcdg/src/find_class_elements.dart:46:39)
<asynchronous suspension>
#2      main (file:///Users/stan/.pub-cache/hosted/pub.dartlang.org/dcdg-4.0.1/bin/dcdg.dart:35:19)
<asynchronous suspension>

Note: When I try options to limit the scope of my folder search, I come up empty.

eg.
dcdg -s "lib/services"|pbcopy  

BTW: Several of the other packages were extremely large and I was successful getting them into SVG files. I do not understand the error message.

P.S. I was able to achieve 99% of what I want by removing the freezed.dart file outside of the package. My question now becomes; can you explain what the error means and how I might better handle the problem if I have a similar issue in the future? Why the behavior on freezed files? The scope question remains as well. I am obviously missing something as I was not able to scope the output.

glesica commented 2 years ago

I'm not sure exactly why it's failing but I see that the freezed package requires a newer version of the analyzer package, so it's possible that is the problem.

AlexKenbo commented 2 years ago

I'm not sure exactly why it's failing but I see that the freezed package requires a newer version of the analyzer package, so it's possible that is the problem.

dcdg does not work with the new analyzer >=3.0.0 - but it is required for freezed to work. And freezed is a structured package... Can this be fixed?

Because tortuga depends on freezed ^2.0.2 which depends on analyzer >=3.0.0 <5.0.0, analyzer >=3.0.0 <5.0.0 is required. So, because tortuga depends on analyzer ^2.6.0, version solving failed. pub get failed (1; So, because tortuga depends on analyzer ^2.6.0, version solving failed.) exit code 1

glesica commented 2 years ago

I can try to bump the analyzer dependency, but then we also risk breaking things that depend on an older analyzer version.

paulkastel commented 1 year ago

Hi @glesica! today I also came on this issue, and I figured out one conclusion: dcdg to not like anything related to code generation: It didn't work with project that had used any kind of annotation: auto_route, freezed, injectable, hive, json_annotation or package that generated translations: localizely. (so pretty popular and widely used packages from pub.dev). The moment I removed all of those dependencies from my code then dcdg correctly generated syntax for PlantUML.

Thats a bummer that it cant ignore *.g.dart or *.freezed.dart files.

This is related to whole bunch of issues here: https://github.com/glesica/dcdg.dart/issues/55 https://github.com/glesica/dcdg.dart/issues/46#issuecomment-974890404 https://github.com/glesica/dcdg.dart/issues/43 https://github.com/glesica/dcdg.dart/issues/41

And on stackoverflow: https://stackoverflow.com/q/72679594/6229867