Skip to content

Commit

Permalink
Merge branch 'release/0.0.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
DominusKelvin committed Sep 13, 2024
2 parents fc1d4f2 + a11169d commit bfb08c0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
17 changes: 15 additions & 2 deletions packages/language-server/go-to-definitions/go-to-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ const fs = require('fs').promises
const findProjectRoot = require('../helpers/find-project-root')
const findFnLine = require('../helpers/find-fn-line')

function camelToKebabCase(str) {
return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)
}

function normalizeHelperPath(helperPath) {
const parts = helperPath.split('/')
const fileName = parts.pop() // Get the last part (file name)
const normalizedFileName = camelToKebabCase(fileName)
return [...parts, normalizedFileName].join('/')
}

module.exports = async function goToHelper(document, position) {
const helperInfo = extractHelperInfo(document, position)

Expand All @@ -12,9 +23,11 @@ module.exports = async function goToHelper(document, position) {
}

const projectRoot = await findProjectRoot(document.uri)
const normalizedHelperPath = normalizeHelperPath(
helperInfo.helperPath.join('/')
)
const fullHelperPath =
path.join(projectRoot, 'api', 'helpers', ...helperInfo.helperPath) + '.js'

path.join(projectRoot, 'api', 'helpers', normalizedHelperPath) + '.js'
if (fullHelperPath) {
const fnLineNumber = await findFnLine(fullHelperPath)
return lsp.Location.create(
Expand Down
3 changes: 2 additions & 1 deletion packages/language-server/helpers/load-sails.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ module.exports = async function loadSails(workspaceUri, operation) {
new Sails().load(
{
hooks: { shipwright: false },
log: { level: 'silent' }
log: { level: 'silent' },
models: { migrate: 'safe' }
},
(err, sails) => {
if (err) {
Expand Down
2 changes: 1 addition & 1 deletion packages/language-server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sailshq/language-server",
"version": "0.0.4",
"version": "0.0.5",
"description": "Language Server Protocol server for Sails Language Service",
"homepage": "https://sailjs.com",
"repository": {
Expand Down
4 changes: 2 additions & 2 deletions packages/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"private": "true",
"name": "sails-vscode",
"displayName": "Sails",
"version": "0.0.4",
"version": "0.0.5",
"description": "Language support for Sails",
"main": "./dist/client.js",
"author": "Kelvin Omereshone",
Expand Down Expand Up @@ -39,7 +39,7 @@
},
"devDependencies": {
"@rsdoctor/rspack-plugin": "^0.4.1",
"@sailshq/language-server": "^0.0.4",
"@sailshq/language-server": "^0.0.5",
"@types/node": "^22.5.2",
"@types/vscode": "^1.82.0",
"@vscode/vsce": "^3.0.0"
Expand Down

0 comments on commit bfb08c0

Please sign in to comment.