Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions MULTI_LANGUAGE_ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ class JavaScriptTransformer:

from pathlib import Path
from codeflash.languages.base import LanguageSupport, FunctionInfo, CodeContext
from codeflash.languages.treesitter_utils import TreeSitterAnalyzer
from codeflash.languages.javascript.treesitter import TreeSitterAnalyzer
from codeflash.languages.javascript.transformer import JavaScriptTransformer

class JavaScriptSupport(LanguageSupport):
Expand Down Expand Up @@ -523,7 +523,7 @@ class JavaScriptSupport(LanguageSupport):
# codeflash/languages/javascript/test_discovery.py

from pathlib import Path
from codeflash.languages.treesitter_utils import TreeSitterAnalyzer
from codeflash.languages.javascript.treesitter import TreeSitterAnalyzer

class JestTestDiscovery:
"""Static analysis-based test discovery for Jest."""
Expand Down
2 changes: 1 addition & 1 deletion codeflash/code_utils/code_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1772,7 +1772,7 @@ def _extract_calling_function_js(source_code: str, function_name: str, ref_line:

"""
try:
from codeflash.languages.treesitter_utils import TreeSitterAnalyzer, TreeSitterLanguage
from codeflash.languages.javascript.treesitter import TreeSitterAnalyzer, TreeSitterLanguage

# Try TypeScript first, fall back to JavaScript
for lang in [TreeSitterLanguage.TYPESCRIPT, TreeSitterLanguage.TSX, TreeSitterLanguage.JAVASCRIPT]:
Expand Down
4 changes: 2 additions & 2 deletions codeflash/code_utils/code_replacer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

from codeflash.discovery.functions_to_optimize import FunctionToOptimize
from codeflash.languages.base import Language, LanguageSupport
from codeflash.languages.treesitter_utils import TreeSitterAnalyzer
from codeflash.languages.javascript.treesitter import TreeSitterAnalyzer
from codeflash.models.models import CodeOptimizationContext, CodeStringsMarkdown, OptimizedCandidate, ValidCode

ASTNodeT = TypeVar("ASTNodeT", bound=ast.AST)
Expand Down Expand Up @@ -640,7 +640,7 @@ def _add_global_declarations_for_language(
return original_source

try:
from codeflash.languages.treesitter_utils import get_analyzer_for_file
from codeflash.languages.javascript.treesitter import get_analyzer_for_file

analyzer = get_analyzer_for_file(module_abspath)

Expand Down
2 changes: 1 addition & 1 deletion codeflash/code_utils/normalizers/javascript.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def normalize(self, code: str) -> str:

"""
try:
from codeflash.languages.treesitter_utils import TreeSitterAnalyzer, TreeSitterLanguage
from codeflash.languages.javascript.treesitter import TreeSitterAnalyzer, TreeSitterLanguage

lang_map = {"javascript": TreeSitterLanguage.JAVASCRIPT, "typescript": TreeSitterLanguage.TYPESCRIPT}
lang = lang_map.get(self._get_tree_sitter_language(), TreeSitterLanguage.JAVASCRIPT)
Expand Down
2 changes: 1 addition & 1 deletion codeflash/discovery/functions_to_optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def _is_js_ts_function_exported(file_path: Path, function_name: str) -> tuple[bo
Tuple of (is_exported, export_name). export_name may be 'default' for default exports.

"""
from codeflash.languages.treesitter_utils import get_analyzer_for_file
from codeflash.languages.javascript.treesitter import get_analyzer_for_file

try:
source = file_path.read_text(encoding="utf-8")
Expand Down
12 changes: 6 additions & 6 deletions codeflash/languages/javascript/find_references.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from tree_sitter import Node

from codeflash.discovery.functions_to_optimize import FunctionToOptimize
from codeflash.languages.treesitter_utils import ImportInfo, TreeSitterAnalyzer
from codeflash.languages.javascript.treesitter import ImportInfo, TreeSitterAnalyzer

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -112,7 +112,7 @@ def find_references(
List of Reference objects describing each call site.

"""
from codeflash.languages.treesitter_utils import get_analyzer_for_file
from codeflash.languages.javascript.treesitter import get_analyzer_for_file

function_name = function_to_optimize.function_name
source_file = function_to_optimize.file_path
Expand Down Expand Up @@ -168,7 +168,7 @@ def find_references(
if import_info:
# Found an import - mark as visited and search for calls
context.visited_files.add(file_path)
import_name, original_import = import_info
import_name, _original_import = import_info
file_refs = self._find_references_in_file(
file_path, file_code, function_name, import_name, file_analyzer, include_self=True
)
Expand Down Expand Up @@ -213,7 +213,7 @@ def find_references(
trigger_check = True
if import_info:
context.visited_files.add(file_path)
import_name, original_import = import_info
import_name, _original_import = import_info
file_refs = self._find_references_in_file(
file_path, file_code, reexport_name, import_name, file_analyzer, include_self=True
)
Expand Down Expand Up @@ -404,7 +404,7 @@ def _find_identifier_references(
name_node = node.child_by_field_name("name")
if name_node:
new_current_function = source_bytes[name_node.start_byte : name_node.end_byte].decode("utf8")
elif node.type in ("variable_declarator",):
elif node.type == "variable_declarator":
# Arrow function or function expression assigned to variable
name_node = node.child_by_field_name("name")
value_node = node.child_by_field_name("value")
Expand Down Expand Up @@ -719,7 +719,7 @@ def _find_reexports_direct(
continue

# Create a fake ImportInfo to resolve the re-export source
from codeflash.languages.treesitter_utils import ImportInfo
from codeflash.languages.javascript.treesitter import ImportInfo

fake_import = ImportInfo(
module_path=exp.reexport_source,
Expand Down
6 changes: 3 additions & 3 deletions codeflash/languages/javascript/import_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
if TYPE_CHECKING:
from codeflash.discovery.functions_to_optimize import FunctionToOptimize
from codeflash.languages.base import HelperFunction
from codeflash.languages.treesitter_utils import ImportInfo, TreeSitterAnalyzer
from codeflash.languages.javascript.treesitter import ImportInfo, TreeSitterAnalyzer

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -486,7 +486,7 @@ def _extract_helper_from_file(

"""
from codeflash.languages.base import HelperFunction
from codeflash.languages.treesitter_utils import get_analyzer_for_file
from codeflash.languages.javascript.treesitter import get_analyzer_for_file

try:
source = file_path.read_text(encoding="utf-8")
Expand Down Expand Up @@ -558,8 +558,8 @@ def _find_helpers_recursive(

"""
from codeflash.discovery.functions_to_optimize import FunctionToOptimize
from codeflash.languages.javascript.treesitter import get_analyzer_for_file
from codeflash.languages.registry import get_language_support
from codeflash.languages.treesitter_utils import get_analyzer_for_file

if context.current_depth >= context.max_depth:
return {}
Expand Down
2 changes: 1 addition & 1 deletion codeflash/languages/javascript/instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ def validate_and_fix_import_style(test_code: str, source_file_path: Path, functi
Fixed test code with correct import style.

"""
from codeflash.languages.treesitter_utils import get_analyzer_for_file
from codeflash.languages.javascript.treesitter import get_analyzer_for_file

# Read source file to determine export style
try:
Expand Down
2 changes: 1 addition & 1 deletion codeflash/languages/javascript/line_profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import logging
from typing import TYPE_CHECKING

from codeflash.languages.treesitter_utils import get_analyzer_for_file
from codeflash.languages.javascript.treesitter import get_analyzer_for_file

if TYPE_CHECKING:
from pathlib import Path
Expand Down
4 changes: 2 additions & 2 deletions codeflash/languages/javascript/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@

from codeflash.discovery.functions_to_optimize import FunctionToOptimize
from codeflash.languages.base import CodeContext, FunctionFilterCriteria, HelperFunction, Language, TestInfo, TestResult
from codeflash.languages.javascript.treesitter import TreeSitterAnalyzer, TreeSitterLanguage, get_analyzer_for_file
from codeflash.languages.registry import register_language
from codeflash.languages.treesitter_utils import TreeSitterAnalyzer, TreeSitterLanguage, get_analyzer_for_file
from codeflash.models.models import FunctionParent

if TYPE_CHECKING:
from collections.abc import Sequence

from codeflash.languages.base import ReferenceInfo
from codeflash.languages.treesitter_utils import TypeDefinition
from codeflash.languages.javascript.treesitter import TypeDefinition

logger = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ class ExportInfo:
reexport_source: str | None # Module path for re-exports
start_line: int
end_line: int
# Functions passed as arguments to wrapper calls in default exports
# e.g., export default curry(traverseEntity) -> ["traverseEntity"]
wrapped_default_args: list[str] | None = None


@dataclass
Expand Down Expand Up @@ -707,6 +710,7 @@ def _extract_export_info(self, node: Node, source_bytes: bytes) -> ExportInfo |
default_export: str | None = None
is_reexport = False
reexport_source: str | None = None
wrapped_default_args: list[str] | None = None

# Check for re-export source (export { x } from './other')
source_node = node.child_by_field_name("source")
Expand All @@ -726,6 +730,12 @@ def _extract_export_info(self, node: Node, source_bytes: bytes) -> ExportInfo |
default_export = self.get_node_text(sibling, source_bytes)
elif sibling.type in ("arrow_function", "function_expression", "object", "array"):
default_export = "default"
elif sibling.type == "call_expression":
# Handle wrapped exports: export default curry(traverseEntity)
# The default export is the result of the call, but we track
# the wrapped function names for export checking
default_export = "default"
wrapped_default_args = self._extract_call_expression_identifiers(sibling, source_bytes)
break

# Handle named exports: export { a, b as c }
Expand Down Expand Up @@ -773,8 +783,37 @@ def _extract_export_info(self, node: Node, source_bytes: bytes) -> ExportInfo |
reexport_source=reexport_source,
start_line=node.start_point[0] + 1,
end_line=node.end_point[0] + 1,
wrapped_default_args=wrapped_default_args,
)

def _extract_call_expression_identifiers(self, node: Node, source_bytes: bytes) -> list[str]:
"""Extract identifier names from arguments of a call expression.

For patterns like curry(traverseEntity) or compose(fn1, fn2), this extracts
the function names passed as arguments: ["traverseEntity"] or ["fn1", "fn2"].

Args:
node: A call_expression node.
source_bytes: The source code as bytes.

Returns:
List of identifier names found in the call arguments.

"""
identifiers: list[str] = []

# Get the arguments node
args_node = node.child_by_field_name("arguments")
if args_node:
for child in args_node.children:
if child.type == "identifier":
identifiers.append(self.get_node_text(child, source_bytes))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚡️Codeflash found 24% (0.24x) speedup for TreeSitterAnalyzer._extract_call_expression_identifiers in codeflash/languages/javascript/treesitter.py

⏱️ Runtime : 195 microseconds 157 microseconds (best of 165 runs)

📝 Explanation and details

The optimized code achieves a 23% runtime improvement (from 195μs to 157μs) by eliminating unnecessary function call overhead in a hot loop.

Key Optimization:

The critical change is inlining the text extraction operation for identifier nodes. Instead of calling self.get_node_text(child, source_bytes) for each identifier, the optimized version directly performs:

source_bytes[child.start_byte : child.end_byte].decode("utf8")

Why This Improves Runtime:

The line profiler reveals that in the original code, the identifiers.append(self.get_node_text(...)) line consumed 86.3% of total execution time (2.25ms out of 2.61ms). This is executed 1,008 times per test run, meaning each call has significant cumulative overhead:

  1. Method call overhead: Each self.get_node_text() invocation adds function call stack setup/teardown
  2. Attribute lookup: Accessing self.get_node_text requires traversing the instance's method resolution order
  3. Parameter passing: Copying child and source_bytes references to the new stack frame

By inlining, the optimized version reduces this hot path from 2.25ms to just 507μs (77% reduction), directly accounting for the overall speedup.

Test Case Performance:

The optimization shows particularly strong results for workloads with many identifiers:

  • Large-scale extraction (1000 identifiers): 25.6% faster (180μs → 143μs)
  • Special character identifiers: 15.7% faster
  • Single identifier: 12.3% faster
  • Edge cases (no arguments, non-identifiers): Minimal overhead, maintaining correctness

The get_node_text() method is preserved for potential use elsewhere in the codebase, but is bypassed in this performance-critical loop where the same operation can be performed inline without abstraction cost.

Correctness verification report:

Test Status
⚙️ Existing Unit Tests 🔘 None Found
🌀 Generated Regression Tests 9 Passed
⏪ Replay Tests 🔘 None Found
🔎 Concolic Coverage Tests 🔘 None Found
📊 Tests Coverage 100.0%
🌀 Click to see Generated Regression Tests
import pytest  # used for our unit tests
from codeflash.languages.javascript.treesitter import TreeSitterAnalyzer

# function to test
# We will create a minimal Node-like structure compatible with the attributes and methods
# used by TreeSitterAnalyzer._extract_call_expression_identifiers. We intentionally
# avoid using external parsing libraries to keep tests deterministic and focused.
class _DummyNode:
    """
    Minimal compatible stand-in for tree-sitter Node for testing purposes.

    NOTE: The real analyzer expects a Node with:
      - .type (str)
      - .children (list of nodes)
      - .start_byte (int), .end_byte (int) for slicing source bytes
      - .child_by_field_name(name) -> node or None

    We provide these attributes so the method under test can operate normally.
    """
    def __init__(self, type_, start_byte=0, end_byte=0, children=None, arguments_node=None):
        self.type = type_
        self.start_byte = start_byte
        self.end_byte = end_byte
        # children should be a list of other _DummyNode instances
        self.children = children or []
        # arguments_node is returned when child_by_field_name("arguments") is called
        self._arguments_node = arguments_node

    def child_by_field_name(self, name: str):
        # Only "arguments" is used by the method under test
        if name == "arguments":
            return self._arguments_node
        return None

# Helper factory functions to build nodes used by tests
def make_identifier_node(source_bytes: bytes, start: int, end: int):
    """Create an identifier node that slices source_bytes[start:end]."""
    return _DummyNode("identifier", start_byte=start, end_byte=end, children=[])

def make_arguments_node(children):
    """Create an arguments node that contains a list of child nodes."""
    return _DummyNode("arguments", children=children)

def make_call_node(arguments_node: _DummyNode):
    """Create a call_expression node whose 'arguments' field returns arguments_node."""
    # start/end bytes on call node are irrelevant for the extraction logic
    return _DummyNode("call_expression", children=[arguments_node], arguments_node=arguments_node)

# Create an analyzer instance without invoking __init__ to avoid requiring TreeSitterLanguage.
# This is acceptable because the method under test does not depend on instance initialization
# other than bound methods (get_node_text & _extract_call_expression_identifiers) existing.
analyzer = object.__new__(TreeSitterAnalyzer)

def test_single_identifier_argument_basic():
    # Basic case: curry(traverseEntity) -> should extract ["traverseEntity"]
    src = b"curry(traverseEntity)"
    # locate the identifier substring
    start = src.index(b"traverseEntity")
    end = start + len(b"traverseEntity")
    ident_node = make_identifier_node(src, start, end)  # identifier node for traverseEntity
    args = make_arguments_node([ident_node])  # arguments node wrapping the identifier
    call = make_call_node(args)  # top-level call_expression node

    # Call the method under test and verify the single identifier is extracted
    codeflash_output = analyzer._extract_call_expression_identifiers(call, src); result = codeflash_output # 1.64μs -> 1.46μs (12.3% faster)

def test_multiple_identifier_arguments_basic():
    # Basic case: compose(fn1, fn2) -> should extract ["fn1", "fn2"]
    src = b"compose(fn1, fn2)"
    # find positions of fn1 and fn2
    start1 = src.index(b"fn1")
    end1 = start1 + len(b"fn1")
    start2 = src.index(b"fn2")
    end2 = start2 + len(b"fn2")

    ident1 = make_identifier_node(src, start1, end1)
    ident2 = make_identifier_node(src, start2, end2)
    args = make_arguments_node([ident1, ident2])
    call = make_call_node(args)

    codeflash_output = analyzer._extract_call_expression_identifiers(call, src); result = codeflash_output # 1.80μs -> 1.71μs (5.25% faster)

def test_nested_call_expression_recursion():
    # Nested case: compose(curry(fn)) -> should extract ["fn"] by recursing into nested call_expression
    src = b"compose(curry(fn))"
    # locate fn
    start_fn = src.index(b"fn")
    end_fn = start_fn + len(b"fn")
    fn_node = make_identifier_node(src, start_fn, end_fn)

    # inner curry(...) arguments node contains fn identifier
    inner_args = make_arguments_node([fn_node])
    inner_call = _DummyNode("call_expression", children=[inner_args], arguments_node=inner_args)

    # outer compose(...) arguments node contains the inner call expression node
    outer_args = make_arguments_node([inner_call])
    outer_call = make_call_node(outer_args)

    codeflash_output = analyzer._extract_call_expression_identifiers(outer_call, src); result = codeflash_output # 1.96μs -> 1.90μs (3.21% faster)

def test_no_arguments_returns_empty_list():
    # If the call node has no 'arguments' field (child_by_field_name returns None), result should be []
    src = b"noArgsCall()"
    # create a call node that returns None for arguments
    call = _DummyNode("call_expression", children=[], arguments_node=None)

    codeflash_output = analyzer._extract_call_expression_identifiers(call, src); result = codeflash_output # 641ns -> 651ns (1.54% slower)

def test_non_identifier_arguments_are_ignored():
    # Arguments that are not identifiers (e.g., numeric literals) should be ignored
    src = b"call(42, 'string', { obj: 1 })"
    # create dummy children with types that are not "identifier"
    num_node = _DummyNode("number", start_byte=5, end_byte=7)  # "42"
    str_node = _DummyNode("string", start_byte=9, end_byte=17)  # "'string'"
    obj_node = _DummyNode("object", start_byte=19, end_byte=len(src))
    args = make_arguments_node([num_node, str_node, obj_node])
    call = make_call_node(args)

    codeflash_output = analyzer._extract_call_expression_identifiers(call, src); result = codeflash_output # 981ns -> 932ns (5.26% faster)

def test_special_character_identifiers():
    # Identifiers may include characters like ' and '_' commonly used in JS
    src = b"compose($fn, _fn)"
    start1 = src.index(b"$fn")
    end1 = start1 + len(b"$fn")
    start2 = src.index(b"_fn")
    end2 = start2 + len(b"_fn")

    id1 = make_identifier_node(src, start1, end1)
    id2 = make_identifier_node(src, start2, end2)
    args = make_arguments_node([id1, id2])
    call = make_call_node(args)

    codeflash_output = analyzer._extract_call_expression_identifiers(call, src); result = codeflash_output # 1.77μs -> 1.53μs (15.7% faster)

def test_empty_source_bytes_for_identifier():
    # If source_bytes is empty but nodes have start/end 0, the extracted identifier is an empty string
    # This tests boundary behavior of get_node_text slicing an empty buffer
    src = b""
    ident_node = make_identifier_node(src, 0, 0)  # zero-length slice
    args = make_arguments_node([ident_node])
    call = make_call_node(args)

    codeflash_output = analyzer._extract_call_expression_identifiers(call, src); result = codeflash_output # 1.34μs -> 1.25μs (7.27% faster)

def test_large_number_of_identifier_arguments_performance_and_correctness():
    # Large-scale test: create 1000 identifier arguments and ensure all are extracted in order
    count = 1000
    # Build a source like "f0,f1,f2,...,f999" to easily compute offsets
    identifiers = [f"f{i}" for i in range(count)]
    # Construct source bytes with comma separators
    src_str = ",".join(identifiers)
    src = src_str.encode("utf8")

    # Build identifier nodes with correct start/end positions
    children = []
    offset = 0
    for i, ident in enumerate(identifiers):
        b = ident.encode("utf8")
        start = offset
        end = start + len(b)
        children.append(make_identifier_node(src, start, end))
        # advance offset past the identifier and the comma (1 byte) except after the last
        offset = end + 1

    args = make_arguments_node(children)
    call = make_call_node(args)

    codeflash_output = analyzer._extract_call_expression_identifiers(call, src); result = codeflash_output # 180μs -> 143μs (25.6% faster)

def test_deeply_nested_multiple_levels():
    # Build nested calls like a(b(c(d(e(fn))))) and ensure the identifier is still found.
    src = b"a(b(c(d(e(fn)))))"
    # locate "fn"
    start_fn = src.index(b"fn")
    end_fn = start_fn + len(b"fn")
    fn_node = make_identifier_node(src, start_fn, end_fn)
    # Build inner-most call
    args_inner = make_arguments_node([fn_node])
    call_inner = _DummyNode("call_expression", children=[args_inner], arguments_node=args_inner)

    # Wrap with additional nested call_expression nodes multiple times
    level = call_inner
    nesting = 10  # modest depth to test recursion without hitting recursion limits
    for _ in range(nesting):
        args = make_arguments_node([level])
        level = _DummyNode("call_expression", children=[args], arguments_node=args)

    # Top-level call: pass into extractor
    top_call = level
    codeflash_output = analyzer._extract_call_expression_identifiers(top_call, src); result = codeflash_output # 4.24μs -> 4.04μs (4.98% faster)
# codeflash_output is used to check that the output of the original code is the same as that of the optimized code.

To test or edit this optimization locally git merge codeflash/optimize-pr1441-2026-02-10T21.37.43

Suggested change
identifiers.append(self.get_node_text(child, source_bytes))
identifiers.append(source_bytes[child.start_byte : child.end_byte].decode("utf8"))

Static Badge

# Also handle nested call expressions: compose(curry(fn))
elif child.type == "call_expression":
identifiers.extend(self._extract_call_expression_identifiers(child, source_bytes))

return identifiers

def _extract_commonjs_export(self, node: Node, source_bytes: bytes) -> ExportInfo | None:
"""Extract export information from CommonJS module.exports or exports.* patterns.

Expand Down Expand Up @@ -876,6 +915,7 @@ def is_function_exported(
"""Check if a function is exported and get its export name.

For class methods, also checks if the containing class is exported.
Also handles wrapped exports like: export default curry(traverseEntity)

Args:
source: The source code to analyze.
Expand All @@ -901,6 +941,11 @@ def is_function_exported(
if name == function_name:
return (True, alias if alias else name)

# Check wrapped default exports: export default curry(traverseEntity)
# The function is exported via wrapper, so it's accessible as "default"
if export.wrapped_default_args and function_name in export.wrapped_default_args:
return (True, "default")

# For class methods, check if the containing class is exported
if class_name:
for export in exports:
Expand Down Expand Up @@ -1580,9 +1625,9 @@ def get_analyzer_for_file(file_path: Path) -> TreeSitterAnalyzer:
"""
suffix = file_path.suffix.lower()

if suffix in (".ts",):
if suffix == ".ts":
return TreeSitterAnalyzer(TreeSitterLanguage.TYPESCRIPT)
if suffix in (".tsx",):
if suffix == ".tsx":
return TreeSitterAnalyzer(TreeSitterLanguage.TSX)
# Default to JavaScript for .js, .jsx, .mjs, .cjs
return TreeSitterAnalyzer(TreeSitterLanguage.JAVASCRIPT)
2 changes: 1 addition & 1 deletion codeflash/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# These version placeholders will be replaced by uv-dynamic-versioning during build.
__version__ = "0.20.0"
__version__ = "0.20.0.post510.dev0+b8932209"
10 changes: 5 additions & 5 deletions tests/test_languages/test_import_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import pytest

from codeflash.languages.javascript.import_resolver import HelperSearchContext, ImportResolver, MultiFileHelperFinder
from codeflash.languages.treesitter_utils import ImportInfo
from codeflash.languages.javascript.treesitter import ImportInfo


class TestImportResolver:
Expand Down Expand Up @@ -286,7 +286,7 @@ class TestExportInfo:
@pytest.fixture
def js_analyzer(self):
"""Create a JavaScript analyzer."""
from codeflash.languages.treesitter_utils import TreeSitterAnalyzer, TreeSitterLanguage
from codeflash.languages.javascript.treesitter import TreeSitterAnalyzer, TreeSitterLanguage

return TreeSitterAnalyzer(TreeSitterLanguage.JAVASCRIPT)

Expand Down Expand Up @@ -388,7 +388,7 @@ class TestCommonJSRequire:
@pytest.fixture
def js_analyzer(self):
"""Create a JavaScript analyzer."""
from codeflash.languages.treesitter_utils import TreeSitterAnalyzer, TreeSitterLanguage
from codeflash.languages.javascript.treesitter import TreeSitterAnalyzer, TreeSitterLanguage

return TreeSitterAnalyzer(TreeSitterLanguage.JAVASCRIPT)

Expand Down Expand Up @@ -470,14 +470,14 @@ class TestCommonJSExports:
@pytest.fixture
def js_analyzer(self):
"""Create a JavaScript analyzer."""
from codeflash.languages.treesitter_utils import TreeSitterAnalyzer, TreeSitterLanguage
from codeflash.languages.javascript.treesitter import TreeSitterAnalyzer, TreeSitterLanguage

return TreeSitterAnalyzer(TreeSitterLanguage.JAVASCRIPT)

@pytest.fixture
def ts_analyzer(self):
"""Create a TypeScript analyzer."""
from codeflash.languages.treesitter_utils import TreeSitterAnalyzer, TreeSitterLanguage
from codeflash.languages.javascript.treesitter import TreeSitterAnalyzer, TreeSitterLanguage

return TreeSitterAnalyzer(TreeSitterLanguage.TYPESCRIPT)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_languages/test_javascript_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ def test_find_jest_tests(self, js_support):
file_path = Path(f.name)

source = file_path.read_text()
from codeflash.languages.treesitter_utils import get_analyzer_for_file
from codeflash.languages.javascript.treesitter import get_analyzer_for_file

analyzer = get_analyzer_for_file(file_path)
test_names = js_support._find_jest_tests(source, analyzer)
Expand Down
Loading
Loading