本文整理汇总了Java中org.netbeans.modules.csl.api.StructureItem类的典型用法代码示例。如果您正苦于以下问题:Java StructureItem类的具体用法?Java StructureItem怎么用?Java StructureItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StructureItem类属于org.netbeans.modules.csl.api包,在下文中一共展示了StructureItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findCachedStructure
import org.netbeans.modules.csl.api.StructureItem; //导入依赖的package包/类
public static List<? extends StructureItem> findCachedStructure(Snapshot s, Parser.Result r) {
if (!(r instanceof ParserResult)) {
return null;
}
Reference<ResultStructure> previousRef;
previousRef = lastResults.get(s);
if (previousRef == null) {
return null;
}
ResultStructure cached = previousRef.get();
if (cached == null || cached.result != r) {
// remove from cache:
lastResults.remove(s);
return null;
}
return cached.structure;
}
示例2: selectNode
import org.netbeans.modules.csl.api.StructureItem; //导入依赖的package包/类
private void selectNode(Document doc, StructureItem structureRoot, long id, int caret) {
StructureItemNode root = new StructureItemNode(structureRoot);
StructureItemNode toSelect = root;
OUTER: while (requestId.get() == id) {
for (Node n : toSelect.getChildren().getNodes(true)) {
StructureItemNode sin = (StructureItemNode) n;
if (sin.item.getPosition() <= caret && caret <= sin.item.getEndPosition()) {
toSelect = sin;
// see #223480, mimetype nodes look ugly in the breadcrumb bar
if (toSelect.item instanceof ElementScanningTask.MimetypeRootNode) {
root = sin;
}
continue OUTER;
}
}
break;
}
if (requestId.get() == id) {
BreadcrumbsController.setBreadcrumbs(doc, root, toSelect);
}
}
示例3: StructureItemNode
import org.netbeans.modules.csl.api.StructureItem; //导入依赖的package包/类
public StructureItemNode(final StructureItem item) {
super(Children.create(new ChildFactory<StructureItem>() {
@Override protected boolean createKeys(List<StructureItem> toPopulate) {
toPopulate.addAll(item.getNestedItems());
return true;
}
@Override
protected Node createNodeForKey(StructureItem key) {
return new StructureItemNode(key);
}
}, false), Lookups.fixed(new OpenCookie() {
@Override public void open() {
ElementHandle elementHandle = item.getElementHandle();
FileObject file = elementHandle != null ? elementHandle.getFileObject() : null;
if (file != null) {
UiUtils.open(file, (int) item.getPosition());
}
}
}));
this.item = item;
setDisplayName(item.getName());
}
示例4: findLogicalRanges
import org.netbeans.modules.csl.api.StructureItem; //导入依赖的package包/类
@Override
public List<OffsetRange> findLogicalRanges(ParserResult info, int caretOffset) {
YamlParserResult result = (YamlParserResult) info;
if (result == null) {
return Collections.emptyList();
}
List<? extends StructureItem> items = result.getItems();
if (items.isEmpty()) {
return Collections.emptyList();
}
List<OffsetRange> ranges = new ArrayList<OffsetRange>();
for (StructureItem item : items) {
addRanges(ranges, caretOffset, item);
}
Collections.reverse(ranges);
Document doc = info.getSnapshot().getSource().getDocument(false);
if (doc != null) {
ranges.add(new OffsetRange(0, doc.getLength()));
}
return ranges;
}
示例5: 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);
}
}
}
示例6: getStructureItemsNodeVisitor
import org.netbeans.modules.csl.api.StructureItem; //导入依赖的package包/类
@Override
public <T extends List<StructureItem>> NodeVisitor<T> getStructureItemsNodeVisitor(final FeatureContext context, final T result) {
final List<StructureItem> items = new ArrayList<>();
return new NodeVisitor<T>() {
private void addItem(StructureItem si) {
if (items.isEmpty()) {
result.add(new TopLevelStructureItem.Namespaces(items));
}
items.add(si);
}
@Override
public boolean visit(Node node) {
if (node.type() == NodeType.namespace) {
addItem(new NamespaceStructureItem(context.getFileObject(), node));
}
return false;
}
};
}
示例7: visitPropertyValue
import org.netbeans.modules.csl.api.StructureItem; //导入依赖的package包/类
@Override
public Void visitPropertyValue(EditorConfigParser.PropertyValueContext ctx) {
propertyValue = ctx.getText();
if (propertyKey != null && !propertyKey.isEmpty() && propertyValue != null) {
properties.add(new EditorConfigPropertyStructureItem(propertyKey, propertyValue, propertyStart, propertyEnd));
}
propertyKey = null;
propertyValue = null;
propertyStart = 0;
propertyEnd = 0;
if (childCount == currentChildCount) {
if (sectionName != null) {
ArrayList<StructureItem> children = new ArrayList<>(properties);
sections.add(new EditorConfigSectionStructureItem(sectionName, sectionStart, sectionEnd, children));
}
sectionName = null;
sectionStart = 0;
sectionEnd = 0;
properties.clear();
currentChildCount = 0;
}
return super.visitPropertyValue(ctx);
}
示例8: visitPropertyValue
import org.netbeans.modules.csl.api.StructureItem; //导入依赖的package包/类
@Override
public Void visitPropertyValue(EditorConfigParser.PropertyValueContext ctx) {
propertyValue = ctx.getText();
if (propertyKey != null && !propertyKey.isEmpty() && propertyValue != null) {
properties.add(new EditorConfigPropertyStructureItem(propertyKey, propertyValue, propertyStart, propertyEnd));
}
propertyKey = null;
propertyValue = null;
propertyStart = 0;
propertyEnd = 0;
if (childCount == currentChildCount) {
if (sectionName != null) {
ArrayList<StructureItem> children = new ArrayList<>(properties);
sections.add(new EditorConfigSectionStructureItem(sectionName, sectionStart, sectionEnd, children));
}
sectionName = null;
sectionStart = 0;
sectionEnd = 0;
properties.clear();
currentChildCount = 0;
}
return super.visitPropertyValue(ctx);
}
示例9: ElementNode
import org.netbeans.modules.csl.api.StructureItem; //导入依赖的package包/类
/** Creates a new instance of TreeNode */
public ElementNode( StructureItem description, ClassMemberPanelUI ui, FileObject fileObject) {
super(description.isLeaf() ? Children.LEAF: new ElementChildren(description, ui, fileObject), Lookups.fixed(fileObject));
this.description = description;
setDisplayName( description.getName() );
this.ui = ui;
this.fileObject = fileObject;
}
示例10: refreshRecursively
import org.netbeans.modules.csl.api.StructureItem; //导入依赖的package包/类
private void refreshRecursively(Collection<ElementNode> toDo, final Collection<Node> toExpand) {
for (ElementNode elnod : toDo) {
final Children ch = elnod.getChildren();
if ( ch instanceof ElementChildren ) {
((ElementChildren)ch).resetKeys((List<StructureItem>)elnod.description.getNestedItems(), elnod.ui.getFilters());
Collection<ElementNode> children = (Collection<ElementNode>)(List)Arrays.asList((Node[])ch.getNodes());
toExpand.addAll(children);
refreshRecursively(children, toExpand);
}
}
}
示例11: addNotify
import org.netbeans.modules.csl.api.StructureItem; //导入依赖的package包/类
@Override
protected void addNotify() {
super.addNotify();
if (parent != null) {
resetKeys((List<StructureItem>)parent.getNestedItems(), ui.getFilters());
}
}
示例12: compare
import org.netbeans.modules.csl.api.StructureItem; //导入依赖的package包/类
public int compare(StructureItem d1, StructureItem d2) {
if ( alpha ) {
if ( k2i(d1.getKind()) != k2i(d2.getKind()) ) {
return k2i(d1.getKind()) - k2i(d2.getKind());
}
return d1.getSortText().compareTo(d2.getSortText());
}
else {
return d1.getPosition() == d2.getPosition() ? 0 : d1.getPosition() < d2.getPosition() ? -1 : 1;
}
}
示例13: MimetypeRootNode
import org.netbeans.modules.csl.api.StructureItem; //导入依赖的package包/类
private MimetypeRootNode(Language lang, List<? extends StructureItem> items, MimePath mimePath) {
this.language = lang;
this.items = new ArrayList<StructureItem>(items);
Collections.sort(items, Description.POSITION_COMPARATOR);
this.from = items.size() > 0 ? items.get(0).getPosition() : 0;
this.to = items.size() > 0 ? items.get(items.size() - 1).getEndPosition() : 0;
this.mimePath = mimePath;
}
示例14: getTask
import org.netbeans.modules.csl.api.StructureItem; //导入依赖的package包/类
public org.netbeans.modules.csl.navigation.ElementScanningTask getTask() {
return new ElementScanningTask() {
public @Override int getPriority() {
return 20000;
}
public @Override Class<? extends Scheduler> getSchedulerClass() {
return CSLNavigatorScheduler.class;
}
@Override public void run(final ParserResult result, final SchedulerEvent event) {
runWithCancelService(new Runnable() {
@Override
public void run() {
resume();
StructureItem root = computeStructureRoot(result.getSnapshot().getSource());
FileObject file = result.getSnapshot().getSource().getFileObject();
if (root != null && file != null) {
Document doc = result.getSnapshot().getSource().getDocument(false);
BaseDocument bd = doc instanceof BaseDocument ? (BaseDocument)doc : null;
refresh(root, file, bd);
}
}
});
}
};
}
示例15: isExpandedByDefault
import org.netbeans.modules.csl.api.StructureItem; //导入依赖的package包/类
boolean isExpandedByDefault(Node node) {
if (node instanceof ElementNode) {
StructureItem item = ((ElementNode) node).getDescription();
if (item instanceof StructureItem.CollapsedDefault && ((StructureItem.CollapsedDefault) item).isCollapsedByDefault()) {
return false;
}
}
return true;
}