Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bash-language-server

Package Overview
Dependencies
Maintainers
2
Versions
107
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bash-language-server - npm Package Compare versions

Comparing version 4.5.5 to 4.6.0

6

CHANGELOG.md
# Bash Language Server
## 4.6.0
- Support parsing `: "${VARIABLE:="default"}"` as a variable definition https://github.com/bash-lsp/bash-language-server/pull/693
## 4.5.5
- Use sourcing info even if `includeAllWorkspaceSymbols` is true to ensure that files not matching the `globPattern` (and therefor not part of the background analysis) is still resolved based on source commands. https://github.com/bash-lsp/bash-language-server/pull/695
- Use sourcing info even if `includeAllWorkspaceSymbols` is true to ensure that files not matching the `globPattern` (and therefore not part of the background analysis) is still resolved based on source commands. https://github.com/bash-lsp/bash-language-server/pull/695

@@ -7,0 +11,0 @@ ## 4.5.4

41

out/util/declarations.js

@@ -33,8 +33,6 @@ "use strict";

const followChildren = !GLOBAL_DECLARATION_LEAF_NODE_TYPES.has(node.type);
if (TreeSitterUtil.isDefinition(node)) {
const symbol = nodeToSymbolInformation({ node, uri });
if (symbol) {
const word = symbol.name;
globalDeclarations[word] = symbol;
}
const symbol = getDeclarationSymbolFromNode({ node, uri });
if (symbol) {
const word = symbol.name;
globalDeclarations[word] = symbol;
}

@@ -53,9 +51,6 @@ return followChildren;

TreeSitterUtil.forEach(tree.rootNode, (node) => {
if (TreeSitterUtil.isDefinition(node)) {
const symbol = nodeToSymbolInformation({ node, uri });
if (symbol) {
symbols.push(symbol);
}
const symbol = getDeclarationSymbolFromNode({ node, uri });
if (symbol) {
symbols.push(symbol);
}
return;
});

@@ -90,5 +85,2 @@ return symbols;

}
else if (TreeSitterUtil.isDefinition(childNode)) {
symbol = nodeToSymbolInformation({ node: childNode, uri });
}
else if (childNode.type === 'for_statement') {

@@ -100,2 +92,5 @@ const variableNode = childNode.child(1);

}
else {
symbol = getDeclarationSymbolFromNode({ node: childNode, uri });
}
if (symbol) {

@@ -153,2 +148,18 @@ if (!declarations[symbol.name]) {

}
function getDeclarationSymbolFromNode({ node, uri, }) {
var _a, _b;
if (TreeSitterUtil.isDefinition(node)) {
return nodeToSymbolInformation({ node, uri });
}
else if (node.type === 'command' && node.text.startsWith(': ')) {
// : does argument expansion and retains the side effects.
// A common usage is to define default values of environment variables, e.g. : "${VARIABLE:="default"}".
const variableNode = (_b = (_a = node.namedChildren
.find((c) => c.type === 'string')) === null || _a === void 0 ? void 0 : _a.namedChildren.find((c) => c.type === 'expansion')) === null || _b === void 0 ? void 0 : _b.namedChildren.find((c) => c.type === 'variable_name');
if (variableNode) {
return LSP.SymbolInformation.create(variableNode.text, LSP.SymbolKind.Variable, TreeSitterUtil.range(variableNode), uri);
}
}
return null;
}
//# sourceMappingURL=declarations.js.map

@@ -6,3 +6,3 @@ {

"license": "MIT",
"version": "4.5.5",
"version": "4.6.0",
"main": "./out/server.js",

@@ -9,0 +9,0 @@ "typings": "./out/server.d.ts",

@@ -982,2 +982,19 @@ import { pathToFileURL } from 'node:url'

},
Object {
"kind": 13,
"location": Object {
"range": Object {
"end": Object {
"character": 14,
"line": 25,
},
"start": Object {
"character": 5,
"line": 25,
},
},
"uri": "file://__REPO_ROOT_FOLDER__/testing/fixtures/extension.inc",
},
"name": "FILE_PATH",
},
]

@@ -984,0 +1001,0 @@ `)

@@ -563,57 +563,68 @@ import * as Process from 'node:child_process'

expect(result).toMatchInlineSnapshot(`
Array [
Object {
"data": Object {
"type": 3,
},
"documentation": undefined,
"kind": 6,
"label": "BOLD",
},
Object {
"data": Object {
"type": 3,
},
"documentation": Object {
"kind": "markdown",
"value": "Variable: **RED** - *defined in extension.inc*",
},
"kind": 6,
"label": "RED",
},
Object {
"data": Object {
"type": 3,
},
"documentation": Object {
"kind": "markdown",
"value": "Variable: **GREEN** - *defined in extension.inc*",
},
"kind": 6,
"label": "GREEN",
},
Object {
"data": Object {
"type": 3,
},
"documentation": Object {
"kind": "markdown",
"value": "Variable: **BLUE** - *defined in extension.inc*",
},
"kind": 6,
"label": "BLUE",
},
Object {
"data": Object {
"type": 3,
},
"documentation": Object {
"kind": "markdown",
"value": "Variable: **RESET** - *defined in extension.inc*",
},
"kind": 6,
"label": "RESET",
},
]
`)
Array [
Object {
"data": Object {
"type": 3,
},
"documentation": undefined,
"kind": 6,
"label": "BOLD",
},
Object {
"data": Object {
"type": 3,
},
"documentation": Object {
"kind": "markdown",
"value": "Variable: **RED** - *defined in extension.inc*",
},
"kind": 6,
"label": "RED",
},
Object {
"data": Object {
"type": 3,
},
"documentation": Object {
"kind": "markdown",
"value": "Variable: **GREEN** - *defined in extension.inc*",
},
"kind": 6,
"label": "GREEN",
},
Object {
"data": Object {
"type": 3,
},
"documentation": Object {
"kind": "markdown",
"value": "Variable: **BLUE** - *defined in extension.inc*",
},
"kind": 6,
"label": "BLUE",
},
Object {
"data": Object {
"type": 3,
},
"documentation": Object {
"kind": "markdown",
"value": "Variable: **RESET** - *defined in extension.inc*",
},
"kind": 6,
"label": "RESET",
},
Object {
"data": Object {
"type": 3,
},
"documentation": Object {
"kind": "markdown",
"value": "Variable: **FILE_PATH** - *defined in extension.inc*",
},
"kind": 6,
"label": "FILE_PATH",
},
]
`)
})

