This repository has been archived on 2025-10-24. You can view files and clone it, but cannot push or open issues or pull requests.
Files
nub-lang-archive-2/compiler/NubLang.LSP/WorkspaceManager.cs
2025-10-23 10:16:52 +02:00

29 lines
802 B
C#

using NubLang.Syntax;
using OmniSharp.Extensions.LanguageServer.Protocol;
namespace NubLang.LSP;
public class WorkspaceManager(DiagnosticsPublisher diagnosticsPublisher)
{
private readonly Dictionary<DocumentUri, SyntaxTree> _files = new();
public void UpdateFile(DocumentUri path)
{
var text = File.ReadAllText(path.GetFileSystemPath());
var tokenizer = new Tokenizer(path.GetFileSystemPath(), text);
tokenizer.Tokenize();
diagnosticsPublisher.Publish(path, tokenizer.Diagnostics);
var parser = new Parser();
var result = parser.Parse(tokenizer.Tokens);
diagnosticsPublisher.Publish(path, parser.Diagnostics);
_files[path] = result;
}
public void RemoveFile(Uri path)
{
_files.Remove(path);
}
}