Package org.sonar.python.checks.cdk
Class CdkUtils
- java.lang.Object
-
- org.sonar.python.checks.cdk.CdkUtils
-
public class CdkUtils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static Optional<org.sonar.python.checks.cdk.CdkUtils.ExpressionFlow>getArgument(SubscriptionContext ctx, CallExpression callExpression, String argumentName)Resolve a particular argument of a call by keyword or get an empty optional if the argument is not set nor resolvable.static Optional<org.sonar.python.checks.cdk.CdkUtils.ExpressionFlow>getArgument(SubscriptionContext ctx, CallExpression callExpression, String argumentName, int argumentPosition)Resolve a particular argument of a call by keyword or position.static Optional<CallExpression>getCall(Expression expression, String fqn)static Optional<DictionaryLiteral>getDictionary(Expression expression)static Optional<DictionaryLiteral>getDictionary(org.sonar.python.checks.cdk.CdkUtils.ExpressionFlow flow)Returns a DictionaryLiteral if the given expression flow origins of this kindstatic List<DictionaryLiteral>getDictionaryInList(SubscriptionContext ctx, ListLiteral listeners)Collects all dictionary elements of a list as a return.static Optional<org.sonar.python.checks.cdk.CdkUtils.ResolvedKeyValuePair>getDictionaryPair(List<org.sonar.python.checks.cdk.CdkUtils.ResolvedKeyValuePair> pairs, String key)A key-value pair can be returned by a given key.static Optional<org.sonar.python.checks.cdk.CdkUtils.ResolvedKeyValuePair>getDictionaryPair(SubscriptionContext ctx, DictionaryLiteral dict, String key)By resolving the individual dictionary elements, a key-value pair can be returned by a given key.static Optional<org.sonar.python.checks.cdk.CdkUtils.ExpressionFlow>getDictionaryValue(List<org.sonar.python.checks.cdk.CdkUtils.ResolvedKeyValuePair> pairs, String key)Return a resolved dictionary value by a given keystatic Optional<Integer>getInt(Expression expression)static Optional<org.sonar.python.checks.cdk.CdkUtils.ResolvedKeyValuePair>getKeyValuePair(SubscriptionContext ctx, DictionaryLiteralElement element)Resolve the key and value of a dictionary element or get an empty optional if the element is an UnpackingExpression.static Optional<ListLiteral>getList(org.sonar.python.checks.cdk.CdkUtils.ExpressionFlow flow)Returns a ListLiteral if the given expression flow origins of this kindstatic List<org.sonar.python.checks.cdk.CdkUtils.ExpressionFlow>getListElements(SubscriptionContext ctx, ListLiteral list)Creates flows for the individual elements of a liststatic Optional<ListLiteral>getListExpression(org.sonar.python.checks.cdk.CdkUtils.ExpressionFlow expression)static Optional<String>getString(Expression expression)static List<org.sonar.python.checks.cdk.CdkUtils.ResolvedKeyValuePair>resolveDictionary(SubscriptionContext ctx, DictionaryLiteral dict)Resolves all elements of a dictionary.
-
-
-
Method Detail
-
getInt
public static Optional<Integer> getInt(Expression expression)
-
getString
public static Optional<String> getString(Expression expression)
-
getCall
public static Optional<CallExpression> getCall(Expression expression, String fqn)
-
getListExpression
public static Optional<ListLiteral> getListExpression(org.sonar.python.checks.cdk.CdkUtils.ExpressionFlow expression)
-
getDictionary
public static Optional<DictionaryLiteral> getDictionary(Expression expression)
-
getArgument
protected static Optional<org.sonar.python.checks.cdk.CdkUtils.ExpressionFlow> getArgument(SubscriptionContext ctx, CallExpression callExpression, String argumentName)
Resolve a particular argument of a call by keyword or get an empty optional if the argument is not set nor resolvable.
-
getArgument
public static Optional<org.sonar.python.checks.cdk.CdkUtils.ExpressionFlow> getArgument(SubscriptionContext ctx, CallExpression callExpression, String argumentName, int argumentPosition)
Resolve a particular argument of a call by keyword or position. Return an empty optional if the argument is not set nor resolvable.
-
getList
public static Optional<ListLiteral> getList(org.sonar.python.checks.cdk.CdkUtils.ExpressionFlow flow)
Returns a ListLiteral if the given expression flow origins of this kind
-
getListElements
public static List<org.sonar.python.checks.cdk.CdkUtils.ExpressionFlow> getListElements(SubscriptionContext ctx, ListLiteral list)
Creates flows for the individual elements of a list
-
getDictionary
public static Optional<DictionaryLiteral> getDictionary(org.sonar.python.checks.cdk.CdkUtils.ExpressionFlow flow)
Returns a DictionaryLiteral if the given expression flow origins of this kind
-
getDictionaryPair
public static Optional<org.sonar.python.checks.cdk.CdkUtils.ResolvedKeyValuePair> getDictionaryPair(SubscriptionContext ctx, DictionaryLiteral dict, String key)
By resolving the individual dictionary elements, a key-value pair can be returned by a given key. The value is also a resolved flow.
-
getDictionaryPair
public static Optional<org.sonar.python.checks.cdk.CdkUtils.ResolvedKeyValuePair> getDictionaryPair(List<org.sonar.python.checks.cdk.CdkUtils.ResolvedKeyValuePair> pairs, String key)
A key-value pair can be returned by a given key. The value is also a resolved flow.
-
getDictionaryValue
public static Optional<org.sonar.python.checks.cdk.CdkUtils.ExpressionFlow> getDictionaryValue(List<org.sonar.python.checks.cdk.CdkUtils.ResolvedKeyValuePair> pairs, String key)
Return a resolved dictionary value by a given key
-
getDictionaryInList
public static List<DictionaryLiteral> getDictionaryInList(SubscriptionContext ctx, ListLiteral listeners)
Collects all dictionary elements of a list as a return.
-
resolveDictionary
public static List<org.sonar.python.checks.cdk.CdkUtils.ResolvedKeyValuePair> resolveDictionary(SubscriptionContext ctx, DictionaryLiteral dict)
Resolves all elements of a dictionary. All keys and values are resolved into flows.
-
getKeyValuePair
public static Optional<org.sonar.python.checks.cdk.CdkUtils.ResolvedKeyValuePair> getKeyValuePair(SubscriptionContext ctx, DictionaryLiteralElement element)
Resolve the key and value of a dictionary element or get an empty optional if the element is an UnpackingExpression.
-
-