diff --git a/.github/workflows/checkout.yml b/.github/workflows/checkout.yml index bcd002b..1cf73b4 100644 --- a/.github/workflows/checkout.yml +++ b/.github/workflows/checkout.yml @@ -36,15 +36,15 @@ jobs: - name: Checkout id: checkout uses: actions/checkout@v4 - with: - sparse-checkout: | - .github - src/ - *.json - *.js - *.mjs - README.md - CHANGELOG.md + #with: + # sparse-checkout: | + # .github + # src/ + # *.json + # *.js + # *.mjs + # README.md + # CHANGELOG.md - name: Install Node.js uses: actions/setup-node@v4 diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 5be3083..53dcbd3 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -18,17 +18,21 @@ jobs: timeout-minutes: 15 steps: - name: Checkout + id: checkout uses: actions/checkout@v4 - name: Install Node.js + id: node-setup uses: actions/setup-node@v4 with: node-version: 18.x - name: Install Dependencies + id: install run: npm install - name: Publish + id: publish if: success() && startsWith(github.ref, 'refs/tags/') run: npm run deploy env: diff --git a/package.json b/package.json index c400699..e4ed87e 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "displayName": "Flutter Plus", "description": "Extension with various improvements for Flutter", "icon": "assets/logo.png", - "version": "0.1.0", + "version": "0.2.0", "pricing": "Free", "engines": { "vscode": "^1.92.0" @@ -110,4 +110,4 @@ "@vscode/test-cli": "^0.0.9", "@vscode/test-electron": "^2.4.0" } -} +} \ No newline at end of file diff --git a/snippets/dart.json b/snippets/dart.json index 9e26dfe..3c8582e 100644 --- a/snippets/dart.json +++ b/snippets/dart.json @@ -1 +1,319 @@ -{} \ No newline at end of file +{ + "Main entry point": { + "scope": "flutter, dart", + "prefix": "main", + "description": "Main entry point", + "body": [ + "import 'dart:async';\n", + "@pragma('vm:entry-point')", + "void main([List? args]) =>", + " runZonedGuarded(() async {", + " ${0:// ...}", + " },", + " (error, stackTrace) => print('\\$error\\n\\$stackTrace'), // ignore: avoid_print", + " );\n" + ] + }, + "Try-catch-finally block": { + "scope": "flutter, dart", + "prefix": "try", + "description": "Try-catch-finally block", + "body": [ + "try {", + " // ...", + "} on Object catch (error, stackTrace) {", + " rethrow; // or Error.throwWithStackTrace(error, stackTrace);", + "} finally {", + " // ...", + "}" + ] + }, + "Timeout handler": { + "scope": "flutter, dart", + "prefix": "timeout", + "description": "Timeout handler", + "body": "timeout(const Duration(milliseconds: 5000))${0:;}" + }, + "Stopwatch": { + "scope": "flutter, dart", + "prefix": "stopwatch", + "description": "Stopwatch", + "body": [ + "final stopwatch = Stopwatch()..start();", + "try {", + " /* ... */", + "} finally {", + " log(", + " '${(stopwatch..stop()).elapsedMicroseconds} μs',", + " name: 'select',", + " level: 100,", + " );", + "}" + ] + }, + "Platform conditional imports": { + "scope": "flutter, dart", + "prefix": [ + "conditional_imports", + "import_conditional" + ], + "description": "Platform conditional imports", + "body": [ + "import 'stub.dart'", + " // ignore: uri_does_not_exist", + " if (dart.library.js_interop) 'js.dart'", + " // ignore: uri_does_not_exist", + " if (dart.library.io) 'io.dart';\n" + ] + }, + "Changelog unreleased": { + "scope": "md, markdown", + "prefix": [ + "changelog_unreleased", + "unreleased" + ], + "description": "Changelog unreleased", + "body": [ + "## Unreleased", + "", + "- **ADDED**: ${0}", + "- **CHANGED**: ", + "- **DEPRECATED**: ", + "- **REMOVED**: ", + "- **FIXED**: ", + "- **SECURITY**: ", + "- **REFACTOR**: ", + "- **DOCS**: ", + " " + ] + }, + "Changelog version": { + "scope": "md, markdown", + "prefix": [ + "changelog_version", + "version" + ], + "description": "Changelog version section", + "body": [ + "## ${1:0}.${2:0}.${3:0}", + "", + "- **ADDED**: ${0}", + "- **CHANGED**: ", + "- **DEPRECATED**: ", + "- **REMOVED**: ", + "- **FIXED**: ", + "- **SECURITY**: ", + "- **REFACTOR**: ", + "- **DOCS**: ", + " " + ] + }, + "Divider": { + "scope": "flutter, dart", + "prefix": [ + "dvd", + "divider_comment" + ], + "description": "Divider comment line", + "body": "// --- ${1} --- //\n\n$0" + }, + "Reverse bypass": { + "scope": "flutter, dart", + "prefix": [ + "reverseList" + ], + "description": "Reverse list traversal in a loop", + "body": [ + "for (var i = list.length - 1; i >= 0; i--) $0" + ] + }, + "Part": { + "scope": "flutter, dart", + "prefix": "part", + "description": "Part of file", + "body": [ + "part '${TM_FILENAME_BASE}.g.dart';$0" + ] + }, + "Mocks": { + "scope": "flutter, dart", + "prefix": "mocks", + "description": "Import mocks file", + "body": [ + "import '${TM_FILENAME_BASE}.mocks.dart';$0" + ] + }, + "Hash Code": { + "scope": "flutter, dart", + "prefix": [ + "hashCode", + "equals", + "==" + ], + "description": "Hash Code and Equals override", + "body": [ + "@override", + "int get hashCode => id.hashCode;\n", + "@override", + "bool operator ==(Object other) =>", + " identical(this, other) ||", + " other is ${1:${TM_FILENAME_BASE/(.)(.*)/${1:/upcase}${2:/camelcase}/}} &&", + " id == other.id;${0}\n" + ] + }, + "No Such Method": { + "scope": "flutter, dart", + "prefix": [ + "nosm", + "noSuchMethod" + ], + "description": "This method is invoked when a non-existent method or property is accessed.", + "body": [ + "@override", + "dynamic noSuchMethod(Invocation invocation) {", + " ${1:}", + "}" + ] + }, + "Test": { + "scope": "flutter, dart", + "prefix": [ + "test", + "unitTest" + ], + "description": "Create a test function", + "body": [ + "test('${1:test description}', () {", + " ${0:expect(true, isTrue);}", + "});\n" + ] + }, + "Pragma": { + "scope": "flutter, dart", + "prefix": [ + "@pragma", + "pragma" + ], + "description": "Pragma annotation https://mrale.ph/dartvm/pragmas.html", + "body": "@pragma(${1|'vm:entry-point','vm:never-inline','vm:prefer-inline','dart2js:tryInline','vm:notify-debugger-on-exception','vm:invisible','vm:always-consider-inlining','flutter:keep-to-string','flutter:keep-to-string-in-subtypes'|})" + }, + "Dart doc disable documentation": { + "scope": "flutter, dart", + "prefix": [ + "doc-disabled", + "@doc-disabled" + ], + "description": "No documentation annotation", + "body": [] + }, + "Dart doc category": { + "scope": "flutter, dart", + "prefix": [ + "category", + "doc-category", + "dartdoc-category", + "@doc-category" + ], + "description": "Add category to documentation", + "body": [ + "/// {@${1|category,subCategory|} ${0}}" + ] + }, + "Dart doc image": { + "scope": "flutter, dart", + "prefix": [ + "doc-image", + "dartdoc-image", + "@doc-image" + ], + "description": "Add image to documentation", + "body": [ + "/// {@image }" + ] + }, + "Dart doc animation": { + "scope": "flutter, dart", + "prefix": [ + "doc-animation", + "dartdoc-animation", + "@doc-animation" + ], + "description": "Add animation to documentation", + "body": "/// {@animation name 100 200 ${0:https://host.tld/path/to/video.mp4}}" + }, + "Dart doc new template": { + "scope": "flutter, dart", + "prefix": [ + "@template", + "template", + "dartdoc-new-template", + "doc-new-macro", + "newtmpl", + "@doc-template" + ], + "description": "Creates a new dartdoc template with current file's name as its prefix", + "body": [ + "/// {@template ${1:$TM_FILENAME_BASE}}", + "/// ${0:Body of the template}", + "/// {@endtemplate}" + ] + }, + "Dart doc use macro": { + "scope": "flutter, dart", + "prefix": [ + "@macro", + "macro", + "dartdoc-use-template", + "doc-use-macro", + "usetmpl", + "@doc-macro" + ], + "description": "Uses existing dartdoc macro with current file's name as its prefix", + "body": "/// {@macro ${0:$TM_FILENAME_BASE}}" + }, + "Dart doc inject html": { + "scope": "flutter, dart", + "prefix": [ + "@inject-html", + "inject-html", + "dartdoc-html", + "doc-html", + "html", + "@doc-html" + ], + "description": "Injects html into the current comment", + "body": [ + "/// {@inject-html}", + "/// ${0:

