Code Vision

Code Vision lenses above routes, hooks, step types, custom APIs and cartridge paths link each one to its declaration, usages and endpoint

Code Vision puts a grey line of links above your SFCC code. Above a controller route you can open or copy its storefront URL, list the places that call it and jump to the cartridges that extend it. Above a hook, step type or custom API function a lens opens its declaration, and the lens in site.xml opens the Cartridge Path Editor. The lenses come from the plugin's own indexes, the same ones behind B2C Entry Points

Above a route, lenses open or copy its storefront URL, list its usages and the cartridges that extend it. Hook, step type and custom API lenses open their declarations, and the lens in site.xml edits the cartridge path

Lens groups

Each kind of lens is a group in Settings › Editor › Inlay Hints › Code vision. Uncheck a group to hide its lenses and check it to bring them back

GroupLenses
SFCC routesOpen Endpoint, Copy Endpoint URL, the usage count and the SFRA prepend, append and replace targets of each controller route and pipeline start node, see Routes
SFCC hooksThe hooks.json declaration of each hook function, see Hooks
SFCC step typesThe steptypes.json declaration of each step type function, see Step types
SFCC custom APIsLinks between a custom API's script, its schema.yaml operations and its api.json endpoints, see Custom APIs
SFCC cartridge pathEdit cartridge path above the cartridge path of a site or of Business Manager, see Cartridge path

The lenses of templates, such as the usage count and Rendered by, are in the ISML group, see ISML navigation

Which files have lenses

Lenses show in the local files of your linked cartridges, see Cartridges & Modules

  • Scripts (.js, .ds and .ts), .json files and .yaml or .yml files
  • Pipeline XML under cartridge/pipelines
  • Route lenses in a script need the file under cartridge/controllers

Files in a node_modules, test, __test__ or __tests__ folder, under cartridge/client or cartridge/static, in a folder whose name starts with a dot, and files with .test. in their name have no lenses. Every lens needs a valid license or trial

Routes

Every route a controller declares gets a row of lenses, in this order

LensExampleClick
Open Endpoint Open EndpointOpens the route on the active connection in your browser, see Open Endpoint and Copy Endpoint URL
Copy Endpoint URLCopy Endpoint URLCopies the same URL
Usages5 usagesLists the places that call the route, see Usages
SFRA targetsprepend (1), append (2), replace (1)Lists the cartridges that extend the route, see SFRA extensions

The usage lens shows 0 usages too. An SFRA target lens shows only when another declaration of the route uses that method

Open Endpoint and Copy Endpoint URL

Both build the storefront URL of the route from the active connection and the site selected in the Site Scope widget, for example https://zzrf-001.dx.commercecloud.salesforce.com/on/demandware.store/Sites-RefArch-Site/default/Cart-Show. Hover Open Endpoint to see Open Cart-Show on the active connection in the browser. After a copy, a hint shows Copied and the URL

When the URL can't be built, an error hint says why

HintWhat to do
Select an active connection to open endpointsPick an active connection, see Switch the active connection
Select a site in the Site Scope widget to open endpointsPick a site in the Site Scope widget. Global has no storefront URL
This route has no nameThe declaration has an empty route name. Give it one

Usages

The usage lens counts the places in your linked cartridges that reference the route. Hover it to see Show where Cart-Show is used

  • Route arguments of calls in scripts, ISML templates and cartridge XML outside cartridge/forms, such as URLUtils.url('Cart-Show'). Which calls count follows the route call rules, so a helper you add in SFCC Route Calls counts too
  • <iscomponent pipeline="Cart-Show"> in templates
  • The start node a pipeline call node or jump node calls
  • <exec pipeline="..." node="..."> in other cartridge XML

Click the lens and a list titled Cart-Show: 5 usages opens. Each row shows the file type icon, the file name and, in grey, the line number and the code on that line. The rows follow the file path. Type to filter them, and press Enter or click a row to open the code at the route. A single usage opens right away, and with none a hint shows No usages of Cart-Show

SFRA extensions

On an SFRA route, the prepend, append and replace lenses count the other declarations of the same route that use that method, such as server.append('Show', ...) in app_custom for the Cart-Show of app_storefront_base. Hover a lens to see Cartridges that call server.append for Cart-Show

Click it and a list titled server.append for Cart-Show opens with the cartridge in bold at the start of each row. A single target opens right away. A target opens at the quote of its route name

The targets follow the cartridge path of the site selected in the Site Scope widget, and cartridges outside that path drop out. With Global scope, or a site without cartridges, every target shows in project order. Targets in the same position follow the cartridge name, then the file path

Pipeline start nodes

Open a pipeline's XML with Show Pipeline Source from the right-click menu of the file. Each named start node gets Open Endpoint, Copy Endpoint URL and the usage lens above its <branch>. Private start nodes get them too. SiteGenesis controller routes get the same three lenses. A start node or SiteGenesis route declared twice in one file gets one row, above its first declaration

Hooks

A script that hooks.json names as a hook script gets a lens above its hook functions

  • For a Salesforce hook point, such as dw.order.calculate, the lens sits above the function named after the last part of the hook name, calculate, and reads the hook name, dw.order.calculate
  • For a custom hook, every exported function gets a lens with the hook and the function, such as app.loyalty.points.earn → earn

Hover a lens to see Open the hooks.json declaration in int_loyalty, with the cartridge of that hooks.json. Click it and hooks.json opens with the hook's whole entry selected, from { to }

Step types

A module that a step type in steptypes.json runs gets a lens above each function the step type names. It reads the step type ID and the key that names the function, such as custom.Loyalty-SyncMembers → readFunction. A script step that names no function gets its lens on execute, and the click opens its @type-id

Key in steptypes.jsonLens
functionfunction
read-functionreadFunction
process-functionprocessFunction
write-functionwriteFunction
total-count-functiontotalCountFunction
before-step-functionbeforeStepFunction
before-chunk-functionbeforeChunkFunction
after-chunk-functionafterChunkFunction
after-step-functionafterStepFunction

A function gets one lens, from the first step type that names it in cartridge order. Hover it to see Open the steptypes.json declaration in int_loyalty, and click it to open steptypes.json at the function name

Custom APIs

The api.json, schema.yaml and script of a custom API link to each other. Each lens opens one file, and its tooltip names it, such as Open schema.yaml

FileLineLensOpens
api.jsonendpointThe method of each operation, such as GET The function of the script, also when the script registers it with app.handle
api.jsonschemaThe path of each operation, such as /members/{memberId}/pointsThe operation in schema.yaml
schema.yamlEach operation, such as get:The script name, such as script.js , and api.jsonThe function of the script, or the endpoint in api.json
ScriptThe endpoint functionschema.yaml and api.jsonThe operation in schema.yaml, or the endpoint in api.json

Lenses link files of the same cartridge only

Cartridge path

In a site.xml, the <custom-cartridges> element directly under <site> gets a lens such as Edit cartridge path: RefArch (3), with the site-id of the site, or Site without one, and the number of cartridges on the path. In a preferences.xml, <preference preference-id="CustomCartridges"> gets Edit cartridge path: Business Manager (2)

Hover the lens to see Edit Cartridge Path, and click it to open the Cartridge Path Editor for that path. Unlike the other lenses, this one stays while the IDE indexes

Several lenses on one line

When two lenses of the same kind land on one line, they share it, joined by ·. A script that serves both dw.order.calculate and a custom hook shows dw.order.calculate · app.loyalty.points.earn → calculate above calculate. A shared lens has no tooltip, and a click opens a list of the lenses to choose from

When lenses refresh

  • The file you edit updates its lenses as the IDE checks it
  • A change elsewhere, such as in a hooks.json, a steptypes.json, an api.json, the routes of another cartridge or a file changed outside the IDE, updates the other open files about 300 ms after the last change. Only the files whose lenses changed redraw
  • Choosing another site in the Site Scope widget redraws the lenses of every open file, so the SFRA targets follow the new cartridge path
  • The route, hook, step type and custom API lenses hide while the IDE indexes and come back when it finishes

Troubleshooting

SymptomWhat to do
No lenses at allCheck that the license or trial is valid and that the file is in a linked cartridge, see Which files have lenses. Check the group in Settings › Editor › Inlay Hints › Code vision
The lenses disappeared for a momentThe IDE is indexing. They come back when it finishes
A controller has no route lensesThe file has to be under cartridge/controllers
Open Endpoint shows a hint instead of the browserPick an active connection and a site in the Site Scope widget, see Open Endpoint and Copy Endpoint URL
A usage count is lower than expectedCalls through your own helper count only with a rule in SFCC Route Calls. Files outside linked cartridges don't count
An append lens is missingThe other cartridge isn't on the selected site's cartridge path. Select Global in the Site Scope widget to see every cartridge
A hook function has no lensFor a Salesforce hook point, the function has to be named after the last part of the hook name
A click shows File not found and a pathThe file moved or was deleted since the lens was drawn. Edit the file or reopen it to refresh the lenses

On this page