Avoid reporting false positives when a colon is in a comment in the first line of a script where the user was not trying to select a different script engine.
This works by only posting the "Selected engine unavailable" message if we're falling back on XEngine and the language is one handled by XEngine. In cases where the language is not handled or not allowed, the user will still be notified by the later compiler error. This avoids the overwhelming majority of false positives where the first line contains a : for other reasons (e.g. source control systems, vim settings, etc.) Ultimately, I think it would be better to detect script language/engine with a mechanism that didn't just rely on : detection (e.g like #! in unix scripts).0.7.4.1
parent
f9769a9fcb
commit
25baa2d894
|
@ -778,6 +778,29 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (engine == ScriptEngineName)
|
if (engine == ScriptEngineName)
|
||||||
|
{
|
||||||
|
// If we are falling back on XEngine as the default engine, then only complain to the user
|
||||||
|
// if a script language has been explicitly set and it's one that we recognize. If it's
|
||||||
|
// explicitly not allowed or the script is not in LSL then the user will be informed by a later compiler message.
|
||||||
|
//
|
||||||
|
// This avoids the overwhelming number of false positives where we're in this code because
|
||||||
|
// there's a colon in a comment in the first line of a script for entirely
|
||||||
|
// unrelated reasons (e.g. vim settings).
|
||||||
|
//
|
||||||
|
// TODO: A better fix would be to deprecate simple : detection and look for some less likely
|
||||||
|
// string to begin the comment (like #! in unix shell scripts).
|
||||||
|
bool scriptExplicitlyInXEngineLanguage = false;
|
||||||
|
string restOfScript = script.Substring(colon + 1);
|
||||||
|
|
||||||
|
// FIXME: These are hardcoded because they are currently hardcoded in Compiler.cs
|
||||||
|
if (restOfScript.StartsWith("c#")
|
||||||
|
|| restOfScript.StartsWith("vb")
|
||||||
|
|| restOfScript.StartsWith("lsl")
|
||||||
|
|| restOfScript.StartsWith("js")
|
||||||
|
|| restOfScript.StartsWith("yp"))
|
||||||
|
scriptExplicitlyInXEngineLanguage = true;
|
||||||
|
|
||||||
|
if (scriptExplicitlyInXEngineLanguage)
|
||||||
{
|
{
|
||||||
SceneObjectPart part =
|
SceneObjectPart part =
|
||||||
m_Scene.GetSceneObjectPart(
|
m_Scene.GetSceneObjectPart(
|
||||||
|
@ -802,6 +825,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (engine != ScriptEngineName)
|
if (engine != ScriptEngineName)
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue