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

Method checkUsage

src/main/java/org/codehaus/groovy/ast/ModuleNode.java:394–415  ·  view source on GitHub ↗
(final String name, final ClassNode type)

Source from the content-addressed store, hash-verified

392 }
393
394 private void checkUsage(final String name, final ClassNode type) {
395 for (ClassNode node : classes) {
396 if (node.getNameWithoutPackage().equals(name) && !node.equals(type)) {
397 getContext().addErrorAndContinue(new SyntaxException("The name " + name + " is already declared", type));
398 return;
399 }
400 }
401
402 for (ImportNode node : imports) {
403 if (node.getAlias().equals(name) && !node.getType().equals(type)) {
404 getContext().addErrorAndContinue(new SyntaxException("The name " + name + " is already declared", type));
405 return;
406 }
407 }
408
409 {
410 ImportNode node = staticImports.get(name);
411 if (node != null && !node.getType().equals(type.getOuterClass())) {
412 getContext().addErrorAndContinue(new SyntaxException("The name " + name + " is already declared", type));
413 }
414 }
415 }
416
417 /**
418 * Adds a module-level method definition.

Callers 3

addImportMethod · 0.95
addStaticImportMethod · 0.95
addClassMethod · 0.95

Calls 9

equalsMethod · 0.95
getContextMethod · 0.95
getAliasMethod · 0.95
getTypeMethod · 0.95
getNameWithoutPackageMethod · 0.80
equalsMethod · 0.65
getMethod · 0.65
addErrorAndContinueMethod · 0.45
getOuterClassMethod · 0.45

Tested by

no test coverage detected