language server start
This commit is contained in:
@@ -1,6 +1,29 @@
|
||||
using NubLang.Syntax;
|
||||
using OmniSharp.Extensions.LanguageServer.Protocol;
|
||||
|
||||
namespace NubLang.LSP;
|
||||
|
||||
public class WorkspaceManager
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user