flutter / dart syntax improved

This commit is contained in:
Zira project 2020-10-31 14:02:17 +05:00
parent 8c6ce0d515
commit 62617cba75
11 changed files with 235 additions and 46 deletions

View File

@ -51,11 +51,14 @@ public:
std::map<std::string, std::string> phpMagicComplete;
std::map<std::string, std::string> dartObjectsComplete;
std::map<std::string, std::string> flutterObjectsComplete;
std::map<std::string, std::string> dartFunctionsComplete;
std::map<std::string, std::string> flutterFunctionsComplete;
protected:
void loadCSSWords();
void loadHTMLWords();
void loadJSWords();
void loadPHPWords();
void loadFlutterWords();
private:
HighlightWords * HW;
public slots:

View File

@ -28,6 +28,7 @@ public:
void addJSInterface(QString k);
void addJSObject(QString k);
void addJSExtDartObject(QString k);
void addJSExtDartFunction(QString k);
void addCSSProperty(QString k);
void addHTMLTag(QString k);
void addHTMLShortTag(QString k);

View File

@ -0,0 +1,38 @@
runZoned
runZonedGuarded
scheduleMicrotask
base64Decode
base64Encode
base64UrlEncode
jsonDecode
jsonEncode
identical
identityHashCode
print
debugger
getCurrentTag
inspect
log
postEvent
registerExtension
acos
asin
atan
atan2
cos
exp
log
max
min
pow
sin
sqrt
tan
decodeImageFromList
decodeImageFromPixels
hashList
hashValues
instantiateImageCodec
lerpDouble
loadFontFromList
saveCompilationTrace

View File

@ -0,0 +1,83 @@
applyBoxFit
axisDirectionIsReversed
axisDirectionToAxis
createLocalImageConfiguration
debugAssertAllPaintingVarsUnset
debugAssertAllWidgetVarsUnset
debugCheckHasDirectionality
debugCheckHasMaterial
debugCheckHasMaterialLocalizations
debugCheckHasMediaQuery
debugCheckHasScaffold
debugCheckHasTable
debugChildrenHaveDuplicateKeys
debugDescribeFocusTree
debugDescribeTransform
debugDumpApp
debugDumpFocusTree
debugDumpLayerTree
debugDumpRenderTree
debugFlushLastFrameImageSizeInfo
debugIsLocalCreationLocation
debugItemsHaveDuplicateKeys
debugPrintStack
debugWidgetBuilderValue
decodeImageFromList
defaultScrollNotificationPredicate
flipAxis
flipAxisDirection
getAxisDirectionFromAxisReverseAndDirectionality
hashList
hashValues
hourFormat
paintBorder
paintImage
paintZigZag
positionDependentBox
precacheImage
runApp
showAboutDialog
showBottomSheet
showDatePicker
showDateRangePicker
showDialog
showGeneralDialog
showLicensePage
showMenu
showModalBottomSheet
showSearch
showTimePicker
textDirectionToAxisDirection
transformDebugCreator
binarySearch
consolidateHttpClientResponseBytes
debugAssertAllFoundationVarsUnset
debugFormatDouble
debugInstrumentAction
debugPrintStack
debugPrintSynchronously
debugPrintThrottled
debugWordWrap
describeEnum
describeIdentity
lerpDuration
listEquals
mapEquals
mergeSort
objectRuntimeType
setEquals
shortHash
computeHitSlop
computePanSlop
computeScaleSlop
debugAssertAllGesturesVarsUnset
isSingleButton
nthMouseButton
nthStylusButton
smallestButton
nearEqual
nearZero
debugAssertAllSchedulerVarsUnset
defaultSchedulingStrategy
debugResetSemanticsIdCounter
debugIsSerializableForRestoration

View File

