Giter Site home page Giter Site logo

flutter_ast's Introduction

Dart/Flutter AST Generator

Parse a Dart or Flutter file and return a opinionated AST for use to create a dynamic widget or runtime. Works in a browser or native at runtime.

You can pass an input as a file or directory:

$ dart ./bin/generator.dart -p samples/example.dart

$ dart ./bin/generator.dart -p samples    

Or you can call the method directly:

final DartResult result = parseSource("Dart Code Here");
print(result.toJson());

Features

  • ✅ Classes
  • ✅ Enums
  • ✅ Logic Tree
  • ✅ Flutter Support
  • ✅ Top Level Methods and Variables
  • ✅ Methods
  • ✅ Fields
  • ✅ Constructors

Example

Here is a sample input:

import 'package:flutter/material.dart';

enum MyEnum { one, type, three }

const int kGlobalField = 1;

/// This is a doc comment
class MyScreen extends StatelessWidget {
  const MyScreen(this.position, {Key key, this.myField = false, this.mySecondField = 1, 
  this.numField = 3,
  this.mapField = const {},
  this.dateField,
  this.listField  = const [],
  }) : super(key: key);

  const MyScreen.alt(this.position, {Key key, this.mySecondField = double.infinity,
  this.numField = 3,
  this.mapField = const {},
  this.listField  = const [],
  this.dateField,
  }) :  this.myField = true,  super(key: key);

  static const String routeName = '/my_route';

  final bool myField;
  final double mySecondField;
  final num numField;
  final Map mapField;
  final DateTime dateField;
  final List listField;

  final int position;

  // This is a normal comment
  Map<String, dynamic> toJson() {
    return {};
  }

  @override
  Widget build(BuildContext context) {
    if (myField) {
      return mySecondField == 1 ? Container(color: Colors.red) : Container(color: Colors.blue);
    }
    return Container(
      color: Colors.red,
      width: 20,
      child: Center(
        child: Builder((context) {
          return Text('Hello World');
        }),
      ),
    );
  }
}

void myGlobalMethod() {

}

// Ignore this simple comment
class Simple {
  String value;
}

And that would produce this output:

