Commit de4951b5 authored by Victor Yacovlev's avatar Victor Yacovlev

Merged kumir program search path from "master"

parent 81327b46
...@@ -40,6 +40,11 @@ QString Analizer::sourceText() const ...@@ -40,6 +40,11 @@ QString Analizer::sourceText() const
return d->sourceText.join("\n")+"\n"; return d->sourceText.join("\n")+"\n";
} }
void Analizer::setSourceDirName(const QString &dirName)
{
d->analizer->setSourceDirName(dirName);
}
LineProp Analizer::lineProp(const QString &text) const LineProp Analizer::lineProp(const QString &text) const
{ {
QList<Lexem*> lexems; QList<Lexem*> lexems;
......
...@@ -33,7 +33,7 @@ public: ...@@ -33,7 +33,7 @@ public:
public slots: public slots:
void setSourceDirName(const QString & dirName);
void changeSourceText(const QList<Shared::ChangeTextTransaction> & changes); void changeSourceText(const QList<Shared::ChangeTextTransaction> & changes);
void setHiddenText(const QString & text, int baseLineNo); void setHiddenText(const QString & text, int baseLineNo);
void setHiddenBaseLine(int lineNo); void setHiddenBaseLine(int lineNo);
......
...@@ -88,6 +88,12 @@ void KumirAnalizerPlugin::setSourceText(int documentId, const QString &text) ...@@ -88,6 +88,12 @@ void KumirAnalizerPlugin::setSourceText(int documentId, const QString &text)
m_analizers[documentId]->changeSourceText(QList<Shared::ChangeTextTransaction>() << change); m_analizers[documentId]->changeSourceText(QList<Shared::ChangeTextTransaction>() << change);
} }
void KumirAnalizerPlugin::setSourceDirName(int documentId, const QString &dirPath)
{
Q_CHECK_PTR(m_analizers[documentId]);
m_analizers[documentId]->setSourceDirName(dirPath);
}
void KumirAnalizerPlugin::setHiddenText(int documentId, const QString &text, int baseLine) void KumirAnalizerPlugin::setHiddenText(int documentId, const QString &text, int baseLine)
{ {
Q_CHECK_PTR(m_analizers[documentId]); Q_CHECK_PTR(m_analizers[documentId]);
......
...@@ -28,6 +28,7 @@ public: ...@@ -28,6 +28,7 @@ public:
int newDocument(); int newDocument();
void dropDocument(int documentId); void dropDocument(int documentId);
void setSourceDirName(int documentId, const QString &dirPath);
void setSourceText(int documentId, const QString &text); void setSourceText(int documentId, const QString &text);
void setHiddenText(int documentId, const QString &text, int baseLine); void setHiddenText(int documentId, const QString &text, int baseLine);
void setHiddenTextBaseLine(int documentId, int baseLine); void setHiddenTextBaseLine(int documentId, int baseLine);
......
...@@ -41,6 +41,7 @@ struct SyntaxAnalizerPrivate ...@@ -41,6 +41,7 @@ struct SyntaxAnalizerPrivate
QList<Statement> statements; QList<Statement> statements;
QSet<QString> unresolvedImports; QSet<QString> unresolvedImports;
QStringList alwaysEnabledModules; QStringList alwaysEnabledModules;
QString sourceDirName;
void parseImport(int str); void parseImport(int str);
void parseModuleHeader(int str); void parseModuleHeader(int str);
...@@ -552,6 +553,11 @@ void SyntaxAnalizer::processAnalisys() ...@@ -552,6 +553,11 @@ void SyntaxAnalizer::processAnalisys()
} }
} }
void SyntaxAnalizer::setSourceDirName(const QString &dirName)
{
d->sourceDirName = dirName;
}
void SyntaxAnalizerPrivate::parseImport(int str) void SyntaxAnalizerPrivate::parseImport(int str)
{ {
if (statements[str].hasError()) if (statements[str].hasError())
...@@ -587,8 +593,8 @@ void SyntaxAnalizerPrivate::parseImport(int str) ...@@ -587,8 +593,8 @@ void SyntaxAnalizerPrivate::parseImport(int str)
if (name.endsWith(".kum")) { if (name.endsWith(".kum")) {
kumName = name; kumName = name;
name = binName = name.left(name.length()-4)+".kod"; name = binName = name.left(name.length()-4)+".kod";
binFile = QFileInfo (QDir::current().absoluteFilePath(binName)); binFile = QFileInfo (QDir(sourceDirName).absoluteFilePath(binName));
kumFile = QFileInfo (QDir::current().absoluteFilePath(kumName)); kumFile = QFileInfo (QDir(sourceDirName).absoluteFilePath(kumName));
QString kumir2bc = QDir(QCoreApplication::applicationDirPath()).absoluteFilePath("kumir2-bc"); QString kumir2bc = QDir(QCoreApplication::applicationDirPath()).absoluteFilePath("kumir2-bc");
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN32
kumir2bc += ".exe"; kumir2bc += ".exe";
......
...@@ -22,6 +22,7 @@ public: ...@@ -22,6 +22,7 @@ public:
, AST_Algorhitm *algorhitm); , AST_Algorhitm *algorhitm);
void syncStatements(); void syncStatements();
QStringList unresolvedImports() const; QStringList unresolvedImports() const;
void setSourceDirName(const QString & dirName);
void buildTables(bool allowOperatorsDeclaration); void buildTables(bool allowOperatorsDeclaration);
void processAnalisys(); void processAnalisys();
~SyntaxAnalizer(); ~SyntaxAnalizer();
......
...@@ -87,6 +87,7 @@ void KumirBytecodeCompilerPlugin::start() ...@@ -87,6 +87,7 @@ void KumirBytecodeCompilerPlugin::start()
int id = m_analizer->newDocument(); int id = m_analizer->newDocument();
m_analizer->setSourceText(id, kumFile.visibleText); m_analizer->setSourceText(id, kumFile.visibleText);
m_analizer->setSourceDirName(id, QFileInfo(filename).absoluteDir().dirName());
if (kumFile.hasHiddenText) { if (kumFile.hasHiddenText) {
m_analizer->setHiddenText(id, kumFile.hiddenText, -1); m_analizer->setHiddenText(id, kumFile.hiddenText, -1);
} }
......
...@@ -21,6 +21,7 @@ public: ...@@ -21,6 +21,7 @@ public:
virtual bool caseInsensitiveGrammatic() const = 0; virtual bool caseInsensitiveGrammatic() const = 0;
virtual bool supportPartialCompiling() const = 0; virtual bool supportPartialCompiling() const = 0;
virtual void dropDocument(int documentId) = 0; virtual void dropDocument(int documentId) = 0;
virtual void setSourceDirName(int documentId, const QString & dirPath) = 0;
virtual void setSourceText(int documentId, const QString &text) = 0; virtual void setSourceText(int documentId, const QString &text) = 0;
virtual void setHiddenText(int documentId, const QString &text, int baseLine) = 0; virtual void setHiddenText(int documentId, const QString &text, int baseLine) = 0;
virtual void setHiddenTextBaseLine(int documentId, int baseLine) = 0; virtual void setHiddenTextBaseLine(int documentId, int baseLine) = 0;
......
...@@ -17,9 +17,10 @@ struct EditorComponent { ...@@ -17,9 +17,10 @@ struct EditorComponent {
class EditorInterface class EditorInterface
{ {
public: public:
virtual struct EditorComponent newDocument(const QString & analizerName = "Analizer", virtual struct EditorComponent newDocument(const QString & analizerName,
const QString & initialText = "", const QString & initialText,
bool initiallyNotSaved = false const QString & documentDir,
bool initiallyNotSaved
) = 0; ) = 0;
virtual void closeDocument(int documentId) = 0; virtual void closeDocument(int documentId) = 0;
virtual int analizerDocumentId(int editorDocumentId) const = 0; virtual int analizerDocumentId(int editorDocumentId) const = 0;
......
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