예제 #1
0
 /// <summary>
 /// Generates a suitable Diagnostic from the given CompilerDiagnostic returned by the Q# compiler.
 /// The message range contained in the given CompilerDiagnostic is first converted to a Position object,
 /// and then added to the given positionOffset if the latter is not null.
 /// </summary>
 /// <exception cref="ArgumentOutOfRangeException">The contained range contains zero or negative entries, or its Start is bigger than its End.</exception>
 internal static Diagnostic Generate(string filename, QsCompilerDiagnostic msg, Position?positionOffset = null) =>
 new Diagnostic
 {
     Severity = Severity(msg),
     Code     = Code(msg),
     Source   = filename,
     Message  = msg.Message,
     Range    = ((positionOffset ?? Position.Zero) + msg.Range).ToLsp()
 };
예제 #2
0
 /// <summary>
 /// Generates a suitable Diagnostic from the given CompilerDiagnostic returned by the Q# compiler.
 /// The message range contained in the given CompilerDiagnostic is first converted to a Position object,
 /// and then added to the given positionOffset if the latter is not null.
 /// Throws an ArgumentNullException if the Range of the given CompilerDiagnostic is null.
 /// Throws an ArgumentOutOfRangeException if the contained range contains zero or negative entries, or if its Start is bigger than its End.
 /// </summary>
 internal static Diagnostic Generate(string filename, QsCompilerDiagnostic msg, Position positionOffset = null)
 {
     if (msg.Range == null)
     {
         throw new ArgumentNullException(nameof(msg.Range));
     }
     return(new Diagnostic
     {
         Severity = Severity(msg),
         Code = Code(msg),
         Source = filename,
         Message = msg.Message,
         Range = DiagnosticTools.GetAbsoluteRange(positionOffset, msg.Range)
     });
 }
예제 #3
0
 private static string Code(QsCompilerDiagnostic msg)
 {
     if (msg.Diagnostic.IsError)
     {
         return(Errors.Error(msg.Code));
     }
     else if (msg.Diagnostic.IsWarning)
     {
         return(Warnings.Warning(msg.Code));
     }
     else if (msg.Diagnostic.IsInformation)
     {
         return(Informations.Information(msg.Code));
     }
     else
     {
         throw new NotImplementedException("Hints are currently not supported - they need to be added to Diagnostics.fs in the QsLanguageProcessor, and here.");
     }
 }
예제 #4
0
 private static DiagnosticSeverity Severity(QsCompilerDiagnostic msg)
 {
     if (msg.Diagnostic.IsError)
     {
         return(DiagnosticSeverity.Error);
     }
     else if (msg.Diagnostic.IsWarning)
     {
         return(DiagnosticSeverity.Warning);
     }
     else if (msg.Diagnostic.IsInformation)
     {
         return(DiagnosticSeverity.Information);
     }
     else
     {
         throw new NotImplementedException("Hints are currently not supported - they need to be added to Diagnostics.fs in the QsLanguageProcessor, and here.");
     }
 }