Exemple #1
0
		/// <summary>
		/// Formats the location according to script preferences
		/// </summary>
		/// <param name="script">The script.</param>
		/// <param name="forceClassicFormat">if set to <c>true</c> the classic Lua format is forced.</param>
		/// <returns></returns>
		public string FormatLocation(Script script, bool forceClassicFormat = false)
		{
			SourceCode sc = script.GetSourceCode(this.SourceIdx);

			if (this.IsClrLocation)
				return "[clr]";

			if (script.Options.UseLuaErrorLocations || forceClassicFormat)
			{
				return string.Format("{0}:{1}", sc.Name, this.FromLine);
			}
			else if (this.FromLine == this.ToLine)
			{
				if (this.FromChar == this.ToChar)
				{
					return string.Format("{0}:({1},{2})", sc.Name, this.FromLine, this.FromChar, this.ToLine, this.ToChar);
				}
				else
				{
					return string.Format("{0}:({1},{2}-{4})", sc.Name, this.FromLine, this.FromChar, this.ToLine, this.ToChar);
				}
			}
			else
			{
				return string.Format("{0}:({1},{2}-{3},{4})", sc.Name, this.FromLine, this.FromChar, this.ToLine, this.ToChar);
			}
		}
Exemple #2
0
        /// <summary>
        ///     Formats the location according to script preferences
        /// </summary>
        /// <param name="script">The script.</param>
        /// <param name="forceClassicFormat">if set to <c>true</c> the classic Lua format is forced.</param>
        /// <returns></returns>
        public string FormatLocation(Script script, bool forceClassicFormat = false)
        {
            var sc = script.GetSourceCode(SourceIdx);

            if (IsClrLocation)
                return "[clr]";

            if (script.Options.UseLuaErrorLocations || forceClassicFormat)
            {
                return string.Format("{0}:{1}", sc.Name, FromLine);
            }
            if (FromLine == ToLine)
            {
                if (FromChar == ToChar)
                {
                    return string.Format("{0}:({1},{2})", sc.Name, FromLine, FromChar, ToLine, ToChar);
                }
                return string.Format("{0}:({1},{2}-{4})", sc.Name, FromLine, FromChar, ToLine, ToChar);
            }
            return string.Format("{0}:({1},{2}-{3},{4})", sc.Name, FromLine, FromChar, ToLine, ToChar);
        }