当前位置: 首页>>代码示例>>Java>>正文


Java TextRange.getStartOffset方法代码示例

本文整理汇总了Java中com.intellij.openapi.util.TextRange.getStartOffset方法的典型用法代码示例。如果您正苦于以下问题:Java TextRange.getStartOffset方法的具体用法?Java TextRange.getStartOffset怎么用?Java TextRange.getStartOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.util.TextRange的用法示例。


在下文中一共展示了TextRange.getStartOffset方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: appendDescriptors

import com.intellij.openapi.util.TextRange; //导入方法依赖的package包/类
private void appendDescriptors(final ASTNode node, final Document document, final List<FoldingDescriptor> descriptors) {
    if (node.getElementType() == GCMTypes.CLASS_DECLARATION || node.getElementType() == GCMTypes.CUSTOM_TYPE_DECLARATION) {
        TextRange fullRange = node.getTextRange();
        if (fullRange.getEndOffset() - fullRange.getStartOffset() > 0) {

            try {
                int startOffset = fullRange.getStartOffset() + document.getText(fullRange).indexOf("{") + 1;
                int endOffset = fullRange.getEndOffset() - 1;
                if (startOffset < endOffset) {
                    TextRange shortRange = new TextRange(startOffset, fullRange.getEndOffset() - 1);
                    if (shortRange.getEndOffset() - shortRange.getStartOffset() > 1) {
                        descriptors.add(new FoldingDescriptor(node, shortRange));
                    }
                }
            } catch (Throwable e) {

            }
        }
    }
    ASTNode child = node.getFirstChildNode();
    while (child != null) {
        appendDescriptors(child, document, descriptors);
        child = child.getTreeNext();
    }
}
 
开发者ID:datathings,项目名称:greycat-idea-plugin,代码行数:26,代码来源:GCMFoldingBuilder.java

示例2: getLineNumber

