Exemple #1
0
 public RegexPatternDetector(
     SemanticModel semanticModel,
     RegexEmbeddedLanguage langauge,
     INamedTypeSymbol regexType,
     HashSet <string> methodNamesOfInterest)
 {
     _language              = langauge;
     _semanticModel         = semanticModel;
     _regexType             = regexType;
     _methodNamesOfInterest = methodNamesOfInterest;
 }
Exemple #2
0
        public static RegexPatternDetector TryGetOrCreate(
            SemanticModel semanticModel, RegexEmbeddedLanguage language)
        {
            // Do a quick non-allocating check first.
            if (_modelToDetector.TryGetValue(semanticModel, out var detector))
            {
                return(detector);
            }

            return(_modelToDetector.GetValue(
                       semanticModel, _ => TryCreate(semanticModel, language)));
        }
        public RegexDiagnosticAnalyzer(RegexEmbeddedLanguage language)
        {
            _language = language;

            _descriptor = new DiagnosticDescriptor(DiagnosticId,
                                                   new LocalizableResourceString(nameof(WorkspacesResources.Regex_issue_0), WorkspacesResources.ResourceManager, typeof(WorkspacesResources)),
                                                   new LocalizableResourceString(nameof(WorkspacesResources.Regex_issue_0), WorkspacesResources.ResourceManager, typeof(WorkspacesResources)),
                                                   category: "REGEX",
                                                   DiagnosticSeverity.Warning,
                                                   isEnabledByDefault: true);

            SupportedDiagnostics = ImmutableArray.Create(_descriptor);
        }
Exemple #4
0
        private static RegexPatternDetector TryCreate(
            SemanticModel semanticModel, RegexEmbeddedLanguage language)
        {
            var regexType = semanticModel.Compilation.GetTypeByMetadataName(typeof(Regex).FullName);

            if (regexType == null)
            {
                return(null);
            }

            var methodNamesOfInterest = GetMethodNamesOfInterest(regexType, language.SyntaxFacts);

            return(new RegexPatternDetector(
                       semanticModel, language, regexType, methodNamesOfInterest));
        }
Exemple #5
0
 public RegexEmbeddedBraceMatcher(RegexEmbeddedLanguage language)
 {
     _language = language;
 }
 public RegexEmbeddedHighlighter(RegexEmbeddedLanguage language)
 {
     _language = language;
 }
Exemple #7
0
 public RegexEmbeddedClassifier(RegexEmbeddedLanguage language)
 {
     _language = language;
 }