Ejemplo n.º 1
0
 private boolean isInUnterminatedMultilineComment(int offset, IDocument d) {
   CommonToken token = getTokenStrictlyContainingOffset(offset);
   if (token == null) return false;
   try {
     return token.getType() == MULTI_COMMENT
         && !token.getText().endsWith("*/")
         && d.getLineOfOffset(offset) + 1 == token.getLine();
   } catch (BadLocationException e) {
     return false;
   }
 }
Ejemplo n.º 2
0
 private void fixIndentOfStringOrCommentContinuation() throws BadLocationException {
   int endOfWs = firstEndOfWhitespace(command.offset, getEndOfCurrentLine());
   if (endOfWs < 0) return;
   CommonToken tokenContainingOffset = getTokenStrictlyContainingOffset(command.offset);
   CommonToken token = getStartOfStringToken(tokenContainingOffset);
   int pos = command.offset - getStartOfCurrentLine();
   int tokenIndent = token.getCharPositionInLine();
   if (pos > tokenIndent) return;
   StringBuilder indent = new StringBuilder();
   int startOfTokenLine = document.getLineOffset(token.getLine() - 1);
   String prefix = document.get(startOfTokenLine + pos, tokenIndent - pos);
   for (int i = 0; i < prefix.length(); i++) {
     char ch = prefix.charAt(i);
     indent.append(ch == '\t' ? '\t' : ' ');
   }
   indent.append(getExtraIndent(token));
   indent.append(getRelativeIndent(command.offset));
   if (indent.length() > 0) {
     command.length = endOfWs - command.offset;
     command.text = indent.toString();
   }
 }
 private int[] start() {
   final CommonToken t = (CommonToken) input.LT(1);
   if (t == null) return new int[] {0, 0};
   return new int[] {t.getStartIndex(), t.getLine()};
 }