Generate a call hierarchy of the template and its partials
@param currentFile
@param partials
772322
function createPartialTree (currentFile, partials, visitedFiles) {
  if (visitedFiles[currentFile.name]) {
    return {
      label: '*' + currentFile.name + '*',
      name: currentFile.name
    }
  }
  visitedFiles[currentFile.name] = true

  var result = {
    label: currentFile.name,
    name: currentFile.name,
    summary: _.trunc(chainOrUndefined(currentFile, 'apidocs', 0, 'parsed', 'description'), {
      separator: ' ',
      length: 50
    })
  }
  if (currentFile.children.length > 0) {
    _.merge(result, {
      children: currentFile.children.map(function (child) {
        return createPartialTree(partials[child], partials, visitedFiles)
      })
    })
  }
  return result
}
910879
private void checkBasicCall(CallBasicNode node, TemplateRegistry registry) {
    TemplateMetadata callee = registry.getBasicTemplateOrElement(node.getCalleeName());

    if (callee == null) {
      String extraErrorMessage =
          SoyErrors.getDidYouMeanMessage(
              registry.getBasicTemplateOrElementNames(), node.getCalleeName());
      errorReporter.report(
          node.getSourceLocation(),
          CALL_TO_UNDEFINED_TEMPLATE,
          node.getCalleeName(),
          extraErrorMessage);
    } else {
      SoyFileKind calleeKind = callee.getSoyFileKind();
      String callerFilePath = node.getSourceLocation().getFilePath();
      String calleeFilePath = callee.getSourceLocation().getFilePath();
      if (calleeKind == SoyFileKind.INDIRECT_DEP) {
        errorReporter.report(
            node.getSourceLocation(),
            CALL_TO_INDIRECT_DEPENDENCY,
            calleeFilePath);
      }
    }
  }
1309804
function renderJade(viewFiles, viewModel, callback) {
  var jadeFile = viewFiles[0];

  if (viewFiles.length > 1) {
    console.warn('TEMPLATES: More than one possible Jade view file found, will take main or index.');
    jadeFile = _.find(viewFiles, function (file) {
      return Path.basename(file, Path.extname(file)) === 'main' || Path.basename(file, Path.extname(file)) === 'index';
    });
  }

  if (jadeFile) {
    // Handle exports.
    viewModel.basedir = Path.join(__dirname, '../templates/jade/');
    
    Consolidate.jade(jadeFile, viewModel, function (err, html) {
      if (!err) {
        callback && callback(html);
      }
      else {
        console.error('TEMPLATES: Error generating view from Jade file ' + jadeFile, err);
        callback && callback();
      }
    });
  }
  else {
    console.warn('TEMPLATES: Could not find appropriate main Jade view file, please rename your main template to main.jade or index.jade.');
    callback && callback();
  }
}
1011985
private void genFileStructure() {
    List<INode> leaves = getLeaves();
    int totalLeaves = leaves.size();
    for (int i=0; i<numOfFiles; i++) {
      int leaveNum = r.nextInt(totalLeaves);
      double fileSize;
      do {
        fileSize = r.nextGaussian()+avgFileSize;
      } while (fileSize<0);
      leaves.get(leaveNum).addChild(
          new FileINode(FILE_NAME_PREFIX+i, fileSize));
    }
  }
1066535
private void buildCallHierarchy() {
                
        final ExecutionNodeUsage rootUsage = new ExecutionNodeUsage(this.rootNode);
        
        callerHierarchy.put(rootUsage, null); // nothing calls this
        
        for (final FeatureNode feature : this.rootNode.getChildren()){
            
            addToCallHierarchy(feature);
            
            for (final ScenarioNode scenario : feature.getChildren()){

                addToCallHierarchy(scenario);

                processChildrenForCallHierarchy(scenario.getChildren());
            }
        }
    }
1213841
function(current_templates) {

		var i = 1,
			count = current_templates.length,
			guid,
			previous_template = current_templates[0];

		if (previous_template) { // if list is not empty

			delete this._remove_queue[previous_template.guid];

			// handle first template separately from others
			if (!previous_template.isInDOM()) {

				this._insertFirstTemplate(previous_template);
				this._fire('insertion_complete', previous_template);

			}

			for (; i < count; i++) {

				delete this._remove_queue[current_templates[i].guid];

				if (current_templates[i].isInDOM()) {

					this._moveTemplate(current_templates[i], previous_template, current_templates);

				} else {

					this._insertTemplate(current_templates[i], previous_template, i);
					this._fire('insertion_complete', current_templates[i]);

				}

				previous_template = current_templates[i];

			}

		}

		for (guid in this._remove_queue) {

			if (this._remove_queue[guid].isInDOM()) {

				this._removeTemplate(this._remove_queue[guid]);
				this._fire('removal_complete', this._remove_queue[guid]);

			}

		}

		this._remove_queue = {};

	}
