Commit 8f7804d6 authored by Alexander A. Maly's avatar Alexander A. Maly

Moved struct Data out of SourceFileInterface.

parent ddc5a5fe
Pipeline #2431 passed with stages
in 4 minutes
......@@ -56,33 +56,47 @@ struct ApiHelpItem {
class HelperInterface
{
public:
virtual QList<Suggestion> suggestAutoComplete(int lineNo, const QString &before, const QString &after) const = 0;
virtual QList<Suggestion> suggestAutoComplete(
int lineNo,
const QString &before,
const QString &after
) const = 0;
virtual TextAppend closingBracketSuggestion(int lineNo) const = 0;
virtual QStringList importModuleSuggestion(int lineNo) const = 0;
virtual ApiHelpItem itemUnderCursor(const QString &text, int lineNo, int colNo, bool includeRightBound) const = 0;
virtual ApiHelpItem itemUnderCursor(
const QString &text,
int lineNo, int colNo,
bool includeRightBound
) const = 0;
virtual QStringList imports() const = 0;
virtual QString createImportStatementLine(const QString &importName) const = 0;
virtual QString createImportStatementLine(
const QString &importName
) const = 0;
virtual QString suggestFileName() const = 0;
virtual QRegExp lineCommentStartLexemPattern() const = 0;
virtual void connectSignalImportsChanged(
QObject *receiver,
const char *slot /* void (QStringList localizedNames) */
)
{
) {
Q_UNUSED(receiver);
Q_UNUSED(slot);
}
/** Corrects lexem capitalization for case-insensetive grammatics (optional)
*/
virtual QString correctCapitalization(const QString &name, LexemType lxType) const
{
virtual QString correctCapitalization(
const QString &name,
LexemType lxType
) const {
return name;
}
virtual bool isKnownLexem(const QString &lexem, int lineNo, int colNo, const QString &context) const
{
virtual bool isKnownLexem(
const QString &lexem,
int lineNo, int colNo,
const QString &context
) const {
return false;
}
};
......
......@@ -12,32 +12,34 @@ namespace Shared
namespace Analizer
{
struct SFData {
QString visibleText;
QSet<int> protectedLineNumbers;
QString hiddenText;
bool hasHiddenText;
QString sourceEncoding;
QByteArray hiddenTextSignature;
QString canonicalSourceLanguageName; // the same as file suffix after '.'
QUrl sourceUrl;
};
class SourceFileInterface
{
public /*types*/:
struct Data {
QString visibleText;
QSet<int> protectedLineNumbers;
QString hiddenText;
bool hasHiddenText;
QString sourceEncoding;
QByteArray hiddenTextSignature;
QString canonicalSourceLanguageName; // the same as file suffix after '.'
QUrl sourceUrl;
};
public:
typedef Shared::Analizer::SFData Data;
public /*methods*/:
// Abstract methods to read and write from/to string in language-specific way
virtual QString toString(const Data &data) const = 0;
virtual Data fromString(const QString &string) const = 0;
virtual QString toString(const SFData &data) const = 0;
virtual SFData fromString(const QString &string) const = 0;
// Generic methods to read and write from/to raw byte array. Default implementation
// assumes UTF-8 encoding with BOM mark, but it is possible to override
virtual QByteArray toBytes(
const Data &data,
const SFData &data,
const QString &forceEncoding = ""
) const {
QByteArray buffer;
......@@ -53,7 +55,7 @@ public /*methods*/:
return buffer;
}
virtual Data fromBytes(
virtual SFData fromBytes(
const QByteArray &bytes,
const QString &forceEncoding = ""
) const {
......
......@@ -51,7 +51,7 @@ public:
) /* throws QString */ = 0;
virtual void loadDocument(
const Analizer::SourceFileInterface::Data &data, QString *error
const Analizer::SFData &data, QString *error
) /* throws QString */ = 0;
virtual void saveDocument(
......@@ -61,18 +61,23 @@ public:
QIODevice *device, QString *error
) /* throws QString */ = 0;
virtual Analizer::SourceFileInterface::Data documentContents() const = 0;
virtual Analizer::SFData documentContents() const = 0;
virtual Analizer::InstanceInterface *analizer() = 0;
virtual quint32 errorLinesCount() const = 0;
virtual void ensureAnalized() = 0;
virtual void highlightLineGreen(int lineNo, quint32 colStart, quint32 colEnd) = 0;
virtual void highlightLineRed(int lineNo, quint32 colStart, quint32 colEnd) = 0;
virtual void highlightLineGreen(
int lineNo, quint32 colStart, quint32 colEnd
) = 0;
virtual void highlightLineRed(
int lineNo, quint32 colStart, quint32 colEnd
) = 0;
virtual void unhighlightLine() = 0;
virtual void appendMarginText(int lineNo, const QString &text) = 0;
virtual void setMarginText(int lineNo, const QString &text, const QColor &fgColor) = 0;
virtual void setMarginText(
int lineNo, const QString &text, const QColor &fgColor
) = 0;
virtual void clearMarginText(int fromLine = 0, int toLine = -1) = 0;
virtual bool supportsContextHelp() const = 0;
......
#ifndef EDITOR_INTERFACE
#define EDITOR_INTERFACE
#include "analizer_sourcefileinterface.h"
#include <QtPlugin>
namespace Shared
{
......@@ -10,6 +10,10 @@ namespace Editor {
class InstanceInterface;
}
namespace Analizer {
struct SFData;
}
class EditorInterface
{
public:
......@@ -27,7 +31,7 @@ public:
) = 0;
virtual Editor::InstanceInterface *loadDocument(
const Analizer::SourceFileInterface::Data &data,
const Analizer::SFData &data,
QString *error
) = 0;
......
......@@ -17,7 +17,7 @@ public:
Language language;
QDateTime saved;
QDateTime changed;
Shared::Analizer::SourceFileInterface::Data content;
Shared::Analizer::SFData content;
QString title;
QUrl url;
};
......
......@@ -16,16 +16,19 @@ class InsertCommand: public QUndoCommand
friend QDataStream &operator<< (QDataStream &stream, const InsertCommand &command);
friend QDataStream &operator>> (QDataStream &stream, InsertCommand &command);
public:
explicit InsertCommand(class TextDocument *doc,
class TextCursor *cursor,
explicit InsertCommand(
TextDocument *doc,
TextCursor *cursor,
Shared::Analizer::InstanceInterface *analizer,
int line,
int pos,
const QString &text
);
explicit InsertCommand(class TextDocument *doc,
class TextCursor *cursor,
Shared::Analizer::InstanceInterface *analizer);
explicit InsertCommand(
TextDocument *doc,
TextCursor *cursor,
Shared::Analizer::InstanceInterface *analizer
);
void redo();
void undo();
int id() const
......@@ -35,8 +38,8 @@ public:
bool mergeWith(const QUndoCommand *other);
private:
class TextDocument *doc;
class TextCursor *cursor;
TextDocument *doc;
TextCursor *cursor;
Shared::Analizer::InstanceInterface *analizer;
int line;
int pos;
......@@ -53,8 +56,9 @@ class RemoveCommand: public QUndoCommand
friend QDataStream &operator<< (QDataStream &stream, const RemoveCommand &command);
friend QDataStream &operator>> (QDataStream &stream, RemoveCommand &command);
public:
explicit RemoveCommand(class TextDocument *doc,
class TextCursor *cursor,
explicit RemoveCommand(
TextDocument *doc,
TextCursor *cursor,
Shared::Analizer::InstanceInterface *analizer,
int line,
int pos,
......@@ -63,9 +67,11 @@ public:
int newCursorRow,
int newCursorColumn
);
explicit RemoveCommand(class TextDocument *doc,
class TextCursor *cursor,
Shared::Analizer::InstanceInterface *analizer);
explicit RemoveCommand(
TextDocument *doc,
TextCursor *cursor,
Shared::Analizer::InstanceInterface *analizer
);
void redo();
void undo();
int id() const
......@@ -74,8 +80,8 @@ public:
}
bool mergeWith(const QUndoCommand *other);
private:
class TextDocument *doc;
class TextCursor *cursor;
TextDocument *doc;
TextCursor *cursor;
Shared::Analizer::InstanceInterface *analizer;
int line;
int pos;
......@@ -94,15 +100,18 @@ class InsertBlockCommand: public QUndoCommand
friend QDataStream &operator<< (QDataStream &stream, const InsertBlockCommand &command);
friend QDataStream &operator>> (QDataStream &stream, InsertBlockCommand &command);
public:
explicit InsertBlockCommand(class TextDocument *doc,
class TextCursor *cursor,
explicit InsertBlockCommand(
TextDocument *doc,
TextCursor *cursor,
Shared::Analizer::InstanceInterface *analizer,
int row,
int column,
const QStringList &block);
explicit InsertBlockCommand(class TextDocument *doc,
class TextCursor *cursor,
Shared::Analizer::InstanceInterface *analizer);
explicit InsertBlockCommand(
TextDocument *doc,
TextCursor *cursor,
Shared::Analizer::InstanceInterface *analizer
);
void redo();
void undo();
int id() const
......@@ -111,8 +120,8 @@ public:
}
private:
class TextDocument *doc;
class TextCursor *cursor;
TextDocument *doc;
TextCursor *cursor;
Shared::Analizer::InstanceInterface *analizer;
int row;
int column;
......@@ -128,13 +137,17 @@ class RemoveBlockCommand: public QUndoCommand
friend QDataStream &operator<< (QDataStream &stream, const RemoveBlockCommand &command);
friend QDataStream &operator>> (QDataStream &stream, RemoveBlockCommand &command);
public:
explicit RemoveBlockCommand(class TextDocument *doc,
class TextCursor *cursor,
explicit RemoveBlockCommand(
TextDocument *doc,
TextCursor *cursor,
Shared::Analizer::InstanceInterface *analizer,
const QRect &block);
explicit RemoveBlockCommand(class TextDocument *doc,
class TextCursor *cursor,
Shared::Analizer::InstanceInterface *analizer);
const QRect &block
);
explicit RemoveBlockCommand(
TextDocument *doc,
TextCursor *cursor,
Shared::Analizer::InstanceInterface *analizer
);
void redo();
void undo();
int id() const
......@@ -143,8 +156,8 @@ public:
}
private:
class TextDocument *doc;
class TextCursor *cursor;
TextDocument *doc;
TextCursor *cursor;
Shared::Analizer::InstanceInterface *analizer;
QRect block;
int cursorRow;
......@@ -158,8 +171,8 @@ class InsertImportCommand : public QUndoCommand
friend QDataStream &operator>> (QDataStream &, InsertImportCommand &);
public:
explicit InsertImportCommand(
class TextDocument *document,
class TextCursor *cursor,
TextDocument *document,
TextCursor *cursor,
Shared::Analizer::InstanceInterface *analizer,
const QString &importName
);
......@@ -172,8 +185,8 @@ public:
}
private:
class TextDocument *document_;
class TextCursor *cursor_;
TextDocument *document_;
TextCursor *cursor_;
Shared::Analizer::InstanceInterface *analizer_;
QString importName_;
uint lineNo_;
......@@ -184,7 +197,7 @@ class ToggleLineProtectedCommand: public QUndoCommand
friend QDataStream &operator<< (QDataStream &stream, const ToggleLineProtectedCommand &command);
friend QDataStream &operator>> (QDataStream &stream, ToggleLineProtectedCommand &command);
public:
explicit ToggleLineProtectedCommand(class TextDocument *Doc, int lineNo);
explicit ToggleLineProtectedCommand(TextDocument *Doc, int lineNo);
void redo();
void undo();
int id() const
......@@ -192,7 +205,7 @@ public:
return 0xA0;
}
private:
class TextDocument *doc;
TextDocument *doc;
int lineNo;
};
......@@ -202,13 +215,15 @@ class ChangeHiddenLineDelimeterCommand: public QUndoCommand
friend QDataStream &operator<< (QDataStream &stream, const ChangeHiddenLineDelimeterCommand &command);
friend QDataStream &operator>> (QDataStream &stream, ChangeHiddenLineDelimeterCommand &command);
public:
explicit ChangeHiddenLineDelimeterCommand(class TextDocument *doc,
int firstHiddenLineNo);
explicit ChangeHiddenLineDelimeterCommand(
TextDocument *doc,
int firstHiddenLineNo
);
void redo();
void undo();
private:
class TextDocument *doc;
struct Shared::Analizer::SourceFileInterface::Data prevData;
TextDocument *doc;
Shared::Analizer::SFData prevData;
int firstHiddenLineNo;
};
......@@ -218,10 +233,10 @@ class ToggleCommentCommand: public QUndoCommand
friend QDataStream &operator>> (QDataStream &stream, ToggleCommentCommand &command);
public:
explicit ToggleCommentCommand(
class TextDocument *Doc,
TextDocument *Doc,
uint FromLineInclusive,
uint ToLineInclusive,
class TextCursor *cursor,
TextCursor *cursor,
Shared::Analizer::InstanceInterface *analizer
);
void redo();
......@@ -231,8 +246,8 @@ public:
return 0xB0;
}
private:
class TextDocument *doc;
class TextCursor *cursor;
TextDocument *doc;
TextCursor *cursor;
Shared::Analizer::InstanceInterface *analizer;
uint fromLineInclusive;
uint toLineInclusive;
......
......@@ -6,6 +6,7 @@
#include <kumir2/editorinterface.h>
#include <kumir2/analizerinterface.h>
#include <kumir2/analizer_sourcefileinterface.h>
#include <kumir2-libs/extensionsystem/kplugin.h>
#include <kumir2-libs/extensionsystem/pluginspec.h>
......@@ -44,7 +45,7 @@ public:
) override;
Shared::Editor::InstanceInterface *loadDocument(
const Shared::Analizer::SourceFileInterface::Data &data, QString *error
const Shared::Analizer::SFData &data, QString *error
) override;
int analizerDocumentId(int editorDocumentId) const;
......@@ -53,9 +54,9 @@ public:
bool hasUnsavedChanges(int documentId) const;
void setDocumentChangesSaved(int documentId);
QString loadDocument(int documentId, const QString &fileName, bool keepIndents, QString *error);
QString loadDocument(int documentId, const Shared::Analizer::SourceFileInterface::Data &data, QString *error);
QString loadDocument(int documentId, const Shared::Analizer::SFData &data, QString *error);
QString saveDocument(int documentId, const QString &fileName, QString *error);
Shared::Analizer::SourceFileInterface::Data documentContent(int documentId) const;
Shared::Analizer::SFData documentContent(int documentId) const;
Shared::AnalizerInterface *analizer(int documentId);
quint32 errorsLinesCount(int documentId) const;
void highlightLineGreen(int documentId, int lineNo, quint32 colStart, quint32 colEnd);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment