OSDN Git Service

QmlJS checks: Limit warning about unintentional empty blocks.
authorChristian Kamm <christian.d.kamm@nokia.com>
Thu, 13 Oct 2011 12:19:50 +0000 (14:19 +0200)
committerChristian Kamm <christian.d.kamm@nokia.com>
Tue, 18 Oct 2011 06:15:11 +0000 (08:15 +0200)
    width: {
    }

should not trigger a warning. We now only warn if { and } are
on the same line.

Change-Id: I45fa846ff63d0a83de782c412212165845c07e72
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
src/libs/qmljs/qmljscheck.cpp

index e3d55ef..88f6ffe 100644 (file)
@@ -935,8 +935,9 @@ bool Check::visit(Block *ast)
         }
         if (!ast->statements
                 && (cast<UiPublicMember *>(p)
-                    || cast<UiScriptBinding *>(p))) {
-            addMessage(WarnUnintentinalEmptyBlock, ast->firstSourceLocation());
+                    || cast<UiScriptBinding *>(p))
+                && ast->lbraceToken.startLine == ast->rbraceToken.startLine) {
+            addMessage(WarnUnintentinalEmptyBlock, locationFromRange(ast->firstSourceLocation(), ast->lastSourceLocation()));
         }
     }
     return true;