Java Code Examples for org.eclipse.xtext.nodemodel.BidiIterator#hasPrevious()
The following examples show how to use
org.eclipse.xtext.nodemodel.BidiIterator#hasPrevious() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XtextLinkingService.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
private List<EObject> getLinkedMetaModel(TypeRef context, EReference ref, ILeafNode text) throws IllegalNodeException { final ICompositeNode parentNode = text.getParent(); BidiIterator<INode> iterator = parentNode.getChildren().iterator(); while(iterator.hasPrevious()) { INode child = iterator.previous(); if (child instanceof ILeafNode) { ILeafNode leaf = (ILeafNode) child; if (text == leaf) return super.getLinkedObjects(context, ref, text); if (!(leaf.getGrammarElement() instanceof Keyword) && !leaf.isHidden()) { IScope scope = getScope(context, ref); return XtextMetamodelReferenceHelper.findBestMetamodelForType( context, text.getText(), leaf.getText(), scope); } } } return Collections.emptyList(); }
Example 2
Source File: GrammarUtil.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
public static String getTypeRefName(TypeRef typeRef) { if (typeRef.getClassifier() != null) return typeRef.getClassifier().getName(); final ICompositeNode node = NodeModelUtils.getNode(typeRef); if (node != null) { final BidiIterator<INode> leafNodes = node.getAsTreeIterable().iterator(); while (leafNodes.hasPrevious()) { INode previous = leafNodes.previous(); if (previous instanceof ILeafNode && !((ILeafNode) previous).isHidden()) { String result = previous.getText(); if (result != null && result.startsWith("^")) { result = result.substring(1); } return result; } } } return null; }
Example 3
Source File: SleighHighlightingCalculator.java From ghidra with Apache License 2.0 | 5 votes |
INode skipWhiteSpaceBackwards(IHighlightedPositionAcceptor acceptor, BidiIterator<INode> it) { INode n = null; while (it.hasPrevious() && (n = it.previous()).getClass() == HiddenLeafNode.class) processHiddenNode(acceptor, (HiddenLeafNode) n); return n; }
Example 4
Source File: AbstractNode.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public int getLength() { BidiIterator<AbstractNode> iter = basicIterator(); while(iter.hasPrevious()) { INode prev = iter.previous(); if (prev instanceof ILeafNode && !((ILeafNode) prev).isHidden()) { int offset = getOffset(); return prev.getTotalEndOffset() - offset; } } return getTotalLength(); }
Example 5
Source File: AbstractNode.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
/** * @since 2.5 */ @Override public int getEndOffset() { BidiIterator<AbstractNode> iter = basicIterator(); while(iter.hasPrevious()) { INode prev = iter.previous(); if (prev instanceof ILeafNode && !((ILeafNode) prev).isHidden()) { return prev.getTotalEndOffset(); } } return getTotalEndOffset(); }
Example 6
Source File: PartialParsingHelper.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
private void collectNodesEnclosingChangeRegion(ICompositeNode parent, Range range, List<ICompositeNode> nodesEnclosingRegion) { nodesEnclosingRegion.add(parent); BidiIterator<INode> iterator = parent.getChildren().iterator(); while(iterator.hasPrevious()) { INode prev = iterator.previous(); if (prev instanceof ICompositeNode) { if (nodeEnclosesRegion((ICompositeNode) prev, range)) { collectNodesEnclosingChangeRegion((ICompositeNode) prev, range, nodesEnclosingRegion); break; } } } }
Example 7
Source File: FixedPartialParsingHelper.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
private void collectNodesEnclosingChangeRegion(final ICompositeNode parent, final Range range, final List<ICompositeNode> nodesEnclosingRegion) { nodesEnclosingRegion.add(parent); BidiIterator<INode> iterator = parent.getChildren().iterator(); while (iterator.hasPrevious()) { INode prev = iterator.previous(); if (prev instanceof ICompositeNode) { if (nodeEnclosesRegion((ICompositeNode) prev, range)) { collectNodesEnclosingChangeRegion((ICompositeNode) prev, range, nodesEnclosingRegion); break; } } } }