Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Better Go to Definition for SalesforceNew to Visual Studio Code? Get it now.
Better Go to Definition for Salesforce

Better Go to Definition for Salesforce

Kaz Schmanski

| (0) | Free
Enhanced go to definition/navigation for JavaScript/TypeScript + Salesforce Apex & LWC modules with smart fallbacks.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Better Go To Definition for Salesforce

Enhanced go to definition/navigation for Apex and JavaScript/TypeScript in Salesforce repos (Apex imports & LWC modules) plus same-file JS method jumps, with graceful fallbacks and an inline ephemeral message when nothing is found.

Quick Install

  1. Get the packaged VSIX (e.g. better-go-to-definition-0.0.1.vsix).
  2. VS Code Command Palette → Extensions: Install from VSIX... → choose the file.
  3. Place cursor inside a method invocation and press Cmd+Alt+V (macOS) / map a key on other platforms.
  4. If nothing found you’ll see an inline decoration above the current line.

Key behaviors:

  • Same-file JS/TS navigation (function declarations and object/class shorthand methods)
  • Apex import navigation (from @salesforce/apex/Class.method imports to the Apex .cls file)
  • Simple cross-class Apex method resolution (ClassName.methodName())
  • LWC module import resolution (import { foo } from 'c/utils')
  • Fallback that avoids jumping into TypeScript lib .d.ts files
  • Ephemeral inline decoration for “No definition found” (unobtrusive)

Command: Go to Definition (Better) (better-go-to-definition.betterGoToMethod). Default keybinding: Cmd+Alt+B (macOS).

Features

Feature Description
Same-file JS/TS definition jump Finds function name( and name(...) { shorthand methods.
Apex import navigation From JS import: import myFn from '@salesforce/apex/MyClass.myFn' -> opens MyClass.cls and selects method.
LWC module navigation Resolves symbols imported from 'c/<module>' to module file and export definition.
Cross-class Apex call Detects ClassName.methodName() in non-JS files and opens method declaration.
Built-in/global symbol handling Suppresses navigation to TypeScript lib definitions (lib.dom.d.ts, etc).
Fallback UX Ephemeral inline decoration above cursor line (auto-clears).
Ephemeral inline message Non-blocking decoration one line above cursor that auto-removes after ~2.5s.

Ephemeral Inline Message

When navigation fails, an inline decoration appears above the cursor line (default text: No workspace definition found). This is less intrusive than a toast message.

Requirements

No external runtime requirements. Pure TypeScript extension.

For Apex/LWC navigation to work, your workspace should include Salesforce project structure (e.g. force-app/main/default/lwc/<module>/<module>.js and Apex class files). If absent, those features quietly skip.

Extension Settings

No user-editable settings at this time. (Previous experimental flag removed for simplicity.)

Known Issues

  • The inline banner relies on a temporary empty definition provider; if other extensions race results you might occasionally see a peek panel instead.
  • Navigation logic is textual (regex/string search); edge cases (minified code, unconventional formatting) may not resolve.
  • Cross-class Apex resolution is simple and may fail for nested/inner classes.

Release Notes

0.0.x

  • Initial prototype with JS same-file, Apex import, LWC module, cross-class Apex, and configurable fallback.
  • Added ephemeral inline decoration feature.

Planned

  • Built-in tests for suppression of lib definitions.
  • Setting to choose between decoration and status bar.

Packaging & Distribution

1. Install VSCE (Publishing/Packaging Tool)

npm install -g @vscode/vsce

2. Bump Version

Update package.json version field (e.g. 0.0.2). Commit the change.

3. Create a .vsix Package

From the extension root:

vsce package

Generates better-go-to-definition-0.0.2.vsix (name includes current version).

Bundling: The extension is bundled with esbuild (output in dist/) to reduce install size and startup overhead. Development sources (src/), tests, and Salesforce project artifacts are excluded via .vscodeignore.

4. Share with Teammates

Distribute the .vsix file via internal repo, artifact store, or chat.

5. Install Locally

In VS Code:

  • Command Palette → Extensions: Install from VSIX... → select the file
  • Or CLI:
code --install-extension better-go-to-definition-0.0.2.vsix

6. Uninstall / Update

  • Uninstall: Command Palette → Extensions: Show Installed Extensions, find the extension, uninstall.
  • Update: Re-run vsce package after version bump and reinstall the new .vsix.

7. Optional: Publish to Marketplace

If later desired:

  1. Create a publisher: vsce create-publisher <publisherName>
  2. Add publisher field to package.json.
  3. Acquire a Personal Access Token (Azure DevOps) scoped for Marketplace.
  4. vsce publish patch (or minor, major).

Installation Instructions (Summary for Teammates)

  1. Obtain .vsix file (e.g. from internal share).
  2. Open VS Code → Command Palette → Extensions: Install from VSIX....
  3. Set optional settings in settings.json:
    {
      "betterGoToDefinition.preferInlineBanner": false
    }
    
  4. Use Cmd+Alt+V (macOS) on a symbol or Apex import line to navigate.

Usage Tips

  • If you would prefer a native inline banner instead of the decoration, open an issue to request that option.
  • For global functions like setTimeout, the extension avoids opening TypeScript lib sources.
  • Place cursor inside the invoked identifier for best detection (e.g. inside myFunc in obj.myFunc()).

Contributing / Local Dev

npm install
npm run watch   # incremental compile
code .          # launch VS Code

Press F5 to start a new Extension Development Host to test changes.

Troubleshooting

  • If packaging fails, ensure @vscode/vsce is installed globally and you’re in the project root.
  • If navigation doesn’t work, check file languageId (only JS/TS features apply in those files).
  • If Apex/LWC jumps fail silently, confirm expected folder layout exists.

License

Internal/distribution only (add a proper license if publishing publicly).


Enjoy!

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft