diff --git a/src/shared/qml/qmldocument.cpp b/src/shared/qml/qmldocument.cpp
index 06e11626730ea9b9625aff4bc5f6adb0bab44837..95698a21c997585eb704f96e1df913f6070ec7e7 100644
--- a/src/shared/qml/qmldocument.cpp
+++ b/src/shared/qml/qmldocument.cpp
@@ -117,6 +117,8 @@ bool QmlDocument::parse()
 
          Internal::QmlIdCollector collect;
         _ids = collect(*this);
+        if (_diagnosticMessages.isEmpty())
+            _diagnosticMessages = collect.diagnosticMessages();
     }
 
     return _parsedCorrectly;
diff --git a/src/shared/qml/qmlidcollector.cpp b/src/shared/qml/qmlidcollector.cpp
index 2ac5ed95eb931eae0bc7051d06411c0cbf0735ea..381af48d280d7131ae06046978f40e5058a5b703 100644
--- a/src/shared/qml/qmlidcollector.cpp
+++ b/src/shared/qml/qmlidcollector.cpp
@@ -31,7 +31,6 @@
 
 #include "qmlidcollector.h"
 #include "qmljsast_p.h"
-#include "qmljsengine_p.h"
 
 using namespace QmlJS;
 using namespace QmlJS::AST;
@@ -108,10 +107,14 @@ QmlSymbolFromFile *QmlIdCollector::switchSymbol(QmlJS::AST::UiObjectMember *node
 
 void QmlIdCollector::addId(const QString &id, QmlJS::AST::UiScriptBinding *ast)
 {
-    if (!_ids.contains(id) && _currentSymbol) {
-        QmlSymbolFromFile *symbol = _currentSymbol->findMember(ast);
+    if (!_currentSymbol)
+        return;
 
-        if (QmlIdSymbol *idSymbol = symbol->asIdSymbol())
-            _ids[id] = idSymbol;
+    if (_ids.contains(id)) {
+        _diagnosticMessages.append(DiagnosticMessage(DiagnosticMessage::Warning, ast->statement->firstSourceLocation(), "Duplicate ID"));
+    } else {
+        if (QmlSymbolFromFile *symbol = _currentSymbol->findMember(ast))
+            if (QmlIdSymbol *idSymbol = symbol->asIdSymbol())
+                _ids[id] = idSymbol;
     }
 }
diff --git a/src/shared/qml/qmlidcollector.h b/src/shared/qml/qmlidcollector.h
index 4206ca8ce36632405d2d374cf722852a99cf6802..3db91fe4b9df22d2888f492b83ef6950c66aae54 100644
--- a/src/shared/qml/qmlidcollector.h
+++ b/src/shared/qml/qmlidcollector.h
@@ -30,15 +30,16 @@
 #ifndef QMLIDCOLLECTOR_H
 #define QMLIDCOLLECTOR_H
 
+#include <qml/parser/qmljsastvisitor_p.h>
+#include <qml/parser/qmljsengine_p.h>
+#include <qml/qmldocument.h>
+#include <qml/qmlsymbol.h>
+
 #include <QMap>
 #include <QPair>
 #include <QStack>
 #include <QString>
 
-#include <qml/parser/qmljsastvisitor_p.h>
-#include <qml/qmldocument.h>
-#include <qml/qmlsymbol.h>
-
 namespace Qml {
 namespace Internal {
 
@@ -47,6 +48,9 @@ class QML_EXPORT QmlIdCollector: protected QmlJS::AST::Visitor
 public:
     QMap<QString, Qml::QmlIdSymbol*> operator()(QmlEditor::QmlDocument &doc);
 
+    QList<QmlJS::DiagnosticMessage> diagnosticMessages()
+    { return _diagnosticMessages; }
+
 protected:
     virtual bool visit(QmlJS::AST::UiArrayBinding *ast);
     virtual bool visit(QmlJS::AST::UiObjectBinding *ast);
@@ -61,6 +65,7 @@ private:
     QmlEditor::QmlDocument *_doc;
     QMap<QString, Qml::QmlIdSymbol*> _ids;
     Qml::QmlSymbolFromFile *_currentSymbol;
+    QList<QmlJS::DiagnosticMessage> _diagnosticMessages;
 };
 
 } // namespace Internal