public boolean prefixMatches(@NotNull PsiBuilder builder, @NotNull String text) {
      int builderOffset = builder.getCurrentOffset();
      int diff = offset - builderOffset;
      int length = text.length();
      if (diff == 0) {
        return true;
      }
      else if (diff > 0 && diff <= length) {
        CharSequence fragment = builder.getOriginalText().subSequence(builderOffset, offset);
        return prefixMatches(fragment.toString(), text);
      }
      else if (diff < 0) {
        for (int i=-1; ; i--) {
          IElementType type = builder.rawLookup(i);
          int tokenStart = builder.rawTokenTypeStart(i);
          if (isWhitespaceOrComment(builder, type)) {
            diff = offset - tokenStart;
          }
          else if (type != null && tokenStart < offset) {
            CharSequence fragment = builder.getOriginalText().subSequence(tokenStart, offset);
            if (prefixMatches(fragment.toString(), text)) {
              diff = offset - tokenStart;
            }
            break;
          }
          else break;
        }
        return diff >= 0 && diff < length;
      }
      return false;
    }
public boolean prefixMatches(@NotNull PsiBuilder builder, @NotNull String text)