refactor
This commit is contained in:
parent
a80b9b855b
commit
06a528313d
|
@ -224,7 +224,7 @@ PSearchResultTreeItem CppRefacter::findOccurenceInFile(
|
|||
editor.setSyntaxer(syntaxerManager.getSyntaxer(QSynedit::ProgrammingLanguage::CPP));
|
||||
int posY = 0;
|
||||
while (posY < editor.document()->count()) {
|
||||
QString line = editor.document()->getString(posY);
|
||||
QString line = editor.document()->getLine(posY);
|
||||
if (line.isEmpty()) {
|
||||
posY++;
|
||||
continue;
|
||||
|
@ -234,7 +234,7 @@ PSearchResultTreeItem CppRefacter::findOccurenceInFile(
|
|||
editor.syntaxer()->resetState();
|
||||
} else {
|
||||
editor.syntaxer()->setState(
|
||||
editor.document()->ranges(posY-1));
|
||||
editor.document()->getSyntaxState(posY-1));
|
||||
}
|
||||
editor.syntaxer()->setLine(line,posY);
|
||||
while (!editor.syntaxer()->eol()) {
|
||||
|
@ -289,13 +289,13 @@ void CppRefacter::renameSymbolInFile(const QString &filename, const PStatement &
|
|||
editor.setSyntaxer(syntaxerManager.getSyntaxer(QSynedit::ProgrammingLanguage::CPP));
|
||||
int posY = 0;
|
||||
while (posY < editor.document()->count()) {
|
||||
QString line = editor.document()->getString(posY);
|
||||
QString line = editor.document()->getLine(posY);
|
||||
|
||||
if (posY == 0) {
|
||||
editor.syntaxer()->resetState();
|
||||
} else {
|
||||
editor.syntaxer()->setState(
|
||||
editor.document()->ranges(posY-1));
|
||||
editor.document()->getSyntaxState(posY-1));
|
||||
}
|
||||
editor.syntaxer()->setLine(line,posY);
|
||||
QString newLine;
|
||||
|
|
|
@ -672,16 +672,16 @@ void Editor::keyPressEvent(QKeyEvent *event)
|
|||
} else if (syntaxer()
|
||||
&& caretY()>=2
|
||||
&& syntaxer()->isLastLineCommentNotFinished(
|
||||
document()->ranges(caretY()-2).state)) {
|
||||
document()->getSyntaxState(caretY()-2).state)) {
|
||||
s=trimLeft(lineText());
|
||||
if (s.startsWith("* ")) {
|
||||
handled = true;
|
||||
int right = document()->getString(caretY()-1).length()-caretX();
|
||||
int right = document()->getLine(caretY()-1).length()-caretX();
|
||||
s=lineBreak()+"* ";
|
||||
insertString(s,false);
|
||||
QSynedit::BufferCoord p = caretXY();
|
||||
p.line++;
|
||||
p.ch = document()->getString(p.line-1).length()+1;
|
||||
p.ch = document()->getLine(p.line-1).length()+1;
|
||||
if (right>0) {
|
||||
p.ch -=right+1;
|
||||
}
|
||||
|
@ -1001,7 +1001,7 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to
|
|||
return;
|
||||
|
||||
if (mParser && syntaxer()) {
|
||||
QString lineText = document()->getString(line-1);
|
||||
QString lineText = document()->getLine(line-1);
|
||||
if (mParser->isIncludeLine(lineText)) {
|
||||
if (cursor() == Qt::PointingHandCursor) {
|
||||
QSynedit::BufferCoord p;
|
||||
|
@ -1035,8 +1035,8 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to
|
|||
QString s= getWordAtPosition(this,p, pBeginPos,pEndPos, WordPurpose::wpInformation);
|
||||
if ((pEndPos.line>=1)
|
||||
&& (pEndPos.ch>=0)
|
||||
&& (pEndPos.ch+1 < document()->getString(pEndPos.line-1).length())
|
||||
&& (document()->getString(pEndPos.line-1)[pEndPos.ch+1] == '(')) {
|
||||
&& (pEndPos.ch+1 < document()->getLine(pEndPos.line-1).length())
|
||||
&& (document()->getLine(pEndPos.line-1)[pEndPos.ch+1] == '(')) {
|
||||
kind = StatementKind::skFunction;
|
||||
} else {
|
||||
kind = StatementKind::skVariable;
|
||||
|
@ -1167,7 +1167,7 @@ bool Editor::event(QEvent *event)
|
|||
case TipType::Preprocessor:
|
||||
// When hovering above a preprocessor line, determine if we want to show an include or a identifier hint
|
||||
if (mParser) {
|
||||
s = document()->getString(p.line - 1);
|
||||
s = document()->getLine(p.line - 1);
|
||||
isIncludeNextLine = mParser->isIncludeNextLine(s);
|
||||
if (!isIncludeNextLine)
|
||||
isIncludeLine = mParser->isIncludeLine(s);
|
||||
|
@ -1316,7 +1316,7 @@ void Editor::mouseReleaseEvent(QMouseEvent *event)
|
|||
|
||||
QSynedit::BufferCoord p;
|
||||
if (mParser && pointToCharLine(event->pos(),p)) {
|
||||
QString s = document()->getString(p.line - 1);
|
||||
QString s = document()->getLine(p.line - 1);
|
||||
if (mParser->isIncludeNextLine(s)) {
|
||||
QString filename = mParser->getHeaderFileName(mFilename,s, true);
|
||||
pMainWindow->openFile(filename);
|
||||
|
@ -1570,15 +1570,15 @@ void Editor::addSyntaxIssues(int line, int startChar, int endChar, CompileIssueT
|
|||
pError = std::make_shared<SyntaxIssue>();
|
||||
p.ch = startChar;
|
||||
p.line = line;
|
||||
if (startChar >= document()->getString(line-1).length()) {
|
||||
if (startChar >= document()->getLine(line-1).length()) {
|
||||
start = 1;
|
||||
token = document()->getString(line-1);
|
||||
token = document()->getLine(line-1);
|
||||
} else if (endChar < 1) {
|
||||
if (!getTokenAttriAtRowColEx(p,token,start,attr))
|
||||
return;
|
||||
} else {
|
||||
start = startChar;
|
||||
token = document()->getString(line-1).mid(start-1,endChar-startChar);
|
||||
token = document()->getLine(line-1).mid(start-1,endChar-startChar);
|
||||
}
|
||||
pError->startChar = start;
|
||||
pError->endChar = start + token.length();
|
||||
|
@ -1985,9 +1985,9 @@ QStringList Editor::getExpressionAtPosition(
|
|||
if (line==0) {
|
||||
syntaxer.resetState();
|
||||
} else {
|
||||
syntaxer.setState(document()->ranges(line-1));
|
||||
syntaxer.setState(document()->getSyntaxState(line-1));
|
||||
}
|
||||
QString sLine = document()->getString(line);
|
||||
QString sLine = document()->getLine(line);
|
||||
syntaxer.setLine(sLine,line-1);
|
||||
while (!syntaxer.eol()) {
|
||||
int start = syntaxer.getTokenPos();
|
||||
|
@ -2182,7 +2182,7 @@ QStringList Editor::getExpressionAtPosition(
|
|||
|
||||
line--;
|
||||
if (line>=0)
|
||||
ch = document()->getString(line).length()+1;
|
||||
ch = document()->getLine(line).length()+1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -2192,7 +2192,7 @@ QString Editor::getWordForCompletionSearch(const QSynedit::BufferCoord &pos,bool
|
|||
QString result = "";
|
||||
QString s;
|
||||
|
||||
s = document()->getString(pos.line - 1);
|
||||
s = document()->getLine(pos.line - 1);
|
||||
int len = s.length();
|
||||
|
||||
int wordBegin = pos.ch - 1 - 1; //BufferCoord::Char starts with 1
|
||||
|
@ -2229,9 +2229,9 @@ bool Editor::handleSymbolCompletion(QChar key)
|
|||
if (syntaxer()) {
|
||||
if (caretX() <= 1) {
|
||||
if (caretY()>1) {
|
||||
if (syntaxer()->isLastLineCommentNotFinished(document()->ranges(caretY() - 2).state))
|
||||
if (syntaxer()->isLastLineCommentNotFinished(document()->getSyntaxState(caretY() - 2).state))
|
||||
return false;
|
||||
if (syntaxer()->isLastLineStringNotFinished(document()->ranges(caretY() - 2).state)
|
||||
if (syntaxer()->isLastLineStringNotFinished(document()->getSyntaxState(caretY() - 2).state)
|
||||
&& (key!='\"') && (key!='\''))
|
||||
return false;
|
||||
}
|
||||
|
@ -2372,7 +2372,7 @@ bool Editor::handleParentheseSkip()
|
|||
if (document()->count()==0)
|
||||
return false;
|
||||
if (syntaxer() && syntaxer()->supportBraceLevel()) {
|
||||
QSynedit::SyntaxerState lastLineState = document()->ranges(document()->count()-1);
|
||||
QSynedit::SyntaxState lastLineState = document()->getSyntaxState(document()->count()-1);
|
||||
if (lastLineState.parenthesisLevel==0) {
|
||||
setCaretXY( QSynedit::BufferCoord{caretX() + 1, caretY()}); // skip over
|
||||
return true;
|
||||
|
@ -2423,7 +2423,7 @@ bool Editor::handleBracketSkip()
|
|||
if (document()->count()==0)
|
||||
return false;
|
||||
if (syntaxer() && syntaxer()->supportBraceLevel()) {
|
||||
QSynedit::SyntaxerState lastLineState = document()->ranges(document()->count()-1);
|
||||
QSynedit::SyntaxState lastLineState = document()->getSyntaxState(document()->count()-1);
|
||||
if (lastLineState.bracketLevel==0) {
|
||||
setCaretXY( QSynedit::BufferCoord{caretX() + 1, caretY()}); // skip over
|
||||
return true;
|
||||
|
@ -2466,7 +2466,7 @@ bool Editor::handleBraceCompletion()
|
|||
QString s = lineText().trimmed();
|
||||
int i= caretY()-2;
|
||||
while ((s.isEmpty()) && (i>=0)) {
|
||||
s=document()->getString(i);
|
||||
s=document()->getLine(i);
|
||||
i--;
|
||||
}
|
||||
QString text=selText();
|
||||
|
@ -2510,7 +2510,7 @@ bool Editor::handleBraceSkip()
|
|||
return false;
|
||||
|
||||
if (syntaxer() && syntaxer()->supportBraceLevel()) {
|
||||
QSynedit::SyntaxerState lastLineState = document()->ranges(document()->count()-1);
|
||||
QSynedit::SyntaxState lastLineState = document()->getSyntaxState(document()->count()-1);
|
||||
if (lastLineState.braceLevel==0) {
|
||||
bool oldInsertMode = insertMode();
|
||||
setInsertMode(false); //set mode to overwrite
|
||||
|
@ -2712,10 +2712,10 @@ Editor::QuoteStatus Editor::getQuoteStatus()
|
|||
QuoteStatus Result = QuoteStatus::NotQuote;
|
||||
if (!syntaxer())
|
||||
return Result;
|
||||
if ((caretY()>1) && syntaxer()->isLastLineStringNotFinished(document()->ranges(caretY() - 2).state))
|
||||
if ((caretY()>1) && syntaxer()->isLastLineStringNotFinished(document()->getSyntaxState(caretY() - 2).state))
|
||||
Result = QuoteStatus::DoubleQuote;
|
||||
|
||||
QString Line = document()->getString(caretY()-1);
|
||||
QString Line = document()->getLine(caretY()-1);
|
||||
int posX = caretX()-1;
|
||||
if (posX >= Line.length()) {
|
||||
posX = Line.length()-1;
|
||||
|
@ -3265,7 +3265,7 @@ void Editor::showHeaderCompletion(bool autoComplete, bool forceShow)
|
|||
bool Editor::testInFunc(int x, int y)
|
||||
{
|
||||
bool result = false;
|
||||
QString s = document()->getString(y);
|
||||
QString s = document()->getLine(y);
|
||||
int posY = y;
|
||||
int posX = std::min(x,s.length()-1); // x is started from 1
|
||||
int bracketLevel=0;
|
||||
|
@ -3274,7 +3274,7 @@ bool Editor::testInFunc(int x, int y)
|
|||
posY--;
|
||||
if (posY < 0)
|
||||
return false;
|
||||
s = document()->getString(posY);
|
||||
s = document()->getLine(posY);
|
||||
posX = s.length()-1;
|
||||
}
|
||||
if (s[posX] == '>'
|
||||
|
@ -3585,7 +3585,7 @@ Editor::TipType Editor::getTipType(QPoint point, QSynedit::BufferCoord& pos)
|
|||
// do not allow when dragging selection
|
||||
if (isPointInSelection(pos))
|
||||
return TipType::Selection;
|
||||
} else if (mParser && mParser->isIncludeLine(document()->getString(pos.line-1))) {
|
||||
} else if (mParser && mParser->isIncludeLine(document()->getLine(pos.line-1))) {
|
||||
return TipType::Preprocessor;
|
||||
}else if (attr == syntaxer()->identifierAttribute())
|
||||
return TipType::Identifier;
|
||||
|
@ -3765,7 +3765,7 @@ void Editor::updateFunctionTip(bool showTip)
|
|||
return;
|
||||
|
||||
while (currentLine>=0) {
|
||||
QString line = document()->getString(currentLine);
|
||||
QString line = document()->getLine(currentLine);
|
||||
if (currentLine!=caretPos.line-1)
|
||||
currentChar = line.length();
|
||||
QStringList tokens;
|
||||
|
@ -3774,7 +3774,7 @@ void Editor::updateFunctionTip(bool showTip)
|
|||
syntaxer()->resetState();
|
||||
else
|
||||
syntaxer()->setState(
|
||||
document()->ranges(currentLine-1));
|
||||
document()->getSyntaxState(currentLine-1));
|
||||
syntaxer()->setLine(line,currentLine);
|
||||
while(!syntaxer()->eol()) {
|
||||
int start = syntaxer()->getTokenPos();
|
||||
|
@ -3866,7 +3866,7 @@ void Editor::updateFunctionTip(bool showTip)
|
|||
QString s = getWordAtPosition(this, functionNamePos, pWordBegin,pWordEnd, WordPurpose::wpInformation);
|
||||
|
||||
int x = pWordBegin.ch-1-1;
|
||||
QString line = document()->getString(pWordBegin.line-1);
|
||||
QString line = document()->getLine(pWordBegin.line-1);
|
||||
bool hasPreviousWord=false;
|
||||
while (x>=0) {
|
||||
QChar ch=line[x];
|
||||
|
@ -3966,7 +3966,7 @@ void Editor::popUserCodeInTabStops()
|
|||
tabStopBegin = mTabStopEnd + p->x;
|
||||
tabStopEnd = mTabStopEnd + p->endX;
|
||||
} else {
|
||||
int n=countLeadingWhitespaceChars(document()->getString(caretY()-1+p->y));
|
||||
int n=countLeadingWhitespaceChars(document()->getLine(caretY()-1+p->y));
|
||||
// qDebug()<<line<<n<<p->x;
|
||||
tabStopBegin = n+p->x+1;
|
||||
tabStopEnd = n+p->endX+1;
|
||||
|
@ -4009,8 +4009,8 @@ void Editor::onExportedFormatToken(QSynedit::PSyntaxer syntaxer, int Line, int c
|
|||
if (kind == StatementKind::skUnknown) {
|
||||
if ((pEndPos.line>=1)
|
||||
&& (pEndPos.ch>=0)
|
||||
&& (pEndPos.ch < document()->getString(pEndPos.line-1).length())
|
||||
&& (document()->getString(pEndPos.line-1)[pEndPos.ch] == '(')) {
|
||||
&& (pEndPos.ch < document()->getLine(pEndPos.line-1).length())
|
||||
&& (document()->getLine(pEndPos.line-1)[pEndPos.ch] == '(')) {
|
||||
kind = StatementKind::skFunction;
|
||||
} else {
|
||||
kind = StatementKind::skVariable;
|
||||
|
@ -4217,7 +4217,7 @@ QString getWordAtPosition(QSynedit::QSynEdit *editor, const QSynedit::BufferCoor
|
|||
return "";
|
||||
}
|
||||
|
||||
s = editor->document()->getString(p.line - 1);
|
||||
s = editor->document()->getLine(p.line - 1);
|
||||
int len = s.length();
|
||||
|
||||
int wordBegin = p.ch - 1 - 1; //BufferCoord::Char starts with 1
|
||||
|
@ -4372,7 +4372,7 @@ QString getWordAtPosition(QSynedit::QSynEdit *editor, const QSynedit::BufferCoor
|
|||
if (i<0) {
|
||||
line--;
|
||||
if (line>=1) {
|
||||
s=editor->document()->getString(line-1);
|
||||
s=editor->document()->getLine(line-1);
|
||||
i=s.length();
|
||||
continue;
|
||||
} else
|
||||
|
@ -4427,7 +4427,7 @@ QString Editor::getPreviousWordAtPositionForSuggestion(const QSynedit::BufferCoo
|
|||
}
|
||||
bool inFunc = testInFunc(p.ch-1,p.line-1);
|
||||
|
||||
QString s = document()->getString(p.line - 1);
|
||||
QString s = document()->getLine(p.line - 1);
|
||||
int wordBegin;
|
||||
int wordEnd = p.ch-1;
|
||||
if (wordEnd >= s.length())
|
||||
|
@ -4490,7 +4490,7 @@ QString Editor::getPreviousWordAtPositionForCompleteFunctionDefinition(const QSy
|
|||
return "";
|
||||
}
|
||||
|
||||
QString s = document()->getString(p.line - 1);
|
||||
QString s = document()->getLine(p.line - 1);
|
||||
int wordBegin;
|
||||
int wordEnd = p.ch-1;
|
||||
if (wordEnd >= s.length())
|
||||
|
|
|
@ -5446,9 +5446,9 @@ void MainWindow::onCompileIssue(PCompileIssue issue)
|
|||
int line = issue->line;
|
||||
if (line > e->document()->count())
|
||||
return;
|
||||
int col = std::min(issue->column,e->document()->getString(line-1).length()+1);
|
||||
int col = std::min(issue->column,e->document()->getLine(line-1).length()+1);
|
||||
if (col < 1)
|
||||
col = e->document()->getString(line-1).length()+1;
|
||||
col = e->document()->getLine(line-1).length()+1;
|
||||
e->addSyntaxIssues(line,col,issue->endColumn,issue->type,issue->description);
|
||||
}
|
||||
}
|
||||
|
@ -7853,7 +7853,7 @@ void MainWindow::on_actionAdd_bookmark_triggered()
|
|||
return;
|
||||
QString desc = QInputDialog::getText(editor,tr("Bookmark Description"),
|
||||
tr("Description:"),QLineEdit::Normal,
|
||||
editor->document()->getString(line-1).trimmed());
|
||||
editor->document()->getLine(line-1).trimmed());
|
||||
desc = desc.trimmed();
|
||||
editor->addBookmark(line);
|
||||
mBookmarkModel->addBookmark(editor->filename(),line,desc,editor->inProject());
|
||||
|
|
|
@ -118,7 +118,7 @@ void CPUDialog::setDisassembly(const QString& file, const QString& funcName,cons
|
|||
if (line.startsWith("=>")) {
|
||||
activeLine = i;
|
||||
}
|
||||
ui->txtCode->document()->add(line);
|
||||
ui->txtCode->document()->addLine(line);
|
||||
}
|
||||
if (activeLine!=-1)
|
||||
ui->txtCode->setCaretXYEx(true,QSynedit::BufferCoord{1,activeLine+1});
|
||||
|
|
|
@ -51,7 +51,7 @@ void FilePropertiesDialog::calcFile(Editor *editor,
|
|||
includeLines = 0;
|
||||
// iterate through all lines of file
|
||||
for (int i=0;i<editor->document()->count();i++) {
|
||||
QString line = editor->document()->getString(i);
|
||||
QString line = editor->document()->getLine(i);
|
||||
int j=0;
|
||||
while (j<line.length() && (line[j]=='\t' || line[j]==' '))
|
||||
j++;
|
||||
|
|
|
@ -256,7 +256,7 @@ std::shared_ptr<SearchResultTreeItem> SearchInFileDialog::batchFindInEditor(QSyn
|
|||
item->start = ch;
|
||||
item->len = wordLen;
|
||||
item->parent = parentItem.get();
|
||||
item->text = e->document()->getString(Line-1);
|
||||
item->text = e->document()->getLine(Line-1);
|
||||
item->text.replace('\t',' ');
|
||||
parentItem->results.append(item);
|
||||
return QSynedit::SearchAction::Skip;
|
||||
|
|
|
@ -55,29 +55,29 @@ static void ListIndexOutOfBounds(int index) {
|
|||
|
||||
|
||||
|
||||
int Document::parenthesisLevels(int index)
|
||||
int Document::parenthesisLevel(int index)
|
||||
{
|
||||
QMutexLocker locker(&mMutex);
|
||||
if (index>=0 && index < mLines.size()) {
|
||||
return mLines[index]->fRange.parenthesisLevel;
|
||||
return mLines[index]->syntaxState.parenthesisLevel;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Document::bracketLevels(int index)
|
||||
int Document::bracketLevel(int index)
|
||||
{
|
||||
QMutexLocker locker(&mMutex);
|
||||
if (index>=0 && index < mLines.size()) {
|
||||
return mLines[index]->fRange.bracketLevel;
|
||||
return mLines[index]->syntaxState.bracketLevel;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Document::braceLevels(int index)
|
||||
int Document::braceLevel(int index)
|
||||
{
|
||||
QMutexLocker locker(&mMutex);
|
||||
if (index>=0 && index < mLines.size()) {
|
||||
return mLines[index]->fRange.braceLevel;
|
||||
return mLines[index]->syntaxState.braceLevel;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
@ -86,10 +86,10 @@ int Document::lineColumns(int index)
|
|||
{
|
||||
QMutexLocker locker(&mMutex);
|
||||
if (index>=0 && index < mLines.size()) {
|
||||
if (mLines[index]->fColumns == -1) {
|
||||
if (mLines[index]->columns == -1) {
|
||||
return calculateLineColumns(index);
|
||||
} else
|
||||
return mLines[index]->fColumns;
|
||||
return mLines[index]->columns;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ int Document::blockLevel(int index)
|
|||
{
|
||||
QMutexLocker locker(&mMutex);
|
||||
if (index>=0 && index < mLines.size()) {
|
||||
return mLines[index]->fRange.blockLevel;
|
||||
return mLines[index]->syntaxState.blockLevel;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ int Document::blockStarted(int index)
|
|||
{
|
||||
QMutexLocker locker(&mMutex);
|
||||
if (index>=0 && index < mLines.size()) {
|
||||
return mLines[index]->fRange.blockStarted;
|
||||
return mLines[index]->syntaxState.blockStarted;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
@ -116,9 +116,9 @@ int Document::blockEnded(int index)
|
|||
{
|
||||
QMutexLocker locker(&mMutex);
|
||||
if (index>=0 && index < mLines.size()) {
|
||||
int result = mLines[index]->fRange.blockEnded;
|
||||
int result = mLines[index]->syntaxState.blockEnded;
|
||||
// if (index+1 < mLines.size())
|
||||
// result += mLines[index+1]->fRange.blockEndedLastLine;
|
||||
// result += mLines[index+1]->syntaxState.blockEndedLastLine;
|
||||
return result;
|
||||
} else
|
||||
return 0;
|
||||
|
@ -140,7 +140,7 @@ int Document::lengthOfLongestLine() {
|
|||
}
|
||||
}
|
||||
if (mIndexOfLongestLine >= 0)
|
||||
return mLines[mIndexOfLongestLine]->fColumns;
|
||||
return mLines[mIndexOfLongestLine]->columns;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
@ -158,22 +158,22 @@ QString Document::lineBreak() const
|
|||
return "\n";
|
||||
}
|
||||
|
||||
SyntaxerState Document::ranges(int index)
|
||||
SyntaxState Document::getSyntaxState(int index)
|
||||
{
|
||||
QMutexLocker locker(&mMutex);
|
||||
if (index>=0 && index < mLines.size()) {
|
||||
return mLines[index]->fRange;
|
||||
return mLines[index]->syntaxState;
|
||||
} else {
|
||||
ListIndexOutOfBounds(index);
|
||||
}
|
||||
return SyntaxerState();
|
||||
return SyntaxState();
|
||||
}
|
||||
|
||||
void Document::insertItem(int Index, const QString &s)
|
||||
{
|
||||
beginUpdate();
|
||||
PDocumentLine line = std::make_shared<DocumentLine>();
|
||||
line->fString = s;
|
||||
line->lineText = s;
|
||||
mIndexOfLongestLine = -1;
|
||||
mLines.insert(Index,line);
|
||||
endUpdate();
|
||||
|
@ -183,7 +183,7 @@ void Document::addItem(const QString &s)
|
|||
{
|
||||
beginUpdate();
|
||||
PDocumentLine line = std::make_shared<DocumentLine>();
|
||||
line->fString = s;
|
||||
line->lineText = s;
|
||||
mIndexOfLongestLine = -1;
|
||||
mLines.append(line);
|
||||
endUpdate();
|
||||
|
@ -201,24 +201,24 @@ void Document::setAppendNewLineAtEOF(bool appendNewLineAtEOF)
|
|||
mAppendNewLineAtEOF = appendNewLineAtEOF;
|
||||
}
|
||||
|
||||
void Document::setRange(int Index, const SyntaxerState& range)
|
||||
void Document::setSyntaxState(int Index, const SyntaxState& range)
|
||||
{
|
||||
QMutexLocker locker(&mMutex);
|
||||
if (Index<0 || Index>=mLines.count()) {
|
||||
ListIndexOutOfBounds(Index);
|
||||
}
|
||||
beginUpdate();
|
||||
mLines[Index]->fRange = range;
|
||||
mLines[Index]->syntaxState = range;
|
||||
endUpdate();
|
||||
}
|
||||
|
||||
QString Document::getString(int Index)
|
||||
QString Document::getLine(int Index)
|
||||
{
|
||||
QMutexLocker locker(&mMutex);
|
||||
if (Index<0 || Index>=mLines.count()) {
|
||||
return QString();
|
||||
}
|
||||
return mLines[Index]->fString;
|
||||
return mLines[Index]->lineText;
|
||||
}
|
||||
|
||||
int Document::count()
|
||||
|
@ -264,7 +264,7 @@ QStringList Document::contents()
|
|||
QStringList Result;
|
||||
DocumentLines list = mLines;
|
||||
foreach (const PDocumentLine& line, list) {
|
||||
Result.append(line->fString);
|
||||
Result.append(line->lineText);
|
||||
}
|
||||
return Result;
|
||||
}
|
||||
|
@ -286,7 +286,7 @@ void Document::endUpdate()
|
|||
}
|
||||
|
||||
|
||||
int Document::add(const QString &s)
|
||||
int Document::addLine(const QString &s)
|
||||
{
|
||||
QMutexLocker locker(&mMutex);
|
||||
beginUpdate();
|
||||
|
@ -297,7 +297,7 @@ int Document::add(const QString &s)
|
|||
return Result;
|
||||
}
|
||||
|
||||
void Document::addStrings(const QStringList &strings)
|
||||
void Document::addLines(const QStringList &strings)
|
||||
{
|
||||
QMutexLocker locker(&mMutex);
|
||||
if (strings.count() > 0) {
|
||||
|
@ -320,7 +320,7 @@ int Document::getTextLength()
|
|||
QMutexLocker locker(&mMutex);
|
||||
int Result = 0;
|
||||
foreach (const PDocumentLine& line, mLines ) {
|
||||
Result += line->fString.length();
|
||||
Result += line->lineText.length();
|
||||
if (mNewlineType == NewlineType::Windows) {
|
||||
Result += 2;
|
||||
} else {
|
||||
|
@ -385,7 +385,7 @@ void Document::exchange(int index1, int index2)
|
|||
endUpdate();
|
||||
}
|
||||
|
||||
void Document::insert(int index, const QString &s)
|
||||
void Document::insertLine(int index, const QString &s)
|
||||
{
|
||||
QMutexLocker locker(&mMutex);
|
||||
if ((index < 0) || (index > mLines.count())) {
|
||||
|
@ -418,32 +418,32 @@ QString Document::getTextStr() const
|
|||
QString result;
|
||||
for (int i=0;i<mLines.count()-1;i++) {
|
||||
const PDocumentLine& line = mLines[i];
|
||||
result.append(line->fString);
|
||||
result.append(line->lineText);
|
||||
result.append(lineBreak());
|
||||
}
|
||||
if (mLines.length()>0) {
|
||||
result.append(mLines.back()->fString);
|
||||
result.append(mLines.back()->lineText);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void Document::putString(int index, const QString &s, bool notify) {
|
||||
void Document::putLine(int index, const QString &s, bool notify) {
|
||||
QMutexLocker locker(&mMutex);
|
||||
if (index == mLines.count()) {
|
||||
add(s);
|
||||
addLine(s);
|
||||
} else {
|
||||
if (index<0 || index>=mLines.count()) {
|
||||
ListIndexOutOfBounds(index);
|
||||
}
|
||||
beginUpdate();
|
||||
int oldColumns = mLines[index]->fColumns;
|
||||
mLines[index]->fString = s;
|
||||
int oldColumns = mLines[index]->columns;
|
||||
mLines[index]->lineText = s;
|
||||
calculateLineColumns(index);
|
||||
if (mIndexOfLongestLine == index && oldColumns>mLines[index]->fColumns )
|
||||
if (mIndexOfLongestLine == index && oldColumns>mLines[index]->columns )
|
||||
mIndexOfLongestLine = -1;
|
||||
else if (mIndexOfLongestLine>=0
|
||||
&& mIndexOfLongestLine<mLines.count()
|
||||
&& mLines[index]->fColumns > mLines[mIndexOfLongestLine]->fColumns)
|
||||
&& mLines[index]->columns > mLines[mIndexOfLongestLine]->columns)
|
||||
mIndexOfLongestLine = index;
|
||||
if (notify)
|
||||
emit putted(index,1);
|
||||
|
@ -463,8 +463,8 @@ int Document::calculateLineColumns(int Index)
|
|||
{
|
||||
PDocumentLine line = mLines[Index];
|
||||
|
||||
line->fColumns = stringColumns(line->fString,0);
|
||||
return line->fColumns;
|
||||
line->columns = stringColumns(line->lineText,0);
|
||||
return line->columns;
|
||||
}
|
||||
|
||||
void Document::insertLines(int index, int numLines)
|
||||
|
@ -692,12 +692,12 @@ void Document::saveToFile(QFile &file, const QByteArray& encoding,
|
|||
bool allAscii = true;
|
||||
for (PDocumentLine& line:mLines) {
|
||||
if (allAscii) {
|
||||
allAscii = isTextAllAscii(line->fString);
|
||||
allAscii = isTextAllAscii(line->lineText);
|
||||
}
|
||||
if (!allAscii) {
|
||||
file.write(codec->fromUnicode(line->fString));
|
||||
file.write(codec->fromUnicode(line->lineText));
|
||||
} else {
|
||||
file.write(line->fString.toLatin1());
|
||||
file.write(line->lineText.toLatin1());
|
||||
}
|
||||
file.write(lineBreak().toLatin1());
|
||||
}
|
||||
|
@ -758,7 +758,7 @@ void Document::putTextStr(const QString &text)
|
|||
}
|
||||
pos++;
|
||||
}
|
||||
add(text.mid(start,pos-start));
|
||||
addLine(text.mid(start,pos-start));
|
||||
if (pos>=text.length())
|
||||
break;
|
||||
if (text[pos] == '\r')
|
||||
|
@ -804,7 +804,7 @@ void Document::resetColumns()
|
|||
mIndexOfLongestLine = -1;
|
||||
if (mLines.count() > 0 ) {
|
||||
for (int i=0;i<mLines.size();i++) {
|
||||
mLines[i]->fColumns = -1;
|
||||
mLines[i]->columns = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -814,14 +814,14 @@ void Document::invalidAllLineColumns()
|
|||
QMutexLocker locker(&mMutex);
|
||||
mIndexOfLongestLine = -1;
|
||||
for (PDocumentLine& line:mLines) {
|
||||
line->fColumns = -1;
|
||||
line->columns = -1;
|
||||
}
|
||||
}
|
||||
|
||||
DocumentLine::DocumentLine():
|
||||
fString(),
|
||||
fRange(),
|
||||
fColumns(-1)
|
||||
lineText(),
|
||||
syntaxState(),
|
||||
columns(-1)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -31,12 +31,13 @@
|
|||
namespace QSynedit {
|
||||
|
||||
struct DocumentLine {
|
||||
QString fString;
|
||||
SyntaxerState fRange;
|
||||
int fColumns; //
|
||||
|
||||
QString lineText;
|
||||
SyntaxState syntaxState;
|
||||
int columns; //
|
||||
public:
|
||||
explicit DocumentLine();
|
||||
DocumentLine(const DocumentLine&)=delete;
|
||||
DocumentLine& operator=(const DocumentLine&)=delete;
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<DocumentLine> PDocumentLine;
|
||||
|
@ -54,39 +55,41 @@ class Document : public QObject
|
|||
Q_OBJECT
|
||||
public:
|
||||
explicit Document(const QFont& font, const QFont& nonAsciiFont, QObject* parent=nullptr);
|
||||
Document(const Document&)=delete;
|
||||
Document& operator=(const Document&)=delete;
|
||||
|
||||
int parenthesisLevels(int index);
|
||||
int bracketLevels(int index);
|
||||
int braceLevels(int index);
|
||||
int parenthesisLevel(int index);
|
||||
int bracketLevel(int index);
|
||||
int braceLevel(int index);
|
||||
int lineColumns(int index);
|
||||
int blockLevel(int index);
|
||||
int blockStarted(int index);
|
||||
int blockEnded(int index);
|
||||
int lengthOfLongestLine();
|
||||
QString lineBreak() const;
|
||||
SyntaxerState ranges(int index);
|
||||
void setRange(int index, const SyntaxerState& range);
|
||||
QString getString(int index);
|
||||
SyntaxState getSyntaxState(int index);
|
||||
void setSyntaxState(int index, const SyntaxState& range);
|
||||
QString getLine(int index);
|
||||
int count();
|
||||
QString text();
|
||||
void setText(const QString& text);
|
||||
void setContents(const QStringList& text);
|
||||
QStringList contents();
|
||||
|
||||
void putString(int index, const QString& s, bool notify=true);
|
||||
void putLine(int index, const QString& s, bool notify=true);
|
||||
|
||||
void beginUpdate();
|
||||
void endUpdate();
|
||||
|
||||
int add(const QString& s);
|
||||
void addStrings(const QStringList& strings);
|
||||
int addLine(const QString& s);
|
||||
void addLines(const QStringList& strings);
|
||||
|
||||
int getTextLength();
|
||||
void clear();
|
||||
void deleteAt(int index);
|
||||
void deleteLines(int index, int numLines);
|
||||
void exchange(int index1, int index2);
|
||||
void insert(int index, const QString& s);
|
||||
void insertLine(int index, const QString& s);
|
||||
void insertLines(int index, int numLines);
|
||||
|
||||
void loadFromFile(const QString& filename, const QByteArray& encoding, QByteArray& realEncoding);
|
||||
|
|
|
@ -56,9 +56,9 @@ void Exporter::exportRange(const PDocument& doc, BufferCoord start, BufferCoord
|
|||
if (!doc || !mSyntaxer || (doc->count() == 0))
|
||||
return;
|
||||
stop.line = std::max(1, std::min(stop.line, doc->count()));
|
||||
stop.ch = std::max(1, std::min(stop.ch, doc->getString(stop.line - 1).length() + 1));
|
||||
stop.ch = std::max(1, std::min(stop.ch, doc->getLine(stop.line - 1).length() + 1));
|
||||
start.line = std::max(1, std::min(start.line, doc->count()));
|
||||
start.ch = std::max(1, std::min(start.ch, doc->getString(start.line - 1).length() + 1));
|
||||
start.ch = std::max(1, std::min(start.ch, doc->getLine(start.line - 1).length() + 1));
|
||||
if ( (start.line > doc->count()) || (start.line > stop.line) )
|
||||
return;
|
||||
if ((start.line == stop.line) && (start.ch >= stop.ch))
|
||||
|
@ -71,9 +71,9 @@ void Exporter::exportRange(const PDocument& doc, BufferCoord start, BufferCoord
|
|||
if (start.line == 1)
|
||||
mSyntaxer->resetState();
|
||||
else
|
||||
mSyntaxer->setState(doc->ranges(start.line-2));
|
||||
mSyntaxer->setState(doc->getSyntaxState(start.line-2));
|
||||
for (int i = start.line; i<=stop.line; i++) {
|
||||
QString Line = doc->getString(i-1);
|
||||
QString Line = doc->getLine(i-1);
|
||||
// order is important, since Start.Y might be equal to Stop.Y
|
||||
// if (i == Stop.Line)
|
||||
// Line.remove(Stop.Char-1, INT_MAX);
|
||||
|
|
|
@ -659,7 +659,7 @@ void QSynEditPainter::addHighlightToken(const QString &token, int columnsBefore,
|
|||
|
||||
void QSynEditPainter::paintFoldAttributes()
|
||||
{
|
||||
int TabSteps, LineIndent, LastNonBlank, X, Y, cRow, vLine;
|
||||
int tabSteps, lineIndent, lastNonBlank, X, Y, cRow, vLine;
|
||||
// Paint indent guides. Use folds to determine indent value of these
|
||||
// Use a separate loop so we can use a custom pen
|
||||
// Paint indent guides using custom pen
|
||||
|
@ -685,24 +685,24 @@ void QSynEditPainter::paintFoldAttributes()
|
|||
Y++;
|
||||
}
|
||||
// Get next nonblank line
|
||||
LastNonBlank = vLine - 1;
|
||||
while (LastNonBlank + 1 < edit->mDocument->count() && edit->mDocument->getString(LastNonBlank).isEmpty())
|
||||
LastNonBlank++;
|
||||
if (LastNonBlank>=edit->document()->count())
|
||||
lastNonBlank = vLine - 1;
|
||||
while (lastNonBlank + 1 < edit->mDocument->count() && edit->mDocument->getLine(lastNonBlank).isEmpty())
|
||||
lastNonBlank++;
|
||||
if (lastNonBlank>=edit->document()->count())
|
||||
continue;
|
||||
LineIndent = edit->getLineIndent(edit->mDocument->getString(LastNonBlank));
|
||||
int braceLevel = edit->mDocument->ranges(LastNonBlank).braceLevel;
|
||||
lineIndent = edit->getLineIndent(edit->mDocument->getLine(lastNonBlank));
|
||||
int braceLevel = edit->mDocument->getSyntaxState(lastNonBlank).braceLevel;
|
||||
int indentLevel = braceLevel ;
|
||||
if (edit->tabWidth()>0)
|
||||
indentLevel = LineIndent / edit->tabWidth();
|
||||
indentLevel = lineIndent / edit->tabWidth();
|
||||
// Step horizontal coord
|
||||
//TabSteps = edit->mTabWidth;
|
||||
TabSteps = 0;
|
||||
tabSteps = 0;
|
||||
indentLevel = 0;
|
||||
|
||||
while (TabSteps < LineIndent) {
|
||||
X = TabSteps * edit->mCharWidth + edit->textOffset() - 2;
|
||||
TabSteps+=edit->tabWidth();
|
||||
while (tabSteps < lineIndent) {
|
||||
X = tabSteps * edit->mCharWidth + edit->textOffset() - 2;
|
||||
tabSteps+=edit->tabWidth();
|
||||
indentLevel++ ;
|
||||
if (edit->mSyntaxer) {
|
||||
if (edit->mCodeFolding.indentGuides) {
|
||||
|
@ -721,10 +721,10 @@ void QSynEditPainter::paintFoldAttributes()
|
|||
}
|
||||
if (edit->mCodeFolding.fillIndents) {
|
||||
int X1;
|
||||
if (TabSteps>LineIndent)
|
||||
X1 = LineIndent * edit->mCharWidth + edit->textOffset() - 2;
|
||||
if (tabSteps>lineIndent)
|
||||
X1 = lineIndent * edit->mCharWidth + edit->textOffset() - 2;
|
||||
else
|
||||
X1 = TabSteps * edit->mCharWidth + edit->textOffset() - 2;
|
||||
X1 = tabSteps * edit->mCharWidth + edit->textOffset() - 2;
|
||||
gradientStart.setAlpha(20);
|
||||
gradientEnd.setAlpha(10);
|
||||
QLinearGradient gradient(X,Y,X1,Y);
|
||||
|
@ -820,7 +820,7 @@ void QSynEditPainter::paintLines()
|
|||
break;
|
||||
|
||||
// Get the line.
|
||||
sLine = edit->mDocument->getString(vLine - 1);
|
||||
sLine = edit->mDocument->getLine(vLine - 1);
|
||||
// determine whether will be painted with ActiveLineColor
|
||||
if (edit->mActiveSelectionMode == SelectionMode::Column) {
|
||||
bCurrentLine = (vLine >= selectionBegin.line && vLine <= selectionEnd.line);
|
||||
|
@ -943,7 +943,7 @@ void QSynEditPainter::paintLines()
|
|||
edit->mSyntaxer->resetState();
|
||||
} else {
|
||||
edit->mSyntaxer->setState(
|
||||
edit->mDocument->ranges(vLine-2));
|
||||
edit->mDocument->getSyntaxState(vLine-2));
|
||||
}
|
||||
edit->mSyntaxer->setLine(sLine, vLine - 1);
|
||||
// Try to concatenate as many tokens as possible to minimize the count
|
||||
|
@ -981,7 +981,7 @@ void QSynEditPainter::paintLines()
|
|||
|| sToken == "("
|
||||
|| sToken == "{"
|
||||
) {
|
||||
SyntaxerState rangeState = edit->mSyntaxer->getState();
|
||||
SyntaxState rangeState = edit->mSyntaxer->getState();
|
||||
getBraceColorAttr(rangeState.bracketLevel
|
||||
+rangeState.braceLevel
|
||||
+rangeState.parenthesisLevel
|
||||
|
@ -990,7 +990,7 @@ void QSynEditPainter::paintLines()
|
|||
|| sToken == ")"
|
||||
|| sToken == "}"
|
||||
){
|
||||
SyntaxerState rangeState = edit->mSyntaxer->getState();
|
||||
SyntaxState rangeState = edit->mSyntaxer->getState();
|
||||
getBraceColorAttr(rangeState.bracketLevel
|
||||
+rangeState.braceLevel
|
||||
+rangeState.parenthesisLevel+1,
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -441,14 +441,14 @@ bool ASMSyntaxer::isLastLineStringNotFinished(int /*state*/) const
|
|||
return true;
|
||||
}
|
||||
|
||||
SyntaxerState ASMSyntaxer::getState() const
|
||||
SyntaxState ASMSyntaxer::getState() const
|
||||
{
|
||||
SyntaxerState state;
|
||||
SyntaxState state;
|
||||
state.hasTrailingSpaces = mHasTrailingSpaces;
|
||||
return state;
|
||||
}
|
||||
|
||||
void ASMSyntaxer::setState(const SyntaxerState&)
|
||||
void ASMSyntaxer::setState(const SyntaxState&)
|
||||
{
|
||||
mHasTrailingSpaces = false;
|
||||
}
|
||||
|
|
|
@ -104,8 +104,8 @@ public:
|
|||
bool getTokenFinished() const override;
|
||||
bool isLastLineCommentNotFinished(int state) const override;
|
||||
bool isLastLineStringNotFinished(int state) const override;
|
||||
SyntaxerState getState() const override;
|
||||
void setState(const SyntaxerState& rangeState) override;
|
||||
SyntaxState getState() const override;
|
||||
void setState(const SyntaxState& rangeState) override;
|
||||
void resetState() override;
|
||||
|
||||
|
||||
|
|
|
@ -1575,7 +1575,7 @@ bool CppSyntaxer::isKeyword(const QString &word)
|
|||
return Keywords.contains(word) || mCustomTypeKeywords.contains(word);
|
||||
}
|
||||
|
||||
void CppSyntaxer::setState(const SyntaxerState& rangeState)
|
||||
void CppSyntaxer::setState(const SyntaxState& rangeState)
|
||||
{
|
||||
mRange = rangeState;
|
||||
// current line's left / right parenthesis count should be reset before parsing each line
|
||||
|
@ -1614,7 +1614,7 @@ ProgrammingLanguage CppSyntaxer::language()
|
|||
return ProgrammingLanguage::CPP;
|
||||
}
|
||||
|
||||
SyntaxerState CppSyntaxer::getState() const
|
||||
SyntaxState CppSyntaxer::getState() const
|
||||
{
|
||||
return mRange;
|
||||
}
|
||||
|
|
|
@ -139,7 +139,7 @@ private:
|
|||
|
||||
private:
|
||||
bool mAsmStart;
|
||||
SyntaxerState mRange;
|
||||
SyntaxState mRange;
|
||||
// SynRangeState mSpaceRange;
|
||||
QString mLine;
|
||||
int mLineSize;
|
||||
|
@ -181,7 +181,7 @@ public:
|
|||
void next() override;
|
||||
void setLine(const QString &newLine, int lineNumber) override;
|
||||
bool isKeyword(const QString &word) override;
|
||||
void setState(const SyntaxerState& rangeState) override;
|
||||
void setState(const SyntaxState& rangeState) override;
|
||||
void resetState() override;
|
||||
|
||||
QString languageName() override;
|
||||
|
@ -189,7 +189,7 @@ public:
|
|||
|
||||
// SynHighlighter interface
|
||||
public:
|
||||
SyntaxerState getState() const override;
|
||||
SyntaxState getState() const override;
|
||||
|
||||
// SynHighlighter interface
|
||||
public:
|
||||
|
|
|
@ -49,7 +49,7 @@ protected:
|
|||
QString mLanguageName;
|
||||
QSet<QString> mSuffixes;
|
||||
|
||||
SyntaxerState mRange;
|
||||
SyntaxState mRange;
|
||||
// SynRangeState mSpaceRange;
|
||||
QString mLine;
|
||||
int mLineSize;
|
||||
|
|
|
@ -1402,7 +1402,7 @@ bool GLSLSyntaxer::isKeyword(const QString &word)
|
|||
return Keywords.contains(word);
|
||||
}
|
||||
|
||||
void GLSLSyntaxer::setState(const SyntaxerState& rangeState)
|
||||
void GLSLSyntaxer::setState(const SyntaxState& rangeState)
|
||||
{
|
||||
mRange = rangeState;
|
||||
// current line's left / right parenthesis count should be reset before parsing each line
|
||||
|
@ -1441,7 +1441,7 @@ ProgrammingLanguage GLSLSyntaxer::language()
|
|||
return ProgrammingLanguage::GLSL;
|
||||
}
|
||||
|
||||
SyntaxerState GLSLSyntaxer::getState() const
|
||||
SyntaxState GLSLSyntaxer::getState() const
|
||||
{
|
||||
return mRange;
|
||||
}
|
||||
|
|
|
@ -134,7 +134,7 @@ private:
|
|||
void pushIndents(int indentType);
|
||||
|
||||
private:
|
||||
SyntaxerState mRange;
|
||||
SyntaxState mRange;
|
||||
// SynRangeState mSpaceRange;
|
||||
QString mLineString;
|
||||
QChar* mLine;
|
||||
|
@ -175,7 +175,7 @@ public:
|
|||
void next() override;
|
||||
void setLine(const QString &newLine, int lineNumber) override;
|
||||
bool isKeyword(const QString &word) override;
|
||||
void setState(const SyntaxerState& rangeState) override;
|
||||
void setState(const SyntaxState& rangeState) override;
|
||||
void resetState() override;
|
||||
|
||||
QString languageName() override;
|
||||
|
@ -183,7 +183,7 @@ public:
|
|||
|
||||
// SynHighlighter interface
|
||||
public:
|
||||
SyntaxerState getState() const override;
|
||||
SyntaxState getState() const override;
|
||||
|
||||
// SynHighlighter interface
|
||||
public:
|
||||
|
|
|
@ -664,15 +664,15 @@ bool MakefileSyntaxer::isLastLineStringNotFinished(int /*state*/) const
|
|||
return false;
|
||||
}
|
||||
|
||||
SyntaxerState MakefileSyntaxer::getState() const
|
||||
SyntaxState MakefileSyntaxer::getState() const
|
||||
{
|
||||
SyntaxerState state;
|
||||
SyntaxState state;
|
||||
state.state = (int)mState;
|
||||
state.hasTrailingSpaces = mHasTrailingSpaces;
|
||||
return state;
|
||||
}
|
||||
|
||||
void MakefileSyntaxer::setState(const SyntaxerState & rangeState)
|
||||
void MakefileSyntaxer::setState(const SyntaxState & rangeState)
|
||||
{
|
||||
mState = (RangeState)rangeState.state;
|
||||
mStates.clear();
|
||||
|
|
|
@ -148,8 +148,8 @@ public:
|
|||
bool getTokenFinished() const override;
|
||||
bool isLastLineCommentNotFinished(int state) const override;
|
||||
bool isLastLineStringNotFinished(int state) const override;
|
||||
SyntaxerState getState() const override;
|
||||
void setState(const SyntaxerState& rangeState) override;
|
||||
SyntaxState getState() const override;
|
||||
void setState(const SyntaxState& rangeState) override;
|
||||
void resetState() override;
|
||||
|
||||
bool isIdentChar(const QChar& ch) const override;
|
||||
|
|
|
@ -248,7 +248,7 @@ TokenAttribute::TokenAttribute(const QString &name, TokenType tokenType):
|
|||
|
||||
}
|
||||
|
||||
bool SyntaxerState::operator==(const SyntaxerState &s2)
|
||||
bool SyntaxState::operator==(const SyntaxState &s2)
|
||||
{
|
||||
// indents contains the information of brace/parenthesis/brackets embedded levels
|
||||
return (state == s2.state)
|
||||
|
@ -256,14 +256,14 @@ bool SyntaxerState::operator==(const SyntaxerState &s2)
|
|||
;
|
||||
}
|
||||
|
||||
int SyntaxerState::getLastIndent()
|
||||
int SyntaxState::getLastIndent()
|
||||
{
|
||||
if (indents.isEmpty())
|
||||
return -1;
|
||||
return indents.back();
|
||||
}
|
||||
|
||||
SyntaxerState::SyntaxerState():
|
||||
SyntaxState::SyntaxState():
|
||||
state(0),
|
||||
blockLevel(0),
|
||||
blockStarted(0),
|
||||
|
|
|
@ -34,7 +34,7 @@ enum IndentType {
|
|||
IndentForStatement,
|
||||
};
|
||||
|
||||
struct SyntaxerState {
|
||||
struct SyntaxState {
|
||||
int state; // current syntax parsing state
|
||||
int blockLevel; // needed by block folding
|
||||
int blockStarted; // needed by block folding
|
||||
|
@ -52,9 +52,9 @@ struct SyntaxerState {
|
|||
but not started at this line
|
||||
(need by auto indent) */
|
||||
bool hasTrailingSpaces;
|
||||
bool operator==(const SyntaxerState& s2);
|
||||
bool operator==(const SyntaxState& s2);
|
||||
int getLastIndent();
|
||||
SyntaxerState();
|
||||
SyntaxState();
|
||||
};
|
||||
|
||||
enum class TokenType {
|
||||
|
@ -146,14 +146,14 @@ public:
|
|||
virtual bool isLastLineCommentNotFinished(int state) const = 0;
|
||||
virtual bool isLastLineStringNotFinished(int state) const = 0;
|
||||
virtual bool eol() const = 0;
|
||||
virtual SyntaxerState getState() const = 0;
|
||||
virtual SyntaxState getState() const = 0;
|
||||
virtual QString getToken() const=0;
|
||||
virtual const PTokenAttribute &getTokenAttribute() const=0;
|
||||
virtual int getTokenPos() = 0;
|
||||
virtual bool isKeyword(const QString& word);
|
||||
virtual void next() = 0;
|
||||
virtual void nextToEol();
|
||||
virtual void setState(const SyntaxerState& rangeState) = 0;
|
||||
virtual void setState(const SyntaxState& rangeState) = 0;
|
||||
virtual void setLine(const QString& newLine, int lineNumber) = 0;
|
||||
virtual void resetState() = 0;
|
||||
virtual QSet<QString> keywords() const;
|
||||
|
|
Loading…
Reference in New Issue