本文整理汇总了Java中org.eclipse.xtext.naming.QualifiedName.getSegment方法的典型用法代码示例。如果您正苦于以下问题:Java QualifiedName.getSegment方法的具体用法?Java QualifiedName.getSegment怎么用?Java QualifiedName.getSegment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.xtext.naming.QualifiedName
的用法示例。
在下文中一共展示了QualifiedName.getSegment方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: lookupCrossReference
import org.eclipse.xtext.naming.QualifiedName; //导入方法依赖的package包/类
/**
* Retrieves possible reference targets from scope, including erroneous solutions (e.g., not visible targets). This
* list is further filtered here. This is a general pattern: Do not change or modify scoping for special content
* assist requirements, instead filter here.
*
* @param proposalFactory
* usually this will be an instance of
* {@link AbstractJavaBasedContentProposalProvider.DefaultProposalCreator DefaultProposalCreator}.
* @param filter
* by default an instance of {@link N4JSCandidateFilter} will be provided here.
*/
@SuppressWarnings("javadoc")
public void lookupCrossReference(
EObject model,
EReference reference,
ContentAssistContext context,
ICompletionProposalAcceptor acceptor,
Predicate<IEObjectDescription> filter,
Function<IEObjectDescription, ICompletionProposal> proposalFactory) {
if (model != null) {
final IScope scope = ((IContentAssistScopeProvider) scopeProvider).getScopeForContentAssist(model,
reference);
// iterate over candidates, filter them, and create ICompletionProposals for them
final Iterable<IEObjectDescription> candidates = scope.getAllElements();
// don't use candidates.forEach since we want an early exit
for (IEObjectDescription candidate : candidates) {
if (!acceptor.canAcceptMoreProposals())
return;
if (filter.apply(candidate)) {
QualifiedName qfn = candidate.getQualifiedName();
String tmodule = null;
if (qfn.getSegmentCount() >= 2) {
tmodule = qfn.getSegment(qfn.getSegmentCount() - 2);
}
// In case of main module, adjust the qualified name, e.g. index.Element -> react.Element
IN4JSProject project = n4jsCore.findProject(candidate.getEObjectURI()).orNull();
QualifiedName candidateName;
if (project != null && tmodule != null && tmodule.equals(project.getMainModule())) {
candidateName = QualifiedName.create(project.getProjectId(),
candidate.getQualifiedName().getLastSegment().toString());
} else {
candidateName = candidate.getQualifiedName();
}
final ICompletionProposal proposal = getProposal(candidate,
model,
scope,
reference,
context,
filter,
proposalFactory);
if (proposal instanceof ConfigurableCompletionProposal
&& candidate.getName().getSegmentCount() > 1) {
ConfigurableCompletionProposal castedProposal = (ConfigurableCompletionProposal) proposal;
castedProposal.setAdditionalData(FQNImporter.KEY_QUALIFIED_NAME,
candidateName);
// Original qualified name is the qualified name before adjustment
castedProposal.setAdditionalData(FQNImporter.KEY_ORIGINAL_QUALIFIED_NAME,
candidate.getQualifiedName());
}
acceptor.accept(proposal);
}
}
}
}