use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BStructSymbol.BAttachedFunction in project ballerina by ballerina-lang.
the class BLangEndpointContextResolver method resolveItems.
@Override
@SuppressWarnings("unchecked")
public ArrayList<CompletionItem> resolveItems(TextDocumentServiceContext completionContext) {
BLangNode bLangEndpoint = completionContext.get(CompletionKeys.SYMBOL_ENV_NODE_KEY);
ArrayList<CompletionItem> completionItems = new ArrayList<>();
ArrayList<SymbolInfo> configurationFields = new ArrayList<>();
List<BStructSymbol.BAttachedFunction> attachedFunctions = new ArrayList<>();
if (((BLangEndpoint) bLangEndpoint).type.tsymbol instanceof BStructSymbol) {
attachedFunctions.addAll(((BStructSymbol) ((BLangEndpoint) bLangEndpoint).type.tsymbol).attachedFuncs);
}
BStructSymbol.BAttachedFunction initFunction = attachedFunctions.stream().filter(bAttachedFunction -> bAttachedFunction.funcName.getValue().equals(INIT)).findFirst().orElseGet(null);
BVarSymbol configSymbol = initFunction.symbol.getParameters().get(0);
BType configSymbolType = configSymbol.getType();
if (configSymbolType instanceof BStructType) {
((BStructType) configSymbolType).getFields().forEach(bStructField -> configurationFields.add(new SymbolInfo(bStructField.getName().getValue(), new Scope.ScopeEntry(bStructField.symbol, null))));
}
this.populateCompletionItemList(configurationFields, completionItems);
return completionItems;
}
Aggregations