All Downloads are FREE. Search and download functionalities are using the official Maven repository.

mal.jamal-snippet.2.8.1.source-code.snippet.jim Maven / Gradle / Ivy

The newest version!
{@comment this file defines user defined macros that help the use of the built-in snippet macros}

{@define java:class:simpleName($x)={#java:class {@define classFormat=$simpleName}$x}}
{@define java:class:canonicalName($x)={#java:class {@define classFormat=$canonicalName}$x}}
{@define java:class:name($x)={#java:class {@define classFormat=$name}$x}}
{@define java:class:packageName($x)={#java:class {@define classFormat=$packageName}$x}}
{@define java:class:typeName($x)={#java:class {@define classFormat=$typeName}$x}}

{@define java:method:name($x)={#java:method {@define methodFormat=$name}$x}}
{@define java:method:classSimpleName($x)={#java:method {@define methodFormat=$classSimpleName}$x}}
{@define java:method:className($x)={#java:class {@define methodFormat=$className}$x}}
{@define java:method:classCanonicalName($x)={#java:method {@define methodFormat=$classCanonicalName}$x}}
{@define java:method:classTypeName($x)={#java:method {@define methodFormat=$classTypeName}$x}}
{@define java:method:packageName($x)={#java:method {@define methodFormat=$packageName}$x}}
{@define java:method:typeClass($x)={#java:method {@define methodFormat=$typeClass}$x}}
{@define java:method:exceptions($x)={#java:method {@define methodFormat=$exceptions}$x}}
{@define java:method:parameterTypes($x)={#java:method {@define methodFormat=$parameterTypes}$x}}
{@define java:method:parameterCount($x)={#java:method {@define methodFormat=$parameterCount}$x}}
{@define java:method:modifiers($x)={#java:method {@define methodFormat=$modifiers}$x}}

{@define chop($x)={@options regex}{@replace /$x/.$//}}

{@define java:method:parameterTypes:simpleName($x)={chop /{!#for $z in ({java:method:parameterTypes /$x})={`java:class:simpleName $z},}}}
{@define java:method:exceptions:simpleName($x)={chop /{!#for $z in ({java:method:exceptions /$x})={`java:class:simpleName $z},}}}

+-----------------------------------------------------------------------------------------------------------------------
MACRO: docFrom

Automatically include all the snippets defined in a file in the order they are defined and also evaluate them.
DOES NOT COLLECT THE SNIPPETS from the file. They have to be collected.

This macro can be used to include documentation from a program source file.
The macro argument has to be the file included with the option [verbatim].
The macro selects the lines that start a snippet and creates a list from the snippet names.
When it is done it iterates through the snippet names and calls the `snip:eval` macro to include the snippets evaluated.

{@define [named] docFrom(file)=
    {@comment select the lines that contain a 'snippet name' string starting a snippet}\
    {@define allSnippetStartLines={#killLines keep pattern="^.*snippet\\s+\\w+.*$"
{#include [verbatim]file}}}
    {@comment convert '...snippet name ...' -> 'name,' }\
    {@define snipetNamesWithNewLines={#replaceLines detectNoChange=false replace="/^.*snippet\\s+(\\w+).*$/$1,/"
        {allSnippetStartLines}}}
    {@comment remove all the new lines from the list of snippet names}\
    {@define snippetNames={#replace (regex detectNoChange=false) /
        {snipetNamesWithNewLines}/\n//}}
    {!#for [skipEmpty] $snippet in ({snippetNames})={@ident {#snip:eval (snippet=$snippet)}
}}}
+-----------------------------------------------------------------------------------------------------------------------





© 2015 - 2024 Weber Informatics LLC | Privacy Policy