@@ -620,0 +631,0 @@ })

@@ -46,8 +46,6 @@ import * as LSP from 'vscode-languageserver/node'

if (TreeSitterUtil.isDefinition(node)) {
const symbol = nodeToSymbolInformation({ node, uri })
if (symbol) {
const word = symbol.name
globalDeclarations[word] = symbol
}
const symbol = getDeclarationSymbolFromNode({ node, uri })
if (symbol) {
const word = symbol.name
globalDeclarations[word] = symbol
}

@@ -75,11 +73,6 @@

TreeSitterUtil.forEach(tree.rootNode, (node) => {
if (TreeSitterUtil.isDefinition(node)) {
const symbol = nodeToSymbolInformation({ node, uri })
if (symbol) {
symbols.push(symbol)
}
const symbol = getDeclarationSymbolFromNode({ node, uri })
if (symbol) {
symbols.push(symbol)
}
return
})

@@ -127,4 +120,2 @@

}
} else if (TreeSitterUtil.isDefinition(childNode)) {
symbol = nodeToSymbolInformation({ node: childNode, uri })
} else if (childNode.type === 'for_statement') {

@@ -140,2 +131,4 @@ const variableNode = childNode.child(1)

}
} else {
symbol = getDeclarationSymbolFromNode({ node: childNode, uri })
}

@@ -229,1 +222,31 @@

}
function getDeclarationSymbolFromNode({
node,
uri,
}: {
node: Parser.SyntaxNode
uri: string
}): LSP.SymbolInformation | null {
if (TreeSitterUtil.isDefinition(node)) {
return nodeToSymbolInformation({ node, uri })
} else if (node.type === 'command' && node.text.startsWith(': ')) {
// : does argument expansion and retains the side effects.
// A common usage is to define default values of environment variables, e.g. : "${VARIABLE:="default"}".
const variableNode = node.namedChildren
.find((c) => c.type === 'string')
?.namedChildren.find((c) => c.type === 'expansion')
?.namedChildren.find((c) => c.type === 'variable_name')
if (variableNode) {
return LSP.SymbolInformation.create(
variableNode.text,
LSP.SymbolKind.Variable,
TreeSitterUtil.range(variableNode),
uri,
)
}
}
return null
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc