Groovy Documentation

groovy.org.codenarc.util
[Groovy] Class ImportUtil

java.lang.Object
  groovy.org.codenarc.util.ImportUtil

class 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


Method Summary
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 sourceLineAndNumberForStarImport(SourceCode sourceCode, org.codehaus.groovy.ast.ImportNode importNode)

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

 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Method Detail

getImportsSortedByLineNumber

static List getImportsSortedByLineNumber(def sourceCode)


getNonStaticImportsSortedByLineNumber

static List getNonStaticImportsSortedByLineNumber(def sourceCode)


packageNameForImport

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


sourceLineAndNumberForImport

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


sourceLineAndNumberForImport

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


sourceLineAndNumberForStarImport

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


 

Groovy Documentation