Add example project to play around with the AS plugin

This commit is contained in:
Simon Binder 2019-08-26 21:11:26 +02:00
parent a3f6f1e326
commit fc6c9857bb
No known key found for this signature in database
GPG Key ID: 7891917E4147B8C0
8 changed files with 89 additions and 5 deletions

35
extras/plugin_example/.gitignore vendored Normal file
View File

@ -0,0 +1,35 @@
# Created by https://www.gitignore.io/api/dart,intellij
# Edit at https://www.gitignore.io/?templates=dart,intellij
.vscode
### Dart ###
# See https://www.dartlang.org/guides/libraries/private-files
# Files and directories created by pub
.dart_tool/
.packages
build/
# If you're building an application, you may want to check-in your pubspec.lock
pubspec.lock
# Directory created by dartdoc
# If you don't generate documentation locally you can remove this line.
doc/api/
# Avoid committing generated Javascript files:
*.dart.js
*.info.json # Produced by the --dump-info flag.
*.js # When generated by dart2js. Don't specify *.js if your
# project includes source files written in JavaScript.
*.js_
*.js.deps
*.js.map
android/
ios/
### Intellij ###
.idea/**/*
# End of https://www.gitignore.io/api/dart,intellij

View File

@ -0,0 +1,24 @@
Playground to test the analyzer plugin for `.moor` files.
## Playing around with this
At the moment, [DartCode](https://dartcode.org/) with version `v3.4.0-beta.2` is needed to run the
plugin. To set up the plugin, run the following steps
1. Change the file `moor/tools/analyzer_plugin/pubspec.yaml` so that the `dependency_overrides`
section points to the location where you cloned this repository. This is needed because we
can't use relative paths for dependencies in analyzer plugins yet.
2. In VS Code, change `dart.additionalAnalyzerFileExtensions` to include `moor` files:
```json
{
"dart.additionalAnalyzerFileExtensions": [
"moor"
]
}
```
3. If you already had the project open, close and re-open VS Code. Otherwise, simply open this
project.
4. Type around in a `.moor` file - notice how you still don't get syntax highlighting because
VS Code required a static grammar for files and can't use a language server for that :(
Debugging plugins is not fun. See the [docs](https://github.com/dart-lang/sdk/blob/master/pkg/analyzer_plugin/doc/tutorial/debugging.md)
on some general guidance, and good luck. Enabling the analyzer diagnostics server can help.

View File

@ -0,0 +1,5 @@
include: package:pedantic/analysis_options.yaml
analyzer:
plugins:
- moor

View File

@ -0,0 +1 @@
class Test {}

View File

@ -0,0 +1,3 @@
CREATE TABLE playground (
id INT NOT NULL PRIMARY KEY AUTOINCREMENT
)

View File

@ -0,0 +1,3 @@
CREATE TABLE playground (
id INT NOT NULL PRIMARY KEY AUTOINCREMENT
)

View File

@ -0,0 +1,13 @@
name: plugin_example
description: Playground to test the analyzer plugin
environment:
sdk: '>=2.4.0 <3.0.0'
dependencies:
moor:
path: ../../moor
dev_dependencies:
pedantic: ^1.7.0
test: ^1.5.0

View File

@ -8,8 +8,8 @@ dependencies:
# To work on this plugin, you need to add the absolute paths here. Relative paths aren't supported yet
# https://github.com/dart-lang/sdk/issues/35281
#dependency_overrides:
# moor_generator:
# path: /home/simon/IdeaProjects/moor/moor_generator
# sqlparser:
# path: /home/simon/IdeaProjects/moor/sqlparser
dependency_overrides:
moor_generator:
path: /home/simon/IdeaProjects/moor/moor_generator
sqlparser:
path: /home/simon/IdeaProjects/moor/sqlparser