CodeLens Actions

Eight source-connected CodeLens integrations for routes, hooks, jobs, custom APIs, resources, metadata, cartridge paths, and logs

CodeLens places small, clickable actions above the code they describe. The VS Code extension supplies these actions using language-server indexes, project metadata, and log analysis. They connect a file to its registrations, callers, overrides, or runtime issues

Enable Editor: Code Lens in VS Code settings. Open the relevant source file and let its project data finish indexing

Routes and SFRA extensions

The lens row above an SFRA route copies or opens its storefront URL, lists the calls that reach it and jumps to the cartridges that append to it

On indexed SFRA, SiteGenesis, and pipeline endpoints, the extension offers:

  • Open Endpoint to open the route using the active connection and site context
  • Copy Endpoint URL to copy the resolved endpoint address
  • A usages count to inspect indexed callers
  • On SFRA routes, append, prepend, and replace counts when those actions have indexed targets

For example, start at a base server.get('Show', …) in Product.js, then use the append lens to find a cartridge extending Product-Show. The usages lens connects the route to calls such as URLUtils.url('Product-Show', …)

Opening a URL is a browser request, not a debugger session or a request editor. Routes requiring POST data or authentication still need the appropriate caller. Debugging is a separate workflow

Hook implementations

A script registered in hooks.json gets a lens naming the hook it implements. Click it to open the registration in hooks.json

A system hook's function shows the hook it implements, and every function of a custom hook shows hook → function. Click a lens to open its registration in hooks.json
ScriptLensExample
Implements a system hookThe hook namedw.order.calculate above exports.calculate
Implements a custom hookHook and exported functionapp.loyalty.points → redeem above exports.redeem

Every exported function of a custom hook script gets its own lens, which helps when one script serves several hook functions. See Typed hooks for the matching completion and type behavior

Job step functions

Step-type lenses link an implementation back to steptypes.json. The lens reads step type → property, and clicking it opens that property in steptypes.json

Each job step function shows the step type and the steptypes.json property that calls it. Click the lens to open that property
StepLens on the function
Task-oriented (script-module-step)custom.ExportOrders → function
Chunk-oriented (chunk-script-module-step)custom.ImportProducts → readFunction, processFunction, writeFunction

Chunk steps also label the optional totalCountFunction, beforeStepFunction, beforeChunkFunction, afterChunkFunction, and afterStepFunction. This lets you trace a helper-looking export back to the job-step contract that calls it

Custom API operations

Custom APIs span three files: api.json, an OpenAPI schema, and a script. Each file gets lenses that open the other two at the matching operation

api.json shows the method and the path of each endpoint, while the script and the schema link to the other two files. Each lens opens its target at the matching operation
FileLensOpens
api.jsonThe HTTP method, for example GET, above endpointThe exported function in the script
api.jsonThe schema path, for example /points, above schemaThe operation in the schema
Scriptschema.yaml and api.json above the exported functionThe operation in the schema, the endpoint in api.json
SchemaThe script name and api.json above the operationThe exported function, the endpoint in api.json

Completion and definition navigation for the same files are described in SFCC contracts

Resource keys

Every key in a .properties text editor shows how often scripts and templates use it and how many files of the bundle define it. Usages opens a peek, Localizations opens the Resource Bundle Editor on that key

Every key of a .properties file under cartridge/templates/resources gets two lenses in the text editor:

LensClick
N usagesPeeks the indexed Resource.msg and Resource.msgf calls of that key in scripts and templates
N localizationsOpens the Resource Bundle Editor with the key selected, so you can compare and edit every locale

The localizations count is the number of files of the bundle, across locales and cartridges, that define the key. Lenses show in the active editor only, and refresh as you type

A zero count describes the current local index. It does not prove a key is unused, because keys built at runtime are not counted

Metadata attributes

An attribute definition in metadata XML shows Indexing usages… while its usage data is being prepared, then an N usages lens. Click it to peek every reference to that attribute

Attribute definitions in metadata XML show how often code reads them. Click the count to peek every reference

Open Generated Metadata Types is a separate command and editor action, not a second CodeLens. It helps inspect the declarations generated from the active metadata document. See Metadata & generated types

Cartridge paths

The lens above a site's custom-cartridges or the Business Manager CustomCartridges preference opens the Cartridge Path Editor. Changes go into the XML document, ready for you to save

Cartridge path XML gets a lens that opens the Cartridge Path Editor:

FileElementLens
sites/<site>/site.xmlcustom-cartridgesEdit RefArch Cartridge Path (3)
preferences.xmlThe CustomCartridges preferenceEdit BM Cartridge Path (2)

The number is the cartridge count. Use the editor to add, remove, and reorder cartridges, then save the XML. The action is available on recognized cartridge-path metadata, not arbitrary colon-separated XML text

Log occurrences

Lines that analyzed logs point at show how often they failed. Open the event group in Log Center, or export it as a Markdown report

When log analysis maps an error to a local source line, that line gets two lenses:

  • SFCC Logs: N occurrences opens the event group in Log Center. When the occurrences come from more than one log file, the lens adds the file count, as in SFCC Logs: 3 occurrences in 2 files
  • Export SFCC log issue writes a Markdown report of that issue and opens its preview

These lenses depend on logs loaded or streamed into the extension and on source mapping. They are not produced by static type checking

Missing a lens?

Check that editor.codeLens is enabled, the file is saved where needed, and the source is linked to an indexed registration or metadata definition. Route URL actions additionally need an active target, and log lenses need analyzed log data. Follow Configuration & troubleshooting for the shared project checks

On this page