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


Java CrossReference类代码示例

本文整理汇总了Java中org.eclipse.xtext.CrossReference的典型用法代码示例。如果您正苦于以下问题:Java CrossReference类的具体用法?Java CrossReference怎么用?Java CrossReference使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: rewriteIdentifiers

import org.eclipse.xtext.CrossReference; //导入依赖的package包/类
private static void rewriteIdentifiers(N4JSGrammarAccess ga,
		ImmutableMap.Builder<AbstractElement, Integer> builder) {
	ImmutableSet<AbstractRule> identifierRules = ImmutableSet.of(
			ga.getBindingIdentifierRule(),
			ga.getIdentifierNameRule(),
			ga.getIDENTIFIERRule());
	for (ParserRule rule : GrammarUtil.allParserRules(ga.getGrammar())) {
		for (EObject obj : EcoreUtil2.eAllContents(rule.getAlternatives())) {
			if (obj instanceof Assignment) {
				Assignment assignment = (Assignment) obj;
				AbstractElement terminal = assignment.getTerminal();
				int type = InternalN4JSParser.RULE_IDENTIFIER;
				if (terminal instanceof CrossReference) {
					terminal = ((CrossReference) terminal).getTerminal();
					type = IDENTIFIER_REF_TOKEN;
				}
				if (terminal instanceof RuleCall) {
					AbstractRule calledRule = ((RuleCall) terminal).getRule();
					if (identifierRules.contains(calledRule)) {
						builder.put(assignment, type);
					}
				}
			}
		}
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:27,代码来源:TokenTypeRewriter.java

示例2: serializeCrossRef

import org.eclipse.xtext.CrossReference; //导入依赖的package包/类
@Override
public String serializeCrossRef(EObject semanticObject, CrossReference crossref, EObject target, INode node,
		Acceptor errors) {
	if (((InternalEObject) target).eProxyURI() != null) {
		if (((InternalEObject) target).eProxyURI().toString().startsWith("#")) {
			return super.serializeCrossRef(semanticObject, crossref, getEObjectfromEProxy(semanticObject, target),
					node, errors);
		}
	}

	return super.serializeCrossRef(semanticObject, crossref, target, node, errors);

}
 
开发者ID:occiware,项目名称:OCCI-Studio,代码行数:14,代码来源:OCCICrossReferenceSerializer.java

示例3: resolveCrossReferencedElement

import org.eclipse.xtext.CrossReference; //导入依赖的package包/类
@Override
protected EObject resolveCrossReferencedElement(INode node) {
	EObject referenceOwner = NodeModelUtils.findActualSemanticObjectFor(node);
	if (referenceOwner != null) {
		EReference crossReference = GrammarUtil.getReference((CrossReference) node.getGrammarElement(),
				referenceOwner.eClass());
		if (!crossReference.isMany()) {
			EObject resultOrProxy = (EObject) referenceOwner.eGet(crossReference);
			if (resultOrProxy != null && resultOrProxy.eIsProxy() && crossReference == XbasePackage.Literals.XCONSTRUCTOR_CALL__CONSTRUCTOR) {
				if (referenceOwner instanceof XConstructorCall) {
					JvmIdentifiableElement linkedType = batchTypeResolver.resolveTypes(referenceOwner).getLinkedFeature((XConstructorCall)referenceOwner);
					if (linkedType != null)
						return linkedType;
				}
			} 
			return resultOrProxy;
		} else {
			return super.resolveCrossReferencedElement(node);
		}
	}
	return null;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:23,代码来源:BrokenConstructorCallAwareEObjectAtOffsetHelper.java

示例4: getLocationWithoutTypeArguments

import org.eclipse.xtext.CrossReference; //导入依赖的package包/类
protected ILocationData getLocationWithoutTypeArguments(XAbstractFeatureCall call) {
	final ICompositeNode startNode = NodeModelUtils.getNode(call);
	if (startNode != null) {
		List<INode> resultNodes = Lists.newArrayList();
		if (call instanceof XFeatureCall || call instanceof XMemberFeatureCall) {
			boolean featureReferenceSeen = false;
			for (INode child : startNode.getChildren()) {
				if (featureReferenceSeen) {
					resultNodes.add(child);
				} else {
					EObject grammarElement = child.getGrammarElement();
					if (grammarElement instanceof CrossReference) {
						Assignment assignment = GrammarUtil.containingAssignment(grammarElement);
						if (assignment != null && "feature".equals(assignment.getFeature())) {
							featureReferenceSeen = true;
							resultNodes.add(child);
						}
					}
				}
			}
		}
		return toLocationData(resultNodes);
	}
	return null;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:26,代码来源:FeatureCallCompiler.java

示例5: createReceiverProposals

import org.eclipse.xtext.CrossReference; //导入依赖的package包/类
protected void createReceiverProposals(final XExpression receiver, final CrossReference crossReference, final ContentAssistContext context, final IIdeContentProposalAcceptor acceptor) {
  final IResolvedTypes resolvedTypes = this.typeResolver.resolveTypes(receiver);
  final LightweightTypeReference receiverType = resolvedTypes.getActualType(receiver);
  if (((receiverType == null) || receiverType.isPrimitiveVoid())) {
    return;
  }
  final IExpressionScope expressionScope = resolvedTypes.getExpressionScope(receiver, IExpressionScope.Anchor.RECEIVER);
  IScope scope = null;
  final EObject currentModel = context.getCurrentModel();
  if ((currentModel != receiver)) {
    if (((currentModel instanceof XMemberFeatureCall) && 
      (((XMemberFeatureCall) currentModel).getMemberCallTarget() == receiver))) {
      scope = this.syntaxFilteredScopes.create(expressionScope.getFeatureScope(((XAbstractFeatureCall) currentModel)), crossReference);
    } else {
      scope = this.syntaxFilteredScopes.create(expressionScope.getFeatureScope(), crossReference);
    }
  } else {
    scope = this.syntaxFilteredScopes.create(expressionScope.getFeatureScope(), crossReference);
  }
  this.getCrossrefProposalProvider().lookupCrossReference(scope, crossReference, context, acceptor, this.featureDescriptionPredicate);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:22,代码来源:XbaseIdeContentProposalProvider.java

示例6: createProposals

import org.eclipse.xtext.CrossReference; //导入依赖的package包/类
public void createProposals(final AbstractElement assignment, final ContentAssistContext context, final IIdeContentProposalAcceptor acceptor) {
  if (assignment instanceof Assignment) {
    _createProposals((Assignment)assignment, context, acceptor);
    return;
  } else if (assignment instanceof CrossReference) {
    _createProposals((CrossReference)assignment, context, acceptor);
    return;
  } else if (assignment instanceof Keyword) {
    _createProposals((Keyword)assignment, context, acceptor);
    return;
  } else if (assignment instanceof RuleCall) {
    _createProposals((RuleCall)assignment, context, acceptor);
    return;
  } else if (assignment != null) {
    _createProposals(assignment, context, acceptor);
    return;
  } else {
    throw new IllegalArgumentException("Unhandled parameter types: " +
      Arrays.<Object>asList(assignment, context, acceptor).toString());
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:22,代码来源:XbaseIdeContentProposalProvider.java

示例7: getParsedStringUnchecked

import org.eclipse.xtext.CrossReference; //导入依赖的package包/类
/**
 * Returns the source text assigned to the given feature of the given object. Does not work for multi-valued features. Optionally also converts the source
 * text using the corresponding value converter. Conversion is only performed for keywords, rule call or cross reference grammar rules.
 * <p>
 * This method does not perform a check to make sure the feature matches the given object.
 *
 * @param object
 *          the semantic object
 * @param feature
 *          the feature to be considered when parsing the parse tree model
 * @param convert
 *          {@code true} if the parsed string needs conversion using its value converter
 * @return the parsed string from the node model
 */
public static String getParsedStringUnchecked(final EObject object, final EStructuralFeature feature, final boolean convert) {
  INode node = Iterables.getFirst(NodeModelUtils.findNodesForFeature(object, feature), null);
  if (node != null) {
    if (convert) {
      final LazyLinkingResource res = (LazyLinkingResource) object.eResource();
      EObject grammarElement = node.getGrammarElement();
      if (res != null && (grammarElement instanceof Keyword || grammarElement instanceof RuleCall || grammarElement instanceof CrossReference)) {
        final DefaultLinkingService linkingService = (DefaultLinkingService) res.getLinkingService();
        return linkingService.getCrossRefNodeAsString(node);
      }
    }
    // result may contain escape sequences or quotes
    return NodeModelUtils.getTokenText(node);
  }
  return null;
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:31,代码来源:ParseTreeUtil.java

示例8: acceptRuleCall

import org.eclipse.xtext.CrossReference; //导入依赖的package包/类
protected void acceptRuleCall(RuleCall rc, Object value, String token, int index, INode node) {
	CrossReference crossRef = GrammarUtil.containingCrossReference(rc);
	if (crossRef != null) {
		if (rc.getRule() instanceof ParserRule)
			sequenceAcceptor.acceptAssignedCrossRefDatatype(rc, token, (EObject) value, index,
					getCompositeNode(node));
		else if (rc.getRule() instanceof TerminalRule)
			sequenceAcceptor.acceptAssignedCrossRefTerminal(rc, token, (EObject) value, index, getLeafNode(node));
		else if (rc.getRule() instanceof EnumRule)
			sequenceAcceptor.acceptAssignedCrossRefEnum(rc, token, (EObject) value, index, getCompositeNode(node));
	} else {
		if (rc.getRule() instanceof ParserRule) {
			AbstractRule rule = rc.getRule();
			if (rule.getType() != null && rule.getType().getClassifier() instanceof EClass)
				acceptEObjectRuleCall(rc, (EObject) value, getCompositeNode(node));
			else
				sequenceAcceptor.acceptAssignedDatatype(rc, token, value, index, getCompositeNode(node));
		} else if (rc.getRule() instanceof TerminalRule)
			sequenceAcceptor.acceptAssignedTerminal(rc, token, value, index, getLeafNode(node));
		else if (rc.getRule() instanceof EnumRule)
			sequenceAcceptor.acceptAssignedEnum(rc, token, value, index, getCompositeNode(node));
	}
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:24,代码来源:SequenceFeeder.java

示例9: lookupCrossReference

import org.eclipse.xtext.CrossReference; //导入依赖的package包/类
public void lookupCrossReference(final IScope scope, final CrossReference crossReference, final ContentAssistContext context, final IIdeContentProposalAcceptor acceptor, final Predicate<IEObjectDescription> filter) {
  try {
    Iterable<IEObjectDescription> _queryScope = this.queryScope(scope, crossReference, context);
    for (final IEObjectDescription candidate : _queryScope) {
      {
        boolean _canAcceptMoreProposals = acceptor.canAcceptMoreProposals();
        boolean _not = (!_canAcceptMoreProposals);
        if (_not) {
          return;
        }
        boolean _apply = filter.apply(candidate);
        if (_apply) {
          final ContentAssistEntry entry = this.createProposal(candidate, crossReference, context);
          acceptor.accept(entry, this.proposalPriorities.getCrossRefPriority(candidate, entry));
        }
      }
    }
  } catch (final Throwable _t) {
    if (_t instanceof UnsupportedOperationException) {
      final UnsupportedOperationException uoe = (UnsupportedOperationException)_t;
      IdeCrossrefProposalProvider.LOG.error("Failed to create content assist proposals for cross-reference.", uoe);
    } else {
      throw Exceptions.sneakyThrow(_t);
    }
  }
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:27,代码来源:IdeCrossrefProposalProvider.java

示例10: createProposals

import org.eclipse.xtext.CrossReference; //导入依赖的package包/类
protected void createProposals(final AbstractElement assignment, final ContentAssistContext context, final IIdeContentProposalAcceptor acceptor) {
  if (assignment instanceof Assignment) {
    _createProposals((Assignment)assignment, context, acceptor);
    return;
  } else if (assignment instanceof CrossReference) {
    _createProposals((CrossReference)assignment, context, acceptor);
    return;
  } else if (assignment instanceof Keyword) {
    _createProposals((Keyword)assignment, context, acceptor);
    return;
  } else if (assignment instanceof RuleCall) {
    _createProposals((RuleCall)assignment, context, acceptor);
    return;
  } else if (assignment != null) {
    _createProposals(assignment, context, acceptor);
    return;
  } else {
    throw new IllegalArgumentException("Unhandled parameter types: " +
      Arrays.<Object>asList(assignment, context, acceptor).toString());
  }
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:22,代码来源:IdeContentProposalProvider.java

示例11: getAbstractElements

import org.eclipse.xtext.CrossReference; //导入依赖的package包/类
protected List<AbstractElement> getAbstractElements(EObject obj) {
	if (obj instanceof AbstractElement)
		return Collections.singletonList((AbstractElement) obj);
	if (obj instanceof AbstractRule) {
		AbstractRule rule = (AbstractRule) obj;
		if (rule.getType().getClassifier() instanceof EClass)
			return Collections.singletonList(rule.getAlternatives());
		List<AbstractElement> result = Lists.newArrayList();
		for (RuleCall rc : grammarAccess.findRuleCalls(rule)) {
			CrossReference cr = GrammarUtil.containingCrossReference(rc);
			result.add(cr == null ? rc : cr);
		}
		return result;
	}
	return null;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:17,代码来源:AbstractFormattingConfig.java

示例12: _crossrefEbnf

import org.eclipse.xtext.CrossReference; //导入依赖的package包/类
protected String _crossrefEbnf(final RuleCall it, final CrossReference ref, final boolean supportActions) {
  String _xblockexpression = null;
  {
    final AbstractRule rule = it.getRule();
    if ((rule instanceof ParserRule)) {
      ParserRule _originalElement = AntlrGrammarGenUtil.<ParserRule>getOriginalElement(((ParserRule)rule));
      boolean _isDatatypeRule = GrammarUtil.isDatatypeRule(((AbstractRule) _originalElement));
      boolean _not = (!_isDatatypeRule);
      if (_not) {
        throw new IllegalStateException("crossrefEbnf is not supported for ParserRule that is not a datatype rule");
      }
    }
    _xblockexpression = this.crossrefEbnf(rule, it, ref, supportActions);
  }
  return _xblockexpression;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:17,代码来源:AbstractAntlrGrammarGenerator.java

示例13: getCrossReferenceNameFromScope

import org.eclipse.xtext.CrossReference; //导入依赖的package包/类
@Override
protected String getCrossReferenceNameFromScope(EObject semanticObject, CrossReference crossref,
		EObject target, IScope scope, Acceptor errors) {
	if (target instanceof AbstractRule) {
		return ((AbstractRule) target).getName();
	}
	if (target instanceof ENamedElement) {
		return ((ENamedElement) target).getName();
	}
	return super.getCrossReferenceNameFromScope(semanticObject, crossref, target, scope, errors);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:12,代码来源:GrammarPrettyPrinter.java

示例14: installProxies

import org.eclipse.xtext.CrossReference; //导入依赖的package包/类
/**
 * Installs proxies for all non containment references and only if the node representing the EObject that contains
 * the cross reference has got leaf nodes (as a leaf node represents the cross reference).
 *
 * @param resource
 *            the N4JSResource
 * @param obj
 *            the EObject containing the cross reference
 * @param producer
 *            the error/warning producer
 * @param parentNode
 *            the node representing obj inside the node model
 */
private void installProxies(N4JSResource resource, EObject obj, IDiagnosticProducer producer,
		ICompositeNode parentNode, boolean dontCheckParent) {
	final EClass eClass = obj.eClass();
	if (eClass.getEAllReferences().size() - eClass.getEAllContainments().size() == 0)
		return;

	for (INode node = parentNode.getFirstChild(); node != null; node = node.getNextSibling()) {
		EObject grammarElement = node.getGrammarElement();
		if (grammarElement instanceof CrossReference && hasLeafNodes(node)) {
			producer.setNode(node);
			CrossReference crossReference = (CrossReference) grammarElement;
			final EReference eRef = GrammarUtil.getReference(crossReference, eClass);
			if (eRef == null) {
				ParserRule parserRule = GrammarUtil.containingParserRule(crossReference);
				final String feature = GrammarUtil.containingAssignment(crossReference).getFeature();
				throw new IllegalStateException("Couldn't find EReference for crossreference '" + eClass.getName()
						+ "::" + feature + "' in parser rule '" + parserRule.getName() + "'.");
			}
			createAndSetProxy(resource, obj, node, eRef, crossReference, producer);
			afterCreateAndSetProxy(obj, node, eRef, crossReference, producer);
		} else if (grammarElement instanceof RuleCall && node instanceof ICompositeNode) {
			RuleCall ruleCall = (RuleCall) grammarElement;
			AbstractRule calledRule = ruleCall.getRule();
			if (calledRule instanceof ParserRule && ((ParserRule) calledRule).isFragment()) {
				installProxies(resource, obj, producer, (ICompositeNode) node, true);
			}
		}
	}
	if (!dontCheckParent && shouldCheckParentNode(parentNode)) {
		installProxies(resource, obj, producer, parentNode.getParent(), dontCheckParent);
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:46,代码来源:N4JSLinker.java

示例15: createAndSetProxy

import org.eclipse.xtext.CrossReference; //导入依赖的package包/类
/**
 * Creates a proxy instance that will later on allow to lazily resolve the semantically referenced instance for the
 * given {@link CrossReference xref}.
 */
@SuppressWarnings("unchecked")
private void createAndSetProxy(N4JSResource resource, EObject obj, INode node, EReference eRef,
		CrossReference xref,
		IDiagnosticProducer diagnosticProducer) {
	final EObject proxy = createProxy(resource, obj, node, eRef, xref, diagnosticProducer);
	proxy.eSetDeliver(false);
	if (eRef.isMany()) {
		((InternalEList<EObject>) obj.eGet(eRef, false)).addUnique(proxy);
	} else {
		obj.eSet(eRef, proxy);
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:17,代码来源:N4JSLinker.java


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