-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathapi.js
40 lines (33 loc) · 1.02 KB
/
api.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const { defaultsDeep, flatMap } = require("lodash");
const { computeCompletionSyntacticContext } = require("./content-assist");
function getSuggestions(options) {
const actualOptions = defaultsDeep(options, {
providers: {
elementContent: [],
elementName: [],
attributeName: [],
attributeValue: [],
},
context: undefined,
});
let { providerType, providerArgs } = computeCompletionSyntacticContext({
cst: actualOptions.cst,
tokenVector: actualOptions.tokenVector,
ast: actualOptions.ast,
offset: actualOptions.offset,
});
// Inject Additional semantic context for the content assist providers.
providerArgs.context = actualOptions.context;
if (providerType === null) {
return [];
} else {
const selectedProviders = actualOptions.providers[providerType];
const suggestions = flatMap(selectedProviders, (suggestionProvider) =>
suggestionProvider(providerArgs)
);
return suggestions;
}
}
module.exports = {
getSuggestions: getSuggestions,
};