stan-language-server-bin 0.4.5 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +280 -220
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -9871,24 +9871,60 @@ function getWellformedEdit(textEdit) {
|
|
|
9871
9871
|
var import_node = __toESM(require_main4(), 1);
|
|
9872
9872
|
|
|
9873
9873
|
// src/handlers/completion.ts
|
|
9874
|
+
var import_vscode_languageserver7 = __toESM(require_main4(), 1);
|
|
9875
|
+
var import_trie_search = __toESM(require_TrieSearch(), 1);
|
|
9876
|
+
|
|
9877
|
+
// src/handlers/completion/constraints.ts
|
|
9874
9878
|
var import_vscode_languageserver = __toESM(require_main4(), 1);
|
|
9879
|
+
function constraintToCompletionItem(constraint) {
|
|
9880
|
+
return {
|
|
9881
|
+
label: constraint,
|
|
9882
|
+
kind: import_vscode_languageserver.CompletionItemKind.Property
|
|
9883
|
+
};
|
|
9884
|
+
}
|
|
9885
|
+
var CONSTRAINTS = ["lower", "upper", "offset", "multiplier"].map(constraintToCompletionItem);
|
|
9875
9886
|
|
|
9876
|
-
// src/
|
|
9877
|
-
var
|
|
9878
|
-
|
|
9879
|
-
|
|
9880
|
-
|
|
9881
|
-
|
|
9882
|
-
};
|
|
9883
|
-
|
|
9884
|
-
|
|
9885
|
-
|
|
9886
|
-
|
|
9887
|
-
|
|
9888
|
-
|
|
9887
|
+
// src/handlers/completion/datatypes.ts
|
|
9888
|
+
var import_vscode_languageserver2 = __toESM(require_main4(), 1);
|
|
9889
|
+
function datatypeToCompletionItem(datatype) {
|
|
9890
|
+
return {
|
|
9891
|
+
label: datatype,
|
|
9892
|
+
kind: import_vscode_languageserver2.CompletionItemKind.Class
|
|
9893
|
+
};
|
|
9894
|
+
}
|
|
9895
|
+
var DATATYPES = [
|
|
9896
|
+
"void",
|
|
9897
|
+
"int",
|
|
9898
|
+
"real",
|
|
9899
|
+
"complex",
|
|
9900
|
+
"vector",
|
|
9901
|
+
"row_vector",
|
|
9902
|
+
"matrix",
|
|
9903
|
+
"complex_vector",
|
|
9904
|
+
"complex_row_vector",
|
|
9905
|
+
"complex_matrix",
|
|
9906
|
+
"ordered",
|
|
9907
|
+
"positive_ordered",
|
|
9908
|
+
"simplex",
|
|
9909
|
+
"unit_vector",
|
|
9910
|
+
"sum_to_zero_vector",
|
|
9911
|
+
"cholesky_factor_corr",
|
|
9912
|
+
"cholesky_factor_cov",
|
|
9913
|
+
"corr_matrix",
|
|
9914
|
+
"cov_matrix",
|
|
9915
|
+
"stochastic_column_matrix",
|
|
9916
|
+
"stochastic_row_matrix"
|
|
9917
|
+
].map(datatypeToCompletionItem);
|
|
9889
9918
|
|
|
9890
|
-
// src/
|
|
9891
|
-
var
|
|
9919
|
+
// src/handlers/completion/keywords.ts
|
|
9920
|
+
var import_vscode_languageserver3 = __toESM(require_main4(), 1);
|
|
9921
|
+
function keywordToCompletionItem(keyword) {
|
|
9922
|
+
return {
|
|
9923
|
+
label: keyword,
|
|
9924
|
+
kind: import_vscode_languageserver3.CompletionItemKind.Keyword
|
|
9925
|
+
};
|
|
9926
|
+
}
|
|
9927
|
+
var KEYWORDS = [
|
|
9892
9928
|
"for",
|
|
9893
9929
|
"in",
|
|
9894
9930
|
"while",
|
|
@@ -9930,94 +9966,137 @@ var ALL_KEYWORDS = [
|
|
|
9930
9966
|
"tuple",
|
|
9931
9967
|
"truncate",
|
|
9932
9968
|
"jacobian"
|
|
9933
|
-
];
|
|
9934
|
-
var getKeywords = () => {
|
|
9935
|
-
return ALL_KEYWORDS.map((keyword) => ({
|
|
9936
|
-
name: keyword
|
|
9937
|
-
}));
|
|
9938
|
-
};
|
|
9939
|
-
var provideKeywordCompletions = (text, position) => {
|
|
9940
|
-
const textUpToCursor = getTextUpToCursor(text, position);
|
|
9941
|
-
const keywords = getKeywords();
|
|
9942
|
-
const searchableKeywords = getSearchableItems(keywords, {
|
|
9943
|
-
splitOnRegEx: /[\s_]/g,
|
|
9944
|
-
min: 0
|
|
9945
|
-
});
|
|
9946
|
-
const match = textUpToCursor.match(/(?:^|\s)([\w_]+)$/);
|
|
9947
|
-
if (match) {
|
|
9948
|
-
const keywordName = match[1] || "";
|
|
9949
|
-
const completionProposals = searchableKeywords.search(keywordName);
|
|
9950
|
-
return completionProposals;
|
|
9951
|
-
}
|
|
9952
|
-
return [];
|
|
9953
|
-
};
|
|
9969
|
+
].map(keywordToCompletionItem);
|
|
9954
9970
|
|
|
9955
|
-
// src/
|
|
9956
|
-
var
|
|
9957
|
-
|
|
9958
|
-
|
|
9959
|
-
|
|
9960
|
-
|
|
9961
|
-
|
|
9962
|
-
|
|
9963
|
-
|
|
9964
|
-
|
|
9965
|
-
|
|
9966
|
-
|
|
9967
|
-
|
|
9968
|
-
|
|
9969
|
-
|
|
9970
|
-
|
|
9971
|
-
}
|
|
9972
|
-
|
|
9971
|
+
// src/handlers/completion/snippets.ts
|
|
9972
|
+
var import_vscode_languageserver4 = __toESM(require_main4(), 1);
|
|
9973
|
+
function snippetToCompletionItem(snippet) {
|
|
9974
|
+
return {
|
|
9975
|
+
label: snippet.name,
|
|
9976
|
+
kind: import_vscode_languageserver4.CompletionItemKind.Snippet,
|
|
9977
|
+
insertText: snippet.body.join(`
|
|
9978
|
+
`),
|
|
9979
|
+
insertTextFormat: import_vscode_languageserver4.InsertTextFormat.Snippet,
|
|
9980
|
+
insertTextMode: import_vscode_languageserver4.InsertTextMode.adjustIndentation,
|
|
9981
|
+
detail: snippet.description
|
|
9982
|
+
};
|
|
9983
|
+
}
|
|
9984
|
+
var SNIPPETS = [
|
|
9985
|
+
{
|
|
9986
|
+
name: "else",
|
|
9987
|
+
body: ["else {", " ${0:/* code */}", "}"],
|
|
9988
|
+
description: "Code snippet for 'else' conditional"
|
|
9989
|
+
},
|
|
9990
|
+
{
|
|
9991
|
+
name: "elseif",
|
|
9992
|
+
body: ["else if (${1:/* condition */}) {", " ${0:/* code */}", "}"],
|
|
9993
|
+
description: "Code snippet for 'else if' conditional"
|
|
9994
|
+
},
|
|
9995
|
+
{
|
|
9996
|
+
name: "for",
|
|
9997
|
+
body: [
|
|
9998
|
+
"for (${1:identifier} in ${2:collection}) {",
|
|
9999
|
+
" ${0:/* code */}",
|
|
10000
|
+
"}"
|
|
10001
|
+
],
|
|
10002
|
+
description: "Code snippet for 'for' loop"
|
|
10003
|
+
},
|
|
10004
|
+
{
|
|
10005
|
+
name: "if",
|
|
10006
|
+
body: ["if (${1:/* condition */}) {", " ${0:/* code */}", "}"],
|
|
10007
|
+
description: "Code snippet for 'if' conditional"
|
|
10008
|
+
},
|
|
10009
|
+
{
|
|
10010
|
+
name: "ifelse",
|
|
10011
|
+
body: [
|
|
10012
|
+
"if (${1:/* condition */}) {",
|
|
10013
|
+
" ${2:/* code */}",
|
|
10014
|
+
"} else {",
|
|
10015
|
+
" ${0:/* code */}",
|
|
10016
|
+
"}"
|
|
10017
|
+
],
|
|
10018
|
+
description: "Code snippet for 'if-else' conditional block"
|
|
10019
|
+
},
|
|
10020
|
+
{
|
|
10021
|
+
name: "while",
|
|
10022
|
+
body: ["while (${1:/* condition */}) {", " ${0:/* code */}", "}"],
|
|
10023
|
+
description: "Code snippet for 'while' loop"
|
|
10024
|
+
},
|
|
10025
|
+
{
|
|
10026
|
+
name: "profile",
|
|
10027
|
+
body: ['profile("${1:name}") {', " ${0:/* code to be profiled */}", "}"],
|
|
10028
|
+
description: "Code snippet for 'profile' block"
|
|
10029
|
+
},
|
|
10030
|
+
{
|
|
10031
|
+
name: "data",
|
|
10032
|
+
body: ["data {", " ${0:/* ... declarations ... */}", "}"],
|
|
10033
|
+
description: "Code snippet for 'data' block"
|
|
10034
|
+
},
|
|
10035
|
+
{
|
|
10036
|
+
name: "transformed data",
|
|
10037
|
+
body: [
|
|
10038
|
+
"transformed data {",
|
|
10039
|
+
" ${0:/* ... declarations ... statements ... */}",
|
|
10040
|
+
"}"
|
|
10041
|
+
],
|
|
10042
|
+
description: "Code snippet for 'transformed data' block"
|
|
10043
|
+
},
|
|
10044
|
+
{
|
|
10045
|
+
name: "parameters",
|
|
10046
|
+
body: ["parameters {", " ${0:/* ... declarations ... */}", "}"],
|
|
10047
|
+
description: "Code snippet for 'parameters' block"
|
|
10048
|
+
},
|
|
10049
|
+
{
|
|
10050
|
+
name: "transformed parameters",
|
|
10051
|
+
body: [
|
|
10052
|
+
"transformed parameters {",
|
|
10053
|
+
" ${0:/* ... declarations ... statements ... */}",
|
|
10054
|
+
"}"
|
|
10055
|
+
],
|
|
10056
|
+
description: "Code snippet for 'transformed parameters' block"
|
|
10057
|
+
},
|
|
10058
|
+
{
|
|
10059
|
+
name: "model",
|
|
10060
|
+
body: ["model {", " ${0:/* ... declarations ... statements ... */}", "}"],
|
|
10061
|
+
description: "Code snippet for 'model' block"
|
|
10062
|
+
},
|
|
10063
|
+
{
|
|
10064
|
+
name: "generated quantities",
|
|
10065
|
+
body: [
|
|
10066
|
+
"generated quantities {",
|
|
10067
|
+
" ${0:/* ... declarations ... statements ... */}",
|
|
10068
|
+
"}"
|
|
10069
|
+
],
|
|
10070
|
+
description: "Code snippet for 'generated quantities' block"
|
|
10071
|
+
},
|
|
10072
|
+
{
|
|
10073
|
+
name: "functions",
|
|
10074
|
+
body: [
|
|
10075
|
+
"functions {",
|
|
10076
|
+
" ${0:/* ... function declarations and definitions ... */}",
|
|
10077
|
+
"}"
|
|
10078
|
+
],
|
|
10079
|
+
description: "Code snippet for 'functions' block"
|
|
10080
|
+
},
|
|
10081
|
+
{
|
|
10082
|
+
name: "include",
|
|
10083
|
+
body: ['#include "${1:filename}"'],
|
|
10084
|
+
description: "Code snippet for 'include' preprocessor"
|
|
10085
|
+
},
|
|
10086
|
+
{
|
|
10087
|
+
name: "target",
|
|
10088
|
+
body: ["target += ${1};"],
|
|
10089
|
+
description: "Code snippet for 'target +=' statement"
|
|
10090
|
+
},
|
|
10091
|
+
{
|
|
10092
|
+
name: "jacobian",
|
|
10093
|
+
body: ["jacobian += ${1};"],
|
|
10094
|
+
description: "Code snippet for 'jacobian +=' statement"
|
|
9973
10095
|
}
|
|
9974
|
-
|
|
9975
|
-
};
|
|
10096
|
+
].map(snippetToCompletionItem);
|
|
9976
10097
|
|
|
9977
|
-
// src/
|
|
9978
|
-
var
|
|
9979
|
-
"void",
|
|
9980
|
-
"int",
|
|
9981
|
-
"real",
|
|
9982
|
-
"complex",
|
|
9983
|
-
"vector",
|
|
9984
|
-
"row_vector",
|
|
9985
|
-
"matrix",
|
|
9986
|
-
"complex_vector",
|
|
9987
|
-
"complex_row_vector",
|
|
9988
|
-
"complex_matrix",
|
|
9989
|
-
"ordered",
|
|
9990
|
-
"positive_ordered",
|
|
9991
|
-
"simplex",
|
|
9992
|
-
"unit_vector",
|
|
9993
|
-
"sum_to_zero_vector",
|
|
9994
|
-
"cholesky_factor_corr",
|
|
9995
|
-
"cholesky_factor_cov",
|
|
9996
|
-
"corr_matrix",
|
|
9997
|
-
"cov_matrix",
|
|
9998
|
-
"stochastic_column_matrix",
|
|
9999
|
-
"stochastic_row_matrix"
|
|
10000
|
-
];
|
|
10001
|
-
var getDatatypes = () => {
|
|
10002
|
-
return DATATYPES.map((datatype) => ({
|
|
10003
|
-
name: datatype
|
|
10004
|
-
}));
|
|
10005
|
-
};
|
|
10006
|
-
var provideDatatypeCompletions = (text, position) => {
|
|
10007
|
-
const textUpToCursor = getTextUpToCursor(text, position);
|
|
10008
|
-
const datatypes = getDatatypes();
|
|
10009
|
-
const searchableDatatypes = getSearchableItems(datatypes, {
|
|
10010
|
-
splitOnRegEx: /[\s_]/g,
|
|
10011
|
-
min: 0
|
|
10012
|
-
});
|
|
10013
|
-
const match = textUpToCursor.match(/(?:^|\s)([\w_]+)$/);
|
|
10014
|
-
if (match) {
|
|
10015
|
-
const typeName = match[1] || "";
|
|
10016
|
-
const completionProposals = searchableDatatypes.search(typeName);
|
|
10017
|
-
return completionProposals;
|
|
10018
|
-
}
|
|
10019
|
-
return [];
|
|
10020
|
-
};
|
|
10098
|
+
// src/handlers/completion/distributions.ts
|
|
10099
|
+
var import_vscode_languageserver5 = __toESM(require_main4(), 1);
|
|
10021
10100
|
|
|
10022
10101
|
// node_modules/stanc3/dist/index.js
|
|
10023
10102
|
var stanc_default = `// Generated by js_of_ocaml
|
|
@@ -29967,6 +30046,23 @@ if (typeof module_dist !== "undefined") {
|
|
|
29967
30046
|
}
|
|
29968
30047
|
var stanc_version = stanc("", "", ["version"]).result;
|
|
29969
30048
|
|
|
30049
|
+
// src/handlers/completion/distributions.ts
|
|
30050
|
+
function distributionToCompletionItem(distribution) {
|
|
30051
|
+
return {
|
|
30052
|
+
label: distribution,
|
|
30053
|
+
kind: import_vscode_languageserver5.CompletionItemKind.Function
|
|
30054
|
+
};
|
|
30055
|
+
}
|
|
30056
|
+
var getDistributions = () => {
|
|
30057
|
+
const distributions = dump_stan_math_distributions().split(`
|
|
30058
|
+
`).map((line) => line.split(":")[0]?.trim() ?? "").filter((name) => name !== "");
|
|
30059
|
+
return distributions.map(distributionToCompletionItem);
|
|
30060
|
+
};
|
|
30061
|
+
var DISTRIBUTIONS = getDistributions();
|
|
30062
|
+
|
|
30063
|
+
// src/handlers/completion/functions.ts
|
|
30064
|
+
var import_vscode_languageserver6 = __toESM(require_main4(), 1);
|
|
30065
|
+
|
|
29970
30066
|
// src/language/hover/util.ts
|
|
29971
30067
|
var isWordChar = (char) => {
|
|
29972
30068
|
const code = char.charCodeAt(0);
|
|
@@ -30161,122 +30257,84 @@ async function handleHover(document, params) {
|
|
|
30161
30257
|
}
|
|
30162
30258
|
var hover_default = handleHover;
|
|
30163
30259
|
|
|
30164
|
-
// src/
|
|
30165
|
-
|
|
30166
|
-
|
|
30167
|
-
|
|
30168
|
-
|
|
30169
|
-
|
|
30170
|
-
|
|
30171
|
-
|
|
30172
|
-
|
|
30173
|
-
|
|
30260
|
+
// src/handlers/completion/functions.ts
|
|
30261
|
+
function functionToCompletionItem(func) {
|
|
30262
|
+
return {
|
|
30263
|
+
label: func,
|
|
30264
|
+
kind: import_vscode_languageserver6.CompletionItemKind.Function
|
|
30265
|
+
};
|
|
30266
|
+
}
|
|
30267
|
+
var getFunctions = () => {
|
|
30268
|
+
const functions = dump_stan_math_signatures().split(`
|
|
30269
|
+
`);
|
|
30270
|
+
const functionNames = functions.map((line) => line.split("(", 1)[0]?.trim() ?? "").filter((name) => name !== "");
|
|
30271
|
+
const uniqueFunctions = [...new Set([...functionNames, ...manual_functions])];
|
|
30272
|
+
return uniqueFunctions.map(functionToCompletionItem);
|
|
30273
|
+
};
|
|
30274
|
+
var FUNCTIONS = getFunctions();
|
|
30275
|
+
|
|
30276
|
+
// src/handlers/completion.ts
|
|
30277
|
+
var COMPLETION_TRIE = new import_trie_search.default("label", {
|
|
30278
|
+
splitOnRegEx: /[\s_]/g,
|
|
30279
|
+
min: 0
|
|
30280
|
+
});
|
|
30281
|
+
COMPLETION_TRIE.addAll([
|
|
30282
|
+
...CONSTRAINTS,
|
|
30283
|
+
...DATATYPES,
|
|
30284
|
+
...KEYWORDS,
|
|
30285
|
+
...FUNCTIONS,
|
|
30286
|
+
...SNIPPETS
|
|
30287
|
+
]);
|
|
30288
|
+
var searchWords = (textUpToCursor, supportsSnippets) => {
|
|
30174
30289
|
const match = textUpToCursor.match(/(?:^|\s)([\w_]+)$/);
|
|
30175
30290
|
if (match) {
|
|
30176
|
-
const
|
|
30177
|
-
const completionProposals =
|
|
30291
|
+
const word = match[1] || "";
|
|
30292
|
+
const completionProposals = COMPLETION_TRIE.search(word);
|
|
30293
|
+
if (!supportsSnippets) {
|
|
30294
|
+
return completionProposals.filter((item) => item.kind !== import_vscode_languageserver7.CompletionItemKind.Snippet);
|
|
30295
|
+
}
|
|
30178
30296
|
return completionProposals;
|
|
30179
30297
|
}
|
|
30180
30298
|
return [];
|
|
30181
30299
|
};
|
|
30182
|
-
|
|
30183
|
-
|
|
30184
|
-
|
|
30185
|
-
|
|
30186
|
-
|
|
30187
|
-
|
|
30188
|
-
|
|
30189
|
-
"ordered",
|
|
30190
|
-
"positive_ordered",
|
|
30191
|
-
"simplex",
|
|
30192
|
-
"unit_vector",
|
|
30193
|
-
"sum_to_zero_vector",
|
|
30194
|
-
"cholesky_factor_corr",
|
|
30195
|
-
"cholesky_factor_cov",
|
|
30196
|
-
"corr_matrix",
|
|
30197
|
-
"cov_matrix",
|
|
30198
|
-
"stochastic_column_matrix",
|
|
30199
|
-
"stochastic_row_matrix"
|
|
30200
|
-
];
|
|
30201
|
-
var getConstraints = () => {
|
|
30202
|
-
return CONSTRAINTS.map((constraint) => ({
|
|
30203
|
-
name: constraint
|
|
30204
|
-
}));
|
|
30205
|
-
};
|
|
30206
|
-
var provideConstraintCompletions = (text, position) => {
|
|
30207
|
-
const textUpToCursor = getTextUpToCursor(text, position);
|
|
30208
|
-
const constraints = getConstraints();
|
|
30209
|
-
const searchableConstraints = getSearchableItems(constraints, {
|
|
30210
|
-
splitOnRegEx: /[\s_]/g,
|
|
30211
|
-
min: 0
|
|
30212
|
-
});
|
|
30213
|
-
const match = textUpToCursor.match(/(?:^|\s)([\w_]+)$/);
|
|
30300
|
+
var DISTRIBUTION_TRIE = new import_trie_search.default("label", {
|
|
30301
|
+
splitOnRegEx: /[\s_]/g,
|
|
30302
|
+
min: 0
|
|
30303
|
+
});
|
|
30304
|
+
DISTRIBUTION_TRIE.addAll(DISTRIBUTIONS);
|
|
30305
|
+
var searchDistributions = (textUpToCursor) => {
|
|
30306
|
+
const match = textUpToCursor.match(/.*~\s*([\w_]*)$/);
|
|
30214
30307
|
if (match) {
|
|
30215
|
-
const
|
|
30216
|
-
|
|
30308
|
+
const distName = match[1] || "";
|
|
30309
|
+
let completionProposals;
|
|
30310
|
+
if (distName === "") {
|
|
30311
|
+
completionProposals = DISTRIBUTIONS;
|
|
30312
|
+
} else {
|
|
30313
|
+
completionProposals = DISTRIBUTION_TRIE.search(distName);
|
|
30314
|
+
}
|
|
30217
30315
|
return completionProposals;
|
|
30218
30316
|
}
|
|
30219
30317
|
return [];
|
|
30220
30318
|
};
|
|
30221
|
-
|
|
30222
|
-
|
|
30223
|
-
function keywordToCompletionItem(keyword) {
|
|
30224
|
-
return {
|
|
30225
|
-
label: keyword.name,
|
|
30226
|
-
kind: import_vscode_languageserver.CompletionItemKind.Keyword
|
|
30227
|
-
};
|
|
30228
|
-
}
|
|
30229
|
-
function distributionToCompletionItem(distribution) {
|
|
30230
|
-
return {
|
|
30231
|
-
label: distribution.name,
|
|
30232
|
-
kind: import_vscode_languageserver.CompletionItemKind.Function
|
|
30233
|
-
};
|
|
30234
|
-
}
|
|
30235
|
-
function datatypeToCompletionItem(datatype) {
|
|
30236
|
-
return {
|
|
30237
|
-
label: datatype.name,
|
|
30238
|
-
kind: import_vscode_languageserver.CompletionItemKind.Class
|
|
30239
|
-
};
|
|
30240
|
-
}
|
|
30241
|
-
function functionToCompletionItem(func) {
|
|
30242
|
-
return {
|
|
30243
|
-
label: func.name,
|
|
30244
|
-
kind: import_vscode_languageserver.CompletionItemKind.Function
|
|
30245
|
-
};
|
|
30246
|
-
}
|
|
30247
|
-
function constraintToCompletionItem(constraint) {
|
|
30248
|
-
return {
|
|
30249
|
-
label: constraint.name,
|
|
30250
|
-
kind: import_vscode_languageserver.CompletionItemKind.Property
|
|
30251
|
-
};
|
|
30252
|
-
}
|
|
30253
|
-
var DISTRIBUTION_DATA = dump_stan_math_distributions().split(`
|
|
30254
|
-
`).map((line) => line.split(":")[0]?.trim() ?? "").filter((name) => name !== "");
|
|
30255
|
-
var FUNCTION_DATA = dump_stan_math_signatures().split(`
|
|
30319
|
+
var getTextUpToCursor = (text, position) => {
|
|
30320
|
+
const lines = text.split(`
|
|
30256
30321
|
`);
|
|
30257
|
-
|
|
30322
|
+
const currentLine = lines[position.line] || "";
|
|
30323
|
+
return currentLine.substring(0, position.character);
|
|
30324
|
+
};
|
|
30325
|
+
function handleCompletion(params, documents, supportsSnippets) {
|
|
30258
30326
|
const document = documents.get(params.textDocument.uri);
|
|
30259
|
-
if (!document) {
|
|
30327
|
+
if (!document || !document.languageId.startsWith("stan")) {
|
|
30260
30328
|
return [];
|
|
30261
30329
|
}
|
|
30262
|
-
const
|
|
30263
|
-
|
|
30264
|
-
|
|
30265
|
-
|
|
30266
|
-
const datatypes = provideDatatypeCompletions(text, position);
|
|
30267
|
-
const functions = provideFunctionCompletions(text, position, FUNCTION_DATA);
|
|
30268
|
-
const constraints = provideConstraintCompletions(text, position);
|
|
30269
|
-
const allItems = [
|
|
30270
|
-
...keywords.map(keywordToCompletionItem),
|
|
30271
|
-
...distributions.map(distributionToCompletionItem),
|
|
30272
|
-
...datatypes.map(datatypeToCompletionItem),
|
|
30273
|
-
...functions.map(functionToCompletionItem),
|
|
30274
|
-
...constraints.map(constraintToCompletionItem)
|
|
30330
|
+
const textUpToCursor = getTextUpToCursor(document.getText(), params.position);
|
|
30331
|
+
return [
|
|
30332
|
+
...searchDistributions(textUpToCursor),
|
|
30333
|
+
...searchWords(textUpToCursor, supportsSnippets)
|
|
30275
30334
|
];
|
|
30276
|
-
return allItems;
|
|
30277
30335
|
}
|
|
30278
30336
|
// src/handlers/diagnostics.ts
|
|
30279
|
-
var
|
|
30337
|
+
var import_vscode_languageserver8 = __toESM(require_main4(), 1);
|
|
30280
30338
|
|
|
30281
30339
|
// src/constants/index.ts
|
|
30282
30340
|
var SERVER_ID = "stan-language-server";
|
|
@@ -30814,7 +30872,7 @@ var readIncludedFileFromFileSystem = async (filename, dirs, fileSystemReader) =>
|
|
|
30814
30872
|
const localPath = join(currentDir, filename);
|
|
30815
30873
|
const content = await fileSystemReader(localPath);
|
|
30816
30874
|
return TextDocument.create(URI.file(localPath).toString(), "stan", 0, content);
|
|
30817
|
-
} catch (
|
|
30875
|
+
} catch (_error) {}
|
|
30818
30876
|
}
|
|
30819
30877
|
return Promise.resolve({ msg: `File not found: ${filename}` });
|
|
30820
30878
|
};
|
|
@@ -30822,44 +30880,44 @@ var readIncludedFileFromFileSystem = async (filename, dirs, fileSystemReader) =>
|
|
|
30822
30880
|
// src/handlers/compilation/compilation.ts
|
|
30823
30881
|
var defaultSettings = {
|
|
30824
30882
|
maxLineLength: 78,
|
|
30825
|
-
includePaths: []
|
|
30883
|
+
includePaths: [],
|
|
30884
|
+
warnPedantic: false
|
|
30826
30885
|
};
|
|
30827
|
-
async function handleCompilation(document, documentManager, workspaceFolders, settings, logger, reader) {
|
|
30886
|
+
async function handleCompilation(document, documentManager, workspaceFolders, settings, purpose, logger, reader) {
|
|
30828
30887
|
const filename = URI.parse(document.uri).fsPath;
|
|
30829
30888
|
const code = document.getText();
|
|
30830
30889
|
const includes = await handleIncludes(document, documentManager, workspaceFolders, settings.includePaths, logger, reader);
|
|
30831
|
-
const stanc_args = [
|
|
30832
|
-
"auto-format",
|
|
30833
|
-
`filename-in-msg=${filename}`,
|
|
30834
|
-
`max-line-length=${settings.maxLineLength}`,
|
|
30835
|
-
"canonicalze=deprecations",
|
|
30836
|
-
"allow-undefined"
|
|
30837
|
-
];
|
|
30890
|
+
const stanc_args = [`filename-in-msg=${filename}`, "allow-undefined"];
|
|
30838
30891
|
if (filename.endsWith(".stanfunctions")) {
|
|
30839
30892
|
stanc_args.push("functions-only");
|
|
30840
30893
|
}
|
|
30894
|
+
if (purpose === "formatting") {
|
|
30895
|
+
stanc_args.push("auto-format", `max-line-length=${settings.maxLineLength}`, "canonicalze=deprecations");
|
|
30896
|
+
} else if (settings.warnPedantic) {
|
|
30897
|
+
stanc_args.push("warn-pedantic");
|
|
30898
|
+
}
|
|
30841
30899
|
return Promise.resolve(stanc(filename, code, stanc_args, includes));
|
|
30842
30900
|
}
|
|
30843
30901
|
|
|
30844
30902
|
// src/handlers/diagnostics.ts
|
|
30845
30903
|
async function handleDiagnostics(params, documents, workspaceFolders, settings, logger, reader) {
|
|
30846
30904
|
const document = documents.get(params.textDocument.uri);
|
|
30847
|
-
if (!document) {
|
|
30905
|
+
if (!document || !document.languageId.startsWith("stan")) {
|
|
30848
30906
|
return [];
|
|
30849
30907
|
}
|
|
30850
|
-
const compilerResult = await handleCompilation(document, documents, workspaceFolders, settings, logger, reader);
|
|
30908
|
+
const compilerResult = await handleCompilation(document, documents, workspaceFolders, settings, "linting", logger, reader);
|
|
30851
30909
|
const diagnostics = provideDiagnostics(compilerResult).map((diagnostic) => {
|
|
30852
30910
|
if (diagnostic.severity === "error") {
|
|
30853
30911
|
return {
|
|
30854
30912
|
range: diagnostic.range,
|
|
30855
|
-
severity:
|
|
30913
|
+
severity: import_vscode_languageserver8.DiagnosticSeverity.Error,
|
|
30856
30914
|
message: diagnostic.message,
|
|
30857
30915
|
source: SERVER_ID
|
|
30858
30916
|
};
|
|
30859
30917
|
} else if (diagnostic.severity === "warning") {
|
|
30860
30918
|
return {
|
|
30861
30919
|
range: diagnostic.range,
|
|
30862
|
-
severity:
|
|
30920
|
+
severity: import_vscode_languageserver8.DiagnosticSeverity.Warning,
|
|
30863
30921
|
message: diagnostic.message,
|
|
30864
30922
|
source: SERVER_ID
|
|
30865
30923
|
};
|
|
@@ -30870,10 +30928,10 @@ async function handleDiagnostics(params, documents, workspaceFolders, settings,
|
|
|
30870
30928
|
// src/handlers/formatting.ts
|
|
30871
30929
|
async function handleFormatting(params, documents, workspaceFolders, settings, logger, reader) {
|
|
30872
30930
|
const document = documents.get(params.textDocument.uri);
|
|
30873
|
-
if (!document) {
|
|
30931
|
+
if (!document || !document.languageId.startsWith("stan")) {
|
|
30874
30932
|
return [];
|
|
30875
30933
|
}
|
|
30876
|
-
const result = await handleCompilation(document, documents, workspaceFolders, settings, logger, reader);
|
|
30934
|
+
const result = await handleCompilation(document, documents, workspaceFolders, settings, "formatting", logger, reader);
|
|
30877
30935
|
if (result.errors && result.errors.length > 0) {
|
|
30878
30936
|
return { errors: result.errors };
|
|
30879
30937
|
} else if (result.result) {
|
|
@@ -30898,12 +30956,14 @@ var startLanguageServer = (connection, reader) => {
|
|
|
30898
30956
|
let hasConfigurationCapability = false;
|
|
30899
30957
|
let hasWorkspaceFolderCapability = false;
|
|
30900
30958
|
let hasDynamicConfigurationRequestCapability = false;
|
|
30959
|
+
let hasSnippetSupport = false;
|
|
30901
30960
|
connection.onInitialize((params) => {
|
|
30902
30961
|
connection.console.info("Initializing Stan language server...");
|
|
30903
|
-
|
|
30962
|
+
const capabilities = params.capabilities;
|
|
30904
30963
|
hasConfigurationCapability = Boolean(capabilities.workspace?.configuration);
|
|
30905
30964
|
hasDynamicConfigurationRequestCapability = Boolean(capabilities.workspace?.configuration && capabilities.workspace?.didChangeConfiguration?.dynamicRegistration);
|
|
30906
30965
|
hasWorkspaceFolderCapability = Boolean(capabilities.workspace?.workspaceFolders);
|
|
30966
|
+
hasSnippetSupport = Boolean(capabilities.textDocument?.completion?.completionItem?.snippetSupport);
|
|
30907
30967
|
return {
|
|
30908
30968
|
capabilities: {
|
|
30909
30969
|
textDocumentSync: import_node.TextDocumentSyncKind.Incremental,
|
|
@@ -30937,7 +30997,7 @@ var startLanguageServer = (connection, reader) => {
|
|
|
30937
30997
|
connection.console.info("Stan language server is exiting...");
|
|
30938
30998
|
});
|
|
30939
30999
|
let globalSettings = defaultSettings;
|
|
30940
|
-
|
|
31000
|
+
const documentSettings = new Map;
|
|
30941
31001
|
connection.onDidChangeConfiguration((change) => {
|
|
30942
31002
|
if (hasDynamicConfigurationRequestCapability) {
|
|
30943
31003
|
documentSettings.clear();
|
|
@@ -30951,11 +31011,11 @@ var startLanguageServer = (connection, reader) => {
|
|
|
30951
31011
|
if (!hasConfigurationCapability) {
|
|
30952
31012
|
return Promise.resolve(globalSettings);
|
|
30953
31013
|
}
|
|
30954
|
-
|
|
31014
|
+
const result = documentSettings.get(resource);
|
|
30955
31015
|
if (result !== undefined) {
|
|
30956
31016
|
return result;
|
|
30957
31017
|
}
|
|
30958
|
-
|
|
31018
|
+
const clientSettings = await connection.workspace.getConfiguration({
|
|
30959
31019
|
scopeUri: resource,
|
|
30960
31020
|
section: SERVER_ID
|
|
30961
31021
|
}) || {};
|
|
@@ -30965,7 +31025,7 @@ var startLanguageServer = (connection, reader) => {
|
|
|
30965
31025
|
};
|
|
30966
31026
|
const documents = new import_node.TextDocuments(TextDocument);
|
|
30967
31027
|
connection.onCompletion((params) => {
|
|
30968
|
-
return handleCompletion(params, documents);
|
|
31028
|
+
return handleCompletion(params, documents, hasSnippetSupport);
|
|
30969
31029
|
});
|
|
30970
31030
|
const getWorkspaceFolders = async () => {
|
|
30971
31031
|
if (hasWorkspaceFolderCapability) {
|
|
@@ -31001,7 +31061,7 @@ var startLanguageServer = (connection, reader) => {
|
|
|
31001
31061
|
});
|
|
31002
31062
|
connection.onHover((params) => {
|
|
31003
31063
|
const document = documents.get(params.textDocument.uri);
|
|
31004
|
-
if (!document) {
|
|
31064
|
+
if (!document || !document.languageId.startsWith("stan")) {
|
|
31005
31065
|
return null;
|
|
31006
31066
|
}
|
|
31007
31067
|
return hover_default(document, params);
|