ballerina-lang icon indicating copy to clipboard operation
ballerina-lang copied to clipboard

[Improvement]: Reorder top level node list

Open chiranSachintha opened this issue 1 year ago • 2 comments
trafficstars

Description

In the existing implementation, we currently reorder the constants list and the global variable list separately. However, when considering the annotations of type definitions(as annotations are part of the typedesc), they depend on the order of both constants and global variables. Therefore, it is necessary to reorder the toplevel node list instead of reordering constants, global variables, and type definitions separately.

type AnnotRecord record {|
    string value;
|};

annotation AnnotRecord annot on type;

@annot {
    value: l
}
type T1 record {
    string name;
};

string l = "chiranS";

When considering the above example, the annot (annotation) is a component of the type description (typedesc) of T1. So we need to rearrange the top-level node list as follows.

type AnnotRecord record {|
    string value;
|};

annotation AnnotRecord annot on type;
string l = "chiranS";
@annot {
    value: l
}
type T1 record {
    string name;
};

Describe your problem(s)

No response

Describe your solution(s)

No response

Related area

-> Compilation

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

chiranSachintha avatar Jan 08 '24 04:01 chiranSachintha