Also add plugin to drift

This commit is contained in:
Simon Binder 2021-10-11 10:25:50 +02:00
parent 331d600df3
commit bb5f08f90f
No known key found for this signature in database
GPG Key ID: 7891917E4147B8C0
4 changed files with 64 additions and 3 deletions

View File

@ -0,0 +1,43 @@
//@dart=2.6
import 'dart:convert';
import 'dart:isolate';
import 'package:drift_dev/plugin.dart' as plugin;
import 'package:web_socket_channel/io.dart';
const useDebuggingVariant = false;
void main(List<String> args, SendPort sendPort) {
if (useDebuggingVariant) {
_PluginProxy(sendPort).start();
} else {
plugin.start(args, sendPort);
}
}
// Used during development. See CONTRIBUTING.md in the moor repo on how to debug
// the plugin.
class _PluginProxy {
final SendPort sendToAnalysisServer;
ReceivePort _receive;
IOWebSocketChannel _channel;
_PluginProxy(this.sendToAnalysisServer);
Future<void> start() async {
_channel = IOWebSocketChannel.connect('ws://localhost:9999');
_receive = ReceivePort();
sendToAnalysisServer.send(_receive.sendPort);
_receive.listen((data) {
// the server will send messages as maps, convert to json
_channel.sink.add(json.encode(data));
});
_channel.stream.listen((data) {
sendToAnalysisServer.send(json.decode(data as String));
});
}
}

View File

@ -0,0 +1,18 @@
name: analyzer_load_moor_plugin
version: 1.0.0
description: This pubspec is a part of Drift and determines the version of the analyzer plugin to load
environment:
sdk: '>=2.9.0 <3.0.0'
dependencies:
drift_dev: ^1.0.0
web_socket_channel: ^1.0.15
# These overrides are only needed when working on the plugin with useDebuggingVariant = false (not recommended)
#dependency_overrides:
# drift_dev:
# path: /path/to/drift/drift_dev
# sqlparser:
# path: /path/to/drift/sqlparser

View File

@ -41,9 +41,9 @@ class MoorPlugin extends ServerPlugin
}
@override
List<String> get fileGlobsToAnalyze => const ['*.moor'];
List<String> get fileGlobsToAnalyze => const ['*.moor', '*.drift'];
@override
String get name => 'Moor plugin';
String get name => 'Drift plugin';
@override
// docs say that this should a version of _this_ plugin, but they lie. this
// version will be used to determine compatibility with the analyzer

View File

@ -25,7 +25,7 @@ dependencies:
io: ^1.0.3
# Moor-specific analysis and apis
drift: ^4.6.0
drift: ^1.0.0
sqlite3: '>=0.1.6 <2.0.0'
sqlparser: ^0.17.0