auto complete improved
This commit is contained in:
parent
caa87daa17
commit
c33d86b73b
|
@ -48,6 +48,7 @@ public:
|
|||
std::map<std::string, std::string> phpClassMethodsComplete;
|
||||
std::map<std::string, std::string> phpGlobalsComplete;
|
||||
std::map<std::string, std::string> phpSpecialsComplete;
|
||||
std::map<std::string, std::string> phpMagicComplete;
|
||||
protected:
|
||||
void loadCSSWords();
|
||||
void loadHTMLWords();
|
||||
|
|
15
qrc/resources/syntax/php/magic
Normal file
15
qrc/resources/syntax/php/magic
Normal file
|
@ -0,0 +1,15 @@
|
|||
__construct
|
||||
__destruct
|
||||
__call
|
||||
__callStatic
|
||||
__get
|
||||
__set
|
||||
__isset
|
||||
__unset
|
||||
__sleep
|
||||
__wakeup
|
||||
__toString
|
||||
__invoke
|
||||
__set_state
|
||||
__clone
|
||||
__debugInfo
|
|
@ -22,5 +22,6 @@
|
|||
<file alias="css_values">resources/syntax/css/values</file>
|
||||
<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>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -392,4 +392,15 @@ void CompleteWords::loadPHPWords()
|
|||
phpClassMethodTypes[kList.at(0).toStdString()] = kList.at(1).toStdString();
|
||||
}
|
||||
mtf.close();
|
||||
|
||||
// php magic methods
|
||||
QFile magf(":/syntax/php_magic");
|
||||
magf.open(QIODevice::ReadOnly);
|
||||
QTextStream magin(&magf);
|
||||
while (!magin.atEnd()) {
|
||||
k = magin.readLine();
|
||||
if (k == "") continue;
|
||||
phpMagicComplete[k.toStdString()] = k.toStdString();
|
||||
}
|
||||
magf.close();
|
||||
}
|
||||
|
|
|
@ -2851,6 +2851,17 @@ void Editor::detectCompleteTextCSS(QString text, QChar cursorTextPrevChar)
|
|||
}
|
||||
}
|
||||
}
|
||||
if (completePopup->count() < completePopup->limit()) {
|
||||
// html tags
|
||||
for (auto & it : CW->htmlAllTagsComplete) {
|
||||
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 (cursorTextPrevChar == ":" && completePopup->count() < completePopup->limit()) {
|
||||
// css pseudo
|
||||
for (auto & it : CW->cssPseudoComplete) {
|
||||
|
@ -3195,6 +3206,16 @@ void Editor::detectCompleteTextPHPGlobalContext(QString text, int cursorTextPos,
|
|||
// do not detect php tag
|
||||
completeDetectedPHP = true;
|
||||
}
|
||||
} else if (text[0] == "_" && prevWord == "function") {
|
||||
// php magic methods
|
||||
for (auto & it : CW->phpMagicComplete) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
} else if (text[0] == "$") {
|
||||
std::unordered_map<std::string, std::string> vars;
|
||||
std::unordered_map<std::string, std::string>::iterator varsIterator;
|
||||
|
|
Loading…
Reference in a new issue