コード例 #1
0
 /**
  * @param document
  * @param offset
  * @return
  */
 private String computePrefix(EmbeddedDocument document, int offset) {
   final TextPosition textPosition = document.getPositionFromIndex(offset);
   final String line = document.getLineContent(textPosition.getLine());
   final LinearRange lineRange = document.getLinearRangeForLine(textPosition.getLine());
   String partLine = line.substring(0, offset - lineRange.getStartOffset());
   for (int i = partLine.length() - 1; i >= 0; i--) {
     switch (partLine.charAt(i)) {
       case '.':
         break;
       case ' ':
       case '(':
       case ')':
       case '{':
       case '}':
       case ';':
       case '[':
       case ']':
       case '"':
       case '\'':
         return partLine.substring(i + 1);
       default:
         break;
     }
   }
   return partLine;
 }
コード例 #2
0
 /**
  * @param document
  * @param offset
  * @return
  */
 private String computeTemplatePrefix(EmbeddedDocument document, int offset) {
   final TextPosition textPosition = document.getPositionFromIndex(offset);
   final String line = document.getLineContent(textPosition.getLine());
   final LinearRange lineRange = document.getLinearRangeForLine(textPosition.getLine());
   return line.substring(0, offset - lineRange.getStartOffset());
 }