From 692fd99a2b8834c510cb448c798a804f079ed08f Mon Sep 17 00:00:00 2001 From: Slava Tutushkin Date: Wed, 4 Oct 2023 01:35:45 +0200 Subject: [PATCH 1/2] Add Target and MinimumVersion to SourceTemplateAttribute --- src/Annotations.cs | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/Annotations.cs b/src/Annotations.cs index ddb5754..9500fa6 100644 --- a/src/Annotations.cs +++ b/src/Annotations.cs @@ -768,6 +768,7 @@ public PathReferenceAttribute([NotNull, PathReference] string basePath) /// Text inside these comments is added as source code when the template is applied. Template parameters /// can be used either as additional method parameters or as identifiers wrapped in two '$' signs. /// Use the attribute to specify macros for parameters. + /// The expression to be used in the expansion can be adjusted by the parameter. /// /// /// In this example, the 'forEach' method is a source template available over all values @@ -783,7 +784,42 @@ public PathReferenceAttribute([NotNull, PathReference] string basePath) /// [AttributeUsage(AttributeTargets.Method)] [Conditional("JETBRAINS_ANNOTATIONS")] - public sealed class SourceTemplateAttribute : Attribute { } + public sealed class SourceTemplateAttribute : Attribute + { + /// + /// Allows specifying which expression to capture for template execution if more than one present on the expansion. + /// If omitted, the Default is assumed. + /// + /// + /// _args = args.{caret} + /// Inner: args + /// Outer: _args = args + /// + /// + /// In versions before 2023.3 the Default used to be the Outer. Since 2023.3 the Default is Inner. + /// if this causes problems in specific cases. + /// + public SourceTemplateTargetExpression Target { get; set; } + /// + /// Allows to hide the source template from the users of the older versions of the product if a serious difference + /// in behaviour was introduced and template is not suitable or applicable in the previous versions. + /// + /// + /// 0 - Applicable for all versions + /// 1 - 2023.3 and higher. Notable change: default capturing expression have been changed from Outer to Inner + /// Products before 2023.2 do not know about this parameter and will ignore it. Workaround: SourceTemplateExAttribute + /// can be added to the solution as an exact copy of this attribute, older version will ignore it and will not suggest + /// templates for expansion. + /// Specify this parameter only if you have a reasons to do so. + /// + public int MinimumVersion { get; set; } + } + public enum SourceTemplateTargetExpression + { + Default = 0, + Inner = 1, + Outer = 2 + } /// /// Allows specifying a macro for a parameter of a source template. From 802aa5f7722d08106244578b4ac06c8d57d5d5d1 Mon Sep 17 00:00:00 2001 From: Slava Tutushkin Date: Wed, 4 Oct 2023 22:43:52 +0200 Subject: [PATCH 2/2] Fixed after review, removed versioning --- src/Annotations.cs | 37 +++++++++++-------------------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/src/Annotations.cs b/src/Annotations.cs index 9500fa6..2bcaef5 100644 --- a/src/Annotations.cs +++ b/src/Annotations.cs @@ -788,37 +788,22 @@ public sealed class SourceTemplateAttribute : Attribute { /// /// Allows specifying which expression to capture for template execution if more than one present on the expansion. - /// If omitted, the Default is assumed. + /// If not specified, Inner is assumed. /// - /// - /// _args = args.{caret} - /// Inner: args - /// Outer: _args = args - /// - /// - /// In versions before 2023.3 the Default used to be the Outer. Since 2023.3 the Default is Inner. - /// if this causes problems in specific cases. - /// public SourceTemplateTargetExpression Target { get; set; } - /// - /// Allows to hide the source template from the users of the older versions of the product if a serious difference - /// in behaviour was introduced and template is not suitable or applicable in the previous versions. - /// - /// - /// 0 - Applicable for all versions - /// 1 - 2023.3 and higher. Notable change: default capturing expression have been changed from Outer to Inner - /// Products before 2023.2 do not know about this parameter and will ignore it. Workaround: SourceTemplateExAttribute - /// can be added to the solution as an exact copy of this attribute, older version will ignore it and will not suggest - /// templates for expansion. - /// Specify this parameter only if you have a reasons to do so. - /// - public int MinimumVersion { get; set; } } + /// + /// Provides a value for the to define how to capture + /// the expression at the point of expansion + /// public enum SourceTemplateTargetExpression { - Default = 0, - Inner = 1, - Outer = 2 + /// Selects inner expression + /// _args = args.{caret} captures args + Inner = 0, + /// Selects outer expression + /// _args = args.{caret} captures whole assignment + Outer = 1 } ///