github robotcodedev/robotcode v2.5.0

7 hours ago

Bug Fixes

  • robot: Strip trailing = from variable names in resource builder (e11ca60)

  • robot: Do not override the source on a model if there is already a source field (7e74c2d)

    Newer Robot Framework versions already set the source field on File AST blocks, so overriding it here is unnecessary.

  • robot: Resolve relative library paths in namespace cache validation (45d8f9f)

    Namespace cache validation failed for files importing libraries via
    relative paths (e.g. ../../resources/libraries/common.py), causing
    unnecessary full rebuilds on every warm start.

    Two issues fixed:

    • validate_namespace_meta now passes the source file's directory as
      base_dir when falling back to get_library_meta/get_variables_meta,
      so relative paths resolve correctly
    • get_library_meta and get_variables_meta initialize import_name
      before the try block to avoid UnboundLocalError when find_library
      or find_variables fails
  • robot: Correct check for init.py file in _is_valid_file function (ffad219)

  • robot: Add lock for _workspace_languages to prevent race condition (9bf0ee6)

    WeakKeyDictionary is not thread-safe for concurrent read/write.
    Protect all access to _workspace_languages with a dedicated RLock.

Documentation

  • news: Add supplementary release note for v2.5.0 (a8c39a3)

  • Update release notes for v2.5.0 with (9978a88)

  • Add news section to documentation site (7f14925)

    Add a dedicated news section for release announcements with
    auto-generated sidebar (sorted newest-first), content loader,
    and redirect from /news/ to the latest article.

Features

  • analyze: Add cache management CLI commands (1421107)

    Add robotcode analyze cache subcommand group with five commands:

    • path: print resolved cache directory
    • info: show cache statistics with per-section breakdown
    • list: list cached entries with glob pattern filtering (-p)
    • clear: remove cached entries by section
    • prune: delete entire .robotcode_cache directory

    Output adapts to the global --format flag (text/json/toml) and
    --no-color mode. Text output uses rich-rendered markdown tables
    when color is enabled, plain aligned tables otherwise.

  • analyze: Enable namespace caching by default (d896213)

    Namespace caching speeds up startup for large projects by skipping
    re-analysis of unchanged files. It is now mature enough to be enabled
    by default.

  • analyze: Add --cache-namespaces/--no-cache-namespaces CLI option (b050c32)

    Add option to enable/disable caching of fully analyzed namespace data
    to disk. Disabled by default until the cache is fully optimized and
    validated. When enabled, skips re-analysis of unchanged files on
    startup, which can significantly speed up large projects.

    Available as CLI flag (--cache-namespaces/--no-cache-namespaces),
    robot.toml setting (tool.robotcode-analyze.cache.cache_namespaces),
    and VS Code setting (robotcode.analysis.cache.cacheNamespaces).

  • analyze: Add collection of unused keywords and variables on the CLI (5734690)

    Add support for collecting unused keyword and variable diagnostics when
    running robotcode analyze code from the command line.

    The feature can be enabled in robot.toml:

    [tool.robotcode-analyze.code]
    collect-unused = true

    or controlled directly per invocation:

    robotcode analyze code --collect-unused
    robotcode analyze code --no-collect-unused
  • langserver: Add code completion for Literal type hint values (42ab3a0)

    Keywords with Literal["fast", "slow", "auto"] type hints now show
    their allowed values in the completion list, making it easier to
    discover and select valid argument values without checking the
    keyword documentation.

    Also supports Union types containing Literal, e.g.
    Union[Literal["x", "y"], int].

  • language_server: Add json to watched file extensions (74e92b0)

  • plugin: Add has_rich property to detect rich availability (4581cc6)

    Fall back to plain-text output in cache CLI commands when the rich
    package is not installed, instead of dumping raw unformatted markdown.

  • robot: Add ROBOTCODE_CACHE_DIR env var for cache path override (a778cd5)

    Enable redirecting the analysis cache to a custom directory via the
    ROBOTCODE_CACHE_DIR environment variable. This allows all RobotCode
    tools — CLI commands, analyze runs, and the language server — to
    share the same cache regardless of where it is stored.

    The VS Code extension automatically sets this variable in the
    integrated terminal, so CLI commands find the correct cache
    without any manual setup.

    Cache clearing now operates on the database directly instead of
    removing the directory, preventing errors when multiple processes
    access the cache concurrently.

  • robot: Add advisory file locking to SQLite cache (b9351fc)

    Add shared/exclusive advisory file locking (fcntl.flock) to prevent
    prune from deleting a cache database while another process (language
    server, analyze run) is using it.

  • robot: Add SQLite cache backend for library and namespace data (edaea47)

    Replace file-based pickle caching with a single SQLite database per
    workspace, consolidating all cache entries into one file instead of
    many individual .pkl files scattered across directories.

  • robot: Add namespace disk cache for cold-start acceleration (abf3387)

    Speed up first-time file analysis by caching fully resolved
    namespace results to disk. On subsequent IDE starts, cached
    namespaces are reused instead of re-analyzing every file from
    scratch, significantly reducing the time until diagnostics,
    code completion, and navigation become available.

    The cache is automatically invalidated when source files,
    library dependencies, environment variables, command-line
    variables, language configuration, or the RobotCode version
    change.

  • robot: Add ProjectIndex for O(1) workspace-wide reference lookups (6ef90f1)

    Add an incrementally maintained inverse reference index (ProjectIndex)
    scoped per WorkspaceFolder. On each file build, references are updated
    in-place instead of scanning all files. All six reference types are
    supported: keywords, variables, namespace entries, keyword tags,
    testcase tags, and metadata.

  • robot: Track tag and metadata references in namespace analysis (6a372fe)

    Add structured reference tracking for tags and metadata during analysis.
    Tags are split into keyword_tag_references and testcase_tag_references
    to reflect their different semantics in Robot Framework (keyword visibility
    vs test selection/reporting). Metadata references track settings-level
    metadata entries by key. All reference keys are normalized for consistent
    lookups. Remove unused TagDefinition class.

  • settings: Remove deprecated robocop configuration options (fa2217e)

  • vscode: Show "What's New" notification after extension update (7fb2071)

    Display an info notification when the extension version changes,
    linking to the news page on robotcode.io via the built-in Simple Browser.
    Also adds a public "RobotCode: Show What's New" command to the palette.

Performance

  • cache: Defer data blob loading in CacheEntry until first access (795c420)

  • diagnostics: Remove redundant exists() check in get_resource_meta (5696868)

  • diagnostics: Consolidate to single AST model and remove data_only parameter (e2e4cbd)

    This eliminates the second cached AST model per document, saving ~500KB/doc
    in CLI and ~200KB/doc in the Language Server. Releasing the model reference
    after analysis frees an additional ~100-500KB/doc in CLI mode.

  • imports: Cache get_module_spec results in ImportsManager (fa83b30)

  • robot: Patch RF's variable_not_found to skip slow RecommendationFinder (78a26c3)

    Robot Framework's variable_not_found() calls RecommendationFinder for
    fuzzy "Did you mean...?" suggestions on every unresolved variable. This
    is O(n*m) over all variable candidates and extremely slow for large
    projects (see #587: 30+ min for 375 files).

    RobotCode never uses the recommendation text — all VariableError catch
    sites either ignore the error or use it for unrelated diagnostics.

    The monkey-patch replaces variable_not_found in all 5 RF modules that
    import it (notfound, finders, evaluation, store, init) with a fast
    version that raises VariableError with just the base message.

  • robot: Speed up namespace cache loading with source hints and top-level-only imports (1d4ba6b)

    Add resolved_resource_sources to NamespaceData that maps import hint
    keys to resolved file paths. During from_data() re-resolution, these
    hints skip expensive find_resource() filesystem searches when the
    cached path still exists on disk.

    Also limit cached imports to top-level only (recursive imports are
    re-discovered during resolution), replace Path-based normalization
    with string-only os.path calls in imports_manager, and add a hint_key
    property to Import for consistent key computation.

  • robot: Fix ArgumentSpec.resolve() caching bug for RobotArgumentSpec (05142c8)

    The RobotArgumentSpec was recreated on every call (100K times) because:

    • hasattr() always returned False with @DataClass(slots=True)
    • Assignment went to a local variable instead of self

    RobotArgumentSpec.init calls: 100K → 1.3K (-98.7%)
    resolve cumtime: 3.93s → 3.29s (-0.64s)
    Warm no-NS total: 30.78s → 29.81s (-0.97s, -3.2%)

  • robot: Replace pathlib with os.path in file resolution (f3118bd)

    Replace pathlib.Path operations with os.path string functions
    in robot_path.py for significantly faster file resolution:

    • Use os.path.join/abspath/isfile/isdir instead of Path objects
    • Cache validated sys.path entries lazily (_get_valid_sys_path)
    • Separate basedir check from sys.path iteration
    • Introduce _PathLike type alias for cleaner signatures
    • Fix is_fifo() bug: use os.path.isfile() for init.py check

    Warm namespace-cache scenario: 19.30s -> 13.84s (-28.3%).
    Pathlib calls reduced by 78-100%, posix.stat calls by 35%.

  • robot: Cache KeywordMatcher and add dict-index to KeywordStore (5d21baf)

    • Cache KeywordMatcher on KeywordDoc via lazy-init _matcher slot,
      eliminating 7.5M redundant instantiations per analysis run
    • Add dict-index (_index + _embedded) to KeywordStore for O(1)
      keyword lookup by normalized name; linear scan only for embedded
      keywords
    • Add getstate/setstate to KeywordDoc and KeywordStore to
      exclude transient fields (_matcher, _index, _embedded, parent,
      _hash_value, _stable_id) from pickle serialization
    • Restore parent references in LibraryDoc.setstate via
      _update_keywords after deserialization
    • Remove unused nosave metadata from argument_definitions, parent,
      and keyword_doc fields
    • Fix Application.keyboard_interrupt to use self.exit() for
      consistent shutdown behavior

    Measured improvement (cProfile, 1065 Robot files):

    • Warm no-NS: 37.46s -> 29.25s (-22%)
    • Cold no-NS: 42.94s -> 33.39s (-22%)
    • Keyword matching: ~9.0s -> ~0.5s (-94%)
    • Function calls: 118M -> 81M (-31%)
  • robot: Optimize dataclass identity for ProjectIndex caching (deedd7b)

    Prepare VariableDefinition, KeywordDoc, and LibraryDoc for efficient
    use as dictionary keys in the upcoming ProjectIndex disk cache and
    cross-process worker communication.

Refactor

  • cache: Optimize SqliteDataCache with lazy deserialization and per-section tables (eeec613)

    Replace single cache_entries table with per-section tables (libdoc,
    variables, resource, namespace) for better query performance.

    Introduce CacheEntry with lazy meta/data deserialization — data blobs
    are only unpickled on cache hit, avoiding expensive deserialization on
    meta mismatch.

    Move version checking from per-entry meta_version field to DB-level
    app_version parameter. On version mismatch all tables are dropped and
    recreated automatically.

    Simplify cache API from 3 methods (cache_data_exists, read_cache_data,
    save_cache_data) to 2 (read_entry, save_entry), reducing DB
    round-trips from 3 to 1 for reads and 2 to 1 for writes.

    Remove filepath_base property (adler32 hash-based keys) from all
    metadata classes — cache keys now use source paths or library names
    directly.

  • diagnostics: Extract _run_in_subprocess and _save_import_cache helpers (0c347fd)

    • Unify duplicated ProcessPoolExecutor lifecycle from
      _get_library_libdoc and _get_variables_libdoc into _run_in_subprocess
    • Unify duplicated cache save logic into _save_import_cache
  • diagnostics: Deduplicate and optimize metadata classes in imports_manager (a0cb4c6)

    • Extract _collect_library_mtimes() to unify duplicated mtime collection
      from get_library_meta and get_variables_meta, using os.walk instead of
      Path.rglob for better performance
    • Extract _matches_any_pattern() to unify triplicated pattern matching
    • Add slots=True to LibraryMetaData, RobotFileMeta, and NamespaceMetaData
    • Move mtime collection into dataclass constructors to avoid post-init mutation
    • Remove unused itertools import
  • jsonrpc2: Harden resource lifecycle without del (5cb7bb7)

    • remove del-based resource cleanup from server, debugger client, and protocol
    • move shutdown to explicit close/close_async paths
    • make JsonRPCServer.close wait for server shutdown when safe
    • add best-effort weakref finalizers for forgotten cleanup without noisy warnings
    • unify runtime and finalizer bookkeeping into shared state objects
  • robot: Remove unnecessary type casting in CacheEntry (c4eb160)

  • robot: Optimize RF_VERSION checks with module-level dispatch (eec1627)

    • Remove redundant _ROBOT_VERSION alias in semantic_tokens.py
    • Remove always-true RF >= 5.0 guards (minimum supported version)
    • Use conditional class-level property/method definitions for
      is_private and is_reserved in library_doc.py
    • Add _RF7_PLUS module-level bool for BDD keyword search hot path
    • Move ExceptHeader/WhileHeader imports to top-level (always available)
  • robot: Replace Namespace getter methods with read-only properties (127ad65)

  • robot: Extract Namespace into DTO with event-driven invalidation (4f37419)

    Split the monolithic Namespace class into focused modules to reduce
    complexity and improve maintainability. The Namespace is now a pure data
    container built by NamespaceBuilder, with dedicated modules for import
    resolution, AST analysis, variable scoping, and scope trees.

  • Introduce RF_VERSION constant and remove RF < 5.0 dead code (02cf495)

    • Add module-level RF_VERSION constant to robotcode.robot.utils,
      resolved once at import time instead of repeated lru_cache lookups
    • Remove dead code paths for Robot Framework < 5.0 (no longer supported),
      including the internal tidy-based formatter and obsolete version branches
    • Replace all ~134 get_robot_version() call sites across 27 files with
      the RF_VERSION constant

Testing

  • namespace: Ensure mtime differs on coarse resolution filesystems (c2b6a79)
  • Add unit tests for SqliteDataCache backend functionality (f315426)
  • Improve resource file modification simulation for validation (a3107fd)
  • Improve mtime simulation for file modification in namespace validation (9a58278)

Don't miss a new robotcode release

NewReleases is sending notifications on new releases.