Skip to content

Commit

Permalink
Merge pull request #100 from jheld/dart-3-analyzer-7-support
Browse files Browse the repository at this point in the history
dart 3.3.0+, analyzer 7+
  • Loading branch information
fzyzcjy authored Jan 31, 2025
2 parents 962766e + c8e1e96 commit 245757a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
15 changes: 12 additions & 3 deletions packages/interactive/lib/src/parser.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
// ignore_for_file: implementation_imports

import 'dart:io';

import 'package:analyzer/dart/analysis/features.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/error/error.dart';
import 'package:analyzer/error/listener.dart';
import 'package:analyzer/source/line_info.dart';
Expand All @@ -13,6 +16,7 @@ import 'package:analyzer/src/generated/parser.dart';
import 'package:analyzer/src/string_source.dart';
import 'package:interactive/src/workspace_code.dart';
import 'package:logging/logging.dart';
import 'package:pub_semver/pub_semver.dart';

class InputParser {
final log = Logger('InputParser');
Expand All @@ -37,8 +41,8 @@ class InputParser {
if (declaration is ClassDeclaration) {
classMap[identifier] = ClassInfo(
rawCode: declaration.getCode(rawCode),
potentialAccessors:
_PotentialAccessorParser().parseClassDeclaration(declaration),
potentialAccessors: _PotentialAccessorParser()
.parseClassDeclaration(declaration as ClassDeclaration),
);
} else if (declaration is FunctionDeclaration) {
functionMap[identifier] = declaration.getCode(rawCode);
Expand Down Expand Up @@ -91,8 +95,13 @@ T? _tryParse<T extends AstNode>(String code, ParserClosure<T> parse) {
..configureFeatures(
featureSetForOverriding: featureSet, featureSet: featureSet);
final token = scanner.tokenize();
// actual version via sem ver is before the first space. so, we leverage the runtime's version, ignoring override currently.
final languageVersionViaRuntime = Platform.version.split(' ').first;
final parser = Parser(StringSource(code, ''), errorListener,
featureSet: featureSet, lineInfo: LineInfo.fromContent(code));
featureSet: featureSet,
lineInfo: LineInfo.fromContent(code),
languageVersion: LibraryLanguageVersion(
package: Version.parse(languageVersionViaRuntime), override: null));

final result = parse(parser, token);

Expand Down
5 changes: 3 additions & 2 deletions packages/interactive/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ version: 1.4.0
repository: https://github.com/fzyzcjy/flutter_interactive

environment:
sdk: ">=2.18.0 <3.0.0"
sdk: ">=3.3.0 <4.0.0"

dependencies:
analyzer: ">=5.0.0 <=5.2.0"
analyzer: ^7.0.0
args: ^2.3.1
cli_repl: ^0.2.3
collection: ^1.17.0
logging: ^1.1.0
path: ^1.8.2
pub_semver: ^2.1.5
vm_service: ">=9.0.0 <12.0.0"

dev_dependencies:
Expand Down

0 comments on commit 245757a

Please sign in to comment.