52 #include <QtCore/qdir.h> 53 #include <QtCore/qfileinfo.h> 54 #include <QtCore/qstring.h> 55 #include <QtCore/qstringlist.h> 56 #include <QtCore/qdebug.h> 57 #include <QtScript/qscriptcontextinfo.h> 58 #include <QtScript/qscriptengine.h> 314 qScriptRegisterSequenceMetaType<QScriptDebuggerValuePropertyList>(
commandEngine);
317 qScriptRegisterSequenceMetaType<QScriptDebuggerConsoleCommandList>(
commandEngine);
338 QDir dir(scriptsPath);
341 for (
int i = 0; i < entries.
size(); ++i) {
373 name = command.
left(i);
382 if (completions.
size() > 1) {
386 for (
int j = 0; j < completions.
size(); ++j) {
414 return cmd->
createJob(args, q_func(), messageHandler, commandScheduler);
430 d->loadScriptedCommands(scriptsPath, messageHandler);
436 return d->commandManager;
442 return !
d->input.isEmpty();
460 return d->commandPrefix;
473 static const int maximumHistoryCount = 100;
475 if (
d->input.isEmpty() && input.
isEmpty()) {
476 if (
d->commandHistory.isEmpty())
478 cmd =
d->commandHistory.first();
482 if (
d->input.isEmpty() && cmd.
startsWith(
d->commandPrefix)) {
484 d->commandHistory.prepend(cmd);
485 if (
d->commandHistory.size() > maximumHistoryCount)
486 d->commandHistory.removeLast();
488 cmd.
remove(0,
d->commandPrefix.length());
489 return d->createJob(cmd, messageHandler, commandScheduler);
501 d->commandHistory.prepend(cmd);
502 if (
d->commandHistory.size() > maximumHistoryCount)
503 d->commandHistory.removeLast();
505 cmd.
remove(0,
d->commandPrefix.length());
506 return d->createJob(cmd, messageHandler, commandScheduler);
512 return d->currentFrameIndex;
518 d->currentFrameIndex =
index;
524 return d->currentScriptId;
530 d->currentScriptId = id;
536 return d->currentLineNumber;
542 d->currentLineNumber = lineNumber;
548 return d->evaluateAction;
554 d->evaluateAction = action;
575 "Welcome to the Qt Script debugger.\n" 576 "Debugger commands start with a . (period).\n" 577 "Any other input will be evaluated by the script interpreter.\n" 578 "Type \".help\" for help.\n"));
587 return d->commandHistory.size();
596 return d->commandHistory.value(index);
605 d->commandHistory[
index] = newHistory;
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
The QDir class provides access to directory structures and their contents.
void loadScriptedCommands(const QString &scriptsPath, QScriptMessageHandlerInterface *messageHandler)
Loads command definitions from scripts located in the given scriptsPath.
QScriptDebuggerConsoleCommandManager * commandManager
static void debuggerScriptValuePropertyFromScriptValue(const QScriptValue &in, QScriptDebuggerValueProperty &out)
bool isSingleShot() const
Returns true if the breakpoint is single-shot, false otherwise.
int currentFrameIndex() const
QScriptValue property(const QString &name, const ResolveFlags &mode=ResolvePrototype) const
Returns the value of this QScriptValue's property with the given name, using the given mode to resolv...
virtual QString group() const =0
Returns the group that this console command belongs to.
void changeHistoryAt(int index, const QString &newHistory)
Reimplemented Function
#define QT_END_NAMESPACE
This macro expands to.
Error error() const
Returns the error code of this response.
void addCommand(QScriptDebuggerConsoleCommand *command)
Adds the given command.
int baseLineNumber() const
#define it(className, varName)
void setScriptId(qint64 id)
bool open(OpenMode flags)
Opens the file using OpenMode mode, returning true if successful; otherwise false.
static QScriptValue scriptDataToScriptValue(QScriptEngine *eng, const QScriptScriptData &in)
static QScriptValue debuggerScriptValuePropertyToScriptValue(QScriptEngine *eng, const QScriptDebuggerValueProperty &in)
void setFileName(const QString &fileName)
qint32 toInt32() const
Returns the signed 32-bit integer value of this QScriptValue, using the conversion rules described in...
The QScriptDebuggerResponse class represents a front-end's response to a QScriptDebuggerCommand.
QString longDescription() const
static QScriptDebuggerScriptedConsoleCommand * parse(const QString &program, const QString &fileName, QScriptEngine *engine, QScriptMessageHandlerInterface *messageHandler)
Parses a command defined by the given program.
QScriptValue toScriptValue(const T &value)
Creates a QScriptValue with the given value.
QString name() const
Returns the name of this QScriptDebuggerValueProperty.
static void breakpointMapFromScriptValue(const QScriptValue &, QScriptBreakpointMap &)
QString fileName() const
Returns the name of the file, excluding the path.
QString toString() const
Returns the string value of this QScriptValue, as defined in ECMA-262 section 9.8, "ToString".
QT_DEPRECATED int columnNumber() const
QStringList commandHistory
int ignoreCount() const
Returns the ignore count of the breakpoint.
QString incompleteInput() const
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
QScriptDebuggerValue value() const
Returns the value of this QScriptDebuggerValueProperty.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void setLineNumber(int lineNumber)
Sets the breakpoint line number to lineNumber.
The QString class provides a Unicode character string.
virtual QString name() const =0
Returns the name of this console command.
static QScriptValue debuggerResponseToScriptValue(QScriptEngine *eng, const QScriptDebuggerResponse &in)
~QScriptDebuggerConsole()
virtual QStringList argumentTypes() const
QStringList completions(const QString &prefix) const
Returns the possible completions for the given prefix.
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
QScriptValue::PropertyFlags flags() const
Returns the flags of this QScriptDebuggerValueProperty.
void setIncompleteInput(const QString &input)
static QScriptValue breakpointMapToScriptValue(QScriptEngine *eng, const QScriptBreakpointMap &in)
QString valueAsString() const
QString fileName() const
Returns the name of the file where the code being executed was defined, if available; otherwise retur...
void setSingleShot(bool singleShot)
Sets the singleShot state of the breakpoint.
The QScriptScriptData class holds data associated with a script.
static QScriptValue consoleCommandGroupDataToScriptValue(QScriptEngine *eng, const QScriptDebuggerConsoleCommandGroupData &in)
QScriptDebuggerConsoleCommandJob * createJob(const QString &command, QScriptMessageHandlerInterface *messageHandler, QScriptDebuggerCommandSchedulerInterface *commandScheduler)
Creates a job that will execute the given debugger command.
T qscriptvalue_cast(const QScriptValue &value)
Returns the given value converted to the template type T.
The QScriptDebuggerConsole class provides the core functionality of a debugger console.
void showDebuggerInfoMessage(QScriptMessageHandlerInterface *messageHandler)
void append(const T &t)
Inserts value at the end of the list.
The QScriptEngine class provides an environment for evaluating Qt Script code.
#define QT_BEGIN_NAMESPACE
This macro expands to.
virtual QStringList seeAlso() const
Returns a list of names of commands that may also be of interest to users of this command...
qint64 currentScriptId() const
int lineNumber() const
Returns the line number corresponding to the statement being executed, or -1 if the line number is no...
static void scriptDataFromScriptValue(const QScriptValue &in, QScriptScriptData &out)
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
int size() const
Returns the number of characters in this string.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QString shortDescription() const
void setIgnoreCount(int count)
Sets the ignore count of the breakpoint.
const T & at(int i) const
Returns the item at index position i in the list.
virtual QString shortDescription() const =0
Returns a short (one line) description of the command.
The QStringList class provides a list of strings.
static QScriptValue breakpointDataToScriptValue(QScriptEngine *eng, const QScriptBreakpointData &in)
static QScriptValue consoleCommandGroupMapToScriptValue(QScriptEngine *eng, const QScriptDebuggerConsoleCommandGroupMap &in)
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
void setEnabled(bool enabled)
Sets the enabled state of the breakpoint.
The QScriptSyntaxCheckResult class provides the result of a script syntax check.
QScriptValue newObject()
Creates a QtScript object of class Object.
QBool contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the list contains the string str; otherwise returns false.
QFileInfoList entryInfoList(Filters filters=NoFilter, SortFlags sort=NoSort) const
Returns a list of QFileInfo objects for all the files and directories in the directory, ordered according to the name and attribute filters previously set with setNameFilters() and setFilter(), and sorted according to the flags set with setSorting().
virtual QString longDescription() const =0
Returns a detailed description of how to use the command.
QString commandPrefix() const
void setCondition(const QString &condition)
Sets the condition of the breakpoint.
QScriptDebuggerConsolePrivate(QScriptDebuggerConsole *)
void loadScriptedCommands(const QString &scriptsPath, QScriptMessageHandlerInterface *messageHandler)
The QScriptBreakpointData class contains data associated with a breakpoint.
static QScriptValue contextInfoToScriptValue(QScriptEngine *eng, const QScriptContextInfo &in)
bool toBoolean() const
Use toBool() instead.
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the map.
bool hasIncompleteInput() const
QScriptDebuggerConsoleCommandJob * consumeInput(const QString &input, QScriptMessageHandlerInterface *messageHandler, QScriptDebuggerCommandSchedulerInterface *commandScheduler)
Consumes the given line of input.
void setEvaluateAction(int action)
static void breakpointDataFromScriptValue(const QScriptValue &in, QScriptBreakpointData &out)
qsreal toNumber() const
Returns the number value of this QScriptValue, as defined in ECMA-262 section 9.3, "ToNumber".
QScriptDebuggerConsoleCommand * findCommand(const QString &name) const
Returns the command with the given name if one exists, otherwise returns 0.
static void consoleCommandGroupMapFromScriptValue(const QScriptValue &, QScriptDebuggerConsoleCommandGroupMap &)
static const MacSpecialKey entries[NumEntries]
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
static QScriptValue consoleCommandToScriptValue(QScriptEngine *eng, QScriptDebuggerConsoleCommand *const &in)
The QScriptDebuggerValue class represents a script value.
The QScriptDebuggerConsoleCommandGroupData class holds data associated with a console command group...
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the map...
void setProperty(const QString &name, const QScriptValue &value, const PropertyFlags &flags=KeepExistingFlags)
Sets the value of this QScriptValue's property with the given name to the given value.
The QScriptContextInfo class provides additional information about a QScriptContext.
The QScriptDebuggerScriptedConsoleCommand class encapsulates a command defined in a script...
#define Q_DECLARE_PUBLIC(Class)
QString & append(QChar c)
The QFile class provides an interface for reading from and writing to files.
The QScriptDebuggerConsoleCommand class is the base class of console commands.
static void scriptMapFromScriptValue(const QScriptValue &, QScriptScriptMap &)
The QTextStream class provides a convenient interface for reading and writing text.
int historyCount() const
Reimplemented Function
static QScriptValue scriptMapToScriptValue(QScriptEngine *eng, const QScriptScriptMap &in)
bool isEnabled() const
Returns true if the breakpoint is enabled, false otherwise.
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
static void messageHandler(QtMsgType type, const char *msg)
virtual QScriptDebuggerConsoleCommandJob * createJob(const QStringList &arguments, QScriptDebuggerConsole *console, QScriptMessageHandlerInterface *messageHandler, QScriptDebuggerCommandSchedulerInterface *scheduler)=0
Creates a job that will execute this command with the given arguments.
int size() const
Returns the number of items in the list.
QString historyAt(int index) const
Reimplemented Function
~QScriptDebuggerConsolePrivate()
int currentLineNumber() const
void setCurrentScriptId(qint64 id)
void setCurrentLineNumber(int lineNumber)
QScriptDebuggerConsole * q_ptr
static QScriptSyntaxCheckResult checkSyntax(const QString &program)
Checks the syntax of the given program.
int evaluateAction() const
QString condition() const
Returns the condition of the breakpoint.
static void consoleCommandGroupDataFromScriptValue(const QScriptValue &, QScriptDebuggerConsoleCommandGroupData &)
QString readAll()
Reads the entire content of the stream, and returns it as a QString.
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
QScriptValue undefinedValue()
Returns a QScriptValue of the primitive type Undefined.
qint64 scriptId() const
Returns the ID of the script where the code being executed was defined, or -1 if the ID is not availa...
QScriptDebuggerConsoleCommandManager * commandManager() const
QString & remove(int i, int len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
QScriptEngine * commandEngine
The QFileInfo class provides system-independent file information.
static void consoleCommandFromScriptValue(const QScriptValue &, QScriptDebuggerConsoleCommand *&)
static void contextInfoFromScriptValue(const QScriptValue &, QScriptContextInfo &)
virtual void message(QtMsgType type, const QString &text, const QString &fileName=QString(), int lineNumber=-1, int columnNumber=-1, const QVariant &data=QVariant())=0
int lineNumber() const
Returns the breakpoint line number.
The QScriptValue class acts as a container for the Qt Script data types.
static QString fileName(const QString &fileUrl)
QVariant result() const
Returns the result of this response.
virtual QStringList aliases() const
Returns a list of aliases for this command.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
bool isValid() const
Returns true if this QScriptValue is valid; otherwise returns false.
static void debuggerResponseFromScriptValue(const QScriptValue &, QScriptDebuggerResponse &)
QString functionName() const
Returns the name of the called function, or an empty string if the name is not available.
friend class const_iterator
void setCurrentFrameIndex(int index)
State state() const
Returns the state of this QScriptSyntaxCheckResult.