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

Method visitClass

src/main/java/org/codehaus/groovy/classgen/Verifier.java:264–317  ·  view source on GitHub ↗

{@inheritDoc}

(final ClassNode node)

Source from the content-addressed store, hash-verified

262 * {@inheritDoc}
263 */
264 @Override
265 public void visitClass(final ClassNode node) {
266 this.classNode = node;
267
268 if (node.isRecord()) {
269 detectInvalidRecordComponentNames(node);
270 if (node.isAbstract()) {
271 throw new RuntimeParserException("Record '" + node.getNameWithoutPackage() + "' must not be abstract", node);
272 }
273 }
274
275 checkForDuplicateInterfaces(node);
276 checkForDuplicateDefaultMethods(node);
277
278 if (node.isInterface() || Traits.isTrait(node)) {
279 // interfaces have no constructors but this expects one,
280 // so create a dummy but do not add it to the class node
281 addInitialization(node, new ConstructorNode(0, null));
282 node.visitContents(this);
283 if (node.getNodeMetaData(ClassNodeSkip.class) == null) {
284 node.setNodeMetaData(ClassNodeSkip.class, Boolean.TRUE);
285 }
286 if (node.isInterface()) {
287 addCovariantMethods(node); // GROOVY-8299
288 checkFinalVariables(node); // GROOVY-11273
289 }
290 return;
291 }
292
293 addDefaultParameterMethods(node);
294 addDefaultParameterConstructors(node);
295
296 boolean skipGroovify = hasAnnotation(node, POJO_ANNOTATION) && hasAnnotation(node, COMPILESTATIC_ANNOTATION);
297 if (!skipGroovify) {
298 String classInternalName = BytecodeHelper.getClassInternalName(node);
299
300 addStaticMetaClassField(node, classInternalName);
301 addFastPathHelperFieldsAndHelperMethod(node, classInternalName);
302 if (!node.isDerivedFrom(ClassHelper.GROOVY_OBJECT_SUPPORT_TYPE))
303 addGroovyObjectInterfaceAndMethods(node, classInternalName);
304 }
305
306 addDefaultConstructor(node);
307
308 addInitialization(node);
309 checkReturnInObjectInitializer(node.getObjectInitializerStatements());
310 node.getObjectInitializerStatements().clear();
311 node.visitContents(this);
312 checkForDuplicateMethods(node);
313 checkForDuplicateConstructors(node);
314 addCovariantMethods(node);
315 detectNonSealedType(node);
316 checkFinalVariables(node);
317 }
318
319 private static void checkForDuplicateDefaultMethods(ClassNode node) {
320 if (node.getInterfaces().length < 2) return;

Callers 2

printClassContentsMethod · 0.95
callMethod · 0.95

Tested by

no test coverage detected