MCPcopy Index your code
hub / github.com/antlr/codebuff / load

Method load

output/java8/1.4.13/STGroupDir.java:111–147  ·  view source on GitHub ↗

Load a template from directory or group file. Group file is given precedence over directory with same name. name is always fully-qualified.

(String name)

Source from the content-addressed store, hash-verified

109 */
110
111 @Override
112 protected CompiledST load(String name) {
113 if ( verbose ) System.out.println("STGroupDir.load("+name+")");
114 String parent = Misc.getParent(name); // must have parent; it's fully-qualified
115 String prefix = Misc.getPrefix(name);
116// if (parent.isEmpty()) {
117// // no need to check for a group file as name has no parent
118// return loadTemplateFile("/", name+TEMPLATE_FILE_EXTENSION); // load t.st file
119// }
120 URL groupFileURL;
121 try { // see if parent of template name is a group file
122 groupFileURL = new URL(root+parent+GROUP_FILE_EXTENSION);
123 }
124 catch (MalformedURLException e) {
125 errMgr.internalError(null, "bad URL: "+root+parent+GROUP_FILE_EXTENSION, e);
126 return null;
127 }
128 InputStream is = null;
129 try {
130 is = groupFileURL.openStream();
131 }
132 catch (IOException ioe) {
133 // must not be in a group file
134 String unqualifiedName = Misc.getFileName(name);
135 return loadTemplateFile(prefix, unqualifiedName+TEMPLATE_FILE_EXTENSION); // load t.st file
136 }
137 finally { // clean up
138 try {
139 if ( is!=null ) is.close();
140 }
141 catch (IOException ioe) {
142 errMgr.internalError(null, "can't close template file stream "+name, ioe);
143 }
144 }
145 loadGroupFile(prefix, root+parent+GROUP_FILE_EXTENSION);
146 return rawGetTemplate(name);
147 }
148
149 /** Load .st as relative file name relative to root by {@code prefix}. */
150

Callers

nothing calls this directly

Calls 9

getParentMethod · 0.95
getPrefixMethod · 0.95
getFileNameMethod · 0.95
loadTemplateFileMethod · 0.95
internalErrorMethod · 0.65
openStreamMethod · 0.45
closeMethod · 0.45
loadGroupFileMethod · 0.45
rawGetTemplateMethod · 0.45

Tested by

no test coverage detected