Add Alarm syntax
This commit is contained in:
parent
022013d46f
commit
3021ef4baf
@ -15,6 +15,7 @@ CodeCompletion::CodeCompletion(QObject *parent):
|
|||||||
m_classes.insert("DeviceState", ClassInfo("DeviceState", {"id", "deviceId", "stateTypeId", "stateName", "value"}, {}, {"onValueChanged"}));
|
m_classes.insert("DeviceState", ClassInfo("DeviceState", {"id", "deviceId", "stateTypeId", "stateName", "value"}, {}, {"onValueChanged"}));
|
||||||
m_classes.insert("DeviceEvent", ClassInfo("DeviceEvent", {"id", "deviceId", "eventTypeId", "eventName"}, {}, {"onTriggered"}));
|
m_classes.insert("DeviceEvent", ClassInfo("DeviceEvent", {"id", "deviceId", "eventTypeId", "eventName"}, {}, {"onTriggered"}));
|
||||||
m_classes.insert("Timer", ClassInfo("Timer", {"id", "interval", "running", "repeat"}, {"start", "stop"}, {"onTriggered"}));
|
m_classes.insert("Timer", ClassInfo("Timer", {"id", "interval", "running", "repeat"}, {"start", "stop"}, {"onTriggered"}));
|
||||||
|
m_classes.insert("Alarm", ClassInfo("Alarm", {"id", "time", "endTime", "weekDays", "active"}, {}, {"onTriggered", "onActiveChanged"}));
|
||||||
m_classes.insert("PropertyAnimation", ClassInfo("PropertyAnimation", {"id", "target", "targets", "property", "properties", "value", "from", "to", "easing", "exclude", "duration", "alwaysRunToEnd", "loops", "paused", "running"}, {"start", "stop", "pause", "resume", "complete"}, {"onStarted", "onStopped", "onFinished", "onRunningChanged"}));
|
m_classes.insert("PropertyAnimation", ClassInfo("PropertyAnimation", {"id", "target", "targets", "property", "properties", "value", "from", "to", "easing", "exclude", "duration", "alwaysRunToEnd", "loops", "paused", "running"}, {"start", "stop", "pause", "resume", "complete"}, {"onStarted", "onStopped", "onFinished", "onRunningChanged"}));
|
||||||
m_classes.insert("ColorAnimation", ClassInfo("ColorAnimation", {"id", "target", "targets", "property", "properties", "value", "from", "to", "easing", "exclude", "duration", "alwaysRunToEnd", "loops", "paused", "running"}, {"start", "stop", "pause", "resume", "complete"}, {"onStarted", "onStopped", "onFinished", "onRunningChanged"}));
|
m_classes.insert("ColorAnimation", ClassInfo("ColorAnimation", {"id", "target", "targets", "property", "properties", "value", "from", "to", "easing", "exclude", "duration", "alwaysRunToEnd", "loops", "paused", "running"}, {"start", "stop", "pause", "resume", "complete"}, {"onStarted", "onStopped", "onFinished", "onRunningChanged"}));
|
||||||
m_classes.insert("SequentialAnimation", ClassInfo("SequentialAnimation", {"id", "alwaysRunToEnd", "loops", "paused", "running"}, {"start", "stop", "pause", "resume", "complete"}, {"onStarted", "onStopped", "onFinished", "onRunningChanged"}));
|
m_classes.insert("SequentialAnimation", ClassInfo("SequentialAnimation", {"id", "alwaysRunToEnd", "loops", "paused", "running"}, {"start", "stop", "pause", "resume", "complete"}, {"onStarted", "onStopped", "onFinished", "onRunningChanged"}));
|
||||||
@ -22,6 +23,7 @@ CodeCompletion::CodeCompletion(QObject *parent):
|
|||||||
m_classes.insert("PauseAnimation", ClassInfo("PauseAnimation", {"id", "duration", "alwaysRunToEnd", "loops", "paused", "running"}, {"start", "stop", "pause", "resume", "complete"}, {"onStarted", "onStopped", "onFinished", "onRunningChanged"}));
|
m_classes.insert("PauseAnimation", ClassInfo("PauseAnimation", {"id", "duration", "alwaysRunToEnd", "loops", "paused", "running"}, {"start", "stop", "pause", "resume", "complete"}, {"onStarted", "onStopped", "onFinished", "onRunningChanged"}));
|
||||||
|
|
||||||
m_attachedClasses.insert("Component", ClassInfo("Component", {}, {}, {"onCompleted", "onDestruction", "onDestroyed"}));
|
m_attachedClasses.insert("Component", ClassInfo("Component", {}, {}, {"onCompleted", "onDestruction", "onDestroyed"}));
|
||||||
|
m_attachedClasses.insert("Alarm", ClassInfo("Alarm", {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "AllDays"}, {}, {}));
|
||||||
|
|
||||||
m_genericSyntax.insert("property", "property ");
|
m_genericSyntax.insert("property", "property ");
|
||||||
m_genericSyntax.insert("function", "function ");
|
m_genericSyntax.insert("function", "function ");
|
||||||
@ -307,7 +309,7 @@ void CodeCompletion::update()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QRegExp rValueExp(" *[\\.a-zA-Z0-0]+:[ a-zA-Z0-0]*");
|
QRegExp rValueExp(" *[\\.a-zA-Z0-0]+[^id]:[ a-zA-Z0-0]*");
|
||||||
if (rValueExp.exactMatch(blockText)) {
|
if (rValueExp.exactMatch(blockText)) {
|
||||||
QTextCursor tmp = m_cursor;
|
QTextCursor tmp = m_cursor;
|
||||||
tmp.movePosition(QTextCursor::StartOfWord, QTextCursor::KeepAnchor);
|
tmp.movePosition(QTextCursor::StartOfWord, QTextCursor::KeepAnchor);
|
||||||
@ -387,6 +389,7 @@ void CodeCompletion::update()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isImperative) {
|
if (isImperative) {
|
||||||
|
qDebug() << "Is imperative!";
|
||||||
// Starting a new expression?
|
// Starting a new expression?
|
||||||
QRegExp newExpressionExp("(.*; [a-zA-Z0-9]*| *[a-zA-Z0-9]*)");
|
QRegExp newExpressionExp("(.*; [a-zA-Z0-9]*| *[a-zA-Z0-9]*)");
|
||||||
if (newExpressionExp.exactMatch(blockText)) {
|
if (newExpressionExp.exactMatch(blockText)) {
|
||||||
@ -471,12 +474,14 @@ CodeCompletion::BlockInfo CodeCompletion::getBlockInfo(int position) const
|
|||||||
info.end = m_document->textDocument()->find("}", position).position();
|
info.end = m_document->textDocument()->find("}", position).position();
|
||||||
info.valid = true;
|
info.valid = true;
|
||||||
|
|
||||||
|
qDebug() << "block name" << blockStart.block().text();
|
||||||
info.name = blockStart.block().text();
|
info.name = blockStart.block().text();
|
||||||
info.name.remove(QRegExp(" *\\{"));
|
info.name.remove(QRegExp(" *\\{ *"));
|
||||||
|
qDebug() << "stripped klammer" << info.name;
|
||||||
while (info.name.contains(" ")) {
|
while (info.name.contains(" ")) {
|
||||||
info.name.remove(QRegExp(".* "));
|
info.name.remove(QRegExp(".* "));
|
||||||
}
|
}
|
||||||
|
qDebug() << "final name" << info.name;
|
||||||
|
|
||||||
int childBlocks = 0;
|
int childBlocks = 0;
|
||||||
while (!blockStart.isNull() && blockStart.position() < position) {
|
while (!blockStart.isNull() && blockStart.position() < position) {
|
||||||
@ -501,14 +506,14 @@ CodeCompletion::BlockInfo CodeCompletion::getBlockInfo(int position) const
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
foreach (const QString &statement, blockStart.block().text().split(";")) {
|
foreach (const QString &statement, blockStart.block().text().split(";")) {
|
||||||
qDebug() << "Have statement" << statement;
|
// qDebug() << "Have statement" << statement;
|
||||||
QStringList parts = statement.split(":");
|
QStringList parts = statement.split(":");
|
||||||
if (parts.length() != 2) {
|
if (parts.length() != 2) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
QString propName = parts.first().trimmed();
|
QString propName = parts.first().trimmed();
|
||||||
QString propValue = parts.last().split("//").first().trimmed().remove("\"");
|
QString propValue = parts.last().split("//").first().trimmed().remove("\"");
|
||||||
qDebug() << "inserting:" << propName << "->" << propValue;
|
// qDebug() << "inserting:" << propName << "->" << propValue;
|
||||||
info.properties.insert(propName, propValue);
|
info.properties.insert(propName, propValue);
|
||||||
}
|
}
|
||||||
if (!blockStart.movePosition(QTextCursor::NextBlock)) {
|
if (!blockStart.movePosition(QTextCursor::NextBlock)) {
|
||||||
|
|||||||
@ -142,9 +142,9 @@ void ScriptSyntaxHighlighterPrivate::update(bool dark)
|
|||||||
// String literals
|
// String literals
|
||||||
format.setForeground(dark ? QColor("#e64ad7") : Qt::darkGreen);
|
format.setForeground(dark ? QColor("#e64ad7") : Qt::darkGreen);
|
||||||
rule.format = format;
|
rule.format = format;
|
||||||
rule.pattern = QRegExp("\".*\"");
|
rule.pattern = QRegExp("\".[^\"]*\"");
|
||||||
highlightingRules.append(rule);
|
highlightingRules.append(rule);
|
||||||
rule.pattern = QRegExp("'.*'");
|
rule.pattern = QRegExp("'.[^']*'");
|
||||||
highlightingRules.append(rule);
|
highlightingRules.append(rule);
|
||||||
|
|
||||||
// comments
|
// comments
|
||||||
|
|||||||
@ -317,8 +317,11 @@ Page {
|
|||||||
var newErrorLines = []
|
var newErrorLines = []
|
||||||
errors.forEach( function(error) {
|
errors.forEach( function(error) {
|
||||||
var parts = error.split(":")
|
var parts = error.split(":")
|
||||||
append({line: parseInt(parts[0]), column: parseInt(parts[1]), message: parts[2].trim()})
|
var line = parseInt(parts.shift());
|
||||||
newErrorLines.push(parseInt(parts[0]));
|
var col = parseInt(parts.shift());
|
||||||
|
var message = parts.join(":").trim();
|
||||||
|
append({line: line, column: col, message: message})
|
||||||
|
newErrorLines.push(line);
|
||||||
})
|
})
|
||||||
errorLines = newErrorLines;
|
errorLines = newErrorLines;
|
||||||
if (errorModel.count > 0) {
|
if (errorModel.count > 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user