Method: defaultInPIR(PIR)

1: package org.overture.codegen.vdm2jml.util;
2:
3: import java.util.Collections;
4: import java.util.Comparator;
5:
6: import org.overture.ast.util.ClonableString;
7: import org.overture.codegen.ir.PIR;
8: import org.overture.codegen.ir.analysis.AnalysisException;
9: import org.overture.codegen.ir.analysis.DepthFirstAnalysisAdaptor;
10: import org.overture.codegen.ir.declarations.ADefaultClassDeclIR;
11:
12: public class AnnotationSorter extends DepthFirstAnalysisAdaptor
13: {
14:         private Comparator<ClonableString> comparator;
15:
16:         public AnnotationSorter()
17:         {
18:                 super();
19:                 this.comparator = new JmlAnnotationComparator();
20:         }
21:
22:         @Override
23:         public void defaultInPIR(PIR node) throws AnalysisException
24:         {
25:•                if (!node.getMetaData().isEmpty())
26:                 {
27:                         Collections.sort(node.getMetaData(), comparator);
28:                 }
29:
30:•                if (node instanceof ADefaultClassDeclIR)
31:                 {
32:                         ADefaultClassDeclIR clazz = (ADefaultClassDeclIR) node;
33:
34:•                        if (!clazz.getGlobalMetaData().isEmpty())
35:                         {
36:                                 Collections.sort(clazz.getGlobalMetaData(), comparator);
37:                         }
38:
39:                 }
40:         }
41: }