[stringtemplate-interest] ST4: How to get group template name list?

Udo Borkowski ub at abego-software.de
Tue May 17 00:46:55 PDT 2011


What a coincidence! I was going to ask for just the same.

I am working on some kind of "Template Workbench". The list of template names of a group will be needed in various places, e.g. in some kind of browser, when analyzing groups, etc.

For now I patched the STGroup class and added this function to experiment with:

	public Set<String> getTemplateNames() {
		load();
		HashSet<String> result = new HashSet<String>();
		for (Map.Entry<String, CompiledST> e: templates.entrySet()) {
			if (e.getValue() != NOT_FOUND_ST) {
				result.add(e.getKey());
			}
		}
		return result;
	}

If it is OK with Ter I could add this to the sources.


Udo



On 17.05.2011, at 00:59, Terence Parr wrote:

> Hi Igor,
> 
> so you just need StringTemplateGroup.getTemplateNames to return a collection of strings representing the names? I I can add that if you want. what are you going to use the names for?
> T
> On May 16, 2011, at 3:23 PM, Igor Katrayev wrote:
> 
>> Hello,
>> 
>> There is a method in stringtemplate 3 called StringTemplateGroup.getTemplateNames. What is the ST4 counterpart of this method? It seems there is no anything that could give me a list of templates in a template group.
>> 
>> Igor.
>> _______________________________________________
>> stringtemplate-interest mailing list
>> stringtemplate-interest at antlr.org
>> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
> 
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20110517/e2b87fe4/attachment.html 


More information about the stringtemplate-interest mailing list