Example #1
0
 // ISourceRange getNameRange();
 @Test
 public void getNameRange() throws Exception {
   module.open(null);
   final IErlElement element = module.getElementAt(1);
   final IErlAttribute attribute = (IErlAttribute) element;
   final ISourceRange nameRange = attribute.getNameRange();
   assertEquals(0, nameRange.getOffset());
   assertEquals(12, nameRange.getLength());
 }
Example #2
0
 // void setNameRange(int offset, int length);
 @Test
 public void setNameRange() throws Exception {
   module.open(null);
   final IErlElement element = module.getElementAt(1);
   final IErlAttribute attribute = (IErlAttribute) element;
   final int offset = 1, length = 2;
   attribute.setNameRange(offset, length);
   final ISourceRange nameRange = attribute.getNameRange();
   assertEquals(offset, nameRange.getOffset());
   assertEquals(length, nameRange.getLength());
 }
 /**
  * Tests if a position is inside the source range of an element.
  *
  * @param pos Position to be tested.
  * @param sourceElement Source element (must be a IErlElement)
  * @return boolean Return <code>true</code> if position is located inside the source element.
  * @throws CoreException Exception thrown if element range could not be accessed.
  */
 protected static boolean isInside(final int pos, final ISourceReference sourceElement)
     throws CoreException {
   // if (fCachedRange == null) {
   // fCachedRange= sourceElement.getSourceRange();
   // }
   // ISourceRange range= fCachedRange;
   final ISourceRange range = sourceElement.getSourceRange();
   if (range != null) {
     final int rangeOffset = range.getOffset();
     return rangeOffset <= pos && rangeOffset + range.getLength() > pos;
   }
   return false;
 }