Skip to content

Commit

Permalink
Set up dummy error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyRay committed Feb 9, 2016
1 parent 5b905ac commit 077f00a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 9 deletions.
43 changes: 36 additions & 7 deletions SemDiff.Core/Diagnostics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Threading;

namespace SemDiff.Core
{
Expand All @@ -10,25 +11,53 @@ namespace SemDiff.Core
/// </summary>
public class Diagnostics
{
//Shared Values
private const string Category = "Conflicts"; //Not sure where this shows up yet

//False-Negative
public const string FalseNegativeDiagnosticId = "SemDiffFN"; //Like the error code (just like missing semicolon is CS1002)

private const string FalseNegativeDescription = "False-Negatives occur text based tools fail to detect a conflict that affects the semantics of the application. i.e., when the semantics of a dependant item (a called method, a base class, a variable used) has been changed in a way that changes the runtime of the application when the changes are merged.";

private const string FalseNegativeMessageFormat = "False-Negatives for type '{0}' between '{1}' and '({2})[{3}]'";

private const string FalseNegativeTitle = "Possible False-Negative condition detected";

//False-Positive
public const string FalsePositiveDiagnosticId = "SemDiffFP";

private const string FalsePositiveDescription = "False-Positives occur text based tools detect a conflict that affects the semantics of the application. i.e., when merge conflicts may occur, but there are no semantic differences between the conflicting changes.";

private const string FalsePositiveMessageFormat = "False-Positive between '{0}' and '({1})[{2}]'";

private const string FalsePositiveTitle = "Possible False-Positive condition detected"; //Not sure where this comes up yet

//similar to fp
private static readonly DiagnosticDescriptor FalseNegative = new DiagnosticDescriptor(FalseNegativeDiagnosticId, FalseNegativeTitle, FalseNegativeMessageFormat, Category, DiagnosticSeverity.Warning, isEnabledByDefault: true, description: FalseNegativeDescription);

//0 is name of file, 1 is title of pull request, 2 is url of pull request //Actual error message text (formatable string)
//There is a option to show this in the error list for more info
private static readonly DiagnosticDescriptor FalsePositive = new DiagnosticDescriptor(FalsePositiveDiagnosticId, FalsePositiveTitle, FalsePositiveMessageFormat, Category, DiagnosticSeverity.Warning, isEnabledByDefault: true, description: FalsePositiveDescription);

/// <summary>
/// The Diagnostics we support, provided for the SupportedDiagnostics property of DiagnosticAnalyzer
/// </summary>
public static ImmutableArray<DiagnosticDescriptor> Supported { get; internal set; }
public static ImmutableArray<DiagnosticDescriptor> Supported { get; } = ImmutableArray.Create(FalsePositive, FalseNegative);

/// <summary>
/// Converts `DetectedFalsePositive`s to Diagnostics (the class provided by Roslyn) and sends them to the function provided
/// Converts `DetectedFalseNegative`s to Diagnostics (the class provided by Roslyn) and sends them to the function provided
/// </summary>
public static void Report(IEnumerable<DetectedFalsePositive> fps, Action<Diagnostic> reporter)
public static void Report(IEnumerable<DetectedFalseNegative> fps, Action<Diagnostic> reporter)
{
throw new NotImplementedException();
reporter(Diagnostic.Create(FalseNegative, Location.None, "FileName", @"dir\dir\FileName.cs", "My pull request title", "https://github.com/semdiffdotnet/semdiff/pull/33"));
}

/// <summary>
/// Converts `DetectedFalseNegative`s to Diagnostics (the class provided by Roslyn) and sends them to the function provided
/// Converts `DetectedFalsePositive`s to Diagnostics (the class provided by Roslyn) and sends them to the function provided
/// </summary>
public static void Report(IEnumerable<DetectedFalseNegative> fps, Action<Diagnostic> reporter)
public static void Report(IEnumerable<DetectedFalsePositive> fps, Action<Diagnostic> reporter)
{
throw new NotImplementedException();
reporter(Diagnostic.Create(FalsePositive, Location.None, @"dir\dir\FileName.cs", "My pull request title", "https://github.com/semdiffdotnet/semdiff/pull/33"));
}
}
}
4 changes: 2 additions & 2 deletions SemDiff.Core/SemDiffAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ private static void OnSyntaxTree(SyntaxTreeAnalysisContext context)
{
var filePath = context.Tree.FilePath;
var repo = Repo.GetRepoFor(filePath);
if (repo == null)
if (repo != null)
{
var fps = Analysis.ForFalsePositive(repo, context.Tree, filePath);
Diagnostics.Report(fps, context.ReportDiagnostic);
Expand All @@ -32,7 +32,7 @@ private static void OnSemanticModel(SemanticModelAnalysisContext context)
{
var filePath = context.SemanticModel.SyntaxTree.FilePath;
var repo = Repo.GetRepoFor(filePath);
if (repo == null)
if (repo != null)
{
var fns = Analysis.ForFalseNegative(repo, context.SemanticModel);
Diagnostics.Report(fns, context.ReportDiagnostic);
Expand Down

0 comments on commit 077f00a

Please sign in to comment.