Skip to content

Create New Tool To Group Very Small Elements Into a Seperate Containers for CDF Files at every Level #442

@R3tes

Description

@R3tes

Some codebases include many tiny elements (for example, classes under 10 lines of code) that clutter the city layout. Rather than excluding them altogether, this new tool should let the user merge those elements under pre-defined properties so they remain represented but don’t overwhelm the main city view when visually represented. The threshold for what counts as “small” is user-defined, and the user also selects which property triggers this grouping. The grouping should be done locally at every depth of the element tree.

Example tool run:

<codebase>
  <element name="<root_package>" type="package">
    <children>
      <element name="MainClass" type="class">
        <properties>
          <property name="LOC" type="int" value="100"/>
        </properties>
        <children/>
      </element>
      <element name="TinyHelper" type="class">
        <properties>
          <property name="LOC" type="int" value="8"/>
        </properties>
        <children>
          <!-- A nested class or element with LOC=4 -->
          <element name="MiniSubclass" type="class">
            <properties>
              <property name="LOC" type="int" value="4"/>
            </properties>
            <children/>
          </element>
        </children>
      </element>
      <element name="MediumClass" type="class">
        <properties>
          <property name="LOC" type="int" value="50"/>
        </properties>
        <children/>
      </element>
    </children>
  </element>
</codebase>
java -jar GroupTinyCdfElementsLocally.jar \
     --input original.xml \
     --property LOC \
     --threshold 10 \
     --output grouped.xml
<codebase>
  <element name="<root_package>" type="package">
    <children>

      <!-- main class remains as normal -->
      <element name="MainClass" type="class">
        <properties>
          <property name="LOC" type="int" value="100"/>
        </properties>
        <children/>
      </element>

      <!-- medium class remains as normal -->
      <element name="MediumClass" type="class">
        <properties>
          <property name="LOC" type="int" value="50"/>
        </properties>
        <children/>
      </element>

      <!-- local container for all tiny siblings under <root_package> -->
      <element name="LocalSmallContainer_1" type="virtual-container">
        <properties/>
        <children>

          <!-- TinyHelper is moved here since LOC=8 < 10 -->
          <element name="TinyHelper" type="class">
            <properties>
              <property name="LOC" type="int" value="8"/>
            </properties>
            <children>
              <!-- new local container inside TinyHelper for MiniSubclass -->
              <element name="LocalSmallContainer_2" type="virtual-container">
                <properties/>
                <children>
                  <!-- MiniSubclass is also below threshold (4 < 10) -->
                  <element name="MiniSubclass" type="class">
                    <properties>
                      <property name="LOC" type="int" value="4"/>
                    </properties>
                    <children/>
                  </element>
                </children>
              </element>
            </children>
          </element>
        </children>
      </element>
    </children>
  </element>
</codebase>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions