Skip to content

Commit 0a43548

Browse files
authored
Merge pull request #22 from tutushkin/main
Add Target and MinimumVersion to SourceTemplateAttribute
2 parents 8437ec3 + 802aa5f commit 0a43548

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

src/Annotations.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,7 @@ public PathReferenceAttribute([NotNull, PathReference] string basePath)
768768
/// Text inside these comments is added as source code when the template is applied. Template parameters
769769
/// can be used either as additional method parameters or as identifiers wrapped in two '$' signs.
770770
/// Use the <see cref="MacroAttribute"/> attribute to specify macros for parameters.
771+
/// The expression to be used in the expansion can be adjusted by the <see cref="SourceTemplateAttribute.Target"/> parameter.
771772
/// </remarks>
772773
/// <example>
773774
/// In this example, the 'forEach' method is a source template available over all values
@@ -783,7 +784,27 @@ public PathReferenceAttribute([NotNull, PathReference] string basePath)
783784
/// </example>
784785
[AttributeUsage(AttributeTargets.Method)]
785786
[Conditional("JETBRAINS_ANNOTATIONS")]
786-
public sealed class SourceTemplateAttribute : Attribute { }
787+
public sealed class SourceTemplateAttribute : Attribute
788+
{
789+
/// <summary>
790+
/// Allows specifying which expression to capture for template execution if more than one present on the expansion.
791+
/// If not specified, Inner is assumed.
792+
/// </summary>
793+
public SourceTemplateTargetExpression Target { get; set; }
794+
}
795+
/// <summary>
796+
/// Provides a value for the <see cref="SourceTemplateAttribute"/> to define how to capture
797+
/// the expression at the point of expansion
798+
/// </summary>
799+
public enum SourceTemplateTargetExpression
800+
{
801+
/// <summary>Selects inner expression</summary>
802+
/// <example><c>_args = args.{caret}</c> captures <c>args</c></example>
803+
Inner = 0,
804+
/// <summary>Selects outer expression</summary>
805+
/// <example><c>_args = args.{caret}</c> captures whole assignment</example>
806+
Outer = 1
807+
}
787808

788809
/// <summary>
789810
/// Allows specifying a macro for a parameter of a <see cref="SourceTemplateAttribute">source template</see>.

0 commit comments

Comments
 (0)