import com.intellij.openapi.util.TextRange; //导入方法依赖的package包/类
private static int getLineNumber(VirtualFile virtualFile, TextRange textRange) {
    try {
        BufferedReader br = new BufferedReader(new InputStreamReader(virtualFile.getInputStream()));
        String line;
        int pos = 0;
        int lineNumber = 0;

        while ((line = br.readLine()) != null) {
            pos += line.length() + 1; //+1 for new line
            lineNumber++;

            if (pos >= textRange.getStartOffset()) {
                return lineNumber;
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return -1;
}
 
开发者ID:BFergerson,项目名称:JNomad-Plugin,代码行数:21,代码来源:JNomadQueryVisitor.java

示例3: getRangeInElement

import com.intellij.openapi.util.TextRange; //导入方法依赖的package包/类
@Override
public TextRange getRangeInElement() {
  final TextRange textRange = getTextRange();

  AppleScriptReferenceElement[] appleScriptReferences = PsiTreeUtil.getChildrenOfType(this, AppleScriptReferenceElement.class);
  if (appleScriptReferences != null && appleScriptReferences.length > 0) {
    TextRange lastReferenceRange = appleScriptReferences[appleScriptReferences.length - 1].getTextRange();
    return new UnfairTextRange(
        lastReferenceRange.getStartOffset() - textRange.getStartOffset(),
        lastReferenceRange.getEndOffset() - textRange.getEndOffset()
    );
  }
  return new UnfairTextRange(0, textRange.getEndOffset() - textRange.getStartOffset());
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:15,代码来源:AppleScriptReferenceElementImpl.java

示例4: rangeInParent

import com.intellij.openapi.util.TextRange; //导入方法依赖的package包/类
@NotNull
private static TextRange rangeInParent(@NotNull TextRange parent, @NotNull TextRange child) {
    int start = child.getStartOffset() - parent.getStartOffset();
    if (start < 0) {
        return TextRange.EMPTY_RANGE;
    }

    return TextRange.create(start, start + child.getLength());
}
 
开发者ID:reasonml-editor,项目名称:reasonml-idea-plugin,代码行数:10,代码来源:RmlPsiUtil.java

示例5: applyHighlight

import com.intellij.openapi.util.TextRange; //导入方法依赖的package包/类
@NotNull
private RangeHighlighter applyHighlight(Editor editor, TextAttributes attributes, PsiMethod psiMethod) {
	TextRange textRange = psiMethod.getTextRange();
	int start = textRange.getStartOffset();
	int end = textRange.getEndOffset();
	MarkupModel markupModel = editor.getMarkupModel();
	return markupModel.addRangeHighlighter(start, end, COLOR_Z_INDEX, attributes, TARGET_AREA);
}
 
开发者ID:AWeinb,项目名称:IntellijMethodHierarchyHighlighter,代码行数:9,代码来源:MethodBackgroundPainter.java

示例6: ellipsizeText

import com.intellij.openapi.util.TextRange; //导入方法依赖的package包/类
String ellipsizeText(@NotNull String text, Matcher matcher) {
    final int textLength = text.length();

    if (textLength > MAX_LENGTH) {
        if (matcher instanceof MinusculeMatcher) {
            FList iterable = ((MinusculeMatcher) matcher).matchingFragments(text);
            if (iterable != null) {
                TextRange textRange = (TextRange) iterable.getHead();
                int startOffset = textRange.getStartOffset();

                int startIndex = 0;
                int endIndex = textLength;

                if (startOffset > ELLIPSIS_EXTRA_LENGTH) {
                    startIndex = startOffset - ELLIPSIS_EXTRA_LENGTH;
                }
                if (textLength > startIndex + MAX_LENGTH) {
                    endIndex = startIndex + MAX_LENGTH;
                }

                String ellipsizedText = text.substring(startIndex, endIndex);

                if (startIndex > 0) {
                    ellipsizedText = DOTS + ellipsizedText;
                }
                if (endIndex < textLength) {
                    ellipsizedText = ellipsizedText + DOTS;
                }

                return ellipsizedText;
            }
        }
    }

    return text;
}
 
开发者ID:hoai265,项目名称:SearchResourcePlugin,代码行数:37,代码来源:StringEllipsisPolicy.java

示例7: clearHighlights

import com.intellij.openapi.util.TextRange; //导入方法依赖的package包/类
private static void clearHighlights(Editor editor, HighlightManager highlightManager,
        List<TextRange> toRemoves) {
    if (editor instanceof EditorWindow) {
        editor = ((EditorWindow) editor).getDelegate();
    }
    
    RangeHighlighter[] highlighters =
            ((HighlightManagerImpl) highlightManager).getHighlighters(editor);
    
    Arrays.sort(highlighters, (o1, o2) -> o1.getStartOffset() - o2.getStartOffset());
    Collections.sort(toRemoves, (o1, o2) -> o1.getStartOffset() - o2.getStartOffset());
    
    int i = 0;
    int j = 0;
    while (i < highlighters.length && j < toRemoves.size()) {
        RangeHighlighter highlighter = highlighters[i];
        final TextAttributes ta = highlighter.getTextAttributes();
        final TextRange textRange = TextRange.create(highlighter);
        final TextRange toRemove = toRemoves.get(j);
        if (ta != null && ta instanceof NamedTextAttr // wrap
                && highlighter.getLayer() == HighlighterLayer.SELECTION - 1 // wrap
                && toRemove.equals(textRange)) {
            highlightManager.removeSegmentHighlighter(editor, highlighter);
            i++;
        } else if (toRemove.getStartOffset() > textRange.getEndOffset()) {
            i++;
        } else if (toRemove.getEndOffset() < textRange.getStartOffset()) {
            j++;
        } else {
            i++;
            j++;
        }
    }
}
 
开发者ID:huoguangjin,项目名称:MultiHighlight,代码行数:35,代码来源:MultiHighlightHandler.java

示例8: 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


注:本文中的com.intellij.openapi.util.TextRange.getStartOffset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。