137335
function addPartial(filename, done) {
      // Create a copy of the file and delete it from the database.
      const file = clone(files[filename])
      delete files[filename]

      // Compile the partial.
      const info = path.parse(filename)
      const transform = info.ext ? info.ext.substring(1) : null
      const transformer = getTransformer(transform)
      if (transformer) {
        // Construct the options.
        const options = extend({}, metalsmith.metadata(), file, {
          filename: path.join(metalsmith.source(), filename)
        })

        // Compile the partial.
        transformer.compileAsync(file.contents.toString(), options).then(template => {
          /**
           * Define the partial as a function.
           */
          metalsmith.metadata().partials[info.name] = locals => {
            const opt = extend({}, options, locals)
            return template.fn.apply(file, [opt])
          }
          metalsmith.metadata().partials[info.name].file = file
          done()
        }, done)
      } else {
        // Do not error out when the Transformer is not found.
        done()
      }
    }
384463
private void importFile( FormattableContainer currentRule, final String name ) {
        String filename = name.trim();
        boolean isReference = reader.isReference();
        boolean isCss = false;
        boolean isLess = false;
        boolean isMultiple = reader.isMultiple();
        boolean isInline = false;
        boolean isOptional = false;
        if( filename.startsWith( "(" ) ) {
            int endIdx = filename.indexOf( ')', 1);
            if( endIdx > 0 ) {
                StringTokenizer tokenizer = new StringTokenizer( filename.substring( 1, endIdx ), "," );
                filename = name.substring( endIdx + 1 ).trim();
                while( tokenizer.hasMoreTokens() ) {
                    String keywordStr = tokenizer.nextToken().trim();
                    switch( keywordStr ) {
                        case "inline":
                            isInline = true;
                            break;
                        case "optional":
                            isOptional = true;
                            break;
                        case "once":
                            isMultiple = false;
                            break;
                        case "multiple":
                            isMultiple = true;
                            break;
                        case "less":
                            isLess = true;
                            isCss = false;
                            break;
                        case "css":
                            isCss = true;
                            isLess = false;
                            break;
                        case "reference":
                            isReference = true;
                            break;
                        default:
                            throw new LessException( "Unknown @import keyword: " + keywordStr );
                    }
                }
            }
        }

        Object[] old = { reader, baseURL, relativeURL }; //store on the heap to reduce the stack size
        try {
            int i;
            boolean isURL;
            if( filename.startsWith( "url(" ) ) {
                i = 4;
                isURL = true;
            } else {
                i = 0;
                isURL = false;
            }
            StringBuilder builder = cachesBuilder;
            String media = null;
            char quote = 0;
            LOOP:
            for( ; i < filename.length(); i++ ) {
                char ch = filename.charAt( i );
                switch(ch){
                    case '\"':
                    case '\'':
                        if( quote == 0 ) {
                            quote = ch;
                        } else {
                            quote = 0;
                            if( !isURL ) {
                                break LOOP;
                            }
                        }
                        break;
                    case '\\':
                        builder.append( filename.charAt( ++i ) );
                        break;
                    case ')':
                        if( quote == 0 ) {
                            break LOOP;
                        }
                        //$FALL-THROUGH$
                    default:
                        builder.append( ch );
                }
            }
            if( i < filename.length() - 1 ) {
                //additional content after url(...)
                media = filename.substring( i + 1 ).trim();
                Rule rule = new Rule( reader, currentRule, "@media " + media, null, null );
                currentRule.add( rule );
                currentRule = rule;
            }
            filename = trim( builder );

            if( filename.contains( "@{" ) ) { // filename with variable name, we need to parse later
                if( currentRule != this ) {
                    //import is inside of a mixin and will be process if the mixin will be process
                    currentRule.add( new CssAtRule( reader, "@import " + name + ';' ) );
                    return;
                }
                HashMap<String, Expression> importVariables = new DefaultedHashMap<>( variables );
                variables = new DefaultedHashMap<>( importVariables );
                Formattable lastRuleBefore = rules.size() == 0 ? null : rules.get( rules.size() - 1 );
                LazyImport lazy = new LazyImport( reader, baseURL, name, importVariables, lastRuleBefore );
                if( lazyImports == null ) {
                    lazyImports = new ArrayList<>();
                }
                lazyImports.add( lazy );
                return;
            }
            if( !isLess && !isInline && (isCss || filename.endsWith( "css" )) ) {
                // filenames ends with "css" will not be inline else a CSS @import directive is written
                currentRule.add( new CssAtRule( reader, "@import " + name + ';') );
                return;
            }
            baseURL = baseURL == null ? new URL( filename ) : new URL( baseURL, filename );
            if( !isLess && !isInline && baseURL.getPath().endsWith( "css" ) ) {
                // URL path ends with "css" will not be inline else a CSS @import directive is written
                currentRule.add( new CssAtRule( reader, "@import " + name + ';') );
                return;
            }
            if( "file".equals( baseURL.getProtocol() ) && filename.lastIndexOf( '.' ) <= filename.lastIndexOf( '/' ) ) {
                filename += ".less";
                baseURL = (URL)old[1];
                baseURL = baseURL == null ? new URL( filename ) : new URL( baseURL, filename );
            }
            relativeURL = new URL( relativeURL, filename );
            if( imports.add( baseURL ) || isMultiple ) {
                if( isReference != reader.isReference() ) {
                    add( new ReferenceInfo( isReference ) );
                }
                Reader importReader = readerFactory.create( baseURL );
                if( isInline ) {
                    Scanner scanner = new Scanner(importReader).useDelimiter( "\\A" );
                    if( scanner.hasNext() ) {
                        currentRule.add( new CssAtRule( reader, scanner.next() ) );
                    }
                } else {
                    reader = new LessLookAheadReader( importReader, filename, isReference, isMultiple );
                    parse( currentRule );
                    reader.close();
                }
            }
        } catch( LessException ex ) {
            throw ex;
        } catch( IOException ex ) {
            if( !isOptional ) {
                throw new LessException( ex );
            }
        } catch( Exception ex ) {
            throw new LessException( ex );
        } finally {
            reader = (LessLookAheadReader)old[0];
            baseURL = (URL)old[1];
            relativeURL = (URL)old[2];
            if( isReference != reader.isReference() ) {
                add( new ReferenceInfo( reader.isReference() ) );
            }
        }
    }
