antlr / antlr/stringtemplate4

STGroup.getTemplateNames() only returns templates defined in the group

Open
#173 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1k
Forks
234
PR merge metrics
No merged PRs in 30d

Description

From my tests, it appears that calling `getTemplateNames()` on an instantiated `STGroupFile` object only returns the names of templates that are defined in the group (`.stg`) file, itself, ignoring any templates defined in subfiles pulled in via `import`. This behavior appears in my tests against v4.0.8.

Is this intended behavior? If so, what's the call to `load()` inside `getTemplateNames()` doing, if not loading imports?

If it's not intended behavior, then perhaps this is a bug...

Tested with the following files:

**`/tmp/st/foo.stg`:**
```
delimiters "%", "%"
import "parens.st"

bar(args) ::= <>
```

**`/tmp/st/parens.st`:**
```
parens(args) ::= <<
(%args; separator=","%)
>>
```

**Code**

``` java
STGroupFile g = new STGroupFile("/tmp/st/foo.stg");
System.out.println(g.getTemplateNames()); // Prints: [/bar]
ST t = g.getInstanceOf("parens"); // retrieves the "parens" template, as expected
System.out.println(g.getTemplateNames()); // Prints: [/bar]
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.