Skip to content

Commit

Permalink
Refactor: various refactors and code cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
WilsonZiweiWang committed Oct 19, 2023
1 parent b63a3e6 commit 48c3bff
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions server/src/completions/reserved-keywords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const BITBAKE_KEYWORDS = [
'INHERIT'
]

const PYTHON_VARIABLES = [
const PYTHON_KEYWORDS = [
'def',
'from',
'import',
Expand Down Expand Up @@ -76,6 +76,6 @@ const SHELL_KEYWORDS = [

export const RESERVED_KEYWORDS = [...new Set([
...BITBAKE_KEYWORDS,
...PYTHON_VARIABLES,
...PYTHON_KEYWORDS,
...SHELL_KEYWORDS
])]
1 change: 0 additions & 1 deletion server/src/connectionHandlers/onCompletion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export function onCompletionHandler (textDocumentPositionParams: TextDocumentPos
logger.debug(`onCompletion - current word: ${word}`)

const shouldComplete = analyzer.shouldProvideCompletionItems(textDocumentPositionParams.textDocument.uri, wordPosition.line, wordPosition.character)
logger.debug(`isString: ${shouldComplete}`)
// Do not provide completions if it is inside a string but not inside a variable expansion
if (!shouldComplete) {
return []
Expand Down
2 changes: 1 addition & 1 deletion server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ connection.onDidChangeWatchedFiles((change) => {
bitBakeProjectScanner.rescanProject()
})

connection.onCompletion(onCompletionHandler.bind(this))
connection.onCompletion(onCompletionHandler)

connection.onCompletionResolve((item: CompletionItem): CompletionItem => {
logger.debug(`onCompletionResolve: ${JSON.stringify(item)}`)
Expand Down
2 changes: 1 addition & 1 deletion server/src/tree-sitter/analyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export default class Analyzer {
column: number
): boolean {
const n = this.nodeAtPoint(uri, line, column)
if (n !== null && (n.type === 'string_content' || n.type === 'ERROR')) {
if (n?.type === 'string_content' || n?.type === 'ERROR') {
return false
}
return true
Expand Down

0 comments on commit 48c3bff

Please sign in to comment.