/**
  * Load a template from dir or group file. Group file is given precedence over dir with same name.
  */
 @Override
 protected CompiledST load(String name) {
   String parent = Misc.getPrefix(name);
   try {
     if (fProvider.templateExists(parent + ".stg")) {
       loadGroupFile(parent, parent + ".stg");
     } else if (fProvider.templateExists(name + ".st")) {
       loadTemplateFile(parent, name + ".st");
     }
   } catch (IOException ioe) {
     errMgr.internalError(null, "can't load template file " + name, ioe);
   }
   return rawGetTemplate(name);
 }
 @Override
 public void importTemplates(Token fileNameToken) {
   String fileName = fileNameToken.getText();
   // do nothing upon syntax error
   if (fileName == null || fileName.equals("<missing STRING>")) {
     return;
   }
   fileName = Misc.strip(fileName, 1);
   STGroup g = null;
   try {
     if (fProvider.templateExists(fileName)) {
       g = new STGroup();
       g.setListener(this.getListener());
       InputStream input = fProvider.getTemplate(fileName);
       ANTLRInputStream templateStream = new ANTLRInputStream(input);
       templateStream.name = fileName;
       CompiledST code = g.loadTemplateFile("", fileName, templateStream);
       if (code == null) {
         g = null;
       }
     }
   } catch (IOException ioe) {
     errMgr.internalError(null, "can't read from " + fileName, ioe);
     g = null;
   }
   if (g == null) {
     errMgr.compileTimeError(ErrorType.CANT_IMPORT, null, fileNameToken, fileName);
   } else {
     importTemplates(g);
   }
 }