894456
function( tmpl, data, options, parentItem ) {
			var ret, topLevel = !parentItem;
			if ( topLevel ) {
				// This is a top-level tmpl call (not from a nested template using {{tmpl}})
				parentItem = topTmplItem;
				tmpl = jQuery.template[tmpl] || jQuery.template( null, tmpl );
				wrappedItems = {}; // Any wrapped items will be rebuilt, since this is top level
			} else if ( !tmpl ) {
				// The template item is already associated with DOM - this is a refresh.
				// Re-evaluate rendered template for the parentItem
				tmpl = parentItem.tmpl;
				newTmplItems[parentItem.key] = parentItem;
				parentItem.nodes = [];
				if ( parentItem.wrapped ) {
					updateWrapped( parentItem, parentItem.wrapped );
				}
				// Rebuild, without creating a new template item
				return jQuery( build( parentItem, null, parentItem.tmpl( jQuery, parentItem ) ));
			}
			if ( !tmpl ) {
				return []; // Could throw...
			}
			if ( typeof data === "function" ) {
				data = data.call( parentItem || {} );
			}
			if ( options && options.wrapped ) {
				updateWrapped( options, options.wrapped );
			}
			ret = jQuery.isArray( data ) ? 
				jQuery.map( data, function( dataItem ) {
					return dataItem ? newTmplItem( options, parentItem, tmpl, dataItem ) : null;
				}) :
				[ newTmplItem( options, parentItem, tmpl, data ) ];
			return topLevel ? jQuery( build( parentItem, null, ret ) ) : ret;
		}
564339
public void deleteTemplate(File templateFile) {
        ThymeLeafTemplateImplementation template = getTemplateByFile(templateFile);
        if (template != null) {
            deleteTemplate(template);
        }
    }
1024093
function invokePartialWrapper(partial, context, options) {
  var env = Handlebars;
  if (options.hash) {
    context = Object.assign({}, context, options.hash);
    if (options.ids) {
      options.ids[0] = true;
    }
  }

  partial = env.VM.resolvePartial.call(env.VM, partial, context, options);
  var result = env.VM.invokePartial.call(env.VM, partial, context, options);

  if (result == null && env.compile) {
    options.partials[options.name] = env.compile(partial, options);
    result = options.partials[options.name](context, options);
  }

  if (result != null) {
    if (options.indent) {
      let lines = result.split('\n');
      for (let i = 0, l = lines.length; i < l; i++) {
        if (!lines[i] && i + 1 === l) {
          break;
        }

        lines[i] = options.indent + lines[i];
      }
      result = lines.join('\n');
    }
    return result;
  }

  throw new Exception('The partial ' + options.name + ' could not be compiled when running in runtime-only mode');
}
300822
@Override
  protected void visitSoyFileNode(SoyFileNode node) {
    templatesInFile = new LinkedHashSet<>();
    for (TemplateNode template : node.getChildren()) {
      templatesInFile.add(template.getTemplateName());
    }

    calleesNotInFile = new LinkedHashSet<>();
    visitChildren(node);
  }
