エディタ関連をEditorフォルダへ整理

このコミットが含まれているのは:
routersys committed 2026-07-03 18:02:42 +09:00
1 親 4fd519249f
コミット 5fac495848
3ファイル変更

検索条件に一致するファイルはありません

+10
ファイルの表示
@@ -0,0 +1,10 @@
using System.Collections.Generic;
using YukkuriMovieMaker.Controls.AvalonEdit.ToolBarStrategy;
namespace LuaScript
{
internal sealed class EmptyToolBarStrategy : IToolBarStrategy
{
public IEnumerable<ToolBarGroup> GetToolBarGroups() => [];
}
}
+60
ファイルの表示
@@ -0,0 +1,60 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using LuaScript.Api;
using YukkuriMovieMaker.Controls.AvalonEdit.AutoCompletionStrategy;
namespace LuaScript
{
internal sealed partial class LuaAutoCompletionStrategy : IAutoCompletionStrategy
{
[GeneratedRegex(@"[a-zA-Z_][a-zA-Z_0-9]*$", RegexOptions.None)]
private static partial Regex IdentifierPattern();
[GeneratedRegex(@"(?<!local\s)\bfunction\s+([a-zA-Z_][a-zA-Z_0-9]*(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*)\s*\(", RegexOptions.None)]
private static partial Regex FunctionPattern();
[GeneratedRegex(@"\blocal\s+function\s+([a-zA-Z_][a-zA-Z_0-9]*)\s*\(", RegexOptions.None)]
private static partial Regex LocalFunctionPattern();
public IEnumerable<string> GetCompletionItems(string input, string line, string sourceCode)
{
if (string.IsNullOrEmpty(input))
return [];
var lastDot = line.LastIndexOf('.');
if (lastDot >= 0)
{
var beforeDot = line[..lastDot];
var nsMatch = IdentifierPattern().Match(beforeDot);
if (!nsMatch.Success)
return [];
return LuaCompletionSource.TryGetTableMembers(nsMatch.Value, out var members)
? members
: [];
}
if (input[0] is (>= 'a' and <= 'z') or (>= 'A' and <= 'Z') or '_')
{
var userFunctions = GetUserDefinedFunctions(sourceCode);
return LuaCompletionSource.StaticCandidates
.Concat(userFunctions)
.Distinct()
.OrderBy(x => x.Length)
.ThenBy(x => x, StringComparer.OrdinalIgnoreCase);
}
return [];
}
private static IEnumerable<string> GetUserDefinedFunctions(string sourceCode)
{
foreach (Match m in FunctionPattern().Matches(sourceCode))
yield return m.Groups[1].Value;
foreach (Match m in LocalFunctionPattern().Matches(sourceCode))
yield return m.Groups[1].Value;
}
}
}
+92
ファイルの表示
@@ -0,0 +1,92 @@
using System.Collections.Generic;
using System.Text.RegularExpressions;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Folding;
using LuaScript.Diagnostics;
using YukkuriMovieMaker.Controls.AvalonEdit.FoldingStrategy;
namespace LuaScript
{
internal sealed partial class LuaFoldingStrategy : IFoldingStrategy
{
[GeneratedRegex(
@"--\[(?<lc>=*)\[.*?\]\k<lc>\]" +
@"|\[(?<ls>=*)\[.*?\]\k<ls>\]" +
@"|--[^\r\n]*" +
@"|""(?:[^""\\]|\\.)*""|'(?:[^'\\]|\\.)*'" +
@"|(?<repeat>\brepeat\b)" +
@"|(?<until>\buntil\b)" +
@"|(?<open>\b(?:function|do|if)\b)" +
@"|(?<close>\bend\b)",
RegexOptions.Singleline)]
private static partial Regex TokenPattern();
private readonly record struct Frame(int Offset, bool IsRepeat);
public void UpdateFoldings(FoldingManager manager, TextDocument document)
{
manager.UpdateFoldings(CreateNewFoldings(document, out int firstErrorOffset), firstErrorOffset);
LuaScriptDiagnosticOverlay.Attach(manager);
}
private static IEnumerable<NewFolding> CreateNewFoldings(TextDocument document, out int firstErrorOffset)
{
firstErrorOffset = -1;
var text = document.Text;
var newFoldings = new List<NewFolding>();
var openStack = new Stack<Frame>();
foreach (Match m in TokenPattern().Matches(text))
{
if (m.Groups["repeat"].Success)
{
openStack.Push(new Frame(m.Index + m.Length, IsRepeat: true));
}
else if (m.Groups["open"].Success)
{
openStack.Push(new Frame(m.Index + m.Length, IsRepeat: false));
}
else if (m.Groups["until"].Success)
{
if (openStack.Count > 0 && openStack.Peek().IsRepeat)
{
var frame = openStack.Pop();
int blockEnd = m.Index + m.Length;
if (document.GetLineByOffset(frame.Offset).LineNumber <
document.GetLineByOffset(blockEnd).LineNumber)
{
newFoldings.Add(new NewFolding(frame.Offset, blockEnd));
}
}
else
{
firstErrorOffset = m.Index;
}
}
else if (m.Groups["close"].Success)
{
if (openStack.Count > 0 && !openStack.Peek().IsRepeat)
{
var frame = openStack.Pop();
int blockEnd = m.Index + m.Length;
if (document.GetLineByOffset(frame.Offset).LineNumber <
document.GetLineByOffset(blockEnd).LineNumber)
{
newFoldings.Add(new NewFolding(frame.Offset, blockEnd));
}
}
else
{
firstErrorOffset = m.Index;
}
}
}
if (firstErrorOffset < 0 && openStack.Count > 0)
firstErrorOffset = openStack.Peek().Offset;
newFoldings.Sort((a, b) => a.StartOffset.CompareTo(b.StartOffset));
return newFoldings;
}
}
}