mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 23:53:52 +00:00
added setting for controlling script compiler warnings
This commit is contained in:
parent
1ee1934053
commit
9a102f81c8
4 changed files with 49 additions and 2 deletions
|
@ -293,7 +293,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
|||
autoDelete->setDefaultValue ("true");
|
||||
}
|
||||
|
||||
declareSection ("script-editor", "Script Editor");
|
||||
declareSection ("script-editor", "Scripts");
|
||||
{
|
||||
Setting *lineNum = createSetting (Type_CheckBox, "show-linenum", "Show Line Numbers");
|
||||
lineNum->setDefaultValue ("true");
|
||||
|
@ -312,6 +312,20 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
|||
"\nA name from the list of colors defined in the list of SVG color keyword names."
|
||||
"\nX11 color names may also work.";
|
||||
|
||||
QString modeIgnore ("Ignore");
|
||||
|
||||
QStringList modes;
|
||||
modes << modeIgnore << "Strict";
|
||||
|
||||
Setting *warnings = createSetting (Type_ComboBox, "warnings",
|
||||
"Warning Mode");
|
||||
warnings->setDeclaredValues (modes);
|
||||
warnings->setDefaultValue (modeIgnore);
|
||||
warnings->setToolTip ("<ul>How to handle warning messages during compilation:<p>"
|
||||
"<li>Ignore: Do not report warning</li>"
|
||||
"<li>Strict: Promote warning to an error</li>"
|
||||
"</ul>");
|
||||
|
||||
Setting *formatInt = createSetting (Type_LineEdit, "colour-int", "Highlight Colour: Int");
|
||||
formatInt->setDefaultValues (QStringList() << "Dark magenta");
|
||||
formatInt->setToolTip ("(Default: Green) Use one of the following formats:" + tooltip);
|
||||
|
|
|
@ -44,7 +44,7 @@ void CSMTools::ScriptCheckStage::report (const std::string& message, Type type)
|
|||
}
|
||||
|
||||
CSMTools::ScriptCheckStage::ScriptCheckStage (const CSMDoc::Document& document)
|
||||
: mDocument (document), mContext (document.getData()), mMessages (0)
|
||||
: mDocument (document), mContext (document.getData()), mMessages (0), mWarningMode (Mode_Ignore)
|
||||
{
|
||||
/// \todo add an option to configure warning mode
|
||||
setWarningsMode (0);
|
||||
|
@ -58,6 +58,7 @@ int CSMTools::ScriptCheckStage::setup()
|
|||
mContext.clear();
|
||||
mMessages = 0;
|
||||
mId.clear();
|
||||
Compiler::ErrorHandler::reset();
|
||||
|
||||
return mDocument.getData().getScripts().getSize();
|
||||
}
|
||||
|
@ -72,6 +73,12 @@ void CSMTools::ScriptCheckStage::perform (int stage, CSMDoc::Messages& messages)
|
|||
|
||||
mMessages = &messages;
|
||||
|
||||
switch (mWarningMode)
|
||||
{
|
||||
case Mode_Ignore: setWarningsMode (0); break;
|
||||
case Mode_Strict: setWarningsMode (1); break;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
const CSMWorld::Data& data = mDocument.getData();
|
||||
|
@ -99,3 +106,14 @@ void CSMTools::ScriptCheckStage::perform (int stage, CSMDoc::Messages& messages)
|
|||
|
||||
mMessages = 0;
|
||||
}
|
||||
|
||||
void CSMTools::ScriptCheckStage::updateUserSetting (const QString& name, const QStringList& value)
|
||||
{
|
||||
if (name=="script-editor/warnings")
|
||||
{
|
||||
if (value.at (0)=="Ignore")
|
||||
mWarningMode = Mode_Ignore;
|
||||
else if (value.at (0)=="Strict")
|
||||
mWarningMode = Mode_Strict;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,12 +18,20 @@ namespace CSMTools
|
|||
/// \brief VerifyStage: make sure that scripts compile
|
||||
class ScriptCheckStage : public CSMDoc::Stage, private Compiler::ErrorHandler
|
||||
{
|
||||
enum WarningMode
|
||||
{
|
||||
Mode_Ignore,
|
||||
Mode_Strict
|
||||
};
|
||||
|
||||
const CSMDoc::Document& mDocument;
|
||||
Compiler::Extensions mExtensions;
|
||||
CSMWorld::ScriptContext mContext;
|
||||
std::string mId;
|
||||
std::string mFile;
|
||||
CSMDoc::Messages *mMessages;
|
||||
WarningMode mWarningMode;
|
||||
|
||||
|
||||
virtual void report (const std::string& message, const Compiler::TokenLoc& loc, Type type);
|
||||
///< Report error to the user.
|
||||
|
@ -40,6 +48,8 @@ namespace CSMTools
|
|||
|
||||
virtual void perform (int stage, CSMDoc::Messages& messages);
|
||||
///< Messages resulting from this tage will be appended to \a messages.
|
||||
|
||||
virtual void updateUserSetting (const QString& name, const QStringList& value);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -51,6 +51,11 @@ CSMDoc::OperationHolder *CSMTools::Tools::getVerifier()
|
|||
{
|
||||
mVerifierOperation = new CSMDoc::Operation (CSMDoc::State_Verifying, false);
|
||||
|
||||
std::vector<QString> settings;
|
||||
settings.push_back ("script-editor/warnings");
|
||||
|
||||
mVerifierOperation->configureSettings (settings);
|
||||
|
||||
connect (&mVerifier, SIGNAL (progress (int, int, int)), this, SIGNAL (progress (int, int, int)));
|
||||
connect (&mVerifier, SIGNAL (done (int, bool)), this, SIGNAL (done (int, bool)));
|
||||
connect (&mVerifier,
|
||||
|
|
Loading…
Reference in a new issue