Class CdkUtils


  • public class CdkUtils
    extends Object
    • Method Detail

      • getListExpression

        public static Optional<ListLiteral> getListExpression​(org.sonar.python.checks.cdk.CdkUtils.ExpressionFlow 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
      • 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.