Global variable annotations checks only in first block. release701
authorSubhashini Sooriarachchi <subslk@netbeans.org>
Fri, 01 Jun 2012 13:45:40 +0530
branchrelease701
changeset 232da12dc5e8eec
parent 231 444acb912904
child 233 3f5ef65e34ca
Global variable annotations checks only in first block.
PLSQL/Annotation/src/org/netbeans/modules/plsql/annotation/PlsqlPackageAnnotationUtil.java
     1.1 --- a/PLSQL/Annotation/src/org/netbeans/modules/plsql/annotation/PlsqlPackageAnnotationUtil.java	Fri May 25 16:57:23 2012 +0530
     1.2 +++ b/PLSQL/Annotation/src/org/netbeans/modules/plsql/annotation/PlsqlPackageAnnotationUtil.java	Fri Jun 01 13:45:40 2012 +0530
     1.3 @@ -104,6 +104,37 @@
     1.4  
     1.5        return offset;
     1.6     }
     1.7 +   //Use in global variable annotation to get the end of CONSTANT variables
     1.8 +    public static int checkForFirstImplBlock(final PlsqlBlock temp) {
     1.9 +      int offset = temp.getEndOffset();
    1.10 +      final Comparator<PlsqlBlock> comparator = new Comparator<PlsqlBlock>() {
    1.11 +
    1.12 +         @Override
    1.13 +         public int compare(final PlsqlBlock block1, final PlsqlBlock block2) {
    1.14 +            Integer o1pos, o2pos;
    1.15 +            if (block1.getStartOffset() > -1 && block2.getStartOffset() > -1) {
    1.16 +               o1pos = Integer.valueOf(block1.getStartOffset());
    1.17 +               o2pos = Integer.valueOf(block2.getStartOffset());
    1.18 +            } else {
    1.19 +               o1pos = Integer.valueOf(block1.getEndOffset());
    1.20 +               o2pos = Integer.valueOf(block2.getEndOffset());
    1.21 +            }
    1.22 +            return o1pos.compareTo(o2pos);
    1.23 +         }
    1.24 +      };
    1.25 +
    1.26 +      final List<PlsqlBlock> blocks = temp.getChildBlocks();
    1.27 +      Collections.sort(blocks, comparator);
    1.28 +      for (PlsqlBlock child : blocks) {
    1.29 +            PlsqlBlockType type = child.getType();
    1.30 +        if (!(type == PlsqlBlockType.COMMENT || type == PlsqlBlockType.CURSOR)) {
    1.31 +            offset = child.getStartOffset();
    1.32 +            break;
    1.33 +         }
    1.34 +      }
    1.35 +
    1.36 +      return offset;
    1.37 +   }
    1.38  
    1.39     public static boolean insertPackageDeclaration(final DataObject dataObj, final Document doc, final String decType, final int offset) {
    1.40        if (PlsqlAnnotationUtil.isFileReadOnly(doc)) {