MCPcopy Index your code
hub / github.com/apache/groovy / getText

Method getText

src/main/java/org/codehaus/groovy/ast/ImportNode.java:111–134  ·  view source on GitHub ↗

Generates the text representation of this import statement as it would appear in source code. For example: "import java.util.List", "import static java.util.Collections. ", etc. @return the text representation of this import

()

Source from the content-addressed store, hash-verified

109 * @return the text representation of this import
110 */
111 @Override
112 public String getText() {
113 String simpleName = getAlias();
114 String memberName = getFieldName();
115
116 if (!isStatic()) {
117 if (isStar()) {
118 return "import " + getPackageName() + "*";
119 } else if (simpleName == null || simpleName.isEmpty()
120 || simpleName.equals(getType().getNameWithoutPackage())) {
121 return "import " + getClassName();
122 } else {
123 return "import " + getClassName() + " as " + simpleName;
124 }
125 } else {
126 if (isStar()) {
127 return "import static " + getClassName() + ".*";
128 } else if (simpleName == null || simpleName.isEmpty() || simpleName.equals(memberName)) {
129 return "import static " + getClassName() + "." + memberName;
130 } else {
131 return "import static " + getClassName() + "." + memberName + " as " + simpleName;
132 }
133 }
134 }
135
136 public boolean isStar() {
137 return isStar;

Callers

nothing calls this directly

Calls 10

getAliasMethod · 0.95
getFieldNameMethod · 0.95
isStaticMethod · 0.95
isStarMethod · 0.95
getPackageNameMethod · 0.95
getTypeMethod · 0.95
getClassNameMethod · 0.95
getNameWithoutPackageMethod · 0.80
equalsMethod · 0.65
isEmptyMethod · 0.45

Tested by

no test coverage detected