From 2e94227aa442d476afec5e093fd2e5fd7ddaecb0 Mon Sep 17 00:00:00 2001 From: Hadrien Lejard Date: Wed, 11 Nov 2020 15:54:44 +0100 Subject: [PATCH 1/2] remove import --- snippets/dart-snippets.code-snippets | 45 +++++++++------------------- snippets/html-snippets.code-snippets | 18 +++++------ 2 files changed, 23 insertions(+), 40 deletions(-) diff --git a/snippets/dart-snippets.code-snippets b/snippets/dart-snippets.code-snippets index f1dc6f1..69cad48 100644 --- a/snippets/dart-snippets.code-snippets +++ b/snippets/dart-snippets.code-snippets @@ -3,7 +3,6 @@ "prefix": "ad-comp", "description": "Angular Component", "body": [ - "import 'package:angular/angular.dart';\n", "@Component(", "\tselector: '${1:component-selector}',", "\ttemplateUrl: '${2:component_path}.html',", @@ -19,12 +18,11 @@ "prefix": "ad-directive", "description": "Angular Directive", "body": [ - "import 'package:angular/angular.dart';\n", "@Directive(", "\tselector: '${1:directiveSelector}',", "\tproviders: [],", ")", - "class ${3:Name}Directive {", + "class ${2:Name}Directive {", "\tfinal Element element;", "", "\t${3:Name}Directive(this.element);", @@ -35,9 +33,7 @@ "prefix": "ad-pipe", "description": "Angular pipe", "body": [ - "import 'package:angular/angular.dart';", - "", - "@Pipe('${1:selectorName}')", + "@Pipe('${1:pipeSelector}')", "class ${2:Name}Pipe implements PipeTransform {", "\ttransform(dynamic value) {", "\t\t$0", @@ -49,7 +45,6 @@ "prefix": "ad-comp-push", "description": "Angular Component using OnPush change detection", "body": [ - "import 'package:angular/angular.dart';\n", "@Component(", "\tselector: '${1:component-selector}',", "\ttemplateUrl: '${2:component_path}.html',", @@ -69,20 +64,14 @@ "prefix": "ad-comp-route", "description": "Angular Route Component", "body": [ - "import 'package:angular/angular.dart';", - "import 'package:angular_router/angular_router.dart';", - "import '$TM_FILENAME_BASE.template.dart' as template;", - "", - "final ngFactory = template.${1:Name}ComponentNgFactory;", - "", "@Component(", - "\tselector: '${2:component-selector}',", - "\ttemplateUrl: '${3:component_path}.html',", - "\tstyleUrls: ['${3:component_path}.css'],", + "\tselector: '${1:component-selector}',", + "\ttemplateUrl: '${2:component_path}.html',", + "\tstyleUrls: ['${2:component_path}.css'],", "\tdirectives: [coreDirectives],", "\tproviders: [],", ")", - "class ${1:Name}Component implements OnActivate, OnDeactivate {", + "class ${3:Name}Component implements OnActivate, OnDeactivate {", "", "\t@override", "\tvoid onActivate(RouterState previous, RouterState current) {", @@ -100,12 +89,9 @@ "prefix": "ad-route", "description": "Angular Route Definition", "body": [ - "import 'package:angular_router/angular_router.dart';", - "import '${1:component_route_path}' as ${2:name}_lib;", - "", - "final ${2:name}Route = RouteDefinition(", - "\tpath: ${3:RoutePath},", - "\tcomponent: ${2:name}_lib.ngFactory,", + "final ${1:Name}Route = RouteDefinition(", + "\troutePath: ${2:RoutePath},", + "\tcomponent: ${3:ComponentFactory},", ");", ] }, @@ -113,14 +99,11 @@ "prefix": "ad-route-lazy", "description": "Angular Route Definition Lazy", "body": [ - "import 'package:angular_router/angular_router.dart';", - "import '${1:component_route_path}' deferred as ${2:name}_lib;", - "", - "final ${2:name}Route = RouteDefinition.defer(", - "\tpath: ${3:RoutePath},", + "final ${1:Name}Route = RouteDefinition.defer(", + "\troutePath: ${2:RoutePath},", "\tloader: () async {", - "\t\tawait ${2:name}_lib.loadLibrary();", - "\t\treturn ${2:name}_lib.ngFactory;", + "\t\tawait ${3:deferredLibrary}.loadLibrary();", + "\t\treturn ${3:deferredLibrary}.${4:ComponentFactory};", "\t},", ");", ] @@ -129,7 +112,7 @@ "prefix": "ad-trackby", "description": "TrackBy Function", "body": [ - "${1:trackBy}(int index,, item) {", + "${1:trackBy}(int index, item) {", "\t$0", "}" ] diff --git a/snippets/html-snippets.code-snippets b/snippets/html-snippets.code-snippets index d567f82..e01510f 100644 --- a/snippets/html-snippets.code-snippets +++ b/snippets/html-snippets.code-snippets @@ -3,28 +3,28 @@ "prefix": "ad-router-link", "description": "Router link", "body": [ - "${name}$0" + "${2:name}$0" ] }, "Angular Dart Router Attribute": { "prefix": "ad-router-attribute", "description": "Router link", "body": [ - "[routerLink]=\"${path}\"$0" + "[routerLink]=\"${1:path}\"$0" ] }, "Angular Dart Router Active Link": { "prefix": "ad-router-linkActive", "description": "Router active link", "body": [ - "${name}$0" + "${2:name}$0" ] }, "Angular Dart Router Outlet": { "prefix": "ad-router-outlet", "description": "Router outlet element", "body": [ - "", + "", "$0" ] }, @@ -32,35 +32,35 @@ "prefix": "ad-if", "description": "If directive: *ngIf=\"expression\"", "body": [ - "*ngIf=\"${expression}\"$0" + "*ngIf=\"${1:expression}\"$0" ] }, "Angular Dart For-loop Directive": { "prefix": "ad-for", "description": "For-loop directive", "body": [ - "*ngFor=\"let ${item} of ${items}\"$0" + "*ngFor=\"let ${1:item} of ${2:items}\"$0" ] }, "Angular Dart For-loop Directive with li element": { "prefix": "ad-for-li", "description": "For-loop directive with li element", "body": [ - "
  • $0
  • " + "
  • $0
  • " ] }, "Angular Dart For-loop Directive with index": { "prefix": "ad-for-index", "description": "For-loop directive with index", "body": [ - "*ngFor=\"let ${item} of ${items}; let i=index\"$0" + "*ngFor=\"let ${1:item} of ${2:items}; let i=index\"$0" ] }, "Angular Dart Click Event": { "prefix": "ad-click", "description": "Click event", "body": [ - "(click)=\"${expression}\"$0" + "(click)=\"${1:expression}\"$0" ] }, } \ No newline at end of file From de6f4d6d965c79aabbe0a3eef15c383321ea070c Mon Sep 17 00:00:00 2001 From: Hadrien Lejard Date: Wed, 11 Nov 2020 15:55:54 +0100 Subject: [PATCH 2/2] cleanup --- CHANGELOG.md | 5 +++++ package.json | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7012852..4d59199 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to the "adsnippets" extension will be documented in this file. +## [0.0.7] + +- Remove imports from dart snippets +- Fix routes snippet + ## [0.0.6] - rename `adcomp` to `ad-comp` diff --git a/package.json b/package.json index a6cdf76..4c6749a 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "adsnippets", "displayName": "Angular Dart Snippets", "description": "A simple Angular Dart snippet extension. Generate boilerplate code for your next Angular Dart Project", - "version": "0.0.6", + "version": "0.0.7", "publisher": "aadarshadhakalg", "repository": { "type": "git", @@ -21,8 +21,7 @@ "Snippets" ], "contributes": { - "snippets": [ - { + "snippets": [{ "language": "dart", "path": "./snippets/dart-snippets.code-snippets" },