Scaffold the package layout of a future analyzer plugin

This commit is contained in:
Simon Binder 2019-07-29 10:27:50 +02:00
parent a550a49705
commit 5ddcd17c21
No known key found for this signature in database
GPG Key ID: 7891917E4147B8C0
9 changed files with 100 additions and 1 deletions

View File

@ -31,7 +31,8 @@ updates that span multiple versions, we should follow these steps
2. Make sure each package has the correct dependencies: `moor_flutter` version `1.x` should depend 2. Make sure each package has the correct dependencies: `moor_flutter` version `1.x` should depend
on moor `1.x` as well to ensure users will always `pub get` moor packages that are compatible on moor `1.x` as well to ensure users will always `pub get` moor packages that are compatible
with each other. with each other.
3. Comment out the `dependency_overrides` section 3. Comment out the `dependency_overrides` section in `moor`, `moor/tool/analyzer_plugin`, `moor_flutter`,
`moor_generator` and `sqlparser`.
4. Publish packages in this order to avoid scoring penalties caused by versions not existing: 4. Publish packages in this order to avoid scoring penalties caused by versions not existing:
1. `moor` 1. `moor`
2. `moor_generator` 2. `moor_generator`

View File

@ -0,0 +1,7 @@
import 'dart:isolate';
import 'package:moor_generator/plugin.dart';
void main(List<String> args, SendPort sendPort) {
start(args, sendPort);
}

View File

@ -0,0 +1,10 @@
name: analyzer_load_moor_plugin
version: 1.0.0
description: This pubspec is a part of moor and determines the version of the moor analyzer to load
dependencies:
moor_generator: ^1.6.0
dependency_overrides:
moor_generator:
path: ../../../moor_generator

View File

@ -0,0 +1 @@
export 'src/plugin/starter.dart';

View File

@ -0,0 +1,40 @@
// ignore_for_file: implementation_imports
import 'package:analyzer/src/dart/analysis/driver.dart';
class MoorDriver implements AnalysisDriverGeneric {
final _addedFiles = <String>{};
bool _ownsFile(String path) => path.endsWith('.moor');
@override
void addFile(String path) {
if (_ownsFile(path)) {
_addedFiles.add(path);
handleFileChanged(path);
}
}
@override
void dispose() {}
void handleFileChanged(String path) {
if (_ownsFile(path)) {}
}
@override
bool get hasFilesToAnalyze => null;
@override
Future<void> performWork() {
// TODO: implement performWork
return null;
}
@override
set priorityFiles(List<String> priorityPaths) {
// We don't support this ATM
}
@override
AnalysisDriverPriority get workPriority => AnalysisDriverPriority.general;
}

View File

@ -0,0 +1,24 @@
import 'package:analyzer/file_system/file_system.dart';
// ignore: implementation_imports
import 'package:analyzer/src/dart/analysis/driver.dart';
import 'package:analyzer_plugin/plugin/plugin.dart';
import 'package:analyzer_plugin/protocol/protocol_generated.dart';
class MoorPlugin extends ServerPlugin {
MoorPlugin(ResourceProvider provider) : super(provider);
@override
final List<String> fileGlobsToAnalyze = const ['**/*.moor'];
@override
final String name = 'Moor plugin';
@override
final String version = '0.0.1';
@override
final String contactInfo =
'Create an issue at https://github.com/simolus3/moor/';
@override
AnalysisDriverGeneric createAnalysisDriver(ContextRoot contextRoot) {
return null;
}
}

View File

@ -0,0 +1,10 @@
import 'dart:isolate';
import 'package:analyzer/file_system/physical_file_system.dart';
import 'package:analyzer_plugin/starter.dart';
import 'package:moor_generator/src/plugin/plugin.dart';
void start(List<String> args, SendPort sendPort) {
ServerPluginStarter(MoorPlugin(PhysicalResourceProvider.INSTANCE))
.start(sendPort);
}

View File

@ -0,0 +1,5 @@
/// Keeps track of files that need to be analyzed by the moor generator.
class FileTracker {}
/// A `.moor` file added to the plugin.
class _TrackedFile {}

View File

@ -13,6 +13,7 @@ environment:
dependencies: dependencies:
analyzer: '>=0.36.0 <0.38.0' analyzer: '>=0.36.0 <0.38.0'
analyzer_plugin:
recase: ^2.0.1 recase: ^2.0.1
built_value: '>=6.3.0 <7.0.0' built_value: '>=6.3.0 <7.0.0'
source_gen: ^0.9.4 source_gen: ^0.9.4