UNPKG

pss-langserver

Version:

A Language server for the Portable Stimulus Standard

53 lines (52 loc) 2.41 kB
"use strict"; /* * Copyright (C) 2025 Darshan(@thisisthedarshan) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.getSmartAutocompletions = getSmartAutocompletions; const autoCompletionHelpers_1 = require("./autoCompletionHelpers"); function getSmartAutocompletions(params, content, ast, autoCompletions, builtInCompletions) { const uri = params.textDocument.uri; const position = params.position; const text = content; if (content.length > 0) { // 1. Inside multiline comment if ((0, autoCompletionHelpers_1.isInsideMultilineComment)(text, position)) { return (0, autoCompletionHelpers_1.getCommentCompletions)(); } // 2 & 3. Dot notation (abc. or abc.def.) const chain = (0, autoCompletionHelpers_1.getDotNotationChain)(text, position); if (chain) { return (0, autoCompletionHelpers_1.getCompletionsForChain)(chain, ast); } // 4. Inside function call const funcContext = (0, autoCompletionHelpers_1.getFunctionContext)(text, position); if (funcContext) { const completions = (0, autoCompletionHelpers_1.getCompletionsForFunction)(funcContext.functionName, funcContext.parameterIndex, ast); if (completions.length === 0) { return [...builtInCompletions, ...autoCompletions]; } return completions; } // 5. Scoped notation const scopedItems = (0, autoCompletionHelpers_1.getScopeNotationChain)(text, position); if (scopedItems) { return (0, autoCompletionHelpers_1.getCompletionsForScopedItems)(scopedItems, ast); } } // Default case return [...builtInCompletions, ...autoCompletions]; }