module Analyzer::Dart::Helper

Overview

Shared helpers for the Dart framework analyzers (Dart Frog, Shelf, Serverpod). Kept framework-agnostic so each analyzer can opt in without duplicating path/string conventions.

Extended Modules

Defined in:

analyzer/analyzers/dart/dart_helper.cr

Instance Method Summary

Instance Method Detail

def extract_string_literal(text : String) : String | Nil #

Pull the contents of a leading single/double-quoted string literal from an argument expression, honouring backslash escapes. Returns nil when the expression doesn't start with a string literal.


[View source]
def strip_comments(text : String) : String #

Replace // line and /* */ block comments with spaces, leaving string literals and overall byte offsets intact so downstream regex/offset logic still lines up with the original source.


[View source]
def test_path?(path : String, base_path : String | Nil = nil) : Bool #

Standard Dart test-file conventions. The Dart tooling discovers tests under a project-root test/ directory and via the *_test.dart suffix; neither ever serves real traffic. Dart Frog in particular mirrors the route tree under test/routes/, so a naive /routes/ match would surface every mock handler as a live endpoint. Centralized so every Dart analyzer can opt in via next if Helper.test_path?(path, base_paths).

  • /test/, test/ — Dart's dart test discovery root and the Dart Frog test/routes/ mirror tree
  • *_test.dart — the canonical Dart unit-test suffix

[View source]
def test_path?(path : String, base_paths : Array(String)) : Bool #

[View source]