diff --git a/src/libs/qmljs/qmljsdocument.cpp b/src/libs/qmljs/qmljsdocument.cpp
index b8aef81f6af97596007b4cfad906ac5974720305..f93480152e27e30802fb80961d13f839c66c9fd0 100644
--- a/src/libs/qmljs/qmljsdocument.cpp
+++ b/src/libs/qmljs/qmljsdocument.cpp
@@ -50,11 +50,16 @@ Document::Document(const QString &fileName)
 {
     QFileInfo fileInfo(fileName);
     _path = fileInfo.absolutePath();
-    _componentName = fileInfo.baseName();
-    if (! _componentName.isEmpty()) {
-        // ### TODO: check the component name.
-        if (! _componentName.at(0).isUpper())
-            _componentName.clear();
+
+    if (fileInfo.suffix() == QLatin1String("qml")) {
+        _componentName = fileInfo.baseName();
+
+        if (! _componentName.isEmpty()) {
+            // ### TODO: check the component name.
+
+            if (! _componentName.at(0).isUpper())
+                _componentName.clear();
+        }
     }
 }