#16: add first implementation of tableEntry analyzer
parent
a27d344bbb
commit
9c1b890959
2 changed files with 39 additions and 0 deletions
@ -0,0 +1,38 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Collections.Immutable; |
||||||
|
using System.Linq; |
||||||
|
using System.Threading; |
||||||
|
using Microsoft.CodeAnalysis; |
||||||
|
using Microsoft.CodeAnalysis.CSharp; |
||||||
|
using Microsoft.CodeAnalysis.CSharp.Syntax; |
||||||
|
using Microsoft.CodeAnalysis.Diagnostics; |
||||||
|
|
||||||
|
namespace GBase.Diagnosis |
||||||
|
{ |
||||||
|
[DiagnosticAnalyzer(LanguageNames.CSharp)] |
||||||
|
public class GBaseTableEntryAnalyzer : DiagnosticAnalyzer |
||||||
|
{ |
||||||
|
private const string DIAGNOSTIC_ID = "GBaseTableEntryAnalyzer"; |
||||||
|
private const string CATEGORY = "GBaseTableEntryAnalyzer Category"; |
||||||
|
|
||||||
|
private static readonly LocalizableString _title = "Missing GBaseEntries for this GBaseTable"; |
||||||
|
private static readonly LocalizableString _messageFormat = "Type '{0}' is marked as GBaseTable but doesn't contain any GBase entries."; |
||||||
|
|
||||||
|
private static readonly DiagnosticDescriptor _rule = new DiagnosticDescriptor(DIAGNOSTIC_ID, _title, _messageFormat, CATEGORY, DiagnosticSeverity.Warning, true); |
||||||
|
|
||||||
|
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get { return ImmutableArray.Create(_rule); } } |
||||||
|
|
||||||
|
public override void Initialize(AnalysisContext context) |
||||||
|
{ |
||||||
|
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics); |
||||||
|
context.EnableConcurrentExecution(); |
||||||
|
context.RegisterSyntaxNodeAction(AnalyzeNode, SyntaxKind.Attribute); |
||||||
|
} |
||||||
|
|
||||||
|
private void AnalyzeNode(SyntaxNodeAnalysisContext context) |
||||||
|
{ |
||||||
|
AttributeSyntax attribute = (AttributeSyntax) context.Node; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue