本文整理汇总了Java中org.eclipse.xtext.nodemodel.ILeafNode.isHidden方法的典型用法代码示例。如果您正苦于以下问题:Java ILeafNode.isHidden方法的具体用法?Java ILeafNode.isHidden怎么用?Java ILeafNode.isHidden使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.xtext.nodemodel.ILeafNode
的用法示例。
在下文中一共展示了ILeafNode.isHidden方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: highlightNode
import org.eclipse.xtext.nodemodel.ILeafNode; //导入方法依赖的package包/类
/**
* Highlights the non-hidden parts of {@code node} with the styles given by the {@code styleIds}
*/
protected void highlightNode(IHighlightedPositionAcceptor acceptor, INode node, String... styleIds) {
if (node == null)
return;
if (node instanceof ILeafNode) {
ITextRegion textRegion = node.getTextRegion();
acceptor.addPosition(textRegion.getOffset(), textRegion.getLength(), styleIds);
} else {
for (ILeafNode leaf : node.getLeafNodes()) {
if (!leaf.isHidden()) {
ITextRegion leafRegion = leaf.getTextRegion();
acceptor.addPosition(leafRegion.getOffset(), leafRegion.getLength(), styleIds);
}
}
}
}
示例2: getLegacyImportSyntax
import org.eclipse.xtext.nodemodel.ILeafNode; //导入方法依赖的package包/类
@Override
public String getLegacyImportSyntax(XImportDeclaration importDeclaration) {
List<INode> list = NodeModelUtils.findNodesForFeature(importDeclaration, XtypePackage.Literals.XIMPORT_DECLARATION__IMPORTED_TYPE);
if (list.isEmpty()) {
return null;
}
INode singleNode = list.get(0);
if (singleNode.getText().indexOf('$') < 0) {
return null;
}
StringBuilder sb = new StringBuilder();
for(ILeafNode node: singleNode.getLeafNodes()) {
if (!node.isHidden()) {
sb.append(node.getText().replace("^", ""));
}
}
return sb.toString();
}
示例3: getDocumentationNodes
import org.eclipse.xtext.nodemodel.ILeafNode; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public List<INode> getDocumentationNodes(final EObject object) {
ICompositeNode node = NodeModelUtils.getNode(object);
if (node == null) {
return ImmutableList.of();
}
// get all single line comments before a non hidden leaf node
List<INode> result = Lists.newArrayList();
for (ILeafNode leaf : node.getLeafNodes()) {
if (!leaf.isHidden()) {
break;
}
EObject grammarElement = leaf.getGrammarElement();
if (grammarElement instanceof AbstractRule && ruleName.equals(((AbstractRule) grammarElement).getName())) {
String comment = leaf.getText();
if (getCommentPattern().matcher(comment).matches() && !comment.matches(ignore)) {
result.add(leaf);
}
}
}
return result;
}
示例4: getTokenText
import org.eclipse.xtext.nodemodel.ILeafNode; //导入方法依赖的package包/类
/**
* This method converts a node to text.
*
* Leading and trailing text from hidden tokens (whitespace/comments) is removed. Text from hidden tokens that is
* surrounded by text from non-hidden tokens is summarized to a single whitespace.
*
* The preferred use case of this method is to convert the {@link ICompositeNode} that has been created for a data
* type rule to text.
*
* This is also the recommended way to convert a node to text if you want to invoke
* {@link org.eclipse.xtext.conversion.IValueConverterService#toValue(String, String, INode)}
*
*/
public static String getTokenText(INode node) {
if (node instanceof ILeafNode)
return ((ILeafNode) node).getText();
else {
StringBuilder builder = new StringBuilder(Math.max(node.getTotalLength(), 1));
boolean hiddenSeen = false;
for (ILeafNode leaf : node.getLeafNodes()) {
if (!leaf.isHidden()) {
if (hiddenSeen && builder.length() > 0)
builder.append(' ');
builder.append(leaf.getText());
hiddenSeen = false;
} else {
hiddenSeen = true;
}
}
return builder.toString();
}
}
示例5: getOffset
import org.eclipse.xtext.nodemodel.ILeafNode; //导入方法依赖的package包/类
@Override
public int getOffset() {
Iterator<ILeafNode> leafIter = Iterators.filter(basicIterator(), ILeafNode.class);
int firstLeafOffset = -1;
while(leafIter.hasNext()) {
ILeafNode leaf = leafIter.next();
if (firstLeafOffset == -1) {
firstLeafOffset = leaf.getTotalOffset();
}
if (!leaf.isHidden())
return leaf.getTotalOffset();
}
if (firstLeafOffset != -1)
return firstLeafOffset;
return getTotalOffset();
}
示例6: getLinkedMetaModel
import org.eclipse.xtext.nodemodel.ILeafNode; //导入方法依赖的package包/类
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();
}
示例7: highlightSpecialIdentifiers
import org.eclipse.xtext.nodemodel.ILeafNode; //导入方法依赖的package包/类
@Override
protected void highlightSpecialIdentifiers(final IHighlightedPositionAcceptor acceptor, final ICompositeNode root) {
TerminalRule idRule = grammarAccess.getIDRule();
for (ILeafNode leaf : root.getLeafNodes()) {
if (commentProvider.isJavaDocComment(leaf)) {
// not really a special identifier, but we don't want to iterate over the leaf nodes twice, do we?
acceptor.addPosition(leaf.getOffset(), leaf.getLength(), CheckHighlightingConfiguration.JAVADOC_ID);
} else if (!leaf.isHidden()) {
if (leaf.getGrammarElement() instanceof Keyword) {
// Check if it is a keyword used as an identifier.
ParserRule rule = GrammarUtil.containingParserRule(leaf.getGrammarElement());
if (FEATURE_CALL_ID_RULE_NAME.equals(rule.getName())) {
acceptor.addPosition(leaf.getOffset(), leaf.getLength(), DefaultHighlightingConfiguration.DEFAULT_ID);
}
} else {
highlightSpecialIdentifiers(leaf, acceptor, idRule);
}
}
}
}
示例8: acceptNode
import org.eclipse.xtext.nodemodel.ILeafNode; //导入方法依赖的package包/类
protected void acceptNode(INode node) {
Object ge = node.getGrammarElement();
if (ge instanceof Keyword)
acceptUnassignedKeyword((Keyword) ge, node.getText(), (ILeafNode) node);
else if (ge instanceof RuleCall) {
RuleCall rc = (RuleCall) ge;
if (rc.getRule() instanceof TerminalRule)
acceptUnassignedTerminal(rc, node.getText(), (ILeafNode) node);
else if (rc.getRule() instanceof ParserRule) {
StringBuilder text = new StringBuilder();
for (ILeafNode leaf : node.getLeafNodes())
if (text.length() > 0 || !leaf.isHidden())
text.append(leaf.getText());
acceptUnassignedDatatype(rc, text.toString(), (ICompositeNode) node);
} else if (rc.getRule() instanceof EnumRule)
acceptUnassignedEnum(rc, node.getText(), (ICompositeNode) node);
} else if (ge instanceof Action)
acceptUnassignedAction((Action) ge);
else
throw new RuntimeException("Unexpected grammar element: " + node.getGrammarElement());
}
示例9: getNodeForModifier
import org.eclipse.xtext.nodemodel.ILeafNode; //导入方法依赖的package包/类
/**
* Returns the INode for a given modifier. This is intended for computing error message regions, quick fixes, etc.
*/
public static final ILeafNode getNodeForModifier(ModifiableElement elem, int index) {
final List<INode> nodes = NodeModelUtils.findNodesForFeature(elem,
N4JSPackage.eINSTANCE.getModifiableElement_DeclaredModifiers());
if (index >= 0 && index < nodes.size()) {
final Iterable<ILeafNode> leafNodes = nodes.get(index).getLeafNodes();
for (ILeafNode currLeaf : leafNodes) {
if (!currLeaf.isHidden())
return currLeaf;
}
}
return null;
}
示例10: nextToken
import org.eclipse.xtext.nodemodel.ILeafNode; //导入方法依赖的package包/类
/**
* Implementation of the {@link TokenSource} interface. Return new tokens as long as there are some, afterwards
* return {@link Token#EOF_TOKEN}.
*/
@Override
public Token nextToken() {
if (next != null) {
Token result = next;
next = null;
return result;
}
if (!leafNodes.hasNext()) {
return Token.EOF_TOKEN;
}
ILeafNode leaf = leafNodes.next();
if (leaf.getTotalOffset() >= endOffset) {
leafNodes = Iterators.emptyIterator();
return Token.EOF_TOKEN;
}
if (leaf.getTotalEndOffset() <= startOffset) {
return nextToken();
}
if (leaf.getTotalEndOffset() > endOffset) {
return toPrefixToken(leaf);
}
SyntaxErrorMessage syntaxErrorMessage = leaf.getSyntaxErrorMessage();
if (syntaxErrorMessage != null && SEMICOLON_INSERTED.equals(syntaxErrorMessage.getIssueCode())) {
return toASIToken(leaf);
}
if (leaf.isHidden()) {
return processHiddenToken(leaf);
}
int tokenType = tokenTypeMapper.getInternalTokenType(leaf);
return new CommonToken(tokenType, leaf.getText());
}
示例11: getDocumentation
import org.eclipse.xtext.nodemodel.ILeafNode; //导入方法依赖的package包/类
private String getDocumentation(/* @NonNull */EObject object) {
if (object.eContainer() == null) {
// if a comment is at the beginning of the file it will be returned for
// the root element (e.g. Script in N4JS) as well -> avoid this!
return null;
}
ICompositeNode node = NodeModelUtils.getNode(object);
if (node != null) {
// get the last multi line comment before a non hidden leaf node
for (ILeafNode leafNode : node.getLeafNodes()) {
if (!leafNode.isHidden())
break;
EObject grammarElem = leafNode.getGrammarElement();
if (grammarElem instanceof TerminalRule
&& "ML_COMMENT".equalsIgnoreCase(((TerminalRule) grammarElem).getName())) {
String comment = leafNode.getText();
if (commentStartTagRegex.matcher(comment).matches()) {
return leafNode.getText();
}
}
}
}
return null;
}
示例12: getNode
import org.eclipse.xtext.nodemodel.ILeafNode; //导入方法依赖的package包/类
@Override
protected INode getNode() {
INode result = super.getNode();
for(ILeafNode leaf: result.getLeafNodes()) {
if (!leaf.isHidden()) {
return leaf;
}
}
return result;
}
示例13: toValue
import org.eclipse.xtext.nodemodel.ILeafNode; //导入方法依赖的package包/类
@Override
public String toValue(String string, INode node) throws ValueConverterException {
StringBuilder buffer = new StringBuilder();
boolean isFirst = true;
if (node != null) {
for(INode child: node.getAsTreeIterable()) {
EObject grammarElement = child.getGrammarElement();
if (isDelegateRuleCall(grammarElement) || isWildcardLiteral(grammarElement)) {
if (!isFirst)
buffer.append(getValueNamespaceDelimiter());
isFirst = false;
if (isDelegateRuleCall(grammarElement))
for(ILeafNode leafNode :child.getLeafNodes()){
if(!leafNode.isHidden())
buffer.append(delegateToValue(leafNode));
}
else
buffer.append(getWildcardLiteral());
}
}
} else {
for (String segment : Strings.split(string, getStringNamespaceDelimiter())) {
if (!isFirst)
buffer.append(getValueNamespaceDelimiter());
isFirst = false;
if(getWildcardLiteral().equals(segment)) {
buffer.append(getWildcardLiteral());
} else {
buffer.append((String) valueConverterService.toValue(segment, getDelegateRuleName(), null));
}
}
}
return buffer.toString();
}
示例14: getTypeNameSegmentsFromConcreteSyntax
import org.eclipse.xtext.nodemodel.ILeafNode; //导入方法依赖的package包/类
protected List<String> getTypeNameSegmentsFromConcreteSyntax(List<INode> nodes, boolean staticNotation) {
List<String> result = null;
for(INode node: nodes) {
for(ILeafNode leaf: node.getLeafNodes()) {
if (!leaf.isHidden()) {
String text = leaf.getText();
// XParenthesizedExpression
if (text.equals("(") || text.equals(")")) {
return null;
}
if (text.equals(".")) {
if (staticNotation) {
return null;
}
}
if (text.equals("::")) {
if (!staticNotation) {
return null;
}
}
if (!text.equals(".") && !text.equals("::")) {
if (result == null) {
result = Lists.newArrayListWithCapacity(4);
}
if (text.charAt(0) == '^') {
result.add(text.substring(1));
} else {
result.add(text);
}
}
}
}
}
return result;
}
示例15: getHiddenLeafsBefore
import org.eclipse.xtext.nodemodel.ILeafNode; //导入方法依赖的package包/类
public HiddenLeafs getHiddenLeafsBefore(final INode node) {
HiddenLeafs _xblockexpression = null;
{
final Function1<ILeafNode, Boolean> _function = (ILeafNode it) -> {
boolean _isHidden = it.isHidden();
return Boolean.valueOf((!_isHidden));
};
final ILeafNode start = this._nodeModelAccess.findNextLeaf(node, _function);
final List<ILeafNode> nodes = this.findPreviousHiddenLeafs(start);
HiddenLeafs _xifexpression = null;
if ((start != null)) {
int _xifexpression_1 = (int) 0;
boolean _isEmpty = nodes.isEmpty();
if (_isEmpty) {
_xifexpression_1 = start.getOffset();
} else {
_xifexpression_1 = IterableExtensions.<ILeafNode>head(nodes).getOffset();
}
_xifexpression = this.newHiddenLeafs(_xifexpression_1, nodes);
} else {
int _offset = 0;
if (node!=null) {
_offset=node.getOffset();
}
_xifexpression = new HiddenLeafs(_offset);
}
_xblockexpression = _xifexpression;
}
return _xblockexpression;
}