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


Java StructureItem.getNestedItems方法代码示例

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


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

示例1: addBlocks

import org.netbeans.modules.csl.api.StructureItem; //导入方法依赖的package包/类
private void addBlocks(YamlParserResult result, BaseDocument doc, CharSequence text, List<OffsetRange> codeblocks, StructureItem item) throws BadLocationException {
    int docLength = doc == null ? text.length() : doc.getLength();
    int begin = Math.min((int) item.getPosition(), docLength);
    int end = Math.min((int) item.getEndPosition(), docLength);
    int firstRowEnd = doc == null ? GsfUtilities.getRowEnd(text, begin) : Utilities.getRowEnd(doc, begin);
    int lastRowEnd = doc == null ? GsfUtilities.getRowEnd(text, end) : Utilities.getRowEnd(doc, end);
    if (begin < end && firstRowEnd != lastRowEnd) {
        codeblocks.add(new OffsetRange(firstRowEnd, end));
    } else {
        return;
    }

    for (StructureItem child : item.getNestedItems()) {
        int childBegin = (int) child.getPosition();
        int childEnd = (int) child.getEndPosition();
        if (childBegin >= begin && childEnd <= end) {
            addBlocks(result, doc, text, codeblocks, child);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:YamlScanner.java

示例2: addRanges

import org.netbeans.modules.csl.api.StructureItem; //导入方法依赖的package包/类
private void addRanges(List<OffsetRange> ranges, int caretOffset, StructureItem item) {
    int start = (int) item.getPosition();
    int end = (int) item.getEndPosition();
    if (caretOffset >= start && caretOffset <= end) {
        ranges.add(new OffsetRange(start, end));

        for (StructureItem child : item.getNestedItems()) {
            addRanges(ranges, caretOffset, child);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:YamlKeystrokeHandler.java

示例3: annotateStructureItem

import org.netbeans.modules.csl.api.StructureItem; //导入方法依赖的package包/类
private void annotateStructureItem(int indent, StringBuilder sb, List<? extends StructureItem> structure,
        HtmlFormatter formatter, boolean includePositions) {

    for (StructureItem element : structure) {
        for (int i = 0; i < indent; i++) {
            sb.append("  ");
        }
        sb.append(element.getName());
        sb.append(":");
        sb.append(element.getKind());
        sb.append(":");
        sb.append(element.getModifiers());
        sb.append(":");
        formatter.reset();
        sb.append(element.getHtml(formatter));
        sb.append(":");
        if (includePositions) {
            sb.append(element.getPosition());
            sb.append(",");
            sb.append(element.getEndPosition());
            sb.append(":");
        }
        sb.append("\n");
        List<? extends StructureItem> children = element.getNestedItems();
        if (children != null && children.size() > 0) {
            List<? extends StructureItem> c = new ArrayList<StructureItem>(children);
            // Sort children to make tests more stable
            Collections.sort(c, new Comparator<StructureItem>() {
                public int compare(StructureItem s1, StructureItem s2) {
                    String s1Name = s1.getName();
                    String s2Name = s2.getName();
                    if (s1Name == null || s2Name == null) {
                        if (s1Name == (Object)s2Name) { // Object Cast: avoid String==String semantic warning
                            return 0;
                        } else if (s1Name == null) {
                            return -1;
                        } else {
                            return 1;
                        }
                    } else {
                        return s1Name.compareTo(s2Name);
                    }
                }

            });

            annotateStructureItem(indent+1, sb, c, formatter, includePositions);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:51,代码来源:CslTestBase.java


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