work save
This commit is contained in:
parent
54443c20f8
commit
fd03ea4098
|
@ -1664,32 +1664,129 @@ QStringList Editor::getExpressionAtPositionForCompletion(const BufferCoord &pos)
|
|||
for (int i=tokens.count()-1;i>=0;i--) {
|
||||
QString token = tokens[i];
|
||||
switch(lastSymbolType) {
|
||||
case LastSymbolType::None:
|
||||
case LastSymbolType::MemberOperator:
|
||||
case LastSymbolType::ParenthesisMatched:
|
||||
case LastSymbolType::BracketMatched:
|
||||
if ((token =="::" || token == "." || token == "->")
|
||||
&& lastSymbolType!=LastSymbolType::MemberOperator
|
||||
){
|
||||
lastSymbolType=LastSymbolType::MemberOperator;
|
||||
} else if (token == ")" ) {
|
||||
case LastSymbolType::ScopeResolutionOperator: //before '::'
|
||||
if (token==">") {
|
||||
lastSymbolType=LastSymbolType::MatchingAngleQuotation;
|
||||
symbolMatchingLevel=0;
|
||||
} else if (isIdentChar(token.front())) {
|
||||
lastSymbolType=LastSymbolType::Identifier;
|
||||
} else
|
||||
return result;
|
||||
break;
|
||||
case LastSymbolType::ObjectMemberOperator: //before '.'
|
||||
case LastSymbolType::PointerMemberOperator: //before '->'
|
||||
case LastSymbolType::PointerToMemberOfObjectOperator: //before '.*'
|
||||
case LastSymbolType::PointerToMemberOfPointerOperator: //before '->*'
|
||||
if (token == ")" ) {
|
||||
lastSymbolType=LastSymbolType::MatchingParenthesis;
|
||||
symbolMatchingLevel = 0;
|
||||
} else if (token == "]") {
|
||||
if (lastSymbolType == LastSymbolType::BracketMatched)
|
||||
return result;
|
||||
lastSymbolType=LastSymbolType::MatchingBracket;
|
||||
symbolMatchingLevel = 0;
|
||||
} else if (isIdentChar(token.front())) {
|
||||
lastSymbolType=LastSymbolType::Identifier;
|
||||
} else
|
||||
return result;
|
||||
result.push_front(token);
|
||||
break;
|
||||
case LastSymbolType::AsteriskSign: // before '*':
|
||||
if (token == '*') {
|
||||
|
||||
} else
|
||||
return result;
|
||||
break;
|
||||
case LastSymbolType::AmpersandSign: // before '&':
|
||||
return result;
|
||||
break;
|
||||
case LastSymbolType::ParenthesisMatched: //before '()'
|
||||
if (token == ".") {
|
||||
lastSymbolType=LastSymbolType::ObjectMemberOperator;
|
||||
} else if (token=="->") {
|
||||
lastSymbolType = LastSymbolType::PointerMemberOperator;
|
||||
} else if (token == ".*") {
|
||||
lastSymbolType = LastSymbolType::PointerToMemberOfObjectOperator;
|
||||
} else if (token == "->*"){
|
||||
lastSymbolType = LastSymbolType::PointerToMemberOfPointerOperator;
|
||||
} else if (token==">") {
|
||||
lastSymbolType=LastSymbolType::MatchingAngleQuotation;
|
||||
symbolMatchingLevel=0;
|
||||
} else if (token == ")" ) {
|
||||
lastSymbolType=LastSymbolType::MatchingParenthesis;
|
||||
symbolMatchingLevel = 0;
|
||||
} else if (token == "]") {
|
||||
lastSymbolType=LastSymbolType::MatchingBracket;
|
||||
symbolMatchingLevel = 0;
|
||||
} else if (token == "*") {
|
||||
lastSymbolType=LastSymbolType::AsteriskSign;
|
||||
} else if (token == "&") {
|
||||
lastSymbolType=LastSymbolType::AmpersandSign;
|
||||
} else if (isIdentChar(token.front())) {
|
||||
lastSymbolType=LastSymbolType::Identifier;
|
||||
} else
|
||||
return result;
|
||||
break;
|
||||
case LastSymbolType::BracketMatched: //before '[]'
|
||||
if (token == ")" ) {
|
||||
lastSymbolType=LastSymbolType::MatchingParenthesis;
|
||||
symbolMatchingLevel = 0;
|
||||
} else if (token == "]") {
|
||||
lastSymbolType=LastSymbolType::MatchingBracket;
|
||||
symbolMatchingLevel = 0;
|
||||
} else if (isIdentChar(token.front())) {
|
||||
lastSymbolType=LastSymbolType::Identifier;
|
||||
} else
|
||||
return result;
|
||||
break;
|
||||
case LastSymbolType::AngleQuotationMatched: //before '<>'
|
||||
if (isIdentChar(token.front())) {
|
||||
lastSymbolType=LastSymbolType::Identifier;
|
||||
} else
|
||||
return result;
|
||||
break;
|
||||
case LastSymbolType::None:
|
||||
if (token =="::") {
|
||||
lastSymbolType=LastSymbolType::ScopeResolutionOperator;
|
||||
} else if (token == ".") {
|
||||
lastSymbolType=LastSymbolType::ObjectMemberOperator;
|
||||
} else if (token=="->") {
|
||||
lastSymbolType = LastSymbolType::PointerMemberOperator;
|
||||
} else if (token == ".*") {
|
||||
lastSymbolType = LastSymbolType::PointerToMemberOfObjectOperator;
|
||||
} else if (token == "->*"){
|
||||
lastSymbolType = LastSymbolType::PointerToMemberOfPointerOperator;
|
||||
} else if (token == ")" ) {
|
||||
lastSymbolType=LastSymbolType::MatchingParenthesis;
|
||||
symbolMatchingLevel = 0;
|
||||
} else if (token == "]") {
|
||||
lastSymbolType=LastSymbolType::MatchingBracket;
|
||||
symbolMatchingLevel = 0;
|
||||
} else if (isIdentChar(token.front())) {
|
||||
lastSymbolType=LastSymbolType::Identifier;
|
||||
} else
|
||||
return result;
|
||||
break;
|
||||
case LastSymbolType::TildeSign:
|
||||
if (token =="::") {
|
||||
lastSymbolType=LastSymbolType::ScopeResolutionOperator;
|
||||
} else
|
||||
return result;
|
||||
break;;
|
||||
case LastSymbolType::Identifier:
|
||||
if (token =="::" || token == "." || token == "->") {
|
||||
lastSymbolType=LastSymbolType::MemberOperator;
|
||||
result.push_front(token);
|
||||
if (token =="::") {
|
||||
lastSymbolType=LastSymbolType::ScopeResolutionOperator;
|
||||
} else if (token == ".") {
|
||||
lastSymbolType=LastSymbolType::ObjectMemberOperator;
|
||||
} else if (token=="->") {
|
||||
lastSymbolType = LastSymbolType::PointerMemberOperator;
|
||||
} else if (token == ".*") {
|
||||
lastSymbolType = LastSymbolType::PointerToMemberOfObjectOperator;
|
||||
} else if (token == "->*"){
|
||||
lastSymbolType = LastSymbolType::PointerToMemberOfPointerOperator;
|
||||
} else if (token == "~") {
|
||||
lastSymbolType=LastSymbolType::TildeSign;
|
||||
} else if (token == "*") {
|
||||
lastSymbolType=LastSymbolType::AsteriskSign;
|
||||
} else if (token == "&") {
|
||||
lastSymbolType=LastSymbolType::AmpersandSign;
|
||||
} else
|
||||
return result; // stop matching;
|
||||
break;
|
||||
|
@ -1703,7 +1800,6 @@ QStringList Editor::getExpressionAtPositionForCompletion(const BufferCoord &pos)
|
|||
} else if (token==")") {
|
||||
symbolMatchingLevel++;
|
||||
}
|
||||
result.push_front(token);
|
||||
break;
|
||||
case LastSymbolType::MatchingBracket:
|
||||
if (token=="[") {
|
||||
|
@ -1715,9 +1811,20 @@ QStringList Editor::getExpressionAtPositionForCompletion(const BufferCoord &pos)
|
|||
} else if (token=="]") {
|
||||
symbolMatchingLevel++;
|
||||
}
|
||||
result.push_front(token);
|
||||
break;
|
||||
case LastSymbolType::MatchingAngleQuotation:
|
||||
if (token=="<") {
|
||||
if (symbolMatchingLevel==0) {
|
||||
lastSymbolType=LastSymbolType::MatchingAngleQuotation;
|
||||
} else {
|
||||
symbolMatchingLevel--;
|
||||
}
|
||||
} else if (token==">") {
|
||||
symbolMatchingLevel++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
result.push_front(token);
|
||||
}
|
||||
|
||||
line--;
|
||||
|
|
|
@ -43,11 +43,20 @@ class Editor : public SynEdit
|
|||
public:
|
||||
enum class LastSymbolType {
|
||||
Identifier,
|
||||
MemberOperator,
|
||||
ScopeResolutionOperator, //'::'
|
||||
ObjectMemberOperator, //'.'
|
||||
PointerMemberOperator, //'->'
|
||||
PointerToMemberOfObjectOperator, //'.*'
|
||||
PointerToMemberOfPointerOperator, //'->*'
|
||||
MatchingBracket,
|
||||
BracketMatched,
|
||||
MatchingParenthesis,
|
||||
ParenthesisMatched,
|
||||
TildeSign, // '~'
|
||||
AsteriskSign, // '*'
|
||||
AmpersandSign, // '&'
|
||||
MatchingAngleQuotation,
|
||||
AngleQuotationMatched,
|
||||
None
|
||||
};
|
||||
|
||||
|
|
|
@ -565,8 +565,13 @@ void SynEditCppHighlighter::minusProc()
|
|||
mExtTokenId = ExtTokenKind::Decrement;
|
||||
break;
|
||||
case '>':
|
||||
if (mLine[mRun+2]=='*') {
|
||||
mRun += 3;
|
||||
mExtTokenId = ExtTokenKind::PointerToMemberOfPointer;
|
||||
} else {
|
||||
mRun += 2;
|
||||
mExtTokenId = ExtTokenKind::Arrow;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
mRun += 1;
|
||||
|
@ -824,7 +829,10 @@ void SynEditCppHighlighter::plusProc()
|
|||
void SynEditCppHighlighter::pointProc()
|
||||
{
|
||||
mTokenId = TokenKind::Symbol;
|
||||
if (mLine[mRun+1] == '.' && mLine[mRun+2] == '.') {
|
||||
if (mLine[mRun+1] == '*' ) {
|
||||
mRun+=2;
|
||||
mExtTokenId = ExtTokenKind::PointerToMemberOfObject;
|
||||
} else if (mLine[mRun+1] == '.' && mLine[mRun+2] == '.') {
|
||||
mRun+=3;
|
||||
mExtTokenId = ExtTokenKind::Ellipse;
|
||||
} else if (mLine[mRun+1]>='0' && mLine[mRun+1]<='9') {
|
||||
|
|
|
@ -32,7 +32,8 @@ class SynEditCppHighlighter: public SynHighlighter
|
|||
Decrement, Divide, DivideAssign, Ellipse, GreaterThan,
|
||||
GreaterThanEqual, IncOr, IncOrAssign, Increment, LessThan,
|
||||
LessThanEqual, LogAnd, LogComplement, LogEqual, LogOr,
|
||||
Mod, ModAssign, MultiplyAssign, NotEqual, Point, Question,
|
||||
Mod, ModAssign, MultiplyAssign, NotEqual, Point, PointerToMemberOfObject,
|
||||
PointerToMemberOfPointer,Question,
|
||||
RoundClose, RoundOpen, ScopeResolution, SemiColon, ShiftLeft,
|
||||
ShiftLeftAssign, ShiftRight, ShiftRightAssign, SquareClose,
|
||||
SquareOpen, Star, Subtract, SubtractAssign, Xor,
|
||||
|
|
|
@ -85,6 +85,30 @@ void CodeCompletionPopup::prepareSearch(const QString& preWord,const QString &ph
|
|||
setCursor(oldCursor);
|
||||
}
|
||||
|
||||
void CodeCompletionPopup::prepareSearch(const QString &preWord, const QStringList &expression, const QString &filename, int line)
|
||||
{
|
||||
QMutexLocker locker(&mMutex);
|
||||
if (!isEnabled())
|
||||
return;
|
||||
//Screen.Cursor := crHourglass;
|
||||
QCursor oldCursor = cursor();
|
||||
setCursor(Qt::CursorShape::WaitCursor);
|
||||
|
||||
if (preWord.isEmpty()) {
|
||||
mIncludedFiles = mParser->getFileIncludes(filename);
|
||||
getCompletionFor(expression,filename,line);
|
||||
|
||||
if (mFullCompletionStatementList.isEmpty() &&
|
||||
(!expression.isEmpty() && expression.startsWith("~"))) {
|
||||
getCompletionFor(expression.mid(1),filename,line);
|
||||
}
|
||||
} else {
|
||||
getFullCompletionListFor(preWord);
|
||||
}
|
||||
|
||||
setCursor(oldCursor);
|
||||
}
|
||||
|
||||
bool CodeCompletionPopup::search(const QString &phrase, bool autoHideOnSingleResult)
|
||||
{
|
||||
QMutexLocker locker(&mMutex);
|
||||
|
|
|
@ -32,6 +32,7 @@ public:
|
|||
|
||||
void setKeypressedCallback(const KeyPressedCallback &newKeypressedCallback);
|
||||
void prepareSearch(const QString& preWord, const QString& phrase, const QString& filename, int line);
|
||||
void prepareSearch(const QString& preWord, const QStringList & expression, const QString& filename, int line);
|
||||
bool search(const QString& phrase, bool autoHideOnSingleResult);
|
||||
|
||||
PStatement selectedStatement();
|
||||
|
@ -74,6 +75,7 @@ private:
|
|||
void addStatement(PStatement statement, const QString& fileName, int line);
|
||||
void filterList(const QString& member);
|
||||
void getCompletionFor(const QString& fileName,const QString& phrase, int line);
|
||||
void getCompletionFor(const QStringList& expression, const QString& fileName,int line);
|
||||
void getFullCompletionListFor(const QString& preWord);
|
||||
void addKeyword(const QString& keyword);
|
||||
bool isIncluded(const QString& fileName);
|
||||
|
|
Loading…
Reference in New Issue