Angular Modernizer
    Preparing search index...

    Recognizes and classifies Angular service patterns.

    • Uses ng-morph to detect @Injectable decorated classes
    • Falls back to ts-morph for suffix-based pattern matching
    • Provides confidence scores for classifications
    Index

    Constructors

    Methods

    • Classify a source file as a service pattern.

      Uses ng-morph to detect @Injectable, then analyzes class structure and naming to determine the specific service pattern.

      Parameters

      • sourceFile: SourceFile

        The source file to analyze

      Returns ServiceClassification

      Service classification result

      const classification = recognizer.classifyService(sourceFile);
      if (classification.pattern === ServicePattern.INJECTABLE) {
      console.info('This is an Angular service');
      }
    • Detect if a class is a service with confidence scoring.

      This method provides a more detailed analysis than isService(), including confidence levels and detection methodology.

      Parameters

      • classDecl: ClassDeclaration

        The class declaration to analyze

      Returns ServiceDetectionResult

      Service detection result with confidence and method

      const result = recognizer.detectService(classDecl);
      if (result.isService && result.confidence > 0.8) {
      console.info(`Detected service via ${result.detectionMethod}`);
      }
    • Get all service patterns in the source file.

      Some files may contain multiple service classes.

      Parameters

      • sourceFile: SourceFile

        The source file to analyze

      Returns ServiceClassification[]

      Array of service classifications

    • Check if a class declaration has the @Injectable decorator.

      Uses ng-morph adapter if available for enhanced detection, falls back to legacy ts-morph detection otherwise.

      Parameters

      • classDecl: ClassDeclaration

        The class declaration to check

      Returns boolean

      True if the class has @Injectable decorator

      if (recognizer.hasInjectableDecorator(classDecl)) {
      console.info('This is an Angular service');
      }
    • Simple check if a class is a service.

      This is a convenience method that wraps detectService() for backward compatibility with existing code.

      Parameters

      • classDecl: ClassDeclaration

        The class declaration to check

      Returns boolean

      True if the class is detected as a service

      if (recognizer.isService(classDecl)) {
      // Handle service class
      }
    • Check if a source file contains a service class.

      Quick check without full classification.

      Parameters

      • sourceFile: SourceFile

        The source file to check

      Returns boolean

      True if the file contains a service class

      if (recognizer.isServiceFile(sourceFile)) {
      // Perform service-specific analysis
      }