[The HTML to inject.]()

}", + "/// {@end-inject-html}" + ] + }, + "Deprecated": { + "scope": "flutter, dart", + "prefix": [ + "@deprecated", + "deprecated" + ], + "description": "Deprecated", + "body": "@Deprecated('${0:Reason}')" + }, + "Meta": { + "scope": "flutter, dart", + "prefix": [ + "@meta", + "meta", + "@annotation", + "annotation" + ], + "description": "Meta annotation", + "body": "@${1|immutable,useResult,internal,protected,literal,mustCallSuper,sealed,alwaysThrows,factory,visibleForOverriding,visibleForTesting,experimental,nonVirtual,doNotStore,optionalTypeArgs|}" + }, + "Coverage": { + "scope": "flutter, dart", + "prefix": [ + "coverage" + ], + "description": "Coverage annotation", + "body": "// coverage:${1|ignore-line,ignore-start,ignore-end,ignore-file|}" + } +} \ No newline at end of file diff --git a/snippets/flutter.json b/snippets/flutter.json index 32da1da..5247a89 100644 --- a/snippets/flutter.json +++ b/snippets/flutter.json @@ -1,5 +1,4 @@ { - "Material App": { "scope": "flutter, dart", "prefix": "mateapp", @@ -41,15 +40,9 @@ "body": [ "import 'dart:async';\n", "import 'package:flutter/cupertino.dart';\n\n", - "void main() => runZonedGuarded>(() async {", - " runApp(const App());", - " }, (error, stackTrace) => log(", - " 'Top level exception',", - " error: error", - " stackTrace: stackTrace,", - " level: 1000,", - " name: 'main',", - " ),", + "void main() => runZonedGuarded(", + " () => runApp(const App()),", + " (error, stackTrace) => print('Top level exception: \\$error\\n\\$stackTrace'), // ignore: avoid_print", " );\n", "/// {@template app}", "/// App widget.",