Skip to content

Commit

Permalink
WI #2605 Code review
Browse files Browse the repository at this point in the history
  • Loading branch information
efr15 committed Jan 11, 2024
1 parent ad3b2f9 commit 56e95d4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
20 changes: 5 additions & 15 deletions TypeCobol.LanguageServer/TypeCobolServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using TypeCobol.Compiler.Preprocessor;
using TypeCobol.LanguageServer.Context;
using TypeCobol.LanguageServer.SignatureHelper;
using TypeCobol.LanguageServer.Utilities;
using TypeCobol.Tools;

using Range = TypeCobol.LanguageServer.VsCodeProtocol.Range;
Expand Down Expand Up @@ -89,7 +90,7 @@ private bool Logger(string message, Uri uri)
{
type = MessageType.Log,
message = message,
textDocument = new TextDocumentIdentifier(GetOriginalUri(uri))
textDocument = new TextDocumentIdentifier(uri.GetOriginalUri())
};
this.RpcServer.SendNotification(UriLogMessageNotification.Type, uriLogMessageParams);
}
Expand Down Expand Up @@ -187,7 +188,7 @@ private void MissingCopiesDetected(object fileUri, MissingCopiesEvent missingCop
//This event can be used when a dependency have not been loaded

//Send missing copies to client
MissingCopiesDetected(new TextDocumentIdentifier(GetOriginalUri((Uri)fileUri)), missingCopiesEvent.Copies);
MissingCopiesDetected(new TextDocumentIdentifier(((Uri)fileUri).GetOriginalUri()), missingCopiesEvent.Copies);
}

/// <summary>
Expand All @@ -207,7 +208,8 @@ private void DiagnosticsDetected(object fileUri, DiagnosticEvent diagnosticEvent
diag.Info.ReferenceText));
}

diagParameter.uri = GetOriginalUri((Uri)fileUri);
diagParameter.uri = ((Uri)fileUri).GetOriginalUri();
//diagParameter.uri = fileUri.ToString();
diagParameter.diagnostics = diagList.ToArray();
this.RpcServer.SendNotification(PublishDiagnosticsNotification.Type, diagParameter);
}
Expand Down Expand Up @@ -239,18 +241,6 @@ protected DocumentContext GetDocumentContextFromStringUri(string uri, Workspace.
return null;
}

/// <summary>
/// Gets the original URI (which was set by the client)
/// DON'T use ToString() as it returns the canonically unescaped form of the URI
/// (it may cause issue if the path contains some blanks which need to be escaped)
/// </summary>
/// <param name="uri"></param>
/// <returns></returns>
private static string GetOriginalUri(Uri uri)
{
return uri.OriginalString;
}

/// <summary>
/// Creates workspace and returns language server capabilities.
/// </summary>
Expand Down
12 changes: 12 additions & 0 deletions TypeCobol.LanguageServer/Utilities/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,17 @@ public static string ToLanguageServerOption(this LsrTestingOptions lsrOptions)
return "";
}
}

/// <summary>
/// Gets the original URI (which was set by the client)
/// DON'T use ToString() as it returns the canonically unescaped form of the URI
/// (it may cause issue if the path contains some blanks which need to be escaped)
/// </summary>
/// <param name="uri"></param>
/// <returns></returns>
public static string GetOriginalUri(this Uri uri)
{
return uri.OriginalString;
}
}
}

0 comments on commit 56e95d4

Please sign in to comment.