当前位置: 首页>>代码示例>>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;未经允许,请勿转载。