This class provides some utility methods to work with strings in macro context.

Static methods

staticformatString(s:String, pos:Position):Unknown

Available on macro

Formats String s using the usual interpolation rules.

The returned expression is a concatenation of string parts and escaped elements.

staticisFormatExpr(e:ExprOf<String>):Bool

Available on macro

Tells if e is a format string, i.e. uses single quotes ' as delimiters.

This only works if e has a position which the compiler can find. While this is true for any expressions appearing in real Haxe code (i.e. some .hx file), it might not work for expressions generated by macros.

This operation depends on the position of e.

statictoDotPath(pack:Array<String>, name:String):String

Converts a path given by package pack and name name to a String separated by dots.

If pack has no elements, the result is name.

If pack is null, the result is unspecified.

Otherwise the elements of pack are joined with a separating dot, with an appended dot separating the result from name.

statictoFieldExpr(sl:Array<String>, ?pos:Position):Expr

Converts an array of Strings sl to a field expression.

If sl has no elements, the result is null.

If sl has one element, the result is EConst(CIdent(sl[0]).

Otherwise the result is a chain of EField nodes.

If sl is null, the result is unspecified.