diff --git a/sources/plugins/scs/highlightingrules/scsmultilinehighlightingrule.cpp b/sources/plugins/scs/highlightingrules/scsmultilinehighlightingrule.cpp
index 762166e..dd226a0 100644
--- a/sources/plugins/scs/highlightingrules/scsmultilinehighlightingrule.cpp
+++ b/sources/plugins/scs/highlightingrules/scsmultilinehighlightingrule.cpp
@@ -1,3 +1,25 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of OSTIS (Open Semantic Technology for Intelligent Systems)
+For the latest info, see http://www.ostis.net
+
+Copyright (c) 2010 OSTIS
+
+OSTIS is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+OSTIS is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with OSTIS. If not, see .
+-----------------------------------------------------------------------------
+*/
+
#include "scsmultilinehighlightingrule.h"
SCsMultiLinetHighlightingRule::SCsMultiLinetHighlightingRule(QRegExp start, QRegExp end, QTextCharFormat format, BlockRuleState state)
@@ -12,7 +34,7 @@ void SCsMultiLinetHighlightingRule::assignFormat(SCsSyntaxHighlighter *highlight
{
int state = highlighter->curBlockState();
- if(state>0 && state!= mState )
+ if (state>0 && state!= mState )
return;
highlighter->setCurBlockState(0);
diff --git a/sources/plugins/scs/highlightingrules/scsmultilinehighlightingrule.h b/sources/plugins/scs/highlightingrules/scsmultilinehighlightingrule.h
index f63b068..e17e435 100644
--- a/sources/plugins/scs/highlightingrules/scsmultilinehighlightingrule.h
+++ b/sources/plugins/scs/highlightingrules/scsmultilinehighlightingrule.h
@@ -1,3 +1,25 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of OSTIS (Open Semantic Technology for Intelligent Systems)
+For the latest info, see http://www.ostis.net
+
+Copyright (c) 2010 OSTIS
+
+OSTIS is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+OSTIS is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with OSTIS. If not, see .
+-----------------------------------------------------------------------------
+*/
+
#ifndef SCSMULTILINEHIGHLIGHTINGRULE_H
#define SCSMULTILINEHIGHLIGHTINGRULE_H
diff --git a/sources/plugins/scs/scs.pro b/sources/plugins/scs/scs.pro
index e504fe4..adf1042 100644
--- a/sources/plugins/scs/scs.pro
+++ b/sources/plugins/scs/scs.pro
@@ -40,6 +40,7 @@ HEADERS += \
scsparser/SCsCLexer.h \
scsparser/SCsCParser.h \
scsparser/scscparserdefs.h \
+ scsparser/scsasynchparser.h \
scswindow.h \
scsplugin.h \
scscodeerroranalyzer.h \
@@ -63,6 +64,7 @@ SOURCES += \
scsparser/SCsCLexer.c \
scsparser/SCsCParser.c \
scsparser/scscparserdefs.c \
+ scsparser/scsasynchparser.cpp \
scswindow.cpp \
scserrortablewidget.cpp \
scscodeeditor.cpp \
diff --git a/sources/plugins/scs/scscodeanalyzer.cpp b/sources/plugins/scs/scscodeanalyzer.cpp
index 66a6e85..aac0c55 100644
--- a/sources/plugins/scs/scscodeanalyzer.cpp
+++ b/sources/plugins/scs/scscodeanalyzer.cpp
@@ -20,37 +20,36 @@ along with OSTIS. If not, see .
-----------------------------------------------------------------------------
*/
-
-
#include "scscodeanalyzer.h"
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-
#include "scsparserwrapper.h"
+#include "scsasynchparser.h"
+
+#include
const QRegExp SCsCodeAnalyzer::msIdentifierExp("([A-Za-z0-9_.#]+)");
SCsCodeAnalyzer::SCsCodeAnalyzer(QObject *parent) :
-QObject(parent)
+ QObject(parent)
+ , mUpdateModel(0)
+ , mAsynchParser(0)
+ , mIsBusy(false)
{
-
+ mAsynchParser = new SCsAsynchParser(this);
+ connect(mAsynchParser,SIGNAL(parseIdentifiersFinished()),SLOT(asynchUpdateExtractIdftFinished()));
}
-void SCsCodeAnalyzer::fillModel(QStandardItemModel *model)
+void SCsCodeAnalyzer::fillModel(QStandardItemModel *model, const QSet &idtfs)
{
- model->clear();
+ Q_CHECK_PTR(model);
- QSet identifiers = mDocumentIdentifiers;
+ if (!model)
+ return;
- foreach(const QString &id, identifiers)
+ model->clear();
+
+ foreach (const QString &id, idtfs)
{
QStandardItem *item = new QStandardItem(id);
model->appendRow(item);
@@ -76,33 +75,80 @@ bool SCsCodeAnalyzer::isIdentifier(const QString &text)
void SCsCodeAnalyzer::update(const QString &text, QStandardItemModel *model)
{
- extractIdentifiers(text, &mDocumentIdentifiers);
+ if (mIsBusy)
+ return;
+
+ extractIdentifiers(text, mDocumentIdentifiers);
mDocumentIdentifiers -= mIgnoreIdentifiers;
- fillModel(model);
+ fillModel(model, mDocumentIdentifiers);
mIgnoreIdentifiers.clear();
}
+void SCsCodeAnalyzer::asynchUpdate(const QString &text, QStandardItemModel *model)
+{
+ if (mIsBusy)
+ return;
+
+ if (text.isEmpty())
+ return;
+
+ mIsBusy = true;
+
+ mUpdateModel = model;
+
+ mAsynchParser->parseIdentifiers(text);
+
+}
void SCsCodeAnalyzer::parse(const QString &text, QStandardItemModel *model)
{
+ if (mIsBusy)
+ return;
+
+ if (text.isEmpty())
+ return;
+
mDocumentIdentifiers.clear();
mIgnoreIdentifiers.clear();
- extractIdentifiers(text, &mDocumentIdentifiers);
+ extractIdentifiers(text, mDocumentIdentifiers);
- fillModel(model);
+ fillModel(model, mDocumentIdentifiers);
}
-void SCsCodeAnalyzer::extractIdentifiers(const QString &text, QSet *identifiers)
+void SCsCodeAnalyzer::extractIdentifiers(const QString &text, QSet &identifiers)
{
SCsParser parser;
- *identifiers = parser.getIdentifier(text);
+ QSharedPointer idtf = parser.getIdentifier(text);
+
+ identifiers = *idtf;
}
+
+
+void SCsCodeAnalyzer::asynchUpdateExtractIdftFinished()
+{
+ Q_ASSERT(mAsynchParser->isParseIdentifiersResultPresent());
+
+ if (!mAsynchParser->isParseIdentifiersResultPresent())
+ return;
+
+ QSharedPointer idtfs = mAsynchParser->parseIdentifiersResult();
+
+ *idtfs -= mIgnoreIdentifiers;
+
+ fillModel(mUpdateModel, *idtfs);
+
+ mIgnoreIdentifiers.clear();
+
+ mIsBusy = false;
+}
+
+
diff --git a/sources/plugins/scs/scscodeanalyzer.h b/sources/plugins/scs/scscodeanalyzer.h
index 462b3dc..b5f485d 100644
--- a/sources/plugins/scs/scscodeanalyzer.h
+++ b/sources/plugins/scs/scscodeanalyzer.h
@@ -33,6 +33,8 @@ along with OSTIS. If not, see .
#include
class QStandardItemModel;
+class SCsParseExtractIdftAsynchTask;
+class SCsAsynchParser;
class SCsCodeAnalyzer : public QObject
@@ -55,6 +57,8 @@ class SCsCodeAnalyzer : public QObject
*/
void update(const QString &text, QStandardItemModel *model);
+ void asynchUpdate(const QString &text, QStandardItemModel *model);
+
/*! Force to ignore the addition of an \p identifier during the next update
* (identifier wouldn't be added to autocomleter item model)
* @param identifier String that contains identifier
@@ -67,14 +71,19 @@ class SCsCodeAnalyzer : public QObject
static bool isIdentifier(const QString &text);
protected:
- void fillModel(QStandardItemModel *model);
- void extractIdentifiers(const QString &text, QSet *identifiers);
+ void fillModel(QStandardItemModel *model, const QSet &idtfs);
+ void extractIdentifiers(const QString &text, QSet &identifiers);
+
+private slots:
+ void asynchUpdateExtractIdftFinished();
private:
const static QRegExp msIdentifierExp;
QSet mDocumentIdentifiers;
QSet mIgnoreIdentifiers;
-
+ QStandardItemModel* mUpdateModel;
+ SCsAsynchParser* mAsynchParser;
+ bool mIsBusy;
};
diff --git a/sources/plugins/scs/scscodeeditor.cpp b/sources/plugins/scs/scscodeeditor.cpp
index 0705c92..d6edad9 100644
--- a/sources/plugins/scs/scscodeeditor.cpp
+++ b/sources/plugins/scs/scscodeeditor.cpp
@@ -49,7 +49,7 @@ SCsCodeEditor::SCsCodeEditor(QWidget *parent, SCsErrorTableWidget *errorTable) :
mLineNumberArea = new SCsLineNumberArea(this);
mAnalyzer = new SCsCodeAnalyzer(this);
mCompleter = new SCsCodeCompleter(this);
- mErrorAnalyzer = new SCsCodeErrorAnalyzer(mErrorTable,this);
+ mErrorAnalyzer = new SCsCodeErrorAnalyzer(this, mErrorTable);
mCompleter->setWidget(this);
mCompleter->setCompletionMode(QCompleter::PopupCompletion);
@@ -65,11 +65,14 @@ SCsCodeEditor::SCsCodeEditor(QWidget *parent, SCsErrorTableWidget *errorTable) :
connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine()));
connect(this, SIGNAL(textChanged()), this, SLOT(updateAnalyzer()));
connect(mErrorAnalyzer,SIGNAL(errorLines(QSet)),this,SLOT(setErrorsLines(QSet)));
- if( mErrorTable != NULL )
+
+ if (mErrorTable != NULL)
connect(mErrorTable, SIGNAL(errorAt(int,int)), this, SLOT(moveTextCursor(int,int)));
updateLineNumberAreaWidth(0);
highlightCurrentLine();
+
+ setLineWrapMode(QPlainTextEdit::NoWrap);
}
void SCsCodeEditor::setDocumentPath(const QString &path)
@@ -118,22 +121,22 @@ void SCsCodeEditor::resizeEvent(QResizeEvent *e)
void SCsCodeEditor::highlightCurrentLine()
{
- QList extraSelections;
+ QList extraSelections;
- if (!isReadOnly())
- {
- QTextEdit::ExtraSelection selection;
+ if (!isReadOnly())
+ {
+ QTextEdit::ExtraSelection selection;
- QColor lineColor = QColor(Qt::yellow).lighter(160);
+ QColor lineColor = QColor(Qt::yellow).lighter(160);
- selection.format.setBackground(lineColor);
- selection.format.setProperty(QTextFormat::FullWidthSelection, true);
- selection.cursor = textCursor();
- selection.cursor.clearSelection();
- extraSelections.append(selection);
- }
+ selection.format.setBackground(lineColor);
+ selection.format.setProperty(QTextFormat::FullWidthSelection, true);
+ selection.cursor = textCursor();
+ selection.cursor.clearSelection();
+ extraSelections.append(selection);
+ }
- setExtraSelections(extraSelections);
+ setExtraSelections(extraSelections);
}
void SCsCodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event)
@@ -152,7 +155,7 @@ void SCsCodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event)
painter.setPen(Qt::black);
painter.drawText(0, top, mLineNumberArea->width(), fontMetrics().height(),
Qt::AlignRight, number);
- if(isLineWithError(blockNumber+1))
+ if (isLineWithError(blockNumber+1))
painter.drawPixmap(4,top+2,mErrorPixmap);
}
@@ -188,7 +191,7 @@ void SCsCodeEditor::keyPressEvent(QKeyEvent *e)
// return;
// }
- if(e->modifiers() == Qt::ControlModifier && e->key() == Qt::Key_R)
+ if (e->modifiers() == Qt::ControlModifier && e->key() == Qt::Key_R)
updateErrorAnalyzer();
if (mCompleter->popup()->isVisible())
@@ -272,29 +275,29 @@ void SCsCodeEditor::updateAnalyzer()
mLastCursorPosition = tc.position();
mAnalyzer->ignoreUpdate(currentWord);
- mAnalyzer->update(toPlainText(), completerModel);
+ mAnalyzer->asynchUpdate(toPlainText(), completerModel);
}
-
-bool SCsCodeEditor::isLineWithError(int line)
+void SCsCodeEditor::updateErrorAnalyzer()
{
- return mErrorLines.contains(line);
-}
-void SCsCodeEditor::setErrorsLines(QSet lines)
-{
- mErrorLines = lines;
-}
+ QString text = document()->toPlainText();
+ mErrorAnalyzer->parse(text);
+ //update();
+}
-void SCsCodeEditor::updateErrorAnalyzer()
-{
- QString text = document()->toPlainText();
- mErrorAnalyzer->parse(text);
+bool SCsCodeEditor::isLineWithError(int line)
+{
+ return mErrorLines.contains(line);
+}
+void SCsCodeEditor::setErrorsLines(const QSet &lines)
+{
+ mErrorLines = lines;
update();
}
@@ -302,20 +305,23 @@ void SCsCodeEditor::updateErrorAnalyzer()
void SCsCodeEditor::moveTextCursor(int line, int charPos)
{
- if(charPos<0)
+ if (charPos<0)
charPos = 0;
- QTextCursor cursor = textCursor();
+ if (line < 0)
+ line = 0;
+
+ QTextCursor cursor = textCursor();
cursor.movePosition(QTextCursor::Start);
cursor.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, line-1);
- if( cursor.movePosition(QTextCursor::EndOfLine, QTextCursor::MoveAnchor) )
+ if (cursor.movePosition(QTextCursor::EndOfLine, QTextCursor::MoveAnchor))
{
- if( cursor.columnNumber() < charPos)
+ if (cursor.columnNumber() < charPos)
charPos = 0;
}
cursor.movePosition(QTextCursor::StartOfLine, QTextCursor::MoveAnchor);
- cursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, charPos-1);
+ cursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, charPos+1);
setTextCursor(cursor);
setFocus(Qt::ShortcutFocusReason);
diff --git a/sources/plugins/scs/scscodeeditor.h b/sources/plugins/scs/scscodeeditor.h
index 3d04c56..ec26802 100644
--- a/sources/plugins/scs/scscodeeditor.h
+++ b/sources/plugins/scs/scscodeeditor.h
@@ -54,8 +54,10 @@ class SCsCodeEditor : public QPlainTextEdit
void updateErrorAnalyzer();
+public slots:
+ void setErrorsLines(const QSet &lines);
+
private slots:
- void setErrorsLines(QSet lines);
void updateLineNumberAreaWidth(int newBlockCount);
void highlightCurrentLine();
void updateLineNumberArea(const QRect &, int);
@@ -97,8 +99,6 @@ class SCsLineNumberArea : public QWidget
private:
SCsCodeEditor *mCodeEditor;
- int mStartSelectionBlockNumber;
- int mEndSelectionBlockNumber;
};
#endif // SCSCODEEDITOR_H
diff --git a/sources/plugins/scs/scscodeerroranalyzer.cpp b/sources/plugins/scs/scscodeerroranalyzer.cpp
index 662a7e6..0fcd4fa 100644
--- a/sources/plugins/scs/scscodeerroranalyzer.cpp
+++ b/sources/plugins/scs/scscodeerroranalyzer.cpp
@@ -1,47 +1,48 @@
#include "scscodeerroranalyzer.h"
-#include "scsparserwrapper.h"
+#include "scscodeeditor.h"
#include "scserrortablewidget.h"
-#include "scsparserexception.h"
+#include "scsasynchparser.h"
#include
-SCsCodeErrorAnalyzer::SCsCodeErrorAnalyzer(SCsErrorTableWidget *errorTable, QObject *parent /* = 0 */)
- : QObject(parent), mErrorTable(errorTable)
+SCsCodeErrorAnalyzer::SCsCodeErrorAnalyzer(SCsCodeEditor* editor, SCsErrorTableWidget *errorTable)
+ : QObject(editor)
+ , mEditor(editor)
+ , mErrorTable(errorTable)
+ , mAsynchParser(0)
{
+ Q_CHECK_PTR(mEditor);
+ mAsynchParser = new SCsAsynchParser(this);
+
+ connect(mAsynchParser,SIGNAL(parseExceptionsFinished()),SLOT(parseExceptionFinished()));
}
void SCsCodeErrorAnalyzer::parse(QString &text)
{
- SCsParser psr;
- QVector exeptions = psr.getExceptions(text);
- QSet lines;
- for(int i=0; idoWork() || text.isEmpty())
+ return;
- showError(exeptions);
+ mAsynchParser->parseExceptions(text);
}
-void SCsCodeErrorAnalyzer::showError(QVector &exceptions)
+void SCsCodeErrorAnalyzer::showError(const QVector &exceptions) const
{
- if(mErrorTable == NULL)
+ if (mErrorTable == NULL)
return;
mErrorTable->clear();
- QVector::iterator it=exceptions.begin();
- while( it != exceptions.end())
+ QVector::const_iterator it;
+ for (it = exceptions.begin(); it != exceptions.end(); ++it)
{
QString description = getErrorDescription(*it);
- mErrorTable->addError(description,it->line(),it->positionInLine());
- it++;
+ mErrorTable->addError(description, it->line(), it->positionInLine());
}
- if(!exceptions.isEmpty())
+ if (!exceptions.isEmpty())
mErrorTable->show();
else
mErrorTable->hide();
@@ -49,7 +50,7 @@ void SCsCodeErrorAnalyzer::showError(QVector &exceptions)
}
-QString SCsCodeErrorAnalyzer::getErrorDescription(SCsParserException &ex)
+QString SCsCodeErrorAnalyzer::getErrorDescription(const SCsParserException &ex) const
{
QString descr;
SCsParserException::ExceptionType type = ex.getExceptionType();
@@ -88,3 +89,26 @@ QString SCsCodeErrorAnalyzer::getErrorDescription(SCsParserException &ex)
return descr;
}
+
+
+void SCsCodeErrorAnalyzer::parseExceptionFinished()
+{
+ Q_ASSERT(mAsynchParser->isParseExceptionsResultPresent());
+
+ if (!mAsynchParser->isParseExceptionsResultPresent())
+ return;
+
+ QSharedPointer exceptions = mAsynchParser->parseExceptionsResult();
+
+ if (exceptions.isNull())
+ return;
+
+ QSet lines;
+ for (int i=0; isize(); ++i)
+ lines.insert(exceptions->at(i).line());
+
+ emit errorLines(lines);
+
+ showError(*exceptions);
+
+}
diff --git a/sources/plugins/scs/scscodeerroranalyzer.h b/sources/plugins/scs/scscodeerroranalyzer.h
index a0214ff..0d12908 100644
--- a/sources/plugins/scs/scscodeerroranalyzer.h
+++ b/sources/plugins/scs/scscodeerroranalyzer.h
@@ -1,28 +1,59 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of OSTIS (Open Semantic Technology for Intelligent Systems)
+For the latest info, see http://www.ostis.net
+
+Copyright (c) 2010 OSTIS
+
+OSTIS is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+OSTIS is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with OSTIS. If not, see .
+-----------------------------------------------------------------------------
+*/
+
#ifndef SCSCODEERRORANALYZER_H
#define SCSCODEERRORANALYZER_H
#include
-#include
+
+#include "scsparserexception.h"
class SCsErrorTableWidget;
class SCsParserException;
+class SCsCodeEditor;
+class SCsParseExceptionsAsynchTask;
+class SCsAsynchParser;
class SCsCodeErrorAnalyzer : public QObject
{
Q_OBJECT
public:
- explicit SCsCodeErrorAnalyzer(SCsErrorTableWidget *errorTable, QObject *parent = 0);
+ explicit SCsCodeErrorAnalyzer(SCsCodeEditor* editor, SCsErrorTableWidget *errorTable);
void parse(QString &text);
private:
- void showError(QVector &exceptions);
- QString getErrorDescription(SCsParserException &ex);
+ void showError(const QVector &exceptions) const;
+ QString getErrorDescription(const SCsParserException &ex) const;
+
+ SCsAsynchParser* mAsynchParser;
+
+ SCsErrorTableWidget* mErrorTable;
+ SCsCodeEditor* mEditor;
- SCsErrorTableWidget *mErrorTable;
signals:
void errorLines(QSet lines);
-public slots:
-
+
+private slots:
+ void parseExceptionFinished();
};
#endif // SCSCODEERRORANALYZER_H
diff --git a/sources/plugins/scs/scserrortablewidget.h b/sources/plugins/scs/scserrortablewidget.h
index 477fde0..dcc0853 100644
--- a/sources/plugins/scs/scserrortablewidget.h
+++ b/sources/plugins/scs/scserrortablewidget.h
@@ -1,3 +1,25 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of OSTIS (Open Semantic Technology for Intelligent Systems)
+For the latest info, see http://www.ostis.net
+
+Copyright (c) 2010 OSTIS
+
+OSTIS is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+OSTIS is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with OSTIS. If not, see .
+-----------------------------------------------------------------------------
+*/
+
#ifndef SCSERRORTABLEWIDGET_H
#define SCSERRORTABLEWIDGET_H
diff --git a/sources/plugins/scs/scserrortablewidgetitem.h b/sources/plugins/scs/scserrortablewidgetitem.h
index cd2d964..91e00df 100644
--- a/sources/plugins/scs/scserrortablewidgetitem.h
+++ b/sources/plugins/scs/scserrortablewidgetitem.h
@@ -1,3 +1,25 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of OSTIS (Open Semantic Technology for Intelligent Systems)
+For the latest info, see http://www.ostis.net
+
+Copyright (c) 2010 OSTIS
+
+OSTIS is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+OSTIS is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with OSTIS. If not, see .
+-----------------------------------------------------------------------------
+*/
+
#ifndef SCSERRORTABLEWIDGETITEM_H
#define SCSERRORTABLEWIDGETITEM_H
diff --git a/sources/plugins/scs/scsfindwidget.cpp b/sources/plugins/scs/scsfindwidget.cpp
index 8400c4a..04a29b6 100644
--- a/sources/plugins/scs/scsfindwidget.cpp
+++ b/sources/plugins/scs/scsfindwidget.cpp
@@ -68,7 +68,8 @@ SCsFindWidget::~SCsFindWidget()
}
-QTextDocument::FindFlags SCsFindWidget::getFlags(){
+QTextDocument::FindFlags SCsFindWidget::getFlags() const
+{
QTextDocument::FindFlags searchFlags;
if (mCaseSensitiveCheck->isChecked())
diff --git a/sources/plugins/scs/scsfindwidget.h b/sources/plugins/scs/scsfindwidget.h
index b0270f7..329899e 100644
--- a/sources/plugins/scs/scsfindwidget.h
+++ b/sources/plugins/scs/scsfindwidget.h
@@ -1,3 +1,25 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of OSTIS (Open Semantic Technology for Intelligent Systems)
+For the latest info, see http://www.ostis.net
+
+Copyright (c) 2010 OSTIS
+
+OSTIS is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+OSTIS is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with OSTIS. If not, see .
+-----------------------------------------------------------------------------
+*/
+
#ifndef SCSCODEEDITORFINDWIDGET_H
#define SCSCODEEDITORFINDWIDGET_H
@@ -21,7 +43,7 @@ class SCsFindWidget : public QWidget
bool wholeWord() const;
void setPalette(bool found);
- QTextDocument::FindFlags getFlags();
+ QTextDocument::FindFlags getFlags() const;
void find();
diff --git a/sources/plugins/scs/scsparser/SCsCLexer.h b/sources/plugins/scs/scsparser/SCsCLexer.h
index 969c860..0929e45 100644
--- a/sources/plugins/scs/scsparser/SCsCLexer.h
+++ b/sources/plugins/scs/scsparser/SCsCLexer.h
@@ -1,11 +1,6 @@
/** \file
* This C header file was generated by $ANTLR version 3.4
*
- * - From the grammar source file : D:\\Programming\\PROJECTS\\Eclipse\\workspace\\ScsGrammar\\src\\SCsC.g
- * - On : 2013-04-20 09:11:20
- * - for the lexer : SCsCLexerLexer
- *
- * Editing it, at least manually, is not wise.
*
* C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.
*
diff --git a/sources/plugins/scs/scsparser/SCsCParser.h b/sources/plugins/scs/scsparser/SCsCParser.h
index bbc6a8b..c5397ec 100644
--- a/sources/plugins/scs/scsparser/SCsCParser.h
+++ b/sources/plugins/scs/scsparser/SCsCParser.h
@@ -1,11 +1,6 @@
/** \file
* This C header file was generated by $ANTLR version 3.4
*
- * - From the grammar source file : D:\\Programming\\PROJECTS\\Eclipse\\workspace\\ScsGrammar\\src\\SCsC.g
- * - On : 2013-04-20 09:11:20
- * - for the parser : SCsCParserParser
- *
- * Editing it, at least manually, is not wise.
*
* C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.
*
diff --git a/sources/plugins/scs/scsparser/scsasynchparser.cpp b/sources/plugins/scs/scsparser/scsasynchparser.cpp
new file mode 100644
index 0000000..1cbd1ac
--- /dev/null
+++ b/sources/plugins/scs/scsparser/scsasynchparser.cpp
@@ -0,0 +1,296 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of OSTIS (Open Semantic Technology for Intelligent Systems)
+For the latest info, see http://www.ostis.net
+
+Copyright (c) 2010 OSTIS
+
+OSTIS is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+OSTIS is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with OSTIS. If not, see .
+-----------------------------------------------------------------------------
+*/
+
+#include "scsasynchparser.h"
+#include "scsparserwrapper.h"
+
+#include
+
+QSharedPointer parseExceptionsFn(const QString &text)
+{
+ SCsParser psr;
+ QSharedPointer array = psr.getExceptions(text);
+ return array;
+}
+
+QSharedPointer parseIdentifiersFn(const QString &text)
+{
+ SCsParser psr;
+ QSharedPointer array = psr.getIdentifier(text);
+ return array;
+}
+
+QSharedPointer parseTokensFn(const QString &text)
+{
+ SCsParser psr;
+ QSharedPointer array = psr.getTokens(text);
+ return array;
+}
+
+QSharedPointer parseErrorLinesFn(const QString &text)
+{
+ SCsParser psr;
+ QSharedPointer array = psr.getErrorLines(text);
+ return array;
+}
+
+//////////////////////////////////////////////////////////////////////////
+
+SCsAsynchParser::SCsAsynchParser(QObject *parent)
+ : QObject(parent)
+ , mIsProcessed(false)
+ , mCurrentOperation(NONE)
+{
+ connect(&mExceptionWatcher,SIGNAL(finished()),this,SLOT(processParseExceptionsFinished()));
+ connect(&mIdentifiersWatcher,SIGNAL(finished()),this,SLOT(processParseIdentifiersFinished()));
+}
+
+SCsAsynchParser::~SCsAsynchParser()
+{
+
+}
+
+bool SCsAsynchParser::parseExceptions(const QString &data)
+{
+ if (mIsProcessed)
+ return false;
+
+ mCurrentOperation = PARSE_EXCEPTIONS;
+
+ mIsProcessed = true;
+
+ mData = data;
+
+ mExceptionWatcher.setFuture(QtConcurrent::run(parseExceptionsFn, mData));
+
+ return true;
+}
+
+bool SCsAsynchParser::isParseExceptionsResultPresent() const
+{
+ return (mCurrentOperation == PARSE_EXCEPTIONS && mExceptionWatcher.isFinished());
+}
+
+void SCsAsynchParser::processParseExceptionsFinished()
+{
+ emit parseExceptionsFinished();
+}
+
+QSharedPointer SCsAsynchParser::parseExceptionsResult()
+{
+ Q_ASSERT(isParseExceptionsResultPresent());
+
+ if (!isParseExceptionsResultPresent())
+ {
+ return QSharedPointer();
+ }
+
+ mIsProcessed = false;
+ mCurrentOperation = NONE;
+ return mExceptionWatcher.result();
+}
+
+
+bool SCsAsynchParser::parseIdentifiers(const QString &data)
+{
+ if (mIsProcessed)
+ return false;
+
+ mCurrentOperation = PARSE_IDENTIFIERS;
+
+ mIsProcessed = true;
+
+ mData = data;
+
+ mIdentifiersWatcher.setFuture(QtConcurrent::run(parseIdentifiersFn, mData));
+
+ return true;
+}
+
+bool SCsAsynchParser::isParseIdentifiersResultPresent() const
+{
+ return (mCurrentOperation == PARSE_IDENTIFIERS && mIdentifiersWatcher.isFinished());
+}
+
+void SCsAsynchParser::processParseIdentifiersFinished()
+{
+ emit parseIdentifiersFinished();
+}
+
+QSharedPointer SCsAsynchParser::parseIdentifiersResult()
+{
+ Q_ASSERT(isParseIdentifiersResultPresent());
+
+ if (!isParseIdentifiersResultPresent())
+ {
+ return QSharedPointer();
+ }
+
+ mIsProcessed = false;
+ mCurrentOperation = NONE;
+ return mIdentifiersWatcher.result();
+}
+
+
+bool SCsAsynchParser::parseTokens(const QString &data)
+{
+ if (mIsProcessed)
+ return false;
+
+ mCurrentOperation = PARSE_TOKENS;
+
+ mIsProcessed = true;
+
+ mData = data;
+
+ mTokensWatcher.setFuture(QtConcurrent::run(parseTokensFn, mData));
+
+ return true;
+}
+
+bool SCsAsynchParser::isParseTokensResultPresent() const
+{
+ return (mCurrentOperation == PARSE_TOKENS && mTokensWatcher.isFinished());
+}
+
+void SCsAsynchParser::processParseTokensFinished()
+{
+ emit parseTokensFinished();
+}
+
+QSharedPointer SCsAsynchParser::parseTokensResult()
+{
+ Q_ASSERT(isParseTokensResultPresent());
+
+ if (!isParseTokensResultPresent())
+ {
+ return QSharedPointer();
+ }
+
+ mIsProcessed = false;
+ mCurrentOperation = NONE;
+ return mTokensWatcher.result();
+}
+
+
+bool SCsAsynchParser::parseErrorLines(const QString &data)
+{
+ if (mIsProcessed)
+ return false;
+
+ mCurrentOperation = PARSE_ERROR_LINES;
+
+ mIsProcessed = true;
+
+ mData = data;
+
+ mErrorLinesWatcher.setFuture(QtConcurrent::run(parseErrorLinesFn, mData));
+
+ return true;
+}
+
+bool SCsAsynchParser::isParseErrorLinesResultPresent() const
+{
+ return (mCurrentOperation == PARSE_ERROR_LINES && mErrorLinesWatcher.isFinished());
+}
+
+void SCsAsynchParser::processParseErrorLinesFinished()
+{
+ emit parseErrorLinesFinished();
+}
+
+QSharedPointer SCsAsynchParser::parseErrorLinesResult()
+{
+ Q_ASSERT(isParseErrorLinesResultPresent());
+
+ if (!isParseErrorLinesResultPresent())
+ {
+ return QSharedPointer();
+ }
+
+ mIsProcessed = false;
+ mCurrentOperation = NONE;
+ return mErrorLinesWatcher.result();
+}
+
+//////////////////////////////////////////////////////////////////////////
+
+
+SCsParseExceptionsAsynchTask::SCsParseExceptionsAsynchTask(const QString &text, QObject *parent)
+ : QObject(parent)
+ , mText(text)
+{
+ connect(&mWatcher,SIGNAL(finished()),this,SIGNAL(taskFinished()));
+}
+
+SCsParseExceptionsAsynchTask::~SCsParseExceptionsAsynchTask()
+{
+
+}
+
+void SCsParseExceptionsAsynchTask::execute()
+{
+ if (!isRunning())
+ mWatcher.setFuture(QtConcurrent::run(parseExceptionsFn,mText));
+}
+
+QSharedPointer SCsParseExceptionsAsynchTask::result()
+{
+ return QSharedPointer(mWatcher.result());
+}
+
+
+void SCsParseExceptionsAsynchTask::finished()
+{
+ emit taskFinished();
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+
+SCsParseExtractIdftAsynchTask::SCsParseExtractIdftAsynchTask(const QString &text, QObject *parent)
+ : QObject(parent)
+ , mText(text)
+{
+ connect(&mWatcher,SIGNAL(finished()),this,SIGNAL(taskFinished()));
+}
+
+SCsParseExtractIdftAsynchTask::~SCsParseExtractIdftAsynchTask()
+{
+}
+
+void SCsParseExtractIdftAsynchTask::execute()
+{
+ if (!isRunning())
+ mWatcher.setFuture(QtConcurrent::run(parseIdentifiersFn,mText));
+}
+
+QSharedPointer SCsParseExtractIdftAsynchTask::result()
+{
+ return QSharedPointer(mWatcher.result());
+}
+
+
+void SCsParseExtractIdftAsynchTask::finished()
+{
+ emit taskFinished();
+}
diff --git a/sources/plugins/scs/scsparser/scsasynchparser.h b/sources/plugins/scs/scsparser/scsasynchparser.h
new file mode 100644
index 0000000..211d963
--- /dev/null
+++ b/sources/plugins/scs/scsparser/scsasynchparser.h
@@ -0,0 +1,149 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of OSTIS (Open Semantic Technology for Intelligent Systems)
+For the latest info, see http://www.ostis.net
+
+Copyright (c) 2010 OSTIS
+
+OSTIS is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+OSTIS is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with OSTIS. If not, see .
+-----------------------------------------------------------------------------
+*/
+
+#ifndef SCSASYNCHPARSER_H
+#define SCSASYNCHPARSER_H
+
+#include "scsparserexception.h"
+
+#include
+#include
+#include
+
+class SCsAsynchParser: public QObject
+{
+ Q_OBJECT
+
+ typedef enum{
+ NONE = 0
+ , PARSE_EXCEPTIONS
+ , PARSE_ERROR_LINES
+ , PARSE_IDENTIFIERS
+ , PARSE_TOKENS
+ } ParserOperation;
+
+public:
+ SCsAsynchParser(QObject *parent = 0);
+ virtual ~SCsAsynchParser();
+
+ bool parseExceptions(const QString &data);
+ bool parseErrorLines(const QString &data);
+ bool parseIdentifiers(const QString &data);
+ bool parseTokens(const QString &data);
+
+ QSharedPointer parseExceptionsResult();
+ QSharedPointer parseErrorLinesResult();
+ QSharedPointer parseIdentifiersResult();
+ QSharedPointer parseTokensResult();
+
+ bool isParseExceptionsResultPresent() const;
+ bool isParseErrorLinesResultPresent() const;
+ bool isParseIdentifiersResultPresent() const;
+ bool isParseTokensResultPresent() const;
+
+ bool doWork() const { return mIsProcessed; }
+
+signals:
+ void parseExceptionsFinished();
+ void parseErrorLinesFinished();
+ void parseIdentifiersFinished();
+ void parseTokensFinished();
+
+private slots:
+ void processParseExceptionsFinished();
+ void processParseErrorLinesFinished();
+ void processParseIdentifiersFinished();
+ void processParseTokensFinished();
+
+protected:
+ bool mIsProcessed;
+ QString mData;
+ ParserOperation mCurrentOperation;
+
+ QFutureWatcher< QSharedPointer > mExceptionWatcher;
+ QFutureWatcher< QSharedPointer > mErrorLinesWatcher;
+ QFutureWatcher< QSharedPointer > mIdentifiersWatcher;
+ QFutureWatcher< QSharedPointer > mTokensWatcher;
+
+private:
+ Q_DISABLE_COPY(SCsAsynchParser)
+};
+
+
+class SCsParseExceptionsAsynchTask: public QObject
+{
+ Q_OBJECT
+
+public:
+
+ SCsParseExceptionsAsynchTask(const QString &text, QObject *parent = 0);
+ virtual ~SCsParseExceptionsAsynchTask();
+
+ void execute();
+ QSharedPointer result();
+ bool isRunning() const { return mWatcher.isRunning(); }
+ bool isStarted() const { return mWatcher.isStarted(); }
+ bool isFinished() const { return mWatcher.isFinished(); }
+
+signals:
+ void taskFinished();
+
+private slots:
+ void finished();
+
+private:
+ Q_DISABLE_COPY(SCsParseExceptionsAsynchTask)
+
+ QFutureWatcher< QSharedPointer > mWatcher;
+ QString mText;
+};
+
+
+class SCsParseExtractIdftAsynchTask: public QObject
+{
+ Q_OBJECT
+
+public:
+
+ SCsParseExtractIdftAsynchTask(const QString &text, QObject *parent = 0);
+ virtual ~SCsParseExtractIdftAsynchTask();
+
+ void execute();
+ QSharedPointer result();
+ bool isRunning() const { return mWatcher.isRunning(); }
+ bool isStarted() const { return mWatcher.isStarted(); }
+ bool isFinished() const { return mWatcher.isFinished(); }
+
+signals:
+ void taskFinished();
+
+ private slots:
+ void finished();
+
+private:
+ Q_DISABLE_COPY(SCsParseExtractIdftAsynchTask)
+
+ QFutureWatcher< QSharedPointer > mWatcher;
+ QString mText;
+};
+
+#endif // SCSASYNCHPARSER_H
diff --git a/sources/plugins/scs/scsparser/scscparserdefs.c b/sources/plugins/scs/scsparser/scscparserdefs.c
index 59e4539..6e49178 100644
--- a/sources/plugins/scs/scsparser/scscparserdefs.c
+++ b/sources/plugins/scs/scsparser/scscparserdefs.c
@@ -1,3 +1,24 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of OSTIS (Open Semantic Technology for Intelligent Systems)
+For the latest info, see http://www.ostis.net
+
+Copyright (c) 2010 OSTIS
+
+OSTIS is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+OSTIS is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with OSTIS. If not, see .
+-----------------------------------------------------------------------------
+*/
#include "scscparserdefs.h"
diff --git a/sources/plugins/scs/scsparser/scscparserdefs.h b/sources/plugins/scs/scsparser/scscparserdefs.h
index f232374..8a45e10 100644
--- a/sources/plugins/scs/scsparser/scscparserdefs.h
+++ b/sources/plugins/scs/scsparser/scscparserdefs.h
@@ -1,3 +1,25 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of OSTIS (Open Semantic Technology for Intelligent Systems)
+For the latest info, see http://www.ostis.net
+
+Copyright (c) 2010 OSTIS
+
+OSTIS is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+OSTIS is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with OSTIS. If not, see .
+-----------------------------------------------------------------------------
+*/
+
#ifndef _SCSPARSERDEFS_H
#define _SCSPARSERDEFS_H
diff --git a/sources/plugins/scs/scsparser/scsparserexception.cpp b/sources/plugins/scs/scsparser/scsparserexception.cpp
index d04431c..5f6f98c 100644
--- a/sources/plugins/scs/scsparser/scsparserexception.cpp
+++ b/sources/plugins/scs/scsparser/scsparserexception.cpp
@@ -1,3 +1,25 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of OSTIS (Open Semantic Technology for Intelligent Systems)
+For the latest info, see http://www.ostis.net
+
+Copyright (c) 2010 OSTIS
+
+OSTIS is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+OSTIS is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with OSTIS. If not, see .
+-----------------------------------------------------------------------------
+*/
+
#include "scsparserexception.h"
SCsParserException::SCsParserException():
diff --git a/sources/plugins/scs/scsparser/scsparserexception.h b/sources/plugins/scs/scsparser/scsparserexception.h
index 1a283dc..09b317a 100644
--- a/sources/plugins/scs/scsparser/scsparserexception.h
+++ b/sources/plugins/scs/scsparser/scsparserexception.h
@@ -1,8 +1,32 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of OSTIS (Open Semantic Technology for Intelligent Systems)
+For the latest info, see http://www.ostis.net
+
+Copyright (c) 2010 OSTIS
+
+OSTIS is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+OSTIS is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with OSTIS. If not, see .
+-----------------------------------------------------------------------------
+*/
+
#ifndef SCSPARSEREXCEPTION_H
#define SCSPARSEREXCEPTION_H
#include
+#include
+#include
class SCsParserException
{
@@ -23,10 +47,10 @@ class SCsParserException
virtual ~SCsParserException();
- ExceptionPlace type(){ return mExceptionPlace; }
- int line() { return mLine; }
- int positionInLine() { return mPositionInLine; }
- ExceptionType getExceptionType() { return mExceptionType; }
+ ExceptionPlace type() const { return mExceptionPlace; }
+ int line() const { return mLine; }
+ int positionInLine() const { return mPositionInLine; }
+ ExceptionType getExceptionType() const { return mExceptionType; }
private:
ExceptionPlace mExceptionPlace;
@@ -36,11 +60,6 @@ class SCsParserException
};
-
-
-
-
-
class SCsParserToken
{
public:
@@ -68,6 +87,9 @@ class SCsParserToken
int mTokenType;
};
-
+typedef QVector SCsParserExceptionArray;
+typedef QVector SCsParserTokenArray;
+typedef QSet SCsParserErrorLinesArray;
+typedef QSet SCsParserIdtfArray;
#endif // SCSPARSEREXCEPTION_H
diff --git a/sources/plugins/scs/scsparser/scsparserwrapper.cpp b/sources/plugins/scs/scsparser/scsparserwrapper.cpp
index de999d3..2b72d5b 100644
--- a/sources/plugins/scs/scsparser/scsparserwrapper.cpp
+++ b/sources/plugins/scs/scsparser/scsparserwrapper.cpp
@@ -1,4 +1,24 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of OSTIS (Open Semantic Technology for Intelligent Systems)
+For the latest info, see http://www.ostis.net
+Copyright (c) 2010 OSTIS
+
+OSTIS is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+OSTIS is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with OSTIS. If not, see .
+-----------------------------------------------------------------------------
+*/
#include "SCsCLexer.h"
#include "SCsCParser.h"
@@ -18,9 +38,15 @@ SCsParser::SCsParser(QObject *parent) :
}
-pANTLR3_INPUT_STREAM SCsParser::createInputStream(const std::string &text)
+SCsParser::~SCsParser()
+{
+
+}
+
+
+pANTLR3_INPUT_STREAM SCsParser::createInputStream(const std::string &text) const
{
- pANTLR3_INPUT_STREAM input;
+ pANTLR3_INPUT_STREAM input = 0;
#if defined( __WIN32__ ) || defined( _WIN32 )
input = antlr3StringStreamNew((pANTLR3_UINT8)text.c_str(),ANTLR3_ENC_UTF8,text.length(),(pANTLR3_UINT8)"scs");
@@ -33,10 +59,10 @@ pANTLR3_INPUT_STREAM SCsParser::createInputStream(const std::string &text)
}
-QSet SCsParser::getErrorLines(const QString &text)
+QSharedPointer SCsParser::getErrorLines(const QString &text) const
{
- QSet errorLines;
+ QSharedPointer errorLines = QSharedPointer(new SCsParserErrorLinesArray());
pANTLR3_INPUT_STREAM input;
pSCsCLexer lxr;
@@ -47,13 +73,13 @@ QSet SCsParser::getErrorLines(const QString &text)
std::string strData = text.toStdString();
input = createInputStream(strData);
- if(input == NULL)
+ if (input == NULL)
{
return errorLines;
}
lxr = SCsCLexerNew(input);
- if( lxr == NULL )
+ if (lxr == NULL)
{
input->free(input);
return errorLines;
@@ -61,7 +87,7 @@ QSet SCsParser::getErrorLines(const QString &text)
tstream = antlr3CommonTokenStreamSourceNew(ANTLR3_SIZE_HINT, TOKENSOURCE(lxr));
- if( tstream == NULL )
+ if (tstream == NULL)
{
lxr->free(lxr);
input->free(input);
@@ -70,7 +96,7 @@ QSet SCsParser::getErrorLines(const QString &text)
psr = SCsCParserNew(tstream);
- if( psr == NULL )
+ if (psr == NULL)
{
tstream->free(tstream);
lxr->free(lxr);
@@ -83,15 +109,15 @@ QSet SCsParser::getErrorLines(const QString &text)
_ParserException *psrEx = ParserHeadException();
_LexerException *lxrEx = LexerHeadException();
- while(psrEx)
+ while (psrEx)
{
- errorLines.insert(psrEx->mLine);
+ errorLines->insert(psrEx->mLine);
psrEx = psrEx->pNextException;
}
- while(lxrEx)
+ while (lxrEx)
{
- errorLines.insert(lxrEx->mLine);
+ errorLines->insert(lxrEx->mLine);
lxrEx = lxrEx->pNextException;
}
@@ -108,10 +134,10 @@ QSet SCsParser::getErrorLines(const QString &text)
-QVector SCsParser::getExceptions(const QString &text)
+QSharedPointer SCsParser::getExceptions(const QString &text) const
{
- QVector exceptions;
+ QSharedPointer exceptions = QSharedPointer(new SCsParserExceptionArray());
pANTLR3_INPUT_STREAM input;
pSCsCLexer lxr;
@@ -121,32 +147,34 @@ QVector SCsParser::getExceptions(const QString &text)
std::string strData = text.toStdString();
input = createInputStream(strData);
- if( input == NULL )
+ if (input == NULL)
{
- input->free(input);
return exceptions;
}
lxr = SCsCLexerNew(input);
- if( lxr == NULL )
+ if (lxr == NULL)
{
- lxr->free(lxr);
+ input->free(input);
return exceptions;
}
tstream = antlr3CommonTokenStreamSourceNew(ANTLR3_SIZE_HINT, TOKENSOURCE(lxr));
- if( tstream == NULL )
+ if (tstream == NULL)
{
- tstream->free(tstream);
+ input->free(input);
+ lxr->free(lxr);
return exceptions;
}
psr = SCsCParserNew(tstream);
- if( psr == NULL )
+ if (psr == NULL)
{
- psr->free(psr);
+ input->free(input);
+ lxr->free(lxr);
+ tstream->free(tstream);
return exceptions;
}
@@ -155,15 +183,15 @@ QVector SCsParser::getExceptions(const QString &text)
_ParserException *psrEx = ParserHeadException();
_LexerException *lxrEx = LexerHeadException();
- while(psrEx)
+ while (psrEx)
{
- exceptions.push_back(SCsParserException(SCsParserException::PARSER, psrEx->mLine, psrEx->mCharPositionInLine, psrEx->mType));
+ exceptions->push_back(SCsParserException(SCsParserException::PARSER, psrEx->mLine, psrEx->mCharPositionInLine, psrEx->mType));
psrEx = psrEx->pNextException;
}
- while(lxrEx)
+ while (lxrEx)
{
- exceptions.push_back(SCsParserException(SCsParserException::LEXER, lxrEx->mLine, lxrEx->mCharPositionInLine, lxrEx->mType));
+ exceptions->push_back(SCsParserException(SCsParserException::LEXER, lxrEx->mLine, lxrEx->mCharPositionInLine, lxrEx->mType));
lxrEx = lxrEx->pNextException;
}
@@ -179,18 +207,10 @@ QVector SCsParser::getExceptions(const QString &text)
}
-
-SCsParser::~SCsParser()
-{
-
-}
-
-
-
-QVector SCsParser::getTokens(const QString &text)
+QSharedPointer SCsParser::getTokens(const QString &text) const
{
- QVector token;
+ QSharedPointer token = QSharedPointer(new SCsParserTokenArray());
pANTLR3_INPUT_STREAM input;
pSCsCLexer lxr;
pANTLR3_COMMON_TOKEN_STREAM tstream;
@@ -198,24 +218,24 @@ QVector SCsParser::getTokens(const QString &text)
std::string strData = text.toStdString();
input = createInputStream(strData);
- if( input == NULL )
+ if (input == NULL)
{
- input->free(input);
return token;
}
lxr = SCsCLexerNew(input);
- if( lxr == NULL )
+ if (lxr == NULL)
{
- lxr->free(lxr);
+ input->free(input);
return token;
}
tstream = antlr3CommonTokenStreamSourceNew(ANTLR3_SIZE_HINT, TOKENSOURCE(lxr));
- if( tstream == NULL )
+ if (tstream == NULL)
{
- tstream->free(tstream);
+ input->free(input);
+ lxr->free(lxr);
return token;
}
@@ -228,13 +248,12 @@ QVector SCsParser::getTokens(const QString &text)
{
tok = (pANTLR3_COMMON_TOKEN) tokens->elements[i].element;
tokText = tok->getText(tok);
- token.append(SCsParserToken(tok->getType(tok), QString((char*)tokText->chars), tok->getLine(tok), tok->getCharPositionInLine(tok)));
+ token->append(SCsParserToken(tok->getType(tok), QString((char*)tokText->chars), tok->getLine(tok), tok->getCharPositionInLine(tok)));
}
-
-
freeLexerExceptionList();
freeParserExceptionList();
+
tstream->free(tstream);
lxr->free(lxr);
input->free(input);
@@ -243,20 +262,20 @@ QVector SCsParser::getTokens(const QString &text)
}
-QSet SCsParser::getIdentifier(const QString &text)
+QSharedPointer SCsParser::getIdentifier(const QString &text) const
{
- QSet idtf;
+ QSharedPointer idtf = QSharedPointer(new SCsParserIdtfArray());
+
+ QSharedPointer token = getTokens(text);
+ QVector::iterator it;
- QVector token = getTokens(text);
- QVector::iterator it = token.begin();
- while (it!=token.end())
+ for (it = token->begin(); it != token->end(); ++it)
{
- if(it->tokenType() == NAME)
- {
- idtf.insert(it->tokenText());
- }
- ++it;
+ if (it->tokenType() == NAME)
+ idtf->insert(it->tokenText());
}
+ token->clear();
+
return idtf;
}
diff --git a/sources/plugins/scs/scsparser/scsparserwrapper.h b/sources/plugins/scs/scsparser/scsparserwrapper.h
index f20ada6..313e6b4 100644
--- a/sources/plugins/scs/scsparser/scsparserwrapper.h
+++ b/sources/plugins/scs/scsparser/scsparserwrapper.h
@@ -1,31 +1,51 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of OSTIS (Open Semantic Technology for Intelligent Systems)
+For the latest info, see http://www.ostis.net
+
+Copyright (c) 2010 OSTIS
+
+OSTIS is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+OSTIS is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with OSTIS. If not, see .
+-----------------------------------------------------------------------------
+*/
+
#ifndef SCSPARSERWRAPPER_H
#define SCSPARSERWRAPPER_H
#include
#include
#include
+#include
#include "scsparserexception.h"
#include
-
-
class SCsParser : public QObject
{
Q_OBJECT
public:
explicit SCsParser(QObject *parent = 0);
~SCsParser();
- QSet getErrorLines(const QString &text);
- QVector getTokens(const QString &text);
- QSet getIdentifier(const QString &text);
- QVector getExceptions(const QString &text);
+ QSharedPointer getErrorLines(const QString &text) const;
+ QSharedPointer getTokens(const QString &text) const;
+ QSharedPointer getIdentifier(const QString &text) const;
+ QSharedPointer getExceptions(const QString &text) const;
protected:
- //pANTLR3_INPUT_STREAM createInputStream(const QString &text);
- pANTLR3_INPUT_STREAM createInputStream(const std::string &text);
+ pANTLR3_INPUT_STREAM createInputStream(const std::string &text) const;
private:
diff --git a/sources/plugins/scs/scswindow.cpp b/sources/plugins/scs/scswindow.cpp
index 50add07..fa69ee2 100644
--- a/sources/plugins/scs/scswindow.cpp
+++ b/sources/plugins/scs/scswindow.cpp
@@ -52,7 +52,7 @@ SCsWindow::SCsWindow(const QString& _windowTitle, QWidget *parent):
mErrorTable = new SCsErrorTableWidget(this);
- mEditor = new SCsCodeEditor(this,mErrorTable);
+ mEditor = new SCsCodeEditor(this, mErrorTable);
QFont font("Arial", 11);
font.setStyleHint(QFont::Serif);
mEditor->setFont(font);
@@ -232,6 +232,12 @@ void SCsWindow::onEscapePressed()
}
+void SCsWindow::activate(QMainWindow *window)
+{
+ EditorInterface::activate(window);
+ mEditor->setFocus();
+}
+
// ---------------------
SCsWindowFactory::SCsWindowFactory(QObject *parent) :
QObject(parent)
diff --git a/sources/plugins/scs/scswindow.h b/sources/plugins/scs/scswindow.h
index 402d39e..8829bd4 100644
--- a/sources/plugins/scs/scswindow.h
+++ b/sources/plugins/scs/scswindow.h
@@ -71,6 +71,8 @@ class SCsWindow : public QWidget,
*/
void _update();
+ void activate(QMainWindow *window);
+
/*! Get icon specified for window type
*/
QIcon icon() const;