Merge remote branch 'origin/2.0'

Conflicts:
	src/plugins/debugger/moduleshandler.cpp
	src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp
	src/plugins/qt4projectmanager/qt-maemo/maemopackagecontents.cpp
	src/plugins/qt4projectmanager/qt-maemo/maemosshthread.cpp
This commit is contained in:
con
2010-05-20 09:28:00 +02:00
117 changed files with 1073 additions and 533 deletions

View File

@@ -38,6 +38,8 @@
#include <qmljs/qmljsscanner.h>
#include <qmljs/qmljsevaluate.h>
#include <qmljs/qmljscompletioncontextfinder.h>
#include <qmljs/qmljslink.h>
#include <qmljs/qmljsscopebuilder.h>
#include <texteditor/basetexteditor.h>
@@ -595,6 +597,31 @@ static bool isLiteral(AST::Node *ast)
return false;
}
void CodeCompletion::addCompletions(const QHash<QString, const Interpreter::Value *> &newCompletions,
const QIcon &icon)
{
QHashIterator<QString, const Interpreter::Value *> it(newCompletions);
while (it.hasNext()) {
it.next();
TextEditor::CompletionItem item(this);
item.text = it.key();
item.icon = icon;
m_completions.append(item);
}
}
void CodeCompletion::addCompletions(const QStringList &newCompletions,
const QIcon &icon)
{
foreach (const QString &text, newCompletions) {
TextEditor::CompletionItem item(this);
item.text = text;
item.icon = icon;
m_completions.append(item);
}
}
int CodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
{
m_editor = editor;
@@ -627,10 +654,11 @@ int CodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
Interpreter::Engine interp;
Interpreter::Context context(&interp);
Link link(&context, document, snapshot, m_modelManager->importPaths());
// Set up the current scope chain.
QList<AST::Node *> astPath = semanticInfo.astPath(editor->position());
context.build(astPath, document, snapshot, m_modelManager->importPaths());
ScopeBuilder scopeBuilder(document, &context);
scopeBuilder.push(semanticInfo.astPath(editor->position()));
// Search for the operator that triggered the completion.
QChar completionOperator;
@@ -660,24 +688,12 @@ int CodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
enumerateProperties.setGlobalCompletion(true);
enumerateProperties.setEnumerateGeneratedSlots(true);
QHashIterator<QString, const Interpreter::Value *> it(enumerateProperties(qmlScopeType));
while (it.hasNext()) {
it.next();
addCompletions(enumerateProperties(qmlScopeType), symbolIcon);
addCompletions(enumerateProperties(context.scopeChain().qmlTypes), symbolIcon);
TextEditor::CompletionItem item(this);
item.text = it.key();
item.icon = symbolIcon;
m_completions.append(item);
}
it = enumerateProperties(context.scopeChain().qmlTypes);
while (it.hasNext()) {
it.next();
TextEditor::CompletionItem item(this);
item.text = it.key();
item.icon = symbolIcon;
m_completions.append(item);
if (ScopeBuilder::isPropertyChangesObject(&context, qmlScopeType)
&& context.scopeChain().qmlScopeObjects.size() == 2) {
addCompletions(enumerateProperties(context.scopeChain().qmlScopeObjects.first()), symbolIcon);
}
}
@@ -713,60 +729,33 @@ int CodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
// It's a global completion.
EnumerateProperties enumerateProperties(&context);
enumerateProperties.setGlobalCompletion(true);
QHashIterator<QString, const Interpreter::Value *> it(enumerateProperties());
while (it.hasNext()) {
it.next();
TextEditor::CompletionItem item(this);
item.text = it.key();
item.icon = symbolIcon;
m_completions.append(item);
}
addCompletions(enumerateProperties(), symbolIcon);
}
if (doJsKeywordCompletion) {
// add js keywords
foreach (const QString &word, Scanner::keywords()) {
TextEditor::CompletionItem item(this);
item.text = word;
item.icon = keywordIcon;
m_completions.append(item);
}
addCompletions(Scanner::keywords(), keywordIcon);
}
// add qml extra words
if (doQmlKeywordCompletion && isQmlFile) {
static QStringList qmlWords;
static QStringList qmlWordsAlsoInJs;
if (qmlWords.isEmpty()) {
qmlWords << QLatin1String("property")
<< QLatin1String("readonly")
//<< QLatin1String("readonly")
<< QLatin1String("signal")
<< QLatin1String("import");
}
foreach (const QString &word, qmlWords) {
TextEditor::CompletionItem item(this);
item.text = word;
item.icon = keywordIcon;
m_completions.append(item);
if (qmlWordsAlsoInJs.isEmpty()) {
qmlWordsAlsoInJs << QLatin1String("default")
<< QLatin1String("function");
}
if (!doJsKeywordCompletion) {
{
TextEditor::CompletionItem item(this);
item.text = QLatin1String("default");
item.icon = keywordIcon;
m_completions.append(item);
}
{
TextEditor::CompletionItem item(this);
item.text = QLatin1String("function");
item.icon = keywordIcon;
m_completions.append(item);
}
}
addCompletions(qmlWords, keywordIcon);
if (!doJsKeywordCompletion)
addCompletions(qmlWordsAlsoInJs, keywordIcon);
}
}
@@ -787,15 +776,7 @@ int CodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
if (value && completionOperator == QLatin1Char('.')) { // member completion
EnumerateProperties enumerateProperties(&context);
QHashIterator<QString, const Interpreter::Value *> it(enumerateProperties(value));
while (it.hasNext()) {
it.next();
TextEditor::CompletionItem item(this);
item.text = it.key();
item.icon = symbolIcon;
m_completions.append(item);
}
addCompletions(enumerateProperties(value), symbolIcon);
} else if (value && completionOperator == QLatin1Char('(') && m_startPosition == editor->position()) {
// function completion
if (const Interpreter::FunctionValue *f = value->asFunctionValue()) {

View File

@@ -39,6 +39,12 @@ namespace TextEditor {
class ITextEditable;
}
namespace QmlJS {
namespace Interpreter {
class Value;
}
}
namespace QmlJSEditor {
class ModelManagerInterface;
@@ -74,6 +80,11 @@ private:
bool maybeTriggersCompletion(TextEditor::ITextEditable *editor);
bool isDelimiter(const QChar &ch) const;
void addCompletions(const QHash<QString, const QmlJS::Interpreter::Value *> &newCompletions,
const QIcon &icon);
void addCompletions(const QStringList &newCompletions,
const QIcon &icon);
ModelManagerInterface *m_modelManager;
TextEditor::ITextEditable *m_editor;
int m_startPosition;

View File

@@ -39,6 +39,8 @@
#include <qmljs/qmljscheck.h>
#include <qmljs/qmljsevaluate.h>
#include <qmljs/qmljsdocument.h>
#include <qmljs/qmljslink.h>
#include <qmljs/qmljsscopebuilder.h>
#include <qmljs/parser/qmljsastvisitor_p.h>
#include <qmljs/parser/qmljsast_p.h>
#include <qmljs/parser/qmljsengine_p.h>
@@ -1007,8 +1009,9 @@ TextEditor::BaseTextEditor::Link QmlJSTextEditor::findLinkAt(const QTextCursor &
Interpreter::Engine interp;
Interpreter::Context context(&interp);
context.build(semanticInfo.astPath(cursorPosition), semanticInfo.document,
semanticInfo.snapshot, m_modelManager->importPaths());
QmlJS::Link linkedSnapshot(&context, semanticInfo.document, semanticInfo.snapshot, m_modelManager->importPaths());
ScopeBuilder scopeBuilder(semanticInfo.document, &context);
scopeBuilder.push(semanticInfo.astPath(cursorPosition));
Evaluate check(&context);
const Interpreter::Value *value = check.reference(node);
@@ -1018,7 +1021,7 @@ TextEditor::BaseTextEditor::Link QmlJSTextEditor::findLinkAt(const QTextCursor &
if (! (value && value->getSourceLocation(&fileName, &line, &column)))
return Link();
Link link;
BaseTextEditor::Link link;
link.fileName = fileName;
link.line = line;
link.column = column - 1; // adjust the column

View File

@@ -39,6 +39,8 @@
#include <qmljs/qmljsbind.h>
#include <qmljs/qmljsevaluate.h>
#include <qmljs/qmljsinterpreter.h>
#include <qmljs/qmljslink.h>
#include <qmljs/qmljsscopebuilder.h>
#include <qmljs/parser/qmljsast_p.h>
#include <texteditor/itexteditor.h>
#include <texteditor/basetexteditor.h>
@@ -172,7 +174,9 @@ void HoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, int p
Interpreter::Engine interp;
Interpreter::Context context(&interp);
context.build(astPath, qmlDocument, snapshot, m_modelManager->importPaths());
Link link(&context, qmlDocument, snapshot, m_modelManager->importPaths());
ScopeBuilder scopeBuilder(qmlDocument, &context);
scopeBuilder.push(astPath);
Evaluate check(&context);
const Interpreter::Value *value = check(node);