@ -23,8 +23,10 @@
<file alias="js_events">resources/syntax/js/events</file>
<file alias="js_methods">resources/syntax/js/methods</file>
<file alias="php_magic">resources/syntax/php/magic</file>
<file alias="flutter_classes">resources/syntax/js/flutter_classes</file>
<file alias="flutter_widgets">resources/syntax/js/flutter_widgets</file>
<file alias="dart_core">resources/syntax/js/dart_core</file>
<file alias="dart_core">resources/syntax/flutter/dart_core</file>
<file alias="dart_functions">resources/syntax/flutter/dart_functions</file>
<file alias="flutter_classes">resources/syntax/flutter/flutter_classes</file>
<file alias="flutter_functions">resources/syntax/flutter/flutter_functions</file>
<file alias="flutter_widgets">resources/syntax/flutter/flutter_widgets</file>
</qresource>
</RCC>

View File

@ -24,6 +24,7 @@ void CompleteWords::load()
loadCSSWords();
loadHTMLWords();
loadJSWords();
loadFlutterWords();
loadPHPWords();
}
@ -227,6 +228,11 @@ void CompleteWords::loadJSWords()
jsEventsComplete[k.toStdString()] = k.toStdString();
}
ef.close();
}
void CompleteWords::loadFlutterWords()
{
QString k;
// dart core
QFile dcr(":/syntax/dart_core");
@ -240,6 +246,18 @@ void CompleteWords::loadJSWords()
}
dcr.close();
// dart core functions
QFile dcf(":/syntax/dart_functions");
dcf.open(QIODevice::ReadOnly);
QTextStream dcfin(&dcf);
while (!dcfin.atEnd()) {
k = dcfin.readLine();
if (k == "") continue;
dartFunctionsComplete[k.toStdString()] = k.toStdString();
HW->addJSExtDartFunction(k);
}
dcf.close();
// flutter classes
QFile flc(":/syntax/flutter_classes");
flc.open(QIODevice::ReadOnly);
@ -263,6 +281,18 @@ void CompleteWords::loadJSWords()
HW->addJSExtDartObject(k);
}
flw.close();
// flutter functions
QFile flf(":/syntax/flutter_functions");
flf.open(QIODevice::ReadOnly);
QTextStream flfin(&flf);
while (!flfin.atEnd()) {
k = flfin.readLine();
if (k == "") continue;
flutterFunctionsComplete[k.toStdString()] = k.toStdString();
HW->addJSExtDartFunction(k);
}
flf.close();
}
void CompleteWords::loadPHPWords()

View File

