當前位置: 首頁>>代碼示例>>Java>>正文


Java TextRange.getLength方法代碼示例

本文整理匯總了Java中com.intellij.openapi.util.TextRange.getLength方法的典型用法代碼示例。如果您正苦於以下問題:Java TextRange.getLength方法的具體用法?Java TextRange.getLength怎麽用?Java TextRange.getLength使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.openapi.util.TextRange的用法示例。


在下文中一共展示了TextRange.getLength方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: fold

import com.intellij.openapi.util.TextRange; //導入方法依賴的package包/類
@Nullable
private FoldingDescriptor fold(@Nullable PsiElement element) {
    if (element == null) {
        return null;
    }
    TextRange textRange = element.getTextRange();
    return textRange.getLength() > 5 ? new FoldingDescriptor(element, textRange) : null;
}
 
開發者ID:reasonml-editor,項目名稱:reasonml-idea-plugin,代碼行數:9,代碼來源:FoldingBuilder.java

示例2: getOffsetInHost

import com.intellij.openapi.util.TextRange; //導入方法依賴的package包/類
@Override
public int getOffsetInHost(int offsetInDecoded, @NotNull TextRange rangeInsideHost) {
  int result = offsetInDecoded < sourceOffsets.length ? sourceOffsets[offsetInDecoded] : -1;
  if (result == -1) return -1;
  return (result <= rangeInsideHost.getLength() ? result : rangeInsideHost.getLength()) + rangeInsideHost.getStartOffset();
}
 
開發者ID:ant-druha,項目名稱:AppleScript-IDEA,代碼行數:7,代碼來源:AppleScriptStringLiteralExpressionBase.java

示例3: processDirectives

import com.intellij.openapi.util.TextRange; //導入方法依賴的package包/類
private static void processDirectives(
    @Nullable final BladePsiDirective baseDirective,
    @NotNull final Queue<BladePsiDirective> directives,
    @NotNull final Collection<FoldingDescriptor> foldingDescriptors,
    @NotNull final Document document
) {
    while (true) {
        final BladePsiDirective directive = directives.peek();

        if (directive == null) {
            break;
        }

        if (IGNORED_DIRECTIVES.contains(directive.getName())) {
            directives.poll();
            continue;
        }

        if (baseDirective == null) {
            if (!directive.isToBeClosed()) {
                directives.poll();
                continue;
            }

            processDirectives(directives.poll(), directives, foldingDescriptors, document);
            continue;
        }

        // Eg. @endif or @elseif closes @if.
        // Or that @elseif continues @if.
        if (directive.closes(baseDirective) ||
            directive.continues(baseDirective)) {
            // Eg. @endif closes definitively an @if, @else or @elseif.
            // But @elseif or @else don't have the same effect.
            final boolean isDefinitivelyClosing = directive.isClosing() &&
                                                  !directive.isContinued();

            final TextRange foldingRange = new TextRange(
                baseDirective.getTextRange().getEndOffset(),
                directive.getTextRange().getStartOffset() - calculateEndOffsetReductor(directive, isDefinitivelyClosing)
            );

            if ((foldingRange.getLength() > 0) &&
                !StringUtils.strip(document.getText(foldingRange), " ").isEmpty()) {
                foldingDescriptors.add(new FoldingDescriptor(baseDirective.getNode(), foldingRange, FoldingGroup.newGroup("Blade")));
            }

            if (isDefinitivelyClosing) {
                directives.poll();
                break;
            }

            processDirectives(directives.poll(), directives, foldingDescriptors, document);
            break;
        }

        // Eg. @if or @elseif (but it will be catched on previous condition).
        if (directive.isContinued()) {
            processDirectives(directives.poll(), directives, foldingDescriptors, document);
            continue;
        }

        directives.poll();
    }
}
 
開發者ID:rentalhost,項目名稱:laravel-insight,代碼行數:66,代碼來源:BladeFoldingBuilder.java


注:本文中的com.intellij.openapi.util.TextRange.getLength方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。