/**
  * @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;
 }
Ejemplo n.º 2
0
 private void fileOpened(EditorPartPresenter editor) {
   if (editor instanceof EmbeddedTextEditorPresenter) {
     ((EmbeddedTextEditorPresenter) editor)
         .getDocument()
         .setSelectedRange(
             LinearRange.createWithStart(match.getFileMatchRegion().getOffset())
                 .andLength(match.getFileMatchRegion().getLength()),
             true);
   }
 }
 /**
  * @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());
 }