Skip to content

Add a support to be able to caputer static and instance initialization blocks in Java classes #101

@rahlk

Description

@rahlk

Is your feature request related to a problem? Please describe

The codeanalyzer does not capture static and instance initialization blocks in Java classes, missing important initialization logic.

Describe the solution you'd like

Add an InitBlock class to represent initialization blocks. Create Java classed with the new features:

@Data
public class InitBlock {
   private String filePath;
   private String comment;
   private List<String> annotations;
   private List<String> thrownExceptions;
   private String code;
   private int startLine;
   private int endLine;
   private boolean isStatic;
   private List<String> referencedTypes;
   private List<String> accessedFields; 
   private List<CallSite> callSites;
   private List<VariableDeclaration> variableDeclarations;
   private int cyclomaticComplexity;
}

Update Type:

@Data
public class Type {
    // Existing fields
    
    // Database fields
    private List<CRUDOperation> crudOperations;
    
    // Initialization blocks
    private List<InitBlock> staticInitBlocks;
    private List<InitBlock> instanceInitBlocks;
}

Describe alternatives you've considered

  • Treating blocks as special methods - Less accurate semantically
  • Merging block content into constructor - Loses initialization order

Additional context

The construction of this block can be modeled on Callable entity. Consider sub-typing and/or creating an abstraction.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions