Continuously update depending files when changing modules
This commit is contained in:
parent
856a2cacc4
commit
654ec54879
Binary file not shown.
Binary file not shown.
|
@ -31,7 +31,8 @@ namespace UpsilonLanguageServer.Services
|
||||||
BoundTypeParser.LoadStaticVariables(File.ReadAllText(staticConfigFile));
|
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);
|
Session.Client.Window.LogMessage(MessageType.Error, Session.Settings.ModuleDirectory);
|
||||||
}
|
}
|
||||||
return new InitializeResult(new ServerCapabilities
|
return new InitializeResult(new ServerCapabilities
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using JsonRpc.Standard.Contracts;
|
using JsonRpc.Standard.Contracts;
|
||||||
using LanguageServer.VsCode.Contracts;
|
using LanguageServer.VsCode.Contracts;
|
||||||
|
@ -17,7 +18,8 @@ namespace UpsilonLanguageServer.Services
|
||||||
public async Task DidChangeConfiguration(SettingsRoot settings)
|
public async Task DidChangeConfiguration(SettingsRoot settings)
|
||||||
{
|
{
|
||||||
Session.Settings = settings.UpsilonLanguageServer;
|
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)
|
foreach (var doc in Session.Documents.Values)
|
||||||
{
|
{
|
||||||
var diag = await DiagnosticProvider.LintDocument(doc.Document, doc, Session.Settings.MaxNumberOfProblems,
|
var diag = await DiagnosticProvider.LintDocument(doc.Document, doc, Session.Settings.MaxNumberOfProblems,
|
||||||
|
@ -35,6 +37,28 @@ namespace UpsilonLanguageServer.Services
|
||||||
var localPath = change.Uri.AbsolutePath;
|
var localPath = change.Uri.AbsolutePath;
|
||||||
if (string.Equals(Path.GetExtension(localPath), ".yup", StringComparison.InvariantCultureIgnoreCase))
|
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.
|
// 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.
|
// Note that pass null to PublishDiagnostics may mess up the client.
|
||||||
if (change.Type == FileChangeType.Deleted)
|
if (change.Type == FileChangeType.Deleted)
|
||||||
|
|
Loading…
Reference in New Issue