private static CommandOrCodeAction?DisableDiagnostic(DocumentUri documentUri, DiagnosticCode diagnosticCode, BicepFile bicepFile, TextSpan span, ImmutableArray <int> lineStarts) { if (diagnosticCode.String is null) { return(null); } var disabledDiagnosticsCache = bicepFile.DisabledDiagnosticsCache; (int diagnosticLine, _) = TextCoordinateConverter.GetPosition(bicepFile.LineStarts, span.Position); TextEdit?textEdit; int previousLine = diagnosticLine - 1; if (disabledDiagnosticsCache.TryGetDisabledNextLineDirective(previousLine) is { } disableNextLineDirectiveEndPositionAndCodes) { textEdit = new TextEdit { Range = new Range(previousLine, disableNextLineDirectiveEndPositionAndCodes.endPosition, previousLine, disableNextLineDirectiveEndPositionAndCodes.endPosition), NewText = ' ' + diagnosticCode.String }; }
/// <summary> /// Asserts that there is a diagnostic with the specified code and source location. /// If the assertion succeeded, returns an result object for further fluent assertions. /// </summary> public DiagnosticAssertResult AssertDiagnosticAt(DiagnosticCode code, TextPosition position) { var diagnostic = Diagnostics.SingleOrDefault(x => x.Code == code && x.Position == position); Assert.That(diagnostic, Is.Not.Null, $"The diagnostic {code} did not exist at " + $"({position.Line},{position.ByteInLine})"); return(new DiagnosticAssertResult(diagnostic)); }
/// <summary> /// Asserts that there is a diagnostic with the specified code and source location. /// If the assertion succeeded, returns an result object for further fluent assertions. /// </summary> public DiagnosticAssertResult AssertDiagnosticAt(DiagnosticCode code, int line, int offset) { var diagnostic = Diagnostics.SingleOrDefault(x => x.Code == code && x.Position.Line == line && x.Position.ByteInLine == offset); Assert.That(diagnostic, Is.Not.Null, $"The diagnostic {code} did not exist at ({line},{offset})"); return(new DiagnosticAssertResult(diagnostic)); }
public ActionResult Edit(DiagnosticCode diagnosticCode) { if (ModelState.IsValid) { _ctx.Entry(diagnosticCode).State = EntityState.Modified; _ctx.SaveChanges(); return(RedirectToAction("Index")); } return(View(diagnosticCode)); }
/// <summary> /// Creates a compilation diagnostic with diagnostic code and source position. /// </summary> /// <param name="code">The diagnostic code.</param> /// <param name="position">The position within the source file.</param> /// <param name="filename">The source file name (optional if no associated file).</param> /// <param name="moduleName">The module name.</param> /// <param name="actual">Optional actual value encountered.</param> /// <param name="expected">Optional expected value.</param> public Diagnostic(DiagnosticCode code, TextPosition position, string?filename, string moduleName, string?actual, string?expected) { Code = code; Position = position; Filename = filename; Module = moduleName; Actual = actual; Expected = expected; }
public void SimpleTest(string expected) { var model = new DiagnosticCode(); var result = Fixture.SerializeObject(model); result.Should().Be(expected); var deresult = JsonConvert.DeserializeObject <DiagnosticCode>(expected); deresult.ShouldBeEquivalentTo(model); }
public ActionResult DeleteDiagnoticCode(int id) { DiagnosticCode diagnosticCode = _ctx.DiagnosticCodes.Find(id); if (diagnosticCode != null) { _ctx.DiagnosticCodes.Remove(diagnosticCode); } _ctx.SaveChanges(); return(RedirectToAction("Index")); }
public void SimpleTest(string expected) { var model = new DiagnosticCode(); var result = Fixture.SerializeObject(model); result.Should().Be(expected); var deresult = new Serializer(ClientVersion.Lsp3).DeserializeObject <DiagnosticCode>(expected); deresult.Should().BeEquivalentTo(model); }
//Create DiagnosisCode public void CreateDiagnosisCode(DiagnosticCodeCreate model) { var entity = new DiagnosticCode() { Name = model.Name, ICD10Code = model.ICD10Code, Price = model.Price, DiagnosisId = model.DiagnosisId }; _ctx.DiagnosticCodes.Add(entity); _ctx.SaveChanges(); }
/// <summary> /// Eats a token and returns whether it is of the specified type. /// If it is not, additionally logs an error. /// </summary> /// <param name="expectedType">The expected token type.</param> /// <param name="errorCode">The error code to log if the token is not of the expected type.</param> private bool ExpectToken(TokenType expectedType, DiagnosticCode errorCode) { if (_lexer.PeekTokenType() == expectedType) { _lexer.GetToken(); return(true); } else { _diagnosticSink.Add(errorCode, _lexer.Position, ReadTokenIntoString()); return(false); } }
public static string ToDisplayString(this DiagnosticCode kind) { switch (kind) { case DiagnosticCode.UnrecognizedCharacter: return(DiagnosticsResources.UnrecognizedCharacter); case DiagnosticCode.UnterminatedStringLiteral: return(DiagnosticsResources.UnterminatedStringLiteral); case DiagnosticCode.UnexpectedTokenFound: return(DiagnosticsResources.UnexpectedTokenFound); case DiagnosticCode.UnexpectedEndOfStream: return(DiagnosticsResources.UnexpectedEndOfStream); case DiagnosticCode.UnexpectedStatementInsteadOfNewLine: return(DiagnosticsResources.UnexpectedStatementInsteadOfNewLine); case DiagnosticCode.UnexpectedTokenInsteadOfStatement: return(DiagnosticsResources.UnexpectedTokenInsteadOfStatement); case DiagnosticCode.TwoSubModulesWithTheSameName: return(DiagnosticsResources.TwoSubModulesWithTheSameName); case DiagnosticCode.TwoLabelsWithTheSameName: return(DiagnosticsResources.TwoLabelsWithTheSameName); case DiagnosticCode.GoToUndefinedLabel: return(DiagnosticsResources.GoToUndefinedLabel); case DiagnosticCode.PropertyHasNoSetter: return(DiagnosticsResources.PropertyHasNoSetter); case DiagnosticCode.AssigningNonSubModuleToEvent: return(DiagnosticsResources.AssigningNonSubModuleToEvent); case DiagnosticCode.UnassignedExpressionStatement: return(DiagnosticsResources.UnassignedExpressionStatement); case DiagnosticCode.InvalidExpressionStatement: return(DiagnosticsResources.InvalidExpressionStatement); case DiagnosticCode.UnsupportedArrayBaseExpression: return(DiagnosticsResources.UnsupportedArrayBaseExpression); case DiagnosticCode.ValueIsNotANumber: return(DiagnosticsResources.ValueIsNotANumber); case DiagnosticCode.UnsupportedDotBaseExpression: return(DiagnosticsResources.UnsupportedDotBaseExpression); case DiagnosticCode.ExpectedExpressionWithAValue: return(DiagnosticsResources.ExpectedExpressionWithAValue); case DiagnosticCode.LibraryMemberNotFound: return(DiagnosticsResources.LibraryMemberNotFound); case DiagnosticCode.UnexpectedArgumentsCount: return(DiagnosticsResources.UnexpectedArgumentsCount); case DiagnosticCode.UnsupportedInvocationBaseExpression: return(DiagnosticsResources.UnsupportedInvocationBaseExpression); case DiagnosticCode.LibraryMemberDeprecatedFromOlderVersion: return(DiagnosticsResources.LibraryMemberDeprecatedFromOlderVersion); case DiagnosticCode.LibraryMemberNeedsDesktop: return(DiagnosticsResources.LibraryMemberNeedsDesktop); default: throw ExceptionUtilities.UnexpectedValue(kind); } }
/// <summary> /// Eats a token and returns whether it is an identifier. /// If it is not, additionally logs an error. /// </summary> /// <param name="errorCode">The error code to log if the token is not an identifier.</param> /// <param name="identifier">The read identifier.</param> private bool ExpectIdentifier(DiagnosticCode errorCode, out string identifier) { if (_lexer.PeekTokenType() == TokenType.Identifier) { identifier = ReadTokenIntoString(); return(true); } else { _diagnosticSink.Add(errorCode, _lexer.Position, ReadTokenIntoString()); identifier = string.Empty; return(false); } }
private static DiagnosticDescriptor Rule(DiagnosticCode diagnosticCode, string title, Category category, DiagnosticSeverity defaultSeverity, LocalizableString messageFormat = null, LocalizableString description = null) { var diagnosticName = DiagnosticCodeMapping.GetOrAdd(diagnosticCode, d => d.ToString()); var categoryName = CategoryMapping.GetOrAdd(category, c => c.ToString()); return(new DiagnosticDescriptor( id: diagnosticName, title: title, messageFormat: messageFormat ?? title, category: categoryName, defaultSeverity: defaultSeverity, isEnabledByDefault: true, description: description)); }
private bool TryParseType(DiagnosticCode noIdentifierError, [NotNullWhen(true)] out TypeSyntax?type) { type = null; if (!ExpectIdentifier(noIdentifierError, out var typeName)) { return(false); } if (!NameParsing.IsValidFullName(typeName)) { _diagnosticSink.Add(DiagnosticCode.InvalidTypeName, _lexer.LastPosition, typeName); return(false); } type = new TypeNameSyntax(typeName, _lexer.LastPosition); return(true); }
private static DiagnosticDescriptor CreateDescriptor(DiagnosticCode code, string title, string messageFormat, DiagnosticSeverity severity = DiagnosticSeverity.Error) { string[] tags = severity == DiagnosticSeverity.Error ? new[] { WellKnownDiagnosticTags.NotConfigurable } : Array.Empty <string>(); return(new DiagnosticDescriptor(code.Format(), title, messageFormat, "RestEaseGeneration", severity, isEnabledByDefault: true, customTags: tags)); }
public void Add(DiagnosticCode code, TextPosition position) { _diagnostics.Add(new Diagnostic(code, position, _filename, _moduleName, null, null)); }
public void Add(DiagnosticCode code, TextPosition position, string?actual, string?expected) { var diagnostic = new Diagnostic(code, position, string.Empty, string.Empty, actual, expected); _diagnostics.Add(diagnostic); }
/// <summary> /// Format the code as e.g. REST001 /// </summary> public static string Format(this DiagnosticCode code) { return($"REST{(int)code:D3}"); }
private Token CreateBadToken (string spelling, DiagnosticCode code) { return new BadToken (spelling, code, position, Line, Column, FirstOnLine); }
protected void Error(DiagnosticCode diagnostic, FileLocation location) { ReceiveDiagnostic(new DiagnosticInfo(diagnostic, location), true); }
public Diagnostic(DiagnosticCode code, TextRange range, params string[] args) { this.Code = code; this.Range = range; this.args = args; }
public BadToken(string Spelling, DiagnosticCode Diagnostic, int StartCharacterPosition, int StartLine, int StartColumn, bool FirstOnLine) : base(Token.Type.Bad, StartCharacterPosition, StartLine, StartColumn, FirstOnLine) { this.Spelling = Spelling; this.Diagnostic = Diagnostic; }
public DiagMsg(DiagnosticCode code) { Code = code; _msgArgs = null; }
public I18nTextCompileException(DiagnosticCode code, string message, string filePath = null, int linePos = 0) : base(message) { this.Code = code; this.FilePath = filePath; this.LinePos = linePos; }
public void Add(DiagnosticCode code, TextPosition position, string?actual, string?expected) { _diagnostics.Add(new Diagnostic(code, position, _filename, _moduleName, actual, expected)); }
public DiagnosticFacts(DiagnosticCode code) { Description = Resources.ResourceManager.GetString("DESCRIPTION_" + code.ToString()); Enum.TryParse <Severity>(Resources.ResourceManager.GetString("SEVERITY_" + code.ToString()), out var severity); Severity = severity; }
/// <summary> /// Initialises a new instance of the <see cref="ImplementationCreationException"/> class /// </summary> /// <param name="code">Code of this error</param> /// <param name="message">Message to use</param> public ImplementationCreationException(DiagnosticCode code, string message) : base(message) { this.Code = code; }
public void Add(DiagnosticCode code, TextPosition position) { DiagnosticCount++; }
public static void ReceiveDiagnostic(this IDiagnosticReceiver receiver, DiagnosticCode code, FileLocation?location, bool isError) => receiver.ReceiveDiagnostic(new DiagnosticInfo(code, location), isError);
public void Add(DiagnosticCode code, TextPosition position, string?actual, string?expected) { DiagnosticCount++; }
public void Add(DiagnosticCode code, TextPosition position) { var diagnostic = new Diagnostic(code, position, string.Empty, string.Empty, null, null); _diagnostics.Add(diagnostic); }
private void Error (DiagnosticCode code , TextSpan loc) { if (current.Kind == Token.Type.Bad) code = ((BadToken)current).Diagnostic; diagnostics.Add (new Diagnostic (code, loc)); }
public Diagnostic(DiagnosticCode Code, TextSpan Location) { this.Code = Code; this.Location = Location; }
public DiagMsg(DiagnosticCode code, params string[] msgArgs) { Code = code; _msgArgs = msgArgs; }