use of com.facebook.buck.intellij.ideabuck.lang.psi.BuckExpression in project buck by facebook.
the class BuckBuildUtil method getPropertyValue.
/**
* Get the value of a property in a specific buck rule body.
* TODO(#7908675): We should use Buck's own classes for it.
*/
public static String getPropertyValue(BuckRuleBody body, String name) {
if (body == null) {
return null;
}
PsiElement[] children = body.getChildren();
for (PsiElement child : children) {
if (BuckPsiUtils.testType(child, BuckTypes.PROPERTY)) {
PsiElement lvalue = child.getFirstChild();
PsiElement propertyName = lvalue.getFirstChild();
if (propertyName != null && propertyName.getText().equals(name)) {
BuckExpression expression = (BuckExpression) BuckPsiUtils.findChildWithType(child, BuckTypes.EXPRESSION);
return expression != null ? BuckPsiUtils.getStringValueFromExpression(expression) : null;
}
}
}
return null;
}
Aggregations