WhitespaceAroundCheck: fix for anonymous inner class #105

Closed
daniilyar opened this Issue Feb 9, 2014 · 5 comments

Comments

Projects
None yet
3 participants
Contributor

daniilyar commented Feb 9, 2014

Anonymous inner class syntax is not well recognized by WhitespaceAroundCheck, which causes false-positives:

Example:

new Thread() {
public void run() { 
// ... 
}
}.start();
Example 2 (very common in Gui code): 
new SwingWorker() {
public void construct() { 
// ... 
}
}.start();

==> wrong error "missing a space after '}'

The following correction should work and fix it:

in WhitespaceAroundCheck, line 256, instead of:

&& !((type == TokenTypes.RCURLY)
&& ((nextChar == ')')
|| (nextChar == ';')
|| (nextChar == ','))))

use the following:

&& !((type == TokenTypes.RCURLY)
&& ((nextChar == ')')
|| (nextChar == ';')
|| (nextChar == ',')
|| (nextChar == '.'))))

I want to fix this bug, but I will need some help

@carthagian carthagian added a commit to carthagian/checkstyle that referenced this issue Mar 1, 2014

@carthagian carthagian fix for anonymous inner class #105 38973f2

@carthagian carthagian added a commit to carthagian/checkstyle that referenced this issue Mar 1, 2014

@carthagian carthagian fix for anonymous inner class #105 4f2c275

@carthagian carthagian added a commit to carthagian/checkstyle that referenced this issue Mar 1, 2014

@carthagian carthagian fix for anonymous inner class #105 a4d7aa8

Did this fix your issue ?

@carthagian carthagian added a commit to carthagian/checkstyle that referenced this issue Mar 9, 2014

@carthagian carthagian fix for anonymous inner class #105 e3be1c5

@carthagian carthagian added a commit to carthagian/checkstyle that referenced this issue Mar 10, 2014

@carthagian carthagian fix for anonymous inner class #105 UT 555339f

@carthagian carthagian added a commit to carthagian/checkstyle that referenced this issue Mar 10, 2014

@carthagian carthagian fix for anonymous inner class #105 UT 7c0d9e9
Owner

romani commented Mar 30, 2014

carthagian's changes are merged to branch https://github.com/checkstyle/checkstyle/tree/issue-105, but UTs are failed.

Owner

romani commented Sep 14, 2014

fixed by #278

romani closed this Sep 14, 2014

Owner

romani commented Sep 14, 2014

issue-105 branch was removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment