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