chore: adopt Dart 3.9 toolchain — honest floor + tall-style reformat (T-353)
Raise the declared minimums in pubspec.yaml to what our deps already require: Flutter >=3.35.0 / Dart >=3.9.0 (was 3.19.0 / 3.5.0). alchemist 0.12 needs Flutter 3.32; Dart 3.9 first ships in Flutter 3.35, so 3.35 is the binding floor. Pin the exact build toolchain in .fvmrc (Flutter 3.44.1). Moving to the Dart 3.9 language level switches `dart format` to the new "tall" style and enables two new lints. This commit is the resulting mechanical churn, isolated from any behaviour change: - whole-tree `dart format` reformat (tall style) - `dart fix` for unnecessary_underscores + use_null_aware_elements No runtime behaviour change; `make test` green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -124,28 +124,28 @@ typedef DWasmEngineDelete = void Function(Pointer<TSWasmEngine>);
|
||||
|
||||
class TreeSitterLib {
|
||||
TreeSitterLib._(DynamicLibrary lib)
|
||||
: parserNew = lib.lookupFunction<_TsParserNew, DTsParserNew>('ts_parser_new'),
|
||||
parserDelete = lib.lookupFunction<_TsParserDelete, DTsParserDelete>('ts_parser_delete'),
|
||||
parserSetLanguage = lib.lookupFunction<_TsParserSetLanguage, DTsParserSetLanguage>('ts_parser_set_language'),
|
||||
parserSetWasmStore = lib.lookupFunction<_TsParserSetWasmStore, DTsParserSetWasmStore>('ts_parser_set_wasm_store'),
|
||||
parserParseString = lib.lookupFunction<_TsParserParseString, DTsParserParseString>('ts_parser_parse_string'),
|
||||
treeDelete = lib.lookupFunction<_TsTreeDelete, DTsTreeDelete>('ts_tree_delete'),
|
||||
treeRootNode = lib.lookupFunction<_TsTreeRootNode, DTsTreeRootNode>('ts_tree_root_node'),
|
||||
nodeStartByte = lib.lookupFunction<_TsNodeStartByte, DTsNodeStartByte>('ts_node_start_byte'),
|
||||
nodeEndByte = lib.lookupFunction<_TsNodeEndByte, DTsNodeEndByte>('ts_node_end_byte'),
|
||||
queryNew = lib.lookupFunction<_TsQueryNew, DTsQueryNew>('ts_query_new'),
|
||||
queryDelete = lib.lookupFunction<_TsQueryDelete, DTsQueryDelete>('ts_query_delete'),
|
||||
queryCaptureCount = lib.lookupFunction<_TsQueryCaptureCount, DTsQueryCaptureCount>('ts_query_capture_count'),
|
||||
queryCaptureNameForId = lib.lookupFunction<_TsQueryCaptureNameForId, DTsQueryCaptureNameForId>('ts_query_capture_name_for_id'),
|
||||
queryCursorNew = lib.lookupFunction<_TsQueryCursorNew, DTsQueryCursorNew>('ts_query_cursor_new'),
|
||||
queryCursorDelete = lib.lookupFunction<_TsQueryCursorDelete, DTsQueryCursorDelete>('ts_query_cursor_delete'),
|
||||
queryCursorExec = lib.lookupFunction<_TsQueryCursorExec, DTsQueryCursorExec>('ts_query_cursor_exec'),
|
||||
queryCursorNextMatch = lib.lookupFunction<_TsQueryCursorNextMatch, DTsQueryCursorNextMatch>('ts_query_cursor_next_match'),
|
||||
wasmStoreNew = lib.lookupFunction<_TsWasmStoreNew, DTsWasmStoreNew>('ts_wasm_store_new'),
|
||||
wasmStoreDelete = lib.lookupFunction<_TsWasmStoreDelete, DTsWasmStoreDelete>('ts_wasm_store_delete'),
|
||||
wasmStoreLoadLanguage = lib.lookupFunction<_TsWasmStoreLoadLanguage, DTsWasmStoreLoadLanguage>('ts_wasm_store_load_language'),
|
||||
wasmEngineNew = lib.lookupFunction<_WasmEngineNew, DWasmEngineNew>('wasm_engine_new'),
|
||||
wasmEngineDelete = lib.lookupFunction<_WasmEngineDelete, DWasmEngineDelete>('wasm_engine_delete');
|
||||
: parserNew = lib.lookupFunction<_TsParserNew, DTsParserNew>('ts_parser_new'),
|
||||
parserDelete = lib.lookupFunction<_TsParserDelete, DTsParserDelete>('ts_parser_delete'),
|
||||
parserSetLanguage = lib.lookupFunction<_TsParserSetLanguage, DTsParserSetLanguage>('ts_parser_set_language'),
|
||||
parserSetWasmStore = lib.lookupFunction<_TsParserSetWasmStore, DTsParserSetWasmStore>('ts_parser_set_wasm_store'),
|
||||
parserParseString = lib.lookupFunction<_TsParserParseString, DTsParserParseString>('ts_parser_parse_string'),
|
||||
treeDelete = lib.lookupFunction<_TsTreeDelete, DTsTreeDelete>('ts_tree_delete'),
|
||||
treeRootNode = lib.lookupFunction<_TsTreeRootNode, DTsTreeRootNode>('ts_tree_root_node'),
|
||||
nodeStartByte = lib.lookupFunction<_TsNodeStartByte, DTsNodeStartByte>('ts_node_start_byte'),
|
||||
nodeEndByte = lib.lookupFunction<_TsNodeEndByte, DTsNodeEndByte>('ts_node_end_byte'),
|
||||
queryNew = lib.lookupFunction<_TsQueryNew, DTsQueryNew>('ts_query_new'),
|
||||
queryDelete = lib.lookupFunction<_TsQueryDelete, DTsQueryDelete>('ts_query_delete'),
|
||||
queryCaptureCount = lib.lookupFunction<_TsQueryCaptureCount, DTsQueryCaptureCount>('ts_query_capture_count'),
|
||||
queryCaptureNameForId = lib.lookupFunction<_TsQueryCaptureNameForId, DTsQueryCaptureNameForId>('ts_query_capture_name_for_id'),
|
||||
queryCursorNew = lib.lookupFunction<_TsQueryCursorNew, DTsQueryCursorNew>('ts_query_cursor_new'),
|
||||
queryCursorDelete = lib.lookupFunction<_TsQueryCursorDelete, DTsQueryCursorDelete>('ts_query_cursor_delete'),
|
||||
queryCursorExec = lib.lookupFunction<_TsQueryCursorExec, DTsQueryCursorExec>('ts_query_cursor_exec'),
|
||||
queryCursorNextMatch = lib.lookupFunction<_TsQueryCursorNextMatch, DTsQueryCursorNextMatch>('ts_query_cursor_next_match'),
|
||||
wasmStoreNew = lib.lookupFunction<_TsWasmStoreNew, DTsWasmStoreNew>('ts_wasm_store_new'),
|
||||
wasmStoreDelete = lib.lookupFunction<_TsWasmStoreDelete, DTsWasmStoreDelete>('ts_wasm_store_delete'),
|
||||
wasmStoreLoadLanguage = lib.lookupFunction<_TsWasmStoreLoadLanguage, DTsWasmStoreLoadLanguage>('ts_wasm_store_load_language'),
|
||||
wasmEngineNew = lib.lookupFunction<_WasmEngineNew, DWasmEngineNew>('wasm_engine_new'),
|
||||
wasmEngineDelete = lib.lookupFunction<_WasmEngineDelete, DWasmEngineDelete>('wasm_engine_delete');
|
||||
|
||||
/// Constructs a [TreeSitterLib] from caller-supplied Dart closures. Used by
|
||||
/// tests to substitute the FFI surface without dlopen'ing the real library;
|
||||
@@ -176,30 +176,30 @@ class TreeSitterLib {
|
||||
DTsWasmStoreLoadLanguage? wasmStoreLoadLanguage,
|
||||
DWasmEngineNew? wasmEngineNew,
|
||||
DWasmEngineDelete? wasmEngineDelete,
|
||||
}) : parserNew = parserNew ?? (() => nullptr),
|
||||
parserDelete = parserDelete ?? ((_) {}),
|
||||
parserSetLanguage = parserSetLanguage ?? ((_, __) => false),
|
||||
parserSetWasmStore = parserSetWasmStore ?? ((_, __) {}),
|
||||
parserParseString = parserParseString ?? ((_, __, ___, ____) => nullptr),
|
||||
treeDelete = treeDelete ?? ((_) {}),
|
||||
// Leaks a zeroed TSNode allocation — only hit when the test supplies
|
||||
// a non-null parserParseString without also supplying treeRootNode.
|
||||
treeRootNode = treeRootNode ?? ((_) => calloc<TSNode>().ref),
|
||||
nodeStartByte = nodeStartByte ?? ((_) => 0),
|
||||
nodeEndByte = nodeEndByte ?? ((_) => 0),
|
||||
queryNew = queryNew ?? ((_, __, ___, ____, _____) => nullptr),
|
||||
queryDelete = queryDelete ?? ((_) {}),
|
||||
queryCaptureCount = queryCaptureCount ?? ((_) => 0),
|
||||
queryCaptureNameForId = queryCaptureNameForId ?? ((_, __, ___) => nullptr),
|
||||
queryCursorNew = queryCursorNew ?? (() => nullptr),
|
||||
queryCursorDelete = queryCursorDelete ?? ((_) {}),
|
||||
queryCursorExec = queryCursorExec ?? ((_, __, ___) {}),
|
||||
queryCursorNextMatch = queryCursorNextMatch ?? ((_, __) => false),
|
||||
wasmStoreNew = wasmStoreNew ?? ((_, __) => nullptr),
|
||||
wasmStoreDelete = wasmStoreDelete ?? ((_) {}),
|
||||
wasmStoreLoadLanguage = wasmStoreLoadLanguage ?? ((_, __, ___, ____, _____) => nullptr),
|
||||
wasmEngineNew = wasmEngineNew ?? (() => nullptr),
|
||||
wasmEngineDelete = wasmEngineDelete ?? ((_) {});
|
||||
}) : parserNew = parserNew ?? (() => nullptr),
|
||||
parserDelete = parserDelete ?? ((_) {}),
|
||||
parserSetLanguage = parserSetLanguage ?? ((_, _) => false),
|
||||
parserSetWasmStore = parserSetWasmStore ?? ((_, _) {}),
|
||||
parserParseString = parserParseString ?? ((_, _, _, _) => nullptr),
|
||||
treeDelete = treeDelete ?? ((_) {}),
|
||||
// Leaks a zeroed TSNode allocation — only hit when the test supplies
|
||||
// a non-null parserParseString without also supplying treeRootNode.
|
||||
treeRootNode = treeRootNode ?? ((_) => calloc<TSNode>().ref),
|
||||
nodeStartByte = nodeStartByte ?? ((_) => 0),
|
||||
nodeEndByte = nodeEndByte ?? ((_) => 0),
|
||||
queryNew = queryNew ?? ((_, _, _, _, _) => nullptr),
|
||||
queryDelete = queryDelete ?? ((_) {}),
|
||||
queryCaptureCount = queryCaptureCount ?? ((_) => 0),
|
||||
queryCaptureNameForId = queryCaptureNameForId ?? ((_, _, _) => nullptr),
|
||||
queryCursorNew = queryCursorNew ?? (() => nullptr),
|
||||
queryCursorDelete = queryCursorDelete ?? ((_) {}),
|
||||
queryCursorExec = queryCursorExec ?? ((_, _, _) {}),
|
||||
queryCursorNextMatch = queryCursorNextMatch ?? ((_, _) => false),
|
||||
wasmStoreNew = wasmStoreNew ?? ((_, _) => nullptr),
|
||||
wasmStoreDelete = wasmStoreDelete ?? ((_) {}),
|
||||
wasmStoreLoadLanguage = wasmStoreLoadLanguage ?? ((_, _, _, _, _) => nullptr),
|
||||
wasmEngineNew = wasmEngineNew ?? (() => nullptr),
|
||||
wasmEngineDelete = wasmEngineDelete ?? ((_) {});
|
||||
|
||||
final DTsParserNew parserNew;
|
||||
final DTsParserDelete parserDelete;
|
||||
@@ -256,10 +256,10 @@ class TreeSitterLib {
|
||||
final libName = Platform.isLinux
|
||||
? 'libtree-sitter.so'
|
||||
: Platform.isMacOS
|
||||
? 'libtree-sitter.dylib'
|
||||
: Platform.isWindows
|
||||
? 'tree-sitter.dll'
|
||||
: null;
|
||||
? 'libtree-sitter.dylib'
|
||||
: Platform.isWindows
|
||||
? 'tree-sitter.dll'
|
||||
: null;
|
||||
if (libName == null) {
|
||||
lastOpenError = 'unsupported platform ${Platform.operatingSystem}';
|
||||
lastOpenErrorPath = null;
|
||||
|
||||
@@ -20,11 +20,7 @@ typedef GrammarBytesLoader = Future<Uint8List> Function(String language);
|
||||
typedef GrammarQueryLoader = Future<String?> Function(String language);
|
||||
|
||||
class SyntaxSpan {
|
||||
const SyntaxSpan({
|
||||
required this.start,
|
||||
required this.end,
|
||||
required this.role,
|
||||
});
|
||||
const SyntaxSpan({required this.start, required this.end, required this.role});
|
||||
|
||||
final int start;
|
||||
final int end;
|
||||
@@ -39,11 +35,7 @@ class SyntaxResult {
|
||||
}
|
||||
|
||||
class _LoadedGrammar {
|
||||
_LoadedGrammar({
|
||||
required this.language,
|
||||
required this.query,
|
||||
required this.captureNames,
|
||||
});
|
||||
_LoadedGrammar({required this.language, required this.query, required this.captureNames});
|
||||
|
||||
final Pointer<Void> language;
|
||||
final Pointer<TSQuery> query;
|
||||
@@ -56,13 +48,10 @@ class TreeSitterService {
|
||||
/// Production constructor: uses the dlopen'd [TreeSitterLib.instance] and
|
||||
/// the Flutter [rootBundle]. Tests pass [lib] / [grammarBytes] /
|
||||
/// [grammarQuery] to substitute a fake FFI surface and in-memory assets.
|
||||
TreeSitterService({
|
||||
TreeSitterLib? lib,
|
||||
GrammarBytesLoader? grammarBytes,
|
||||
GrammarQueryLoader? grammarQuery,
|
||||
}) : _injectedLib = lib,
|
||||
_grammarBytes = grammarBytes ?? _defaultGrammarBytes,
|
||||
_grammarQuery = grammarQuery ?? _defaultGrammarQuery;
|
||||
TreeSitterService({TreeSitterLib? lib, GrammarBytesLoader? grammarBytes, GrammarQueryLoader? grammarQuery})
|
||||
: _injectedLib = lib,
|
||||
_grammarBytes = grammarBytes ?? _defaultGrammarBytes,
|
||||
_grammarQuery = grammarQuery ?? _defaultGrammarQuery;
|
||||
|
||||
final TreeSitterLib? _injectedLib;
|
||||
final GrammarBytesLoader _grammarBytes;
|
||||
@@ -142,13 +131,7 @@ class TreeSitterService {
|
||||
wasmNative.asTypedList(wasmBytes.length).setAll(0, wasmBytes);
|
||||
final error = calloc<TSWasmError>();
|
||||
|
||||
final lang = lib.wasmStoreLoadLanguage(
|
||||
_store!,
|
||||
nameNative.cast(),
|
||||
wasmNative,
|
||||
wasmBytes.length,
|
||||
error,
|
||||
);
|
||||
final lang = lib.wasmStoreLoadLanguage(_store!, nameNative.cast(), wasmNative, wasmBytes.length, error);
|
||||
|
||||
calloc.free(wasmNative);
|
||||
calloc.free(nameNative);
|
||||
@@ -174,13 +157,7 @@ class TreeSitterService {
|
||||
final errorOffset = calloc<Uint32>();
|
||||
final errorType = calloc<Int32>();
|
||||
|
||||
query = lib.queryNew(
|
||||
lang,
|
||||
queryNative.cast(),
|
||||
queryLen,
|
||||
errorOffset,
|
||||
errorType,
|
||||
);
|
||||
query = lib.queryNew(lang, queryNative.cast(), queryLen, errorOffset, errorType);
|
||||
|
||||
calloc.free(queryNative);
|
||||
calloc.free(errorOffset);
|
||||
@@ -198,11 +175,7 @@ class TreeSitterService {
|
||||
}
|
||||
}
|
||||
|
||||
final grammar = _LoadedGrammar(
|
||||
language: lang,
|
||||
query: query,
|
||||
captureNames: captureNames,
|
||||
);
|
||||
final grammar = _LoadedGrammar(language: lang, query: query, captureNames: captureNames);
|
||||
_grammars[language] = grammar;
|
||||
return grammar;
|
||||
} catch (_) {
|
||||
@@ -244,12 +217,7 @@ class TreeSitterService {
|
||||
// Parse source.
|
||||
final sourceNative = source.toNativeUtf8();
|
||||
final sourceLen = utf8.encode(source).length;
|
||||
final tree = lib.parserParseString(
|
||||
parser,
|
||||
nullptr,
|
||||
sourceNative.cast(),
|
||||
sourceLen,
|
||||
);
|
||||
final tree = lib.parserParseString(parser, nullptr, sourceNative.cast(), sourceLen);
|
||||
|
||||
if (tree == nullptr) {
|
||||
calloc.free(sourceNative);
|
||||
@@ -270,11 +238,7 @@ class TreeSitterService {
|
||||
final cap = m.captures[i];
|
||||
final captureIndex = cap.index;
|
||||
if (captureIndex < grammar.captureNames.length) {
|
||||
spans.add(SyntaxSpan(
|
||||
start: lib.nodeStartByte(cap.node),
|
||||
end: lib.nodeEndByte(cap.node),
|
||||
role: grammar.captureNames[captureIndex],
|
||||
));
|
||||
spans.add(SyntaxSpan(start: lib.nodeStartByte(cap.node), end: lib.nodeEndByte(cap.node), role: grammar.captureNames[captureIndex]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user