Class SpoonUtils

java.lang.Object
org.tudalgo.algoutils.tutor.general.SpoonUtils

public class SpoonUtils extends Object
A collection of utilities for working with spoon.
  • Method Details

    • getCtElementForSourceCode

      public static <T, U extends spoon.reflect.declaration.CtType<?>> T getCtElementForSourceCode(String sourceCode, Class<U> kind, Matcher<Stringifiable> nameMatcher)

      Returns a CtElement of the specified type for the specified source code.

      Type Parameters:
      T - the type of the element to return (subtype of U)
      U - the type of the element to search for
      Parameters:
      sourceCode - the source code
      kind - the kind of the element to find
      nameMatcher - a matcher for matching the name of the element
      Returns:
      the element
    • getNameOfCtElement

      public static String getNameOfCtElement(spoon.reflect.declaration.CtElement element)

      Returns a human-readable name of the given element.

      Parameters:
      element - the element
      Returns:
      the human-readable name
    • getNameOfCtElement

      public static String getNameOfCtElement(Class<?> type)

      Returns a human-readable name of the given element type.

      Parameters:
      type - the element type
      Returns:
      the human-readable name