Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ private void ReceivedSignatureHelpContext(NotificationType notificationType, obj

/// <summary>
/// The Missing copies notification is sent from the client to the server
/// when the client failed to load copies, it send back a list of missing copies to the server.
/// when the client has finished to load copies, it send back a list of missing copies that it fails to load to the server.
/// The list can be empty if all copies has been loaded.
/// </summary>
protected virtual void OnDidReceiveMissingCopies(MissingCopiesParams parameter)
{
Expand Down
7 changes: 7 additions & 0 deletions TypeCobol.LanguageServer/TypeCobolServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ public TypeCobolServer(IRPCServer rpcServer, Queue<MessageActionWrapper> message
/// </summary>
public List<string> CustomAnalyzerFiles { get; set; }

/// <summary>
/// No Copy and Dependency files watchers.
/// </summary>
public bool NoCopyDependencyWatchers { get; set; }

private bool Logger(string message, Uri uri)
{
if (uri == null)
Expand Down Expand Up @@ -238,6 +243,8 @@ protected override InitializeResult OnInitialize(InitializeParams parameters)

// Initialize the workspace.
this.Workspace = new Workspace(rootDirectory.FullName, workspaceName, _messagesActionsQueue, Logger);
if (!NoCopyDependencyWatchers)
this.Workspace.InitCopyDependencyWatchers();
#if EUROINFO_RULES
this.Workspace.CpyCopyNamesMapFilePath = CpyCopyNamesMapFilePath;
#endif
Expand Down
9 changes: 8 additions & 1 deletion TypeCobol.LanguageServer/TypeCobolServerHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ public static string Version
/// </summary>
public static bool UseOutlineRefresh { get; set; }

/// <summary>
/// No Copy and Dependency files watchers.
/// </summary>
public static bool NoCopyDependencyWatchers { get; set; }

#if EUROINFO_RULES
/// <summary>
/// A Path to a file of CPY Copy names
Expand Down Expand Up @@ -233,7 +238,8 @@ static int Main(string[] args)
{ "cfg=", "{dot output mode} Control Flow Graph support and Dot Output mode: No/0, AsFile/1 or AsContent/2.",
(String m) => {TypeCobolCustomLanguageServer.UseCfgMode ucm = TypeCobolCustomLanguageServer.UseCfgMode.No;
Enum.TryParse(m, out ucm); UseCfg = ucm; } },
{ "ca|customanalyzer=", "{PATH} to a custom DLL file containing code analyzers. This option can be specified more than once.", v => CustomAnalyzerFiles.Add(v) }
{ "ca|customanalyzer=", "{PATH} to a custom DLL file containing code analyzers. This option can be specified more than once.", v => CustomAnalyzerFiles.Add(v) },
{ "now|nowatchers", "No Copy and Dependency files watchers.", _ => NoCopyDependencyWatchers = true}
};

System.Collections.Generic.List<string> arguments;
Expand Down Expand Up @@ -312,6 +318,7 @@ static int Main(string[] args)
typeCobolServer.UseOutlineRefresh = UseOutlineRefresh;
typeCobolServer.UseCfgDfaDataRefresh = UseCfg;
typeCobolServer.CustomAnalyzerFiles = CustomAnalyzerFiles;
typeCobolServer.NoCopyDependencyWatchers = NoCopyDependencyWatchers;
#if EUROINFO_RULES
typeCobolServer.CpyCopyNamesMapFilePath = CpyCopyNamesMapFilePath;
#endif
Expand Down
45 changes: 31 additions & 14 deletions TypeCobol.LanguageServer/Workspace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ public bool IsEmpty
}
}
}

#endregion

public Workspace(string rootDirectoryFullName, string workspaceName, Queue<MessageActionWrapper> messagesActionsQueue, Func<string, Uri, bool> logger)
Expand All @@ -179,10 +178,12 @@ public Workspace(string rootDirectoryFullName, string workspaceName, Queue<Messa
this.CompilationProject.CompilationOptions.UseEuroInformationLegacyReplacingSyntax =
this.CompilationProject.CompilationOptions.UseEuroInformationLegacyReplacingSyntax ||
UseEuroInformationLegacyReplacingSyntax;
}

internal void InitCopyDependencyWatchers()
{
// Create the refresh action that will be used by file watchers
Action refreshAction = RefreshOpenedFiles;

_DepWatcher = new DependenciesFileWatcher(this, refreshAction);
_CopyWatcher = new CopyWatcher(this, refreshAction);
}
Expand Down Expand Up @@ -581,26 +582,42 @@ public void DidChangeConfigurationParams(string[] arguments)
else
RefreshCustomSymbols();

//Dispose previous watcher before setting new ones
_DepWatcher.Dispose();
_CopyWatcher.Dispose();
foreach (var depFolder in Configuration.CopyFolders)
//Dispose previous watchers before setting new ones
if (_CopyWatcher != null)
{
_CopyWatcher.SetDirectoryWatcher(depFolder);
}
foreach (var depFolder in Configuration.Dependencies)
{
_DepWatcher.SetDirectoryWatcher(depFolder);
_CopyWatcher.Dispose();
foreach (var copyFolder in Configuration.CopyFolders)
{
_CopyWatcher.SetDirectoryWatcher(copyFolder);
}
}
foreach (var intrinsicFolder in Configuration.Copies)
if (_DepWatcher != null)
{
_DepWatcher.SetDirectoryWatcher(intrinsicFolder);
_DepWatcher.Dispose();
foreach (var depFolder in Configuration.Dependencies)
{
_DepWatcher.SetDirectoryWatcher(depFolder);
}
foreach (var intrinsicFolder in Configuration.Copies)
{
_DepWatcher.SetDirectoryWatcher(intrinsicFolder);
}
}
}

/// <summary>
/// The method is called in response to a MissingCopyNotification from the client.
/// The RemainingMissingCopies list can contain a list of COPY that the client fails to load,
/// or an empty list if all COPY have been loaded.
/// </summary>
/// <param name="fileUri">Uri of the document from wich the response is emitted</param>
/// <param name="RemainingMissingCopies">The list of unloaded COPY if any, an empty list otherwise</param>
public void UpdateMissingCopies(Uri fileUri, List<string> RemainingMissingCopies)
{
//TODO remove client to server notification properly.
if (_CopyWatcher == null)
{// No Copy Watcher ==> Refresh ourself opened file.
RefreshOpenedFiles();
}
}

/// <summary>
Expand Down