cflint / CFLint

Static code analysis for CFML (a linter)
BSD 3-Clause "New" or "Revised" License
174 stars 84 forks source link

"import" statement breaks parsing for scripted components #43

Closed ajmichels closed 9 years ago

ajmichels commented 9 years ago

If I add an import statement to the top of my CFC file I start getting all sorts of parse errors that don't make sense:

line 6:10 no viable alternative at input 'componentextends'
Stage 2!
line 6:10 no viable alternative at input 'componentextends'
line 6:42 missing ';' at 'accessors'
line 7:0 missing ';' at '{'
line 16:8 no viable alternative at input 'publicvoid'
line 18:16 extraneous input 'SomeComponent' expecting {CONTAINS, GT, GTE, LTE, LT, EQ, NEQ, OR, EQV, XOR, AND, '.', ';', '||', '&&', '[', '?'}

Here is an example file:

import my.path.SomeComponent;

/**
* Hello world.
*/
component extends="my.path.BaseComponent" accessors="true"
{

    /**
    * @type string
    */
    property name="myProp";

    public void function myFunc1()
    {
        var foo = new SomeComponent;
    }

}

If I remove the import statement it works just fine. This is however valid CFML.

ryaneberly commented 9 years ago

Thanks for reporting the parse error. I assume you are using v 0.4 from maven?

On Fri, Apr 3, 2015 at 11:24 AM, AJ Michels notifications@github.com wrote:

If I add an import my.component; statement to the top of my CFC file I start getting all sorts of parse errors that don't make sense:

line 6:10 no viable alternative at input 'componentextends' Stage 2! line 6:10 no viable alternative at input 'componentextends' line 6:42 missing ';' at 'accessors' line 7:0 missing ';' at '{' line 16:8 no viable alternative at input 'publicvoid' line 18:16 extraneous input 'SomeComponent' expecting {CONTAINS, GT, GTE, LTE, LT, EQ, NEQ, OR, EQV, XOR, AND, '.', ';', '||', '&&', '[', '?'}

Here is an example file:

import my.path.SomeComponent; /** Hello world./component extends="my.path.BaseComponent" accessors="true" {

/**    * @type string    */
property name="myProp";

public void function myFunc1()
{
    var foo = new SomeComponent;
}

}

If I remove the import and new statements it works just fine. These are however valid CFML.

— Reply to this email directly or view it on GitHub https://github.com/cflint/CFLint/issues/43.

ajmichels commented 9 years ago

Yes, I built the JAR file using Maven. CFLint 0.4.0

I am on Mac OSX v10.10.2 running Java v1.7.0_55

ryaneberly commented 9 years ago

fixed in master branch