{
  "file": {
    "name": null,
    "imports": [
      "package:flutter/material.dart"
    ],
    "classes": [
      {
        "name": "MyScreen",
        "comments": [
          "This is a doc comment"
        ],
        "fields": [
          {
            "name": "routeName",
            "type": "String"
          },
          {
            "name": "myField",
            "type": "bool"
          },
          {
            "name": "mySecondField",
            "type": "double"
          },
          {
            "name": "numField",
            "type": "num"
          },
          {
            "name": "mapField",
            "type": "Map"
          },
          {
            "name": "dateField",
            "type": "DateTime"
          },
          {
            "name": "listField",
            "type": "List"
          },
          {
            "name": "position",
            "type": "int"
          }
        ],
        "constructors": [
          {
            "name": "MyScreen",
            "properties": [
              {
                "value": null,
                "name": "key",
                "type": "Key",
                "isConst": false,
                "isFinal": false,
                "isNamed": true,
                "isOptional": true,
                "isPositional": false,
                "isRequired": false,
                "isRequiredPositional": false,
                "isSynthetic": false,
                "isRequiredNamed": false,
                "isOptionalNamed": true
              },
              {
                "value": "false",
                "name": "myField",
                "type": "bool",
                "isConst": false,
                "isFinal": false,
                "isNamed": true,
                "isOptional": true,
                "isPositional": false,
                "isRequired": false,
                "isRequiredPositional": false,
                "isSynthetic": false,
                "isRequiredNamed": false,
                "isOptionalNamed": true
              },
              {
                "value": "1",
                "name": "mySecondField",
                "type": "double",
                "isConst": false,
                "isFinal": false,
                "isNamed": true,
                "isOptional": true,
                "isPositional": false,
                "isRequired": false,
                "isRequiredPositional": false,
                "isSynthetic": false,
                "isRequiredNamed": false,
                "isOptionalNamed": true
              },
              {
                "value": "3",
                "name": "numField",
                "type": "num",
                "isConst": false,
                "isFinal": false,
                "isNamed": true,
                "isOptional": true,
                "isPositional": false,
                "isRequired": false,
                "isRequiredPositional": false,
                "isSynthetic": false,
                "isRequiredNamed": false,
                "isOptionalNamed": true
              },
              {
                "value": "const {}",
                "name": "mapField",
                "type": "Map",
                "isConst": false,
                "isFinal": false,
                "isNamed": true,
                "isOptional": true,
                "isPositional": false,
                "isRequired": false,
                "isRequiredPositional": false,
                "isSynthetic": false,
                "isRequiredNamed": false,
                "isOptionalNamed": true
              },
              {
                "value": null,
                "name": "dateField",
                "type": "DateTime",
                "isConst": false,
                "isFinal": false,
                "isNamed": true,
                "isOptional": true,
                "isPositional": false,
                "isRequired": false,
                "isRequiredPositional": false,
                "isSynthetic": false,
                "isRequiredNamed": false,
                "isOptionalNamed": true
              },
              {
                "value": "const []",
                "name": "listField",
                "type": "List",
                "isConst": false,
                "isFinal": false,
                "isNamed": true,
                "isOptional": true,
                "isPositional": false,
                "isRequired": false,
                "isRequiredPositional": false,
                "isSynthetic": false,
                "isRequiredNamed": false,
                "isOptionalNamed": true
              }
            ]
          },
          {
            "name": "alt",
            "properties": [
              {
                "value": null,
                "name": "key",
                "type": "Key",
                "isConst": false,
                "isFinal": false,
                "isNamed": true,
                "isOptional": true,
                "isPositional": false,
                "isRequired": false,
                "isRequiredPositional": false,
                "isSynthetic": false,
                "isRequiredNamed": false,
                "isOptionalNamed": true
              },
              {
                "value": null,
                "name": "mySecondField",
                "type": "double",
                "isConst": false,
                "isFinal": false,
                "isNamed": true,
                "isOptional": true,
                "isPositional": false,
                "isRequired": false,
                "isRequiredPositional": false,
                "isSynthetic": false,
                "isRequiredNamed": false,
                "isOptionalNamed": true
              },
              {
                "value": "3",
                "name": "numField",
                "type": "num",
                "isConst": false,
                "isFinal": false,
                "isNamed": true,
                "isOptional": true,
                "isPositional": false,
                "isRequired": false,
                "isRequiredPositional": false,
                "isSynthetic": false,
                "isRequiredNamed": false,
                "isOptionalNamed": true
              },
              {
                "value": "const {}",
                "name": "mapField",
                "type": "Map",
                "isConst": false,
                "isFinal": false,
                "isNamed": true,
                "isOptional": true,
                "isPositional": false,
                "isRequired": false,
                "isRequiredPositional": false,
                "isSynthetic": false,
                "isRequiredNamed": false,
                "isOptionalNamed": true
              },
              {
                "value": "const []",
                "name": "listField",
                "type": "List",
                "isConst": false,
                "isFinal": false,
                "isNamed": true,
                "isOptional": true,
                "isPositional": false,
                "isRequired": false,
                "isRequiredPositional": false,
                "isSynthetic": false,
                "isRequiredNamed": false,
                "isOptionalNamed": true
              },
              {
                "value": null,
                "name": "dateField",
                "type": "DateTime",
                "isConst": false,
                "isFinal": false,
                "isNamed": true,
                "isOptional": true,
                "isPositional": false,
                "isRequired": false,
                "isRequiredPositional": false,
                "isSynthetic": false,
                "isRequiredNamed": false,
                "isOptionalNamed": true
              }
            ]
          }
        ],
        "methods": [
          {
            "name": "toJson",
            "body": {
              "name": "method_declaration",
              "values": [
                {
                  "name": "type",
                  "props": {
                    "0": "Map<String, dynamic>"
                  }
                },
                {
                  "name": "declaration",
                  "values": []
                },
                {
                  "name": "block_body",
                  "values": [
                    {
                      "name": "block",
                      "values": [
                        {
                          "name": "return",
                          "values": [
                            {
                              "name": "value",
                              "props": {
                                "0": {
                                  "type": "Map",
                                  "value": "{}"
                                }
                              }
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            "parameters": []
          },
          {
            "name": "build",
            "body": {
              "name": "method_declaration",
              "values": [
                {
                  "name": "type",
                  "props": {
                    "0": "Widget"
                  }
                },
                {
                  "name": "declaration",
                  "values": []
                },
                {
                  "name": "block_body",
                  "values": [
                    {
                      "name": "block",
                      "values": [
                        {
                          "name": "if",
                          "values": [
                            {
                              "name": "name",
                              "props": {
                                "0": "myField"
                              }
                            },
                            {
                              "name": "block",
                              "values": [
                                {
                                  "name": "return",
                                  "values": [
                                    {
                                      "name": "conditional",
                                      "values": [
                                        {
                                          "name": "binary",
                                          "left": {
                                            "name": "name",
                                            "props": {
                                              "0": "mySecondField"
                                            }
                                          },
                                          "right": {
                                            "name": "value",
                                            "props": {
                                              "0": {
                                                "type": "int",
                                                "value": "1"
                                              }
                                            }
                                          },
                                          "operation": "=="
                                        },
                                        {
                                          "name": "constructor",
                                          "value": "Container",
                                          "arguments": {
                                            "color": null
                                          }
                                        },
                                        {
                                          "name": "constructor",
                                          "value": "Container",
                                          "arguments": {
                                            "color": null
                                          }
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "return",
                          "values": [
                            {
                              "name": "constructor",
                              "value": "Container",
                              "arguments": {
                                "color": null,
                                "width": {
                                  "name": "value",
                                  "props": {
                                    "0": {
                                      "type": "int",
                                      "value": "20"
                                    }
                                  }
                                },
                                "child": {
                                  "name": "constructor",
                                  "value": "Center",
                                  "arguments": {
                                    "child": {
                                      "name": "constructor",
                                      "value": "Builder",
                                      "arguments": {}
                                    }
                                  }
                                }
                              }
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            "parameters": []
          }
        ],
        "tree": {
          "name": null,
          "body": {
            "name": "block_body",
            "values": [
              {
                "name": "block",
                "values": [
                  {
                    "name": "if",
                    "values": [
                      {
                        "name": "name",
                        "props": {
                          "0": "myField"
                        }
                      },
                      {
                        "name": "block",
                        "values": [
                          {
                            "name": "return",
                            "values": [
                              {
                                "name": "conditional",
                                "values": [
                                  {
                                    "name": "binary",
                                    "left": {
                                      "name": "name",
                                      "props": {
                                        "0": "mySecondField"
                                      }
                                    },
                                    "right": {
                                      "name": "value",
                                      "props": {
                                        "0": {
                                          "type": "int",
                                          "value": "1"
                                        }
                                      }
                                    },
                                    "operation": "=="
                                  },
                                  {
                                    "name": "constructor",
                                    "value": "Container",
                                    "arguments": {
                                      "color": null
                                    }
                                  },
                                  {
                                    "name": "constructor",
                                    "value": "Container",
                                    "arguments": {
                                      "color": null
                                    }
                                  }
                                ]
                              }
                            ]
                          }
                        ]
                      }
                    ]
                  },
                  {
                    "name": "return",
                    "values": [
                      {
                        "name": "constructor",
                        "value": "Container",
                        "arguments": {
                          "color": null,
                          "width": {
                            "name": "value",
                            "props": {
                              "0": {
                                "type": "int",
                                "value": "20"
                              }
                            }
                          },
                          "child": {
                            "name": "constructor",
                            "value": "Center",
                            "arguments": {
                              "child": {
                                "name": "constructor",
                                "value": "Builder",
                                "arguments": {}
                              }
                            }
                          }
                        }
                      }
                    ]
                  }
                ]
              }
            ]
          },
          "parameters": []
        }
      },
      {
        "name": "Simple",
        "comments": [],
        "fields": [
          {
            "name": "value",
            "type": "String"
          }
        ],
        "constructors": [],
        "methods": []
      }
    ],
    "enums": [
      {
        "name": "MyEnum",
        "values": [
          "one",
          "type",
          "three"
        ]
      }
    ],
    "fields": [
      {
        "name": "kGlobalField",
        "type": "int"
      }
    ],
    "methods": [
      {
        "name": "myGlobalMethod",
        "body": {
          "name": "function_declaration",
          "values": [
            {
              "name": "type",
              "props": {
                "0": "void"
              }
            },
            {
              "name": "declaration",
              "values": []
            },
            {
              "name": "function",
              "values": [
                {
                  "name": "block_body",
                  "values": [
                    {
                      "name": "block",
                      "values": []
                    }
                  ]
                }
              ]
            }
          ]
        },
        "parameters": []
      }
    ]
  },
  "errors": []
}

flutter_ast's People

Contributors

rodydavis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

flutter_ast's Issues

Crash when compiling file: xxxxxx/source_span-1.7.0/lib/src/highlighter.dart

lib/cli/generator.dart:1: Warning: Interpreting this as package URI, 'package:flutter_ast/cli/generator.dart'.
Crash when compiling file:///Users/xud/.pub-cache/hosted/pub.flutter-io.cn/source_span-1.7.0/lib/src/highlighter.dart,
at character offset 3663:
Internal problem: Can't extend an unmodifiable scope.
#0 internalProblem (package:front_end/src/fasta/problems.dart:45:3)
#1 Scope.declare (package:front_end/src/fasta/scope.dart:234:7)
#2 BodyBuilder.declareVariable (package:front_end/src/fasta/kernel/body_builder.dart:428:36)
#3 BodyBuilder.endInitializedIdentifier (package:front_end/src/fasta/kernel/body_builder.dart:2085:5)
#4 Parser.parseOptionallyInitializedIdentifier (package:front_end/src/fasta/parser/parser.dart:5266:14)
#5 Parser.parseVariablesDeclarationRest (package:front_end/src/fasta/parser/parser.dart:5246:13)
#6 Parser.parseForLoopPartsMid (package:front_end/src/fasta/parser/parser.dart:5380:15)
#7 ForCondition.parse (package:front_end/src/fasta/parser/literal_entry_info_impl.dart:42:20)
#8 Parser.parseListOrSetLiteralEntry (package:front_end/src/fasta/parser/parser.dart:4235:22)
#9 Parser.parseLiteralListSuffix (package:front_end/src/fasta/parser/parser.dart:4192:15)
#10 Parser.parsePrimary (package:front_end/src/fasta/parser/parser.dart:4036:14)
#11 Parser.parseUnaryExpression (package:front_end/src/fasta/parser/parser.dart:3930:12)
#12 Parser.parsePrecedenceExpression (package:front_end/src/fasta/parser/parser.dart:3742:13)
#13 Parser.parseExpression (package:front_end/src/fasta/parser/parser.dart:3714:13)
#14 Parser.parseArgumentsRest (package:front_end/src/fasta/parser/parser.dart:4912:15)
#15 Parser.parseArguments (package:front_end/src/fasta/parser/parser.dart:4884:12)
#16 Parser.parseArgumentsOpt (package:front_end/src/fasta/parser/parser.dart:4865:14)
#17 Parser.parseSend (package:front_end/src/fasta/parser/parser.dart:4844:13)
#18 Parser.parseSendOrFunctionLiteral (package:front_end/src/fasta/parser/parser.dart:4580:12)
#19 Parser.parsePrimary (package:front_end/src/fasta/parser/parser.dart:3991:14)
#20 Parser.parseUnaryExpression (package:front_end/src/fasta/parser/parser.dart:3930:12)
#21 Parser.parsePrecedenceExpression (package:front_end/src/fasta/parser/parser.dart:3742:13)
#22 Parser.parseExpression (package:front_end/src/fasta/parser/parser.dart:3714:13)
#23 Parser.parseArgumentsRest (package:front_end/src/fasta/parser/parser.dart:4912:15)
#24 Parser.parseArguments (package:front_end/src/fasta/parser/parser.dart:4884:12)
#25 Parser.parseArgumentsOpt (package:front_end/src/fasta/parser/parser.dart:4865:14)
#26 Parser.parseSend (package:front_end/src/fasta/parser/parser.dart:4844:13)
#27 Parser.parseSendOrFunctionLiteral (package:front_end/src/fasta/parser/parser.dart:4565:14)
#28 Parser.parsePrimary (package:front_end/src/fasta/parser/parser.dart:3991:14)
#29 Parser.parsePrecedenceExpression (package:front_end/src/fasta/parser/parser.dart:3783:21)
#30 Parser.parseExpression (package:front_end/src/fasta/parser/parser.dart:3714:13)
#31 Parser.parseInitializerExpressionRest (package:front_end/src/fasta/parser/parser.dart:2574:13)
#32 Parser.parseInitializer (package:front_end/src/fasta/parser/parser.dart:2467:17)
#33 Parser.parseInitializers (package:front_end/src/fasta/parser/parser.dart:2419:15)
#34 Parser.parseInitializersOpt (package:front_end/src/fasta/parser/parser.dart:2399:14)
#35 DietListener.buildFunctionBody (package:front_end/src/fasta/source/diet_listener.dart:829:22)
#36 DietListener.endMethod (package:front_end/src/fasta/source/diet_listener.dart:587:5)
#37 Parser.parseMethod (package:front_end/src/fasta/parser/parser.dart:3066:14)
#38 Parser.parseClassOrMixinMemberImpl (package:front_end/src/fasta/parser/parser.dart:2932:15)
#39 Parser.parseClassOrMixinBody (package:front_end/src/fasta/parser/parser.dart:2737:15)
#40 Parser.parseClass (package:front_end/src/fasta/parser/parser.dart:1761:13)
#41 Parser.parseClassOrNamedMixinApplication (package:front_end/src/fasta/parser/parser.dart:1721:14)
#42 Parser.parseTopLevelKeywordDeclaration (package:front_end/src/fasta/parser/parser.dart:573:14)
#43 Parser.parseTopLevelDeclarationImpl (package:front_end/src/fasta/parser/parser.dart:465:14)
#44 Parser.parseUnit (package:front_end/src/fasta/parser/parser.dart:348:15)
#45 SourceLoader.buildBody (package:front_end/src/fasta/source/source_loader.dart:260:14)

#46 Loader.buildBodies (package:front_end/src/fasta/loader.dart:182:15)

#47 KernelTarget.buildComponent. (package:front_end/src/fasta/kernel/kernel_target.dart:293:20)

#48 withCrashReporting (package:front_end/src/fasta/crash.dart:122:24)

#49 KernelTarget.buildComponent (package:front_end/src/fasta/kernel/kernel_target.dart:291:12)

#50 generateKernelInternal. (package:front_end/src/kernel_generator_impl.dart:145:38)

#51 withCrashReporting (package:front_end/src/fasta/crash.dart:122:24)

#52 generateKernelInternal (package:front_end/src/kernel_generator_impl.dart:55:10)

#53 generateKernel. (package:front_end/src/kernel_generator_impl.dart:40:18)

#54 CompilerContext.runWithOptions. (package:front_end/src/fasta/compiler_context.dart:134:20)

#55 CompilerContext.runInContext.. (package:front_end/src/fasta/compiler_context.dart:122:46)
#56 new Future.sync (dart:async/future.dart:224:31)
#57 CompilerContext.runInContext. (package:front_end/src/fasta/compiler_context.dart:122:19)
#58 _rootRun (dart:async/zone.dart:1124:13)
#59 _CustomZone.run (dart:async/zone.dart:1021:19)
#60 _runZoned (dart:async/zone.dart:1516:10)
#61 runZoned (dart:async/zone.dart:1463:12)
#62 CompilerContext.runInContext (package:front_end/src/fasta/compiler_context.dart:121:12)
#63 CompilerContext.runWithOptions (package:front_end/src/fasta/compiler_context.dart:132:10)
#64 generateKernel (package:front_end/src/kernel_generator_impl.dart:39:32)

#65 kernelForComponent (package:front_end/src/api_prototype/kernel_generator.dart:83:17)

#66 SingleShotCompilerWrapper.compileInternal (file:///b/s/w/ir/cache/builder/sdk/pkg/vm/bin/kernel_service.dart:266:11)

#67 Compiler.compile. (file:///b/s/w/ir/cache/builder/sdk/pkg/vm/bin/kernel_service.dart:143:31)

#68 new Future. (dart:async/future.dart:176:37)
#69 _rootRun (dart:async/zone.dart:1120:38)
#70 _CustomZone.run (dart:async/zone.dart:1021:19)
#71 _CustomZone.runGuarded (dart:async/zone.dart:923:7)
#72 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:963:23)
#73 _rootRun (dart:async/zone.dart:1124:13)
#74 _CustomZone.run (dart:async/zone.dart:1021:19)
#75 _CustomZone.bindCallback. (dart:async/zone.dart:947:23)
#76 Timer._createTimer. (dart:async/runtime/libtimer_patch.dart:21:15)
#77 _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:382:19)
#78 _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416:5)
#79 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)

#0 DietListener.buildFunctionBody (package:front_end/src/fasta/source/diet_listener.dart:842:7)
#1 DietListener.endMethod (package:front_end/src/fasta/source/diet_listener.dart:587:5)
#2 Parser.parseMethod (package:front_end/src/fasta/parser/parser.dart:3066:14)
#3 Parser.parseClassOrMixinMemberImpl (package:front_end/src/fasta/parser/parser.dart:2932:15)
#4 Parser.parseClassOrMixinBody (package:front_end/src/fasta/parser/parser.dart:2737:15)
#5 Parser.parseClass (package:front_end/src/fasta/parser/parser.dart:1761:13)
#6 Parser.parseClassOrNamedMixinApplication (package:front_end/src/fasta/parser/parser.dart:1721:14)
#7 Parser.parseTopLevelKeywordDeclaration (package:front_end/src/fasta/parser/parser.dart:573:14)
#8 Parser.parseTopLevelDeclarationImpl (package:front_end/src/fasta/parser/parser.dart:465:14)
#9 Parser.parseUnit (package:front_end/src/fasta/parser/parser.dart:348:15)
#10 SourceLoader.buildBody (package:front_end/src/fasta/source/source_loader.dart:260:14)

#11 Loader.buildBodies (package:front_end/src/fasta/loader.dart:182:15)

#12 KernelTarget.buildComponent. (package:front_end/src/fasta/kernel/kernel_target.dart:293:20)

#13 withCrashReporting (package:front_end/src/fasta/crash.dart:122:24)

#14 KernelTarget.buildComponent (package:front_end/src/fasta/kernel/kernel_target.dart:291:12)

#15 generateKernelInternal. (package:front_end/src/kernel_generator_impl.dart:145:38)

#16 withCrashReporting (package:front_end/src/fasta/crash.dart:122:24)

#17 generateKernelInternal (package:front_end/src/kernel_generator_impl.dart:55:10)

#18 generateKernel. (package:front_end/src/kernel_generator_impl.dart:40:18)

#19 CompilerContext.runWithOptions. (package:front_end/src/fasta/compiler_context.dart:134:20)

#20 CompilerContext.runInContext.. (package:front_end/src/fasta/compiler_context.dart:122:46)
#21 new Future.sync (dart:async/future.dart:224:31)
#22 CompilerContext.runInContext. (package:front_end/src/fasta/compiler_context.dart:122:19)
#23 _rootRun (dart:async/zone.dart:1124:13)
#24 _CustomZone.run (dart:async/zone.dart:1021:19)
#25 _runZoned (dart:async/zone.dart:1516:10)
#26 runZoned (dart:async/zone.dart:1463:12)
#27 CompilerContext.runInContext (package:front_end/src/fasta/compiler_context.dart:121:12)
#28 CompilerContext.runWithOptions (package:front_end/src/fasta/compiler_context.dart:132:10)
#29 generateKernel (package:front_end/src/kernel_generator_impl.dart:39:32)

#30 kernelForComponent (package:front_end/src/api_prototype/kernel_generator.dart:83:17)

#31 SingleShotCompilerWrapper.compileInternal (file:///b/s/w/ir/cache/builder/sdk/pkg/vm/bin/kernel_service.dart:266:11)

#32 Compiler.compile. (file:///b/s/w/ir/cache/builder/sdk/pkg/vm/bin/kernel_service.dart:143:31)

#33 new Future. (dart:async/future.dart:176:37)
#34 _rootRun (dart:async/zone.dart:1120:38)
#35 _CustomZone.run (dart:async/zone.dart:1021:19)
#36 _CustomZone.runGuarded (dart:async/zone.dart:923:7)
#37 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:963:23)
#38 _rootRun (dart:async/zone.dart:1124:13)
#39 _CustomZone.run (dart:async/zone.dart:1021:19)
#40 _CustomZone.bindCallback. (dart:async/zone.dart:947:23)
#41 Timer._createTimer. (dart:async/runtime/libtimer_patch.dart:21:15)
#42 _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:382:19)
#43 _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416:5)
#44 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)

Why isn't JSON output ?

I execute from the command line: dart ./lib/cli/generator.dart -p samples/example.dart
But only the following is output,There is no JSON output. Why is that?
lib/cli/generator.dart: Warning: Interpreting this as package URI, 'package:flutter_ast/cli/generator.dart'.
100% [=================================================================================================================================================================================================================================================================>]-- RESULTS --
Classes: 2
Enums: 1
Imports: 1
Methods: 1
ast_generate.txt

This requires the 'non-nullable' experiment to be enabled.

Hi @rodydavis

I am trying to generate the AST using dart --enable-experiment=non-nullable .\lib\cli\generator.dart -p 'D:\dev\flutter\packages\flutter\lib\src\rendering\box.dart' but i will always run into an error This requires the 'non-nullable' experiment to be enabled..

I am using the master channel in flutter and my dart version is Dart SDK version: 2.12.0-37.0.dev (dev).

How do you get it to work :)?

compile error

$ flutter doctor -v 254 ↵
[✓] Flutter (Channel unknown, 1.22.4, on macOS 11.0.1 20B50 darwin-x64, locale zh-Hans-CN)
• Flutter version 1.22.4 at /Users/caoyubin/Documents/dart/flutter
• Framework revision 1aafb3a8b9 (4 weeks ago), 2020-11-13 09:59:28 -0800
• Engine revision 2c956a31c0
• Dart version 2.10.4
• Pub download mirror https://pub.flutter-io.cn
• Flutter download mirror https://storage.flutter-io.cn

截屏2020-12-08 下午4 44 56

Annotator support?

I would like to preface this by saying that I've been using the nodejs wrapper of flutter-ast found at https://www.npmjs.com/package/flutter-ast

First of all, thanks for this AST! Before I stumbled upon it, I didn't even know what an AST was, so I learned a lot from this package. I just wanted to ask whether this AST supports annotators (I wasn't able to find anything on them) or whether it'd be feasible to implement support for annotators in the AST, and how one would go about doing so?

The fields and properties exchange failed

I used master branch, I used the source project example.dart, the command is 'dart lib/cli/generator.dart -p samples/example.dart'. I find that the output produce with null fields and properties. Attached is the file I generated.

astgenerate.txt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.