Search in sources :

Example 1 with CFMLSource

use of cfml.parsing.CFMLSource in project CFLint by cflint.

the class TestCFMLParse method test.

@Test
public void test() {
    final CFMLSource cfmlSource = new CFMLSource("<cfcomponent><cfset/></cfcomponent>");
    System.out.println(cfmlSource.getAllCFMLTags());
    System.out.println(cfmlSource.getAllElements());
    System.out.println(cfmlSource.getChildElements());
}
Also used : CFMLSource(cfml.parsing.CFMLSource) Test(org.junit.Test)

Example 2 with CFMLSource

use of cfml.parsing.CFMLSource in project CFLint by cflint.

the class CFLint method process.

public void process(final String src, final String filename) throws ParseException, IOException {
    fireStartedProcessing(filename);
    final CFMLSource cfmlSource = new CFMLSource(src != null && src.contains("<!---") ? CommentReformatting.wrap(src) : src);
    final ParserTag firstTag = getFirstTagQuietly(cfmlSource);
    final List<Element> elements = new ArrayList<Element>();
    if (firstTag != null) {
        elements.addAll(cfmlSource.getChildElements());
    }
    if (src.contains("component") && (elements.isEmpty() || elements.get(0).getBegin() > src.indexOf("component"))) {
        // Check if pure cfscript
        final CFScriptStatement scriptStatement = cfmlParser.parseScript(src);
        Context context = new Context(filename, null, null, false, handler, scriptStatement.getTokens());
        process(scriptStatement, context);
    } else {
        processStack(elements, " ", filename, null);
    }
    fireFinishedProcessing(filename);
}
Also used : Context(com.cflint.plugins.Context) CFMLSource(cfml.parsing.CFMLSource) CFScriptStatement(cfml.parsing.cfscript.script.CFScriptStatement) ParserTag(cfml.parsing.ParserTag) Element(net.htmlparser.jericho.Element) ArrayList(java.util.ArrayList)

Aggregations

CFMLSource (cfml.parsing.CFMLSource)2 ParserTag (cfml.parsing.ParserTag)1 CFScriptStatement (cfml.parsing.cfscript.script.CFScriptStatement)1 Context (com.cflint.plugins.Context)1 ArrayList (java.util.ArrayList)1 Element (net.htmlparser.jericho.Element)1 Test (org.junit.Test)1