@ -3094,58 +3094,85 @@ void Editor::detectCompleteTextJS(QString text, int cursorTextPos, QChar cursorT
}
}
}
// js objects
if (completePopup->count() < completePopup->limit()) {
for (auto & it : CW->jsObjectsComplete) {
QString k = QString::fromStdString(it.first);
//if (k == text) continue;
if (k.indexOf(text, 0, Qt::CaseInsensitive)==0) {
completePopup->addItem(QString::fromStdString(it.first), QString::fromStdString(it.second));
if (completePopup->count() >= completePopup->limit()) break;
if (extension != EXTENSION_DART) {
// js objects
if (completePopup->count() < completePopup->limit()) {
for (auto & it : CW->jsObjectsComplete) {
QString k = QString::fromStdString(it.first);
//if (k == text) continue;
if (k.indexOf(text, 0, Qt::CaseInsensitive)==0) {
completePopup->addItem(QString::fromStdString(it.first), QString::fromStdString(it.second));
if (completePopup->count() >= completePopup->limit()) break;
}
}
}
// js functions
if (completePopup->count() < completePopup->limit()) {
for (auto & it : CW->jsFunctionsComplete) {
QString k = QString::fromStdString(it.first);
//if (k == text) continue;
if (k.indexOf(text, 0, Qt::CaseInsensitive)==0) {
completePopup->addItem(QString::fromStdString(it.first), QString::fromStdString(it.second));
if (completePopup->count() >= completePopup->limit()) break;
}
}
}
// js interfaces
if (completePopup->count() < completePopup->limit()) {
for (auto & it : CW->jsInterfacesComplete) {
QString k = QString::fromStdString(it.first);
//if (k == text) continue;
if (k.indexOf(text, 0, Qt::CaseInsensitive)==0) {
completePopup->addItem(QString::fromStdString(it.first), QString::fromStdString(it.second));
if (completePopup->count() >= completePopup->limit()) break;
}
}
}
}
// js functions
if (completePopup->count() < completePopup->limit()) {
for (auto & it : CW->jsFunctionsComplete) {
QString k = QString::fromStdString(it.first);
//if (k == text) continue;
if (k.indexOf(text, 0, Qt::CaseInsensitive)==0) {
completePopup->addItem(QString::fromStdString(it.first), QString::fromStdString(it.second));
if (completePopup->count() >= completePopup->limit()) break;
// flutter / dart
if (extension == EXTENSION_DART) {
// flutter classes
if (completePopup->count() < completePopup->limit()) {
for (auto & it : CW->flutterObjectsComplete) {
QString k = QString::fromStdString(it.first);
//if (k == text) continue;
if (k.indexOf(text, 0, Qt::CaseInsensitive)==0) {
completePopup->addItem(QString::fromStdString(it.first), QString::fromStdString(it.second));
if (completePopup->count() >= completePopup->limit()) break;
}
}
}
}
// js interfaces
if (completePopup->count() < completePopup->limit()) {
for (auto & it : CW->jsInterfacesComplete) {
QString k = QString::fromStdString(it.first);
//if (k == text) continue;
if (k.indexOf(text, 0, Qt::CaseInsensitive)==0) {
completePopup->addItem(QString::fromStdString(it.first), QString::fromStdString(it.second));
if (completePopup->count() >= completePopup->limit()) break;
// dart classes
if (completePopup->count() < completePopup->limit()) {
for (auto & it : CW->dartObjectsComplete) {
QString k = QString::fromStdString(it.first);
//if (k == text) continue;
if (k.indexOf(text, 0, Qt::CaseInsensitive)==0) {
completePopup->addItem(QString::fromStdString(it.first), QString::fromStdString(it.second));
if (completePopup->count() >= completePopup->limit()) break;
}
}
}
}
// flutter
if (completePopup->count() < completePopup->limit() && extension == EXTENSION_DART) {
for (auto & it : CW->flutterObjectsComplete) {
QString k = QString::fromStdString(it.first);
//if (k == text) continue;
if (k.indexOf(text, 0, Qt::CaseInsensitive)==0) {
completePopup->addItem(QString::fromStdString(it.first), QString::fromStdString(it.second));
if (completePopup->count() >= completePopup->limit()) break;
// flutter functions
if (completePopup->count() < completePopup->limit()) {
for (auto & it : CW->flutterFunctionsComplete) {
QString k = QString::fromStdString(it.first);
//if (k == text) continue;
if (k.indexOf(text, 0, Qt::CaseInsensitive)==0) {
completePopup->addItem(QString::fromStdString(it.first), QString::fromStdString(it.second));
if (completePopup->count() >= completePopup->limit()) break;
}
}
}
}
// dart
if (completePopup->count() < completePopup->limit() && extension == EXTENSION_DART) {
for (auto & it : CW->dartObjectsComplete) {
QString k = QString::fromStdString(it.first);
//if (k == text) continue;
if (k.indexOf(text, 0, Qt::CaseInsensitive)==0) {
completePopup->addItem(QString::fromStdString(it.first), QString::fromStdString(it.second));
if (completePopup->count() >= completePopup->limit()) break;
// dart functions
if (completePopup->count() < completePopup->limit()) {
for (auto & it : CW->dartFunctionsComplete) {
QString k = QString::fromStdString(it.first);
//if (k == text) continue;
if (k.indexOf(text, 0, Qt::CaseInsensitive)==0) {
completePopup->addItem(QString::fromStdString(it.first), QString::fromStdString(it.second));
if (completePopup->count() >= completePopup->limit()) break;
}
}
}
}

View File

@ -291,6 +291,11 @@ void HighlightWords::addJSExtDartObject(QString k)
jsExtDartWordsCS[k.toStdString()] = classFormat;
}
void HighlightWords::addJSExtDartFunction(QString k)
{
jsExtDartWordsCS[k.toStdString()] = knownFunctionFormat;
}
void HighlightWords::addCSSProperty(QString k)
{
csswords[k.toStdString()] = knownFormat;