in language-service/src/services/yamlTraversal.ts [54:91]
public getNodePropertyValues(document: TextDocument, yamlDocument: YAMLDocument, position: Position, propertyName: string): YamlNodePropertyValues {
if(!document){
return { values: null };
}
const offset: number = document.offsetAt(position);
const jsonDocument = yamlDocument.documents.length > 0 ? yamlDocument.documents[0] : null;
if(jsonDocument === null){
return { values: null };
}
// get the node by position and then walk up until we find an object node with properties
let node = jsonDocument.getNodeFromOffset(offset);
while (node !== null && !(node instanceof Parser.ObjectASTNode)) {
node = node.parent;
}
if (!node) {
return { values: null };
}
// see if this object has an inputs property
const propertiesArray = (node as Parser.ObjectASTNode).properties.filter(p => p.key.value === propertyName);
if (!propertiesArray || propertiesArray.length !== 1) {
return { values: null };
}
// get the values contained within inputs
let valueMap: {[key: string]: string} = {};
const parameterValueArray = (propertiesArray[0].value as Parser.ObjectASTNode).properties;
parameterValueArray && parameterValueArray.forEach(p => {
valueMap[p.key.value] = p.value.getValue();
});
return {
values: valueMap
};
}