Commit 8c58a2b3 authored by Kavindra Devi Palaraja's avatar Kavindra Devi Palaraja
Browse files

Merge branch 'master' of git@scm.dev.nokia.troll.no:creator/mainline

parents 1e8e1c05 3ba52b25
......@@ -602,8 +602,7 @@ QDumper &QDumper::operator<<(const QByteArray &ba)
QDumper &QDumper::operator<<(const QString &str)
{
QByteArray ba = str.toUtf8();
putBase64Encoded(ba.constData(), ba.size());
putBase64Encoded((const char *)str.constData(), 2 * str.size());
return *this;
}
......@@ -649,7 +648,7 @@ void QDumper::putEllipsis()
P(dumper, "value", value); \
P(dumper, "type", NS"QString"); \
P(dumper, "numchild", "0"); \
P(dumper, "valueencoded", "1"); \
P(dumper, "valueencoded", "2"); \
dumper.endHash();
// simple integer property
......@@ -680,7 +679,7 @@ void QDumper::putEllipsis()
P(dumper, "name", name); \
P(dumper, "value", QString(QLatin1String("'%1' (%2, 0x%3)")) \
.arg(value).arg(value.unicode()).arg(value.unicode(), 0, 16)); \
P(dumper, "valueencoded", "1"); \
P(dumper, "valueencoded", "2"); \
P(dumper, "type", NS"QChar"); \
P(dumper, "numchild", "0"); \
dumper.endHash();
......@@ -755,7 +754,7 @@ static void qDumpInnerValueHelper(QDumper &d, const char *type, const void *addr
const QObject *ob = reinterpret_cast<const QObject *>(addr);
P(d, "addr", ob);
P(d, "value", ob->objectName());
P(d, "valueencoded", "1");
P(d, "valueencoded", "2");
P(d, "type", NS"QObject");
P(d, "displayedtype", ob->metaObject()->className());
} else {
......@@ -767,7 +766,7 @@ static void qDumpInnerValueHelper(QDumper &d, const char *type, const void *addr
case 'S':
if (isEqual(type, "QString")) {
d.addCommaIfNeeded();
d << field << "encoded=\"1\",";
d << field << "encoded=\"2\",";
P(d, field, *(QString*)addr);
}
return;
......@@ -857,7 +856,7 @@ static void qDumpQDateTime(QDumper &d)
P(d, "value", "(null)");
} else {
P(d, "value", date.toString());
P(d, "valueencoded", "1");
P(d, "valueencoded", "2");
}
P(d, "type", NS"QDateTime");
P(d, "numchild", "3");
......@@ -901,7 +900,7 @@ static void qDumpQDir(QDumper &d)
{
const QDir &dir = *reinterpret_cast<const QDir *>(d.data);
P(d, "value", dir.path());
P(d, "valueencoded", "1");
P(d, "valueencoded", "2");
P(d, "type", NS"QDir");
P(d, "numchild", "3");
if (d.dumpChildren) {
......@@ -917,7 +916,7 @@ static void qDumpQFile(QDumper &d)
{
const QFile &file = *reinterpret_cast<const QFile *>(d.data);
P(d, "value", file.fileName());
P(d, "valueencoded", "1");
P(d, "valueencoded", "2");
P(d, "type", NS"QFile");
P(d, "numchild", "2");
if (d.dumpChildren) {
......@@ -933,7 +932,7 @@ static void qDumpQFileInfo(QDumper &d)
{
const QFileInfo &info = *reinterpret_cast<const QFileInfo *>(d.data);
P(d, "value", info.filePath());
P(d, "valueencoded", "1");
P(d, "valueencoded", "2");
P(d, "type", NS"QFileInfo");
P(d, "numchild", "3");
if (d.dumpChildren) {
......@@ -980,7 +979,7 @@ static void qDumpQFileInfo(QDumper &d)
d.beginHash();
P(d, "name", "created");
P(d, "value", info.created().toString());
P(d, "valueencoded", "1");
P(d, "valueencoded", "2");
P(d, "exp", "(("NSX"QFileInfo"NSY"*)" << d.data << ")->created()");
P(d, "type", NS"QDateTime");
P(d, "numchild", "1");
......@@ -989,7 +988,7 @@ static void qDumpQFileInfo(QDumper &d)
d.beginHash();
P(d, "name", "lastModified");
P(d, "value", info.lastModified().toString());
P(d, "valueencoded", "1");
P(d, "valueencoded", "2");
P(d, "exp", "(("NSX"QFileInfo"NSY"*)" << d.data << ")->lastModified()");
P(d, "type", NS"QDateTime");
P(d, "numchild", "1");
......@@ -998,7 +997,7 @@ static void qDumpQFileInfo(QDumper &d)
d.beginHash();
P(d, "name", "lastRead");
P(d, "value", info.lastRead().toString());
P(d, "valueencoded", "1");
P(d, "valueencoded", "2");
P(d, "exp", "(("NSX"QFileInfo"NSY"*)" << d.data << ")->lastRead()");
P(d, "type", NS"QDateTime");
P(d, "numchild", "1");
......@@ -1296,7 +1295,7 @@ static void qDumpQLocale(QDumper &d)
{
const QLocale &locale = *reinterpret_cast<const QLocale *>(d.data);
P(d, "value", locale.name());
P(d, "valueencoded", "1");
P(d, "valueencoded", "2");
P(d, "type", NS"QLocale");
P(d, "numchild", "8");
if (d.dumpChildren) {
......@@ -1508,7 +1507,7 @@ static void qDumpQObject(QDumper &d)
const QMetaObject *mo = ob->metaObject();
unsigned childrenOffset = d.extraInt[0];
P(d, "value", ob->objectName());
P(d, "valueencoded", "1");
P(d, "valueencoded", "2");
P(d, "type", NS"QObject");
P(d, "displayedtype", mo->className());
P(d, "numchild", 4);
......@@ -1627,7 +1626,7 @@ static void qDumpQObjectPropertyList(QDumper &d)
<< ")->" << prop.name() << "()");
if (isEqual(prop.typeName(), "QString")) {
P(d, "value", prop.read(ob).toString());
P(d, "valueencoded", "1");
P(d, "valueencoded", "2");
P(d, "type", NS"QString");
P(d, "numchild", "0");
} else if (isEqual(prop.typeName(), "bool")) {
......@@ -1941,7 +1940,7 @@ static void qDumpQString(QDumper &d)
}
P(d, "value", str);
P(d, "valueencoded", "1");
P(d, "valueencoded", "2");
P(d, "type", NS"QString");
//P(d, "editvalue", str); // handled generically below
P(d, "numchild", "0");
......@@ -1973,7 +1972,7 @@ static void qDumpQStringList(QDumper &d)
d.beginHash();
P(d, "name", i);
P(d, "value", list[i]);
P(d, "valueencoded", "1");
P(d, "valueencoded", "2");
d.endHash();
}
if (n < list.size())
......
......@@ -508,6 +508,9 @@ static int startOfOperator(TextEditor::ITextEditable *editor,
return start;
}
bool CppCodeCompletion::isValid(TextEditor::ITextEditable *editor)
{ return m_manager->isCppEditor(editor); }
bool CppCodeCompletion::triggersCompletion(TextEditor::ITextEditable *editor)
{
if (! m_manager->isCppEditor(editor)) // ### remove me
......
......@@ -58,6 +58,7 @@ class CppCodeCompletion : public TextEditor::ICompletionCollector
public:
explicit CppCodeCompletion(CppModelManager *manager);
bool isValid(TextEditor::ITextEditable *editor);
bool triggersCompletion(TextEditor::ITextEditable *editor);
int startCompletion(TextEditor::ITextEditable *editor);
void completions(QList<TextEditor::CompletionItem> *completions);
......
......@@ -1056,7 +1056,8 @@ void DebuggerManager::sessionLoaded()
void DebuggerManager::sessionUnloaded()
{
return;
cleanupViews();
//FIXME: Breakview crashes on startup as there is
//cleanupViews();
if (m_engine)
m_engine->shutdown();
setStatus(DebuggerProcessNotReady);
......
......@@ -65,6 +65,7 @@
#include <unistd.h>
#include <dlfcn.h>
#endif
#include <ctype.h>
using namespace Debugger;
using namespace Debugger::Internal;
......@@ -2776,36 +2777,55 @@ void GdbEngine::setToolTipExpression(const QPoint &pos, const QString &exp0)
static const QString strNotInScope = QLatin1String("<not in scope>");
static QString quoteUnprintableLatin1(const QByteArray &ba)
{
QString res;
char buf[10];
for (int i = 0, n = ba.size(); i != n; ++i) {
unsigned char c = ba.at(i);
if (isprint(c)) {
res += c;
} else {
qsnprintf(buf, sizeof(buf) - 1, "\\%x", int(c));
res += buf;
}
}
return res;
}
static void setWatchDataValue(WatchData &data, const GdbMi &mi,
int encoding = 0)
{
if (mi.isValid()) {
QByteArray ba;
QString str;
switch (encoding) {
case 0: // unencoded 8 bit data
ba = mi.data();
str = quoteUnprintableLatin1(ba);
break;
case 1: // base64 encoded 8 bit data
case 1: // base64 encoded 8 bit data, used for QByteArray
ba = QByteArray::fromBase64(mi.data());
ba = '"' + ba + '"';
str = '"' + quoteUnprintableLatin1(ba) + '"';
break;
case 2: // base64 encoded 16 bit data
case 2: // base64 encoded 16 bit data, used for QString
ba = QByteArray::fromBase64(mi.data());
ba = QString::fromUtf16((ushort *)ba.data(), ba.size() / 2).toUtf8();
ba = '"' + ba + '"';
str = QString::fromUtf16((ushort *)ba.data(), ba.size() / 2);
str = '"' + str + '"';
break;
case 3: // base64 encoded 32 bit data
ba = QByteArray::fromBase64(mi.data());
ba = QString::fromUcs4((uint *)ba.data(), ba.size() / 4).toUtf8();
ba = '"' + ba + '"';
str = QString::fromUcs4((uint *)ba.data(), ba.size() / 4);
str = '"' + str + '"';
break;
case 4: // base64 encoded 8 bit data
case 4: // base64 encoded 16 bit data, without quotes (see 2)
ba = QByteArray::fromBase64(mi.data());
str = QString::fromUtf16((ushort *)ba.data(), ba.size() / 2);
break;
}
data.setValue(ba);
data.setValue(str);
} else {
data.setValueNeeded();
data.setValueNeeded();
}
}
......@@ -3411,7 +3431,7 @@ void GdbEngine::handleVarCreate(const GdbResultRecord &record,
data.setChildrenNeeded();
setWatchDataChildCount(data, record.data.findChild("numchild"));
//if (data.isValueNeeded() && data.childCount > 0)
// data.setValue(QByteArray());
// data.setValue(QString());
insertData(data);
}
} else if (record.resultClass == GdbResultError) {
......@@ -3607,13 +3627,13 @@ void GdbEngine::handleDumpCustomValue3(const GdbResultRecord &record,
QString str;
for (int i = 0; i < list.size(); ++i)
str.append(list.at(i).toInt());
data.setValue('"' + str.toUtf8() + '"');
data.setValue('"' + str + '"');
data.setChildCount(0);
data.setAllUnneeded();
insertData(data);
} else if (data.type == "QStringList" || data.type.endsWith("::QStringList")) {
int l = list.size();
data.setValue(QString("<%1 items>").arg(l).toLatin1());
data.setValue(tr("<%1 items>").arg(l));
data.setChildCount(list.size());
data.setAllUnneeded();
insertData(data);
......
......@@ -47,9 +47,9 @@
#include <QtGui/QToolTip>
#include <QtGui/QTextEdit>
#include <ctype.h>
// creates debug output regarding pending watch data results
#define DEBUG_PENDING 1
// creates debug output for accesses to the itemmodel
......@@ -91,25 +91,9 @@ void WatchData::setError(const QString &msg)
valuedisabled = true;
}
static QByteArray quoteUnprintable(const QByteArray &ba)
{
QByteArray res;
char buf[10];
for (int i = 0, n = ba.size(); i != n; ++i) {
unsigned char c = ba.at(i);
if (isprint(c)) {
res += c;
} else {
qsnprintf(buf, sizeof(buf) - 1, "\\%x", int(c));
res += buf;
}
}
return res;
}
void WatchData::setValue(const QByteArray &value0)
void WatchData::setValue(const QString &value0)
{
value = quoteUnprintable(value0);
value = value0;
if (value == "{...}") {
value.clear();
childCount = 1; // at least one...
......
......@@ -66,7 +66,7 @@ public:
| ChildCountNeeded
};
void setValue(const QByteArray &);
void setValue(const QString &);
void setType(const QString &);
void setValueToolTip(const QString &);
void setError(const QString &);
......
......@@ -1247,6 +1247,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
m_tc.insertText(text);
moveUp(n);
}
moveToFirstNonBlankOnLine();
} else {
m_desiredColumn = 0;
for (int i = count(); --i >= 0; ) {
......
......@@ -147,7 +147,7 @@ void WinGuiProcess::run()
switch (ret) {
case WAIT_OBJECT_0 + 0:
if (*processId == m_pid->dwProcessId)
emit receivedDebugOutput(QString::fromAscii(message));
emit receivedDebugOutput(QString::fromLocal8Bit(message));
SetEvent(bufferReadyEvent);
break;
case WAIT_OBJECT_0 + 1:
......
......@@ -2179,7 +2179,7 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ;
}
}
const QString msg = QString::fromUtf8("Unexpected token: `%1'").arg(token_buffer[0].token);
const QString msg = QString::fromUtf8("Unexpected token: `%1'").arg(spell[token_buffer[0].token]);
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error,
token_buffer[0].loc.startLine, token_buffer[0].loc.startColumn, msg));
}
......
......@@ -77,6 +77,9 @@ public:
: _lexer(0), _nodePool(0), _ast(0)
{ }
QSet<JavaScriptNameIdImpl> literals() const
{ return _literals; }
JavaScriptNameIdImpl *intern(const QChar *u, int s)
{ return const_cast<JavaScriptNameIdImpl *>(&*_literals.insert(JavaScriptNameIdImpl(u, s))); }
......
......@@ -1184,7 +1184,7 @@ case 266: {
}
}
const QString msg = QString::fromUtf8("Unexpected token: `%1'").arg(token_buffer[0].token);
const QString msg = QString::fromUtf8("Unexpected token: `%1'").arg(spell[token_buffer[0].token]);
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error,
token_buffer[0].loc.startLine, token_buffer[0].loc.startColumn, msg));
}
......
#include "qtscriptcodecompletion.h"
#include "qtscripteditor.h"
#include <texteditor/basetexteditor.h>
#include <QtDebug>
using namespace QtScriptEditor::Internal;
QtScriptCodeCompletion::QtScriptCodeCompletion(QObject *parent)
: TextEditor::ICompletionCollector(parent),
m_editor(0),
m_startPosition(0),
m_caseSensitivity(Qt::CaseSensitive)
{ }
QtScriptCodeCompletion::~QtScriptCodeCompletion()
{ }
Qt::CaseSensitivity QtScriptCodeCompletion::caseSensitivity() const
{ return m_caseSensitivity; }
void QtScriptCodeCompletion::setCaseSensitivity(Qt::CaseSensitivity caseSensitivity)
{ m_caseSensitivity = caseSensitivity; }
bool QtScriptCodeCompletion::isValid(TextEditor::ITextEditable *editor)
{
if (qobject_cast<ScriptEditor *>(editor->widget()))
return true;
return false;
}
bool QtScriptCodeCompletion::triggersCompletion(TextEditor::ITextEditable *)
{ return false; }
int QtScriptCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
{
m_editor = editor;
ScriptEditor *edit = qobject_cast<ScriptEditor *>(m_editor->widget());
if (! edit)
return -1;
int pos = editor->position();
while (editor->characterAt(pos - 1).isLetterOrNumber() || editor->characterAt(pos - 1) == QLatin1Char('_'))
--pos;
m_startPosition = pos;
m_completions.clear();
foreach (const QString &word, edit->words()) {
TextEditor::CompletionItem item(this);
item.m_text = word;
m_completions.append(item);
}
return pos;
}
void QtScriptCodeCompletion::completions(QList<TextEditor::CompletionItem> *completions)
{
// ### FIXME: this code needs to be generalized.
const int length = m_editor->position() - m_startPosition;
if (length == 0)
*completions = m_completions;
else if (length > 0) {
const QString key = m_editor->textAt(m_startPosition, length);
/*
* This code builds a regular expression in order to more intelligently match
* camel-case style. This means upper-case characters will be rewritten as follows:
*
* A => [a-z0-9_]*A (for any but the first capital letter)
*
* Meaning it allows any sequence of lower-case characters to preceed an
* upper-case character. So for example gAC matches getActionController.
*/
QString keyRegExp;
keyRegExp += QLatin1Char('^');
bool first = true;
foreach (const QChar &c, key) {
if (c.isUpper() && !first) {
keyRegExp += QLatin1String("[a-z0-9_]*");
keyRegExp += c;
} else if (m_caseSensitivity == Qt::CaseInsensitive && c.isLower()) {
keyRegExp += QLatin1Char('[');
keyRegExp += c;
keyRegExp += c.toUpper();
keyRegExp += QLatin1Char(']');
} else {
keyRegExp += QRegExp::escape(c);
}
first = false;
}
const QRegExp regExp(keyRegExp, Qt::CaseSensitive);
foreach (TextEditor::CompletionItem item, m_completions) {
if (regExp.indexIn(item.m_text) == 0) {
item.m_relevance = (key.length() > 0 &&
item.m_text.startsWith(key, Qt::CaseInsensitive)) ? 1 : 0;
(*completions) << item;
}
}
}
}
void QtScriptCodeCompletion::complete(const TextEditor::CompletionItem &item)
{
const QString toInsert = item.m_text;
const int length = m_editor->position() - m_startPosition;
m_editor->setCurPos(m_startPosition);
m_editor->replace(length, toInsert);
}
bool QtScriptCodeCompletion::partiallyComplete(const QList<TextEditor::CompletionItem> &completionItems)
{
if (completionItems.count() == 1) {
complete(completionItems.first());
return true;
} else {
// Compute common prefix
QString firstKey = completionItems.first().m_text;
QString lastKey = completionItems.last().m_text;
const int length = qMin(firstKey.length(), lastKey.length());
firstKey.truncate(length);
lastKey.truncate(length);
while (firstKey != lastKey) {
firstKey.chop(1);
lastKey.chop(1);
}
int typedLength = m_editor->position() - m_startPosition;
if (!firstKey.isEmpty() && firstKey.length() > typedLength) {
m_editor->setCurPos(m_startPosition);
m_editor->replace(typedLength, firstKey);
}
}
return false;
}
void QtScriptCodeCompletion::cleanup()
{
m_editor = 0;
m_startPosition = 0;
m_completions.clear();
}
#ifndef QTSCRIPTCODECOMPLETION_H
#define QTSCRIPTCODECOMPLETION_H
#include <texteditor/icompletioncollector.h>
namespace TextEditor {
class ITextEditable;
}
namespace QtScriptEditor {
namespace Internal {
class QtScriptCodeCompletion: public TextEditor::ICompletionCollector
{
Q_OBJECT
public:
QtScriptCodeCompletion(QObject *parent = 0);
virtual ~QtScriptCodeCompletion();
Qt::CaseSensitivity caseSensitivity() const;
void setCaseSensitivity(Qt::CaseSensitivity caseSensitivity);
virtual bool isValid(TextEditor::ITextEditable *editor);
virtual bool triggersCompletion(TextEditor::ITextEditable *editor);
virtual int startCompletion(TextEditor::ITextEditable *editor);
virtual void completions(QList<TextEditor::CompletionItem> *completions);
virtual void complete(const TextEditor::CompletionItem &item);
virtual bool partiallyComplete(const QList<TextEditor::CompletionItem> &completionItems);
virtual void cleanup();
private:
TextEditor::ITextEditable *m_editor;
int m_startPosition;
QList<TextEditor::CompletionItem> m_completions;
Qt::CaseSensitivity m_caseSensitivity;
};
} // end of namespace Internal
} // end of namespace QtScriptEditor
#endif // QTSCRIPTCODECOMPLETION_H
......@@ -166,6 +166,9 @@ ScriptEditor::~ScriptEditor()
QList<Declaration> ScriptEditor::declarations() const
{ return m_declarations; }
QStringList ScriptEditor::words() const
{ return m_words; }
Core::IEditor *ScriptEditorEditable::duplicate(QWidget *parent)
{
ScriptEditor *newEditor = new ScriptEditor(m_context, parent);
......@@ -215,6 +218,10 @@ void ScriptEditor::updateDocumentNow()
FindDeclarations decls;
m_declarations = decls.accept(driver.ast());
m_words.clear();
foreach (const JavaScriptNameIdImpl &id, driver.literals())
m_words.append(id.asString());