@@ -1519,14 +1519,14 @@ public RecordComponent findRecordComponentToRemove(JCVariableDecl var) {
1519
1519
/* creates a record component if non is related to the given variable and recreates a brand new one
1520
1520
* in other case
1521
1521
*/
1522
- public RecordComponent createRecordComponent (RecordComponent existing , JCVariableDecl var , List < JCAnnotation > annotations ) {
1522
+ public RecordComponent createRecordComponent (RecordComponent existing , JCVariableDecl rcDecl , VarSymbol varSym ) {
1523
1523
RecordComponent rc = null ;
1524
1524
if (existing != null ) {
1525
1525
recordComponents = List .filter (recordComponents , existing );
1526
- recordComponents = recordComponents .append (rc = new RecordComponent (var . sym , existing .originalAnnos , existing .isVarargs ));
1526
+ recordComponents = recordComponents .append (rc = new RecordComponent (varSym , existing .ast , existing .isVarargs ));
1527
1527
} else {
1528
1528
// Didn't find the record component: create one.
1529
- recordComponents = recordComponents .append (rc = new RecordComponent (var . sym , annotations ));
1529
+ recordComponents = recordComponents .append (rc = new RecordComponent (varSym , rcDecl ));
1530
1530
}
1531
1531
return rc ;
1532
1532
}
@@ -1786,33 +1786,33 @@ public <R, P> R accept(Symbol.Visitor<R, P> v, P p) {
1786
1786
public static class RecordComponent extends VarSymbol implements RecordComponentElement {
1787
1787
public MethodSymbol accessor ;
1788
1788
public JCTree .JCMethodDecl accessorMeth ;
1789
- /* the original annotations applied to the record component
1790
- */
1791
- private final List <JCAnnotation > originalAnnos ;
1789
+
1792
1790
/* if the user happens to erroneously declare two components with the same name, we need a way to differentiate
1793
1791
* them, the code will fail anyway but we need to keep the information for better error recovery
1794
1792
*/
1795
1793
private final int pos ;
1796
1794
1797
1795
private final boolean isVarargs ;
1798
1796
1797
+ private JCVariableDecl ast ;
1798
+
1799
1799
/**
1800
1800
* Construct a record component, given its flags, name, type and owner.
1801
1801
*/
1802
1802
public RecordComponent (Name name , Type type , Symbol owner ) {
1803
1803
super (PUBLIC , name , type , owner );
1804
1804
pos = -1 ;
1805
- originalAnnos = List . nil () ;
1805
+ ast = null ;
1806
1806
isVarargs = false ;
1807
1807
}
1808
1808
1809
- public RecordComponent (VarSymbol field , List < JCAnnotation > annotations ) {
1810
- this (field , annotations , field .type .hasTag (TypeTag .ARRAY ) && ((ArrayType )field .type ).isVarargs ());
1809
+ public RecordComponent (VarSymbol field , JCVariableDecl ast ) {
1810
+ this (field , ast , field .type .hasTag (TypeTag .ARRAY ) && ((ArrayType )field .type ).isVarargs ());
1811
1811
}
1812
1812
1813
- public RecordComponent (VarSymbol field , List < JCAnnotation > annotations , boolean isVarargs ) {
1813
+ public RecordComponent (VarSymbol field , JCVariableDecl ast , boolean isVarargs ) {
1814
1814
super (PUBLIC , field .name , field .type , field .owner );
1815
- this .originalAnnos = annotations ;
1815
+ this .ast = ast ;
1816
1816
this .pos = field .pos ;
1817
1817
/* it is better to store the original information for this one, instead of relying
1818
1818
* on the info in the type of the symbol. This is because on the presence of APs
@@ -1822,7 +1822,9 @@ public RecordComponent(VarSymbol field, List<JCAnnotation> annotations, boolean
1822
1822
this .isVarargs = isVarargs ;
1823
1823
}
1824
1824
1825
- public List <JCAnnotation > getOriginalAnnos () { return originalAnnos ; }
1825
+ public List <JCAnnotation > getOriginalAnnos () { return this .ast == null ? List .nil () : this .ast .mods .annotations ; }
1826
+
1827
+ public JCVariableDecl declarationFor () { return this .ast ; }
1826
1828
1827
1829
public boolean isVarargs () {
1828
1830
return isVarargs ;
0 commit comments