Search in sources :

Example 1 with HasBody

use of lucee.transformer.bytecode.statement.HasBody in project Lucee by lucee.

the class SourceLastModifiedClassAdapter method getImports.

private static void getImports(List<String> list, Body body) throws TransformerException {
    if (ASMUtil.isEmpty(body))
        return;
    Statement stat;
    List stats = body.getStatements();
    int len = stats.size();
    for (int i = 0; i < len; i++) {
        stat = (Statement) stats.get(i);
        // IFunction
        if (stat instanceof TagImport && !StringUtil.isEmpty(((TagImport) stat).getPath(), true)) {
            ImportDefintion id = ImportDefintionImpl.getInstance(((TagImport) stat).getPath(), null);
            if (id != null && (!list.contains(id.toString()) && !list.contains(id.getPackage() + ".*"))) {
                list.add(id.toString());
            }
            stats.remove(i);
            len--;
            i--;
        } else if (stat instanceof HasBody)
            getImports(list, ((HasBody) stat).getBody());
        else if (stat instanceof HasBodies) {
            Body[] bodies = ((HasBodies) stat).getBodies();
            for (int y = 0; y < bodies.length; y++) {
                getImports(list, bodies[y]);
            }
        }
    }
}
Also used : ImportDefintion(lucee.runtime.component.ImportDefintion) TagImport(lucee.transformer.bytecode.statement.tag.TagImport) HasBodies(lucee.transformer.bytecode.statement.HasBodies) HasBody(lucee.transformer.bytecode.statement.HasBody) List(java.util.List) ArrayList(java.util.ArrayList) HasBody(lucee.transformer.bytecode.statement.HasBody)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 ImportDefintion (lucee.runtime.component.ImportDefintion)1 HasBodies (lucee.transformer.bytecode.statement.HasBodies)1 HasBody (lucee.transformer.bytecode.statement.HasBody)1 TagImport (lucee.transformer.bytecode.statement.tag.TagImport)1