2 Replies Latest reply on Jan 26, 2017 11:31 AM by Ondrej Zoricak

    It is possible find start and end lines of nested types with Roaster?

    Ondrej Zoricak Newbie

      I want to find start and end lines of all methods and types(class, enum, interface, annotation) of file. I found solution only for methods but not for nested types. Is it possible with Roaster?


      My solution for methods:


      private int[] getMethodRows(MethodSource ms, JavaSource js) {

         int[] rows = new int[2];
         rows[0] = ms.getLineNumber();
         String s = js.toUnformattedString();

        int i = getIndexOfRow(rows[0], s.toCharArray());
        int j = i + ms.getEndPosition() - ms.getStartPosition();
        rows[1] = countOfRow(s.substring(i, j).toCharArray()) + rows[0];
        return rows;



      private int countOfRow(char[] s) {

         int i = 0;
        for (char a :

        s) {

         if (a == '\n') {



         return i;