727230
private ThymeLeafTemplateImplementation getTemplateByFile(File templateFile) {
        try {
            return getTemplateByURL(templateFile.toURI().toURL());
        } catch (MalformedURLException e) {  //NOSONAR
            // Ignored.
        }
        return null;
    }
882923
function Templates(options) {
  if (!(this instanceof Templates)) {
    return new Templates(options);
  }

  Base.call(this, null, options);
  this.is('templates');
  this.define('isApp', true);
  this.use(utils.option());
  this.use(utils.plugin());
  this.initTemplates();
}
665498
void processParseResult(final URI currentFile) {
        // Category non-copyto result
        for (final Reference file: listFilter.getNonCopytoResult()) {
            categorizeReferenceFile(file);
        }
        for (final Map.Entry<URI, URI> e : listFilter.getCopytoMap().entrySet()) {
            final URI source = e.getValue();
            final URI target = e.getKey();
            copyTo.put(target, source);
        }
        schemeSet.addAll(listFilter.getSchemeRefSet());

        hrefTargetSet.addAll(listFilter.getHrefTargets());
        conrefTargetSet.addAll(listFilter.getConrefTargets());
        nonConrefCopytoTargetSet.addAll(listFilter.getNonConrefCopytoTargets());
        coderefTargetSet.addAll(listFilter.getCoderefTargets());
        outDitaFilesSet.addAll(listFilter.getOutFilesSet());

        // Generate topic-scheme dictionary
        final Set<URI> schemeSet = listFilter.getSchemeSet();
        if (schemeSet != null && !schemeSet.isEmpty()) {
            Set<URI> children = schemeDictionary.get(currentFile);
            if (children == null) {
                children = new HashSet<>();
            }
            children.addAll(schemeSet);
            schemeDictionary.put(currentFile, children);
            final Set<URI> hrfSet = listFilter.getHrefTargets();
            for (final URI filename: hrfSet) {
                children = schemeDictionary.get(filename);
                if (children == null) {
                    children = new HashSet<>();
                }
                children.addAll(schemeSet);
                schemeDictionary.put(filename, children);
            }
        }
    }
827476
public void generateTreeFile() throws IOException {
        HtmlTree body = getTreeHeader();
        Content headContent = getResource("doclet.Hierarchy_For_All_Packages");
        Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, false,
                HtmlStyle.title, headContent);
        Content div = HtmlTree.DIV(HtmlStyle.header, heading);
        addPackageTreeLinks(div);
        HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
                ? HtmlTree.MAIN()
                : body;
        htmlTree.addContent(div);
        HtmlTree divTree = new HtmlTree(HtmlTag.DIV);
        divTree.addStyle(HtmlStyle.contentContainer);
        addTree(classtree.baseclasses(), "doclet.Class_Hierarchy", divTree);
        addTree(classtree.baseinterfaces(), "doclet.Interface_Hierarchy", divTree);
        addTree(classtree.baseAnnotationTypes(), "doclet.Annotation_Type_Hierarchy", divTree);
        addTree(classtree.baseEnums(), "doclet.Enum_Hierarchy", divTree);
        htmlTree.addContent(divTree);
        if (configuration.allowTag(HtmlTag.MAIN)) {
            body.addContent(htmlTree);
        }
        if (configuration.allowTag(HtmlTag.FOOTER)) {
            htmlTree = HtmlTree.FOOTER();
        } else {
            htmlTree = body;
        }
        addNavLinks(false, htmlTree);
        addBottom(htmlTree);
        if (configuration.allowTag(HtmlTag.FOOTER)) {
            body.addContent(htmlTree);
        }
        printHtmlDocument(null, true, body);
    }
1240562
function Templater(options) {
  if (options == null) {
    options = { allowEval: true };
  }
  this.options = options;
  if (options.stack && Array.isArray(options.stack)) {
    this.stack = options.stack;
  }
  else if (typeof options.stack === 'string') {
    this.stack = [ options.stack ];
  }
  else {
    this.stack = [];
  }
  this.nodes = [];
}