diff --git a/UpsilonLanguageServer/Lib/Upsilon.dll b/UpsilonLanguageServer/Lib/Upsilon.dll index 010d001..6c03c09 100644 Binary files a/UpsilonLanguageServer/Lib/Upsilon.dll and b/UpsilonLanguageServer/Lib/Upsilon.dll differ diff --git a/UpsilonLanguageServer/Lib/Upsilon.pdb b/UpsilonLanguageServer/Lib/Upsilon.pdb index bfe8529..5a35e0a 100644 Binary files a/UpsilonLanguageServer/Lib/Upsilon.pdb and b/UpsilonLanguageServer/Lib/Upsilon.pdb differ diff --git a/UpsilonLanguageServer/UpsilonLanguageServer/Services/InitializationService.cs b/UpsilonLanguageServer/UpsilonLanguageServer/Services/InitializationService.cs index 5ae55ac..fecb573 100644 --- a/UpsilonLanguageServer/UpsilonLanguageServer/Services/InitializationService.cs +++ b/UpsilonLanguageServer/UpsilonLanguageServer/Services/InitializationService.cs @@ -31,7 +31,8 @@ namespace UpsilonLanguageServer.Services BoundTypeParser.LoadStaticVariables(File.ReadAllText(staticConfigFile)); } - Session.Settings.ModuleDirectory = Path.Combine(rootUri.AbsolutePath, Session.Settings.ModuleDirectory); + Session.Settings.ModuleDirectory = + new DirectoryInfo(Path.Combine(rootUri.AbsolutePath, Session.Settings.ModuleDirectory)).FullName; Session.Client.Window.LogMessage(MessageType.Error, Session.Settings.ModuleDirectory); } return new InitializeResult(new ServerCapabilities diff --git a/UpsilonLanguageServer/UpsilonLanguageServer/Services/WorkspaceService.cs b/UpsilonLanguageServer/UpsilonLanguageServer/Services/WorkspaceService.cs index 2474047..500d642 100644 --- a/UpsilonLanguageServer/UpsilonLanguageServer/Services/WorkspaceService.cs +++ b/UpsilonLanguageServer/UpsilonLanguageServer/Services/WorkspaceService.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Threading.Tasks; using JsonRpc.Standard.Contracts; using LanguageServer.VsCode.Contracts; @@ -17,7 +18,8 @@ namespace UpsilonLanguageServer.Services public async Task DidChangeConfiguration(SettingsRoot settings) { Session.Settings = settings.UpsilonLanguageServer; - Session.Settings.ModuleDirectory = Path.Combine(RootUri, Session.Settings.ModuleDirectory); + Session.Settings.ModuleDirectory = + new DirectoryInfo(Path.Combine(RootUri, Session.Settings.ModuleDirectory)).FullName; foreach (var doc in Session.Documents.Values) { var diag = await DiagnosticProvider.LintDocument(doc.Document, doc, Session.Settings.MaxNumberOfProblems, @@ -35,6 +37,28 @@ namespace UpsilonLanguageServer.Services var localPath = change.Uri.AbsolutePath; if (string.Equals(Path.GetExtension(localPath), ".yup", StringComparison.InvariantCultureIgnoreCase)) { + // If its a module + if (string.Equals(Path.GetDirectoryName(localPath), Session.Settings.ModuleDirectory)) + { + var name = Path.GetFileNameWithoutExtension(localPath); + var firstScript = Session.Documents.Values.FirstOrDefault(x => x.Bound != null); + firstScript?.Bound.Script.Options.ModuleHandler.ClearCachedModule(name); + + if (change.Type == FileChangeType.Deleted) + { + await Client.Document.PublishDiagnostics(change.Uri, new Diagnostic[0]); + } + foreach (var doc in Session.Documents.Values) + { + if (doc.Bound == null) + continue; + if (!doc.Bound.Script.ModuleDependencies.Any(x => string.Equals(x, name))) + continue; + var diag = await DiagnosticProvider.LintDocument(doc.Document, doc, + Session.Settings.MaxNumberOfProblems, Session.Settings.ModuleDirectory); + await Client.Document.PublishDiagnostics(doc.Document.Uri, diag); + } + } // If the file has been removed, we will clear the lint result about it. // Note that pass null to PublishDiagnostics may mess up the client. if (change.Type == FileChangeType.Deleted)