diff --git a/src/plugins/qmljstools/qmljsmodelmanager.cpp b/src/plugins/qmljstools/qmljsmodelmanager.cpp index a93af2bf89b..7b864263dcd 100644 --- a/src/plugins/qmljstools/qmljsmodelmanager.cpp +++ b/src/plugins/qmljstools/qmljsmodelmanager.cpp @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include #include @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -326,17 +327,13 @@ void ModelManager::loadQmlTypeDescriptions(const QString &resourcePath) ModelManagerInterface::WorkingCopy ModelManager::workingCopy() const { WorkingCopy workingCopy; - if (!Core::ICore::instance()) - return workingCopy; - - foreach (Core::IEditor *editor, Core::ICore::editorManager()->openedEditors()) { - const QString key = editor->document()->filePath(); - - if (TextEditor::ITextEditor *textEditor = qobject_cast(editor)) { - if (textEditor->context().contains(ProjectExplorer::Constants::LANG_QMLJS)) { - if (TextEditor::BaseTextEditorWidget *ed = qobject_cast(textEditor->widget())) - workingCopy.insert(key, ed->toPlainText(), ed->document()->revision()); - } + Core::DocumentModel *documentModel = Core::EditorManager::documentModel(); + foreach (Core::IDocument *document, documentModel->openedDocuments()) { + const QString key = document->filePath(); + if (TextEditor::BaseTextDocument *textDocument = qobject_cast(document)) { + // TODO the language should be a property on the document, not the editor + if (documentModel->editorsForDocument(document).first()->context().contains(ProjectExplorer::Constants::LANG_QMLJS)) + workingCopy.insert(key, textDocument->contents(), textDocument->document()->revision()); } }