Package: groovy.org.codenarc.util

## [Groovy] Class ImportUtil

- groovy.org.codenarc.util.ImportUtil

- Contains static utility methods and constants related to Import statements.

  This is an internal class and its API is subject to change.
  Authors:
    Chris Mair

- - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `static List` | `getImportsSortedByLineNumber(def sourceCode)`
    `` | `static List` | `getNonStaticImportsSortedByLineNumber(def sourceCode)`
    `` | `static String` | `packageNameForImport(org.codehaus.groovy.ast.ImportNode importNode)` Return the package name for the specified import statement or else an empty String
    `` | `static Map` | `sourceLineAndNumberForImport(SourceCode sourceCode, String className, String alias)` Return the source line and line number for the specified import class name and alias
    `` | `static Map` | `sourceLineAndNumberForImport(SourceCode sourceCode, org.codehaus.groovy.ast.ImportNode importNode)` Return the source line and line number for the specified import
    `` | `static Map` | `sourceLineAndNumberForNonStarImport(SourceCode sourceCode, org.codehaus.groovy.ast.ImportNode importNode)`
    `` | `static Map` | `sourceLineAndNumberForStarImport(SourceCode sourceCode, org.codehaus.groovy.ast.ImportNode importNode)` Return the source line and line number for the specified import class name and alias

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, toString, hashCode, getClass, notify, notifyAll, wait, wait, wait`

- - ### Method Detail

    - #### static List getImportsSortedByLineNumber(def sourceCode)

    - #### static List getNonStaticImportsSortedByLineNumber(def sourceCode)

    - #### static String packageNameForImport(org.codehaus.groovy.ast.ImportNode importNode)

      Return the package name for the specified import statement or else an empty String

      Parameters:
        `importNode` - - the ImportNode for the import
      Returns:
        the name package being imported (i.e., the import minus the class name/spec) or an empty String if the import contains no package component

    - #### static Map sourceLineAndNumberForImport(SourceCode sourceCode, String className, String alias)

      Return the source line and line number for the specified import class name and alias

      Parameters:
        `sourceCode` - - the SourceCode being processed
        `importNode` - - the ImportNode representing the import
      Returns:
        an object that has 'sourceLine' and 'lineNumber' fields

    - #### static Map sourceLineAndNumberForImport(SourceCode sourceCode, org.codehaus.groovy.ast.ImportNode importNode)

      Return the source line and line number for the specified import

      Parameters:
        `sourceCode` - - the SourceCode being processed
        `importNode` - - the ImportNode representing the import
      Returns:
        an object that has 'sourceLine' and 'lineNumber' fields

    - #### static Map sourceLineAndNumberForNonStarImport(SourceCode sourceCode, org.codehaus.groovy.ast.ImportNode importNode)

    - #### static Map sourceLineAndNumberForStarImport(SourceCode sourceCode, org.codehaus.groovy.ast.ImportNode importNode)

      Return the source line and line number for the specified import class name and alias

      Parameters:
        `sourceCode` - - the SourceCode being processed
        `importNode` - - the ImportNode representing the import
      Returns:
        an object that has 'sourceLine' and 'lineNumber' fields