public int getScannerStart ( int p ) { Element elem = getDefaultRootElement ( ) ; int lineNum = elem . getElementIndex ( p ) ; Element line = elem . getElement ( lineNum ) ; AttributeSet a = line . getAttributes ( ) ; while ( a . isDefined ( CommentAttribute ) && lineNum > 0 ) { lineNum -= 1 ; line = elem . getElement ( lineNum ) ; a = line . getAttributes ( ) ; } return line . getStartOffset ( ) ; }
Fetch a reasonable location to start scanning given the desired start location . This allows for adjustments needed to accomodate multiline comments .