Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.Region


      offset += trim;

    while (line.startsWith(trimmable, length))
      length -= trim;

    return new Region(offset, length + trim);
  }
View Full Code Here


      // if next import is on a different line, modify the end position to the next line begin offset
      if (currEndLine < nextOffsetLine) {
        currEndLine++;
        nextOffset= root.getPosition(currEndLine, 0);
      }
      currPackage.add(new ImportDeclEntry(name, isStatic, new Region(currOffset, nextOffset - currOffset)));
      currOffset= nextOffset;
      curr= next;
       
      // add a comment entry for spacing between imports
      if (currEndLine < nextOffsetLine) {
        nextOffset= root.getPosition(nextOffsetLine, 0);
       
        currPackage= new PackageEntry(); // create a comment package entry for this
        this.packageEntries.add(currPackage);
        currPackage.add(new ImportDeclEntry(null, false, new Region(currOffset, nextOffset - currOffset)));
         
        currOffset= nextOffset;
      }
      currEndLine= root.getLineNumber(nextOffset + nextLength);
    }

    boolean isStatic= curr.isStatic();
    String name= getFullName(curr);
    String packName= getQualifier(curr);
    if (currPackage == null || currPackage.compareTo(packName, isStatic) != 0) {
      currPackage= new PackageEntry(packName, null, isStatic);
      this.packageEntries.add(currPackage);
    }
    int length= this.replaceRange.getOffset() + this.replaceRange.getLength() - curr.getStartPosition();
    currPackage.add(new ImportDeclEntry(name, isStatic, new Region(curr.getStartPosition(), length)));
  }
View Full Code Here

          } else {
            endPos= nextLinePos;
          }
        }
      }
      return new Region(startPos, endPos - startPos);
    } else {
      int start= getPackageStatementEndPos(root);
      return new Region(start, 0);
    }   
  }
View Full Code Here

    public static void testEmpty() throws Exception {
        String input = "\n" + "  \n" + "\t  ";
        PropertiesLineReader reader = new PropertiesLineReader(input);

        assertEquals(blank, reader.next());
        assertEquals(new Region(0, 0), reader.region());

        assertEquals(blank, reader.next());
        assertEquals(new Region(1, 2), reader.region());

        assertEquals(blank, reader.next());
        assertEquals(new Region(4, 3), reader.region());

        assertEquals(eof, reader.next());
    }
View Full Code Here

    }

    public static void testRegionAfterEOF() throws Exception {
        PropertiesLineReader reader = new PropertiesLineReader("");
        assertEquals(blank, reader.next());
        assertEquals(new Region(0, 0), reader.region());
        assertEquals(eof, reader.next());
        try {
            reader.region();
            fail("Should throw IllegalStateException");
        } catch (IllegalStateException e) {
View Full Code Here

    public static void testComment() throws Exception {
        String input = "# comment";
        PropertiesLineReader reader = new PropertiesLineReader(input);
        assertEquals(comment, reader.next());
        assertEquals(new Region(0, 9), reader.region());
        assertEquals(eof, reader.next());
    }
View Full Code Here

    public static void testCommentLines() throws Exception {
        String input = "# comment1\n" + "# comment2\n" + "   # comment3\n" + "! comment4\n" + "   ! comment5";
        PropertiesLineReader reader = new PropertiesLineReader(input);
        assertEquals(comment, reader.next());
        assertEquals(new Region(0, 10), reader.region());

        assertEquals(comment, reader.next());
        assertEquals(new Region(11, 10), reader.region());

        assertEquals(comment, reader.next());
        assertEquals(new Region(22, 13), reader.region());

        assertEquals(comment, reader.next());
        assertEquals(new Region(36, 10), reader.region());

        assertEquals(comment, reader.next());
        assertEquals(new Region(47, 13), reader.region());

        assertEquals(eof, reader.next());
    }
View Full Code Here

        // line
        String input = "# comment\\\n# comment";

        PropertiesLineReader reader = new PropertiesLineReader(input);
        assertEquals(comment, reader.next());
        assertEquals(new Region(0, 10), reader.region());

        assertEquals(comment, reader.next());
        assertEquals(new Region(11, 9), reader.region());

        assertEquals(eof, reader.next());
    }
View Full Code Here

    public static void testEntryLines() throws Exception {
        String input = "foo=bar\n" + "foo2:bar2\n" + "   foo3:bar3";
        PropertiesLineReader reader = new PropertiesLineReader(input);

        assertEquals(entry, reader.next());
        assertEquals(new Region(0, 7), reader.region());
        assertEquals("foo", reader.key());

        assertEquals(entry, reader.next());
        assertEquals(new Region(8, 9), reader.region());
        assertEquals("foo2", reader.key());

        assertEquals(entry, reader.next());
        assertEquals(new Region(18, 12), reader.region());
        assertEquals("foo3", reader.key());
    }
View Full Code Here

    public static void testContinuedLine() throws Exception {
        String input = "foo=bar,\\\n" + "  baz";
        PropertiesLineReader reader = new PropertiesLineReader(input);

        assertEquals(entry, reader.next());
        assertEquals(new Region(0, 15), reader.region());
        assertEquals("foo", reader.key());
    }
View Full Code Here

TOP

Related Classes of org.eclipse.jface.text.Region

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.